made changes in xml files to switch eta times on tap

Signed-off-by: Aryan <sagavekararyan@gmail.com>
This commit is contained in:
Aryan 2023-03-27 22:16:01 +05:30
parent 06350598e5
commit 6aab1bc313
2 changed files with 121 additions and 78 deletions

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -7,22 +8,19 @@
android:orientation="horizontal"
tools:background="#3000FF00"
tools:ignore="RtlSymmetry">
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"/>
android:layout_weight="0.5" />
<!-- Speed -->
<LinearLayout
android:id="@+id/speed_view_container"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/speed_cams_bg"
android:gravity="center"
android:minWidth="@dimen/nav_numbers_side_min_width">
android:minWidth="@dimen/nav_numbers_side_min_width"
android:orientation="vertical">
<TextView
android:id="@+id/speed_value"
android:layout_width="wrap_content"
@ -31,7 +29,6 @@
android:lines="1"
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number"
tools:text="999" />
<!-- Speed -->
<TextView
android:id="@+id/speed_dimen"
@ -43,26 +40,25 @@
tools:background="#20FF0000"
tools:text="km/h" />
</LinearLayout>
<Space
android:layout_width="0dp"
android:layout_width="22dp"
android:layout_height="match_parent"
android:layout_weight="1.25"/>
android:layout_weight="1.25" />
<!-- Time -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginRight="-100sp"
android:layout_weight="1"
android:gravity="center"
android:minWidth="@dimen/nav_numbers_side_min_width">
android:minWidth="@dimen/nav_numbers_side_min_width"
android:orientation="vertical">
<LinearLayout
android:id="@+id/time_values_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:background="#20FF0000">
<TextView
android:id="@+id/time_hour_value"
android:layout_width="wrap_content"
@ -71,7 +67,6 @@
android:lines="1"
android:textAppearance="@style/MwmTextAppearance.NavMenu.Time"
tools:text="999" />
<TextView
android:id="@+id/time_hour_dimen"
android:layout_width="wrap_content"
@ -81,7 +76,6 @@
android:lines="1"
android:textAppearance="@style/MwmTextAppearance.NavMenu.Time.Dimension"
tools:text="h" />
<TextView
android:id="@+id/time_minute_value"
android:layout_width="wrap_content"
@ -91,7 +85,6 @@
android:textAlignment="center"
android:textAppearance="@style/MwmTextAppearance.NavMenu.Time"
tools:text="99" />
<TextView
android:id="@+id/time_minute_dimen"
android:layout_width="wrap_content"
@ -101,7 +94,6 @@
android:textAppearance="@style/MwmTextAppearance.NavMenu.Time.Dimension"
tools:text="m" />
</LinearLayout>
<TextView
android:id="@+id/time_estimate"
android:layout_width="wrap_content"
@ -112,20 +104,81 @@
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number.Dimension"
tools:text="99:99 AM" />
</LinearLayout>
<Space
android:layout_width="0dp"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1.25"/>
android:layout_weight="1"
android:gravity="center"
android:minWidth="@dimen/nav_numbers_side_min_width"
android:orientation="vertical">
<TextView
android:id="@+id/time_estimate2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:lines="1"
android:textAlignment="center"
android:textAppearance="@style/MwmTextAppearance.NavMenu.Time.Dimension"
android:textSize="24sp"
android:visibility="gone"
tools:text="99:99 AM" />
<LinearLayout
android:id="@+id/time_values_container2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
tools:background="#20FF0000">
<TextView
android:id="@+id/time_hour_value2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:lines="1"
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number.Dimension"
android:textSize="16sp"
tools:text="999" />
<TextView
android:id="@+id/time_hour_dimen2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/margin_quarter"
android:includeFontPadding="false"
android:lines="1"
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number.Dimension"
android:textSize="12sp"
tools:text="h" />
<TextView
android:id="@+id/time_minute_value2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:lines="1"
android:textAlignment="center"
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number.Dimension"
android:textSize="16sp"
tools:text="99" />
<TextView
android:id="@+id/time_minute_dimen2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:lines="1"
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number.Dimension"
android:textSize="12sp"
tools:text="m" />
</LinearLayout>
</LinearLayout>
<Space
android:layout_width="19dp"
android:layout_height="match_parent"
android:layout_weight="1.25" />
<!-- Distance -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:minWidth="@dimen/nav_numbers_side_min_width">
android:minWidth="@dimen/nav_numbers_side_min_width"
android:orientation="vertical">
<TextView
android:id="@+id/distance_value"
android:layout_width="wrap_content"
@ -134,7 +187,6 @@
android:lines="1"
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number"
tools:text="99999" />
<TextView
android:id="@+id/distance_dimen"
android:layout_width="wrap_content"
@ -145,9 +197,8 @@
tools:background="#20FF0000"
tools:text="km" />
</LinearLayout>
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"/>
</LinearLayout>
android:layout_weight="0.5" />
</LinearLayout>

View file

@ -1,9 +1,7 @@
package app.organicmaps.widget.menu;
import android.content.res.ColorStateList;
import android.location.Location;
import android.util.Pair;
import android.util.TypedValue;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
@ -12,15 +10,15 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import app.organicmaps.R;
import app.organicmaps.location.LocationHelper;
import app.organicmaps.routing.RoutingInfo;
import app.organicmaps.sound.TtsPlayer;
import app.organicmaps.widget.FlatProgressView;
import app.organicmaps.util.Graphics;
import app.organicmaps.util.StringUtils;
import app.organicmaps.util.UiUtils;
import app.organicmaps.widget.FlatProgressView;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@ -42,14 +40,19 @@ public class NavMenu
private final TextView mTimeHourUnits;
private final TextView mTimeMinuteValue;
private final TextView mTimeMinuteUnits;
private final TextView mTimeHourValue2;
private final TextView mTimeHourUnits2;
private final TextView mTimeMinuteValue2;
private final TextView mTimeMinuteUnits2;
private final TextView mTimeEstimate;
private final TextView mTimeEstimate2;
private final TextView mDistanceValue;
private final TextView mDistanceUnits;
private final FlatProgressView mRouteProgress;
private final LinearLayout mTimeValueContainer;
private final AppCompatActivity mActivity;
private final NavMenuListener mNavMenuListener;
private LinearLayout mTimeValueContainer;
private LinearLayout mTimeValueContainer2;
private int currentPeekHeight = 0;
@ -66,7 +69,6 @@ public class NavMenu
mBottomSheetBackground.setOnClickListener(v -> collapseNavBottomSheet());
mBottomSheetBackground.setVisibility(View.GONE);
mBottomSheetBackground.setAlpha(0);
mTimeValueContainer = bottomFrame.findViewById(R.id.time_values_container);
mNavBottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback()
{
@Override
@ -97,10 +99,17 @@ public class NavMenu
mTimeHourUnits = bottomFrame.findViewById(R.id.time_hour_dimen);
mTimeMinuteValue = bottomFrame.findViewById(R.id.time_minute_value);
mTimeMinuteUnits = bottomFrame.findViewById(R.id.time_minute_dimen);
mTimeHourValue2 = bottomFrame.findViewById(R.id.time_hour_value2);
mTimeHourUnits2 = bottomFrame.findViewById(R.id.time_hour_dimen2);
mTimeMinuteValue2 = bottomFrame.findViewById(R.id.time_minute_value2);
mTimeMinuteUnits2 = bottomFrame.findViewById(R.id.time_minute_dimen2);
mTimeEstimate = bottomFrame.findViewById(R.id.time_estimate);
mTimeEstimate2 = bottomFrame.findViewById(R.id.time_estimate2);
mDistanceValue = bottomFrame.findViewById(R.id.distance_value);
mDistanceUnits = bottomFrame.findViewById(R.id.distance_dimen);
mRouteProgress = bottomFrame.findViewById(R.id.navigation_progress);
mTimeValueContainer = bottomFrame.findViewById(R.id.time_values_container);
mTimeValueContainer2 = bottomFrame.findViewById(R.id.time_values_container2);
// Bottom frame buttons
ImageView mSettings = bottomFrame.findViewById(R.id.settings);
@ -163,9 +172,9 @@ public class NavMenu
public void refreshTts()
{
mTts.setImageDrawable(TtsPlayer.isEnabled() ? Graphics.tint(mActivity, R.drawable.ic_voice_on,
R.attr.colorAccent)
: Graphics.tint(mActivity, R.drawable.ic_voice_off));
mTts.setImageDrawable(TtsPlayer.isEnabled() ? Graphics.tint(mActivity,
R.drawable.ic_voice_on, R.attr.colorAccent)
: Graphics.tint(mActivity, R.drawable.ic_voice_off));
}
@ -180,47 +189,39 @@ public class NavMenu
final long hours = TimeUnit.SECONDS.toHours(seconds);
final long minutes = TimeUnit.SECONDS.toMinutes(seconds) % 60;
mTimeMinuteValue.setText(String.valueOf(minutes));
mTimeMinuteValue2.setText(String.valueOf(minutes));
String min = mActivity.getResources().getString(R.string.minute);
mTimeMinuteUnits.setText(min);
mTimeValueContainer.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
changeTimes();
}
});
mTimeMinuteUnits2.setText(min);
mTimeValueContainer.setOnClickListener(v -> changeTimes());
if (hours == 0)
{
UiUtils.hide(mTimeHourUnits, mTimeHourValue);
UiUtils.hide(mTimeHourUnits2, mTimeHourValue2);
return;
}
UiUtils.setTextAndShow(mTimeHourValue, String.valueOf(hours));
UiUtils.setTextAndShow(mTimeHourValue2, String.valueOf(hours));
String hour = mActivity.getResources().getString(R.string.hour);
UiUtils.setTextAndShow(mTimeHourUnits, hour);
UiUtils.setTextAndShow(mTimeHourUnits2, hour);
}
private void changeTimes(){
float s1 = mTimeEstimate.getTextSize(), s2 = mTimeMinuteValue.getTextSize();
mTimeEstimate.setTextSize(TypedValue.COMPLEX_UNIT_PX, s2);
mTimeHourValue.setTextSize(TypedValue.COMPLEX_UNIT_PX, s1);
mTimeMinuteValue.setTextSize(TypedValue.COMPLEX_UNIT_PX, s1);
ColorStateList col = mTimeEstimate.getTextColors();
mTimeEstimate.setTextColor(mTimeMinuteValue.getTextColors());
mTimeMinuteUnits.setTextColor(col);
mTimeHourUnits.setTextColor(col);
mTimeMinuteValue.setTextColor(col);
mTimeHourValue.setTextColor(col);
if(mTimeValueContainer.getY() < mTimeEstimate.getY())
public void changeTimes()
{
if (mTimeValueContainer.getVisibility() == View.VISIBLE)
{
mTimeValueContainer.setY(mSpeedUnits.getY());
mTimeEstimate.setY(mTimeEstimate.getY()/2);
UiUtils.hide(mTimeValueContainer);
UiUtils.show(mTimeValueContainer2);
UiUtils.hide(mTimeEstimate);
UiUtils.show(mTimeEstimate2);
}
else
{
mTimeValueContainer.setY(mSpeedValue.getY());
mTimeEstimate.setY(mSpeedUnits.getY()/2);
UiUtils.show(mTimeValueContainer);
UiUtils.hide(mTimeValueContainer2);
UiUtils.show(mTimeEstimate);
UiUtils.hide(mTimeEstimate2);
}
}
@ -234,18 +235,9 @@ public class NavMenu
else
timeFormat = new SimpleDateFormat("h:mm aa", Locale.getDefault());
mTimeEstimate.setText(timeFormat.format(currentTime.getTime()));
mTimeEstimate.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
changeTimes();
}
});
mTimeEstimate2.setText(timeFormat.format(currentTime.getTime()));
mTimeEstimate2.setOnClickListener(v -> changeTimes());
}
private void updateSpeedView(@NonNull RoutingInfo info)
{
final Location last = LocationHelper.INSTANCE.getSavedLocation();