[android] Map buttons fixes #3398

Merged
arnaudvergnet merged 3 commits from map-buttons-fixes into master 2022-09-14 05:16:56 +00:00
17 changed files with 26 additions and 35 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 714 B

View file

@ -1,15 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<group
android:pivotX="24"
android:pivotY="24"
android:scaleX="0.75"
android:scaleY="0.75">
<path
android:fillColor="#fff"
android:pathData="M6,36h36v-4h-36v4ZM6,26h36v-4h-36v4ZM6,12v4h36v-4h-36Z" />
</group>
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M3,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z"/>
</vector>

View file

@ -3,5 +3,4 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_position"
style="@style/MwmWidget.MapButton"
android:contentDescription="@string/core_my_position"
android:tint="@null" />
android:contentDescription="@string/core_my_position" />

View file

@ -12,7 +12,7 @@
<style name="MwmWidget.MapButton" parent="Theme.Material3.Dark">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:backgroundTint">?mapButtonBackground</item>
<item name="android:backgroundTint">?menuBackground</item>
<item name="elevation">0dp</item>
<item name="hoveredFocusedTranslationZ">0dp</item>
<item name="pressedTranslationZ">0dp</item>

View file

@ -43,7 +43,6 @@
<attr name="primaryButtonBackground" format="reference" />
<attr name="circleAccent" format="reference" />
<attr name="menuBackground" format="color" />
<attr name="mapButtonBackground" format="color" />
<attr name="myPositionButtonAnimation" format="reference" />
<attr name="wheelPendingAnimation" format="reference" />
<attr name="trafficLoadingAnimation" format="reference" />

View file

@ -71,7 +71,6 @@
<item name="circleAccent">@drawable/circle_accent</item>
<item name="menuBackground">@color/bg_menu</item>
<item name="mapButtonBackground">@color/bg_map_button</item>
<item name="myPositionButtonAnimation">@drawable/anim_myposition_pending</item>
<item name="wheelPendingAnimation">@drawable/anim_spinner_pending</item>
@ -249,7 +248,6 @@
<item name="circleAccent">@drawable/circle_accent_night</item>
<item name="menuBackground">@color/bg_menu_night</item>
<item name="mapButtonBackground">@color/bg_map_button_night</item>
<item name="myPositionButtonAnimation">@drawable/anim_myposition_pending_night</item>
<item name="wheelPendingAnimation">@drawable/anim_spinner_pending</item>

View file

@ -237,7 +237,7 @@ public class SearchWheel implements View.OnClickListener
private void resetSearchButtonImage()
{
mSearchButton.setImageDrawable(Graphics.tint(mSearchButton.getContext(),
R.drawable.ic_routing_search_on));
R.drawable.ic_search));
}
private void refreshSearchButtonImage()

View file

@ -1,18 +1,22 @@
package com.mapswithme.maps.widget.menu;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.util.SparseArray;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.AttrRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.widget.ImageViewCompat;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.mapswithme.maps.R;
import com.mapswithme.maps.location.LocationState;
import com.mapswithme.maps.routing.RoutingController;
import com.mapswithme.util.Graphics;
import com.mapswithme.util.ThemeUtils;
import com.mapswithme.util.UiUtils;
@ -39,41 +43,42 @@ public class MyPositionButton
update(myPositionMode);
}
@SuppressWarnings("deprecation")
public void update(int mode)
{
mMode = mode;
Drawable image = mIcons.get(mode);
@AttrRes int colorAttr =
mode == LocationState.FOLLOW || mode == LocationState.FOLLOW_AND_ROTATE || mode == LocationState.PENDING_POSITION
? R.attr.colorAccent : R.attr.iconTint;
Resources resources = mButton.getResources();
Context context = mButton.getContext();
if (image == null)
{
@DrawableRes int drawableRes;
switch (mode)
{
case LocationState.PENDING_POSITION:
image = mButton.getResources()
.getDrawable(ThemeUtils.getResource(mButton.getContext(), R.attr.myPositionButtonAnimation));
drawableRes = ThemeUtils.getResource(context, R.attr.myPositionButtonAnimation);
break;
case LocationState.NOT_FOLLOW_NO_POSITION:
case LocationState.NOT_FOLLOW:
image = Graphics.tint(mButton.getContext(), R.drawable.ic_not_follow);
drawableRes = R.drawable.ic_not_follow;
break;
case LocationState.FOLLOW:
image = Graphics.tint(mButton.getContext(), R.drawable.ic_follow, R.attr.colorAccent);
drawableRes = R.drawable.ic_follow;
break;
case LocationState.FOLLOW_AND_ROTATE:
image = Graphics.tint(mButton.getContext(), R.drawable.ic_follow_and_rotate, R.attr.colorAccent);
drawableRes = R.drawable.ic_follow_and_rotate;
break;
default:
throw new IllegalArgumentException("Invalid button mode: " + mode);
}
image = ResourcesCompat.getDrawable(resources, drawableRes, context.getTheme());
mIcons.put(mode, image);
}
mButton.setImageDrawable(image);
ImageViewCompat.setImageTintList(mButton, ColorStateList.valueOf(ThemeUtils.getColor(context, colorAttr)));
updatePadding(mode);
if (image instanceof AnimationDrawable)