diff --git a/src/org/thoughtcrime/securesms/BaseActionBarActivity.java b/src/org/thoughtcrime/securesms/BaseActionBarActivity.java index ef9a31d901..d636541251 100644 --- a/src/org/thoughtcrime/securesms/BaseActionBarActivity.java +++ b/src/org/thoughtcrime/securesms/BaseActionBarActivity.java @@ -9,17 +9,22 @@ import android.view.ViewConfiguration; import android.view.WindowManager; +import androidx.annotation.IdRes; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; import org.thoughtcrime.securesms.util.Prefs; import java.lang.reflect.Field; +import java.util.Locale; public abstract class BaseActionBarActivity extends AppCompatActivity { private static final String TAG = BaseActionBarActivity.class.getSimpleName(); + public static final String LOCALE_EXTRA = "locale_extra"; @Override protected void onCreate(Bundle savedInstanceState) { @@ -90,4 +95,36 @@ public void makeSearchMenuVisible(final Menu menu, final MenuItem searchItem, bo } } } + + protected T initFragment(@IdRes int target, + @NonNull T fragment) + { + return initFragment(target, fragment, null); + } + + protected T initFragment(@IdRes int target, + @NonNull T fragment, + @Nullable Locale locale) + { + return initFragment(target, fragment, locale, null); + } + + protected T initFragment(@IdRes int target, + @NonNull T fragment, + @Nullable Locale locale, + @Nullable Bundle extras) + { + Bundle args = new Bundle(); + args.putSerializable(LOCALE_EXTRA, locale); + + if (extras != null) { + args.putAll(extras); + } + + fragment.setArguments(args); + getSupportFragmentManager().beginTransaction() + .replace(target, fragment) + .commitAllowingStateLoss(); + return fragment; + } } diff --git a/src/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java b/src/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java index 1786cd1603..e8fb9d93a0 100644 --- a/src/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java +++ b/src/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java @@ -4,21 +4,12 @@ import android.os.Bundle; import android.util.Log; -import androidx.annotation.IdRes; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; - import org.thoughtcrime.securesms.connect.DcHelper; import org.thoughtcrime.securesms.service.GenericForegroundService; -import java.util.Locale; - public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarActivity { private static final String TAG = PassphraseRequiredActionBarActivity.class.getSimpleName(); - public static final String LOCALE_EXTRA = "locale_extra"; - @Override protected final void onCreate(Bundle savedInstanceState) { Log.w(TAG, "onCreate(" + savedInstanceState + ")"); @@ -48,36 +39,4 @@ protected final void onCreate(Bundle savedInstanceState) { protected void onPreCreate() {} protected void onCreate(Bundle savedInstanceState, boolean ready) {} - - protected T initFragment(@IdRes int target, - @NonNull T fragment) - { - return initFragment(target, fragment, null); - } - - protected T initFragment(@IdRes int target, - @NonNull T fragment, - @Nullable Locale locale) - { - return initFragment(target, fragment, locale, null); - } - - protected T initFragment(@IdRes int target, - @NonNull T fragment, - @Nullable Locale locale, - @Nullable Bundle extras) - { - Bundle args = new Bundle(); - args.putSerializable(LOCALE_EXTRA, locale); - - if (extras != null) { - args.putAll(extras); - } - - fragment.setArguments(args); - getSupportFragmentManager().beginTransaction() - .replace(target, fragment) - .commitAllowingStateLoss(); - return fragment; - } } diff --git a/src/org/thoughtcrime/securesms/qr/BackupTransferActivity.java b/src/org/thoughtcrime/securesms/qr/BackupTransferActivity.java index 1f41b90d2e..717ba1e766 100644 --- a/src/org/thoughtcrime/securesms/qr/BackupTransferActivity.java +++ b/src/org/thoughtcrime/securesms/qr/BackupTransferActivity.java @@ -221,19 +221,4 @@ public void appendSSID(final TextView textView) { }).start(); } } - - protected T initFragment(@IdRes int target, - @NonNull T fragment, - @Nullable Locale locale, - @Nullable Bundle extras) - { - Bundle args = new Bundle(); - args.putSerializable(LOCALE_EXTRA, locale); - if (extras != null) { - args.putAll(extras); - } - fragment.setArguments(args); - getSupportFragmentManager().beginTransaction().replace(target, fragment).commitAllowingStateLoss(); - return fragment; - } }