Added option to use standalone browser for OAuth

pull/214/head
M66B 11 months ago
parent 5ff0ca0267
commit a540f1df87

@ -387,11 +387,14 @@ public class FragmentOAuth extends FragmentBase {
EmailProvider provider = EmailProvider.getProvider(context, id); EmailProvider provider = EmailProvider.getProvider(context, id);
EmailProvider.OAuth oauth = (graph ? provider.graph : provider.oauth); EmailProvider.OAuth oauth = (graph ? provider.graph : provider.oauth);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean oauth_tabs = prefs.getBoolean("oauth_tabs", true);
AppAuthConfiguration.Builder appAuthConfig = new AppAuthConfiguration.Builder(); AppAuthConfiguration.Builder appAuthConfig = new AppAuthConfiguration.Builder();
AuthorizationService authService; AuthorizationService authService;
try { try {
appAuthConfig.setBrowserMatcher(getBrowserMatcher(context, true, provider)); appAuthConfig.setBrowserMatcher(getBrowserMatcher(context, oauth_tabs, provider));
authService = new AuthorizationService(context, appAuthConfig.build()); authService = new AuthorizationService(context, appAuthConfig.build());
} catch (Throwable ex) { } catch (Throwable ex) {
/* /*
@ -429,7 +432,6 @@ public class FragmentOAuth extends FragmentBase {
int random = Math.abs(new SecureRandom().nextInt()); int random = Math.abs(new SecureRandom().nextInt());
long expire = new Date().getTime() + OAUTH_TIMEOUT; long expire = new Date().getTime() + OAUTH_TIMEOUT;
AuthState authState = new AuthState(serviceConfig); AuthState authState = new AuthState(serviceConfig);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String key = "oauth." + provider.id + (graph ? ":graph" : ""); String key = "oauth." + provider.id + (graph ? ":graph" : "");
JSONObject jauthstate = authState.jsonSerialize(); JSONObject jauthstate = authState.jsonSerialize();
jauthstate.put(FAIREMAIL_RANDOM, random); jauthstate.put(FAIREMAIL_RANDOM, random);

@ -178,11 +178,12 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swSyncExtra; private SwitchCompat swSyncExtra;
private TextView tvSqliteCache; private TextView tvSqliteCache;
private SeekBar sbSqliteCache; private SeekBar sbSqliteCache;
private ImageButton ibSqliteCache;
private SwitchCompat swOauthTabs;
private TextView tvChunkSize; private TextView tvChunkSize;
private SeekBar sbChunkSize; private SeekBar sbChunkSize;
private TextView tvThreadRange; private TextView tvThreadRange;
private SeekBar sbThreadRange; private SeekBar sbThreadRange;
private ImageButton ibSqliteCache;
private SwitchCompat swAutoScroll; private SwitchCompat swAutoScroll;
private SwitchCompat swUndoManager; private SwitchCompat swUndoManager;
private SwitchCompat swBrowserZoom; private SwitchCompat swBrowserZoom;
@ -274,6 +275,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"test1", "test2", "test3", "test4", "test5", "test1", "test2", "test3", "test4", "test5",
"emergency_file", "work_manager", // "external_storage", "emergency_file", "work_manager", // "external_storage",
"sqlite_integrity_check", "wal", "sqlite_checkpoints", "sqlite_analyze", "sqlite_auto_vacuum", "sqlite_sync_extra", "sqlite_cache", "sqlite_integrity_check", "wal", "sqlite_checkpoints", "sqlite_analyze", "sqlite_auto_vacuum", "sqlite_sync_extra", "sqlite_cache",
"oauth_tabs",
"chunk_size", "thread_range", "chunk_size", "thread_range",
"autoscroll_editor", "undo_manager", "autoscroll_editor", "undo_manager",
"browser_zoom", "fake_dark", "browser_zoom", "fake_dark",
@ -416,6 +418,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvSqliteCache = view.findViewById(R.id.tvSqliteCache); tvSqliteCache = view.findViewById(R.id.tvSqliteCache);
sbSqliteCache = view.findViewById(R.id.sbSqliteCache); sbSqliteCache = view.findViewById(R.id.sbSqliteCache);
ibSqliteCache = view.findViewById(R.id.ibSqliteCache); ibSqliteCache = view.findViewById(R.id.ibSqliteCache);
swOauthTabs = view.findViewById(R.id.swOauthTabs);
tvChunkSize = view.findViewById(R.id.tvChunkSize); tvChunkSize = view.findViewById(R.id.tvChunkSize);
sbChunkSize = view.findViewById(R.id.sbChunkSize); sbChunkSize = view.findViewById(R.id.sbChunkSize);
tvThreadRange = view.findViewById(R.id.tvThreadRange); tvThreadRange = view.findViewById(R.id.tvThreadRange);
@ -1221,6 +1224,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
} }
}); });
swOauthTabs.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton v, boolean checked) {
prefs.edit().putBoolean("oauth_tabs", checked).apply();
}
});
sbChunkSize.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { sbChunkSize.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override @Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
@ -2296,6 +2306,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
Helper.humanReadableByteCount(cache_size * 1024L))); Helper.humanReadableByteCount(cache_size * 1024L)));
sbSqliteCache.setProgress(sqlite_cache); sbSqliteCache.setProgress(sqlite_cache);
swOauthTabs.setChecked(prefs.getBoolean("oauth_tabs", true));
int chunk_size = prefs.getInt("chunk_size", Core.DEFAULT_CHUNK_SIZE); int chunk_size = prefs.getInt("chunk_size", Core.DEFAULT_CHUNK_SIZE);
tvChunkSize.setText(getString(R.string.title_advanced_chunk_size, chunk_size)); tvChunkSize.setText(getString(R.string.title_advanced_chunk_size, chunk_size));
sbChunkSize.setProgress(chunk_size); sbChunkSize.setProgress(chunk_size);

@ -1137,6 +1137,17 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ibSqliteCache" /> app:layout_constraintTop_toBottomOf="@id/ibSqliteCache" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swOauthTabs"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_oauth_tabs"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSqliteCacheHint"
app:switchPadding="12dp" />
<TextView <TextView
android:id="@+id/tvChunkSize" android:id="@+id/tvChunkSize"
android:layout_width="0dp" android:layout_width="0dp"
@ -1147,7 +1158,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSqliteCacheHint" /> app:layout_constraintTop_toBottomOf="@id/swOauthTabs" />
<SeekBar <SeekBar
android:id="@+id/sbChunkSize" android:id="@+id/sbChunkSize"

@ -908,6 +908,7 @@
<string name="title_advanced_auto_vacuum" translatable="false">sqlite auto vacuum</string> <string name="title_advanced_auto_vacuum" translatable="false">sqlite auto vacuum</string>
<string name="title_advanced_sync_extra" translatable="false">sqlite sync extra</string> <string name="title_advanced_sync_extra" translatable="false">sqlite sync extra</string>
<string name="title_advanced_sqlite_cache" translatable="false">sqlite cache: %1$s %% - %2$s</string> <string name="title_advanced_sqlite_cache" translatable="false">sqlite cache: %1$s %% - %2$s</string>
<string name="title_advanced_oauth_tabs" translatable="false">OAuth tabs</string>
<string name="title_advanced_chunk_size" translatable="false">Chunk size: %1$d</string> <string name="title_advanced_chunk_size" translatable="false">Chunk size: %1$d</string>
<string name="title_advanced_thread_range" translatable="false">Thread range: %1$d days</string> <string name="title_advanced_thread_range" translatable="false">Thread range: %1$d days</string>
<string name="title_advanced_auto_scroll" translatable="false">Auto scroll editor</string> <string name="title_advanced_auto_scroll" translatable="false">Auto scroll editor</string>

Loading…
Cancel
Save