[android] Migrate Primary buttons to Material 3 themes

Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
Jean-Baptiste
2025-08-24 17:48:33 +02:00
committed by Konstantin Pastbin
parent 05cc660641
commit ca5cc46f2b
20 changed files with 90 additions and 66 deletions

View File

@@ -9,7 +9,6 @@ import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import androidx.annotation.NonNull;
@@ -27,6 +26,7 @@ import app.organicmaps.util.UiUtils;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.divider.MaterialDividerItemDecoration;
import java.util.ArrayList;
@@ -42,10 +42,10 @@ public class ManageRouteBottomSheet
{
View v = inflater.inflate(R.layout.manage_route_bottom_sheet, container, false);
Button cancelButton = v.findViewById(R.id.btn__cancel);
MaterialButton cancelButton = v.findViewById(R.id.btn__cancel);
cancelButton.setOnClickListener(this);
Button planButton = v.findViewById(R.id.btn__plan);
MaterialButton planButton = v.findViewById(R.id.btn__plan);
planButton.setOnClickListener(this);
mMyLocationImageView = v.findViewById(R.id.image_my_location);

View File

@@ -68,7 +68,7 @@ final class RoutingBottomMenuController implements View.OnClickListener
@NonNull
private final MaterialTextView mError;
@NonNull
private final Button mStart;
private final MaterialButton mStart;
@NonNull
private final ImageView mAltitudeChart;
@NonNull
@@ -101,7 +101,7 @@ final class RoutingBottomMenuController implements View.OnClickListener
View timeElevationLine = getViewById(activity, frame, R.id.time_elevation_line);
View transitFrame = getViewById(activity, frame, R.id.transit_panel);
MaterialTextView error = (MaterialTextView) getViewById(activity, frame, R.id.error);
Button start = (Button) getViewById(activity, frame, R.id.start);
MaterialButton start = (MaterialButton) getViewById(activity, frame, R.id.start);
ImageView altitudeChart = (ImageView) getViewById(activity, frame, R.id.altitude_chart);
MaterialTextView time = (MaterialTextView) getViewById(activity, frame, R.id.time);
TextView timeVehicle = (TextView) getViewById(activity, frame, R.id.time_vehicle);
@@ -123,7 +123,7 @@ final class RoutingBottomMenuController implements View.OnClickListener
private RoutingBottomMenuController(@NonNull Activity context, @NonNull View altitudeChartFrame,
@NonNull View timeElevationLine, @NonNull View transitFrame,
@NonNull MaterialTextView error, @NonNull Button start,
@NonNull MaterialTextView error, @NonNull MaterialButton start,
@NonNull ImageView altitudeChart, @NonNull MaterialTextView time,
@NonNull MaterialTextView altitudeDifference, @NonNull TextView timeVehicle,
@Nullable MaterialTextView arrival, @NonNull View actionFrame,

View File

@@ -166,7 +166,7 @@
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
android:id="@+id/donate"
style="@style/MwmWidget.Button.Accent"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="@dimen/margin_quarter"
@@ -182,10 +182,9 @@
app:layout_constraintVertical_bias="0.5" />
<com.google.android.material.button.MaterialButton
android:id="@+id/report"
style="@style/MwmWidget.Button"
style="@style/MwmWidget.M3.Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/light_gray"
android:text="@string/report_a_bug"
android:textAlignment="center"
android:textColor="@color/text_dark"
@@ -195,7 +194,8 @@
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/donate"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5" />
app:layout_constraintVertical_bias="0.5"
app:backgroundTint="@color/light_gray"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.textview.MaterialTextView

View File

@@ -69,9 +69,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
style="@style/MwmWidget.Button"
style="@style/Widget.Material3.Button.TextButton"
android:text="@string/planning_route_manage_route"
android:textColor="?android:textColorPrimary"
android:textAppearance="@style/MwmTextAppearance.Body1"
app:icon="@drawable/ic_manage_route"
app:iconTint="?android:textColorPrimary"
app:iconPadding="6dp"/>
@@ -84,13 +85,14 @@
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/margin_base"
android:minHeight="@dimen/primary_button_min_height"
style="@style/MwmWidget.Button"
style="@style/Widget.Material3.Button.TextButton"
android:text="@string/save"
android:textColor="?android:textColorPrimary"/>
android:textColor="?android:textColorPrimary"
android:textAppearance="@style/MwmTextAppearance.Body1"/>
<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/start"
style="@style/MwmWidget.Button.Primary"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"

View File

@@ -110,11 +110,10 @@
android:layout_marginBottom="@dimen/margin_base">
<com.google.android.material.button.MaterialButton
android:id="@+id/login"
style="@style/MwmWidget.Button.Accent"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/login_osm"
android:textAppearance="@style/MwmTextAppearance.Body2.Light" />
android:text="@string/login_osm" />
<ProgressBar
android:id="@+id/osm_login_progress"
android:layout_width="@dimen/editor_auth_btn_height"
@@ -147,15 +146,14 @@
android:textColor="?android:textColorPrimary" />
<com.google.android.material.button.MaterialButton
android:id="@+id/register"
style="@style/MwmWidget.Button.Accent"
style="@style/MwmWidget.M3.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_base"
android:background="@drawable/button_editor_light"
android:padding="@dimen/margin_quarter"
android:text="@string/register_at_openstreetmap"
android:textAppearance="@style/MwmTextAppearance.Body2"
android:textColor="@color/text_dark" />
android:textColor="@color/text_dark"
app:backgroundTint="@color/bg_editor_light"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@@ -60,7 +60,7 @@
android:clipChildren="false">
<com.google.android.material.button.MaterialButton
android:id="@+id/downloader_button"
style="@style/MwmWidget.Button.Primary"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_width="180dp"
android:layout_gravity="center"
android:visibility="gone"

View File

@@ -88,9 +88,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
style="@style/MwmWidget.Button"
style="@style/Widget.Material3.Button.TextButton"
android:text="@string/planning_route_manage_route"
android:textColor="?android:textColorPrimary"
android:textAppearance="@style/MwmTextAppearance.Body1"
app:icon="@drawable/ic_manage_route"
app:iconTint="?android:textColorPrimary"
app:iconPadding="6dp"/>
@@ -100,14 +101,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_base"
style="@style/MwmWidget.Button"
style="@style/Widget.Material3.Button.TextButton"
android:minHeight="@dimen/primary_button_min_height"
android:text="@string/save"
android:textColor="?android:textColorPrimary"/>
android:textColor="?android:textColorPrimary"
android:textAppearance="@style/MwmTextAppearance.Body1"/>
<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/start"
style="@style/MwmWidget.Button.Primary"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"

View File

@@ -112,7 +112,7 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/donate"
style="@style/MwmWidget.Button.Accent"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_base"
@@ -121,13 +121,13 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/report"
style="@style/MwmWidget.Button"
style="@style/MwmWidget.M3.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_base"
android:background="@color/light_gray"
android:layout_marginTop="@dimen/margin_half"
android:text="@string/report_a_bug"
android:textColor="@color/text_dark" />
android:textColor="@color/text_dark"
app:backgroundTint="@color/light_gray"/>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/faq"

View File

@@ -41,7 +41,7 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_continue"
style="@style/MwmWidget.Button.Accent"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="32dp"

View File

@@ -25,7 +25,7 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_grant_permissions"
style="@style/MwmWidget.Button.Accent"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="32dp"

View File

@@ -71,9 +71,9 @@
tools:visibility="visible" />
</LinearLayout>
<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/start"
style="@style/MwmWidget.Button.Primary"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
@@ -94,10 +94,11 @@
android:id="@+id/btn__manage_route"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/MwmWidget.Button"
style="@style/Widget.Material3.Button.TextButton"
android:text="@string/planning_route_manage_route"
android:textColor="?android:textColorPrimary"
android:textAlignment="viewStart"
android:textAppearance="@style/MwmTextAppearance.Body1"
app:icon="@drawable/ic_manage_route"
app:iconTint="?android:textColorPrimary"
app:iconPadding="@dimen/margin_quarter_plus"/>
@@ -107,11 +108,12 @@
android:id="@+id/btn__save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/MwmWidget.Button"
style="@style/Widget.Material3.Button.TextButton"
android:layout_marginStart="@dimen/margin_base"
android:minHeight="@dimen/primary_button_min_height"
android:text="@string/save"
android:textColor="?android:textColorPrimary"/>
android:textColor="?android:textColorPrimary"
android:textAppearance="@style/MwmTextAppearance.Body1"/>
</LinearLayout>
</LinearLayout>

View File

@@ -31,7 +31,7 @@
app:trackColor="@color/bg_routing_progress"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_download_resources"
style="@style/MwmWidget.Button.Primary"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_base_plus"

View File

@@ -94,11 +94,10 @@
android:layout_marginBottom="@dimen/margin_base">
<com.google.android.material.button.MaterialButton
android:id="@+id/login"
style="@style/MwmWidget.Button.Accent"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/login_osm"
android:textAppearance="@style/MwmTextAppearance.Body2.Light" />
android:text="@string/login_osm" />
<ProgressBar
android:id="@+id/osm_login_progress"
android:layout_width="@dimen/editor_auth_btn_height"
@@ -109,14 +108,16 @@
</FrameLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/lost_password"
style="@style/MwmWidget.Button"
style="@style/MwmWidget.M3.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:background="?clickableBackground"
android:padding="@dimen/margin_half"
android:text="@string/forgot_password"
android:textAppearance="@style/MwmTextAppearance.Body3" />
android:textAppearance="@style/MwmTextAppearance.Body3"
android:textColor="@color/text_dark"
tools:visibility="invisible"/>
<com.google.android.material.divider.MaterialDivider
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -130,15 +131,14 @@
android:textColor="?android:textColorPrimary" />
<com.google.android.material.button.MaterialButton
android:id="@+id/register"
style="@style/MwmWidget.Button.Accent"
style="@style/MwmWidget.M3.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_base"
android:background="@drawable/button_editor_light"
android:padding="@dimen/margin_quarter"
android:text="@string/register_at_openstreetmap"
android:textAppearance="@style/MwmTextAppearance.Body2"
android:textColor="@color/text_dark" />
android:textColor="@color/text_dark"
app:backgroundTint="@color/bg_editor_light"/>
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@@ -60,7 +60,7 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/btn__download_map"
style="@style/MwmWidget.Button.Primary"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_marginTop="@dimen/margin_half"
android:text="@string/downloader_download_map"/>
</LinearLayout>
@@ -85,7 +85,7 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/btn__select_map"
style="@style/MwmWidget.Button.Primary"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_marginTop="@dimen/margin_half"
android:text="@string/search_select_map"/>
</LinearLayout>

View File

@@ -45,13 +45,15 @@
android:maxLines="6" />
</com.google.android.material.textfield.TextInputLayout>
<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/send_note_button"
style="@style/MwmWidget.Button.Accent"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="?accentButtonBackground"
android:layout_marginTop="@dimen/margin_base"
android:enabled="false"
android:text="@string/editor_report_problem_send_button" />
android:enabled="true"
android:text="@string/editor_report_problem_send_button"
app:backgroundTint="@null"/>
</LinearLayout>

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/margin_base_plus"
@@ -8,10 +9,12 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/btn__add_time"
style="@style/MwmWidget.Button.Primary"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_gravity="center"
android:enabled="false"
android:background="?accentButtonBackground"
android:padding="@dimen/margin_base"
android:text="@string/editor_time_add"/>
android:text="@string/editor_time_add"
app:backgroundTint="@null"/>
</FrameLayout>

View File

@@ -89,21 +89,22 @@
android:paddingStart="0dp"
android:paddingEnd="@dimen/altitude_chart_container_padding_left">
<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/btn__cancel"
style="@style/MwmWidget.Button"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/cancel"
android:textColor="?android:attr/textColorPrimary"
android:textColor="?android:textColorPrimary"
android:textAppearance="@style/MwmTextAppearance.Body1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/btn__plan"
style="@style/MwmWidget.Button.Primary"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"

View File

@@ -53,7 +53,7 @@
android:clipChildren="false">
<com.google.android.material.button.MaterialButton
android:id="@+id/downloader_button"
style="@style/MwmWidget.Button.Primary"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_width="180dp"
android:layout_gravity="center"
android:visibility="gone"

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Button
<com.google.android.material.button.MaterialButton
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/start"
style="@style/MwmWidget.Button.Primary"
style="@style/MwmWidget.M3.Button.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="@dimen/start_button_width"

View File

@@ -390,4 +390,18 @@
<style name="MwmWidget.SwitchPreferenceCompat" parent="Preference.SwitchPreferenceCompat.Material">
<item name="android:widgetLayout">@layout/preference_switch</item>
</style>
<style name="MwmWidget.M3.Button" parent="ThemeOverlay.Material3.Button">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">?accentButtonTextColor</item>
<item name="backgroundTint">@null</item>
<item name="android:textAllCaps">false</item>
<item name="cornerRadius">20dp</item>
<item name="android:textSize">16sp</item>
</style>
<style name="MwmWidget.M3.Button.Primary" parent="@style/MwmWidget.M3.Button">
<item name="backgroundTint">?colorSecondary</item>
</style>
</resources>