From 7d2fca02bc05c014fb219b8cf2d7666c0ce4708a Mon Sep 17 00:00:00 2001 From: Tomoyuki Murakami Date: Sat, 8 May 2021 21:22:11 +0900 Subject: [PATCH] add sync button to list widget --- .../com/orgzly/android/widgets/ListWidgetProvider.java | 8 ++++++++ app/src/main/res/layout/list_widget.xml | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/app/src/main/java/com/orgzly/android/widgets/ListWidgetProvider.java b/app/src/main/java/com/orgzly/android/widgets/ListWidgetProvider.java index 3590d4cf2..3bff4a5b9 100644 --- a/app/src/main/java/com/orgzly/android/widgets/ListWidgetProvider.java +++ b/app/src/main/java/com/orgzly/android/widgets/ListWidgetProvider.java @@ -19,6 +19,7 @@ import com.orgzly.android.data.DataRepository; import com.orgzly.android.db.entity.SavedSearch; import com.orgzly.android.prefs.AppPreferences; +import com.orgzly.android.sync.SyncService; import com.orgzly.android.ui.main.MainActivity; import com.orgzly.android.ui.share.ShareActivity; import com.orgzly.android.ui.util.ActivityUtils; @@ -101,6 +102,13 @@ private void updateAppWidgetLayout(Context context, AppWidgetManager appWidgetMa // Plus icon - new note remoteViews.setOnClickPendingIntent(R.id.list_widget_header_add, ShareActivity.createNewNoteIntent(context, savedSearch)); + // Sync icon - sync start + Intent syncIntent = new Intent(context, SyncService.class); + syncIntent.setAction(AppIntent.ACTION_SYNC_START); + PendingIntent syncPendingIntent = PendingIntent.getService( + context, 0, syncIntent, PendingIntent.FLAG_UPDATE_CURRENT); + remoteViews.setOnClickPendingIntent(R.id.list_widget_header_sync, syncPendingIntent); + // Logo - open query Intent openIntent = Intent.makeRestartActivityTask(new ComponentName(context, MainActivity.class)); openIntent.putExtra(AppIntent.EXTRA_QUERY_STRING, savedSearch.getQuery()); diff --git a/app/src/main/res/layout/list_widget.xml b/app/src/main/res/layout/list_widget.xml index f60425f60..e71b48434 100644 --- a/app/src/main/res/layout/list_widget.xml +++ b/app/src/main/res/layout/list_widget.xml @@ -59,6 +59,15 @@ android:layout_height="match_parent" android:layout_gravity="center_vertical" android:src="@drawable/ic_add_white_24dp" /> + +