Send POI, Send GPX

This commit is contained in:
androiddevkkotlin 2020-11-05 00:15:54 +02:00
parent e14989f464
commit 26ce1f9d7b
4 changed files with 17 additions and 13 deletions

View file

@ -130,8 +130,8 @@ public class LoginBottomSheetFragment extends MenuBottomSheetDialogFragment {
} }
} }
public interface LoginOsmAutorizationListener { public interface LoginOsmAuthorizationListener {
void informAutorizationPrefsUpdate(); void informAuthorizationPrefsUpdate();
} }
public void authorize(String oauthVerifier) { public void authorize(String oauthVerifier) {
@ -139,8 +139,8 @@ public class LoginBottomSheetFragment extends MenuBottomSheetDialogFragment {
client.authorize(oauthVerifier); client.authorize(oauthVerifier);
} }
Fragment target = getTargetFragment(); Fragment target = getTargetFragment();
if (target instanceof LoginOsmAutorizationListener) { if (target instanceof LoginOsmAuthorizationListener) {
((LoginOsmAutorizationListener) target).informAutorizationPrefsUpdate(); ((LoginOsmAuthorizationListener) target).informAuthorizationPrefsUpdate();
} }
dismiss(); dismiss();
} }

View file

@ -4,16 +4,19 @@ import android.content.DialogInterface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.osm.PoiType; import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.measurementtool.LoginBottomSheetFragment;
import net.osmand.plus.osmedit.OsmPoint.Action; import net.osmand.plus.osmedit.OsmPoint.Action;
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment; import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment;
import net.osmand.plus.osmedit.oauth.OsmOAuthAuthorizationAdapter; import net.osmand.plus.osmedit.oauth.OsmOAuthAuthorizationAdapter;
import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.render.RenderingIcons;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import java.util.Map; import java.util.Map;
@ -39,16 +42,14 @@ public class EditPOIMenuController extends MenuController {
@Override @Override
public void buttonPressed() { public void buttonPressed() {
MapActivity activity = getMapActivity(); MapActivity activity = getMapActivity();
OsmandSettings settings = activity.getMyApplication().getSettings();
if (plugin != null && activity != null) { if (plugin != null && activity != null) {
OsmOAuthAuthorizationAdapter client = new OsmOAuthAuthorizationAdapter(activity.getMyApplication()); OsmOAuthAuthorizationAdapter client = new OsmOAuthAuthorizationAdapter(activity.getMyApplication());
if (client.isValidToken()){ if (client.isValidToken() || !Algorithms.isEmpty(settings.USER_NAME.get()) && !Algorithms.isEmpty(settings.USER_PASSWORD.get())){
new SendPoiDialogFragment.SimpleProgressDialogPoiUploader(activity). new SendPoiDialogFragment.SimpleProgressDialogPoiUploader(activity).
showProgressDialog(new OsmPoint[] { getOsmPoint() }, false, false); showProgressDialog(new OsmPoint[] { getOsmPoint() }, false, false);
} } else {
else { LoginBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), activity.getLoginBottomSheetFragment());
SendPoiDialogFragment sendPoiDialogFragment =
SendPoiDialogFragment.createInstance(new OsmPoint[]{getOsmPoint()}, SendPoiDialogFragment.PoiUploaderType.SIMPLE);
sendPoiDialogFragment.show(activity.getSupportFragmentManager(), SendPoiDialogFragment.TAG);
} }
} }
} }

View file

@ -32,7 +32,7 @@ import org.apache.commons.logging.Log;
import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID; import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID;
import static net.osmand.plus.osmedit.OsmEditingPlugin.OSM_EDIT_TAB; import static net.osmand.plus.osmedit.OsmEditingPlugin.OSM_EDIT_TAB;
public class OsmEditingFragment extends BaseSettingsFragment implements OnPreferenceChanged, ValidateOsmLoginDetailsTask.ValidateOsmLoginListener, LoginBottomSheetFragment.LoginOsmAutorizationListener { public class OsmEditingFragment extends BaseSettingsFragment implements OnPreferenceChanged, ValidateOsmLoginDetailsTask.ValidateOsmLoginListener, LoginBottomSheetFragment.LoginOsmAuthorizationListener {
private static final Log log = PlatformUtil.getLog(OsmEditingFragment.class); private static final Log log = PlatformUtil.getLog(OsmEditingFragment.class);
@ -188,7 +188,7 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer
} }
@Override @Override
public void informAutorizationPrefsUpdate() { public void informAuthorizationPrefsUpdate() {
client = new OsmOAuthAuthorizationAdapter(app); client = new OsmOAuthAuthorizationAdapter(app);
updateAllSettings(); updateAllSettings();
} }

View file

@ -21,6 +21,8 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
@ -41,6 +43,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.TabActivity; import net.osmand.plus.activities.TabActivity;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.measurementtool.LoginBottomSheetFragment;
import net.osmand.plus.myplaces.AvailableGPXFragment; import net.osmand.plus.myplaces.AvailableGPXFragment;
import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo; import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.myplaces.FavoritesActivity;
@ -464,7 +467,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
String pwd = settings.USER_PASSWORD.get(); String pwd = settings.USER_PASSWORD.get();
String authToken = settings.USER_ACCESS_TOKEN.get(); String authToken = settings.USER_ACCESS_TOKEN.get();
if ((Algorithms.isEmpty(name) || Algorithms.isEmpty(pwd)) && Algorithms.isEmpty(authToken)) { if ((Algorithms.isEmpty(name) || Algorithms.isEmpty(pwd)) && Algorithms.isEmpty(authToken)) {
Toast.makeText(la, R.string.validate_gpx_upload_name_pwd, Toast.LENGTH_LONG).show(); LoginBottomSheetFragment.showInstance(f.getFragmentManager(), f.getTargetFragment());
return false; return false;
} }
AlertDialog.Builder bldr = new AlertDialog.Builder(la); AlertDialog.Builder bldr = new AlertDialog.Builder(la);