GPX REC > Save
New ButtomSheet, new layout
This commit is contained in:
parent
181661349e
commit
1d09b6e9df
3 changed files with 31 additions and 65 deletions
|
@ -59,31 +59,4 @@
|
||||||
android:padding="@dimen/content_padding" />
|
android:padding="@dimen/content_padding" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:paddingLeft="@dimen/content_padding"
|
|
||||||
android:paddingTop="@dimen/content_padding_small"
|
|
||||||
android:paddingRight="@dimen/content_padding"
|
|
||||||
android:paddingBottom="@dimen/content_padding_small"
|
|
||||||
android:paddingEnd="@dimen/content_padding"
|
|
||||||
android:paddingStart="@dimen/content_padding">
|
|
||||||
|
|
||||||
<include
|
|
||||||
android:id="@+id/open_track_button"
|
|
||||||
layout="@layout/bottom_sheet_dialog_button" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/buttons_divider"
|
|
||||||
android:layout_width="@dimen/content_padding"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
|
|
||||||
<include
|
|
||||||
android:id="@+id/close_button"
|
|
||||||
layout="@layout/bottom_sheet_dialog_button" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -461,7 +461,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
if (activityRef != null && !Algorithms.isEmpty(result.getFilenames())) {
|
if (activityRef != null && !Algorithms.isEmpty(result.getFilenames())) {
|
||||||
final Activity a = activityRef.get();
|
final Activity a = activityRef.get();
|
||||||
if (a instanceof FragmentActivity && !a.isFinishing()) {
|
if (a instanceof FragmentActivity && !a.isFinishing()) {
|
||||||
OnSaveCurrentTrackFragment.showInstance(((FragmentActivity) a).getSupportFragmentManager(), result.getFilenames());
|
SaveGPXBottomSheetFragment.showInstance(((FragmentActivity) a).getSupportFragmentManager(), result.getFilenames());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,18 +6,13 @@ import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.widget.SwitchCompat;
|
import androidx.appcompat.widget.SwitchCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
@ -25,17 +20,15 @@ import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
import net.osmand.FileUtils;
|
import net.osmand.FileUtils;
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
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.BottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||||
import net.osmand.plus.myplaces.AvailableGPXFragment;
|
import net.osmand.plus.myplaces.AvailableGPXFragment;
|
||||||
import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
|
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
|
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -48,11 +41,10 @@ import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.FileUtils.ILLEGAL_FILE_NAME_CHARACTERS;
|
import static net.osmand.FileUtils.ILLEGAL_FILE_NAME_CHARACTERS;
|
||||||
|
|
||||||
public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
|
public class SaveGPXBottomSheetFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
public static final String TAG = "SaveGPXBottomSheetFragment";
|
||||||
public static final String TAG = "OnSaveCurrentTrackBottomSheetFragment";
|
|
||||||
public static final String SAVED_TRACKS_KEY = "saved_track_filename";
|
public static final String SAVED_TRACKS_KEY = "saved_track_filename";
|
||||||
private static final Log LOG = PlatformUtil.getLog(OnSaveCurrentTrackFragment.class);
|
private static final Log LOG = PlatformUtil.getLog(SaveGPXBottomSheetFragment.class);
|
||||||
|
|
||||||
private boolean openTrack = false;
|
private boolean openTrack = false;
|
||||||
private File file;
|
private File file;
|
||||||
|
@ -60,9 +52,8 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
|
||||||
private String savedGpxName = "";
|
private String savedGpxName = "";
|
||||||
private String newGpxName = "";
|
private String newGpxName = "";
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
final OsmandApplication app = requiredMyApplication();
|
final OsmandApplication app = requiredMyApplication();
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
if (args != null && args.containsKey(SAVED_TRACKS_KEY)) {
|
if (args != null && args.containsKey(SAVED_TRACKS_KEY)) {
|
||||||
|
@ -81,7 +72,7 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
|
||||||
file = new File(app.getAppCustomization().getTracksDir(), savedGpxName + IndexConstants.GPX_FILE_EXT);
|
file = new File(app.getAppCustomization().getTracksDir(), savedGpxName + IndexConstants.GPX_FILE_EXT);
|
||||||
final boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
final boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||||
final int textPrimaryColor = nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light;
|
final int textPrimaryColor = nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light;
|
||||||
View mainView = UiUtilities.getInflater(ctx, nightMode).inflate(R.layout.fragment_on_save_current_track, container);
|
View mainView = UiUtilities.getInflater(ctx, nightMode).inflate(R.layout.save_gpx_fragment, null);
|
||||||
|
|
||||||
OsmandTextFieldBoxes textBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.name_text_box);
|
OsmandTextFieldBoxes textBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.name_text_box);
|
||||||
if (nightMode) {
|
if (nightMode) {
|
||||||
|
@ -131,25 +122,11 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
|
||||||
app.getSettings().SHOW_SAVED_TRACK_REMEMBER.set(isChecked);
|
app.getSettings().SHOW_SAVED_TRACK_REMEMBER.set(isChecked);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
View openTrackBtn = mainView.findViewById(R.id.open_track_button);
|
|
||||||
UiUtilities.setupDialogButton(nightMode, openTrackBtn, DialogButtonType.SECONDARY, R.string.shared_string_open_track);
|
|
||||||
final View showOnMapBtn = mainView.findViewById(R.id.close_button);
|
|
||||||
UiUtilities.setupDialogButton(nightMode, showOnMapBtn, DialogButtonType.SECONDARY, R.string.shared_string_close);
|
|
||||||
|
|
||||||
openTrackBtn.setOnClickListener(new OnClickListener() {
|
SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder()
|
||||||
@Override
|
.setCustomView(mainView)
|
||||||
public void onClick(View v) {
|
.create();
|
||||||
doRename(true);
|
items.add(titleItem);
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
showOnMapBtn.setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
doRename(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return mainView;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doRename(boolean openTrack) {
|
private void doRename(boolean openTrack) {
|
||||||
|
@ -160,6 +137,21 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected UiUtilities.DialogButtonType getRightBottomButtonType() {
|
||||||
|
return UiUtilities.DialogButtonType.SECONDARY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getRightBottomButtonTextId() {
|
||||||
|
return R.string.shared_string_open_track;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRightBottomButtonClick() {
|
||||||
|
doRename(true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(DialogInterface dialog) {
|
public void onDismiss(DialogInterface dialog) {
|
||||||
super.onDismiss(dialog);
|
super.onDismiss(dialog);
|
||||||
|
@ -199,10 +191,10 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
|
||||||
}
|
}
|
||||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||||
|
|
||||||
GpxInfo gpxInfo = new GpxInfo();
|
AvailableGPXFragment.GpxInfo gpxInfo = new AvailableGPXFragment.GpxInfo();
|
||||||
gpxInfo.setGpx(GPXUtilities.loadGPXFile(f));
|
gpxInfo.setGpx(GPXUtilities.loadGPXFile(f));
|
||||||
if (gpxInfo.gpx != null) {
|
if (gpxInfo.gpx != null) {
|
||||||
WptPt loc = gpxInfo.gpx.findPointToShow();
|
GPXUtilities.WptPt loc = gpxInfo.gpx.findPointToShow();
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
app.getSelectedGpxHelper().setGpxFileToDisplay(gpxInfo.gpx);
|
app.getSelectedGpxHelper().setGpxFileToDisplay(gpxInfo.gpx);
|
||||||
if (activity instanceof MapActivity) {
|
if (activity instanceof MapActivity) {
|
||||||
|
@ -223,7 +215,7 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
|
||||||
if (fragmentManager.isStateSaved()) {
|
if (fragmentManager.isStateSaved()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
OnSaveCurrentTrackFragment f = new OnSaveCurrentTrackFragment();
|
SaveGPXBottomSheetFragment f = new SaveGPXBottomSheetFragment();
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putStringArrayList(SAVED_TRACKS_KEY, new ArrayList<>(filenames));
|
b.putStringArrayList(SAVED_TRACKS_KEY, new ArrayList<>(filenames));
|
||||||
f.setArguments(b);
|
f.setArguments(b);
|
||||||
|
@ -234,3 +226,4 @@ public class OnSaveCurrentTrackFragment extends BottomSheetDialogFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue