From 7ba46570a017a583293fc8207e2f2fef0f842537 Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Sat, 7 Nov 2020 15:39:50 +0200 Subject: [PATCH] Switch customize --- OsmAnd/res/drawable/layout_bg_dark.xml | 6 + OsmAnd/res/drawable/layout_bg_dark_solid.xml | 6 + OsmAnd/res/drawable/layout_bg_solid.xml | 6 + OsmAnd/res/layout/send_osm_note_fragment.xml | 18 +- OsmAnd/res/layout/send_poi_fragment.xml | 11 +- .../SendOsmNoteBottomSheetFragment.java | 185 +++++++++--------- .../dialogs/SendPoiBottomSheetFragment.java | 22 ++- 7 files changed, 154 insertions(+), 100 deletions(-) create mode 100644 OsmAnd/res/drawable/layout_bg_dark.xml create mode 100644 OsmAnd/res/drawable/layout_bg_dark_solid.xml create mode 100644 OsmAnd/res/drawable/layout_bg_solid.xml diff --git a/OsmAnd/res/drawable/layout_bg_dark.xml b/OsmAnd/res/drawable/layout_bg_dark.xml new file mode 100644 index 0000000000..f821ad3078 --- /dev/null +++ b/OsmAnd/res/drawable/layout_bg_dark.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/OsmAnd/res/drawable/layout_bg_dark_solid.xml b/OsmAnd/res/drawable/layout_bg_dark_solid.xml new file mode 100644 index 0000000000..59a1c38141 --- /dev/null +++ b/OsmAnd/res/drawable/layout_bg_dark_solid.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/layout_bg_solid.xml b/OsmAnd/res/drawable/layout_bg_solid.xml new file mode 100644 index 0000000000..0824ba1b7b --- /dev/null +++ b/OsmAnd/res/drawable/layout_bg_solid.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/send_osm_note_fragment.xml b/OsmAnd/res/layout/send_osm_note_fragment.xml index b6f4338751..4ce16dc2e8 100644 --- a/OsmAnd/res/layout/send_osm_note_fragment.xml +++ b/OsmAnd/res/layout/send_osm_note_fragment.xml @@ -21,8 +21,10 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" - android:textSize="@dimen/default_desc_text_size" - android:text = "@string/osm_notes" /> + android:textSize="@dimen/default_list_text_size" + osmand:typeface="@string/font_roboto_medium" + android:text = "@string/osm_notes" + android:letterSpacing="@dimen/text_button_letter_spacing"/> + android:paddingBottom="@dimen/content_padding_small" + android:paddingTop="@dimen/content_padding_small" + android:text="@string/upload_anonymously" + android:textColor="?android:textColorPrimary" + android:textSize="@dimen/default_list_text_size" + android:letterSpacing="@dimen/text_button_letter_spacing" + osmand:typeface="@string/font_roboto_regular"/> diff --git a/OsmAnd/res/layout/send_poi_fragment.xml b/OsmAnd/res/layout/send_poi_fragment.xml index 692bd5dd5d..dbc4766d52 100644 --- a/OsmAnd/res/layout/send_poi_fragment.xml +++ b/OsmAnd/res/layout/send_poi_fragment.xml @@ -22,7 +22,9 @@ android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:text="@string/upload_poi" - android:textSize="@dimen/default_desc_text_size" /> + android:textSize="@dimen/default_list_text_size" + osmand:typeface="@string/font_roboto_medium" + android:letterSpacing="@dimen/text_button_letter_spacing"/> + android:paddingLeft="50dp" + android:textColor="?android:textColorPrimary" + android:textSize="@dimen/default_list_text_size" + osmand:typeface="@string/font_roboto_regular" + android:letterSpacing="@dimen/text_button_letter_spacing"/> diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendOsmNoteBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendOsmNoteBottomSheetFragment.java index be0fe84ca4..70f4846f0e 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendOsmNoteBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendOsmNoteBottomSheetFragment.java @@ -1,5 +1,6 @@ package net.osmand.plus.osmedit.dialogs; +import android.content.Context; import android.os.Bundle; import android.view.View; import android.widget.CompoundButton; @@ -22,100 +23,108 @@ import net.osmand.plus.settings.backend.OsmandSettings; public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragment { - public static final String TAG = "SendPoiBottomSheetFragment"; - public static final String OPENSTREETMAP_POINT = "openstreetmap_point"; - public static final String POI_UPLOADER_TYPE = "poi_uploader_type"; - private OsmPoint[] poi; + public static final String TAG = "SendPoiBottomSheetFragment"; + public static final String OPENSTREETMAP_POINT = "openstreetmap_point"; + public static final String POI_UPLOADER_TYPE = "poi_uploader_type"; + private OsmPoint[] poi; - protected OsmandSettings settings; + protected OsmandSettings settings; - public enum PoiUploaderType { - SIMPLE, - FRAGMENT - } + public enum PoiUploaderType { + SIMPLE, + FRAGMENT + } - protected OsmandApplication getMyApplication() { - return (OsmandApplication) getActivity().getApplication(); - } + protected OsmandApplication getMyApplication() { + return (OsmandApplication) getActivity().getApplication(); + } - @Override - public void createMenuItems(Bundle savedInstanceState) { - String userName = getMyApplication().getSettings().USER_DISPLAY_NAME.get(); - final View sendOsmNoteView = View.inflate(getContext(), R.layout.send_osm_note_fragment, null); - final LinearLayout accountBlockView = (LinearLayout) sendOsmNoteView.findViewById(R.id.account_block); - final SwitchCompat uploadAnonymously = (SwitchCompat) sendOsmNoteView.findViewById(R.id.upload_anonymously_switch); - final TextView accountName = (TextView) sendOsmNoteView.findViewById(R.id.user_name); - accountName.setText(userName); - accountBlockView.setVisibility(View.VISIBLE); - uploadAnonymously.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - accountBlockView.setVisibility(isChecked ? View.GONE : View.VISIBLE); - } - }); - final SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder() - .setCustomView(sendOsmNoteView) - .create(); - items.add(titleItem); - } + @Override + public void createMenuItems(Bundle savedInstanceState) { + final boolean isNightMode = !getMyApplication().getSettings().isLightContent(); + final View sendOsmNoteView = View.inflate(getContext(), R.layout.send_osm_note_fragment, null); + final LinearLayout accountBlockView = sendOsmNoteView.findViewById(R.id.account_block); + final SwitchCompat uploadAnonymously = sendOsmNoteView.findViewById(R.id.upload_anonymously_switch); + final TextView accountName = sendOsmNoteView.findViewById(R.id.user_name); + String userName = getMyApplication().getSettings().USER_DISPLAY_NAME.get(); + accountName.setText(userName); + accountBlockView.setVisibility(View.VISIBLE); + uploadAnonymously.setBackgroundResource(isNightMode ? R.drawable.layout_bg_dark : R.drawable.layout_bg); + uploadAnonymously.setPadding(30, 0, 0, 0); + uploadAnonymously.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + accountBlockView.setVisibility(isChecked ? View.GONE : View.VISIBLE); + if (isNightMode) { + uploadAnonymously.setBackgroundResource(isChecked ? R.drawable.layout_bg_dark_solid : R.drawable.layout_bg_dark); + } else { + uploadAnonymously.setBackgroundResource(isChecked ? R.drawable.layout_bg_solid : R.drawable.layout_bg); + } + uploadAnonymously.setPadding(30, 0, 0, 0); + } + }); + final SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder() + .setCustomView(sendOsmNoteView) + .create(); + items.add(titleItem); + } - public static SendOsmNoteBottomSheetFragment showInstance(@NonNull OsmPoint[] points, @NonNull PoiUploaderType uploaderType) { - SendOsmNoteBottomSheetFragment fragment = new SendOsmNoteBottomSheetFragment(); - Bundle bundle = new Bundle(); - bundle.putSerializable(OPENSTREETMAP_POINT, points); - bundle.putString(POI_UPLOADER_TYPE, uploaderType.name()); - fragment.setArguments(bundle); - return fragment; - } + public static SendOsmNoteBottomSheetFragment showInstance(@NonNull OsmPoint[] points, @NonNull PoiUploaderType uploaderType) { + SendOsmNoteBottomSheetFragment fragment = new SendOsmNoteBottomSheetFragment(); + Bundle bundle = new Bundle(); + bundle.putSerializable(OPENSTREETMAP_POINT, points); + bundle.putString(POI_UPLOADER_TYPE, uploaderType.name()); + fragment.setArguments(bundle); + return fragment; + } - @Override - protected UiUtilities.DialogButtonType getRightBottomButtonType() { - return (UiUtilities.DialogButtonType.PRIMARY); - } + @Override + protected UiUtilities.DialogButtonType getRightBottomButtonType() { + return (UiUtilities.DialogButtonType.PRIMARY); + } - @Override - protected void onRightBottomButtonClick() { - View view = getView(); - poi = (OsmPoint[]) getArguments().getSerializable(OPENSTREETMAP_POINT); - boolean hasPoiGroup = false; - assert poi != null; - for (OsmPoint p : poi) { - if (p.getGroup() == OsmPoint.Group.POI) { - hasPoiGroup = true; - break; - } - } - final boolean hasPOI = hasPoiGroup; - final SwitchCompat uploadAnonymously = (SwitchCompat) view.findViewById(R.id.upload_anonymously_switch); - final EditText messageEditText = (EditText) view.findViewById(R.id.message_field); - final SendPoiDialogFragment.PoiUploaderType poiUploaderType = SendPoiDialogFragment.PoiUploaderType.valueOf(getArguments().getString(POI_UPLOADER_TYPE, SendPoiDialogFragment.PoiUploaderType.SIMPLE.name())); - final SendPoiDialogFragment.ProgressDialogPoiUploader progressDialogPoiUploader; - if (poiUploaderType == SendPoiDialogFragment.PoiUploaderType.SIMPLE && getActivity() instanceof MapActivity) { - progressDialogPoiUploader = - new SendPoiDialogFragment.SimpleProgressDialogPoiUploader((MapActivity) getActivity()); - } else { - progressDialogPoiUploader = (SendPoiDialogFragment.ProgressDialogPoiUploader) getParentFragment(); - } - if (progressDialogPoiUploader != null) { - String comment = messageEditText.getText().toString(); - if (comment.length() > 0) { - for (OsmPoint osmPoint : poi) { - if (osmPoint.getGroup() == OsmPoint.Group.POI) { - ((OpenstreetmapPoint) osmPoint).setComment(comment); - break; - } - } - } - progressDialogPoiUploader.showProgressDialog(poi, - false, - !hasPOI && uploadAnonymously.isChecked()); - } - dismiss(); - } - - @Override - protected int getRightBottomButtonTextId() { - return R.string.shared_string_upload; - } + @Override + protected void onRightBottomButtonClick() { + View view = getView(); + poi = (OsmPoint[]) getArguments().getSerializable(OPENSTREETMAP_POINT); + boolean hasPoiGroup = false; + assert poi != null; + for (OsmPoint p : poi) { + if (p.getGroup() == OsmPoint.Group.POI) { + hasPoiGroup = true; + break; + } + } + final boolean hasPOI = hasPoiGroup; + final SwitchCompat uploadAnonymously = (SwitchCompat) view.findViewById(R.id.upload_anonymously_switch); + final EditText messageEditText = (EditText) view.findViewById(R.id.message_field); + final SendPoiDialogFragment.PoiUploaderType poiUploaderType = SendPoiDialogFragment.PoiUploaderType.valueOf(getArguments().getString(POI_UPLOADER_TYPE, SendPoiDialogFragment.PoiUploaderType.SIMPLE.name())); + final SendPoiDialogFragment.ProgressDialogPoiUploader progressDialogPoiUploader; + if (poiUploaderType == SendPoiDialogFragment.PoiUploaderType.SIMPLE && getActivity() instanceof MapActivity) { + progressDialogPoiUploader = + new SendPoiDialogFragment.SimpleProgressDialogPoiUploader((MapActivity) getActivity()); + } else { + progressDialogPoiUploader = (SendPoiDialogFragment.ProgressDialogPoiUploader) getParentFragment(); + } + if (progressDialogPoiUploader != null) { + String comment = messageEditText.getText().toString(); + if (comment.length() > 0) { + for (OsmPoint osmPoint : poi) { + if (osmPoint.getGroup() == OsmPoint.Group.POI) { + ((OpenstreetmapPoint) osmPoint).setComment(comment); + break; + } + } + } + progressDialogPoiUploader.showProgressDialog(poi, + false, + !hasPOI && uploadAnonymously.isChecked()); + } + dismiss(); + } + @Override + protected int getRightBottomButtonTextId() { + return R.string.shared_string_upload; + } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiBottomSheetFragment.java index 17c29f5875..8270891c50 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiBottomSheetFragment.java @@ -2,6 +2,7 @@ package net.osmand.plus.osmedit.dialogs; import android.os.Bundle; import android.view.View; +import android.widget.CompoundButton; import android.widget.EditText; import android.widget.TextView; @@ -35,12 +36,27 @@ public class SendPoiBottomSheetFragment extends MenuBottomSheetDialogFragment { @Override public void createMenuItems(Bundle savedInstanceState) { + final boolean isNightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls(); + final View sendOsmPoiView = View.inflate(getContext(), R.layout.send_poi_fragment, null); + final SwitchCompat closeChangset = sendOsmPoiView.findViewById(R.id.close_change_set_checkbox); + final TextView accountName = (TextView) sendOsmPoiView.findViewById(R.id.user_name); String userName = getMyApplication().getSettings().USER_DISPLAY_NAME.get(); - final View sendOsmNoteView = View.inflate(getContext(), R.layout.send_poi_fragment, null); - final TextView accountName = (TextView) sendOsmNoteView.findViewById(R.id.user_name); accountName.setText(userName); + closeChangset.setBackgroundResource(isNightMode ? R.drawable.layout_bg_dark : R.drawable.layout_bg); + closeChangset.setPadding(30, 0, 0, 0); + closeChangset.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (isNightMode) { + closeChangset.setBackgroundResource(isChecked ? R.drawable.layout_bg_dark_solid : R.drawable.layout_bg_dark); + } else { + closeChangset.setBackgroundResource(isChecked ? R.drawable.layout_bg_solid : R.drawable.layout_bg); + } + closeChangset.setPadding(30, 0, 0, 0); + } + }); final SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder() - .setCustomView(sendOsmNoteView) + .setCustomView(sendOsmPoiView) .create(); items.add(titleItem); }