Skip to content

Commit

Permalink
Use seperate layout for checklist widget
Browse files Browse the repository at this point in the history
Signed-off-by: sunilpaulmathew <sunil.kde@gmail.com>
  • Loading branch information
sunilpaulmathew committed May 1, 2023
1 parent 3d02457 commit 8ac31e2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Expand Up @@ -81,7 +81,7 @@

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.sunilpaulmathew.snotz.provider"
android:authorities="${applicationId}.provider"
android:grantUriPermissions="true"
android:exported="false" >
<meta-data
Expand Down
Expand Up @@ -49,14 +49,14 @@ public void onDeleted(Context context, int[] appWidgetIds) {
}

public static void update(AppWidgetManager appWidgetManager, int appWidgetId, Context context) {
RemoteViews mViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
RemoteViews mViews;
Intent mIntent = new Intent(context, StartActivity.class);
PendingIntent mPendingIntent;

if (sNotzWidgets.getChecklistPath(appWidgetId, context) != null) {
if (sFileUtils.exist(new File(sNotzWidgets.getChecklistPath(appWidgetId, context)))) {
mViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout_checklists);
mViews.setTextViewText(R.id.note, sNotzWidgets.getWidgetText(sNotzWidgets.getChecklistPath(appWidgetId, context)));
mViews.setInt(R.id.layout, "setBackgroundColor", sCommonUtils.getColor(android.R.color.transparent, context));
mViews.setTextColor(R.id.note, sCommonUtils.getInt("checklist_color", sCommonUtils.getColor(R.color.color_black, context), context));
mIntent.putExtra(sNotzWidgets.getChecklistPath(), sNotzWidgets.getChecklistPath(appWidgetId, context));
mPendingIntent = PendingIntent.getActivity(context, appWidgetId, mIntent, Build.VERSION.SDK_INT >=
Expand All @@ -67,6 +67,7 @@ public static void update(AppWidgetManager appWidgetManager, int appWidgetId, Co
for (sNotzItems items : sNotzData.getRawData(context)) {
int noteId = items.getNoteID();
if (noteId == sNotzWidgets.getNoteID(appWidgetId, context)) {
mViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout_notes);
mViews.setTextViewText(R.id.note, items.getNote());
mViews.setTextColor(R.id.note, items.getColorText());
mViews.setInt(R.id.layout, "setBackgroundColor", items.getColorBackground());
Expand Down
Expand Up @@ -3,7 +3,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/color_red"
android:layout_gravity="center"
android:gravity="center" >

Expand All @@ -14,10 +13,9 @@
android:contentDescription="@string/app_name"
android:text="@string/widget_loading_failed"
android:shadowColor="@color/color_black"
android:textColor="@color/color_white"
android:textStyle="bold|italic"
android:layout_margin="8dp"
android:shadowRadius="1"
android:textSize="20sp"
android:shadowRadius="2"
android:textSize="17sp"
android:padding="5dp" />
</LinearLayout>
20 changes: 20 additions & 0 deletions app/src/main/res/layout/widget_layout_notes.xml
@@ -0,0 +1,20 @@
<LinearLayout
android:id="@+id/layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_gravity="center"
android:gravity="center"
android:alpha="0.5" >

<TextView
android:id="@+id/note"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
android:text="@string/widget_loading_failed"
android:textStyle="bold|italic"
android:layout_margin="8dp"
android:textSize="20sp"
android:padding="5dp" />
</LinearLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/xml/widget_provider.xml
Expand Up @@ -3,8 +3,8 @@
android:previewImage="@mipmap/ic_launcher_foreground"
xmlns:android="http://schemas.android.com/apk/res/android"
android:configure="com.sunilpaulmathew.snotz.activities.WidgetActivity"
android:initialKeyguardLayout="@layout/widget_layout"
android:initialLayout="@layout/widget_layout"
android:initialKeyguardLayout="@layout/widget_layout_notes"
android:initialLayout="@layout/widget_layout_notes"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="1800000"
android:widgetCategory="home_screen"
Expand Down

0 comments on commit 8ac31e2

Please sign in to comment.