Add functionality to the new screen; make all markers settings profile
This commit is contained in:
parent
ed1e04f6af
commit
1e3ca4a21b
5 changed files with 57 additions and 19 deletions
|
@ -713,8 +713,8 @@ public class OsmandSettings {
|
|||
|
||||
public final CommonPreference<RulerMode> RULER_MODE = new EnumIntPreference<>("ruler_mode", RulerMode.FIRST, RulerMode.values()).makeGlobal();
|
||||
|
||||
public final CommonPreference<Boolean> SHOW_LINES_TO_FIRST_MARKERS = new BooleanPreference("show_lines_to_first_markers", false).makeGlobal();
|
||||
public final CommonPreference<Boolean> SHOW_ARROWS_TO_FIRST_MARKERS = new BooleanPreference("show_arrows_to_first_markers", false).makeGlobal();
|
||||
public final CommonPreference<Boolean> SHOW_LINES_TO_FIRST_MARKERS = new BooleanPreference("show_lines_to_first_markers", false).makeProfile();
|
||||
public final CommonPreference<Boolean> SHOW_ARROWS_TO_FIRST_MARKERS = new BooleanPreference("show_arrows_to_first_markers", false).makeProfile();
|
||||
|
||||
public final CommonPreference<Boolean> USE_MAPILLARY_FILTER = new BooleanPreference("use_mapillary_filters", false).makeGlobal();
|
||||
public final CommonPreference<String> MAPILLARY_FILTER_USER_KEY = new StringPreference("mapillary_filter_user_key", "").makeGlobal();
|
||||
|
@ -1315,7 +1315,7 @@ public class OsmandSettings {
|
|||
|
||||
public final OsmandPreference<Boolean> USE_MAP_MARKERS = new BooleanPreference("use_map_markers", true).makeGlobal().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> MARKERS_DISTANCE_INDICATION_ENABLED = new BooleanPreference("markers_distance_indication_enabled", true).makeGlobal();
|
||||
public final OsmandPreference<Boolean> MARKERS_DISTANCE_INDICATION_ENABLED = new BooleanPreference("markers_distance_indication_enabled", true).makeProfile();
|
||||
|
||||
public final CommonPreference<MapMarkersMode> MAP_MARKERS_MODE =
|
||||
new EnumIntPreference<>("map_markers_mode", MapMarkersMode.TOOLBAR, MapMarkersMode.values());
|
||||
|
|
|
@ -26,8 +26,13 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
|
|||
|
||||
public final static String TAG = "DirectionIndicationDialogFragment";
|
||||
|
||||
private DirectionIndicationFragmentListener listener;
|
||||
private View mainView;
|
||||
|
||||
public void setListener(DirectionIndicationFragmentListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
@ -50,11 +55,27 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
updateChecked(settings.MARKERS_DISTANCE_INDICATION_ENABLED, distanceIndicationToggle);
|
||||
updateSelection();
|
||||
updateSelection(true);
|
||||
}
|
||||
});
|
||||
|
||||
updateSelection();
|
||||
mainView.findViewById(R.id.top_bar_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
settings.MAP_MARKERS_MODE.set(MapMarkersMode.TOOLBAR);
|
||||
updateSelection(true);
|
||||
}
|
||||
});
|
||||
|
||||
mainView.findViewById(R.id.widget_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
settings.MAP_MARKERS_MODE.set(MapMarkersMode.WIDGETS);
|
||||
updateSelection(true);
|
||||
}
|
||||
});
|
||||
|
||||
updateSelection(false);
|
||||
|
||||
final CompoundButton showArrowsToggle = (CompoundButton) mainView.findViewById(R.id.show_arrows_switch);
|
||||
showArrowsToggle.setChecked(settings.SHOW_ARROWS_TO_FIRST_MARKERS.get());
|
||||
|
@ -99,16 +120,25 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
|
|||
}
|
||||
}
|
||||
|
||||
private void updateSelection() {
|
||||
private void notifyListener() {
|
||||
if (listener != null) {
|
||||
listener.onMapMarkersModeChanged(getSettings().MARKERS_DISTANCE_INDICATION_ENABLED.get());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSelection(boolean notifyListener) {
|
||||
OsmandSettings settings = getSettings();
|
||||
MapMarkersMode mode = settings.MAP_MARKERS_MODE.get();
|
||||
boolean distanceIndicationEnabled = settings.MARKERS_DISTANCE_INDICATION_ENABLED.get();
|
||||
boolean distIndEnabled = settings.MARKERS_DISTANCE_INDICATION_ENABLED.get();
|
||||
boolean topBar = mode == MapMarkersMode.TOOLBAR;
|
||||
boolean widget = mode == MapMarkersMode.WIDGETS;
|
||||
updateIcon(R.id.top_bar_icon, R.drawable.ic_action_device_topbar, topBar && distanceIndicationEnabled);
|
||||
updateIcon(R.id.widget_icon, R.drawable.ic_action_device_widget, widget && distanceIndicationEnabled);
|
||||
updateRadioButton(R.id.top_bar_radio_button, topBar, distanceIndicationEnabled);
|
||||
updateRadioButton(R.id.widget_radio_button, widget, distanceIndicationEnabled);
|
||||
updateIcon(R.id.top_bar_icon, R.drawable.ic_action_device_topbar, topBar && distIndEnabled);
|
||||
updateIcon(R.id.widget_icon, R.drawable.ic_action_device_widget, widget && distIndEnabled);
|
||||
updateMarkerModeRow(R.id.top_bar_row, R.id.top_bar_radio_button, topBar, distIndEnabled);
|
||||
updateMarkerModeRow(R.id.widget_row, R.id.widget_radio_button, widget, distIndEnabled);
|
||||
if (notifyListener) {
|
||||
notifyListener();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateIcon(int imageViewId, int drawableId, boolean active) {
|
||||
|
@ -121,12 +151,17 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
|
|||
: getContentIcon(drawableId));
|
||||
}
|
||||
|
||||
private void updateRadioButton(int radioButtonId, boolean checked, boolean active) {
|
||||
private void updateMarkerModeRow(int rowId, int radioButtonId, boolean checked, boolean active) {
|
||||
boolean night = !getSettings().isLightContent();
|
||||
RadioButton rb = (RadioButton) mainView.findViewById(radioButtonId);
|
||||
rb.setChecked(checked);
|
||||
int colorId = active ? night ? R.color.osmand_orange : R.color.dashboard_blue
|
||||
: night ? R.color.ctx_menu_info_text_dark : R.color.icon_color;
|
||||
CompoundButtonCompat.setButtonTintList(rb, ColorStateList.valueOf(ContextCompat.getColor(getContext(), colorId)));
|
||||
mainView.findViewById(rowId).setEnabled(active);
|
||||
}
|
||||
|
||||
public interface DirectionIndicationFragmentListener {
|
||||
void onMapMarkersModeChanged(boolean showDirectionEnabled);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.TrackActivity;
|
||||
import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.OnMapMarkersSavedListener;
|
||||
import net.osmand.plus.mapmarkers.DirectionIndicationDialogFragment.DirectionIndicationFragmentListener;
|
||||
import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener;
|
||||
import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener;
|
||||
import net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener;
|
||||
import net.osmand.plus.mapmarkers.ShowDirectionBottomSheetDialogFragment.ShowDirectionFragmentListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -99,9 +99,9 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
if (optionsFragment != null) {
|
||||
((OptionsBottomSheetDialogFragment) optionsFragment).setListener(createOptionsFragmentListener());
|
||||
}
|
||||
Fragment showDirectionFragment = fragmentManager.findFragmentByTag(ShowDirectionBottomSheetDialogFragment.TAG);
|
||||
if (showDirectionFragment != null) {
|
||||
((ShowDirectionBottomSheetDialogFragment) showDirectionFragment).setListener(createShowDirectionFragmentListener());
|
||||
Fragment directionIndicationFragment = fragmentManager.findFragmentByTag(DirectionIndicationDialogFragment.TAG);
|
||||
if (directionIndicationFragment != null) {
|
||||
((DirectionIndicationDialogFragment) directionIndicationFragment).setListener(createShowDirectionFragmentListener());
|
||||
}
|
||||
final Fragment orderByFragment = fragmentManager.findFragmentByTag(OrderByBottomSheetDialogFragment.TAG);
|
||||
if (orderByFragment != null) {
|
||||
|
@ -246,6 +246,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
public void showDirectionOnClick() {
|
||||
if (mapActivity != null) {
|
||||
DirectionIndicationDialogFragment fragment = new DirectionIndicationDialogFragment();
|
||||
fragment.setListener(createShowDirectionFragmentListener());
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), DirectionIndicationDialogFragment.TAG);
|
||||
}
|
||||
}
|
||||
|
@ -317,8 +318,8 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
};
|
||||
}
|
||||
|
||||
private ShowDirectionFragmentListener createShowDirectionFragmentListener() {
|
||||
return new ShowDirectionFragmentListener() {
|
||||
private DirectionIndicationFragmentListener createShowDirectionFragmentListener() {
|
||||
return new DirectionIndicationFragmentListener() {
|
||||
|
||||
final MapActivity mapActivity = getMapActivity();
|
||||
|
||||
|
|
|
@ -201,6 +201,7 @@ public class MapMarkersWidgetsFactory {
|
|||
|
||||
List<MapMarker> markers = helper.getMapMarkers();
|
||||
if (zoom < 3 || markers.size() == 0
|
||||
|| !map.getMyApplication().getSettings().MARKERS_DISTANCE_INDICATION_ENABLED.get()
|
||||
|| !map.getMyApplication().getSettings().MAP_MARKERS_MODE.get().isToolbar()
|
||||
|| map.getMyApplication().getRoutingHelper().isFollowingMode()
|
||||
|| map.getMyApplication().getRoutingHelper().isRoutePlanningMode()
|
||||
|
|
|
@ -347,7 +347,8 @@ public class MapWidgetRegistry {
|
|||
public void updateMapMarkersMode(MapActivity mapActivity) {
|
||||
for (MapWidgetRegInfo info : rightWidgetSet) {
|
||||
if ("map_marker_1st".equals(info.key) || "map_marker_2nd".equals(info.key)) {
|
||||
setVisibility(info, settings.MAP_MARKERS_MODE.get().isWidgets(), false);
|
||||
setVisibility(info, settings.MAP_MARKERS_MODE.get().isWidgets()
|
||||
&& settings.MARKERS_DISTANCE_INDICATION_ENABLED.get(), false);
|
||||
}
|
||||
}
|
||||
MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer();
|
||||
|
|
Loading…
Reference in a new issue