-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
android/app/src/main/java/com/bitmark/autonomy_flutter/FeralfileDaily.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.bitmark.autonomy_flutter | ||
|
||
import android.appwidget.AppWidgetManager | ||
import android.appwidget.AppWidgetProvider | ||
import android.content.Context | ||
|
||
/** | ||
* Implementation of App Widget functionality. | ||
*/ | ||
class FeralfileDaily : AppWidgetProvider() { | ||
override fun onUpdate( | ||
context: Context, | ||
appWidgetManager: AppWidgetManager, | ||
appWidgetIds: IntArray | ||
) { | ||
// There may be multiple widgets active, so update all of them | ||
for (appWidgetId in appWidgetIds) { | ||
updateAppWidget(context, appWidgetManager, appWidgetId) | ||
} | ||
} | ||
|
||
override fun onEnabled(context: Context) { | ||
// Enter relevant functionality for when the first widget is created | ||
// print log | ||
println("FeralfileDaily onEnabled") | ||
} | ||
|
||
override fun onDisabled(context: Context) { | ||
// Enter relevant functionality for when the last widget is disabled | ||
// print log | ||
println("FeralfileDaily onDisabled") | ||
} | ||
} | ||
|
||
internal fun updateAppWidget( | ||
context: Context, | ||
appWidgetManager: AppWidgetManager, | ||
appWidgetId: Int | ||
) { | ||
val widgetText = context.getString(R.string.appwidget_text) | ||
// Construct the RemoteViews object | ||
val views = RemoteViews(context.packageName, R.layout.feralfile_daily) | ||
views.setTextViewText(R.id.appwidget_text, widgetText) | ||
|
||
// Instruct the widget manager to update the widget | ||
appWidgetManager.updateAppWidget(appWidgetId, views) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
style="@style/Widget.Android.AppWidget.Container" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:theme="@style/Theme.Android.AppWidgetContainer"> | ||
|
||
<TextView | ||
android:id="@+id/appwidget_text" | ||
style="@style/Widget.Android.AppWidget.InnerView" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_centerInParent="true" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="8dp" | ||
android:layout_marginEnd="8dp" | ||
android:layout_marginBottom="8dp" | ||
android:contentDescription="@string/appwidget_text" | ||
android:text="@string/appwidget_text" | ||
android:textSize="24sp" | ||
android:textStyle="bold|italic" /> | ||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:description="@string/app_widget_description" | ||
android:initialKeyguardLayout="@layout/feralfile_daily" | ||
android:initialLayout="@layout/feralfile_daily" | ||
android:minWidth="40dp" | ||
android:minHeight="40dp" | ||
android:previewImage="@drawable/example_appwidget_preview" | ||
android:previewLayout="@layout/feralfile_daily" | ||
android:resizeMode="horizontal|vertical" | ||
android:targetCellWidth="1" | ||
android:targetCellHeight="1" | ||
android:updatePeriodMillis="86400000" | ||
android:widgetCategory="home_screen" /> |