mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 04:53:36 +00:00
[android] Migrate NavMenu to Material components
Signed-off-by: jeanbaptisteC <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
committed by
Konstantin Pastbin
parent
008387b0cf
commit
c3d8f948ce
@@ -16,7 +16,6 @@ import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.annotation.AnyRes;
|
||||
@@ -208,13 +207,6 @@ public final class UiUtils
|
||||
windowManager.getDefaultDisplay().getRealMetrics(metrics);
|
||||
return metrics.heightPixels;
|
||||
}
|
||||
|
||||
public static void updateRedButton(Button button)
|
||||
{
|
||||
button.setTextColor(ThemeUtils.getColor(
|
||||
button.getContext(), button.isEnabled() ? R.attr.redButtonTextColor : R.attr.redButtonTextColorDisabled));
|
||||
}
|
||||
|
||||
public static void setInputError(@NonNull TextInputLayout layout, @StringRes int error)
|
||||
{
|
||||
setInputError(layout, error == 0 ? null : layout.getContext().getString(error));
|
||||
|
||||
@@ -3,8 +3,6 @@ package app.organicmaps.widget.menu;
|
||||
import android.location.Location;
|
||||
import android.util.Pair;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
@@ -17,6 +15,8 @@ import app.organicmaps.util.Graphics;
|
||||
import app.organicmaps.util.ThemeUtils;
|
||||
import app.organicmaps.util.UiUtils;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.imageview.ShapeableImageView;
|
||||
import com.google.android.material.progressindicator.LinearProgressIndicator;
|
||||
import com.google.android.material.textview.MaterialTextView;
|
||||
import java.time.LocalTime;
|
||||
@@ -29,7 +29,7 @@ public class NavMenu
|
||||
private final View mBottomSheetBackground;
|
||||
private final View mHeaderFrame;
|
||||
|
||||
private final ImageView mTts;
|
||||
private final ShapeableImageView mTts;
|
||||
private final View mSpeedViewContainer;
|
||||
private final MaterialTextView mSpeedValue;
|
||||
private final MaterialTextView mSpeedUnits;
|
||||
@@ -105,13 +105,12 @@ public class NavMenu
|
||||
mRouteProgress = bottomFrame.findViewById(R.id.navigation_progress);
|
||||
|
||||
// Bottom frame buttons
|
||||
ImageView mSettings = bottomFrame.findViewById(R.id.settings);
|
||||
ShapeableImageView mSettings = bottomFrame.findViewById(R.id.settings);
|
||||
mSettings.setOnClickListener(v -> onSettingsClicked());
|
||||
mTts = bottomFrame.findViewById(R.id.tts_volume);
|
||||
mTts.setOnClickListener(v -> onTtsClicked());
|
||||
Button stop = bottomFrame.findViewById(R.id.stop);
|
||||
MaterialButton stop = bottomFrame.findViewById(R.id.stop);
|
||||
stop.setOnClickListener(v -> onStopClicked());
|
||||
UiUtils.updateRedButton(stop);
|
||||
}
|
||||
|
||||
private void onStopClicked()
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/button_pressed">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/button_red"/>
|
||||
<corners android:radius="2dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/button_red_disabled"/>
|
||||
<corners android:radius="2dp"/>
|
||||
</shape>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/button_red"/>
|
||||
<corners android:radius="2dp"/>
|
||||
</shape>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/button_red_pressed"/>
|
||||
<corners android:radius="2dp"/>
|
||||
</shape>
|
||||
@@ -43,7 +43,7 @@
|
||||
android:paddingEnd="@dimen/nav_bottom_gap"
|
||||
tools:background="#300000FF">
|
||||
|
||||
<ImageView
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/tts_volume"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/nav_icon_size"
|
||||
@@ -52,7 +52,7 @@
|
||||
android:scaleType="center"
|
||||
app:srcCompat="@drawable/ic_voice_on" />
|
||||
|
||||
<ImageView
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/settings"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/nav_icon_size"
|
||||
@@ -63,16 +63,16 @@
|
||||
app:srcCompat="@drawable/ic_menu_settings"
|
||||
app:tint="?iconTint" />
|
||||
|
||||
<Button
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/stop"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/nav_button_height"
|
||||
android:layout_weight="0.4"
|
||||
android:background="?redButtonBackground"
|
||||
android:fontFamily="@string/robotoMedium"
|
||||
android:minWidth="@dimen/start_button_width"
|
||||
android:text="@string/navigation_stop_button"
|
||||
android:textAppearance="@style/MwmTextAppearance.Button.Red"
|
||||
android:textColor="@color/button_red_text"
|
||||
android:textStyle="bold"
|
||||
app:backgroundTint="@color/base_red"
|
||||
tools:ignore="UnusedAttribute" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -66,10 +66,6 @@
|
||||
accentButtonTextColor selector -->
|
||||
<item name="accentButtonTextColorDisabled">@color/button_accent_text_disabled_night</item>
|
||||
|
||||
<item name="redButtonBackground">@drawable/button_red</item>
|
||||
<item name="redButtonTextColor">@color/button_red_text</item>
|
||||
<item name="redButtonTextColorDisabled">@color/button_red_text_disabled</item>
|
||||
|
||||
<item name="primaryButtonBackground">@drawable/button_accent_night</item>
|
||||
|
||||
<item name="menuBackground">@color/bg_menu_night</item>
|
||||
|
||||
@@ -108,12 +108,8 @@
|
||||
<color name="button_accent_text_disabled">#42000000</color>
|
||||
<color name="button_accent_text_disabled_night">#4CFFFFFF</color>
|
||||
|
||||
<color name="button_red">@color/button_red_normal</color>
|
||||
<color name="button_red_normal">@color/base_red</color>
|
||||
<color name="button_red_pressed">#FFC22219</color>
|
||||
<color name="button_red_disabled">#FFB9332B</color>
|
||||
<color name="button_red">@color/base_red</color>
|
||||
<color name="button_red_text">#FFFFFFFF</color>
|
||||
<color name="button_red_text_disabled">#FF606060</color>
|
||||
|
||||
<!-- Routing-->
|
||||
<color name="bg_routing_progress">#1F000000</color>
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
<dimen name="nav_numbers_side_min_width">90dp</dimen>
|
||||
<dimen name="nav_progress">4sp</dimen>
|
||||
<dimen name="nav_progress_head">2dp</dimen>
|
||||
<dimen name="nav_button_height">@dimen/primary_button_min_height</dimen>
|
||||
<dimen name="nav_button_height">44dp</dimen>
|
||||
<dimen name="nav_icon_size">48dp</dimen>
|
||||
<dimen name="nav_bottom_gap">12dp</dimen>
|
||||
<dimen name="nav_menu_height">80sp</dimen>
|
||||
|
||||
@@ -30,9 +30,6 @@
|
||||
<attr name="accentButtonBackground" format="reference" />
|
||||
<attr name="accentButtonTextColor" format="color" />
|
||||
<attr name="accentButtonTextColorDisabled" format="color" />
|
||||
<attr name="redButtonBackground" format="reference" />
|
||||
<attr name="redButtonTextColor" format="color" />
|
||||
<attr name="redButtonTextColorDisabled" format="color" />
|
||||
<attr name="primaryButtonBackground" format="reference" />
|
||||
<attr name="menuBackground" format="color" />
|
||||
<attr name="myPositionButtonAnimation" format="reference" />
|
||||
|
||||
@@ -64,10 +64,6 @@
|
||||
accentButtonTextColor selector -->
|
||||
<item name="accentButtonTextColorDisabled">@color/button_accent_text_disabled</item>
|
||||
|
||||
<item name="redButtonBackground">@drawable/button_red</item>
|
||||
<item name="redButtonTextColor">@color/button_red_text</item>
|
||||
<item name="redButtonTextColorDisabled">@color/button_red_text_disabled</item>
|
||||
|
||||
<item name="primaryButtonBackground">@drawable/button_accent</item>
|
||||
|
||||
<item name="menuBackground">@color/bg_menu</item>
|
||||
|
||||
Reference in New Issue
Block a user