Loading app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java +1 −1 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ public class BasePeertubeActivity extends BaseBarActivity { if (item.getItemId() == R.id.action_cast) { if (PeertubeBaseMainActivity.chromeCasts != null && PeertubeBaseMainActivity.chromeCasts.size() > 0) { String[] chromecast_choice = new String[PeertubeBaseMainActivity.chromeCasts.size()]; AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(this); alt_bld.setTitle(R.string.chromecast_choice); int i = 0; for (ChromeCast cc : PeertubeBaseMainActivity.chromeCasts) { Loading app/src/main/java/app/fedilab/android/BaseMainActivity.java +3 −3 Original line number Diff line number Diff line Loading @@ -605,7 +605,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt popup.setOnMenuItemClickListener(item -> { int itemId = item.getItemId(); if (itemId == R.id.action_logout_account) { AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(activity, Helper.dialogStyle()); AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(activity); alt_bld.setTitle(R.string.action_logout); if (currentAccount.mastodon_account != null && currentAccount.instance != null) { alt_bld.setMessage(activity.getString(R.string.logout_account_confirmation, currentAccount.mastodon_account.username, currentAccount.instance)); Loading Loading @@ -1567,7 +1567,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt itemShowDMs.setChecked(show_dms); editor.apply(); } else if (itemId == R.id.action_filter) { AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(BaseMainActivity.this, Helper.dialogStyle()); AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(BaseMainActivity.this); LayoutInflater inflater = getLayoutInflater(); View dialogView = inflater.inflate(R.layout.popup_filter_regex, new LinearLayout(BaseMainActivity.this), false); dialogBuilder.setView(dialogView); Loading Loading @@ -1888,7 +1888,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_logout) { AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(BaseMainActivity.this, Helper.dialogStyle()); AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(BaseMainActivity.this); alt_bld.setTitle(R.string.action_logout); alt_bld.setMessage(getString(R.string.logout_account_confirmation, account.mastodon_account.username, account.instance)); alt_bld.setPositiveButton(R.string.action_logout, (dialog, id) -> { Loading app/src/main/java/app/fedilab/android/MainApplication.java +0 −7 Original line number Diff line number Diff line Loading @@ -27,8 +27,6 @@ import androidx.multidex.MultiDex; import androidx.multidex.MultiDexApplication; import androidx.preference.PreferenceManager; import com.google.android.material.color.DynamicColors; import net.gotev.uploadservice.UploadServiceConfig; import net.gotev.uploadservice.observer.request.GlobalRequestObserver; Loading @@ -54,15 +52,10 @@ public class MainApplication extends MultiDexApplication { @Override public void onCreate() { super.onCreate(); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(MainApplication.this); try { webView = new WebView(this); } catch (Exception ignored) { } boolean dynamicColor = sharedpreferences.getBoolean(getString(R.string.SET_DYNAMICCOLOR), false); if (dynamicColor) { DynamicColors.applyToActivitiesIfAvailable(this); } StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.setVmPolicy(builder.build()); Toasty.Config.getInstance().apply(); Loading app/src/main/java/app/fedilab/android/mastodon/activities/BaseActivity.java +6 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatDelegate; import androidx.preference.PreferenceManager; import com.google.android.material.color.DynamicColors; import com.vanniktech.emoji.EmojiManager; import com.vanniktech.emoji.one.EmojiOneProvider; Loading @@ -53,6 +54,7 @@ public class BaseActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { boolean patch_provider = true; final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this); try { Loading Loading @@ -142,6 +144,10 @@ public class BaseActivity extends AppCompatActivity { } } super.onCreate(savedInstanceState); boolean dynamicColor = sharedpreferences.getBoolean(getString(R.string.SET_DYNAMICCOLOR), false); if (dynamicColor) { DynamicColors.applyToActivityIfAvailable(this); } if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.N) { ThemeHelper.adjustFontScale(this, getResources().getConfiguration()); } Loading app/src/main/java/app/fedilab/android/mastodon/activities/BaseAlertDialogActivity.javadeleted 100644 → 0 +0 −153 Original line number Diff line number Diff line package app.fedilab.android.mastodon.activities; /* Copyright 2021 Thomas Schneider * * This file is a part of Fedilab * * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU General Public License as published by the Free Software Foundation; either version 3 of the * License, or (at your option) any later version. * * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details. * * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see <http://www.gnu.org/licenses>. */ import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; import android.graphics.Color; import android.os.Build; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatDelegate; import androidx.preference.PreferenceManager; import com.vanniktech.emoji.EmojiManager; import com.vanniktech.emoji.one.EmojiOneProvider; import org.conscrypt.Conscrypt; import java.security.Security; import app.fedilab.android.R; import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.ThemeHelper; @SuppressLint("Registered") public class BaseAlertDialogActivity extends AppCompatActivity { static { EmojiManager.install(new EmojiOneProvider()); } @Override protected void onCreate(@Nullable Bundle savedInstanceState) { final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this); boolean patch_provider = true; try { patch_provider = sharedpreferences.getBoolean(Helper.SET_SECURITY_PROVIDER, true); } catch (Exception ignored) { } if (patch_provider) { try { Security.insertProviderAt(Conscrypt.newProvider(), 1); } catch (Exception ignored) { } } String currentTheme = sharedpreferences.getString(getString(R.string.SET_THEME_BASE), getString(R.string.SET_DEFAULT_THEME)); //Default automatic switch if (currentTheme.equals(getString(R.string.SET_DEFAULT_THEME))) { int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; switch (currentNightMode) { case Configuration.UI_MODE_NIGHT_NO: String defaultLight = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_LIGHT), "LIGHT"); switch (defaultLight) { case "LIGHT": setTheme(R.style.AppThemeAlertDialog); break; case "SOLARIZED_LIGHT": setTheme(R.style.SolarizedAlertDialog); break; } break; case Configuration.UI_MODE_NIGHT_YES: String defaultDark = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_DARK), "DARK"); switch (defaultDark) { case "DARK": setTheme(R.style.AppThemeAlertDialog); break; case "SOLARIZED_DARK": setTheme(R.style.SolarizedAlertDialog); break; case "BLACK": Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.BLACK); setTheme(R.style.BlackAlertDialog); break; case "DRACULA": setTheme(R.style.DraculaAlertDialog); break; } break; } } else { switch (currentTheme) { case "LIGHT": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); setTheme(R.style.AppThemeAlertDialog); break; case "DARK": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); setTheme(R.style.AppThemeAlertDialog); break; case "SOLARIZED_LIGHT": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); setTheme(R.style.SolarizedAlertDialog); break; case "SOLARIZED_DARK": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); setTheme(R.style.SolarizedAlertDialog); break; case "BLACK": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.BLACK); setTheme(R.style.BlackAlertDialog); break; case "DRACULA": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); setTheme(R.style.DraculaAlertDialog); break; } } super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.N) { ThemeHelper.adjustFontScale(this, getResources().getConfiguration()); } Helper.setLocale(this); } @Override protected void attachBaseContext(Context newBase) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) { final Configuration override = new Configuration(newBase.getResources().getConfiguration()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(newBase); override.fontScale = prefs.getFloat(newBase.getString(R.string.SET_FONT_SCALE), 1.1f); applyOverrideConfiguration(override); } super.attachBaseContext(newBase); } } Loading
app/src/fdroid/java/app/fedilab/android/activities/BasePeertubeActivity.java +1 −1 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ public class BasePeertubeActivity extends BaseBarActivity { if (item.getItemId() == R.id.action_cast) { if (PeertubeBaseMainActivity.chromeCasts != null && PeertubeBaseMainActivity.chromeCasts.size() > 0) { String[] chromecast_choice = new String[PeertubeBaseMainActivity.chromeCasts.size()]; AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(this, app.fedilab.android.mastodon.helper.Helper.dialogStyle()); AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(this); alt_bld.setTitle(R.string.chromecast_choice); int i = 0; for (ChromeCast cc : PeertubeBaseMainActivity.chromeCasts) { Loading
app/src/main/java/app/fedilab/android/BaseMainActivity.java +3 −3 Original line number Diff line number Diff line Loading @@ -605,7 +605,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt popup.setOnMenuItemClickListener(item -> { int itemId = item.getItemId(); if (itemId == R.id.action_logout_account) { AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(activity, Helper.dialogStyle()); AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(activity); alt_bld.setTitle(R.string.action_logout); if (currentAccount.mastodon_account != null && currentAccount.instance != null) { alt_bld.setMessage(activity.getString(R.string.logout_account_confirmation, currentAccount.mastodon_account.username, currentAccount.instance)); Loading Loading @@ -1567,7 +1567,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt itemShowDMs.setChecked(show_dms); editor.apply(); } else if (itemId == R.id.action_filter) { AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(BaseMainActivity.this, Helper.dialogStyle()); AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(BaseMainActivity.this); LayoutInflater inflater = getLayoutInflater(); View dialogView = inflater.inflate(R.layout.popup_filter_regex, new LinearLayout(BaseMainActivity.this), false); dialogBuilder.setView(dialogView); Loading Loading @@ -1888,7 +1888,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_logout) { AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(BaseMainActivity.this, Helper.dialogStyle()); AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(BaseMainActivity.this); alt_bld.setTitle(R.string.action_logout); alt_bld.setMessage(getString(R.string.logout_account_confirmation, account.mastodon_account.username, account.instance)); alt_bld.setPositiveButton(R.string.action_logout, (dialog, id) -> { Loading
app/src/main/java/app/fedilab/android/MainApplication.java +0 −7 Original line number Diff line number Diff line Loading @@ -27,8 +27,6 @@ import androidx.multidex.MultiDex; import androidx.multidex.MultiDexApplication; import androidx.preference.PreferenceManager; import com.google.android.material.color.DynamicColors; import net.gotev.uploadservice.UploadServiceConfig; import net.gotev.uploadservice.observer.request.GlobalRequestObserver; Loading @@ -54,15 +52,10 @@ public class MainApplication extends MultiDexApplication { @Override public void onCreate() { super.onCreate(); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(MainApplication.this); try { webView = new WebView(this); } catch (Exception ignored) { } boolean dynamicColor = sharedpreferences.getBoolean(getString(R.string.SET_DYNAMICCOLOR), false); if (dynamicColor) { DynamicColors.applyToActivitiesIfAvailable(this); } StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.setVmPolicy(builder.build()); Toasty.Config.getInstance().apply(); Loading
app/src/main/java/app/fedilab/android/mastodon/activities/BaseActivity.java +6 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatDelegate; import androidx.preference.PreferenceManager; import com.google.android.material.color.DynamicColors; import com.vanniktech.emoji.EmojiManager; import com.vanniktech.emoji.one.EmojiOneProvider; Loading @@ -53,6 +54,7 @@ public class BaseActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { boolean patch_provider = true; final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this); try { Loading Loading @@ -142,6 +144,10 @@ public class BaseActivity extends AppCompatActivity { } } super.onCreate(savedInstanceState); boolean dynamicColor = sharedpreferences.getBoolean(getString(R.string.SET_DYNAMICCOLOR), false); if (dynamicColor) { DynamicColors.applyToActivityIfAvailable(this); } if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.N) { ThemeHelper.adjustFontScale(this, getResources().getConfiguration()); } Loading
app/src/main/java/app/fedilab/android/mastodon/activities/BaseAlertDialogActivity.javadeleted 100644 → 0 +0 −153 Original line number Diff line number Diff line package app.fedilab.android.mastodon.activities; /* Copyright 2021 Thomas Schneider * * This file is a part of Fedilab * * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU General Public License as published by the Free Software Foundation; either version 3 of the * License, or (at your option) any later version. * * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details. * * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see <http://www.gnu.org/licenses>. */ import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; import android.graphics.Color; import android.os.Build; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatDelegate; import androidx.preference.PreferenceManager; import com.vanniktech.emoji.EmojiManager; import com.vanniktech.emoji.one.EmojiOneProvider; import org.conscrypt.Conscrypt; import java.security.Security; import app.fedilab.android.R; import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.ThemeHelper; @SuppressLint("Registered") public class BaseAlertDialogActivity extends AppCompatActivity { static { EmojiManager.install(new EmojiOneProvider()); } @Override protected void onCreate(@Nullable Bundle savedInstanceState) { final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this); boolean patch_provider = true; try { patch_provider = sharedpreferences.getBoolean(Helper.SET_SECURITY_PROVIDER, true); } catch (Exception ignored) { } if (patch_provider) { try { Security.insertProviderAt(Conscrypt.newProvider(), 1); } catch (Exception ignored) { } } String currentTheme = sharedpreferences.getString(getString(R.string.SET_THEME_BASE), getString(R.string.SET_DEFAULT_THEME)); //Default automatic switch if (currentTheme.equals(getString(R.string.SET_DEFAULT_THEME))) { int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; switch (currentNightMode) { case Configuration.UI_MODE_NIGHT_NO: String defaultLight = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_LIGHT), "LIGHT"); switch (defaultLight) { case "LIGHT": setTheme(R.style.AppThemeAlertDialog); break; case "SOLARIZED_LIGHT": setTheme(R.style.SolarizedAlertDialog); break; } break; case Configuration.UI_MODE_NIGHT_YES: String defaultDark = sharedpreferences.getString(getString(R.string.SET_THEME_DEFAULT_DARK), "DARK"); switch (defaultDark) { case "DARK": setTheme(R.style.AppThemeAlertDialog); break; case "SOLARIZED_DARK": setTheme(R.style.SolarizedAlertDialog); break; case "BLACK": Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.BLACK); setTheme(R.style.BlackAlertDialog); break; case "DRACULA": setTheme(R.style.DraculaAlertDialog); break; } break; } } else { switch (currentTheme) { case "LIGHT": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); setTheme(R.style.AppThemeAlertDialog); break; case "DARK": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); setTheme(R.style.AppThemeAlertDialog); break; case "SOLARIZED_LIGHT": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); setTheme(R.style.SolarizedAlertDialog); break; case "SOLARIZED_DARK": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); setTheme(R.style.SolarizedAlertDialog); break; case "BLACK": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.BLACK); setTheme(R.style.BlackAlertDialog); break; case "DRACULA": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); setTheme(R.style.DraculaAlertDialog); break; } } super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.N) { ThemeHelper.adjustFontScale(this, getResources().getConfiguration()); } Helper.setLocale(this); } @Override protected void attachBaseContext(Context newBase) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) { final Configuration override = new Configuration(newBase.getResources().getConfiguration()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(newBase); override.fontScale = prefs.getFloat(newBase.getString(R.string.SET_FONT_SCALE), 1.1f); applyOverrideConfiguration(override); } super.attachBaseContext(newBase); } }