Use SettingsScreenType in plugins

This commit is contained in:
Vitaliy 2020-10-12 13:29:21 +03:00
parent 267d1374b5
commit 65de824b55
8 changed files with 34 additions and 30 deletions

View file

@ -8,9 +8,9 @@ import androidx.annotation.NonNull;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
import java.io.IOException;
import java.util.HashMap;
@ -71,8 +71,8 @@ public class AccessibilityPlugin extends OsmandPlugin {
}
@Override
public Class<? extends BaseSettingsFragment> getSettingsFragment() {
return AccessibilitySettingsFragment.class;
public SettingsScreenType getSettingsScreenType() {
return SettingsScreenType.ACCESSIBILITY_SETTINGS;
}
@Override

View file

@ -46,10 +46,9 @@ import net.osmand.plus.quickaction.QuickActionType;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.search.QuickSearchDialogFragment;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
import net.osmand.plus.skimapsplugin.SkiMapsPlugin;
import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.views.OsmandMapTileView;
@ -116,7 +115,7 @@ public abstract class OsmandPlugin {
return null;
}
public Class<? extends BaseSettingsFragment> getSettingsFragment() {
public SettingsScreenType getSettingsScreenType() {
return null;
}

View file

@ -66,7 +66,7 @@ import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.quickaction.QuickActionType;
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
import net.osmand.plus.views.layers.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
@ -1805,8 +1805,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
@Override
public Class<? extends BaseSettingsFragment> getSettingsFragment() {
return MultimediaNotesFragment.class;
public SettingsScreenType getSettingsScreenType() {
return SettingsScreenType.MULTIMEDIA_NOTES;
}
@Override

View file

@ -14,7 +14,7 @@ import net.osmand.plus.Version;
import net.osmand.plus.activities.ContributionVersionActivity;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
import net.osmand.plus.views.layers.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
@ -127,8 +127,8 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
}
@Override
public Class<? extends BaseSettingsFragment> getSettingsFragment() {
return DevelopmentSettingsFragment.class;
public SettingsScreenType getSettingsScreenType() {
return SettingsScreenType.DEVELOPMENT_SETTINGS;
}
@Override

View file

@ -42,7 +42,7 @@ import net.osmand.plus.activities.SavingTrackHelper.SaveGpxResult;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.layers.MapInfoLayer;
@ -173,8 +173,8 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
}
@Override
public Class<? extends BaseSettingsFragment> getSettingsFragment() {
return MonitoringSettingsFragment.class;
public SettingsScreenType getSettingsScreenType() {
return SettingsScreenType.MONITORING_SETTINGS;
}
@Override

View file

@ -13,9 +13,11 @@ import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.data.Amenity;
@ -23,13 +25,11 @@ import net.osmand.data.MapObject;
import net.osmand.data.TransportStop;
import net.osmand.osm.PoiType;
import net.osmand.osm.edit.Entity;
import net.osmand.plus.*;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.EnumAdapter;
import net.osmand.plus.activities.EnumAdapter.IEnumWithResource;
@ -42,16 +42,21 @@ import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.osmedit.OsmPoint.Action;
import net.osmand.plus.quickaction.QuickActionType;
import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import java.util.ArrayList;
import java.util.List;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.*;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_CREATE_POI;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_OPEN_OSM_NOTE;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_EDITS;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_NOTES;
import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction;
@ -198,8 +203,8 @@ public class OsmEditingPlugin extends OsmandPlugin {
}
@Override
public Class<? extends BaseSettingsFragment> getSettingsFragment() {
return OsmEditingFragment.class;
public SettingsScreenType getSettingsScreenType() {
return SettingsScreenType.OPEN_STREET_MAP_EDITING;
}
@Override

View file

@ -53,11 +53,7 @@ import com.google.android.material.snackbar.Snackbar;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.access.AccessibilitySettingsFragment;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
@ -69,6 +65,10 @@ import net.osmand.plus.monitoring.MonitoringSettingsFragment;
import net.osmand.plus.osmedit.OsmEditingFragment;
import net.osmand.plus.profiles.SelectAppModesBottomSheetDialogFragment;
import net.osmand.plus.profiles.SelectAppModesBottomSheetDialogFragment.AppModeChangedListener;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet;
import net.osmand.plus.settings.bottomsheets.ChangeGeneralProfilesPrefBottomSheet;
import net.osmand.plus.settings.bottomsheets.EditTextPreferenceBottomSheet;
@ -112,7 +112,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
public enum SettingsScreenType {
MAIN_SETTINGS(MainSettingsFragment.TAG, false, null, R.xml.settings_main_screen, R.layout.global_preference_toolbar),
MAIN_SETTINGS(MainSettingsFragment.class.getName(), false, null, R.xml.settings_main_screen, R.layout.global_preference_toolbar),
GLOBAL_SETTINGS(GlobalSettingsFragment.class.getName(), false, null, R.xml.global_settings, R.layout.global_preference_toolbar),
CONFIGURE_PROFILE(ConfigureProfileFragment.class.getName(), true, null, R.xml.configure_profile, R.layout.profile_preference_toolbar_with_switch),
PROXY_SETTINGS(ProxySettingsFragment.class.getName(), false, null, R.xml.proxy_preferences, R.layout.global_preferences_toolbar_with_switch),

View file

@ -368,7 +368,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
}
List<OsmandPlugin> plugins = OsmandPlugin.getVisiblePlugins();
for (OsmandPlugin plugin : plugins) {
if (plugin instanceof SkiMapsPlugin || plugin instanceof NauticalMapsPlugin || plugin.getSettingsFragment() == null) {
if (plugin instanceof SkiMapsPlugin || plugin instanceof NauticalMapsPlugin || plugin.getSettingsScreenType() == null) {
continue;
}
Preference preference = new Preference(ctx);
@ -378,7 +378,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
preference.setSummary(plugin.getPrefsDescription());
preference.setIcon(getContentIcon(plugin.getLogoResourceId()));
preference.setLayoutResource(R.layout.preference_with_descr);
preference.setFragment(plugin.getSettingsFragment().getName());
preference.setFragment(plugin.getSettingsScreenType().fragmentName);
preferenceCategory.addPreference(preference);
}