diff --git a/OsmAnd/AndroidManifest-library.xml b/OsmAnd/AndroidManifest-library.xml
new file mode 100644
index 0000000000..379f1ce963
--- /dev/null
+++ b/OsmAnd/AndroidManifest-library.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OsmAnd/build.gradle.lib b/OsmAnd/build.gradle.lib
index b70a881218..2824130409 100644
--- a/OsmAnd/build.gradle.lib
+++ b/OsmAnd/build.gradle.lib
@@ -1,23 +1,5 @@
-//apply plugin: 'com.android.application'
apply plugin: 'com.android.library'
-// Global Parameters accepted
-// TARGET_APP_NAME - app name
-// APK_NUMBER_VERSION - version number of apk
-// APK_VERSION_SUFFIX - build number like #99999Z, appended (for dev builds) to Manifest's versionName as X.X.X#99999Z
-// Z means flavor: M=-master, D=-main-default, B=-Blackberry, Des=-design, MQA=-main-qt-arm, MQDA=-main-qt-default-arm, S=-sherpafy
-// APP_EDITION - date stamp of builds
-// APP_FEATURES - features +play_market +gps_status -parking_plugin -blackberry -free_version -amazon
-
-// 1. To be done Filter fonts
-//
-//
-//
-//
-//
-//
-// Less important
-
task printc {
configurations.each { if(it.isCanBeResolved()) println it.name }
}
@@ -27,67 +9,21 @@ android {
buildToolsVersion "29.0.3"
// compileNdkVersion "android-ndk-r17b"
- signingConfigs {
- development {
- storeFile file("../keystores/debug.keystore")
- storePassword "android"
- keyAlias "androiddebugkey"
- keyPassword "android"
- }
-
- publishing {
- storeFile file("/var/lib/jenkins/osmand_key")
- storePassword System.getenv("OSMAND_APK_PASSWORD")
- keyAlias "osmand"
- keyPassword System.getenv("OSMAND_APK_PASSWORD")
- }
- }
-
defaultConfig {
- minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() : 15
+ minSdkVersion 15
targetSdkVersion 29
- versionCode 390
- versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode
multiDexEnabled true
- versionName "3.9.0"
- versionName System.getenv("APK_VERSION")? System.getenv("APK_VERSION").toString(): versionName
- versionName System.getenv("APK_VERSION_SUFFIX")? versionName + System.getenv("APK_VERSION_SUFFIX").toString(): versionName
- // Stops the Gradle plugin’s automatic rasterization of vectors
- // vectorDrawables.generatedDensities = ['hdpi']
vectorDrawables.useSupportLibrary = true
}
lintOptions {
- lintConfig file("lint.xml")
abortOnError false
- warningsAsErrors false
}
- /*
- bundle {
- language {
- // Specifies that the app bundle should not support
- // configuration APKs for language resources. These
- // resources are instead packaged with each base and
- // dynamic feature APK.
- enableSplit = false
- }
- }
- */
- // related to kuromoji
- //packagingOptions {
- // exclude '/META-INF/CONTRIBUTORS.md'
- // exclude '/META-INF/LICENSE.md'
- // exclude '/META-INF/NOTICE.md'
- //}
-
- // This is from OsmAndCore_android.aar - for some reason it's not inherited
aaptOptions {
// Don't compress any embedded resources
noCompress "qz"
cruncherEnabled = false
- // Flag notifies aapt to keep the attribute IDs around
- // additionalParameters "--no-version-vectors"
}
dexOptions {
@@ -96,7 +32,7 @@ android {
sourceSets {
main {
- manifest.srcFile "AndroidManifest.xml"
+ manifest.srcFile "AndroidManifest-library.xml"
jni.srcDirs = []
jniLibs.srcDirs = ["libs"]
aidl.srcDirs = ["src"]
@@ -107,25 +43,8 @@ android {
assets.srcDirs = ["assets"]
}
debug {
- manifest.srcFile "AndroidManifest-debug.xml"
}
- /*
- full {
- java.srcDirs = ["src-google"]
- }
- free {
- java.srcDirs = ["src-google"]
- manifest.srcFile "AndroidManifest-free.xml"
- }
- freedev {
- java.srcDirs = ["src-google"]
- manifest.srcFile "AndroidManifest-freedev.xml"
- }
- freehuawei {
- java.srcDirs = ["src-huawei"]
- manifest.srcFile "AndroidManifest-freehuawei.xml"
- }
- */
+
legacy {
jniLibs.srcDirs = ["libc++"]
}
@@ -165,70 +84,27 @@ android {
}
}
- /*
- // Version
- freedev {
- dimension "version"
- applicationId "net.osmand.dev"
- // resConfig "en"
- }
- free {
- dimension "version"
- applicationId "net.osmand"
- }
- full {
- dimension "version"
- applicationId "net.osmand.plus"
- }
- freehuawei {
- dimension "version"
- applicationId "net.osmand.huawei"
- }
- */
// CoreVersion
// Build that doesn't include 3D OpenGL
legacy {
dimension "coreversion"
}
- // Build that includes 3D OpenGL release
- qtcore {
- dimension "coreversion"
- }
- // Build that includes 3D OpenGL debug
- qtcoredebug {
- dimension "coreversion"
- }
}
buildTypes {
debug {
- buildConfigField "String", "OPR_BASE_URL", "\"https://test.openplacereviews.org/\""
- buildConfigField "String", "OSM_OAUTH_CONSUMER_KEY", "\"Ti2qq3fo4i4Wmuox3SiWRIGq3obZisBHnxmcM05y\""
- buildConfigField "String", "OSM_OAUTH_CONSUMER_SECRET", "\"lxulb3HYoMmd2cC4xxNe1dyfRMAY8dS0eNihJ0DM\""
- signingConfig signingConfigs.development
+ debuggable true
}
+
release {
- buildConfigField "String", "OPR_BASE_URL", "\"https://test.openplacereviews.org/\""
- buildConfigField "String", "OSM_OAUTH_CONSUMER_KEY", "\"Ti2qq3fo4i4Wmuox3SiWRIGq3obZisBHnxmcM05y\""
- buildConfigField "String", "OSM_OAUTH_CONSUMER_SECRET", "\"lxulb3HYoMmd2cC4xxNe1dyfRMAY8dS0eNihJ0DM\""
- signingConfig signingConfigs.publishing
+ debuggable false
}
}
-
}
def replaceNoTranslate(line) {
- if (line.contains("\"app_name\"") && System.getenv("TARGET_APP_NAME")) {
- return line.replaceAll(">[^<]*<", ">" + System.getenv("TARGET_APP_NAME") + "<")
- }
- if (line.contains("\"app_name_free\"") && System.getenv("TARGET_APP_NAME")) {
- return line.replaceAll(">[^<]*<", ">" + System.getenv("TARGET_APP_NAME") + "<")
- }
- if (line.contains("\"app_edition\"") && System.getenv("APP_EDITION")) {
- return line.replaceAll(">[^<]*<", ">" + System.getenv("APP_EDITION") + "<")
- }
- if (line.contains("\"versionFeatures\"") && System.getenv("APP_FEATURES")) {
- return line.replaceAll(">[^<]*<", ">" + System.getenv("APP_FEATURES") + "<")
+ if (line.contains("\"versionFeatures\"")) {
+ return line.replaceAll(">[^<]*<", ">" + "" + "<")
}
return line;
}
@@ -402,6 +278,8 @@ task collectExternalResources {
// Legacy core build
import org.apache.tools.ant.taskdefs.condition.Os
+import java.util.regex.Pattern
+
task buildOsmAndCore(type: Exec) {
Gradle gradle = getGradle()
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString().toLowerCase()
@@ -452,11 +330,6 @@ afterEvaluate {
android.libraryVariants.all { variant ->
variant.javaCompiler.dependsOn(collectExternalResources, buildOsmAndCore, cleanupDuplicatesInCore)
}
- Gradle gradle = getGradle()
- String tskReqStr = gradle.getStartParameter().getTaskRequests().toString().toLowerCase()
- if (tskReqStr.contains("huawei")) {
- apply plugin: 'com.huawei.agconnect'
- }
}
task appStart(type: Exec) {
@@ -466,6 +339,27 @@ task appStart(type: Exec) {
// commandLine 'cmd', '/c', 'adb', 'shell', 'am', 'start', '-n', 'net.osmand.plus/net.osmand.plus.activities.MapActivity'
}
+// Uploading artifacts to local path
+group = "net.osmand"
+uploadArchives {
+ repositories.ivy {
+ // credentials {
+ // username ""
+ // password ""
+ // }
+ url = System.getenv("OSMAND_BINARIES_IVY_ROOT") ?: "./"
+ layout "pattern" , {
+ artifact "[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
+ }
+
+// def gitInfo = "git describe --long".execute().text.trim()
+// def parsedGitInfo = Pattern.compile("v(\\d+\\.\\d+)-([\\d.]+)-(\\w+)").matcher(gitInfo)
+// assert parsedGitInfo.matches()
+// version = parsedGitInfo.group(1) + "-SNAPSHOT"
+ version = "1.0"
+ }
+}
+
dependencies {
implementation project(path: ':OsmAnd-java', configuration: 'android')
implementation project(':OsmAnd-api')
@@ -497,14 +391,14 @@ dependencies {
// implementation 'com.ibm.icu:icu4j:50.1'
// implementation 'net.sf.trove4j:trove4j:3.0.3'
- qtcoreImplementation fileTree(include: ['QtAndroid.jar', 'QtAndroidBearer.jar'], dir: 'libs')
- qtcoredebugImplementation fileTree(include: ['QtAndroid.jar', 'QtAndroidBearer.jar'], dir: 'libs')
+// qtcoreImplementation fileTree(include: ['QtAndroid.jar', 'QtAndroidBearer.jar'], dir: 'libs')
+// qtcoredebugImplementation fileTree(include: ['QtAndroid.jar', 'QtAndroidBearer.jar'], dir: 'libs')
legacyImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar"
- qtcoredebugImplementation "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar"
- qtcoredebugImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
- qtcoreImplementation "net.osmand:OsmAndCore_androidNativeRelease:0.1-SNAPSHOT@aar"
- qtcoreImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
+// qtcoredebugImplementation "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar"
+// qtcoredebugImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
+// qtcoreImplementation "net.osmand:OsmAndCore_androidNativeRelease:0.1-SNAPSHOT@aar"
+// qtcoreImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
implementation ("com.getkeepsafe.taptargetview:taptargetview:1.12.0"){
exclude group: 'com.android.support'
}
@@ -517,5 +411,5 @@ dependencies {
}
implementation 'com.jaredrummler:colorpicker:1.1.0'
- //freehuaweiImplementation 'com.huawei.hms:iap:5.0.2.300'
+ implementation 'org.bouncycastle:bcpkix-jdk15on:1.56'
}
diff --git a/OsmAnd/res/layout/activity_opr_webview.xml b/OsmAnd/res/layout/activity_opr_webview.xml
index 9d3f28c67a..9e32d56df4 100644
--- a/OsmAnd/res/layout/activity_opr_webview.xml
+++ b/OsmAnd/res/layout/activity_opr_webview.xml
@@ -1,25 +1,23 @@
+ android:layout_height="@dimen/toolbar_height">
diff --git a/OsmAnd/res/layout/dialog_button_with_icon.xml b/OsmAnd/res/layout/dialog_button_with_icon.xml
new file mode 100644
index 0000000000..264f884495
--- /dev/null
+++ b/OsmAnd/res/layout/dialog_button_with_icon.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml
index 64ab1cc330..c1addc1349 100644
--- a/OsmAnd/res/values/sizes.xml
+++ b/OsmAnd/res/values/sizes.xml
@@ -249,6 +249,7 @@
16dp
12dp
8dp
+ 6dp
8dp
13dp
5dp
diff --git a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java
index d7798a646b..e5d7b3e11d 100644
--- a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java
@@ -140,4 +140,13 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
public DashFragmentData getCardFragment() {
return DashSimulateFragment.FRAGMENT_DATA;
}
+
+ @Override
+ public void disable(OsmandApplication app) {
+ if (app.getSettings().USE_DEV_URL.get()) {
+ app.getSettings().USE_DEV_URL.set(false);
+ app.getOsmOAuthHelper().resetAuthorization();
+ }
+ super.disable(app);
+ }
}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java
index bfd21f5abb..26dfdaefa7 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java
@@ -10,7 +10,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.PorterDuff;
-import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
@@ -368,34 +367,17 @@ public class MenuBuilder {
}
}
- private View createAddPhotoButton(Context context) {
- TextView b = new TextView(context);
- b.setOnClickListener(new OnClickListener() {
+ private View createAddPhotoButton(Context ctx) {
+ View view = UiUtilities.getInflater(ctx, !light).inflate(R.layout.dialog_button_with_icon, null);
+ int dp6 = ctx.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_title_padding_bottom);
+ View button = view.findViewById(R.id.button);
+ UiUtilities.setupDialogButton(!light, button, UiUtilities.DialogButtonType.STROKED,
+ ctx.getString(R.string.shared_string_add_photo), R.drawable.ic_sample);
+ TextView textView = view.findViewById(R.id.button_text);
+ textView.setCompoundDrawablePadding(dp6);
+ button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
- AddPhotosBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
- }
- });
- b.setTypeface(FontCache.getRobotoRegular(context));
- Drawable d = ContextCompat.getDrawable(context, R.drawable.ic_sample);
- b.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null);
- LinearLayout.LayoutParams params = new
- LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT);
- int dp16 = AndroidUtils.dpToPx(context, 16f);
- int dp8 = AndroidUtils.dpToPx(context, 8f);
- params.setMargins(dp16, 0, dp16, dp16);
- b.setPadding(dp8, dp8, dp16, dp8);
- b.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
- b.setLayoutParams(params);
- b.setCompoundDrawablePadding(dp8);
- b.setGravity(Gravity.CENTER_VERTICAL);
- b.setTypeface(null, Typeface.BOLD);
- b.setText(context.getResources().getString(R.string.shared_string_add_photo));
- b.setBackgroundResource(R.drawable.btn_border_light);
- b.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(final View view) {
if (false) {
AddPhotosBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
} else {
@@ -429,10 +411,9 @@ public class MenuBuilder {
}
}
});
- //TODO feature under development
- b.setVisibility(View.GONE);
- b.setTextColor(ContextCompat.getColor(context, R.color.preference_category_title));
- return b;
+ //TODO This feature is under development
+ view.setVisibility(View.VISIBLE);
+ return view;
}
private void buildCoordinatesRow(View view) {
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java
index 2b50ea6b2f..94ef66beab 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java
@@ -16,6 +16,7 @@ import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities.DialogButtonType;
+import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.osmedit.oauth.OsmOAuthHelper;
@@ -90,7 +91,7 @@ public class LoginBottomSheetFragment extends MenuBottomSheetDialogFragment impl
View view = getView();
if (view != null) {
Fragment fragment = getTargetFragment();
- if (fragment instanceof OsmAuthorizationListener) {
+ if (!(getActivity() instanceof MapActivity) && fragment instanceof OsmAuthorizationListener) {
osmOAuthHelper.addListener((OsmAuthorizationListener) fragment);
}
osmOAuthHelper.startOAuth((ViewGroup) view);
diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java
index 72aa9873d3..14fd181f54 100644
--- a/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java
+++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OPRWebviewActivity.java
@@ -3,8 +3,10 @@ package net.osmand.plus.openplacereviews;
import android.content.Context;
import android.graphics.PorterDuff;
+import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.view.View;
import android.webkit.CookieManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
@@ -14,8 +16,10 @@ import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import net.osmand.AndroidUtils;
+import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandActionBarActivity;
+import net.osmand.plus.settings.backend.OsmandSettings;
public class OPRWebviewActivity extends OsmandActionBarActivity {
public static final String KEY_LOGIN = "LOGIN_KEY";
@@ -30,7 +34,7 @@ public class OPRWebviewActivity extends OsmandActionBarActivity {
public static String getCookieUrl(Context ctx) {
return getBaseUrl(ctx) + "profile";
}
-
+
public static String getLoginUrl(Context ctx) {
return getBaseUrl(ctx) + "login";
}
@@ -44,24 +48,39 @@ public class OPRWebviewActivity extends OsmandActionBarActivity {
}
public void onCreate(Bundle savedInstanceState) {
+ OsmandApplication app = getMyApplication();
+ OsmandSettings settings = app.getSettings();
+ boolean nightMode = !settings.isLightContent();
+ int themeId = nightMode ? R.style.OsmandDarkTheme_NoActionbar : R.style.OsmandLightTheme_NoActionbar_LightStatusBar;
+ setTheme(themeId);
+ getWindow().setStatusBarColor(ContextCompat.getColor(this, nightMode
+ ? R.color.list_background_color_dark : R.color.list_background_color_light));
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_opr_webview);
- Bundle b = getIntent().getExtras();
- setSupportActionBar(this.findViewById(R.id.toolbar));
- if (b != null) {
- String title = b.getString(KEY_TITLE, "");
- this.findViewById(R.id.toolbar_text).setText(title);
+ Bundle bundle = getIntent().getExtras();
+ Toolbar toolbar = findViewById(R.id.toolbar);
+ if (bundle != null) {
+ TextView titleView = findViewById(R.id.toolbar_text);
+ String title = bundle.getString(KEY_TITLE, "");
+ titleView.setText(title);
}
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- final Drawable upArrow = getMyApplication().getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(this));
+ toolbar.setBackgroundDrawable(new ColorDrawable(AndroidUtils.getColorFromAttr(this, R.attr.bg_color)));
+ final Drawable upArrow = app.getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(this));
upArrow.setColorFilter(ContextCompat.getColor(this, R.color.color_favorite_gray), PorterDuff.Mode.SRC_ATOP);
- getSupportActionBar().setHomeAsUpIndicator(upArrow);
- webView = (WebView) findViewById(R.id.printDialogWebview);
+ toolbar.setNavigationIcon(upArrow);
+ toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
+ toolbar.setNavigationOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ onBackPressed();
+ }
+ });
+ webView = findViewById(R.id.printDialogWebview);
webView.setWebViewClient(new CloseOnSuccessWebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
WebView.setWebContentsDebuggingEnabled(true);
- if (b != null) {
- isLogin = b.getBoolean(KEY_LOGIN);
+ if (bundle != null) {
+ isLogin = bundle.getBoolean(KEY_LOGIN);
if (isLogin) {
webView.loadUrl(getLoginUrl(this));
} else {
diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java
index 2f936cf21e..00aba01997 100644
--- a/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java
+++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OprStartFragment.java
@@ -2,6 +2,7 @@ package net.osmand.plus.openplacereviews;
import android.content.Intent;
import android.graphics.Typeface;
+import android.os.Build;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
@@ -26,11 +27,13 @@ public class OprStartFragment extends BaseOsmAndFragment {
private static final String TAG = OprStartFragment.class.getSimpleName();
private static final Log LOG = PlatformUtil.getLog(OprStartFragment.class);
private static final String openPlaceReviewsUrl = "OpenPlaceReviews.org";
+ private boolean nightMode;
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
- View v = inflater.inflate(R.layout.fragment_opr_login, container, false);
+ nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
+ View v = UiUtilities.getInflater(requireMyActivity(), nightMode).inflate(R.layout.fragment_opr_login, container,
+ false);
View createAccount = v.findViewById(R.id.register_opr_create_account);
v.findViewById(R.id.back_button).setOnClickListener(new View.OnClickListener() {
@Override
@@ -77,6 +80,14 @@ public class OprStartFragment extends BaseOsmAndFragment {
v.findViewById(R.id.start_opr_description).setMovementMethod(LinkMovementMethod.getInstance());
}
+ @Override
+ public int getStatusBarColorId() {
+ View view = getView();
+ if (view != null && Build.VERSION.SDK_INT >= 23 && !nightMode) {
+ view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+ }
+ return nightMode ? R.color.list_background_color_dark : R.color.list_background_color_light;
+ }
private class URLSpanNoUnderline extends URLSpan {
public URLSpanNoUnderline(String url) {
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingFragment.java
index 991073c435..81cebe393d 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingFragment.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingFragment.java
@@ -15,13 +15,14 @@ import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
+import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.measurementtool.LoginBottomSheetFragment;
import net.osmand.plus.osmedit.ValidateOsmLoginDetailsTask.ValidateOsmLoginListener;
-import net.osmand.plus.osmedit.oauth.OsmOAuthAuthorizationAdapter;
+import net.osmand.plus.osmedit.oauth.OsmOAuthHelper;
import net.osmand.plus.osmedit.oauth.OsmOAuthHelper.OsmAuthorizationListener;
import net.osmand.plus.settings.backend.OsmAndAppCustomization;
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
@@ -41,12 +42,12 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer
public static final String OSM_LOGIN_DATA = "osm_login_data";
private static final String OSM_EDITING_INFO = "osm_editing_info";
- private OsmOAuthAuthorizationAdapter authorizationAdapter;
+ private OsmOAuthHelper authHelper;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- authorizationAdapter = app.getOsmOAuthHelper().getAuthorizationAdapter();
+ authHelper = app.getOsmOAuthHelper();
FragmentActivity activity = requireMyActivity();
activity.getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@@ -121,7 +122,7 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer
}
private boolean isValidToken() {
- return authorizationAdapter.isValidToken();
+ return authHelper.isValidToken();
}
private boolean isLoginExists() {
@@ -139,10 +140,14 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer
}
private void setupUseDevUrlPref() {
- Drawable icon = getPersistentPrefIcon(R.drawable.ic_action_laptop);
SwitchPreferenceEx useDevUrlPref = findPreference(settings.USE_DEV_URL.getId());
- useDevUrlPref.setDescription(getString(R.string.use_dev_url_descr));
- useDevUrlPref.setIcon(icon);
+ if (OsmandPlugin.isDevelopment()) {
+ Drawable icon = getPersistentPrefIcon(R.drawable.ic_action_laptop);
+ useDevUrlPref.setDescription(getString(R.string.use_dev_url_descr));
+ useDevUrlPref.setIcon(icon);
+ } else {
+ useDevUrlPref.setVisible(false);
+ }
}
private void setupOsmEditsDescrPref() {
@@ -174,7 +179,6 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer
if (settings.USE_DEV_URL.getId().equals(prefId) && newValue instanceof Boolean) {
settings.USE_DEV_URL.set((Boolean) newValue);
osmLogout();
- authorizationAdapter = app.getOsmOAuthHelper().updateAdapter();
return true;
}
return super.onPreferenceChange(preference, newValue);
@@ -206,33 +210,26 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer
return super.onPreferenceClick(preference);
}
- private void osmLogout() {
- boolean validToken = isValidToken();
- if (validToken || isLoginExists()) {
- if (validToken) {
- settings.USER_ACCESS_TOKEN.resetToDefault();
- settings.USER_ACCESS_TOKEN_SECRET.resetToDefault();
- authorizationAdapter.resetToken();
- } else {
- settings.USER_NAME.resetToDefault();
- settings.USER_PASSWORD.resetToDefault();
- }
+ public void osmLogout() {
+ if (authHelper.isValidToken() || isLoginExists()) {
app.showShortToastMessage(R.string.osm_edit_logout_success);
- updateAllSettings();
}
+ authHelper.resetAuthorization();
+ updateAllSettings();
}
@Override
public void onPreferenceChanged(String prefId) {
if (settings.USE_DEV_URL.getId().equals(prefId)) {
osmLogout();
- authorizationAdapter = app.getOsmOAuthHelper().updateAdapter();
}
updateAllSettings();
}
@Override
public void authorizationCompleted() {
- updateAllSettings();
+ if (getContext() != null) {
+ updateAllSettings();
+ }
}
}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java b/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java
index d7ef523d8c..acda0e0361 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthHelper.java
@@ -5,6 +5,8 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.util.Algorithms;
import java.util.HashSet;
import java.util.Set;
@@ -14,9 +16,11 @@ public class OsmOAuthHelper {
private final OsmandApplication app;
private OsmOAuthAuthorizationAdapter authorizationAdapter;
private final Set listeners = new HashSet<>();
+ private final OsmandSettings settings;
public OsmOAuthHelper(@NonNull OsmandApplication app) {
this.app = app;
+ settings = app.getSettings();
authorizationAdapter = new OsmOAuthAuthorizationAdapter(app);
}
@@ -45,6 +49,22 @@ public class OsmOAuthHelper {
authorizationAdapter.authorize(oauthVerifier, this);
}
+ public void resetAuthorization() {
+ if (isValidToken()) {
+ settings.USER_ACCESS_TOKEN.resetToDefault();
+ settings.USER_ACCESS_TOKEN_SECRET.resetToDefault();
+ authorizationAdapter.resetToken();
+ } else if (isLoginExists()) {
+ settings.USER_NAME.resetToDefault();
+ settings.USER_PASSWORD.resetToDefault();
+ }
+ updateAdapter();
+ }
+
+ private boolean isLoginExists() {
+ return !Algorithms.isEmpty(settings.USER_NAME.get()) && !Algorithms.isEmpty(settings.USER_PASSWORD.get());
+ }
+
public void notifyAndRemoveListeners() {
for (OsmAuthorizationListener listener : listeners) {
listener.authorizationCompleted();
@@ -52,6 +72,10 @@ public class OsmOAuthHelper {
listeners.clear();
}
+ public boolean isValidToken() {
+ return authorizationAdapter.isValidToken();
+ }
+
public interface OsmAuthorizationListener {
void authorizationCompleted();
}
diff --git a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleFormatter.java b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleFormatter.java
index 6a340aa528..0c5780bd6a 100644
--- a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleFormatter.java
+++ b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleFormatter.java
@@ -12,7 +12,6 @@ import net.osmand.util.Algorithms;
import java.text.DecimalFormat;
import java.text.MessageFormat;
-import java.util.Map.Entry;
public class SampleFormatter {
public final static float METERS_IN_KILOMETER = 1000f;
@@ -275,10 +274,9 @@ public class SampleFormatter {
return "";
}
MapPoiTypes poiTypes = ctx.getPoiTypes();
- for(Entry e : amenity.getAdditionalInfo().entrySet()) {
- String key = e.getKey();
- String vl = e.getValue();
- if(key.startsWith("name:")) {
+ for (String key : amenity.getAdditionalInfoKeys()) {
+ String vl = amenity.getAdditionalInfo(key);
+ if (key.startsWith("name:")) {
continue;
} else if(vl.length() >= 150) {
if(shortDescription) {
@@ -291,16 +289,15 @@ public class SampleFormatter {
} else if(Amenity.WEBSITE.equals(key)) {
d.append(ctx.getString("website") + ": ");
} else {
- AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(e.getKey());
+ AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(key);
if (pt != null) {
if(pt instanceof PoiType && !((PoiType) pt).isText()) {
vl = pt.getTranslation();
} else {
- vl = pt.getTranslation() + ": " + amenity.unzipContent(e.getValue());
+ vl = pt.getTranslation() + ": " + vl;
}
} else {
- vl = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey()) +
- ": " + amenity.unzipContent(e.getValue());
+ vl = Algorithms.capitalizeFirstLetterAndLowercase(key) + ": " + vl;
}
}
d.append(vl).append('\n');
diff --git a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/builders/AmenityMenuBuilder.java
index 2215c4ad90..5719c097e8 100644
--- a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/builders/AmenityMenuBuilder.java
+++ b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/mapcontextmenu/builders/AmenityMenuBuilder.java
@@ -39,7 +39,6 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
public class AmenityMenuBuilder extends MenuBuilder {
@@ -275,12 +274,11 @@ public class AmenityMenuBuilder extends MenuBuilder {
List infoRows = new LinkedList<>();
List descriptions = new LinkedList<>();
- for (Map.Entry e : amenity.getAdditionalInfo().entrySet()) {
+ for (String key : amenity.getAdditionalInfoKeys()) {
+ String vl = amenity.getAdditionalInfo(key);
int iconId;
Drawable icon = null;
int textColor = 0;
- String key = e.getKey();
- String vl = e.getValue();
String textPrefix = "";
View collapsableView = null;
@@ -357,7 +355,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
} else if (Amenity.CUISINE.equals(key)) {
iconId = OsmandResources.getDrawableId("ic_action_cuisine");
StringBuilder sb = new StringBuilder();
- for (String c : e.getValue().split(";")) {
+ for (String c : vl.split(";")) {
if (sb.length() > 0) {
sb.append(", ");
} else {
@@ -388,7 +386,6 @@ public class AmenityMenuBuilder extends MenuBuilder {
isText = true;
isDescription = iconId == OsmandResources.getDrawableId("ic_action_note_dark");
textPrefix = pType.getTranslation();
- vl = amenity.unzipContent(e.getValue());
}
if (!isDescription && icon == null) {
icon = getRowIcon(view.getContext(), pType.getIconKeyName());
@@ -400,8 +397,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
iconId = OsmandResources.getDrawableId("ic_action_note_dark");
}
} else {
- textPrefix = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey());
- vl = amenity.unzipContent(e.getValue());
+ textPrefix = Algorithms.capitalizeFirstLetterAndLowercase(vl);
}
}