save
This commit is contained in:
parent
7ba46570a0
commit
a007e8efc5
4 changed files with 44 additions and 10 deletions
|
@ -92,6 +92,10 @@ public class LoginBottomSheetFragment extends MenuBottomSheetDialogFragment {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isValidToken() {
|
||||
return authorizationAdapter.isValidToken();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DialogButtonType getRightBottomButtonType() {
|
||||
return (DialogButtonType.SECONDARY);
|
||||
|
|
|
@ -43,6 +43,8 @@ import net.osmand.osm.edit.Node;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.measurementtool.LoginBottomSheetFragment;
|
||||
import net.osmand.plus.osmedit.dialogs.SendOsmNoteBottomSheetFragment;
|
||||
import net.osmand.plus.osmedit.dialogs.SendPoiBottomSheetFragment;
|
||||
import net.osmand.plus.osmedit.oauth.OsmOAuthAuthorizationAdapter;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -626,17 +628,25 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
|||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
|
||||
private void uploadItems(final OsmPoint[] items) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity != null) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
OsmandSettings settings = app.getSettings();
|
||||
boolean isPoi = getOsmEditsByGroup(Group.POI) instanceof OpenstreetmapPoint;
|
||||
OsmOAuthAuthorizationAdapter authorizationAdapter = new OsmOAuthAuthorizationAdapter(app);
|
||||
if (authorizationAdapter.isValidToken()
|
||||
|| !Algorithms.isEmpty(settings.USER_NAME.get())
|
||||
&& !Algorithms.isEmpty(settings.USER_PASSWORD.get())) {
|
||||
SendPoiDialogFragment.createInstance(items, PoiUploaderType.FRAGMENT)
|
||||
.show(getChildFragmentManager(), SendPoiDialogFragment.TAG);
|
||||
if (isPoi) {
|
||||
SendOsmNoteBottomSheetFragment sendOsmNoteBottomSheetFragment =
|
||||
SendOsmNoteBottomSheetFragment.showInstance(new OsmPoint[]{}, SendOsmNoteBottomSheetFragment.PoiUploaderType.SIMPLE);
|
||||
sendOsmNoteBottomSheetFragment.show(activity.getSupportFragmentManager(), SendPoiDialogFragment.TAG);
|
||||
} else {
|
||||
SendOsmNoteBottomSheetFragment sendOsmNoteBottomSheetFragment =
|
||||
SendOsmNoteBottomSheetFragment.showInstance(new OsmPoint[]{}, SendOsmNoteBottomSheetFragment.PoiUploaderType.SIMPLE);
|
||||
sendOsmNoteBottomSheetFragment.show(activity.getSupportFragmentManager(), SendPoiDialogFragment.TAG);}
|
||||
} else {
|
||||
LoginBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), this);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.osmand.plus.osmedit.dialogs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
|
@ -20,6 +20,7 @@ import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
|||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||
import net.osmand.plus.osmedit.OsmPoint;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragment {
|
||||
|
||||
|
@ -39,14 +40,21 @@ public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragmen
|
|||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
private boolean isLoginOAuth() {
|
||||
return !Algorithms.isEmpty(getMyApplication().getSettings().USER_DISPLAY_NAME.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
final boolean isNightMode = !getMyApplication().getSettings().isLightContent();
|
||||
final View sendOsmNoteView = View.inflate(getContext(), R.layout.send_osm_note_fragment, null);
|
||||
final View sendOsmNoteView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.send_osm_note_fragment, null);
|
||||
final LinearLayout accountBlockView = sendOsmNoteView.findViewById(R.id.account_block);
|
||||
final SwitchCompat uploadAnonymously = sendOsmNoteView.findViewById(R.id.upload_anonymously_switch);
|
||||
final TextView accountName = sendOsmNoteView.findViewById(R.id.user_name);
|
||||
String userName = getMyApplication().getSettings().USER_DISPLAY_NAME.get();
|
||||
settings = getMyApplication().getSettings();
|
||||
String userNameOAuth = settings.USER_DISPLAY_NAME.get();
|
||||
String userNameOpenID = settings.USER_NAME.get();
|
||||
String userName = isLoginOAuth() ? userNameOAuth : userNameOpenID;
|
||||
accountName.setText(userName);
|
||||
accountBlockView.setVisibility(View.VISIBLE);
|
||||
uploadAnonymously.setBackgroundResource(isNightMode ? R.drawable.layout_bg_dark : R.drawable.layout_bg);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.osmedit.dialogs;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
|
@ -17,6 +18,8 @@ import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
|||
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||
import net.osmand.plus.osmedit.OsmPoint;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
public class SendPoiBottomSheetFragment extends MenuBottomSheetDialogFragment {
|
||||
|
||||
|
@ -25,6 +28,8 @@ public class SendPoiBottomSheetFragment extends MenuBottomSheetDialogFragment {
|
|||
public static final String POI_UPLOADER_TYPE = "poi_uploader_type";
|
||||
private OsmPoint[] poi;
|
||||
|
||||
protected OsmandSettings settings;
|
||||
|
||||
public enum PoiUploaderType {
|
||||
SIMPLE,
|
||||
FRAGMENT
|
||||
|
@ -34,13 +39,20 @@ public class SendPoiBottomSheetFragment extends MenuBottomSheetDialogFragment {
|
|||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
private boolean isLoginOAuth() {
|
||||
return !Algorithms.isEmpty(getMyApplication().getSettings().USER_DISPLAY_NAME.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
final boolean isNightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
final View sendOsmPoiView = View.inflate(getContext(), R.layout.send_poi_fragment, null);
|
||||
final View sendOsmPoiView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.send_poi_fragment, null);
|
||||
final SwitchCompat closeChangset = sendOsmPoiView.findViewById(R.id.close_change_set_checkbox);
|
||||
final TextView accountName = (TextView) sendOsmPoiView.findViewById(R.id.user_name);
|
||||
String userName = getMyApplication().getSettings().USER_DISPLAY_NAME.get();
|
||||
final TextView accountName = sendOsmPoiView.findViewById(R.id.user_name);
|
||||
settings = getMyApplication().getSettings();
|
||||
String userNameOAuth = settings.USER_DISPLAY_NAME.get();
|
||||
String userNameOpenID = settings.USER_NAME.get();
|
||||
String userName = isLoginOAuth() ? userNameOAuth : userNameOpenID;
|
||||
accountName.setText(userName);
|
||||
closeChangset.setBackgroundResource(isNightMode ? R.drawable.layout_bg_dark : R.drawable.layout_bg);
|
||||
closeChangset.setPadding(30, 0, 0, 0);
|
||||
|
@ -80,8 +92,8 @@ public class SendPoiBottomSheetFragment extends MenuBottomSheetDialogFragment {
|
|||
View view = getView();
|
||||
poi = (OsmPoint[]) getArguments().getSerializable(OPENSTREETMAP_POINT);
|
||||
final SwitchCompat closeChangeSetCheckBox =
|
||||
(SwitchCompat) view.findViewById(R.id.close_change_set_checkbox);
|
||||
final EditText messageEditText = (EditText) view.findViewById(R.id.message_field);
|
||||
view.findViewById(R.id.close_change_set_checkbox);
|
||||
final EditText messageEditText = view.findViewById(R.id.message_field);
|
||||
final SendPoiDialogFragment.PoiUploaderType poiUploaderType = SendPoiDialogFragment.PoiUploaderType.valueOf(getArguments().getString(POI_UPLOADER_TYPE, SendPoiDialogFragment.PoiUploaderType.SIMPLE.name()));
|
||||
final SendPoiDialogFragment.ProgressDialogPoiUploader progressDialogPoiUploader;
|
||||
if (poiUploaderType == SendPoiDialogFragment.PoiUploaderType.SIMPLE && getActivity() instanceof MapActivity) {
|
||||
|
|
Loading…
Reference in a new issue