init
This commit is contained in:
parent
1ca97f727e
commit
7e3d3b9e79
7 changed files with 535 additions and 20 deletions
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/basic_item_body"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<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" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/switch_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"
|
||||
tools:checked="true" />
|
||||
|
||||
</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/icon_after_divider"
|
||||
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
|
||||
android:layout_width="@dimen/acceptable_touch_radius"
|
||||
android:layout_height="@dimen/acceptable_touch_radius"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
app:srcCompat="@drawable/ic_action_track_line_bold_color" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
101
OsmAnd/res/layout/trip_recording_fragment.xml
Normal file
101
OsmAnd/res/layout/trip_recording_fragment.xml
Normal file
|
@ -0,0 +1,101 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/bottom_sheet_content_margin"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/content_padding"
|
||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||
android:text="@string/monitoring_settings"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
|
||||
<include
|
||||
android:id="@+id/show_track_on_map"
|
||||
layout="@layout/bottom_sheet_with_switch_divider_and_additional_button" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="@dimen/bottom_sheet_content_margin_small"
|
||||
android:background="?attr/dashboard_divider" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/content_padding_small" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/title2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/save_track_interval_globally"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/interval_value_view"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="Interval value" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/up_down_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
app:srcCompat="@drawable/ic_action_arrow_down" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.slider.RangeSlider
|
||||
android:id="@+id/interval_slider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/save_track_interval_globally"
|
||||
android:stepSize="1"
|
||||
app:labelBehavior="gone" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/confirm_every_run"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="@dimen/content_padding"
|
||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||
android:minHeight="@dimen/context_menu_buttons_bottom_height"
|
||||
android:paddingLeft="@dimen/content_padding_small"
|
||||
android:paddingRight="@dimen/content_padding_small"
|
||||
android:text="@string/confirm_every_run"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:visibility="gone"
|
||||
osmand:typeface="@string/font_roboto_regular"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
-->
|
||||
|
||||
<string name="show_track_on_map">Show track on map</string>
|
||||
<string name="start_recording">Start recording</string>
|
||||
<string name="announcement_time_title">Announcement time</string>
|
||||
<string name="announcement_time_descr">Announcement time of different voice prompts depends on prompt type, current navigation speed and default navigation speed.</string>
|
||||
<string name="announcement_time_intervals">Time and distance intervals</string>
|
||||
|
|
|
@ -118,6 +118,7 @@ import net.osmand.plus.measurementtool.LoginBottomSheetFragment;
|
|||
import net.osmand.plus.measurementtool.MeasurementEditingContext;
|
||||
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
||||
import net.osmand.plus.measurementtool.SnapTrackWarningFragment;
|
||||
import net.osmand.plus.monitoring.TripRecordingBottomSheet;
|
||||
import net.osmand.plus.render.RendererRegistry;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
import net.osmand.plus.routepreparationmenu.ChooseRouteFragment;
|
||||
|
@ -2205,6 +2206,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
return getFragment(MeasurementToolFragment.TAG);
|
||||
}
|
||||
|
||||
public TripRecordingBottomSheet getTripRecordingBottomSheet() {
|
||||
return getFragment(TripRecordingBottomSheet.TAG);
|
||||
}
|
||||
|
||||
public ChooseRouteFragment getChooseRouteFragment() {
|
||||
return getFragment(ChooseRouteFragment.TAG);
|
||||
}
|
||||
|
@ -2221,7 +2226,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
return getFragment(SnapTrackWarningFragment.TAG);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public TrackMenuFragment getTrackMenuFragment() {
|
||||
return getFragment(TrackMenuFragment.TAG);
|
||||
}
|
||||
|
|
|
@ -100,12 +100,12 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
public void updateLocation(Location location) {
|
||||
liveMonitoringHelper.updateLocation(location);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLogoResourceId() {
|
||||
return R.drawable.ic_action_gps_info;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Drawable getAssetResourceImage() {
|
||||
return app.getUIUtilities().getIcon(R.drawable.trip_recording);
|
||||
|
@ -140,7 +140,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
private void registerWidget(MapActivity activity) {
|
||||
MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
|
||||
monitoringControl = createMonitoringControl(activity);
|
||||
|
||||
|
||||
layer.registerSideWidget(monitoringControl,
|
||||
R.drawable.ic_action_play_dark, R.string.map_widget_monitoring, "monitoring", false, 30);
|
||||
layer.recreateControls();
|
||||
|
@ -161,7 +161,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static final int[] SECONDS = new int[] {0, 1, 2, 3, 5, 10, 15, 20, 30, 60, 90};
|
||||
public static final int[] MINUTES = new int[] {2, 3, 5};
|
||||
public static final int[] MAX_INTERVAL_TO_SEND_MINUTES = new int[] {1, 2, 5, 10, 15, 20, 30, 60, 90, 2 * 60, 3 * 60, 4 * 60, 6 * 60, 12 * 60, 24 * 60};
|
||||
|
@ -287,7 +287,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
controlDialog(map, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
return monitoringControl;
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
public void saveCurrentTrack() {
|
||||
saveCurrentTrack(null, null);
|
||||
}
|
||||
|
||||
|
||||
public void saveCurrentTrack(@Nullable final Runnable onComplete) {
|
||||
saveCurrentTrack(onComplete, null);
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
SaveGPXBottomSheetFragment.showInstance(((FragmentActivity) a).getSupportFragmentManager(), result.getFilenames());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (onComplete != null) {
|
||||
onComplete.run();
|
||||
}
|
||||
|
@ -506,14 +506,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
if (choice.value || map == null) {
|
||||
runnable.run();
|
||||
} else {
|
||||
showIntervalChooseDialog(map, app.getString(R.string.save_track_interval_globally) + " : %s",
|
||||
app.getString(R.string.save_track_to_gpx_globally), SECONDS, MINUTES, choice, vs, showTrackSelection,
|
||||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
runnable.run();
|
||||
}
|
||||
});
|
||||
TripRecordingBottomSheet.showInstance(mapActivity.getSupportFragmentManager());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -588,7 +581,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
tv.setText(String.format(patternMsg, s));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
for (int i = 0; i < secondsLength + minutesLength - 1; i++) {
|
||||
if (i < secondsLength) {
|
||||
if (v.value <= seconds[i] * 1000) {
|
||||
|
|
|
@ -0,0 +1,335 @@
|
|||
package net.osmand.plus.monitoring;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.google.android.material.slider.RangeSlider;
|
||||
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.NavigationService;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.UiUtilities.DialogButtonType;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.track.TrackAppearanceFragment;
|
||||
|
||||
import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT;
|
||||
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_BOLD;
|
||||
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_MEDIUM;
|
||||
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES;
|
||||
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS;
|
||||
|
||||
public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
|
||||
|
||||
public static final String TAG = TripRecordingBottomSheet.class.getSimpleName();
|
||||
|
||||
private OsmandApplication app;
|
||||
private OsmandSettings settings;
|
||||
|
||||
private ImageView upDownBtn;
|
||||
private SwitchCompat confirmEveryRun;
|
||||
|
||||
private boolean infoExpanded;
|
||||
|
||||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
app = requiredMyApplication();
|
||||
settings = app.getSettings();
|
||||
Context context = requireContext();
|
||||
|
||||
LayoutInflater inflater = UiUtilities.getInflater(context, nightMode);
|
||||
View itemView = inflater.inflate(R.layout.trip_recording_fragment, null, false);
|
||||
items.add(new BottomSheetItemWithDescription.Builder()
|
||||
.setCustomView(itemView)
|
||||
.create());
|
||||
|
||||
int padding = getResources().getDimensionPixelSize(R.dimen.content_padding_small);
|
||||
final int paddingSmall = getResources().getDimensionPixelSize(R.dimen.content_padding_small);
|
||||
|
||||
items.add(new DividerSpaceItem(context, padding));
|
||||
|
||||
LinearLayout showTrackOnMapView = itemView.findViewById(R.id.show_track_on_map);
|
||||
TextView showTrackOnMapTitle = showTrackOnMapView.findViewById(R.id.title);
|
||||
showTrackOnMapTitle.setText(R.string.show_track_on_map);
|
||||
|
||||
ImageView trackAppearanceIcon = showTrackOnMapView.findViewById(R.id.icon_after_divider);
|
||||
Drawable drawable = app.getUIUtilities().getIcon(R.drawable.ic_action_track_line_bold_direction,
|
||||
nightMode ? R.color.profile_icon_color_red_dark : R.color.profile_icon_color_red_light);
|
||||
trackAppearanceIcon.setImageDrawable(drawable);
|
||||
trackAppearanceIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
hide();
|
||||
SelectedGpxFile selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
||||
TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
upDownBtn = itemView.findViewById(R.id.up_down_button);
|
||||
upDownBtn.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
toggleInfoView();
|
||||
}
|
||||
});
|
||||
|
||||
final int secondsLength = SECONDS.length;
|
||||
final int minutesLength = MINUTES.length;
|
||||
|
||||
RangeSlider intervalSlider = itemView.findViewById(R.id.interval_slider);
|
||||
final TextView intervalValueView = itemView.findViewById(R.id.interval_value_view);
|
||||
String text = getString(R.string.save_track_interval_globally);
|
||||
String textValue = getString(R.string.int_continuosly);
|
||||
String textAll = getString(R.string.ltr_or_rtl_combine_via_colon, text, textValue);
|
||||
Typeface typeface = FontCache.getRobotoMedium(app);
|
||||
SpannableString spannableString = UiUtilities.createCustomFontSpannable(typeface, textAll, textValue);
|
||||
intervalValueView.setText(spannableString);
|
||||
intervalSlider.setValueTo(secondsLength + minutesLength - 1);
|
||||
intervalSlider.addOnChangeListener(new RangeSlider.OnChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onValueChange(@NonNull RangeSlider slider, float value, boolean fromUser) {
|
||||
String s;
|
||||
int progress = (int) value;
|
||||
if (progress == 0) {
|
||||
s = getString(R.string.int_continuosly);
|
||||
settings.SAVE_GLOBAL_TRACK_INTERVAL.set(0);
|
||||
} else {
|
||||
if (progress < secondsLength) {
|
||||
s = SECONDS[progress] + " " + getString(R.string.int_seconds);
|
||||
settings.SAVE_GLOBAL_TRACK_INTERVAL.set(SECONDS[progress] * 1000);
|
||||
} else {
|
||||
s = MINUTES[progress - secondsLength] + " " + getString(R.string.int_min);
|
||||
settings.SAVE_GLOBAL_TRACK_INTERVAL.set(MINUTES[progress - secondsLength] * 60 * 1000);
|
||||
}
|
||||
}
|
||||
intervalValueView.setText(String.format(" : %s", s));
|
||||
}
|
||||
});
|
||||
for (int i = 0; i < secondsLength + minutesLength - 1; i++) {
|
||||
if (i < secondsLength) {
|
||||
if (settings.SAVE_GLOBAL_TRACK_INTERVAL.get() <= SECONDS[i] * 1000) {
|
||||
intervalSlider.setValues((float) i);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (settings.SAVE_GLOBAL_TRACK_INTERVAL.get() <= MINUTES[i - secondsLength] * 1000 * 60) {
|
||||
intervalSlider.setValues((float) i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean checked = !settings.SAVE_GLOBAL_TRACK_REMEMBER.get();
|
||||
confirmEveryRun = itemView.findViewById(R.id.confirm_every_run);
|
||||
confirmEveryRun.setBackgroundResource(nightMode ? R.drawable.layout_bg_dark : R.drawable.layout_bg);
|
||||
confirmEveryRun.setChecked(checked);
|
||||
confirmEveryRun.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
setBackgroundAndPadding(isChecked, paddingSmall);
|
||||
settings.SAVE_GLOBAL_TRACK_REMEMBER.set(!isChecked);
|
||||
}
|
||||
});
|
||||
setBackgroundAndPadding(checked, paddingSmall);
|
||||
UiUtilities.setupCompoundButton(confirmEveryRun, nightMode, PROFILE_DEPENDENT);
|
||||
|
||||
SwitchCompat showTrackOnMapButton = showTrackOnMapView.findViewById(R.id.switch_button);
|
||||
showTrackOnMapButton.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null);
|
||||
showTrackOnMapButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), isChecked, false);
|
||||
}
|
||||
});
|
||||
UiUtilities.setupCompoundButton(showTrackOnMapButton, nightMode, PROFILE_DEPENDENT);
|
||||
|
||||
updateUpDownBtn();
|
||||
}
|
||||
|
||||
|
||||
public void show() {
|
||||
Dialog dialog = getDialog();
|
||||
if (dialog != null) {
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
Dialog dialog = getDialog();
|
||||
if (dialog != null) {
|
||||
dialog.hide();
|
||||
}
|
||||
}
|
||||
|
||||
// private void updateAppearanceIcon() {
|
||||
// Drawable icon = getTrackIcon(app, trackDrawInfo.getWidth(), trackDrawInfo.isShowArrows(), trackDrawInfo.getColor());
|
||||
// trackIcon.setImageDrawable(icon);
|
||||
// }
|
||||
|
||||
public static Drawable getTrackIcon(OsmandApplication app, String widthAttr, boolean showArrows, @ColorInt int color) {
|
||||
int widthIconId = getWidthIconId(widthAttr);
|
||||
Drawable widthIcon = app.getUIUtilities().getPaintedIcon(widthIconId, color);
|
||||
|
||||
int strokeIconId = getStrokeIconId(widthAttr);
|
||||
int strokeColor = UiUtilities.getColorWithAlpha(Color.BLACK, 0.7f);
|
||||
Drawable strokeIcon = app.getUIUtilities().getPaintedIcon(strokeIconId, strokeColor);
|
||||
|
||||
Drawable transparencyIcon = getTransparencyIcon(app, widthAttr, color);
|
||||
if (showArrows) {
|
||||
int arrowsIconId = getArrowsIconId(widthAttr);
|
||||
int contrastColor = UiUtilities.getContrastColor(app, color, false);
|
||||
Drawable arrows = app.getUIUtilities().getPaintedIcon(arrowsIconId, contrastColor);
|
||||
return UiUtilities.getLayeredIcon(transparencyIcon, widthIcon, strokeIcon, arrows);
|
||||
}
|
||||
return UiUtilities.getLayeredIcon(transparencyIcon, widthIcon, strokeIcon);
|
||||
}
|
||||
|
||||
private static Drawable getTransparencyIcon(OsmandApplication app, String widthAttr, @ColorInt int color) {
|
||||
int transparencyIconId = getTransparencyIconId(widthAttr);
|
||||
int colorWithoutAlpha = UiUtilities.removeAlpha(color);
|
||||
int transparencyColor = UiUtilities.getColorWithAlpha(colorWithoutAlpha, 0.8f);
|
||||
return app.getUIUtilities().getPaintedIcon(transparencyIconId, transparencyColor);
|
||||
}
|
||||
|
||||
public static int getTransparencyIconId(String widthAttr) {
|
||||
if (TRACK_WIDTH_BOLD.equals(widthAttr)) {
|
||||
return R.drawable.ic_action_track_line_bold_transparency;
|
||||
} else if (TRACK_WIDTH_MEDIUM.equals(widthAttr)) {
|
||||
return R.drawable.ic_action_track_line_medium_transparency;
|
||||
} else {
|
||||
return R.drawable.ic_action_track_line_thin_transparency;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getArrowsIconId(String widthAttr) {
|
||||
if (TRACK_WIDTH_BOLD.equals(widthAttr)) {
|
||||
return R.drawable.ic_action_track_line_bold_direction;
|
||||
} else if (TRACK_WIDTH_MEDIUM.equals(widthAttr)) {
|
||||
return R.drawable.ic_action_track_line_medium_direction;
|
||||
} else {
|
||||
return R.drawable.ic_action_track_line_thin_direction;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getStrokeIconId(String widthAttr) {
|
||||
if (TRACK_WIDTH_BOLD.equals(widthAttr)) {
|
||||
return R.drawable.ic_action_track_line_bold_stroke;
|
||||
} else if (TRACK_WIDTH_MEDIUM.equals(widthAttr)) {
|
||||
return R.drawable.ic_action_track_line_medium_stroke;
|
||||
} else {
|
||||
return R.drawable.ic_action_track_line_thin_stroke;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getWidthIconId(String widthAttr) {
|
||||
if (TRACK_WIDTH_BOLD.equals(widthAttr)) {
|
||||
return R.drawable.ic_action_track_line_bold_color;
|
||||
} else if (TRACK_WIDTH_MEDIUM.equals(widthAttr)) {
|
||||
return R.drawable.ic_action_track_line_medium_color;
|
||||
} else {
|
||||
return R.drawable.ic_action_track_line_thin_color;
|
||||
}
|
||||
}
|
||||
|
||||
private void setBackgroundAndPadding(boolean isChecked, int paddingSmall) {
|
||||
if (nightMode) {
|
||||
confirmEveryRun.setBackgroundResource(
|
||||
isChecked ? R.drawable.layout_bg_dark_solid : R.drawable.layout_bg_dark);
|
||||
} else {
|
||||
confirmEveryRun.setBackgroundResource(
|
||||
isChecked ? R.drawable.layout_bg_solid : R.drawable.layout_bg);
|
||||
}
|
||||
confirmEveryRun.setPadding(paddingSmall, 0, paddingSmall, 0);
|
||||
}
|
||||
|
||||
private void updateUpDownBtn() {
|
||||
int iconId = infoExpanded ? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up;
|
||||
upDownBtn.setImageDrawable(getContentIcon(iconId));
|
||||
}
|
||||
|
||||
private void toggleInfoView() {
|
||||
infoExpanded = !infoExpanded;
|
||||
AndroidUiHelper.updateVisibility(confirmEveryRun, infoExpanded);
|
||||
updateUpDownBtn();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean useVerticalButtons() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRightBottomButtonTextId() {
|
||||
return R.string.start_recording;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDismissButtonTextId() {
|
||||
return R.string.shared_string_cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DialogButtonType getRightBottomButtonType() {
|
||||
return DialogButtonType.PRIMARY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondDividerHeight() {
|
||||
return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_icon_margin);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRightBottomButtonClick() {
|
||||
app.getSavingTrackHelper().startNewSegment();
|
||||
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(true);
|
||||
app.startNavigationService(NavigationService.USED_BY_GPX);
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MapActivity getMapActivity() {
|
||||
Activity activity = getActivity();
|
||||
if (activity instanceof MapActivity) {
|
||||
return (MapActivity) activity;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void showInstance(@NonNull FragmentManager fragmentManager) {
|
||||
if (!fragmentManager.isStateSaved() && fragmentManager.findFragmentByTag(TripRecordingBottomSheet.TAG) == null) {
|
||||
TripRecordingBottomSheet fragment = new TripRecordingBottomSheet();
|
||||
fragment.show(fragmentManager, TAG);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -42,6 +42,7 @@ import net.osmand.plus.dialogs.GpxAppearanceAdapter;
|
|||
import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem;
|
||||
import net.osmand.plus.dialogs.GpxAppearanceAdapter.GpxAppearanceAdapterType;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.monitoring.TripRecordingBottomSheet;
|
||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
|
||||
import net.osmand.plus.settings.backend.CommonPreference;
|
||||
|
@ -160,8 +161,13 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
public void handleOnBackPressed() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
TripRecordingBottomSheet fragment = mapActivity.getTripRecordingBottomSheet();
|
||||
if (fragment != null) {
|
||||
fragment.show();
|
||||
} else {
|
||||
mapActivity.launchPrevActivityIntent();
|
||||
}
|
||||
dismissImmediate();
|
||||
mapActivity.launchPrevActivityIntent();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -405,7 +411,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
}
|
||||
}
|
||||
|
||||
public Drawable getTrackIcon(OsmandApplication app, String widthAttr, boolean showArrows, @ColorInt int color) {
|
||||
public static Drawable getTrackIcon(OsmandApplication app, String widthAttr, boolean showArrows, @ColorInt int color) {
|
||||
int widthIconId = getWidthIconId(widthAttr);
|
||||
Drawable widthIcon = app.getUIUtilities().getPaintedIcon(widthIconId, color);
|
||||
|
||||
|
@ -423,7 +429,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
return UiUtilities.getLayeredIcon(transparencyIcon, widthIcon, strokeIcon);
|
||||
}
|
||||
|
||||
private Drawable getTransparencyIcon(OsmandApplication app, String widthAttr, @ColorInt int color) {
|
||||
private static Drawable getTransparencyIcon(OsmandApplication app, String widthAttr, @ColorInt int color) {
|
||||
int transparencyIconId = getTransparencyIconId(widthAttr);
|
||||
int colorWithoutAlpha = UiUtilities.removeAlpha(color);
|
||||
int transparencyColor = UiUtilities.getColorWithAlpha(colorWithoutAlpha, 0.8f);
|
||||
|
|
Loading…
Reference in a new issue