diff --git a/OsmAnd/res/layout/profile_preference_toolbar.xml b/OsmAnd/res/layout/profile_preference_toolbar.xml index b76eb61696..6776a7a70c 100644 --- a/OsmAnd/res/layout/profile_preference_toolbar.xml +++ b/OsmAnd/res/layout/profile_preference_toolbar.xml @@ -64,6 +64,13 @@ tools:text="Some description" /> + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/access/AccessibilitySettingsFragment.java b/OsmAnd/src/net/osmand/access/AccessibilitySettingsFragment.java index 781a10bf41..609c43fcff 100644 --- a/OsmAnd/src/net/osmand/access/AccessibilitySettingsFragment.java +++ b/OsmAnd/src/net/osmand/access/AccessibilitySettingsFragment.java @@ -4,6 +4,8 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.provider.Settings; +import android.view.LayoutInflater; +import android.view.View; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener; import android.widget.ImageView; @@ -13,21 +15,24 @@ import androidx.preference.Preference; import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceViewHolder; -import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.access.AccessibilityMode; import net.osmand.plus.access.RelativeDirectionStyle; +import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.profiles.SelectCopyAppModeBottomSheet; import net.osmand.plus.profiles.SelectCopyAppModeBottomSheet.CopyAppModePrefsListener; -import net.osmand.plus.settings.fragments.BaseSettingsFragment; -import net.osmand.plus.settings.fragments.OnPreferenceChanged; +import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.bottomsheets.ResetProfilePrefsBottomSheet; import net.osmand.plus.settings.bottomsheets.ResetProfilePrefsBottomSheet.ResetAppModePrefsListener; +import net.osmand.plus.settings.fragments.BaseSettingsFragment; +import net.osmand.plus.settings.fragments.OnPreferenceChanged; import net.osmand.plus.settings.preferences.ListPreferenceEx; import net.osmand.plus.settings.preferences.SwitchPreferenceEx; +import static net.osmand.plus.activities.PluginInfoFragment.PLUGIN_INFO; + public class AccessibilitySettingsFragment extends BaseSettingsFragment implements OnPreferenceChanged, CopyAppModePrefsListener, ResetAppModePrefsListener { private static final String ACCESSIBILITY_OPTIONS = "accessibility_options"; @@ -36,6 +41,8 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen private AccessibilityStateChangeListener accessibilityListener; + boolean showSwitchProfile = false; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -47,6 +54,28 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen } } }; + + Bundle args = getArguments(); + if (args != null) { + showSwitchProfile = args.getBoolean(PLUGIN_INFO, false); + } + } + + @Override + protected void createToolbar(LayoutInflater inflater, View view) { + super.createToolbar(inflater, view); + + View switchProfile = view.findViewById(R.id.profile_button); + if (switchProfile != null) { + AndroidUiHelper.updateVisibility(switchProfile, showSwitchProfile); + } + } + + @Override + public Bundle buildArguments() { + Bundle args = super.buildArguments(); + args.putBoolean(PLUGIN_INFO, showSwitchProfile); + return args; } @Override diff --git a/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java b/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java index ff396a3ed0..7deb85768c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java @@ -45,6 +45,7 @@ public class PluginInfoFragment extends BaseOsmAndFragment implements PluginStat private static final String TAG = PluginInfoFragment.class.getName(); public static final String EXTRA_PLUGIN_ID = "plugin_id"; + public static final String PLUGIN_INFO = "plugin_info"; private OsmandPlugin plugin; private OsmandApplication app; @@ -135,7 +136,9 @@ public class PluginInfoFragment extends BaseOsmAndFragment implements PluginStat if (activity != null) { SettingsScreenType settingsScreenType = plugin.getSettingsScreenType(); if (settingsScreenType != null) { - BaseSettingsFragment.showInstance(activity, settingsScreenType); + Bundle args = new Bundle(); + args.putBoolean(PLUGIN_INFO, true); + BaseSettingsFragment.showInstance(activity, settingsScreenType, null, args); } } } diff --git a/OsmAnd/src/net/osmand/plus/audionotes/MultimediaNotesFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/MultimediaNotesFragment.java index 6996f7ee5b..4c1178ef61 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/MultimediaNotesFragment.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/MultimediaNotesFragment.java @@ -13,6 +13,8 @@ import android.os.Build; import android.os.Bundle; import android.os.StatFs; import android.text.SpannableString; +import android.view.LayoutInflater; +import android.view.View; import androidx.annotation.NonNull; import androidx.core.app.ActivityCompat; @@ -22,17 +24,18 @@ import androidx.preference.PreferenceViewHolder; import net.osmand.AndroidUtils; import net.osmand.PlatformUtil; -import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.OsmAndAppCustomization; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.FontCache; import net.osmand.plus.profiles.SelectCopyAppModeBottomSheet; import net.osmand.plus.profiles.SelectCopyAppModeBottomSheet.CopyAppModePrefsListener; -import net.osmand.plus.settings.fragments.BaseSettingsFragment; +import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.settings.backend.OsmAndAppCustomization; import net.osmand.plus.settings.bottomsheets.ResetProfilePrefsBottomSheet; import net.osmand.plus.settings.bottomsheets.ResetProfilePrefsBottomSheet.ResetAppModePrefsListener; +import net.osmand.plus.settings.fragments.BaseSettingsFragment; import net.osmand.plus.settings.preferences.ListPreferenceEx; import net.osmand.plus.settings.preferences.SwitchPreferenceEx; import net.osmand.plus.widgets.style.CustomTypefaceSpan; @@ -43,6 +46,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import static net.osmand.plus.activities.PluginInfoFragment.PLUGIN_INFO; import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AUDIO_BITRATE_DEFAULT; import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_AUTO; import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_CONTINUOUS; @@ -66,6 +70,35 @@ public class MultimediaNotesFragment extends BaseSettingsFragment implements Cop private static final String RESET_TO_DEFAULT = "reset_to_default"; private static final String OPEN_NOTES = "open_notes"; + boolean showSwitchProfile = false; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Bundle args = getArguments(); + if (args != null) { + showSwitchProfile = args.getBoolean(PLUGIN_INFO, false); + } + } + + @Override + protected void createToolbar(LayoutInflater inflater, View view) { + super.createToolbar(inflater, view); + + View switchProfile = view.findViewById(R.id.profile_button); + if (switchProfile != null) { + AndroidUiHelper.updateVisibility(switchProfile, showSwitchProfile); + } + } + + @Override + public Bundle buildArguments() { + Bundle args = super.buildArguments(); + args.putBoolean(PLUGIN_INFO, showSwitchProfile); + return args; + } + @Override protected void setupPreferences() { AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java index 901348a6d3..ae35fd767c 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java @@ -6,10 +6,13 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.text.SpannableString; import android.text.SpannableStringBuilder; +import android.view.LayoutInflater; +import android.view.View; import androidx.fragment.app.FragmentManager; import androidx.preference.Preference; +import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmAndAppCustomization; import net.osmand.plus.OsmandPlugin; @@ -32,6 +35,7 @@ import net.osmand.plus.widgets.style.CustomTypefaceSpan; import java.util.HashMap; import java.util.LinkedHashMap; +import static net.osmand.plus.activities.PluginInfoFragment.PLUGIN_INFO; import static net.osmand.plus.settings.backend.OsmandSettings.MONTHLY_DIRECTORY; import static net.osmand.plus.settings.backend.OsmandSettings.REC_DIRECTORY; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES; @@ -46,6 +50,35 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment private static final String OPEN_TRACKS = "open_tracks"; private static final String SAVE_GLOBAL_TRACK_INTERVAL = "save_global_track_interval"; + boolean showSwitchProfile = false; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Bundle args = getArguments(); + if (args != null) { + showSwitchProfile = args.getBoolean(PLUGIN_INFO, false); + } + } + + @Override + protected void createToolbar(LayoutInflater inflater, View view) { + super.createToolbar(inflater, view); + + View switchProfile = view.findViewById(R.id.profile_button); + if (switchProfile != null) { + AndroidUiHelper.updateVisibility(switchProfile, showSwitchProfile); + } + } + + @Override + public Bundle buildArguments() { + Bundle args = super.buildArguments(); + args.putBoolean(PLUGIN_INFO, showSwitchProfile); + return args; + } + @Override protected void setupPreferences() { setupSaveTrackToGpxPref(); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java index de995c2ea0..db12e7d781 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java @@ -899,9 +899,13 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl } public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, @Nullable ApplicationMode appMode) { + return showInstance(activity, screenType, null, new Bundle()); + } + + public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, + @Nullable ApplicationMode appMode, @NonNull Bundle args) { try { Fragment fragment = Fragment.instantiate(activity, screenType.fragmentName); - Bundle args = new Bundle(); if (appMode != null) { args.putString(APP_MODE_KEY, appMode.getStringKey()); }