many fixes
This commit is contained in:
parent
e1ea331bfb
commit
ce9b56de2d
7 changed files with 80 additions and 126 deletions
|
@ -413,6 +413,4 @@
|
||||||
|
|
||||||
<dimen name="radioButtonSize">32dp</dimen>
|
<dimen name="radioButtonSize">32dp</dimen>
|
||||||
<dimen name="checkBoxSize">24dp</dimen>
|
<dimen name="checkBoxSize">24dp</dimen>
|
||||||
|
|
||||||
<dimen name="zero">0dp</dimen>
|
|
||||||
</resources>
|
</resources>
|
|
@ -1,11 +1,8 @@
|
||||||
package net.osmand.plus.monitoring;
|
package net.osmand.plus.monitoring;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -15,10 +12,8 @@ import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
|
||||||
import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.ItemType;
|
import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.ItemType;
|
||||||
import net.osmand.plus.widgets.TextViewEx;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.AppCompatImageView;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
|
@ -46,7 +41,7 @@ public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogF
|
||||||
items.add(new DividerSpaceItem(app, verticalBig));
|
items.add(new DividerSpaceItem(app, verticalBig));
|
||||||
|
|
||||||
items.add(new BaseBottomSheetItem.Builder()
|
items.add(new BaseBottomSheetItem.Builder()
|
||||||
.setCustomView(setupBtn(inflater, ItemType.CLEAR_DATA))
|
.setCustomView(TripRecordingActiveBottomSheet.createButton(inflater, ItemType.CLEAR_DATA, nightMode))
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -59,7 +54,7 @@ public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogF
|
||||||
items.add(new DividerSpaceItem(app, verticalBig));
|
items.add(new DividerSpaceItem(app, verticalBig));
|
||||||
|
|
||||||
items.add(new BaseBottomSheetItem.Builder()
|
items.add(new BaseBottomSheetItem.Builder()
|
||||||
.setCustomView(setupBtn(inflater, ItemType.CANCEL))
|
.setCustomView(TripRecordingActiveBottomSheet.createButton(inflater, ItemType.CANCEL, nightMode))
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -71,41 +66,6 @@ public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogF
|
||||||
items.add(new DividerSpaceItem(app, verticalSmall));
|
items.add(new DividerSpaceItem(app, verticalSmall));
|
||||||
}
|
}
|
||||||
|
|
||||||
private View setupBtn(LayoutInflater inflater, ItemType type) {
|
|
||||||
View button = inflater.inflate(R.layout.bottom_sheet_button_with_icon, null);
|
|
||||||
button.setTag(type);
|
|
||||||
Context context = button.getContext();
|
|
||||||
LinearLayout container = button.findViewById(R.id.button_container);
|
|
||||||
container.setClickable(false);
|
|
||||||
container.setFocusable(false);
|
|
||||||
|
|
||||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
|
||||||
int horizontal = context.getResources().getDimensionPixelSize(R.dimen.content_padding);
|
|
||||||
params.setMargins(horizontal, 0, horizontal, 0);
|
|
||||||
button.setLayoutParams(params);
|
|
||||||
|
|
||||||
if (type.getTitleId() != null) {
|
|
||||||
UiUtilities.setupDialogButton(nightMode, button, type.getEffect(), type.getTitleId());
|
|
||||||
}
|
|
||||||
|
|
||||||
TextViewEx title = button.findViewById(R.id.button_text);
|
|
||||||
int margin = context.getResources().getDimensionPixelSize(R.dimen.context_menu_padding_margin_medium);
|
|
||||||
UiUtilities.setMargins(title, 0, margin, 0, margin);
|
|
||||||
|
|
||||||
int colorRes;
|
|
||||||
if (type.getEffect() == UiUtilities.DialogButtonType.SECONDARY_HARMFUL) {
|
|
||||||
colorRes = R.color.color_osm_edit_delete;
|
|
||||||
} else {
|
|
||||||
colorRes = nightMode ? R.color.dlg_btn_secondary_text_dark : R.color.dlg_btn_secondary_text_light;
|
|
||||||
}
|
|
||||||
AppCompatImageView icon = button.findViewById(R.id.icon);
|
|
||||||
if (type.getIconId() != null) {
|
|
||||||
icon.setImageDrawable(getIcon(type.getIconId(), colorRes));
|
|
||||||
}
|
|
||||||
|
|
||||||
return button;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
|
@ -19,6 +19,7 @@ import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.widget.AppCompatCheckBox;
|
import androidx.appcompat.widget.AppCompatCheckBox;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
import com.google.android.material.slider.Slider;
|
import com.google.android.material.slider.Slider;
|
||||||
|
|
||||||
|
@ -326,13 +327,13 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void controlDialog(final Activity activity, final boolean showTrackSelection) {
|
public void controlDialog(final Activity activity, final boolean showTrackSelection) {
|
||||||
|
FragmentManager fragmentManager = ((FragmentActivity) activity).getSupportFragmentManager();
|
||||||
if (hasDataToSave() || wasTrackMonitored()) {
|
if (hasDataToSave() || wasTrackMonitored()) {
|
||||||
FragmentActivity fragmentActivity = (FragmentActivity) activity;
|
TripRecordingActiveBottomSheet.showInstance(fragmentManager, getCurrentTrack());
|
||||||
TripRecordingActiveBottomSheet.showInstance(fragmentActivity.getSupportFragmentManager(), getCurrentTrack());
|
|
||||||
} else {
|
} else {
|
||||||
FragmentActivity fragmentActivity = (FragmentActivity) activity;
|
TripRecordingBottomSheet.showInstance(fragmentManager);
|
||||||
TripRecordingBottomSheet.showInstance(fragmentActivity.getSupportFragmentManager());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*final boolean wasTrackMonitored = settings.SAVE_GLOBAL_TRACK_TO_GPX.get();
|
/*final boolean wasTrackMonitored = settings.SAVE_GLOBAL_TRACK_TO_GPX.get();
|
||||||
final boolean nightMode;
|
final boolean nightMode;
|
||||||
if (activity instanceof MapActivity) {
|
if (activity instanceof MapActivity) {
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
package net.osmand.plus.monitoring;
|
package net.osmand.plus.monitoring;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.UiUtilities.DialogButtonType;
|
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
|
@ -19,10 +15,8 @@ import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
|
||||||
import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.ItemType;
|
import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.ItemType;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.widgets.TextViewEx;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.AppCompatImageView;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
|
@ -60,7 +54,7 @@ public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragm
|
||||||
items.add(new DividerSpaceItem(app, verticalBig));
|
items.add(new DividerSpaceItem(app, verticalBig));
|
||||||
|
|
||||||
items.add(new BaseBottomSheetItem.Builder()
|
items.add(new BaseBottomSheetItem.Builder()
|
||||||
.setCustomView(setupButton(inflater, ItemType.STOP_AND_DISCARD))
|
.setCustomView(TripRecordingActiveBottomSheet.createButton(inflater, ItemType.STOP_AND_DISCARD, nightMode))
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -78,7 +72,7 @@ public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragm
|
||||||
items.add(new DividerSpaceItem(app, verticalBig));
|
items.add(new DividerSpaceItem(app, verticalBig));
|
||||||
|
|
||||||
items.add(new BaseBottomSheetItem.Builder()
|
items.add(new BaseBottomSheetItem.Builder()
|
||||||
.setCustomView(setupButton(inflater, ItemType.SAVE_AND_STOP))
|
.setCustomView(TripRecordingActiveBottomSheet.createButton(inflater, ItemType.SAVE_AND_STOP, nightMode))
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -95,7 +89,7 @@ public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragm
|
||||||
items.add(new DividerSpaceItem(app, verticalSmall));
|
items.add(new DividerSpaceItem(app, verticalSmall));
|
||||||
|
|
||||||
items.add(new BaseBottomSheetItem.Builder()
|
items.add(new BaseBottomSheetItem.Builder()
|
||||||
.setCustomView(setupButton(inflater, ItemType.CANCEL))
|
.setCustomView(TripRecordingActiveBottomSheet.createButton(inflater, ItemType.CANCEL, nightMode))
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -108,47 +102,6 @@ public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragm
|
||||||
items.add(new DividerSpaceItem(app, verticalSmall));
|
items.add(new DividerSpaceItem(app, verticalSmall));
|
||||||
}
|
}
|
||||||
|
|
||||||
private View setupButton(LayoutInflater inflater, ItemType type) {
|
|
||||||
View button = inflater.inflate(R.layout.bottom_sheet_button_with_icon, null);
|
|
||||||
button.setTag(type);
|
|
||||||
Context context = button.getContext();
|
|
||||||
LinearLayout container = button.findViewById(R.id.button_container);
|
|
||||||
container.setClickable(false);
|
|
||||||
container.setFocusable(false);
|
|
||||||
|
|
||||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
|
||||||
int horizontal = context.getResources().getDimensionPixelSize(R.dimen.content_padding);
|
|
||||||
params.setMargins(horizontal, 0, horizontal, 0);
|
|
||||||
button.setLayoutParams(params);
|
|
||||||
|
|
||||||
if (type.getTitleId() != null) {
|
|
||||||
UiUtilities.setupDialogButton(nightMode, button, type.getEffect(), type.getTitleId());
|
|
||||||
}
|
|
||||||
|
|
||||||
TextViewEx title = button.findViewById(R.id.button_text);
|
|
||||||
int margin = context.getResources().getDimensionPixelSize(R.dimen.context_menu_padding_margin_medium);
|
|
||||||
UiUtilities.setMargins(title, 0, margin, 0, margin);
|
|
||||||
|
|
||||||
int colorRes;
|
|
||||||
if (type.getEffect() == DialogButtonType.SECONDARY_HARMFUL) {
|
|
||||||
colorRes = R.color.color_osm_edit_delete;
|
|
||||||
} else {
|
|
||||||
colorRes = nightMode ? R.color.dlg_btn_secondary_text_dark : R.color.dlg_btn_secondary_text_light;
|
|
||||||
}
|
|
||||||
AppCompatImageView icon = button.findViewById(R.id.icon);
|
|
||||||
if (type.getIconId() != null) {
|
|
||||||
icon.setImageDrawable(getIcon(type.getIconId(), colorRes));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == ItemType.STOP_AND_DISCARD) {
|
|
||||||
int size = context.getResources().getDimensionPixelSize(R.dimen.map_widget_height);
|
|
||||||
LinearLayout.LayoutParams iconParams = new LinearLayout.LayoutParams(size, size);
|
|
||||||
icon.setLayoutParams(iconParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
return button;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.plus.monitoring;
|
package net.osmand.plus.monitoring;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -27,9 +28,9 @@ import androidx.annotation.StringRes;
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
import androidx.appcompat.widget.AppCompatImageView;
|
import androidx.appcompat.widget.AppCompatImageView;
|
||||||
import androidx.appcompat.widget.SwitchCompat;
|
import androidx.appcompat.widget.SwitchCompat;
|
||||||
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.graphics.drawable.DrawableCompat;
|
import androidx.core.graphics.drawable.DrawableCompat;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.SavingTrackHelper;
|
import net.osmand.plus.activities.SavingTrackHelper;
|
||||||
import net.osmand.plus.activities.SavingTrackHelper.SaveGpxResult;
|
import net.osmand.plus.activities.SavingTrackHelper.SaveGpxResult;
|
||||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.helpers.FontCache;
|
import net.osmand.plus.helpers.FontCache;
|
||||||
import net.osmand.plus.myplaces.SaveCurrentTrackTask;
|
import net.osmand.plus.myplaces.SaveCurrentTrackTask;
|
||||||
|
@ -69,7 +70,8 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
public static final String TAG = TripRecordingActiveBottomSheet.class.getSimpleName();
|
public static final String TAG = TripRecordingActiveBottomSheet.class.getSimpleName();
|
||||||
private static final Log log = PlatformUtil.getLog(TripRecordingActiveBottomSheet.class);
|
private static final Log log = PlatformUtil.getLog(TripRecordingActiveBottomSheet.class);
|
||||||
private static final String UPDATE_CURRENT_GPX_FILE = "update_current_gpx_file";
|
private static final String UPDATE_CURRENT_GPX_FILE = "update_current_gpx_file";
|
||||||
private static final int GENERAL_UPDATE_INTERVAL = 1000;
|
private static final int GENERAL_UPDATE_GPS_INTERVAL = 1000;
|
||||||
|
private static final int GENERAL_UPDATE_SAVE_INTERVAL = 1000;
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
|
@ -121,7 +123,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
final FragmentManager fragmentManager = getFragmentManager();
|
final FragmentManager fragmentManager = getFragmentManager();
|
||||||
|
|
||||||
View itemView = inflater.inflate(R.layout.trip_recording_active_fragment, null, false);
|
View itemView = inflater.inflate(R.layout.trip_recording_active_fragment, null, false);
|
||||||
items.add(new BottomSheetItemWithDescription.Builder()
|
items.add(new BaseBottomSheetItem.Builder()
|
||||||
.setCustomView(itemView)
|
.setCustomView(itemView)
|
||||||
.create());
|
.create());
|
||||||
|
|
||||||
|
@ -141,7 +143,8 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
|
|
||||||
RecyclerView statBlocks = itemView.findViewById(R.id.block_statistics);
|
RecyclerView statBlocks = itemView.findViewById(R.id.block_statistics);
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
if (savedInstanceState.containsKey(UPDATE_CURRENT_GPX_FILE) && savedInstanceState.getBoolean(UPDATE_CURRENT_GPX_FILE)) {
|
if (savedInstanceState.containsKey(UPDATE_CURRENT_GPX_FILE)
|
||||||
|
&& savedInstanceState.getBoolean(UPDATE_CURRENT_GPX_FILE)) {
|
||||||
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,6 +335,43 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
setItemBackground(button != null ? button : (LinearLayout) view, enabled);
|
setItemBackground(button != null ? button : (LinearLayout) view, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static View createButton(LayoutInflater inflater, ItemType type, boolean nightMode) {
|
||||||
|
View button = inflater.inflate(R.layout.bottom_sheet_button_with_icon, null);
|
||||||
|
button.setTag(type);
|
||||||
|
Context context = button.getContext();
|
||||||
|
LinearLayout container = button.findViewById(R.id.button_container);
|
||||||
|
container.setClickable(false);
|
||||||
|
container.setFocusable(false);
|
||||||
|
|
||||||
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||||
|
int horizontal = context.getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||||
|
params.setMargins(horizontal, 0, horizontal, 0);
|
||||||
|
button.setLayoutParams(params);
|
||||||
|
|
||||||
|
if (type.getTitleId() != null) {
|
||||||
|
UiUtilities.setupDialogButton(nightMode, button, type.getEffect(), type.getTitleId());
|
||||||
|
}
|
||||||
|
|
||||||
|
TextViewEx title = button.findViewById(R.id.button_text);
|
||||||
|
int margin = context.getResources().getDimensionPixelSize(R.dimen.context_menu_padding_margin_medium);
|
||||||
|
UiUtilities.setMargins(title, 0, margin, 0, margin);
|
||||||
|
|
||||||
|
int colorRes;
|
||||||
|
if (type.getEffect() == UiUtilities.DialogButtonType.SECONDARY_HARMFUL) {
|
||||||
|
colorRes = R.color.color_osm_edit_delete;
|
||||||
|
} else {
|
||||||
|
colorRes = nightMode ? R.color.dlg_btn_secondary_text_dark : R.color.dlg_btn_secondary_text_light;
|
||||||
|
}
|
||||||
|
AppCompatImageView icon = button.findViewById(R.id.icon);
|
||||||
|
if (type.getIconId() != null) {
|
||||||
|
Drawable drawable = AppCompatResources.getDrawable(context, type.getIconId());
|
||||||
|
UiUtilities.tintDrawable(drawable, ContextCompat.getColor(context, colorRes));
|
||||||
|
icon.setImageDrawable(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
private String getTimeTrackSaved() {
|
private String getTimeTrackSaved() {
|
||||||
long timeTrackSaved = helper.getLastTimeFileSaved();
|
long timeTrackSaved = helper.getLastTimeFileSaved();
|
||||||
if (timeTrackSaved != 0) {
|
if (timeTrackSaved != 0) {
|
||||||
|
@ -369,7 +409,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
public void run() {
|
public void run() {
|
||||||
int interval = app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.get();
|
int interval = app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.get();
|
||||||
updateStatus();
|
updateStatus();
|
||||||
handler.postDelayed(this, Math.max(GENERAL_UPDATE_INTERVAL, interval));
|
handler.postDelayed(this, Math.max(GENERAL_UPDATE_GPS_INTERVAL, interval));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
handler.post(updatingGPS);
|
handler.post(updatingGPS);
|
||||||
|
@ -385,7 +425,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
public void run() {
|
public void run() {
|
||||||
String time = getTimeTrackSaved();
|
String time = getTimeTrackSaved();
|
||||||
createItem(buttonSave, ItemType.SAVE, hasDataToSave(), !Algorithms.isEmpty(time) ? time : null);
|
createItem(buttonSave, ItemType.SAVE, hasDataToSave(), !Algorithms.isEmpty(time) ? time : null);
|
||||||
handler.postDelayed(this, GENERAL_UPDATE_INTERVAL);
|
handler.postDelayed(this, GENERAL_UPDATE_SAVE_INTERVAL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
handler.post(updatingTimeTrackSaved);
|
handler.post(updatingTimeTrackSaved);
|
||||||
|
@ -405,22 +445,23 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
final SaveGpxResult result = helper.saveDataToGpx(app.getAppCustomization().getTracksDir());
|
final SaveGpxResult result = helper.saveDataToGpx(app.getAppCustomization().getTracksDir());
|
||||||
if (mapActivity != null && context != null) {
|
if (mapActivity != null && context != null) {
|
||||||
Snackbar snackbar = Snackbar.make(mapActivity.getLayout(),
|
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
||||||
getString(R.string.shared_string_file_is_saved, gpxFileName),
|
final FragmentManager fragmentManager = mapActivityRef.get().getSupportFragmentManager();
|
||||||
|
@SuppressLint({"StringFormatInvalid", "LocalSuppress"})
|
||||||
|
Snackbar snackbar = Snackbar.make(getView(),
|
||||||
|
app.getResources().getString(R.string.shared_string_file_is_saved, gpxFileName),
|
||||||
Snackbar.LENGTH_LONG)
|
Snackbar.LENGTH_LONG)
|
||||||
.setAction(R.string.shared_string_rename, new View.OnClickListener() {
|
.setAction(R.string.shared_string_rename, new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
fragmentManager.beginTransaction().remove(TripRecordingActiveBottomSheet.this).commitAllowingStateLoss();
|
||||||
final FragmentActivity fragmentActivity = mapActivityRef.get();
|
SaveGPXBottomSheetFragment.showInstance(fragmentManager, result.getFilenames());
|
||||||
SaveGPXBottomSheetFragment.showInstance(fragmentActivity.getSupportFragmentManager(), result.getFilenames());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
View view = snackbar.getView();
|
View view = snackbar.getView();
|
||||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) view.getLayoutParams();
|
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
|
||||||
params.gravity = Gravity.TOP;
|
params.gravity = Gravity.TOP;
|
||||||
final int dp16 = AndroidUtils.dpToPx(mapActivity, 16f);
|
AndroidUtils.setMargins(params, 0, AndroidUtils.getStatusBarHeight(context), 0, 0);
|
||||||
AndroidUtils.setMargins(params, 0, AndroidUtils.getStatusBarHeight(context) + dp16, 0, 0);
|
|
||||||
view.setLayoutParams(params);
|
view.setLayoutParams(params);
|
||||||
UiUtilities.setupSnackbar(snackbar, nightMode);
|
UiUtilities.setupSnackbar(snackbar, nightMode);
|
||||||
snackbar.show();
|
snackbar.show();
|
||||||
|
@ -521,11 +562,9 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
|
|
||||||
public void setTextColor(TextView tv, boolean enabled, boolean nightMode, ItemType type) {
|
public void setTextColor(TextView tv, boolean enabled, boolean nightMode, ItemType type) {
|
||||||
if (tv != null) {
|
if (tv != null) {
|
||||||
ColorStateList textColorStateList = AndroidUtils.createPressedColorStateList(
|
int activeColorId = type == ItemType.CLEAR_DATA ? R.color.color_osm_edit_delete : getActiveTextColorId(nightMode);
|
||||||
app, enabled ? type == ItemType.CLEAR_DATA ? R.color.color_osm_edit_delete
|
int normalColorId = enabled ? activeColorId : getSecondaryTextColorId(nightMode);
|
||||||
: getActiveTextColorId(nightMode) : getSecondaryTextColorId(nightMode),
|
ColorStateList textColorStateList = AndroidUtils.createPressedColorStateList(app, normalColorId, getPressedColorId(nightMode));
|
||||||
getPressedColorId(nightMode)
|
|
||||||
);
|
|
||||||
tv.setTextColor(textColorStateList);
|
tv.setTextColor(textColorStateList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -534,11 +573,9 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
Integer iconId = type.getIconId();
|
Integer iconId = type.getIconId();
|
||||||
if (iv != null && iconId != null) {
|
if (iv != null && iconId != null) {
|
||||||
Drawable icon = AppCompatResources.getDrawable(app, iconId);
|
Drawable icon = AppCompatResources.getDrawable(app, iconId);
|
||||||
ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList(
|
int activeColorId = type == ItemType.CLEAR_DATA ? R.color.color_osm_edit_delete : getActiveIconColorId(nightMode);
|
||||||
app, enabled ? type == ItemType.CLEAR_DATA ? R.color.color_osm_edit_delete
|
int normalColorId = enabled ? activeColorId : getSecondaryIconColorId(nightMode);
|
||||||
: getActiveIconColorId(nightMode) : getSecondaryIconColorId(nightMode),
|
ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList(app, normalColorId, getPressedColorId(nightMode));
|
||||||
getPressedColorId(nightMode)
|
|
||||||
);
|
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
DrawableCompat.setTintList(icon, iconColorStateList);
|
DrawableCompat.setTintList(icon, iconColorStateList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,7 +282,10 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
helper.startNewSegment();
|
helper.startNewSegment();
|
||||||
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(true);
|
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(true);
|
||||||
app.startNavigationService(NavigationService.USED_BY_GPX);
|
app.startNavigationService(NavigationService.USED_BY_GPX);
|
||||||
TripRecordingActiveBottomSheet.showInstance(getMapActivity().getSupportFragmentManager(), helper.getCurrentTrack());
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
TripRecordingActiveBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), helper.getCurrentTrack());
|
||||||
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,11 @@ public class SaveCurrentTrackTask extends AsyncTask<Void, Void, Boolean> {
|
||||||
}
|
}
|
||||||
for (final String f : files.keySet()) {
|
for (final String f : files.keySet()) {
|
||||||
File fout = new File(dir, f + IndexConstants.GPX_FILE_EXT);
|
File fout = new File(dir, f + IndexConstants.GPX_FILE_EXT);
|
||||||
GPXUtilities.writeGpxFile(fout, gpx);
|
Exception exception = GPXUtilities.writeGpxFile(fout, gpx);
|
||||||
|
if (exception == null) {
|
||||||
app.getSavingTrackHelper().setLastTimeFileSaved(fout.lastModified());
|
app.getSavingTrackHelper().setLastTimeFileSaved(fout.lastModified());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return shouldClearPath;
|
return shouldClearPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue