rename some widget related files

This commit is contained in:
tibbi 2016-11-27 18:50:47 +01:00
parent 072a976584
commit a5a30582b9
6 changed files with 29 additions and 12 deletions

View File

@ -22,7 +22,7 @@
</activity> </activity>
<activity <activity
android:name=".activities.WidgetConfigureActivity" android:name=".activities.WidgetMonthlyConfigureActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/MyWidgetConfigTheme"> android:theme="@style/MyWidgetConfigTheme">
<intent-filter> <intent-filter>
@ -56,7 +56,7 @@
android:parentActivityName=".activities.MainActivity"/> android:parentActivityName=".activities.MainActivity"/>
<receiver <receiver
android:name=".helpers.MyWidgetProvider" android:name=".helpers.MyWidgetMonthlyProvider"
android:icon="@mipmap/widget_preview"> android:icon="@mipmap/widget_preview">
<intent-filter> <intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/> <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
@ -64,7 +64,7 @@
<meta-data <meta-data
android:name="android.appwidget.provider" android:name="android.appwidget.provider"
android:resource="@xml/widget_info"/> android:resource="@xml/widget_monthly_info"/>
</receiver> </receiver>
<receiver android:name=".receivers.NotificationReceiver"/> <receiver android:name=".receivers.NotificationReceiver"/>

View File

@ -24,7 +24,7 @@ import kotlinx.android.synthetic.main.widget_config.*
import org.joda.time.DateTime import org.joda.time.DateTime
import yuku.ambilwarna.AmbilWarnaDialog import yuku.ambilwarna.AmbilWarnaDialog
class WidgetConfigureActivity : AppCompatActivity(), MonthlyCalendar { class WidgetMonthlyConfigureActivity : AppCompatActivity(), MonthlyCalendar {
lateinit var mRes: Resources lateinit var mRes: Resources
private var mDays: List<Day>? = null private var mDays: List<Day>? = null
private var mPackageName = "" private var mPackageName = ""
@ -135,7 +135,7 @@ class WidgetConfigureActivity : AppCompatActivity(), MonthlyCalendar {
} }
private fun requestWidgetUpdate() { private fun requestWidgetUpdate() {
Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE, null, this, MyWidgetProvider::class.java).apply { Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE, null, this, MyWidgetMonthlyProvider::class.java).apply {
putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, intArrayOf(mWidgetId)) putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, intArrayOf(mWidgetId))
sendBroadcast(this) sendBroadcast(this)
} }

View File

@ -13,12 +13,12 @@ import com.simplemobiletools.calendar.models.Event
import com.simplemobiletools.calendar.receivers.NotificationReceiver import com.simplemobiletools.calendar.receivers.NotificationReceiver
fun Context.updateWidget() { fun Context.updateWidget() {
val widgetsCnt = AppWidgetManager.getInstance(this).getAppWidgetIds(ComponentName(this, MyWidgetProvider::class.java)) val widgetsCnt = AppWidgetManager.getInstance(this).getAppWidgetIds(ComponentName(this, MyWidgetMonthlyProvider::class.java))
if (widgetsCnt.isEmpty()) if (widgetsCnt.isEmpty())
return return
val ids = intArrayOf(R.xml.widget_info) val ids = intArrayOf(R.xml.widget_monthly_info)
Intent(this, MyWidgetProvider::class.java).apply { Intent(this, MyWidgetMonthlyProvider::class.java).apply {
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids) putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
sendBroadcast(this) sendBroadcast(this)

View File

@ -21,7 +21,7 @@ import com.simplemobiletools.calendar.interfaces.MonthlyCalendar
import com.simplemobiletools.calendar.models.Day import com.simplemobiletools.calendar.models.Day
import org.joda.time.DateTime import org.joda.time.DateTime
class MyWidgetProvider : AppWidgetProvider(), MonthlyCalendar { class MyWidgetMonthlyProvider : AppWidgetProvider(), MonthlyCalendar {
companion object { companion object {
private val PREV = "prev" private val PREV = "prev"
private val NEXT = "next" private val NEXT = "next"
@ -60,7 +60,7 @@ class MyWidgetProvider : AppWidgetProvider(), MonthlyCalendar {
mWidgetManager = AppWidgetManager.getInstance(mContext) mWidgetManager = AppWidgetManager.getInstance(mContext)
mRemoteViews = RemoteViews(mContext.packageName, R.layout.fragment_month) mRemoteViews = RemoteViews(mContext.packageName, R.layout.fragment_month)
mIntent = Intent(mContext, MyWidgetProvider::class.java) mIntent = Intent(mContext, MyWidgetMonthlyProvider::class.java)
setupButtons() setupButtons()
updateLabelColor() updateLabelColor()
updateTopViews() updateTopViews()
@ -72,7 +72,7 @@ class MyWidgetProvider : AppWidgetProvider(), MonthlyCalendar {
} }
private fun updateWidget() { private fun updateWidget() {
val thisWidget = ComponentName(mContext, MyWidgetProvider::class.java) val thisWidget = ComponentName(mContext, MyWidgetMonthlyProvider::class.java)
AppWidgetManager.getInstance(mContext).updateAppWidget(thisWidget, mRemoteViews) AppWidgetManager.getInstance(mContext).updateAppWidget(thisWidget, mRemoteViews)
} }

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/calendar_events_list_holder"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/calendar_events_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingLeft="@dimen/activity_margin"
android:paddingTop="@dimen/medium_padding"
android:visibility="gone"/>
</RelativeLayout>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:configure="com.simplemobiletools.calendar.activities.WidgetConfigureActivity" android:configure="com.simplemobiletools.calendar.activities.WidgetMonthlyConfigureActivity"
android:initialLayout="@layout/fragment_month" android:initialLayout="@layout/fragment_month"
android:minHeight="@dimen/min_widget_height" android:minHeight="@dimen/min_widget_height"
android:minWidth="@dimen/min_widget_width" android:minWidth="@dimen/min_widget_width"