改用AnalogClock取代CustomView
This commit is contained in:
parent
523bac7f8a
commit
ec1a7f8830
@ -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) {
|
||||
|
||||
@ -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)
|
||||
|
||||
30
app/src/main/res/drawable/bg_clock_dial.xml
Normal file
30
app/src/main/res/drawable/bg_clock_dial.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:width="350dp"
|
||||
android:height="350dp">
|
||||
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#101010" />
|
||||
<corners android:radius="30dp" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:bottom="20dp"
|
||||
android:left="20dp"
|
||||
android:right="20dp"
|
||||
android:top="20dp">
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="#FFFFFF" />
|
||||
<padding
|
||||
android:bottom="25dp"
|
||||
android:left="25dp"
|
||||
android:right="25dp"
|
||||
android:top="25dp" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item android:drawable="@drawable/img_clock_dash" />
|
||||
|
||||
</layer-list>
|
||||
68
app/src/main/res/drawable/img_clock_dash.xml
Normal file
68
app/src/main/res/drawable/img_clock_dash.xml
Normal file
@ -0,0 +1,68 @@
|
||||
<vector android:height="250dp" android:viewportHeight="200"
|
||||
android:viewportWidth="200" android:width="250dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M98.16,3.57l2.91,0l0,7.93l-2.91,0z"/>
|
||||
<path android:fillColor="#FF000000" android:pathData="M98.16,188.5l2.91,0l0,7.92l-2.91,0z"/>
|
||||
<path android:fillColor="#FF000000" android:pathData="M3.08,98.8l7.93,0l0,2.91l-7.93,0z"/>
|
||||
<path android:fillColor="#FF000000" android:pathData="M188.01,98.8l7.93,0l0,2.91l-7.93,0z"/>
|
||||
<path android:fillColor="#FF000000" android:pathData="M50.69,17.15l2.52,-1.45l3.96,6.87l-2.52,1.45z"/>
|
||||
<path android:fillColor="#FF000000" android:pathData="M143.15,177.29l2.52,-1.45l3.96,6.86l-2.52,1.45z"/>
|
||||
<path android:fillColor="#FF000000" android:pathData="M15.96,147.16l6.87,-3.97l1.45,2.52l-6.87,3.97z"/>
|
||||
<path android:fillColor="#FF000000" android:pathData="M176.11,54.7l6.87,-3.97l1.45,2.52l-6.87,3.97z"/>
|
||||
<path android:fillColor="#FF000000" android:pathData="M175.5,145.38l1.45,-2.51l6.84,3.95l-1.45,2.51z"/>
|
||||
<path android:fillColor="#FF000000" android:pathData="M15.37,52.92l1.45,-2.51l6.84,3.95l-1.45,2.51z"/>
|
||||
<path android:fillColor="#FF000000" android:pathData="M175.5,145.38l1.45,-2.51l6.84,3.95l-1.45,2.51z"/>
|
||||
<path android:fillColor="#FF000000" android:pathData="M50.26,182.88l3.95,-6.84l2.51,1.45l-3.95,6.84z"/>
|
||||
<path android:fillColor="#FF000000" android:pathData="M142.72,22.75l3.95,-6.84l2.51,1.45l-3.95,6.84z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M88.09,4.27l2.88,-0.3l0.83,7.86l-2.88,0.3z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M107.39,188.17l2.88,-0.3l0.83,7.86l-2.88,0.3z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M3.47,108.92l7.86,-0.83l0.3,2.88l-7.86,0.83z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M187.36,89.53l7.86,-0.83l0.3,2.88l-7.86,0.83z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M42.25,22.72l2.35,-1.7l4.64,6.39l-2.35,1.7z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M150.95,172.32l2.35,-1.7l4.64,6.39l-2.35,1.7z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M21.29,155.63l6.39,-4.64l1.7,2.35l-6.39,4.64z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M170.88,46.93l6.39,-4.64l1.7,2.35l-6.39,4.64z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M179.75,137.23l1.18,-2.65l7.22,3.21l-1.18,2.65z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M10.85,62.01l1.18,-2.65l7.22,3.21l-1.18,2.65z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M179.75,137.23l1.18,-2.65l7.22,3.21l-1.18,2.65z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M59.17,187.53l3.21,-7.22l2.65,1.18l-3.21,7.22z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M134.39,18.64l3.21,-7.22l2.65,1.18l-3.21,7.22z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M78.11,5.98l2.84,-0.6l1.64,7.73l-2.84,0.6z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M116.51,186.89l2.84,-0.6l1.64,7.73l-2.84,0.6z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M4.87,118.85l7.73,-1.64l0.6,2.84l-7.73,1.64z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M185.77,80.45l7.73,-1.64l0.6,2.84l-7.73,1.64z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M34.49,29.07l2.15,-1.94l5.29,5.87l-2.15,1.94z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M158.23,166.58l2.15,-1.94l5.29,5.87l-2.15,1.94z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M27.54,163.52l5.87,-5.29l1.94,2.15l-5.87,5.29z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M164.97,39.83l5.87,-5.29l1.94,2.15l-5.87,5.29z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M183.23,128.57l0.9,-2.76l7.51,2.44l-0.9,2.76z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M7.4,71.5l0.9,-2.76l7.51,2.44l-0.9,2.76z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M183.23,128.57l0.9,-2.76l7.51,2.44l-0.9,2.76z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M68.56,191.3l2.44,-7.51l2.76,0.9l-2.44,7.51z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M125.63,15.47l2.44,-7.51l2.76,0.9l-2.44,7.51z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M68.35,8.66l2.76,-0.9l2.44,7.51l-2.76,0.9z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M125.55,184.55l2.76,-0.9l2.44,7.51l-2.76,0.9z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M7.44,128.59l7.51,-2.44l0.9,2.76l-7.51,2.44z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M183.26,71.51l7.51,-2.44l0.9,2.76l-7.51,2.44z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M27.41,36.21l1.94,-2.15l5.87,5.29l-1.94,2.15z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M164.85,160.02l1.94,-2.15l5.87,5.29l-1.94,2.15z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M34.62,170.59l5.29,-5.87l2.15,1.94l-5.29,5.87z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M158.36,33.23l5.29,-5.87l2.15,1.94l-5.29,5.87z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M185.8,119.61l0.6,-2.84l7.73,1.64l-0.6,2.84z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M4.88,81.19l0.6,-2.84l7.73,1.64l-0.6,2.84z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M185.8,119.61l0.6,-2.84l7.73,1.64l-0.6,2.84z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M78.26,194.04l1.64,-7.73l2.84,0.6l-1.64,7.73z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M116.69,13.12l1.64,-7.73l2.84,0.6l-1.64,7.73z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M59.02,12.45l2.65,-1.18l3.21,7.22l-2.65,1.18z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M134.19,181.35l2.65,-1.18l3.21,7.22l-2.65,1.18z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M10.96,138.11l7.22,-3.21l1.18,2.65l-7.22,3.21z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M179.82,62.85l7.22,-3.21l1.18,2.65l-7.22,3.21z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M21.18,44.12l1.7,-2.35l6.39,4.64l-1.7,2.35z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M170.78,152.83l1.7,-2.35l6.39,4.64l-1.7,2.35z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M42.33,177.02l4.64,-6.39l2.35,1.7l-4.64,6.39z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M151.04,27.41l4.64,-6.39l2.35,1.7l-4.64,6.39z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M187.33,110.51l0.3,-2.88l7.86,0.83l-0.3,2.88z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M3.47,91.19l0.3,-2.88l7.86,0.83l-0.3,2.88z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M187.33,110.51l0.3,-2.88l7.86,0.83l-0.3,2.88z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M88.22,195.74l0.83,-7.86l2.88,0.3l-0.83,7.86z"/>
|
||||
<path android:fillColor="#888888" android:pathData="M107.55,11.78l0.83,-7.86l2.88,0.3l-0.83,7.86z"/>
|
||||
</vector>
|
||||
41
app/src/main/res/drawable/img_hour_hand.xml
Normal file
41
app/src/main/res/drawable/img_hour_hand.xml
Normal file
@ -0,0 +1,41 @@
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:width="10dp"
|
||||
android:height="150dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@android:color/transparent" />
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item
|
||||
android:width="5dp"
|
||||
android:height="75dp"
|
||||
android:top="75dp"
|
||||
android:left="2.5dp"
|
||||
android:right="2.5dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/black" />
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item
|
||||
android:width="7.5dp"
|
||||
android:height="50dp"
|
||||
android:top="100dp"
|
||||
android:left="1.25dp"
|
||||
android:right="1.25dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/black" />
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item
|
||||
android:width="10dp"
|
||||
android:height="10dp"
|
||||
android:top="70dp">
|
||||
<shape android:shape="oval">
|
||||
<stroke android:color="@color/black" android:width="2dp" />
|
||||
<solid android:color="@color/white" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
41
app/src/main/res/drawable/img_minute_hand.xml
Normal file
41
app/src/main/res/drawable/img_minute_hand.xml
Normal file
@ -0,0 +1,41 @@
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:width="10dp"
|
||||
android:height="250dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@android:color/transparent" />
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item
|
||||
android:width="5dp"
|
||||
android:height="125dp"
|
||||
android:top="125dp"
|
||||
android:left="2.5dp"
|
||||
android:right="2.5dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/black" />
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item
|
||||
android:width="7.5dp"
|
||||
android:height="100dp"
|
||||
android:top="150dp"
|
||||
android:left="1.25dp"
|
||||
android:right="1.25dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/black" />
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item
|
||||
android:width="10dp"
|
||||
android:height="10dp"
|
||||
android:top="120dp">
|
||||
<shape android:shape="oval">
|
||||
<stroke android:color="@color/black" android:width="2dp" />
|
||||
<solid android:color="@color/white" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
@ -5,18 +5,22 @@
|
||||
android:background="@android:color/transparent"
|
||||
android:theme="@style/Theme.IOSClockWidget.AppWidgetContainer">
|
||||
|
||||
<com.ray650128.iosclockwidget.IOSClockView
|
||||
<AnalogClock
|
||||
android:id="@+id/IOSClockView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@id/textView"
|
||||
android:layout_alignParentTop="true" />
|
||||
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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:id="@+id/appwidget_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="TextView" />
|
||||
android:layout_marginBottom="5dp" />
|
||||
</RelativeLayout>
|
||||
22
app/src/main/res/layout/i_o_s_clock_widget_old.xml
Normal file
22
app/src/main/res/layout/i_o_s_clock_widget_old.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/Widget.IOSClockWidget.AppWidget.Container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/transparent"
|
||||
android:theme="@style/Theme.IOSClockWidget.AppWidgetContainer">
|
||||
|
||||
<com.ray650128.iosclockwidget.IOSClockView
|
||||
android:id="@+id/IOSClockView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@id/appwidget_text"
|
||||
android:layout_alignParentTop="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/appwidget_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="TextView" />
|
||||
</RelativeLayout>
|
||||
Loading…
Reference in New Issue
Block a user