Bugs of OSM Editing dialogs #287
This commit is contained in:
parent
abbe0ccf95
commit
b43d6b584c
8 changed files with 37 additions and 49 deletions
|
@ -477,7 +477,8 @@
|
|||
<color name="switch_button_active_stroke_dark">#80D28521</color>
|
||||
<color name="empty_hint_bg">#80000000</color>
|
||||
<color name="input_layout_bg_color">#4DCCCCCC</color>
|
||||
<color name="text_input_background_light">#14000000</color>
|
||||
<color name="text_input_background_dark">#0DFFFFFF</color>
|
||||
<color name="text_input_background_light">#4DCCCCCC</color>
|
||||
<color name="text_input_background_dark">#1AFFFFFF</color>
|
||||
<color name="mtrl_textinput_default_box_stroke_color">#67727272</color>
|
||||
|
||||
</resources>
|
|
@ -94,7 +94,7 @@ public class LoginBottomSheetFragment extends MenuBottomSheetDialogFragment impl
|
|||
if (!(getActivity() instanceof MapActivity) && fragment instanceof OsmAuthorizationListener) {
|
||||
osmOAuthHelper.addListener((OsmAuthorizationListener) fragment);
|
||||
}
|
||||
osmOAuthHelper.startOAuth((ViewGroup) view);
|
||||
osmOAuthHelper.startOAuth((ViewGroup) view, nightMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.osmand.plus.osmedit;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PointF;
|
||||
import android.util.Xml;
|
||||
|
@ -10,10 +9,8 @@ import android.view.View;
|
|||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.FavouritePoint.BackgroundType;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -25,6 +22,7 @@ import net.osmand.osm.io.NetworkUtils;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.base.PointImageDrawable;
|
||||
import net.osmand.plus.osmedit.dialogs.BugBottomSheetDialog;
|
||||
import net.osmand.plus.osmedit.dialogs.SendOsmNoteBottomSheetFragment;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -32,7 +30,6 @@ import net.osmand.plus.osmedit.OsmPoint.Action;
|
|||
import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
@ -370,29 +367,13 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
titleTextId, posButtonTextId, action, bug, point, getHandleBugListener());
|
||||
return;
|
||||
} else {
|
||||
((EditText) view.findViewById(R.id.user_name_field)).setText(getUserName());
|
||||
((EditText) view.findViewById(R.id.password_field)).setText(
|
||||
activity.getMyApplication().getSettings().USER_PASSWORD.get());
|
||||
OsmNotesPoint pnt = new OsmNotesPoint();
|
||||
pnt.setAction(action);
|
||||
pnt.setId(bug.getId());
|
||||
pnt.setLatitude(bug.getLatitude());
|
||||
pnt.setLongitude(bug.getLongitude());
|
||||
SendOsmNoteBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), new OsmPoint[]{pnt});
|
||||
}
|
||||
if (!Algorithms.isEmpty(text)) {
|
||||
((EditText) view.findViewById(R.id.message_field)).setText(text);
|
||||
}
|
||||
view.findViewById(R.id.message_field).requestFocus();
|
||||
AndroidUtils.softKeyboardDelayed(activity, view.findViewById(R.id.message_field));
|
||||
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle(R.string.shared_string_commit);
|
||||
builder.setView(view);
|
||||
builder.setPositiveButton(posButtonTextId, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String text = offline ? getMessageText(view) : getTextAndUpdateUserPwd(view);
|
||||
activity.getContextMenu().close();
|
||||
handleBug(text, bug, action, point);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
private void handleBug(String text, OpenStreetNote bug, Action action, OsmNotesPoint point) {
|
||||
|
|
|
@ -57,8 +57,6 @@ public class BugBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
|||
View osmNoteView = View.inflate(UiUtilities.getThemedContext(app, nightMode),
|
||||
R.layout.open_osm_note_text, null);
|
||||
TextInputLayout textBox = osmNoteView.findViewById(R.id.name_text_box);
|
||||
int highlightColorId = nightMode ? R.color.list_background_color_dark : R.color.activity_background_color_light;
|
||||
textBox.setBoxBackgroundColorResource(highlightColorId);
|
||||
textBox.setHint(AndroidUtils.addColon(app, R.string.osn_bug_name));
|
||||
ColorStateList colorStateList = ColorStateList.valueOf(ContextCompat
|
||||
.getColor(app, nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light));
|
||||
|
@ -86,11 +84,6 @@ public class BugBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
|||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getBgColorId() {
|
||||
return nightMode ? R.color.activity_background_color_dark : R.color.list_background_color_light;
|
||||
}
|
||||
|
||||
public static void showInstance(@NonNull FragmentManager fm, OsmBugsUtil osmBugsUtil, OsmBugsUtil local,
|
||||
String text, int titleTextId, int posButtonTextId, final OsmPoint.Action action,
|
||||
final OsmBugsLayer.OpenStreetNote bug, final OsmNotesPoint point,
|
||||
|
|
|
@ -59,6 +59,7 @@ public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragmen
|
|||
private LinearLayout signInView;
|
||||
private SwitchCompat uploadAnonymously;
|
||||
private OsmandApplication app;
|
||||
private EditText noteText;
|
||||
|
||||
private boolean isLoginOAuth() {
|
||||
return !Algorithms.isEmpty(settings.USER_DISPLAY_NAME.get());
|
||||
|
@ -78,7 +79,7 @@ public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragmen
|
|||
final View sendOsmNoteView = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
|
||||
R.layout.send_osm_note_fragment, null);
|
||||
|
||||
EditText noteText = sendOsmNoteView.findViewById(R.id.note_text);
|
||||
noteText = sendOsmNoteView.findViewById(R.id.note_text);
|
||||
noteText.setText(((OsmNotesPoint) poi[0]).getText());
|
||||
noteText.setSelection(noteText.getText().length());
|
||||
TextInputLayout noteHint = sendOsmNoteView.findViewById(R.id.note_hint);
|
||||
|
@ -98,7 +99,7 @@ public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragmen
|
|||
if (fragment instanceof OsmAuthorizationListener) {
|
||||
app.getOsmOAuthHelper().addListener((OsmAuthorizationListener) fragment);
|
||||
}
|
||||
app.getOsmOAuthHelper().startOAuth((ViewGroup) v);
|
||||
app.getOsmOAuthHelper().startOAuth((ViewGroup) getView(), nightMode);
|
||||
}
|
||||
});
|
||||
View loginButton = sendOsmNoteView.findViewById(R.id.login_button);
|
||||
|
@ -201,6 +202,7 @@ public class SendOsmNoteBottomSheetFragment extends MenuBottomSheetDialogFragmen
|
|||
progressDialogPoiUploader = (ProgressDialogPoiUploader) getParentFragment();
|
||||
}
|
||||
if (progressDialogPoiUploader != null) {
|
||||
((OsmNotesPoint) poi[0]).setText(noteText.getText().toString());
|
||||
progressDialogPoiUploader.showProgressDialog(poi, false, uploadAnonymously.isChecked());
|
||||
}
|
||||
dismiss();
|
||||
|
|
|
@ -36,6 +36,8 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
public class SendPoiDialogFragment extends DialogFragment {
|
||||
|
||||
|
||||
public static final String TAG = "SendPoiDialogFragment";
|
||||
public static final String OPENSTREETMAP_POINT = "openstreetmap_point";
|
||||
public static final String POI_UPLOADER_TYPE = "poi_uploader_type";
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
package net.osmand.plus.osmedit.oauth;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.TrafficStats;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.browser.customtabs.CustomTabsIntent;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.github.scribejava.core.builder.api.DefaultApi10a;
|
||||
import com.github.scribejava.core.model.OAuth1AccessToken;
|
||||
|
@ -20,6 +27,7 @@ import net.osmand.osm.oauth.OsmOAuthAuthorizationClient;
|
|||
import net.osmand.plus.OsmAndConstants;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
@ -79,8 +87,8 @@ public class OsmOAuthAuthorizationAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
public void startOAuth(final ViewGroup rootLayout) {
|
||||
new StartOAuthAsyncTask(rootLayout).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
|
||||
public void startOAuth(final ViewGroup rootLayout, boolean nightMode) {
|
||||
new StartOAuthAsyncTask(rootLayout, nightMode).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
|
||||
}
|
||||
|
||||
private void saveToken() {
|
||||
|
@ -89,11 +97,10 @@ public class OsmOAuthAuthorizationAdapter {
|
|||
app.getSettings().USER_ACCESS_TOKEN_SECRET.set(accessToken.getTokenSecret());
|
||||
}
|
||||
|
||||
private void loadWebView(ViewGroup root, String url) {
|
||||
WebView webView = new WebView(root.getContext());
|
||||
webView.requestFocus(View.FOCUS_DOWN);
|
||||
webView.loadUrl(url);
|
||||
root.addView(webView);
|
||||
private void loadWebView(ViewGroup root, boolean nightMode, String url) {
|
||||
Uri uri = Uri.parse(url);
|
||||
Context context = root.getContext();
|
||||
WikipediaDialogFragment.showFullArticle(context, uri, nightMode);
|
||||
}
|
||||
|
||||
public void performGetRequest(String url, OAuthAsyncRequestCallback<Response> callback) {
|
||||
|
@ -117,9 +124,11 @@ public class OsmOAuthAuthorizationAdapter {
|
|||
private class StartOAuthAsyncTask extends AsyncTask<Void, Void, OAuth1RequestToken> {
|
||||
|
||||
private final ViewGroup rootLayout;
|
||||
boolean nightMode;
|
||||
|
||||
public StartOAuthAsyncTask(ViewGroup rootLayout) {
|
||||
public StartOAuthAsyncTask(ViewGroup rootLayout, boolean nightMode) {
|
||||
this.rootLayout = rootLayout;
|
||||
this.nightMode = nightMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -129,7 +138,7 @@ public class OsmOAuthAuthorizationAdapter {
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(@NonNull OAuth1RequestToken requestToken) {
|
||||
loadWebView(rootLayout, client.getService().getAuthorizationUrl(requestToken));
|
||||
loadWebView(rootLayout, nightMode, client.getService().getAuthorizationUrl(requestToken));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ public class OsmOAuthHelper {
|
|||
return authorizationAdapter;
|
||||
}
|
||||
|
||||
public void startOAuth(@NonNull ViewGroup view) {
|
||||
authorizationAdapter.startOAuth(view);
|
||||
public void startOAuth(@NonNull ViewGroup view, boolean nightMode) {
|
||||
authorizationAdapter.startOAuth(view, nightMode);
|
||||
}
|
||||
|
||||
public void authorize(@NonNull String oauthVerifier) {
|
||||
|
|
Loading…
Reference in a new issue