commit
c1afa86ac7
14 changed files with 256 additions and 236 deletions
49
OsmAnd/AndroidManifest-library.xml
Normal file
49
OsmAnd/AndroidManifest-library.xml
Normal 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>
|
|
@ -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
|
||||
// <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 {
|
||||
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
|
||||
}
|
||||
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 true
|
||||
}
|
||||
|
||||
release {
|
||||
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'
|
||||
}
|
||||
|
|
|
@ -1,25 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/color_white"
|
||||
android:background="?attr/bg_color"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:background="@color/color_white"
|
||||
android:background="?attr/bg_color"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp">
|
||||
android:layout_height="@dimen/toolbar_height">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toolbar_text"
|
||||
android:textSize="20sp"
|
||||
tools:text="demdadao"
|
||||
android:textColor="@color/color_black"
|
||||
android:textSize="@dimen/dialog_header_text_size"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
|
|
43
OsmAnd/res/layout/dialog_button_with_icon.xml
Normal file
43
OsmAnd/res/layout/dialog_button_with_icon.xml
Normal 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>
|
|
@ -249,6 +249,7 @@
|
|||
<dimen name="content_padding">16dp</dimen>
|
||||
<dimen name="content_padding_small">12dp</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="measurement_tool_menu_title_padding_top">13dp</dimen>
|
||||
<dimen name="measurement_tool_menu_title_padding_bottom">5dp</dimen>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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";
|
||||
|
@ -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.<Toolbar>findViewById(R.id.toolbar));
|
||||
if (b != null) {
|
||||
String title = b.getString(KEY_TITLE, "");
|
||||
this.<TextView>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 {
|
||||
|
|
|
@ -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.<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 {
|
||||
public URLSpanNoUnderline(String url) {
|
||||
|
|
|
@ -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());
|
||||
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() {
|
||||
if (getContext() != null) {
|
||||
updateAllSettings();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<OsmAuthorizationListener> 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();
|
||||
}
|
||||
|
|
|
@ -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,9 +274,8 @@ public class SampleFormatter {
|
|||
return "";
|
||||
}
|
||||
MapPoiTypes poiTypes = ctx.getPoiTypes();
|
||||
for(Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) {
|
||||
String key = e.getKey();
|
||||
String vl = e.getValue();
|
||||
for (String key : amenity.getAdditionalInfoKeys()) {
|
||||
String vl = amenity.getAdditionalInfo(key);
|
||||
if (key.startsWith("name:")) {
|
||||
continue;
|
||||
} else if(vl.length() >= 150) {
|
||||
|
@ -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');
|
||||
|
|
|
@ -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<AmenityInfoRow> infoRows = 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;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue