mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 04:53:36 +00:00
[android] Use material switch in all views
Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr> Co-authored-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr> Co-committed-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
@@ -15,14 +15,13 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AutoCompleteTextView;
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.GridLayout;
|
import android.widget.GridLayout;
|
||||||
import android.widget.Toast;
|
|
||||||
import androidx.annotation.CallSuper;
|
import androidx.annotation.CallSuper;
|
||||||
import androidx.annotation.DrawableRes;
|
import androidx.annotation.DrawableRes;
|
||||||
import androidx.annotation.IdRes;
|
import androidx.annotation.IdRes;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.appcompat.widget.SwitchCompat;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import app.organicmaps.R;
|
import app.organicmaps.R;
|
||||||
@@ -44,9 +43,9 @@ import app.organicmaps.util.Graphics;
|
|||||||
import app.organicmaps.util.InputUtils;
|
import app.organicmaps.util.InputUtils;
|
||||||
import app.organicmaps.util.UiUtils;
|
import app.organicmaps.util.UiUtils;
|
||||||
import com.google.android.material.button.MaterialButton;
|
import com.google.android.material.button.MaterialButton;
|
||||||
import com.google.android.material.card.MaterialCardView;
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
import com.google.android.material.imageview.ShapeableImageView;
|
import com.google.android.material.imageview.ShapeableImageView;
|
||||||
|
import com.google.android.material.materialswitch.MaterialSwitch;
|
||||||
import com.google.android.material.textfield.TextInputEditText;
|
import com.google.android.material.textfield.TextInputEditText;
|
||||||
import com.google.android.material.textfield.TextInputLayout;
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
import com.google.android.material.textview.MaterialTextView;
|
import com.google.android.material.textview.MaterialTextView;
|
||||||
@@ -117,9 +116,9 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
|
|||||||
private MaterialTextView mPhone;
|
private MaterialTextView mPhone;
|
||||||
private MaterialButton mEditPhoneLink;
|
private MaterialButton mEditPhoneLink;
|
||||||
private MaterialTextView mCuisine;
|
private MaterialTextView mCuisine;
|
||||||
private SwitchCompat mWifi;
|
private MaterialSwitch mWifi;
|
||||||
private MaterialTextView mSelfService;
|
private MaterialTextView mSelfService;
|
||||||
private SwitchCompat mOutdoorSeating;
|
private MaterialSwitch mOutdoorSeating;
|
||||||
|
|
||||||
// Default Metadata entries.
|
// Default Metadata entries.
|
||||||
private static final class MetadataEntry
|
private static final class MetadataEntry
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import android.widget.LinearLayout;
|
|||||||
import androidx.annotation.IdRes;
|
import androidx.annotation.IdRes;
|
||||||
import androidx.annotation.IntRange;
|
import androidx.annotation.IntRange;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.SwitchCompat;
|
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
@@ -25,6 +24,7 @@ import app.organicmaps.sdk.util.Utils;
|
|||||||
import app.organicmaps.util.UiUtils;
|
import app.organicmaps.util.UiUtils;
|
||||||
import com.google.android.material.button.MaterialButton;
|
import com.google.android.material.button.MaterialButton;
|
||||||
import com.google.android.material.checkbox.MaterialCheckBox;
|
import com.google.android.material.checkbox.MaterialCheckBox;
|
||||||
|
import com.google.android.material.materialswitch.MaterialSwitch;
|
||||||
import com.google.android.material.textview.MaterialTextView;
|
import com.google.android.material.textview.MaterialTextView;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -195,7 +195,7 @@ class SimpleTimetableAdapter extends RecyclerView.Adapter<SimpleTimetableAdapter
|
|||||||
|
|
||||||
SparseArray<MaterialCheckBox> days = new SparseArray<>(7);
|
SparseArray<MaterialCheckBox> days = new SparseArray<>(7);
|
||||||
View allday;
|
View allday;
|
||||||
SwitchCompat swAllday;
|
MaterialSwitch swAllday;
|
||||||
View schedule;
|
View schedule;
|
||||||
View openClose;
|
View openClose;
|
||||||
View open;
|
View open;
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.SwitchCompat;
|
|
||||||
|
import com.google.android.material.materialswitch.MaterialSwitch;
|
||||||
|
|
||||||
import app.organicmaps.R;
|
import app.organicmaps.R;
|
||||||
import app.organicmaps.base.BaseMwmToolbarFragment;
|
import app.organicmaps.base.BaseMwmToolbarFragment;
|
||||||
import app.organicmaps.sdk.routing.RoutingController;
|
import app.organicmaps.sdk.routing.RoutingController;
|
||||||
@@ -88,34 +90,34 @@ public class DrivingOptionsFragment extends BaseMwmToolbarFragment
|
|||||||
|
|
||||||
private void initViews(@NonNull View root)
|
private void initViews(@NonNull View root)
|
||||||
{
|
{
|
||||||
SwitchCompat tollsBtn = root.findViewById(R.id.avoid_tolls_btn);
|
MaterialSwitch tollsBtn = root.findViewById(R.id.avoid_tolls_btn);
|
||||||
tollsBtn.setChecked(RoutingOptions.hasOption(RoadType.Toll));
|
tollsBtn.setChecked(RoutingOptions.hasOption(RoadType.Toll));
|
||||||
CompoundButton.OnCheckedChangeListener tollBtnListener = new ToggleRoutingOptionListener(RoadType.Toll, root);
|
CompoundButton.OnCheckedChangeListener tollBtnListener = new ToggleRoutingOptionListener(RoadType.Toll, root);
|
||||||
tollsBtn.setOnCheckedChangeListener(tollBtnListener);
|
tollsBtn.setOnCheckedChangeListener(tollBtnListener);
|
||||||
|
|
||||||
SwitchCompat motorwaysBtn = root.findViewById(R.id.avoid_motorways_btn);
|
MaterialSwitch motorwaysBtn = root.findViewById(R.id.avoid_motorways_btn);
|
||||||
motorwaysBtn.setChecked(RoutingOptions.hasOption(RoadType.Motorway));
|
motorwaysBtn.setChecked(RoutingOptions.hasOption(RoadType.Motorway));
|
||||||
CompoundButton.OnCheckedChangeListener motorwayBtnListener =
|
CompoundButton.OnCheckedChangeListener motorwayBtnListener =
|
||||||
new ToggleRoutingOptionListener(RoadType.Motorway, root);
|
new ToggleRoutingOptionListener(RoadType.Motorway, root);
|
||||||
motorwaysBtn.setOnCheckedChangeListener(motorwayBtnListener);
|
motorwaysBtn.setOnCheckedChangeListener(motorwayBtnListener);
|
||||||
|
|
||||||
SwitchCompat ferriesBtn = root.findViewById(R.id.avoid_ferries_btn);
|
MaterialSwitch ferriesBtn = root.findViewById(R.id.avoid_ferries_btn);
|
||||||
ferriesBtn.setChecked(RoutingOptions.hasOption(RoadType.Ferry));
|
ferriesBtn.setChecked(RoutingOptions.hasOption(RoadType.Ferry));
|
||||||
CompoundButton.OnCheckedChangeListener ferryBtnListener = new ToggleRoutingOptionListener(RoadType.Ferry, root);
|
CompoundButton.OnCheckedChangeListener ferryBtnListener = new ToggleRoutingOptionListener(RoadType.Ferry, root);
|
||||||
ferriesBtn.setOnCheckedChangeListener(ferryBtnListener);
|
ferriesBtn.setOnCheckedChangeListener(ferryBtnListener);
|
||||||
|
|
||||||
SwitchCompat dirtyRoadsBtn = root.findViewById(R.id.avoid_dirty_roads_btn);
|
MaterialSwitch dirtyRoadsBtn = root.findViewById(R.id.avoid_dirty_roads_btn);
|
||||||
dirtyRoadsBtn.setChecked(RoutingOptions.hasOption(RoadType.Dirty));
|
dirtyRoadsBtn.setChecked(RoutingOptions.hasOption(RoadType.Dirty));
|
||||||
dirtyRoadsBtn.setEnabled(!RoutingOptions.hasOption(RoadType.Paved) || RoutingOptions.hasOption(RoadType.Dirty));
|
dirtyRoadsBtn.setEnabled(!RoutingOptions.hasOption(RoadType.Paved) || RoutingOptions.hasOption(RoadType.Dirty));
|
||||||
CompoundButton.OnCheckedChangeListener dirtyBtnListener = new ToggleRoutingOptionListener(RoadType.Dirty, root);
|
CompoundButton.OnCheckedChangeListener dirtyBtnListener = new ToggleRoutingOptionListener(RoadType.Dirty, root);
|
||||||
dirtyRoadsBtn.setOnCheckedChangeListener(dirtyBtnListener);
|
dirtyRoadsBtn.setOnCheckedChangeListener(dirtyBtnListener);
|
||||||
|
|
||||||
SwitchCompat stepsBtn = root.findViewById(R.id.avoid_steps_btn);
|
MaterialSwitch stepsBtn = root.findViewById(R.id.avoid_steps_btn);
|
||||||
stepsBtn.setChecked(RoutingOptions.hasOption(RoadType.Steps));
|
stepsBtn.setChecked(RoutingOptions.hasOption(RoadType.Steps));
|
||||||
CompoundButton.OnCheckedChangeListener stepsBtnListener = new ToggleRoutingOptionListener(RoadType.Steps, root);
|
CompoundButton.OnCheckedChangeListener stepsBtnListener = new ToggleRoutingOptionListener(RoadType.Steps, root);
|
||||||
stepsBtn.setOnCheckedChangeListener(stepsBtnListener);
|
stepsBtn.setOnCheckedChangeListener(stepsBtnListener);
|
||||||
|
|
||||||
SwitchCompat pavedBtn = root.findViewById(R.id.avoid_paved_roads_btn);
|
MaterialSwitch pavedBtn = root.findViewById(R.id.avoid_paved_roads_btn);
|
||||||
pavedBtn.setChecked(RoutingOptions.hasOption(RoadType.Paved));
|
pavedBtn.setChecked(RoutingOptions.hasOption(RoadType.Paved));
|
||||||
pavedBtn.setEnabled(!RoutingOptions.hasOption(RoadType.Dirty) || RoutingOptions.hasOption(RoadType.Paved));
|
pavedBtn.setEnabled(!RoutingOptions.hasOption(RoadType.Dirty) || RoutingOptions.hasOption(RoadType.Paved));
|
||||||
CompoundButton.OnCheckedChangeListener pavedBtnListener = new ToggleRoutingOptionListener(RoadType.Paved, root);
|
CompoundButton.OnCheckedChangeListener pavedBtnListener = new ToggleRoutingOptionListener(RoadType.Paved, root);
|
||||||
@@ -144,8 +146,8 @@ public class DrivingOptionsFragment extends BaseMwmToolbarFragment
|
|||||||
else
|
else
|
||||||
RoutingOptions.removeOption(mRoadType);
|
RoutingOptions.removeOption(mRoadType);
|
||||||
|
|
||||||
SwitchCompat dirtyRoadsBtn = mRoot.findViewById(R.id.avoid_dirty_roads_btn);
|
MaterialSwitch dirtyRoadsBtn = mRoot.findViewById(R.id.avoid_dirty_roads_btn);
|
||||||
SwitchCompat pavedBtn = mRoot.findViewById(R.id.avoid_paved_roads_btn);
|
MaterialSwitch pavedBtn = mRoot.findViewById(R.id.avoid_paved_roads_btn);
|
||||||
if (mRoadType == RoadType.Dirty)
|
if (mRoadType == RoadType.Dirty)
|
||||||
{
|
{
|
||||||
pavedBtn.setEnabled(!isChecked);
|
pavedBtn.setEnabled(!isChecked);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:textColor="?android:attr/textColorPrimary"/>
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<com.google.android.material.materialswitch.MaterialSwitch
|
||||||
android:id="@+id/avoid_tolls_btn"
|
android:id="@+id/avoid_tolls_btn"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:textColor="?android:attr/textColorPrimary"/>
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<com.google.android.material.materialswitch.MaterialSwitch
|
||||||
android:id="@+id/avoid_dirty_roads_btn"
|
android:id="@+id/avoid_dirty_roads_btn"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:textColor="?android:attr/textColorPrimary"/>
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<com.google.android.material.materialswitch.MaterialSwitch
|
||||||
android:id="@+id/avoid_paved_roads_btn"
|
android:id="@+id/avoid_paved_roads_btn"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@@ -122,7 +122,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:textColor="?android:attr/textColorPrimary"/>
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<com.google.android.material.materialswitch.MaterialSwitch
|
||||||
android:id="@+id/avoid_ferries_btn"
|
android:id="@+id/avoid_ferries_btn"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@@ -150,7 +150,7 @@
|
|||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="?android:attr/textColorPrimary"/>
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<com.google.android.material.materialswitch.MaterialSwitch
|
||||||
android:id="@+id/avoid_motorways_btn"
|
android:id="@+id/avoid_motorways_btn"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:padding="@dimen/margin_half_double_plus"
|
android:padding="@dimen/margin_half_double_plus"
|
||||||
@@ -178,7 +178,7 @@
|
|||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="?android:attr/textColorPrimary"/>
|
android:textColor="?android:attr/textColorPrimary"/>
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<com.google.android.material.materialswitch.MaterialSwitch
|
||||||
android:id="@+id/avoid_steps_btn"
|
android:id="@+id/avoid_steps_btn"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:padding="@dimen/margin_half_double_plus"
|
android:padding="@dimen/margin_half_double_plus"
|
||||||
|
|||||||
@@ -260,7 +260,7 @@
|
|||||||
android:layout_marginStart="@dimen/editor_margin_left"
|
android:layout_marginStart="@dimen/editor_margin_left"
|
||||||
android:layout_toStartOf="@+id/sw__wifi"
|
android:layout_toStartOf="@+id/sw__wifi"
|
||||||
android:text="@string/category_wifi"/>
|
android:text="@string/category_wifi"/>
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<com.google.android.material.materialswitch.MaterialSwitch
|
||||||
android:id="@+id/sw__wifi"
|
android:id="@+id/sw__wifi"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -314,7 +314,7 @@
|
|||||||
android:layout_marginStart="@dimen/editor_margin_left"
|
android:layout_marginStart="@dimen/editor_margin_left"
|
||||||
android:layout_toStartOf="@+id/sw__outdoor_seating"
|
android:layout_toStartOf="@+id/sw__outdoor_seating"
|
||||||
android:text="@string/outdoor_seating"/>
|
android:text="@string/outdoor_seating"/>
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<com.google.android.material.materialswitch.MaterialSwitch
|
||||||
android:id="@+id/sw__outdoor_seating"
|
android:id="@+id/sw__outdoor_seating"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|||||||
@@ -173,10 +173,10 @@
|
|||||||
android:text="@string/editor_time_allday"
|
android:text="@string/editor_time_allday"
|
||||||
android:textAppearance="@style/MwmTextAppearance.Body1"/>
|
android:textAppearance="@style/MwmTextAppearance.Body1"/>
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<com.google.android.material.materialswitch.MaterialSwitch
|
||||||
android:id="@+id/sw__allday"
|
android:id="@+id/sw__allday"
|
||||||
android:layout_width="48dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="48dp"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user