mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-02 15:17:03 +02:00
Added option to open widget content standalone
This commit is contained in:
@@ -737,9 +737,18 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||
}
|
||||
}
|
||||
|
||||
if (getSupportFragmentManager().getFragments().size() == 0 &&
|
||||
!getIntent().hasExtra(Intent.EXTRA_PROCESS_TEXT))
|
||||
init();
|
||||
if (getSupportFragmentManager().getFragments().size() == 0) {
|
||||
Intent intent = getIntent();
|
||||
boolean search = (intent != null && intent.hasExtra(Intent.EXTRA_PROCESS_TEXT));
|
||||
boolean standalone = (intent != null && intent.getBooleanExtra("standalone", false));
|
||||
boolean unified = (intent != null &&
|
||||
("unified".equals(intent.getAction()) ||
|
||||
("folder:-1".equals(intent.getAction()) &&
|
||||
intent.getLongExtra("account", 0) < 0 &&
|
||||
intent.getStringExtra("type") == null)));
|
||||
if (!search && !(standalone && !unified))
|
||||
init();
|
||||
}
|
||||
|
||||
if (savedInstanceState != null)
|
||||
drawerToggle.setDrawerIndicatorEnabled(savedInstanceState.getBoolean("fair:toggle"));
|
||||
@@ -1312,7 +1321,11 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||
else {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ActivityView.this);
|
||||
boolean double_back = prefs.getBoolean("double_back", false);
|
||||
if (searching || !double_back)
|
||||
|
||||
Intent intent = getIntent();
|
||||
boolean standalone = (intent != null && intent.getBooleanExtra("standalone", false));
|
||||
|
||||
if (searching || !double_back || standalone)
|
||||
performBack();
|
||||
else {
|
||||
exit = true;
|
||||
@@ -2051,7 +2064,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||
long folder = intent.getLongExtra("widget_folder", -1);
|
||||
String type = intent.getStringExtra("widget_type");
|
||||
if (account > 0 && folder > 0 && !TextUtils.isEmpty(type)) {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||
if (!intent.getBooleanExtra("standalone", false) &&
|
||||
getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||
getSupportFragmentManager().popBackStack("messages", FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
|
||||
Bundle args = new Bundle();
|
||||
|
||||
@@ -73,6 +73,7 @@ public class ActivityWidget extends ActivityBase {
|
||||
private CheckBox cbTop;
|
||||
private Spinner spFontSize;
|
||||
private EditText etName;
|
||||
private CheckBox cbStandalone;
|
||||
private Button btnSave;
|
||||
private ContentLoadingProgressBar pbWait;
|
||||
private Group grpReady;
|
||||
@@ -104,6 +105,7 @@ public class ActivityWidget extends ActivityBase {
|
||||
boolean top = prefs.getBoolean("widget." + appWidgetId + ".top", false);
|
||||
int size = prefs.getInt("widget." + appWidgetId + ".text_size", -1);
|
||||
String name = prefs.getString("widget." + appWidgetId + ".name", null);
|
||||
boolean standalone = prefs.getBoolean("widget." + appWidgetId + ".standalone", false);
|
||||
|
||||
daynight = daynight && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S);
|
||||
|
||||
@@ -124,6 +126,7 @@ public class ActivityWidget extends ActivityBase {
|
||||
cbTop = findViewById(R.id.cbTop);
|
||||
spFontSize = findViewById(R.id.spFontSize);
|
||||
etName = findViewById(R.id.etName);
|
||||
cbStandalone = findViewById(R.id.cbStandalone);
|
||||
btnSave = findViewById(R.id.btnSave);
|
||||
pbWait = findViewById(R.id.pbWait);
|
||||
grpReady = findViewById(R.id.grpReady);
|
||||
@@ -296,6 +299,7 @@ public class ActivityWidget extends ActivityBase {
|
||||
editor.putInt("widget." + appWidgetId + ".text_size", pos - 1);
|
||||
else
|
||||
editor.remove("widget." + appWidgetId + ".text_size");
|
||||
editor.putBoolean("widget." + appWidgetId + ".standalone", cbStandalone.isChecked());
|
||||
editor.putInt("widget." + appWidgetId + ".version", BuildConfig.VERSION_CODE);
|
||||
editor.apply();
|
||||
|
||||
@@ -410,6 +414,7 @@ public class ActivityWidget extends ActivityBase {
|
||||
cbTop.setChecked(top);
|
||||
spFontSize.setSelection(size + 1);
|
||||
etName.setText(name);
|
||||
cbStandalone.setChecked(standalone);
|
||||
updatePreview();
|
||||
|
||||
grpReady.setVisibility(View.GONE);
|
||||
|
||||
@@ -78,6 +78,7 @@ public class ActivityWidgetUnified extends ActivityBase {
|
||||
private EditText etName;
|
||||
private CheckBox cbRefresh;
|
||||
private CheckBox cbCompose;
|
||||
private CheckBox cbStandalone;
|
||||
private Button btnSave;
|
||||
private ContentLoadingProgressBar pbWait;
|
||||
private Group grpReady;
|
||||
@@ -122,6 +123,7 @@ public class ActivityWidgetUnified extends ActivityBase {
|
||||
String name = prefs.getString("widget." + appWidgetId + ".name", null);
|
||||
boolean refresh = prefs.getBoolean("widget." + appWidgetId + ".refresh", false);
|
||||
boolean compose = prefs.getBoolean("widget." + appWidgetId + ".compose", false);
|
||||
boolean standalone = prefs.getBoolean("widget." + appWidgetId + ".standalone", false);
|
||||
|
||||
daynight = daynight && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S);
|
||||
|
||||
@@ -149,6 +151,7 @@ public class ActivityWidgetUnified extends ActivityBase {
|
||||
etName = findViewById(R.id.etName);
|
||||
cbRefresh = findViewById(R.id.cbRefresh);
|
||||
cbCompose = findViewById(R.id.cbCompose);
|
||||
cbStandalone = findViewById(R.id.cbStandalone);
|
||||
btnSave = findViewById(R.id.btnSave);
|
||||
pbWait = findViewById(R.id.pbWait);
|
||||
grpReady = findViewById(R.id.grpReady);
|
||||
@@ -304,6 +307,7 @@ public class ActivityWidgetUnified extends ActivityBase {
|
||||
editor.putBoolean("widget." + appWidgetId + ".caption", cbCaption.isChecked());
|
||||
editor.putBoolean("widget." + appWidgetId + ".refresh", cbRefresh.isChecked());
|
||||
editor.putBoolean("widget." + appWidgetId + ".compose", cbCompose.isChecked());
|
||||
editor.putBoolean("widget." + appWidgetId + ".standalone", cbStandalone.isChecked());
|
||||
editor.putInt("widget." + appWidgetId + ".version", BuildConfig.VERSION_CODE);
|
||||
|
||||
editor.apply();
|
||||
@@ -441,6 +445,7 @@ public class ActivityWidgetUnified extends ActivityBase {
|
||||
etName.setEnabled(caption);
|
||||
cbRefresh.setChecked(refresh);
|
||||
cbCompose.setChecked(compose);
|
||||
cbStandalone.setChecked(standalone);
|
||||
|
||||
grpReady.setVisibility(View.GONE);
|
||||
pbWait.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -68,6 +68,7 @@ public class Widget extends AppWidgetProvider {
|
||||
int layout = prefs.getInt("widget." + appWidgetId + ".layout", 0);
|
||||
boolean top = prefs.getBoolean("widget." + appWidgetId + ".top", false);
|
||||
int size = prefs.getInt("widget." + appWidgetId + ".text_size", -1);
|
||||
boolean standalone = prefs.getBoolean("widget." + appWidgetId + ".standalone", false);
|
||||
int version = prefs.getInt("widget." + appWidgetId + ".version", 0);
|
||||
|
||||
if (version <= 1550)
|
||||
@@ -90,6 +91,7 @@ public class Widget extends AppWidgetProvider {
|
||||
view.setAction("folder:" + folders.get(0).id);
|
||||
view.putExtra("account", account);
|
||||
view.putExtra("type", folders.get(0).type);
|
||||
view.putExtra("standalone", standalone);
|
||||
view.putExtra("refresh", true);
|
||||
view.putExtra("version", version);
|
||||
view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
@@ -99,6 +101,7 @@ public class Widget extends AppWidgetProvider {
|
||||
if (account < 0) {
|
||||
Intent view = new Intent(context, ActivityView.class);
|
||||
view.setAction("unified");
|
||||
view.putExtra("standalone", standalone);
|
||||
view.putExtra("refresh", true);
|
||||
view.putExtra("version", version);
|
||||
view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
@@ -107,6 +110,7 @@ public class Widget extends AppWidgetProvider {
|
||||
} else {
|
||||
Intent view = new Intent(context, ActivityView.class);
|
||||
view.setAction("folders:" + account);
|
||||
view.putExtra("standalone", standalone);
|
||||
view.putExtra("refresh", true);
|
||||
view.putExtra("version", version);
|
||||
view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
|
||||
@@ -59,6 +59,7 @@ public class WidgetUnified extends AppWidgetProvider {
|
||||
boolean caption = prefs.getBoolean("widget." + appWidgetId + ".caption", true);
|
||||
boolean refresh = prefs.getBoolean("widget." + appWidgetId + ".refresh", false);
|
||||
boolean compose = prefs.getBoolean("widget." + appWidgetId + ".compose", false);
|
||||
boolean standalone = prefs.getBoolean("widget." + appWidgetId + ".standalone", false);
|
||||
int version = prefs.getInt("widget." + appWidgetId + ".version", 0);
|
||||
|
||||
if (version <= 1550)
|
||||
@@ -72,6 +73,7 @@ public class WidgetUnified extends AppWidgetProvider {
|
||||
view.setAction("folder:" + folder);
|
||||
view.putExtra("account", account);
|
||||
view.putExtra("type", type);
|
||||
view.putExtra("standalone", standalone);
|
||||
view.putExtra("refresh", true);
|
||||
view.putExtra("version", version);
|
||||
view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
@@ -133,6 +135,7 @@ public class WidgetUnified extends AppWidgetProvider {
|
||||
thread.putExtra("widget_folder", folder);
|
||||
thread.putExtra("widget_type", type);
|
||||
thread.putExtra("filter_archive", !EntityFolder.ARCHIVE.equals(type));
|
||||
thread.putExtra("standalone", standalone);
|
||||
thread.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
PendingIntent piItem = PendingIntentCompat.getActivity(
|
||||
context, ActivityView.PI_WIDGET, thread, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
|
||||
|
||||
Reference in New Issue
Block a user