Fix profile button visibility for plugin settings
This commit is contained in:
parent
834080be31
commit
3abbffa491
6 changed files with 117 additions and 8 deletions
|
@ -64,6 +64,13 @@
|
|||
tools:text="Some description" />
|
||||
</LinearLayout>
|
||||
|
||||
<include
|
||||
layout="@layout/profile_button_small"
|
||||
android:layout_width="@dimen/list_header_height"
|
||||
android:layout_height="@dimen/list_header_height"
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_marginRight="@dimen/content_padding_half" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.appcompat.widget.Toolbar>
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue