From 2a0687a534255d05feac7eb19dd31f3181a3c008 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Sun, 4 Apr 2021 10:58:33 -0400 Subject: [PATCH] Use FragmentContainerView in settings --- .../antennapod/activity/PreferenceActivity.java | 14 +++++--------- .../preferences/MainPreferencesFragment.java | 8 +++++--- .../fragment/preferences/about/AboutFragment.java | 6 ++++-- app/src/main/res/layout/feedsettings.xml | 2 +- app/src/main/res/layout/settings_activity.xml | 5 +++++ 5 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 app/src/main/res/layout/settings_activity.xml diff --git a/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java index aa0a5afea..d0670b906 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java @@ -11,14 +11,13 @@ import androidx.preference.PreferenceFragmentCompat; import android.provider.Settings; import android.view.Menu; import android.view.MenuItem; -import android.view.ViewGroup; -import android.widget.FrameLayout; import com.bytehamster.lib.preferencesearch.SearchPreferenceResult; import com.bytehamster.lib.preferencesearch.SearchPreferenceResultListener; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.preferences.UserPreferences; +import de.danoeh.antennapod.databinding.SettingsActivityBinding; import de.danoeh.antennapod.fragment.preferences.AutoDownloadPreferencesFragment; import de.danoeh.antennapod.fragment.preferences.GpodderPreferencesFragment; import de.danoeh.antennapod.fragment.preferences.ImportExportPreferencesFragment; @@ -46,15 +45,12 @@ public class PreferenceActivity extends AppCompatActivity implements SearchPrefe ab.setDisplayHomeAsUpEnabled(true); } - FrameLayout root = new FrameLayout(this); - root.setId(R.id.content); - root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT)); - setContentView(root); + final SettingsActivityBinding binding = SettingsActivityBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); if (getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG) == null) { getSupportFragmentManager().beginTransaction() - .replace(R.id.content, new MainPreferencesFragment(), FRAGMENT_TAG) + .replace(R.id.settingsContainer, new MainPreferencesFragment(), FRAGMENT_TAG) .commit(); } } @@ -115,7 +111,7 @@ public class PreferenceActivity extends AppCompatActivity implements SearchPrefe intent.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName()); startActivity(intent); } else { - getSupportFragmentManager().beginTransaction().replace(R.id.content, fragment) + getSupportFragmentManager().beginTransaction().replace(R.id.settingsContainer, fragment) .addToBackStack(getString(getTitleOfPage(screen))).commit(); } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java index f27ff371e..955012f3c 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java @@ -87,14 +87,16 @@ public class MainPreferencesFragment extends PreferenceFragmentCompat { }); findPreference(PREF_ABOUT).setOnPreferenceClickListener( preference -> { - getParentFragmentManager().beginTransaction().replace(R.id.content, new AboutFragment()) + getParentFragmentManager().beginTransaction() + .replace(R.id.settingsContainer, new AboutFragment()) .addToBackStack(getString(R.string.about_pref)).commit(); return true; } ); findPreference(STATISTICS).setOnPreferenceClickListener( preference -> { - getParentFragmentManager().beginTransaction().replace(R.id.content, new StatisticsFragment()) + getParentFragmentManager().beginTransaction() + .replace(R.id.settingsContainer, new StatisticsFragment()) .addToBackStack(getString(R.string.statistics_label)).commit(); return true; } @@ -117,7 +119,7 @@ public class MainPreferencesFragment extends PreferenceFragmentCompat { SearchPreference searchPreference = findPreference("searchPreference"); SearchConfiguration config = searchPreference.getSearchConfiguration(); config.setActivity((AppCompatActivity) getActivity()); - config.setFragmentContainerViewId(R.id.content); + config.setFragmentContainerViewId(R.id.settingsContainer); config.setBreadcrumbsEnabled(true); config.index(R.xml.preferences_user_interface) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/AboutFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/AboutFragment.java index 0a64bbe71..e85f60027 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/AboutFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/AboutFragment.java @@ -28,7 +28,8 @@ public class AboutFragment extends PreferenceFragmentCompat { return true; }); findPreference("about_contributors").setOnPreferenceClickListener((preference) -> { - getParentFragmentManager().beginTransaction().replace(R.id.content, new ContributorsPagerFragment()) + getParentFragmentManager().beginTransaction() + .replace(R.id.settingsContainer, new ContributorsPagerFragment()) .addToBackStack(getString(R.string.contributors)).commit(); return true; }); @@ -37,7 +38,8 @@ public class AboutFragment extends PreferenceFragmentCompat { return true; }); findPreference("about_licenses").setOnPreferenceClickListener((preference) -> { - getParentFragmentManager().beginTransaction().replace(R.id.content, new LicensesFragment()) + getParentFragmentManager().beginTransaction() + .replace(R.id.settingsContainer, new LicensesFragment()) .addToBackStack(getString(R.string.translators)).commit(); return true; }); diff --git a/app/src/main/res/layout/feedsettings.xml b/app/src/main/res/layout/feedsettings.xml index ec53703ab..acd1089bd 100644 --- a/app/src/main/res/layout/feedsettings.xml +++ b/app/src/main/res/layout/feedsettings.xml @@ -15,7 +15,7 @@ android:elevation="4dp" android:id="@+id/toolbar"/> - +