|
|
@ -35,6 +35,8 @@ import android.widget.RemoteViews;
|
|
|
|
import androidx.core.graphics.ColorUtils;
|
|
|
|
import androidx.core.graphics.ColorUtils;
|
|
|
|
import androidx.preference.PreferenceManager;
|
|
|
|
import androidx.preference.PreferenceManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
|
|
public class WidgetUnified extends AppWidgetProvider {
|
|
|
|
public class WidgetUnified extends AppWidgetProvider {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
|
|
|
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
|
|
@ -49,6 +51,7 @@ public class WidgetUnified extends AppWidgetProvider {
|
|
|
|
int background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT);
|
|
|
|
int background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT);
|
|
|
|
int font = prefs.getInt("widget." + appWidgetId + ".font", 0);
|
|
|
|
int font = prefs.getInt("widget." + appWidgetId + ".font", 0);
|
|
|
|
int padding = prefs.getInt("widget." + appWidgetId + ".padding", 0);
|
|
|
|
int padding = prefs.getInt("widget." + appWidgetId + ".padding", 0);
|
|
|
|
|
|
|
|
boolean refresh = prefs.getBoolean("widget." + appWidgetId + ".refresh", false);
|
|
|
|
boolean compose = prefs.getBoolean("widget." + appWidgetId + ".compose", false);
|
|
|
|
boolean compose = prefs.getBoolean("widget." + appWidgetId + ".compose", false);
|
|
|
|
int version = prefs.getInt("widget." + appWidgetId + ".version", 0);
|
|
|
|
int version = prefs.getInt("widget." + appWidgetId + ".version", 0);
|
|
|
|
|
|
|
|
|
|
|
@ -69,6 +72,13 @@ public class WidgetUnified extends AppWidgetProvider {
|
|
|
|
PendingIntent pi = PendingIntentCompat.getActivity(
|
|
|
|
PendingIntent pi = PendingIntentCompat.getActivity(
|
|
|
|
context, appWidgetId, view, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
context, appWidgetId, view, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Intent sync = new Intent(context, ServiceUI.class);
|
|
|
|
|
|
|
|
sync.setAction("widget:" + appWidgetId);
|
|
|
|
|
|
|
|
sync.putExtra("account", account);
|
|
|
|
|
|
|
|
sync.putExtra("folder", folder);
|
|
|
|
|
|
|
|
PendingIntent piSync = PendingIntentCompat.getService(
|
|
|
|
|
|
|
|
context, appWidgetId, sync, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
|
|
|
|
|
|
|
Intent edit = new Intent(context, ActivityCompose.class);
|
|
|
|
Intent edit = new Intent(context, ActivityCompose.class);
|
|
|
|
edit.setAction("widget:" + appWidgetId);
|
|
|
|
edit.setAction("widget:" + appWidgetId);
|
|
|
|
edit.putExtra("action", "new");
|
|
|
|
edit.putExtra("action", "new");
|
|
|
@ -91,6 +101,15 @@ public class WidgetUnified extends AppWidgetProvider {
|
|
|
|
|
|
|
|
|
|
|
|
views.setOnClickPendingIntent(R.id.title, pi);
|
|
|
|
views.setOnClickPendingIntent(R.id.title, pi);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
views.setViewVisibility(R.id.refresh, refresh ? View.VISIBLE : View.GONE);
|
|
|
|
|
|
|
|
views.setViewPadding(R.id.refresh, px, px, px, px);
|
|
|
|
|
|
|
|
views.setOnClickPendingIntent(R.id.refresh, piSync);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long refreshing = prefs.getLong("widget." + appWidgetId + ".sync", 0L);
|
|
|
|
|
|
|
|
views.setImageViewResource(R.id.refresh,
|
|
|
|
|
|
|
|
refreshing < new Date().getTime()
|
|
|
|
|
|
|
|
? R.drawable.twotone_sync_24 : R.drawable.twotone_compare_arrows_24);
|
|
|
|
|
|
|
|
|
|
|
|
views.setViewVisibility(R.id.compose, compose ? View.VISIBLE : View.GONE);
|
|
|
|
views.setViewVisibility(R.id.compose, compose ? View.VISIBLE : View.GONE);
|
|
|
|
views.setViewPadding(R.id.compose, px, px, px, px);
|
|
|
|
views.setViewPadding(R.id.compose, px, px, px, px);
|
|
|
|
views.setOnClickPendingIntent(R.id.compose, piCompose);
|
|
|
|
views.setOnClickPendingIntent(R.id.compose, piCompose);
|
|
|
|