From ec1a7f88302c60340be0c0b9c6440603f36d0161 Mon Sep 17 00:00:00 2001 From: Raymond Yang Date: Mon, 10 Apr 2023 11:51:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E7=94=A8AnalogClock=E5=8F=96=E4=BB=A3?= =?UTF-8?q?CustomView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ray650128/iosclockwidget/IOSClockView.kt | 2 + .../iosclockwidget/IOSClockWidget.kt | 2 +- app/src/main/res/drawable/bg_clock_dial.xml | 30 ++++++++ app/src/main/res/drawable/img_clock_dash.xml | 68 +++++++++++++++++++ app/src/main/res/drawable/img_hour_hand.xml | 41 +++++++++++ app/src/main/res/drawable/img_minute_hand.xml | 41 +++++++++++ .../main/res/layout/i_o_s_clock_widget.xml | 16 +++-- .../res/layout/i_o_s_clock_widget_old.xml | 22 ++++++ 8 files changed, 215 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/drawable/bg_clock_dial.xml create mode 100644 app/src/main/res/drawable/img_clock_dash.xml create mode 100644 app/src/main/res/drawable/img_hour_hand.xml create mode 100644 app/src/main/res/drawable/img_minute_hand.xml create mode 100644 app/src/main/res/layout/i_o_s_clock_widget_old.xml diff --git a/app/src/main/java/com/ray650128/iosclockwidget/IOSClockView.kt b/app/src/main/java/com/ray650128/iosclockwidget/IOSClockView.kt index d1b3095..650310a 100644 --- a/app/src/main/java/com/ray650128/iosclockwidget/IOSClockView.kt +++ b/app/src/main/java/com/ray650128/iosclockwidget/IOSClockView.kt @@ -4,10 +4,12 @@ import android.content.Context import android.graphics.* import android.util.AttributeSet import android.view.View +import android.widget.RemoteViews.RemoteView import java.util.* import kotlin.math.cos import kotlin.math.sin +@RemoteView class IOSClockView: View { constructor(context: Context) : super(context, null) { diff --git a/app/src/main/java/com/ray650128/iosclockwidget/IOSClockWidget.kt b/app/src/main/java/com/ray650128/iosclockwidget/IOSClockWidget.kt index b6c3400..0345da7 100644 --- a/app/src/main/java/com/ray650128/iosclockwidget/IOSClockWidget.kt +++ b/app/src/main/java/com/ray650128/iosclockwidget/IOSClockWidget.kt @@ -37,7 +37,7 @@ internal fun updateAppWidget( val widgetText = context.getString(R.string.appwidget_text) // Construct the RemoteViews object val views = RemoteViews(context.packageName, R.layout.i_o_s_clock_widget) - //views.setTextViewText(R.id.appwidget_text, widgetText) + views.setTextViewText(R.id.appwidget_text, widgetText) // Instruct the widget manager to update the widget appWidgetManager.updateAppWidget(appWidgetId, views) diff --git a/app/src/main/res/drawable/bg_clock_dial.xml b/app/src/main/res/drawable/bg_clock_dial.xml new file mode 100644 index 0000000..5a340f7 --- /dev/null +++ b/app/src/main/res/drawable/bg_clock_dial.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/img_clock_dash.xml b/app/src/main/res/drawable/img_clock_dash.xml new file mode 100644 index 0000000..c3a88e6 --- /dev/null +++ b/app/src/main/res/drawable/img_clock_dash.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/img_hour_hand.xml b/app/src/main/res/drawable/img_hour_hand.xml new file mode 100644 index 0000000..c5f59aa --- /dev/null +++ b/app/src/main/res/drawable/img_hour_hand.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/img_minute_hand.xml b/app/src/main/res/drawable/img_minute_hand.xml new file mode 100644 index 0000000..0cb609a --- /dev/null +++ b/app/src/main/res/drawable/img_minute_hand.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/i_o_s_clock_widget.xml b/app/src/main/res/layout/i_o_s_clock_widget.xml index b15145b..0a3f71f 100644 --- a/app/src/main/res/layout/i_o_s_clock_widget.xml +++ b/app/src/main/res/layout/i_o_s_clock_widget.xml @@ -5,18 +5,22 @@ android:background="@android:color/transparent" android:theme="@style/Theme.IOSClockWidget.AppWidgetContainer"> - + android:layout_above="@+id/appwidget_text" + android:layout_alignParentTop="true" + android:layout_centerHorizontal="true" + android:dial="@drawable/bg_clock_dial" + android:hand_hour="@drawable/img_hour_hand" + android:hand_minute="@drawable/img_minute_hand" /> + android:layout_marginBottom="5dp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/i_o_s_clock_widget_old.xml b/app/src/main/res/layout/i_o_s_clock_widget_old.xml new file mode 100644 index 0000000..3e1f7be --- /dev/null +++ b/app/src/main/res/layout/i_o_s_clock_widget_old.xml @@ -0,0 +1,22 @@ + + + + + + \ No newline at end of file