Merge remote-tracking branch 'origin/trip_recording' into trip_recording_graphs
# Conflicts: # OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java # OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomFragment.java
This commit is contained in:
commit
bb1aef0862
8 changed files with 105 additions and 124 deletions
|
@ -25,6 +25,7 @@ import com.google.android.material.slider.Slider;
|
|||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.ValueHolder;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.NavigationService;
|
||||
|
@ -48,6 +49,8 @@ import net.osmand.plus.views.layers.MapInfoLayer;
|
|||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collections;
|
||||
|
@ -57,6 +60,7 @@ import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT;
|
|||
|
||||
public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||
|
||||
private static final Log LOG = PlatformUtil.getLog(OsmandMonitoringPlugin.class);
|
||||
public static final String ID = "osmand.monitoring";
|
||||
public final static String OSMAND_SAVE_SERVICE_ACTION = "OSMAND_SAVE_SERVICE_ACTION";
|
||||
public static final int REQUEST_LOCATION_PERMISSION_FOR_GPX_RECORDING = 208;
|
||||
|
@ -470,12 +474,10 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
try {
|
||||
SavingTrackHelper helper = app.getSavingTrackHelper();
|
||||
SaveGpxResult result = helper.saveDataToGpx(app.getAppCustomization().getTracksDir());
|
||||
if (stopRecording) {
|
||||
helper.close();
|
||||
}
|
||||
helper.close();
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOG.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import net.osmand.plus.OsmandPlugin;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
|
@ -76,12 +77,12 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment i
|
|||
|
||||
public static final String TAG = TripRecordingBottomFragment.class.getSimpleName();
|
||||
private static final Log LOG = PlatformUtil.getLog(TripRecordingBottomFragment.class);
|
||||
private static final String SAVE_CURRENT_GPX_FILE = "save_current_gpx_file";
|
||||
public static final String UPDATE_TRACK_ICON = "update_track_icon";
|
||||
private static final int GPS_UPDATE_INTERVAL = 1000;
|
||||
|
||||
private OsmandApplication app;
|
||||
private OsmandSettings settings;
|
||||
private SavingTrackHelper helper;
|
||||
private OsmandMonitoringPlugin plugin;
|
||||
|
||||
private View statusContainer;
|
||||
|
@ -106,7 +107,7 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment i
|
|||
}
|
||||
|
||||
private boolean hasDataToSave() {
|
||||
return app.getSavingTrackHelper().hasDataToSave();
|
||||
return helper.hasDataToSave();
|
||||
}
|
||||
|
||||
private boolean searchingGPS() {
|
||||
|
@ -129,17 +130,12 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment i
|
|||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
app = requiredMyApplication();
|
||||
settings = app.getSettings();
|
||||
helper = app.getSavingTrackHelper();
|
||||
plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class);
|
||||
selectedGpxFile = helper.getCurrentTrack();
|
||||
LayoutInflater inflater = UiUtilities.getInflater(getContext(), nightMode);
|
||||
final FragmentManager fragmentManager = getFragmentManager();
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
if (savedInstanceState.containsKey(SAVE_CURRENT_GPX_FILE)
|
||||
&& savedInstanceState.getBoolean(SAVE_CURRENT_GPX_FILE)) {
|
||||
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
||||
}
|
||||
}
|
||||
|
||||
View itemView = inflater.inflate(R.layout.trip_recording_fragment, null, false);
|
||||
items.add(new BaseBottomSheetItem.Builder()
|
||||
.setCustomView(itemView)
|
||||
|
@ -201,7 +197,7 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment i
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null && plugin != null && app.getSavingTrackHelper().hasDataToSave()) {
|
||||
if (mapActivity != null && plugin != null && hasDataToSave()) {
|
||||
plugin.saveCurrentTrack(null, mapActivity);
|
||||
app.getNotificationHelper().refreshNotifications();
|
||||
dismiss();
|
||||
|
@ -215,16 +211,11 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment i
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (fragmentManager != null) {
|
||||
TripRecordingOptionsBottomFragment.showInstance(fragmentManager, TripRecordingBottomFragment.this, selectedGpxFile);
|
||||
TripRecordingOptionsBottomFragment.showInstance(fragmentManager, TripRecordingBottomFragment.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(SAVE_CURRENT_GPX_FILE, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -404,9 +395,10 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment i
|
|||
});
|
||||
}
|
||||
|
||||
protected static void setShowTrackItemBackground(View view, boolean checked, boolean nightMode) {
|
||||
int background = checked ? getActiveTransparentBackgroundId(nightMode) : getInactiveStrokedBackgroundId(nightMode);
|
||||
view.setBackgroundResource(background);
|
||||
public static void setShowTrackItemBackground(View view, boolean checked, boolean nightMode) {
|
||||
Drawable background = AppCompatResources.getDrawable(view.getContext(),
|
||||
checked ? getActiveTransparentBackgroundId(nightMode) : getInactiveStrokedBackgroundId(nightMode));
|
||||
view.setBackgroundDrawable(background);
|
||||
}
|
||||
|
||||
private void createItem(View view, ItemType type) {
|
||||
|
@ -458,18 +450,18 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment i
|
|||
}
|
||||
|
||||
public static void setItemBackground(Context context, boolean nightMode, View view, boolean enabled) {
|
||||
Drawable background = AppCompatResources.getDrawable(context, R.drawable.btn_background_inactive_light);
|
||||
if (view instanceof CardView) {
|
||||
int colorId = enabled ? getActiveTransparentColorId(nightMode) : getInactiveButtonColorId(nightMode);
|
||||
((CardView) view).setCardBackgroundColor(AndroidUtils.createPressedColorStateList(
|
||||
context, colorId, getActiveTextColorId(nightMode)
|
||||
));
|
||||
return;
|
||||
}
|
||||
Drawable background = AppCompatResources.getDrawable(context, getInactiveButtonBackgroundId(nightMode));
|
||||
if (background != null && enabled) {
|
||||
int normalColorId = view instanceof CardView
|
||||
? getActiveTransparentColorId(nightMode) : getInactiveButtonColorId(nightMode);
|
||||
ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList(
|
||||
context, normalColorId, getActiveTextColorId(nightMode)
|
||||
);
|
||||
if (view instanceof CardView) {
|
||||
((CardView) view).setCardBackgroundColor(iconColorStateList);
|
||||
return;
|
||||
}
|
||||
DrawableCompat.setTintList(background, iconColorStateList);
|
||||
DrawableCompat.setTintList(background, AndroidUtils.createPressedColorStateList(
|
||||
context, getInactiveButtonColorId(nightMode), getActiveTextColorId(nightMode)
|
||||
));
|
||||
} else {
|
||||
UiUtilities.tintDrawable(background, ContextCompat.getColor(context, getInactiveButtonColorId(nightMode)));
|
||||
}
|
||||
|
@ -594,6 +586,10 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment i
|
|||
public void openAnalyzeOnMap(GpxDisplayItem gpxItem) {
|
||||
}
|
||||
|
||||
public interface DismissTargetFragment {
|
||||
void dismissTarget();
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
public static int getActiveTextColorId(boolean nightMode) {
|
||||
return nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
||||
|
@ -624,7 +620,7 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment i
|
|||
return nightMode ? R.color.icon_color_osmand_dark : R.color.icon_color_osmand_light;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
@ColorRes
|
||||
public static int getActiveTransparentColorId(boolean nightMode) {
|
||||
return nightMode ? R.color.switch_button_active_dark : R.color.switch_button_active_light;
|
||||
}
|
||||
|
@ -644,6 +640,11 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment i
|
|||
return nightMode ? R.drawable.btn_background_stroked_inactive_dark : R.drawable.btn_background_stroked_inactive_light;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
public static int getInactiveButtonBackgroundId(boolean nightMode) {
|
||||
return nightMode ? R.drawable.btn_background_inactive_dark : R.drawable.btn_background_inactive_light;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hideButtonsContainer() {
|
||||
return true;
|
||||
|
@ -657,5 +658,4 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment i
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,9 +18,8 @@ import androidx.fragment.app.Fragment;
|
|||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import static net.osmand.AndroidUtils.getPrimaryTextColorId;
|
||||
import static net.osmand.plus.monitoring.TripRecordingOptionsBottomFragment.*;
|
||||
|
||||
public class TripRecordingClearDataBottomFragment extends MenuBottomSheetDialogFragment {
|
||||
public class TripRecordingClearDataBottomFragment extends MenuBottomSheetDialogFragment implements TripRecordingBottomFragment.DismissTargetFragment {
|
||||
|
||||
public static final String TAG = TripRecordingClearDataBottomFragment.class.getSimpleName();
|
||||
|
||||
|
@ -41,7 +40,7 @@ public class TripRecordingClearDataBottomFragment extends MenuBottomSheetDialogF
|
|||
int verticalBig = getResources().getDimensionPixelSize(R.dimen.dialog_content_margin);
|
||||
int verticalNormal = getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||
String description = getString(R.string.clear_recorded_data_warning)
|
||||
.concat(getString(R.string.lost_data_warning));
|
||||
.concat("\n").concat(getString(R.string.lost_data_warning));
|
||||
final View buttonClear = createItem(inflater, ItemType.CLEAR_DATA);
|
||||
final View buttonCancel = createItem(inflater, ItemType.CANCEL);
|
||||
|
||||
|
@ -61,7 +60,7 @@ public class TripRecordingClearDataBottomFragment extends MenuBottomSheetDialogF
|
|||
public void onClick(View v) {
|
||||
app.getSavingTrackHelper().clearRecordedData(true);
|
||||
dismiss();
|
||||
dismissTargetDialog(TripRecordingClearDataBottomFragment.this, TripRecordingOptionsBottomFragment.class);
|
||||
dismissTarget();
|
||||
}
|
||||
})
|
||||
.create());
|
||||
|
@ -108,4 +107,11 @@ public class TripRecordingClearDataBottomFragment extends MenuBottomSheetDialogF
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissTarget() {
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof TripRecordingOptionsBottomFragment) {
|
||||
((TripRecordingOptionsBottomFragment) target).dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,9 @@ import androidx.fragment.app.Fragment;
|
|||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import static net.osmand.AndroidUtils.getPrimaryTextColorId;
|
||||
import static net.osmand.plus.monitoring.TripRecordingOptionsBottomFragment.ACTION_STOP_AND_DISCARD;
|
||||
import static net.osmand.plus.monitoring.TripRecordingOptionsBottomFragment.dismissTargetDialog;
|
||||
import static net.osmand.plus.monitoring.TripRecordingOptionsBottomFragment.ACTION_STOP_AND_DISMISS;
|
||||
|
||||
public class TripRecordingDiscardBottomFragment extends MenuBottomSheetDialogFragment {
|
||||
public class TripRecordingDiscardBottomFragment extends MenuBottomSheetDialogFragment implements TripRecordingBottomFragment.DismissTargetFragment {
|
||||
|
||||
public static final String TAG = TripRecordingDiscardBottomFragment.class.getSimpleName();
|
||||
|
||||
|
@ -43,13 +42,11 @@ public class TripRecordingDiscardBottomFragment extends MenuBottomSheetDialogFra
|
|||
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
|
||||
int verticalBig = getResources().getDimensionPixelSize(R.dimen.dialog_content_margin);
|
||||
int verticalNormal = getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||
String description = getString(R.string.track_recording_description)
|
||||
.concat(getString(R.string.lost_data_warning));
|
||||
final View buttonDiscard = createItem(inflater, ItemType.STOP_AND_DISCARD);
|
||||
final View buttonCancel = createItem(inflater, ItemType.CANCEL);
|
||||
|
||||
items.add(new BottomSheetItemWithDescription.Builder()
|
||||
.setDescription(description)
|
||||
.setDescription(getString(R.string.track_recording_description))
|
||||
.setDescriptionColorId(getPrimaryTextColorId(nightMode))
|
||||
.setTitle(app.getString(R.string.track_recording_title))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_title_with_description)
|
||||
|
@ -68,8 +65,14 @@ public class TripRecordingDiscardBottomFragment extends MenuBottomSheetDialogFra
|
|||
}
|
||||
app.getSavingTrackHelper().clearRecordedData(true);
|
||||
dismiss();
|
||||
dismissTargetDialog(TripRecordingDiscardBottomFragment.this,
|
||||
TripRecordingOptionsBottomFragment.class, ACTION_STOP_AND_DISCARD, true);
|
||||
|
||||
Fragment target = getTargetFragment();
|
||||
if (target != null) {
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(ACTION_STOP_AND_DISMISS, true);
|
||||
target.setArguments(args);
|
||||
}
|
||||
dismissTarget();
|
||||
}
|
||||
})
|
||||
.create());
|
||||
|
@ -111,6 +114,14 @@ public class TripRecordingDiscardBottomFragment extends MenuBottomSheetDialogFra
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissTarget() {
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof TripRecordingOptionsBottomFragment) {
|
||||
((TripRecordingOptionsBottomFragment) target).dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hideButtonsContainer() {
|
||||
return true;
|
||||
|
|
|
@ -11,7 +11,6 @@ import android.view.View;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
|
@ -36,11 +35,10 @@ import net.osmand.util.Algorithms;
|
|||
|
||||
import static net.osmand.AndroidUtils.getPrimaryTextColorId;
|
||||
|
||||
public class TripRecordingOptionsBottomFragment extends MenuBottomSheetDialogFragment {
|
||||
public class TripRecordingOptionsBottomFragment extends MenuBottomSheetDialogFragment implements TripRecordingBottomFragment.DismissTargetFragment {
|
||||
|
||||
public static final String TAG = TripRecordingOptionsBottomFragment.class.getSimpleName();
|
||||
public static final String ACTION_STOP_AND_DISCARD = "action_stop_and_discard";
|
||||
private static final String SAVE_CURRENT_GPX_FILE = "save_current_gpx_file";
|
||||
public static final String ACTION_STOP_AND_DISMISS = "action_stop_and_discard";
|
||||
private static final int SAVE_UPDATE_INTERVAL = 1000;
|
||||
|
||||
private OsmandApplication app;
|
||||
|
@ -72,11 +70,10 @@ public class TripRecordingOptionsBottomFragment extends MenuBottomSheetDialogFra
|
|||
return settings.SAVE_GLOBAL_TRACK_TO_GPX.get();
|
||||
}
|
||||
|
||||
public static void showInstance(@NonNull FragmentManager fragmentManager, @NonNull Fragment target, SelectedGpxFile selectedGpxFile) {
|
||||
public static void showInstance(@NonNull FragmentManager fragmentManager, @NonNull Fragment target) {
|
||||
if (!fragmentManager.isStateSaved()) {
|
||||
TripRecordingOptionsBottomFragment fragment = new TripRecordingOptionsBottomFragment();
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.setSelectedGpxFile(selectedGpxFile);
|
||||
fragment.show(fragmentManager, TAG);
|
||||
}
|
||||
}
|
||||
|
@ -86,18 +83,12 @@ public class TripRecordingOptionsBottomFragment extends MenuBottomSheetDialogFra
|
|||
app = requiredMyApplication();
|
||||
settings = app.getSettings();
|
||||
helper = app.getSavingTrackHelper();
|
||||
selectedGpxFile = helper.getCurrentTrack();
|
||||
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
|
||||
final FragmentManager fragmentManager = getFragmentManager();
|
||||
int dp16 = getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||
int dp36 = getResources().getDimensionPixelSize(R.dimen.context_menu_controller_height);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
if (savedInstanceState.containsKey(SAVE_CURRENT_GPX_FILE)
|
||||
&& savedInstanceState.getBoolean(SAVE_CURRENT_GPX_FILE)) {
|
||||
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
||||
}
|
||||
}
|
||||
|
||||
buttonClear = createItem(inflater, ItemType.CLEAR_DATA, hasDataToSave());
|
||||
final View buttonDiscard = createItem(inflater, ItemType.STOP_AND_DISCARD);
|
||||
final View buttonOnline = createItem(inflater, ItemType.STOP_ONLINE, hasDataToSave());
|
||||
|
@ -193,12 +184,6 @@ public class TripRecordingOptionsBottomFragment extends MenuBottomSheetDialogFra
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(SAVE_CURRENT_GPX_FILE, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
@ -213,14 +198,7 @@ public class TripRecordingOptionsBottomFragment extends MenuBottomSheetDialogFra
|
|||
public void onPause() {
|
||||
super.onPause();
|
||||
stopUpdatingTimeTrackSaved();
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof TripRecordingBottomFragment) {
|
||||
if (isDiscard()) {
|
||||
((TripRecordingBottomFragment) target).dismiss();
|
||||
} else {
|
||||
((TripRecordingBottomFragment) target).show();
|
||||
}
|
||||
}
|
||||
dismissTarget();
|
||||
}
|
||||
|
||||
public void show() {
|
||||
|
@ -237,32 +215,6 @@ public class TripRecordingOptionsBottomFragment extends MenuBottomSheetDialogFra
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isDiscard() {
|
||||
Bundle args = getArguments();
|
||||
if (args != null) {
|
||||
return args.getBoolean(ACTION_STOP_AND_DISCARD);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static void dismissTargetDialog(Fragment current, Class<?> targetClass) {
|
||||
dismissTargetDialog(current, targetClass, null, null);
|
||||
}
|
||||
|
||||
protected static void dismissTargetDialog(Fragment current, Class<?> targetClass, String booleanKey, Boolean value) {
|
||||
if (targetClass.isInstance(current.getTargetFragment())) {
|
||||
Fragment target = current.getTargetFragment();
|
||||
if (booleanKey != null && value != null) {
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(booleanKey, value);
|
||||
target.setArguments(args);
|
||||
}
|
||||
if (target instanceof DialogFragment) {
|
||||
((DialogFragment) target).dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopUpdatingTimeTrackSaved() {
|
||||
handler.removeCallbacks(updatingTimeTrackSaved);
|
||||
}
|
||||
|
@ -312,17 +264,37 @@ public class TripRecordingOptionsBottomFragment extends MenuBottomSheetDialogFra
|
|||
OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class);
|
||||
if (mapActivity != null && plugin != null) {
|
||||
stopUpdatingTimeTrackSaved();
|
||||
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false);
|
||||
plugin.saveCurrentTrack(null, mapActivity, false, true);
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(ACTION_STOP_AND_DISMISS, true);
|
||||
setArguments(args);
|
||||
dismiss();
|
||||
dismissTargetDialog(TripRecordingOptionsBottomFragment.this, TripRecordingBottomFragment.class);
|
||||
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(true);
|
||||
runUpdatingTimeTrackSaved();
|
||||
dismissTarget();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private boolean isDiscard() {
|
||||
Bundle args = getArguments();
|
||||
if (args != null) {
|
||||
return args.getBoolean(ACTION_STOP_AND_DISMISS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissTarget() {
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof TripRecordingBottomFragment) {
|
||||
if (isDiscard()) {
|
||||
((TripRecordingBottomFragment) target).dismiss();
|
||||
} else {
|
||||
((TripRecordingBottomFragment) target).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MapActivity getMapActivity() {
|
||||
Activity activity = getActivity();
|
||||
|
@ -346,5 +318,4 @@ public class TripRecordingOptionsBottomFragment extends MenuBottomSheetDialogFra
|
|||
protected boolean useVerticalButtons() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -103,7 +103,6 @@ public class TripRecordingStartingBottomFragment extends MenuBottomSheetDialogFr
|
|||
updateUpDownBtn();
|
||||
|
||||
CardView cardLeft = itemView.findViewById(R.id.button_left);
|
||||
|
||||
createItem(app, nightMode, cardLeft, ItemType.CANCEL, true, null);
|
||||
cardLeft.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -113,7 +112,6 @@ public class TripRecordingStartingBottomFragment extends MenuBottomSheetDialogFr
|
|||
});
|
||||
|
||||
CardView cardCenter = itemView.findViewById(R.id.button_center);
|
||||
|
||||
createItem(app, nightMode, cardCenter, ItemType.START_RECORDING, true, null);
|
||||
cardCenter.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -123,7 +121,6 @@ public class TripRecordingStartingBottomFragment extends MenuBottomSheetDialogFr
|
|||
});
|
||||
|
||||
CardView cardRight = itemView.findViewById(R.id.button_right);
|
||||
|
||||
createItem(app, nightMode, cardRight, ItemType.SETTINGS, true, null);
|
||||
cardRight.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -222,19 +219,13 @@ public class TripRecordingStartingBottomFragment extends MenuBottomSheetDialogFr
|
|||
dismiss();
|
||||
}
|
||||
|
||||
public void show(String... keys) {
|
||||
public void show() {
|
||||
Dialog dialog = getDialog();
|
||||
if (dialog != null) {
|
||||
dialog.show();
|
||||
for (String key : keys) {
|
||||
if (key.equals(UPDATE_TRACK_ICON)) {
|
||||
updateTrackIcon(app, trackAppearanceIcon);
|
||||
}
|
||||
if (key.equals(UPDATE_LOGGING_INTERVAL)) {
|
||||
updateIntervalValue();
|
||||
AndroidUiHelper.updateVisibility(intervalContainer, infoExpanded);
|
||||
}
|
||||
}
|
||||
updateTrackIcon(app, trackAppearanceIcon);
|
||||
updateIntervalValue();
|
||||
AndroidUiHelper.updateVisibility(intervalContainer, infoExpanded);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
private final Class<? extends LocalRoutingParameter>[] excludeParameters;
|
||||
|
||||
@SafeVarargs
|
||||
DialogMode(Class<? extends LocalRoutingParameter> ... excludeParameters) {
|
||||
DialogMode(Class<? extends LocalRoutingParameter>... excludeParameters) {
|
||||
this.excludeParameters = excludeParameters;
|
||||
}
|
||||
|
||||
|
@ -693,9 +693,9 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
}
|
||||
|
||||
public static void showInstance(MapActivity mapActivity,
|
||||
Fragment targetFragment,
|
||||
DialogMode dialogMode,
|
||||
String appModeKey) {
|
||||
Fragment targetFragment,
|
||||
DialogMode dialogMode,
|
||||
String appModeKey) {
|
||||
try {
|
||||
FragmentManager fm = mapActivity.getSupportFragmentManager();
|
||||
if (!fm.isStateSaved()) {
|
||||
|
|
|
@ -399,7 +399,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
public void onContextMenuDismiss(@NonNull ContextMenuFragment fragment) {
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof TripRecordingStartingBottomFragment) {
|
||||
((TripRecordingStartingBottomFragment) target).show(UPDATE_TRACK_ICON);
|
||||
((TripRecordingStartingBottomFragment) target).show();
|
||||
} else if (target instanceof TripRecordingBottomFragment) {
|
||||
((TripRecordingBottomFragment) target).show(UPDATE_TRACK_ICON);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue