Add settings and items to menu

This commit is contained in:
Alexander Sytnyk 2017-09-19 17:56:03 +03:00
parent 316cd51776
commit b5f826f886
3 changed files with 118 additions and 17 deletions

View file

@ -115,6 +115,67 @@
</LinearLayout>
<LinearLayout
android:id="@+id/show_arrows_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:descendantFocusability="blocksDescendants"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/show_arrows_on_the_map"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/show_arrows_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:clickable="false"/>
</LinearLayout>
<LinearLayout
android:id="@+id/show_guide_line_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/show_guide_line"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/show_guide_line_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:clickable="false"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="@dimen/bottom_sheet_content_padding_small"
android:background="?attr/dashboard_divider"/>
<RelativeLayout
android:id="@+id/top_bar_row"
android:layout_width="match_parent"
@ -148,15 +209,15 @@
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<RadioButton
android:focusable="false"
android:clickable="false"
android:background="@null"
android:id="@+id/top_bar_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</RelativeLayout>
<RelativeLayout
@ -192,15 +253,15 @@
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<RadioButton
android:focusable="false"
android:clickable="false"
android:background="@null"
android:id="@+id/widget_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</RelativeLayout>
<RelativeLayout
@ -235,15 +296,15 @@
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<RadioButton
android:focusable="false"
android:clickable="false"
android:background="@null"
android:id="@+id/none_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</RelativeLayout>
</LinearLayout>

View file

@ -9,6 +9,8 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="show_guide_line">Show guide line</string>
<string name="show_arrows_on_the_map">Show arrows on the map</string>
<string name="show_passed">Show passed</string>
<string name="hide_passed">Hide passed</string>
<string name="remove_from_map_markers">Remove from Map Markers</string>

View file

@ -1,5 +1,6 @@
package net.osmand.plus.mapmarkers;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
@ -12,6 +13,7 @@ import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.TextView;
@ -19,6 +21,7 @@ import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
@ -38,8 +41,9 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final OsmandSettings settings = getMyApplication().getSettings();
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
night = !getMyApplication().getSettings().isLightContent();
night = !settings.isLightContent();
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_show_direction_bottom_sheet_dialog, container);
@ -47,7 +51,7 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
}
OsmandSettings.MapMarkersMode mode = getMyApplication().getSettings().MAP_MARKERS_MODE.get();
OsmandSettings.MapMarkersMode mode = settings.MAP_MARKERS_MODE.get();
highlightSelectedItem(mode, true);
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
@ -84,6 +88,32 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
((TextView) mainView.findViewById(R.id.show_direction_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
}
CompoundButton showArrowsToggle = (CompoundButton) mainView.findViewById(R.id.show_arrows_switch);
showArrowsToggle.setChecked(settings.SHOW_ARROWS_TO_FIRST_MARKERS.get());
mainView.findViewById(R.id.show_arrows_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
settings.SHOW_ARROWS_TO_FIRST_MARKERS.set(!settings.SHOW_ARROWS_TO_FIRST_MARKERS.get());
if (getMapActivity() != null) {
getMapActivity().refreshMap();
}
dismiss();
}
});
CompoundButton showLinesToggle = (CompoundButton) mainView.findViewById(R.id.show_guide_line_switch);
showLinesToggle.setChecked(settings.SHOW_LINES_TO_FIRST_MARKERS.get());
mainView.findViewById(R.id.show_guide_line_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
settings.SHOW_LINES_TO_FIRST_MARKERS.set(!settings.SHOW_LINES_TO_FIRST_MARKERS.get());
if (getMapActivity() != null) {
getMapActivity().refreshMap();
}
dismiss();
}
});
ImageView topBarIcon = (ImageView) mainView.findViewById(R.id.top_bar_icon);
topBarIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, R.color.on_map_icon_color));
topBarIcon.setImageDrawable(getIcon(R.drawable.ic_action_device_topbar, R.color.dashboard_blue));
@ -157,6 +187,14 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
}
}
private MapActivity getMapActivity() {
Activity activity = getActivity();
if (activity != null) {
return (MapActivity) activity;
}
return null;
}
private void highlightSelectedItem(OsmandSettings.MapMarkersMode mode, boolean check) {
int iconBgColor = check ? R.color.dashboard_blue : R.color.on_map_icon_color;
int iconColor = check ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue;