MCPcopy Create free account
hub / github.com/M66B/FairEmail / run

Method run

app/src/main/java/eu/faircode/email/Widget.java:51–218  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49 public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds) {
50 executor.submit(new Runnable() {
51 @Override
52 public void run() {
53 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
54 boolean unseen_ignored = prefs.getBoolean("unseen_ignored", false);
55
56 DB db = DB.getInstance(context);
57 NumberFormat nf = NumberFormat.getIntegerInstance();
58 int colorWidgetForeground = context.getResources().getColor(R.color.colorWidgetForeground);
59
60 for (int appWidgetId : appWidgetIds) {
61 String name = prefs.getString("widget." + appWidgetId + ".name", null);
62 long account = prefs.getLong("widget." + appWidgetId + ".account", -1L);
63 long folder = prefs.getLong("widget." + appWidgetId + ".folder", -1L);
64 boolean daynight = prefs.getBoolean("widget." + appWidgetId + ".daynight", false);
65 boolean semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true);
66 int background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT);
67 int foreground = prefs.getInt("widget." + appWidgetId + ".foreground", Color.TRANSPARENT);
68 int layout = prefs.getInt("widget." + appWidgetId + ".layout", 0);
69 boolean top = prefs.getBoolean("widget." + appWidgetId + ".top", false);
70 int size = prefs.getInt("widget." + appWidgetId + ".text_size", -1);
71 boolean standalone = prefs.getBoolean("widget." + appWidgetId + ".standalone", false);
72 int version = prefs.getInt("widget." + appWidgetId + ".version", 0);
73
74 if (version <= 1550)
75 semi = true; // Legacy
76
77 List<EntityFolder> folders = null;
78 if (folder < 0)
79 folders = db.folder().getNotifyingFolders(account);
80 else {
81 EntityFolder f = db.folder().getFolder(folder);
82 if (f != null)
83 folders = Arrays.asList(f);
84 }
85 if (folders == null)
86 folders = new ArrayList<>();
87
88 PendingIntent pi;
89 if (folders.size() == 1) {
90 Intent view = new Intent(context, ActivityView.class);
91 view.setAction("folder:" + folders.get(0).id);
92 view.putExtra("account", account);
93 view.putExtra("type", folders.get(0).type);
94 view.putExtra("standalone", standalone);
95 view.putExtra("refresh", true);
96 view.putExtra("version", version);
97 view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
98 pi = PendingIntentCompat.getActivity(
99 context, appWidgetId, view, PendingIntent.FLAG_UPDATE_CURRENT);
100 } else {
101 if (account < 0) {
102 Intent view = new Intent(context, ActivityView.class);
103 view.setAction("unified");
104 view.putExtra("standalone", standalone);
105 view.putExtra("refresh", true);
106 view.putExtra("version", version);
107 view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
108 pi = PendingIntentCompat.getActivity(

Callers

nothing calls this directly

Calls 15

getInstanceMethod · 0.95
folderMethod · 0.95
getActivityMethod · 0.95
messageMethod · 0.95
logMethod · 0.95
formatNumberMethod · 0.95
getTextSizeMethod · 0.95
dp2pixelsMethod · 0.95
getBooleanMethod · 0.80
getLongMethod · 0.80
getNotifyingFoldersMethod · 0.80
setActionMethod · 0.80

Tested by

no test coverage detected