commit
7567a1b3ae
2 changed files with 155 additions and 25 deletions
|
@ -0,0 +1,96 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:minHeight="@dimen/bottom_sheet_selected_item_title_height">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/basic_item_body"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:paddingStart="@dimen/content_padding"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingEnd="0dp"
|
||||||
|
android:paddingRight="0dp">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/icon"
|
||||||
|
android:layout_width="@dimen/standard_icon_size"
|
||||||
|
android:layout_height="@dimen/standard_icon_size"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||||
|
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||||
|
tools:src="@drawable/list_destination" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
|
tools:text="Some title" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/description"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:textAppearance="@style/TextAppearance.ContextMenuSubtitle"
|
||||||
|
tools:text="Some description" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/compound_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginStart="@dimen/bottom_sheet_content_margin"
|
||||||
|
android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
|
||||||
|
android:layout_marginEnd="@dimen/content_padding_half"
|
||||||
|
android:layout_marginRight="@dimen/content_padding_half"
|
||||||
|
android:background="@null"
|
||||||
|
android:clickable="false"
|
||||||
|
android:focusable="false"
|
||||||
|
android:focusableInTouchMode="false" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/additional_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="@dimen/content_padding_half"
|
||||||
|
android:layout_marginBottom="@dimen/content_padding_half"
|
||||||
|
android:background="?attr/divider_color_basic" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/additional_button_icon"
|
||||||
|
android:layout_width="@dimen/standard_icon_size"
|
||||||
|
android:layout_height="@dimen/standard_icon_size"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
|
tools:src="@drawable/ic_action_info_dark" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -2,9 +2,12 @@ package net.osmand.plus.routepreparationmenu;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -19,6 +22,7 @@ import net.osmand.AndroidUtils;
|
||||||
import net.osmand.CallbackWithObject;
|
import net.osmand.CallbackWithObject;
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.StateChangedListener;
|
import net.osmand.StateChangedListener;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.plus.OsmAndLocationSimulation;
|
import net.osmand.plus.OsmAndLocationSimulation;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -168,32 +172,62 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
private BaseBottomSheetItem createMuteSoundItem(final LocalRoutingParameter optionsItem) {
|
private BaseBottomSheetItem createMuteSoundItem(final LocalRoutingParameter optionsItem) {
|
||||||
boolean active = !routingHelper.getVoiceRouter().isMuteForMode(applicationMode);
|
boolean active = !routingHelper.getVoiceRouter().isMuteForMode(applicationMode);
|
||||||
final BottomSheetItemWithCompoundButton[] muteSoundItem = new BottomSheetItemWithCompoundButton[1];
|
int selectedModeColor = ContextCompat.getColor(app, selectedModeColorId);
|
||||||
muteSoundItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
final View itemView = UiUtilities.getInflater(app, nightMode).inflate(
|
||||||
.setCompoundButtonColorId(selectedModeColorId)
|
R.layout.bottom_sheet_item_with_descr_switch_and_additional_button_56dp, null, false);
|
||||||
.setChecked(active)
|
final ImageView icon = itemView.findViewById(R.id.icon);
|
||||||
.setDescription(getString(R.string.voice_announcements))
|
TextView tvTitle = itemView.findViewById(R.id.title);
|
||||||
.setIcon(getContentIcon(active ? optionsItem.getActiveIconId() : optionsItem.getDisabledIconId()))
|
TextView tvDescription = itemView.findViewById(R.id.description);
|
||||||
.setTitle(getString(R.string.shared_string_sound))
|
View basicItem = itemView.findViewById(R.id.basic_item_body);
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp)
|
final CompoundButton cb = itemView.findViewById(R.id.compound_button);
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
View voicePromptsBtn = itemView.findViewById(R.id.additional_button);
|
||||||
@Override
|
ImageView voicePromptsBtnImage = itemView.findViewById(R.id.additional_button_icon);
|
||||||
public void onClick(View v) {
|
|
||||||
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
|
tvTitle.setText(getString(R.string.shared_string_sound));
|
||||||
boolean active = !routingHelper.getVoiceRouter().isMuteForMode(applicationMode);
|
tvDescription.setText(getString(R.string.voice_announcements));
|
||||||
routingHelper.getVoiceRouter().setMuteForMode(applicationMode, active);
|
icon.setImageDrawable(getContentIcon(active ?
|
||||||
String voiceProvider = app.getSettings().VOICE_PROVIDER.getModeValue(applicationMode);
|
optionsItem.getActiveIconId() : optionsItem.getDisabledIconId()));
|
||||||
if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) {
|
cb.setChecked(active);
|
||||||
OsmAndDialogs.showVoiceProviderDialog(mapActivity, applicationMode, false);
|
cb.setFocusable(false);
|
||||||
} else {
|
UiUtilities.setupCompoundButton(nightMode, selectedModeColor, cb);
|
||||||
muteSoundItem[0].setChecked(!active);
|
|
||||||
muteSoundItem[0].setIcon(getContentIcon(!active ? optionsItem.getActiveIconId() : optionsItem.getDisabledIconId()));
|
basicItem.setOnClickListener(new View.OnClickListener() {
|
||||||
}
|
@Override
|
||||||
updateMenu();
|
public void onClick(View v) {
|
||||||
}
|
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
|
||||||
})
|
boolean active = !routingHelper.getVoiceRouter().isMuteForMode(applicationMode);
|
||||||
|
routingHelper.getVoiceRouter().setMuteForMode(applicationMode, active);
|
||||||
|
String voiceProvider = app.getSettings().VOICE_PROVIDER.getModeValue(applicationMode);
|
||||||
|
if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) {
|
||||||
|
OsmAndDialogs.showVoiceProviderDialog(mapActivity, applicationMode, false);
|
||||||
|
} else {
|
||||||
|
cb.setChecked(!active);
|
||||||
|
icon.setImageDrawable(getContentIcon(!active ? optionsItem.getActiveIconId() : optionsItem.getDisabledIconId()));
|
||||||
|
}
|
||||||
|
updateMenu();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Drawable drawable = app.getUIUtilities().getIcon(R.drawable.ic_action_settings,
|
||||||
|
nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
Drawable activeDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_settings, selectedModeColorId);
|
||||||
|
drawable = AndroidUtils.createPressedStateListDrawable(drawable, activeDrawable);
|
||||||
|
}
|
||||||
|
voicePromptsBtnImage.setImageDrawable(drawable);
|
||||||
|
|
||||||
|
voicePromptsBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
BaseSettingsFragment.showInstance(
|
||||||
|
mapActivity, BaseSettingsFragment.SettingsScreenType.VOICE_ANNOUNCES);
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return new BaseBottomSheetItem.Builder()
|
||||||
|
.setCustomView(itemView)
|
||||||
.create();
|
.create();
|
||||||
return muteSoundItem[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private BaseBottomSheetItem createTimeConditionalRoutingItem(final LocalRoutingParameter optionsItem) {
|
private BaseBottomSheetItem createTimeConditionalRoutingItem(final LocalRoutingParameter optionsItem) {
|
||||||
|
|
Loading…
Reference in a new issue