Merge pull request #10267 from osmandapp/master

update test branch
This commit is contained in:
Hardy 2020-11-24 17:10:56 +01:00 committed by GitHub
commit c1afa86ac7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 256 additions and 236 deletions

View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto"
package="net.osmand.plus">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<!-- The next 2 seem necessary only for Android < v4.2 (to initialize BT SCO) -->
<uses-permission android:name="android.permission.BROADCAST_STICKY" android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="18" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-feature android:name="android.hardware.microphone" android:required="false" />
<uses-feature android:name="android.hardware.wifi" android:required="false" />
<uses-feature android:name="android.hardware.location" android:required="false" />
<uses-feature android:name="android.hardware.location.network" android:required="false" />
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
<uses-feature android:name="android.hardware.sensor.light" android:required="false" />
<uses-feature android:name="android.hardware.sensor.compass" android:required="false" />
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="false" />
<uses-feature android:name="android.hardware.sensor.gyroscope" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
<uses-feature android:name="com.sec.feature.spen_usp" android:required="false"/>
<uses-sdk android:targetSdkVersion="26"
tools:overrideLibrary="com.getkeepsafe.taptargetview, studio.carbonylgroup.textfieldboxes, android.support.customtabs"/>
<supports-screens android:resizeable="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true"
android:xlargeScreens="true" android:anyDensity="true" />
</manifest>

View file

@ -1,23 +1,5 @@
//apply plugin: 'com.android.application'
apply plugin: 'com.android.library' 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
// <unzip src="OsmAndCore_android.aar" dest=".">
// <patternset>
// <include name="assets/**/map/fonts/OpenSans/*"/>
// <include name="assets/**/map/fonts/NotoSans/*"/>
// </patternset>
// </unzip>
// Less important
task printc { task printc {
configurations.each { if(it.isCanBeResolved()) println it.name } configurations.each { if(it.isCanBeResolved()) println it.name }
} }
@ -27,67 +9,21 @@ android {
buildToolsVersion "29.0.3" buildToolsVersion "29.0.3"
// compileNdkVersion "android-ndk-r17b" // 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 { defaultConfig {
minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() : 15 minSdkVersion 15
targetSdkVersion 29 targetSdkVersion 29
versionCode 390
versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode
multiDexEnabled true 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 plugins automatic rasterization of vectors
// vectorDrawables.generatedDensities = ['hdpi']
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
} }
lintOptions { lintOptions {
lintConfig file("lint.xml")
abortOnError false 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 { aaptOptions {
// Don't compress any embedded resources // Don't compress any embedded resources
noCompress "qz" noCompress "qz"
cruncherEnabled = false cruncherEnabled = false
// Flag notifies aapt to keep the attribute IDs around
// additionalParameters "--no-version-vectors"
} }
dexOptions { dexOptions {
@ -96,7 +32,7 @@ android {
sourceSets { sourceSets {
main { main {
manifest.srcFile "AndroidManifest.xml" manifest.srcFile "AndroidManifest-library.xml"
jni.srcDirs = [] jni.srcDirs = []
jniLibs.srcDirs = ["libs"] jniLibs.srcDirs = ["libs"]
aidl.srcDirs = ["src"] aidl.srcDirs = ["src"]
@ -107,25 +43,8 @@ android {
assets.srcDirs = ["assets"] assets.srcDirs = ["assets"]
} }
debug { 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 { legacy {
jniLibs.srcDirs = ["libc++"] 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 // CoreVersion
// Build that doesn't include 3D OpenGL // Build that doesn't include 3D OpenGL
legacy { legacy {
dimension "coreversion" dimension "coreversion"
} }
// Build that includes 3D OpenGL release
qtcore {
dimension "coreversion"
}
// Build that includes 3D OpenGL debug
qtcoredebug {
dimension "coreversion"
}
} }
buildTypes { buildTypes {
debug { debug {
buildConfigField "String", "OPR_BASE_URL", "\"https://test.openplacereviews.org/\"" debuggable true
buildConfigField "String", "OSM_OAUTH_CONSUMER_KEY", "\"Ti2qq3fo4i4Wmuox3SiWRIGq3obZisBHnxmcM05y\""
buildConfigField "String", "OSM_OAUTH_CONSUMER_SECRET", "\"lxulb3HYoMmd2cC4xxNe1dyfRMAY8dS0eNihJ0DM\""
signingConfig signingConfigs.development
}
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
}
} }
release {
debuggable false
}
}
} }
def replaceNoTranslate(line) { def replaceNoTranslate(line) {
if (line.contains("\"app_name\"") && System.getenv("TARGET_APP_NAME")) { if (line.contains("\"versionFeatures\"")) {
return line.replaceAll(">[^<]*<", ">" + System.getenv("TARGET_APP_NAME") + "<") return line.replaceAll(">[^<]*<", ">" + "" + "<")
}
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") + "<")
} }
return line; return line;
} }
@ -402,6 +278,8 @@ task collectExternalResources {
// Legacy core build // Legacy core build
import org.apache.tools.ant.taskdefs.condition.Os import org.apache.tools.ant.taskdefs.condition.Os
import java.util.regex.Pattern
task buildOsmAndCore(type: Exec) { task buildOsmAndCore(type: Exec) {
Gradle gradle = getGradle() Gradle gradle = getGradle()
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString().toLowerCase() String tskReqStr = gradle.getStartParameter().getTaskRequests().toString().toLowerCase()
@ -452,11 +330,6 @@ afterEvaluate {
android.libraryVariants.all { variant -> android.libraryVariants.all { variant ->
variant.javaCompiler.dependsOn(collectExternalResources, buildOsmAndCore, cleanupDuplicatesInCore) 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) { 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' // 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 { dependencies {
implementation project(path: ':OsmAnd-java', configuration: 'android') implementation project(path: ':OsmAnd-java', configuration: 'android')
implementation project(':OsmAnd-api') implementation project(':OsmAnd-api')
@ -497,14 +391,14 @@ dependencies {
// implementation 'com.ibm.icu:icu4j:50.1' // implementation 'com.ibm.icu:icu4j:50.1'
// implementation 'net.sf.trove4j:trove4j:3.0.3' // implementation 'net.sf.trove4j:trove4j:3.0.3'
qtcoreImplementation 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') // qtcoredebugImplementation fileTree(include: ['QtAndroid.jar', 'QtAndroidBearer.jar'], dir: 'libs')
legacyImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar" legacyImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar"
qtcoredebugImplementation "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar" // qtcoredebugImplementation "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar"
qtcoredebugImplementation "net.osmand:OsmAndCore_android: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_androidNativeRelease:0.1-SNAPSHOT@aar"
qtcoreImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar" // qtcoreImplementation "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
implementation ("com.getkeepsafe.taptargetview:taptargetview:1.12.0"){ implementation ("com.getkeepsafe.taptargetview:taptargetview:1.12.0"){
exclude group: 'com.android.support' exclude group: 'com.android.support'
} }
@ -517,5 +411,5 @@ dependencies {
} }
implementation 'com.jaredrummler:colorpicker:1.1.0' implementation 'com.jaredrummler:colorpicker:1.1.0'
//freehuaweiImplementation 'com.huawei.hms:iap:5.0.2.300' implementation 'org.bouncycastle:bcpkix-jdk15on:1.56'
} }

View file

@ -1,25 +1,23 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:orientation="vertical"
android:background="@color/color_white" android:background="?attr/bg_color"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:background="@color/color_white" android:background="?attr/bg_color"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp"> android:layout_height="@dimen/toolbar_height">
<TextView <TextView
android:id="@+id/toolbar_text" android:id="@+id/toolbar_text"
android:textSize="20sp" android:textSize="@dimen/dialog_header_text_size"
tools:text="demdadao" android:textColor="?android:textColorPrimary"
android:textColor="@color/color_black"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="@dimen/dialog_button_height"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginBottom="@dimen/content_padding_small"
tools:ignore="UselessParent">
<FrameLayout
android:id="@+id/button_container"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:duplicateParentState="true"
tools:ignore="UselessParent">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/button_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingLeft="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding"
android:gravity="center"
android:layout_gravity="center"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
android:duplicateParentState="true"
android:drawablePadding="@dimen/content_padding_small_half"
tools:text="Button"
android:paddingStart="@dimen/content_padding_half"
android:paddingEnd="@dimen/content_padding" />
</FrameLayout>
</FrameLayout>
</FrameLayout>

View file

@ -249,6 +249,7 @@
<dimen name="content_padding">16dp</dimen> <dimen name="content_padding">16dp</dimen>
<dimen name="content_padding_small">12dp</dimen> <dimen name="content_padding_small">12dp</dimen>
<dimen name="content_padding_half">8dp</dimen> <dimen name="content_padding_half">8dp</dimen>
<dimen name="content_padding_small_half">6dp</dimen>
<dimen name="bottom_sheet_content_padding_small">8dp</dimen> <dimen name="bottom_sheet_content_padding_small">8dp</dimen>
<dimen name="measurement_tool_menu_title_padding_top">13dp</dimen> <dimen name="measurement_tool_menu_title_padding_top">13dp</dimen>
<dimen name="measurement_tool_menu_title_padding_bottom">5dp</dimen> <dimen name="measurement_tool_menu_title_padding_bottom">5dp</dimen>

View file

@ -140,4 +140,13 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
public DashFragmentData getCardFragment() { public DashFragmentData getCardFragment() {
return DashSimulateFragment.FRAGMENT_DATA; 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);
}
} }

View file

@ -10,7 +10,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.GradientDrawable;
import android.net.Uri; import android.net.Uri;
@ -368,34 +367,17 @@ public class MenuBuilder {
} }
} }
private View createAddPhotoButton(Context context) { private View createAddPhotoButton(Context ctx) {
TextView b = new TextView(context); View view = UiUtilities.getInflater(ctx, !light).inflate(R.layout.dialog_button_with_icon, null);
b.setOnClickListener(new OnClickListener() { 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 @Override
public void onClick(View view) { 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) { if (false) {
AddPhotosBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager()); AddPhotosBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
} else { } else {
@ -429,10 +411,9 @@ public class MenuBuilder {
} }
} }
}); });
//TODO feature under development //TODO This feature is under development
b.setVisibility(View.GONE); view.setVisibility(View.VISIBLE);
b.setTextColor(ContextCompat.getColor(context, R.color.preference_category_title)); return view;
return b;
} }
private void buildCoordinatesRow(View view) { private void buildCoordinatesRow(View view) {

View file

@ -16,6 +16,7 @@ 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.DialogButtonType; import net.osmand.plus.UiUtilities.DialogButtonType;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.osmedit.oauth.OsmOAuthHelper; import net.osmand.plus.osmedit.oauth.OsmOAuthHelper;
@ -90,7 +91,7 @@ public class LoginBottomSheetFragment extends MenuBottomSheetDialogFragment impl
View view = getView(); View view = getView();
if (view != null) { if (view != null) {
Fragment fragment = getTargetFragment(); Fragment fragment = getTargetFragment();
if (fragment instanceof OsmAuthorizationListener) { if (!(getActivity() instanceof MapActivity) && fragment instanceof OsmAuthorizationListener) {
osmOAuthHelper.addListener((OsmAuthorizationListener) fragment); osmOAuthHelper.addListener((OsmAuthorizationListener) fragment);
} }
osmOAuthHelper.startOAuth((ViewGroup) view); osmOAuthHelper.startOAuth((ViewGroup) view);

View file

@ -3,8 +3,10 @@ package net.osmand.plus.openplacereviews;
import android.content.Context; import android.content.Context;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.view.View;
import android.webkit.CookieManager; import android.webkit.CookieManager;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
@ -14,8 +16,10 @@ import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandActionBarActivity; import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.settings.backend.OsmandSettings;
public class OPRWebviewActivity extends OsmandActionBarActivity { public class OPRWebviewActivity extends OsmandActionBarActivity {
public static final String KEY_LOGIN = "LOGIN_KEY"; public static final String KEY_LOGIN = "LOGIN_KEY";
@ -44,24 +48,39 @@ public class OPRWebviewActivity extends OsmandActionBarActivity {
} }
public void onCreate(Bundle savedInstanceState) { 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); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_opr_webview); setContentView(R.layout.activity_opr_webview);
Bundle b = getIntent().getExtras(); Bundle bundle = getIntent().getExtras();
setSupportActionBar(this.<Toolbar>findViewById(R.id.toolbar)); Toolbar toolbar = findViewById(R.id.toolbar);
if (b != null) { if (bundle != null) {
String title = b.getString(KEY_TITLE, ""); TextView titleView = findViewById(R.id.toolbar_text);
this.<TextView>findViewById(R.id.toolbar_text).setText(title); String title = bundle.getString(KEY_TITLE, "");
titleView.setText(title);
} }
getSupportActionBar().setDisplayHomeAsUpEnabled(true); toolbar.setBackgroundDrawable(new ColorDrawable(AndroidUtils.getColorFromAttr(this, R.attr.bg_color)));
final Drawable upArrow = getMyApplication().getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(this)); final Drawable upArrow = app.getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(this));
upArrow.setColorFilter(ContextCompat.getColor(this, R.color.color_favorite_gray), PorterDuff.Mode.SRC_ATOP); upArrow.setColorFilter(ContextCompat.getColor(this, R.color.color_favorite_gray), PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(upArrow); toolbar.setNavigationIcon(upArrow);
webView = (WebView) findViewById(R.id.printDialogWebview); 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.setWebViewClient(new CloseOnSuccessWebViewClient());
webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setJavaScriptEnabled(true);
WebView.setWebContentsDebuggingEnabled(true); WebView.setWebContentsDebuggingEnabled(true);
if (b != null) { if (bundle != null) {
isLogin = b.getBoolean(KEY_LOGIN); isLogin = bundle.getBoolean(KEY_LOGIN);
if (isLogin) { if (isLogin) {
webView.loadUrl(getLoginUrl(this)); webView.loadUrl(getLoginUrl(this));
} else { } else {

View file

@ -2,6 +2,7 @@ package net.osmand.plus.openplacereviews;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.Spanned; import android.text.Spanned;
@ -26,11 +27,13 @@ public class OprStartFragment extends BaseOsmAndFragment {
private static final String TAG = OprStartFragment.class.getSimpleName(); private static final String TAG = OprStartFragment.class.getSimpleName();
private static final Log LOG = PlatformUtil.getLog(OprStartFragment.class); private static final Log LOG = PlatformUtil.getLog(OprStartFragment.class);
private static final String openPlaceReviewsUrl = "OpenPlaceReviews.org"; private static final String openPlaceReviewsUrl = "OpenPlaceReviews.org";
private boolean nightMode;
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls(); nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
View v = inflater.inflate(R.layout.fragment_opr_login, container, false); View v = UiUtilities.getInflater(requireMyActivity(), nightMode).inflate(R.layout.fragment_opr_login, container,
false);
View createAccount = v.findViewById(R.id.register_opr_create_account); View createAccount = v.findViewById(R.id.register_opr_create_account);
v.findViewById(R.id.back_button).setOnClickListener(new View.OnClickListener() { v.findViewById(R.id.back_button).setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -77,6 +80,14 @@ public class OprStartFragment extends BaseOsmAndFragment {
v.<TextView>findViewById(R.id.start_opr_description).setMovementMethod(LinkMovementMethod.getInstance()); v.<TextView>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 { private class URLSpanNoUnderline extends URLSpan {
public URLSpanNoUnderline(String url) { public URLSpanNoUnderline(String url) {

View file

@ -15,13 +15,14 @@ import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder; import androidx.preference.PreferenceViewHolder;
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.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.FontCache; import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.measurementtool.LoginBottomSheetFragment; import net.osmand.plus.measurementtool.LoginBottomSheetFragment;
import net.osmand.plus.osmedit.ValidateOsmLoginDetailsTask.ValidateOsmLoginListener; 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.osmedit.oauth.OsmOAuthHelper.OsmAuthorizationListener;
import net.osmand.plus.settings.backend.OsmAndAppCustomization; import net.osmand.plus.settings.backend.OsmAndAppCustomization;
import net.osmand.plus.settings.fragments.BaseSettingsFragment; 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"; public static final String OSM_LOGIN_DATA = "osm_login_data";
private static final String OSM_EDITING_INFO = "osm_editing_info"; private static final String OSM_EDITING_INFO = "osm_editing_info";
private OsmOAuthAuthorizationAdapter authorizationAdapter; private OsmOAuthHelper authHelper;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
authorizationAdapter = app.getOsmOAuthHelper().getAuthorizationAdapter(); authHelper = app.getOsmOAuthHelper();
FragmentActivity activity = requireMyActivity(); FragmentActivity activity = requireMyActivity();
activity.getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) { activity.getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@ -121,7 +122,7 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer
} }
private boolean isValidToken() { private boolean isValidToken() {
return authorizationAdapter.isValidToken(); return authHelper.isValidToken();
} }
private boolean isLoginExists() { private boolean isLoginExists() {
@ -139,10 +140,14 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer
} }
private void setupUseDevUrlPref() { private void setupUseDevUrlPref() {
Drawable icon = getPersistentPrefIcon(R.drawable.ic_action_laptop);
SwitchPreferenceEx useDevUrlPref = findPreference(settings.USE_DEV_URL.getId()); SwitchPreferenceEx useDevUrlPref = findPreference(settings.USE_DEV_URL.getId());
if (OsmandPlugin.isDevelopment()) {
Drawable icon = getPersistentPrefIcon(R.drawable.ic_action_laptop);
useDevUrlPref.setDescription(getString(R.string.use_dev_url_descr)); useDevUrlPref.setDescription(getString(R.string.use_dev_url_descr));
useDevUrlPref.setIcon(icon); useDevUrlPref.setIcon(icon);
} else {
useDevUrlPref.setVisible(false);
}
} }
private void setupOsmEditsDescrPref() { 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) { if (settings.USE_DEV_URL.getId().equals(prefId) && newValue instanceof Boolean) {
settings.USE_DEV_URL.set((Boolean) newValue); settings.USE_DEV_URL.set((Boolean) newValue);
osmLogout(); osmLogout();
authorizationAdapter = app.getOsmOAuthHelper().updateAdapter();
return true; return true;
} }
return super.onPreferenceChange(preference, newValue); return super.onPreferenceChange(preference, newValue);
@ -206,33 +210,26 @@ public class OsmEditingFragment extends BaseSettingsFragment implements OnPrefer
return super.onPreferenceClick(preference); return super.onPreferenceClick(preference);
} }
private void osmLogout() { public void osmLogout() {
boolean validToken = isValidToken(); if (authHelper.isValidToken() || isLoginExists()) {
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();
}
app.showShortToastMessage(R.string.osm_edit_logout_success); app.showShortToastMessage(R.string.osm_edit_logout_success);
updateAllSettings();
} }
authHelper.resetAuthorization();
updateAllSettings();
} }
@Override @Override
public void onPreferenceChanged(String prefId) { public void onPreferenceChanged(String prefId) {
if (settings.USE_DEV_URL.getId().equals(prefId)) { if (settings.USE_DEV_URL.getId().equals(prefId)) {
osmLogout(); osmLogout();
authorizationAdapter = app.getOsmOAuthHelper().updateAdapter();
} }
updateAllSettings(); updateAllSettings();
} }
@Override @Override
public void authorizationCompleted() { public void authorizationCompleted() {
if (getContext() != null) {
updateAllSettings(); updateAllSettings();
} }
} }
}

View file

@ -5,6 +5,8 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.util.Algorithms;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -14,9 +16,11 @@ public class OsmOAuthHelper {
private final OsmandApplication app; private final OsmandApplication app;
private OsmOAuthAuthorizationAdapter authorizationAdapter; private OsmOAuthAuthorizationAdapter authorizationAdapter;
private final Set<OsmAuthorizationListener> listeners = new HashSet<>(); private final Set<OsmAuthorizationListener> listeners = new HashSet<>();
private final OsmandSettings settings;
public OsmOAuthHelper(@NonNull OsmandApplication app) { public OsmOAuthHelper(@NonNull OsmandApplication app) {
this.app = app; this.app = app;
settings = app.getSettings();
authorizationAdapter = new OsmOAuthAuthorizationAdapter(app); authorizationAdapter = new OsmOAuthAuthorizationAdapter(app);
} }
@ -45,6 +49,22 @@ public class OsmOAuthHelper {
authorizationAdapter.authorize(oauthVerifier, this); 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() { public void notifyAndRemoveListeners() {
for (OsmAuthorizationListener listener : listeners) { for (OsmAuthorizationListener listener : listeners) {
listener.authorizationCompleted(); listener.authorizationCompleted();
@ -52,6 +72,10 @@ public class OsmOAuthHelper {
listeners.clear(); listeners.clear();
} }
public boolean isValidToken() {
return authorizationAdapter.isValidToken();
}
public interface OsmAuthorizationListener { public interface OsmAuthorizationListener {
void authorizationCompleted(); void authorizationCompleted();
} }

View file

@ -12,7 +12,6 @@ import net.osmand.util.Algorithms;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Map.Entry;
public class SampleFormatter { public class SampleFormatter {
public final static float METERS_IN_KILOMETER = 1000f; public final static float METERS_IN_KILOMETER = 1000f;
@ -275,9 +274,8 @@ public class SampleFormatter {
return ""; return "";
} }
MapPoiTypes poiTypes = ctx.getPoiTypes(); MapPoiTypes poiTypes = ctx.getPoiTypes();
for(Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) { for (String key : amenity.getAdditionalInfoKeys()) {
String key = e.getKey(); String vl = amenity.getAdditionalInfo(key);
String vl = e.getValue();
if (key.startsWith("name:")) { if (key.startsWith("name:")) {
continue; continue;
} else if(vl.length() >= 150) { } else if(vl.length() >= 150) {
@ -291,16 +289,15 @@ public class SampleFormatter {
} else if(Amenity.WEBSITE.equals(key)) { } else if(Amenity.WEBSITE.equals(key)) {
d.append(ctx.getString("website") + ": "); d.append(ctx.getString("website") + ": ");
} else { } else {
AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(e.getKey()); AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(key);
if (pt != null) { if (pt != null) {
if(pt instanceof PoiType && !((PoiType) pt).isText()) { if(pt instanceof PoiType && !((PoiType) pt).isText()) {
vl = pt.getTranslation(); vl = pt.getTranslation();
} else { } else {
vl = pt.getTranslation() + ": " + amenity.unzipContent(e.getValue()); vl = pt.getTranslation() + ": " + vl;
} }
} else { } else {
vl = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey()) + vl = Algorithms.capitalizeFirstLetterAndLowercase(key) + ": " + vl;
": " + amenity.unzipContent(e.getValue());
} }
} }
d.append(vl).append('\n'); d.append(vl).append('\n');

View file

@ -39,7 +39,6 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
public class AmenityMenuBuilder extends MenuBuilder { public class AmenityMenuBuilder extends MenuBuilder {
@ -275,12 +274,11 @@ public class AmenityMenuBuilder extends MenuBuilder {
List<AmenityInfoRow> infoRows = new LinkedList<>(); List<AmenityInfoRow> infoRows = new LinkedList<>();
List<AmenityInfoRow> descriptions = new LinkedList<>(); List<AmenityInfoRow> descriptions = new LinkedList<>();
for (Map.Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) { for (String key : amenity.getAdditionalInfoKeys()) {
String vl = amenity.getAdditionalInfo(key);
int iconId; int iconId;
Drawable icon = null; Drawable icon = null;
int textColor = 0; int textColor = 0;
String key = e.getKey();
String vl = e.getValue();
String textPrefix = ""; String textPrefix = "";
View collapsableView = null; View collapsableView = null;
@ -357,7 +355,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
} else if (Amenity.CUISINE.equals(key)) { } else if (Amenity.CUISINE.equals(key)) {
iconId = OsmandResources.getDrawableId("ic_action_cuisine"); iconId = OsmandResources.getDrawableId("ic_action_cuisine");
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (String c : e.getValue().split(";")) { for (String c : vl.split(";")) {
if (sb.length() > 0) { if (sb.length() > 0) {
sb.append(", "); sb.append(", ");
} else { } else {
@ -388,7 +386,6 @@ public class AmenityMenuBuilder extends MenuBuilder {
isText = true; isText = true;
isDescription = iconId == OsmandResources.getDrawableId("ic_action_note_dark"); isDescription = iconId == OsmandResources.getDrawableId("ic_action_note_dark");
textPrefix = pType.getTranslation(); textPrefix = pType.getTranslation();
vl = amenity.unzipContent(e.getValue());
} }
if (!isDescription && icon == null) { if (!isDescription && icon == null) {
icon = getRowIcon(view.getContext(), pType.getIconKeyName()); icon = getRowIcon(view.getContext(), pType.getIconKeyName());
@ -400,8 +397,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
iconId = OsmandResources.getDrawableId("ic_action_note_dark"); iconId = OsmandResources.getDrawableId("ic_action_note_dark");
} }
} else { } else {
textPrefix = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey()); textPrefix = Algorithms.capitalizeFirstLetterAndLowercase(vl);
vl = amenity.unzipContent(e.getValue());
} }
} }