[android] UI Fixes.

This commit is contained in:
Dmitry Yunitsky 2016-07-29 18:53:00 +03:00 committed by Alexander Marchuk
parent e66fe5b62d
commit e1ca70308a
13 changed files with 133 additions and 43 deletions

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<item
android:drawable="@drawable/news_marker_active"
android:state_enabled="true"/>
<item
android:drawable="@drawable/news_marker_inactive"/>
</selector>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<item
android:drawable="@drawable/news_marker_active_night"
android:state_enabled="true"/>
<item
android:drawable="@drawable/news_marker_inactive_night"/>
</selector>

View file

@ -9,6 +9,8 @@
android:paddingStart="@dimen/nav_numbers_margin"
android:layout_marginRight="@dimen/nav_toggle"
android:layout_marginEnd="@dimen/nav_toggle"
android:paddingBottom="@dimen/margin_quarter"
android:background="?clickableBackground"
tools:background="#3000FF00"
tools:ignore="RtlSymmetry">
<!-- Speed -->
@ -96,20 +98,21 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:theme="?navigationTheme"
android:orientation="horizontal">
<ImageView
android:id="@+id/dot_estimate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_half"
android:layout_marginEnd="@dimen/margin_half"
tools:src="@drawable/news_marker_active"/>
<ImageView
android:id="@+id/dot_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:src="@drawable/news_marker_inactive"/>
android:layout_marginRight="@dimen/margin_half"
android:layout_marginEnd="@dimen/margin_half"
android:src="?newsMarker"/>
<ImageView
android:id="@+id/dot_estimate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="?newsMarker"/>
</LinearLayout>
</LinearLayout>

View file

@ -10,6 +10,7 @@
android:layout_gravity="bottom"
android:clickable="true"
android:visibility="invisible"
android:background="?cardBackground"
tools:visibility="visible">
<FrameLayout
@ -35,7 +36,7 @@
android:id="@+id/navigation_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:headRadius="@dimen/nav_progress"
app:headRadius="@dimen/nav_progress_head"
app:progressColor="?colorAccent"
app:headColor="?colorAccent"
app:progressThickness="@dimen/nav_progress"

View file

@ -9,6 +9,8 @@
android:paddingStart="@dimen/nav_numbers_margin"
android:layout_marginRight="@dimen/nav_toggle"
android:layout_marginEnd="@dimen/nav_toggle"
android:paddingBottom="@dimen/margin_quarter"
android:background="?clickableBackground"
tools:background="#3000FF00"
tools:ignore="RtlSymmetry">
<!-- Speed -->
@ -22,13 +24,13 @@
android:paddingRight="@dimen/nav_numbers_margin"
android:paddingTop="@dimen/margin_eighth"
android:gravity="center_horizontal"
android:background="?clickableBackground"
tools:background="#20FF0000">
<TextView
android:id="@+id/speed_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:includeFontPadding="false"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="999"/>
@ -54,7 +56,6 @@
android:orientation="vertical"
android:paddingTop="@dimen/margin_eighth"
android:gravity="center_horizontal"
android:background="?clickableBackground"
tools:background="#20FF0000">
<LinearLayout
android:layout_width="match_parent"
@ -100,20 +101,21 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:theme="?navigationTheme"
android:layout_marginTop="@dimen/margin_quarter">
<ImageView
android:id="@+id/dot_estimate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/margin_half"
android:layout_marginEnd="@dimen/margin_half"
tools:src="@drawable/news_marker_active"/>
<ImageView
android:id="@+id/dot_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:src="@drawable/news_marker_inactive"/>
android:layout_marginRight="@dimen/margin_half"
android:layout_marginEnd="@dimen/margin_half"
android:src="?newsMarker"/>
<ImageView
android:id="@+id/dot_estimate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="?newsMarker"/>
</LinearLayout>
</LinearLayout>
@ -132,13 +134,13 @@
android:paddingRight="@dimen/nav_numbers_margin"
android:paddingTop="@dimen/margin_eighth"
android:gravity="center_horizontal"
android:background="?clickableBackground"
tools:background="#20FF0000">
<TextView
android:id="@+id/distance_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:includeFontPadding="false"
android:textAppearance="@style/MwmTextAppearance.RoutingNumber"
tools:text="99999"/>

View file

@ -11,13 +11,14 @@
android:layout_width="match_parent"
android:layout_height="@dimen/nav_street_height"
android:elevation="@dimen/nav_elevation"
android:background="?menuBackground">
android:background="?cardBackground">
<TextView
android:id="@+id/street"
style="@style/MwmWidget.TextView.NavStreet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/nav_street_left"
android:layout_marginStart="@dimen/nav_street_left"
android:maxLines="2"
android:layout_gravity="center_vertical"
android:gravity="center"

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Text colors -->
<color name="text_dark">#DE000000</color>
<color name="text_dark_subtitle">#8A000000</color>
<color name="text_dark_hint">#61000000</color>
<color name="text_light">#FFFFFFFF</color>
<color name="text_light_subtitle">#B3FFFFFF</color>
<color name="text_light_hint">#4CFFFFFF</color>
<color name="text_dark">@color/black_primary</color>
<color name="text_dark_subtitle">@color/black_secondary</color>
<color name="text_dark_hint">@color/black_lightest</color>
<color name="text_light">@color/white_primary</color>
<color name="text_light_subtitle">@color/white_secondary</color>
<color name="text_light_hint">@color/white_lightest</color>
<color name="base_accent">#FF1E96F0</color>
<color name="base_accent_night">#FFFFE68C</color>
@ -17,6 +17,13 @@
<color name="base_yellow">#FFFFC30A</color>
<color name="base_green">#FF558B2F</color>
<color name="black_primary">#DE000000</color> <!-- 87% black -->
<color name="black_secondary">#8A000000</color> <!-- 54% black -->
<color name="black_lightest">#61000000</color> <!-- 38% black -->
<color name="white_primary">@android:color/white</color> <!-- 100% black -->
<color name="white_secondary">#B3FFFFFF</color> <!-- 70% white -->
<color name="white_lightest">#4CFFFFFF</color> <!-- 50% black -->
<color name="icon_tint">#FF757575</color>
<color name="icon_tint_night">#FFC4C6C7</color>

View file

@ -97,6 +97,7 @@
<dimen name="nav_numbers_side_min_width">90dp</dimen>
<dimen name="nav_numbers_center_min_width">130dp</dimen>
<dimen name="nav_progress">4dp</dimen>
<dimen name="nav_progress_head">2dp</dimen>
<dimen name="nav_toggle">40dp</dimen>
<dimen name="nav_toggle_margin">8dp</dimen>

View file

@ -70,4 +70,8 @@
<attr name="status_folder" format="reference"/>
<attr name="status_folder_done" format="reference"/>
</declare-styleable>
<declare-styleable name="ThemeAttrs.Navigation">
<attr name="newsMarker" format="reference"/>
</declare-styleable>
</resources>

View file

@ -160,12 +160,13 @@
</style>
<style name="MwmTheme.Navigation">
<item name="iconTint">@android:color/white</item>
<item name="iconTint">@color/white_primary</item>
<item name="newsMarker">@drawable/news_marker</item>
</style>
<!-- TODO get proper color -->
<style name="MwmTheme.Navigation.Night">
<item name="iconTint">@android:color/darker_gray</item>
<item name="iconTint">@color/black_primary</item>
<item name="newsMarker">@drawable/news_marker_night</item>
</style>
</resources>

View file

@ -10,6 +10,8 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
import com.mapswithme.maps.Framework;
@ -50,10 +52,14 @@ public class NavigationController
private final TextView mTimeHourUnits;
private final TextView mTimeMinuteValue;
private final TextView mTimeMinuteUnits;
private final ImageView mDotTimeLeft;
private final ImageView mDotTimeArrival;
private final TextView mDistanceValue;
private final TextView mDistanceUnits;
private final FlatProgressView mRouteProgress;
private boolean mShowTimeLeft = true;
private double mNorth;
public NavigationController(Activity activity)
@ -61,6 +67,14 @@ public class NavigationController
mFrame = activity.findViewById(R.id.navigation_frame);
mTopFrame = mFrame.findViewById(R.id.nav_top_frame);
mBottomFrame = mFrame.findViewById(R.id.nav_bottom_frame);
mBottomFrame.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
switchTimeFormat();
}
});
mNavMenu = createNavMenu();
mNavMenu.refreshTts();
@ -85,6 +99,8 @@ public class NavigationController
mTimeHourUnits = (TextView) mBottomFrame.findViewById(R.id.time_hour_dimen);
mTimeMinuteValue = (TextView) mBottomFrame.findViewById(R.id.time_minute_value);
mTimeMinuteUnits = (TextView) mBottomFrame.findViewById(R.id.time_minute_dimen);
mDotTimeArrival = (ImageView) mBottomFrame.findViewById(R.id.dot_estimate);
mDotTimeLeft = (ImageView) mBottomFrame.findViewById(R.id.dot_left);
mDistanceValue = (TextView) mBottomFrame.findViewById(R.id.distance_value);
mDistanceUnits = (TextView) mBottomFrame.findViewById(R.id.distance_dimen);
mRouteProgress = (FlatProgressView) mBottomFrame.findViewById(R.id.navigation_progress);
@ -199,20 +215,51 @@ public class NavigationController
}
private void updateTime(int seconds)
{
if (mShowTimeLeft)
{
updateTimeLeft(seconds);
mDotTimeLeft.setEnabled(true);
mDotTimeArrival.setEnabled(false);
}
else
{
updateTimeEstimate(seconds);
mDotTimeLeft.setEnabled(false);
mDotTimeArrival.setEnabled(true);
}
}
private void updateTimeLeft(int seconds)
{
final long hours = TimeUnit.SECONDS.toHours(seconds);
final long minutes = TimeUnit.MINUTES.toMinutes(seconds) % 60;
mTimeMinuteValue.setText(String.valueOf(minutes));
final long minutes = TimeUnit.SECONDS.toMinutes(seconds) % 60;
UiUtils.setTextAndShow(mTimeMinuteValue, String.valueOf(minutes));
// TODO set localized text
mTimeMinuteUnits.setText("m");
UiUtils.setTextAndShow(mTimeMinuteUnits, "min");
if (hours == 0)
{
UiUtils.hide(mTimeHourUnits, mTimeHourValue);
return;
}
mTimeHourValue.setText(String.valueOf(hours));
UiUtils.setTextAndShow(mTimeHourValue,String.valueOf(hours));
// TODO set localized text
mTimeHourUnits.setText("h");
UiUtils.setTextAndShow(mTimeHourUnits, "h");
}
private void updateTimeEstimate(int seconds)
{
final Calendar currentTime = Calendar.getInstance();
currentTime.add(Calendar.SECOND, seconds);
UiUtils.setTextAndShow(mTimeMinuteValue, DateFormat.getTimeInstance(DateFormat.SHORT)
.format(currentTime.getTime()));
UiUtils.hide(mTimeHourUnits, mTimeHourValue, mTimeMinuteUnits);
}
private void switchTimeFormat()
{
mShowTimeLeft = !mShowTimeLeft;
updateTime(Framework.nativeGetRouteFollowingInfo().totalTimeInSeconds);
}
public void show(boolean show)

View file

@ -71,7 +71,7 @@ public abstract class BaseMenu
return res;
}
private void adjustTransparency()
protected void adjustTransparency()
{
mFrame.setBackgroundColor(ThemeUtils.getColor(mFrame.getContext(), isOpen() ? R.attr.menuBackgroundOpen
: R.attr.menuBackground));

View file

@ -12,7 +12,7 @@ import com.mapswithme.maps.widget.RotateDrawable;
public class NavMenu extends BaseMenu
{
private final ImageView mToggle;
private final RotateDrawable mToggleImage = new RotateDrawable(R.drawable.ic_menu_close);
private final RotateDrawable mToggleImage = new RotateDrawable(R.drawable.ic_down);
private final ImageView mTts;
public enum Item implements BaseMenu.Item
@ -42,7 +42,7 @@ public class NavMenu extends BaseMenu
super(frame, listener);
mToggle = (ImageView) mLineFrame.findViewById(R.id.toggle);
// mToggle.setImageDrawable(mToggleImage);
// mToggle.setImageDrawable(mToggleImage);
mToggle.setOnClickListener(new View.OnClickListener()
{
@Override
@ -52,7 +52,7 @@ public class NavMenu extends BaseMenu
}
});
// setToggleState(false, false);
// setToggleState(false, false);
mapItem(Item.STOP, mFrame);
mapItem(Item.SETTINGS, mFrame);
@ -77,7 +77,7 @@ public class NavMenu extends BaseMenu
{
if (!animate)
{
// mToggleImage.setAngle(open ? -90.0f : 90.0f);
// mToggleImage.setAngle(open ? -90.0f : 90.0f);
return;
}
@ -87,7 +87,7 @@ public class NavMenu extends BaseMenu
@Override
public void onAnimationUpdate(ValueAnimator animation)
{
float fraction = (float)animation.getAnimatedValue();
float fraction = (float) animation.getAnimatedValue();
mToggleImage.setAngle((1.0f - fraction) * 180.0f);
}
});
@ -101,4 +101,7 @@ public class NavMenu extends BaseMenu
{
return R.dimen.nav_menu_height;
}
@Override
protected void adjustTransparency() {}
}