Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-03-13 18:21:47 +01:00
commit 43ef5696e2
45 changed files with 1821 additions and 962 deletions

View file

@ -310,6 +310,7 @@ dependencies {
"OsmAndCore_android.jar", "OsmAndCore_android.jar",
"OsmAndCore_wrapper.jar"]) "OsmAndCore_wrapper.jar"])
compile "com.android.support:appcompat-v7:21.0.3" compile "com.android.support:appcompat-v7:21.0.3"
compile "com.github.shell-software:fab:1.0.5"
legacyCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar" legacyCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar"
qtcoredebugCompile "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar" qtcoredebugCompile "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar"
qtcoredebugCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar" qtcoredebugCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"

318
OsmAnd/build.gradle~ Normal file
View file

@ -0,0 +1,318 @@
apply plugin: 'com.android.application'
// Global Paramers accepted
// APK_NUMBER_VERSION - version number of apk
// APK_VERSION - build number like #9999Z, for dev builds appended to app_version like 2.0.0 in no_translate.xml)
// flavor Z : M=-master, D=-design, B=-Blackberry, MD=-main-default, MQA=-main-qt-arm, MQDA=-main-qt-default-arm, S=-sherpafy
// TARGET_APP_NAME - app name
// APP_EDITION - date stamp of builds
// APP_FEATURES - features +play_market +gps_status -parking_plugin -blackberry -free_version -amazon
// TODO
// 1. 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
// 2. fix_apostrophe_issues (replace match="[^=]([^\\])'" replace="\1\\\\'") res/**/strings.xml
// 3. sherpafy/free/paid
// 4. Release signature
// 5. TARGET_APP_NAME, APP_EDITION uses flavor
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
signingConfigs {
development {
storeFile file("../keystores/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
publishing {
storeFile file("osmand_key")
storePassword System.getenv("OSMAND_APK_PASSWORD")
keyAlias "androiddebugkey"
keyPassword System.getenv("OSMAND_APK_PASSWORD")
}
}
defaultConfig {
minSdkVersion 9
targetSdkVersion 21
versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode
//versionName already assigned in code
//versionName System.getenv("APK_VERSION")? System.getenv("APK_VERSION").toString(): versionName
}
lintOptions {
lintConfig file("lint.xml")
abortOnError false
warningsAsErrors false
}
// This is from OsmAndCore_android.aar - for some reason it's not inherited
aaptOptions {
// Don't compress any embedded resources
noCompress "qz"
}
dexOptions {
jumboMode = true
}
sourceSets {
main {
manifest.srcFile "AndroidManifest.xml"
jni.srcDirs = []
jniLibs.srcDirs = ["libs"]
aidl.srcDirs = ["src"]
java.srcDirs = ["src"]
resources.srcDirs = ["src"]
renderscript.srcDirs = ["src"]
res.srcDirs = ["res"]
assets.srcDirs = ["assets"]
}
free {
manifest.srcFile "AndroidManifest-free.xml"
}
legacy {
jniLibs.srcDirs = ["libgnustl"]
}
}
flavorDimensions "version", "coreversion", "abi"
productFlavors {
// ABI
armv7 {
flavorDimension "abi"
ndk {
abiFilter "armeabi-v7a"
}
}
armv5 {
flavorDimension "abi"
ndk {
abiFilter "armeabi"
}
}
x86 {
flavorDimension "abi"
ndk {
abiFilter "x86"
}
}
mips {
flavorDimension "abi"
ndk {
abiFilter "mips"
}
}
fat {
flavorDimension "abi"
}
// Version
free {
flavorDimension "version"
applicationId "net.osmand"
}
full {
flavorDimension "version"
applicationId "net.osmand.plus"
}
// CoreVersion
legacy {
flavorDimension "coreversion"
}
qtcore {
flavorDimension "coreversion"
}
qtcoredebug {
flavorDimension "coreversion"
}
}
buildTypes {
debug {
signingConfig signingConfigs.development
}
release {
signingConfig signingConfigs.publishing
}
}
}
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_edition\"") && System.getenv("APP_EDITION")) {
return line.replaceAll(">[^<]*<", ">" + System.getenv("APP_EDITION") + "<")
}
if (line.contains("\"app_version\"") && System.getenv("APK_VERSION")) {
// appends build number to version number for dev builds
return line.replaceAll("</", System.getenv("APK_VERSION") + "</")
}
if (line.contains("\"versionFeatures\"") && System.getenv("APP_FEATURES")) {
return line.replaceAll(">[^<]*<", ">" + System.getenv("APP_FEATURES") + "<")
}
return line;
}
task updateNoTranslate(type: Copy) {
inputs.property 'appName', System.getenv().get("APP_NAME")
inputs.property 'appEdition', System.getenv().get("APP_EDITION")
inputs.property 'appFeatures', System.getenv().get("APP_FEATURES")
inputs.property 'apkVersion', System.getenv().get("APK_VERSION")
from('.') {
include 'no_translate.xml'
filter {
line -> replaceNoTranslate(line);
}
}
into 'res/values/'
}
task collectVoiceAssets(type: Sync) {
from "../../resources/voice"
into "assets/voice"
include "**/*.p"
}
task collectSpecialPhrasesAssets(type: Sync) {
from "../../resources/specialphrases"
into "assets/specialphrases"
include "*.txt"
}
task collectHelpContentsAssets(type: Sync) {
from "../../help"
into "assets/help"
include "*.html"
include "images/**/*.png"
from "assets/"
into "assets/help"
include "style.css"
}
task collectRoutingResources(type: Sync) {
from "../../resources/routing"
into "src/net/osmand/router"
include "*.xml"
}
task collectMiscResources(type: Copy) {
into "src/net/osmand/osm"
from("../../resources/obf_creation") {
include "rendering_types.xml"
}
from("../../resources/poi") {
include "poi_types.xml"
}
}
task collectRenderingStylesResources(type: Sync) {
from "../../resources/rendering_styles"
into "src/net/osmand/render"
include "*.xml"
}
task collectRegionsInfoResources(type: Copy) {
from "../../resources/countries-info"
into "src/net/osmand/map"
include "regions.ocbf"
}
task copyStyleIcons(type: Copy) {
from "../../resources/rendering_styles/style-icons/"
into "res/"
include "**/*.png"
}
task collectExternalResources << {}
collectExternalResources.dependsOn collectVoiceAssets,
collectSpecialPhrasesAssets,
collectHelpContentsAssets,
collectRoutingResources,
collectRenderingStylesResources,
collectRegionsInfoResources,
collectMiscResources,
copyStyleIcons,
updateNoTranslate
tasks.whenTaskAdded { task ->
if (task.name.startsWith("generate") && task.name.endsWith("Resources")) {
task.dependsOn collectExternalResources
}
}
// Legacy core build
import org.apache.tools.ant.taskdefs.condition.Os
task buildOsmAndCore(type: Exec) {
description "Build Legacy OsmAndCore"
if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine "bash", file("./old-ndk-build.sh").getAbsolutePath()
} else {
commandLine "cmd", "/c", "echo", "Not supported"
}
}
task cleanupDuplicatesInCore() {
dependsOn buildOsmAndCore
// doesn't work for legacy debug builds
doLast {
file("libgnustl/armeabi").mkdirs()
println file("libs/armeabi/libgnustl_shared.so").renameTo(file("libgnustl/armeabi/libgnustl_shared.so"))
file("libgnustl/armeabi-v7a").mkdirs()
println file("libs/armeabi-v7a/libgnustl_shared.so").renameTo(file("libgnustl/armeabi-v7a/libgnustl_shared.so"))
file("libgnustl/mips").mkdirs()
println file("libs/mips/libgnustl_shared.so").renameTo(file("libgnustl/mips/libgnustl_shared.so"))
file("libgnustl/x86").mkdirs()
println file("libs/x86/libgnustl_shared.so").renameTo(file("libgnustl/x86/libgnustl_shared.so"))
}
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn << [buildOsmAndCore, cleanupDuplicatesInCore]
}
repositories {
ivy {
name = "OsmAndBinariesIvy"
url = "http://builder.osmand.net"
layout "pattern", {
artifact "ivy/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
}
}
}
dependencies {
compile project(path: ":OsmAnd-java", configuration: "android")
compile fileTree(
dir: "libs",
include: ["*.jar"],
exclude: [
"QtAndroid-bundled.jar",
"QtAndroidAccessibility-bundled.jar",
"android-support*.jar",
"OsmAndCore_android.jar",
"OsmAndCore_wrapper.jar"])
compile "com.android.support:appcompat-v7:21.0.3"
legacyCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar"
qtcoredebugCompile "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar"
qtcoredebugCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
qtcoreCompile "net.osmand:OsmAndCore_androidNativeRelease:0.1-SNAPSHOT@aar"
qtcoreCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/dashboard_parking_dark_selected" android:state_enabled="false"/>
<item android:drawable="@color/dashboard_parking_dark_selected" android:state_pressed="true"/>
<item android:drawable="@color/dashboard_parking_dark_selected" android:state_focused="true"/>
<item android:drawable="@color/dashboard_parking_dark_color"/>
</selector>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@color/parking_card_selected" />
<item android:state_pressed="true" android:drawable="@color/parking_card_selected" />
<item android:state_focused="true" android:drawable="@color/parking_card_selected" />
<item android:drawable="@color/dashboard_blue" />
</selector>

View file

@ -1,91 +1,94 @@
<?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"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="5dp" android:orientation="vertical">
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" > android:background="?attr/osmo_header_background"
android:minHeight="@dimen/osmo_header_height"
android:orientation="horizontal"
android:paddingLeft="@dimen/dashboard_parking_left_margin"
android:paddingRight="@dimen/dashboard_parking_left_margin">
<ImageView <ImageView
android:id="@+id/osmo_status" android:id="@+id/osmo_status"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:paddingLeft="4dp" android:paddingLeft="4dp"
android:paddingRight="4dp" android:paddingRight="4dp"
android:src="@drawable/mon_osmo_conn_small" /> android:src="@drawable/mon_osmo_conn_small"/>
<Switch <Switch
android:id="@+id/enable_service" android:id="@+id/enable_service"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:focusable="false" android:layout_gravity="center_vertical"
android:gravity="center_vertical" android:focusable="false"
android:text="@string/osmo_start_service" /> android:textColor="@color/color_white"
</LinearLayout> android:text="@string/osmo_start_service"/>
</LinearLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/osmo_log_off_layout" android:id="@+id/osmo_log_off_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginLeft="@dimen/dashboard_parking_left_margin"
android:layout_marginTop="3dp" > android:layout_marginRight="@dimen/dashboard_parking_left_margin"
android:minHeight="@dimen/osmo_header_height">
<TextView <TextView
android:id="@+id/osmo_user_name_text_view" android:id="@+id/osmo_user_name_text_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:text="@string/anonymous_user" android:text="@string/anonymous_user"
android:textAppearance="?android:attr/textAppearance" /> android:textAppearance="?android:attr/textAppearance"/>
<Switch <Switch
android:id="@+id/osmo_login_logoff" android:id="@+id/osmo_login_logoff"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:focusable="false" android:focusable="false"
android:gravity="center_vertical" /> android:gravity="center_vertical"/>
<Button <Button
android:id="@+id/osmo_login_hint_button" android:id="@+id/osmo_login_hint_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_toRightOf="@id/osmo_user_name_text_view" android:layout_toRightOf="@id/osmo_user_name_text_view"
android:minHeight="0dp" android:minHeight="0dp"
android:minWidth="0dp" android:minWidth="0dp"
android:text="\?" android:text="\?"
android:textAppearance="?android:attr/textAppearance" /> android:textAppearance="?android:attr/textAppearance"/>
</RelativeLayout>
<Switch </RelativeLayout>
android:id="@+id/enable_tracker"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:layout_marginLeft="3dp"
android:layout_marginTop="3dp"
android:gravity="center_vertical"
android:text="@string/osmo_enable_tracker" />
<TextView <Switch
android:id="@+id/motd" android:id="@+id/enable_tracker"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dip" android:layout_marginLeft="@dimen/dashboard_parking_left_margin"
android:autoLink="web" android:layout_marginRight="@dimen/dashboard_parking_left_margin"
android:gravity="center" android:focusable="false"
android:textSize="18sp" /> android:gravity="center_vertical"
android:minHeight="@dimen/osmo_header_height"
android:text="@string/osmo_enable_tracker"/>
<TextView
android:id="@+id/motd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dip"
android:autoLink="web"
android:gravity="center"
android:textSize="18sp"/>
</LinearLayout> </LinearLayout>

View file

@ -1,77 +1,111 @@
<?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"
android:orientation="vertical"
android:background="?attr/card_bg"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
<LinearLayout android:id="@+id/header_layout" android:background="?attr/card_bg"
android:orientation="horizontal" android:orientation="vertical">
android:layout_width="fill_parent"
android:layout_height="@dimen/dashHeaderHeight"> <LinearLayout
<TextView android:id="@+id/osmo_text" android:id="@+id/header_layout"
android:text="@string/map_widget_av_notes" android:layout_width="fill_parent"
style="?attr/dashboardSubHeaderStyle"/> android:layout_height="@dimen/dashHeaderHeight"
<Button android:id="@+id/manage" android:orientation="horizontal">
android:text="@string/shared_string_show_all"
style="?attr/dashboardGeneralButtonStyle"/> <TextView
android:id="@+id/osmo_text"
style="?attr/dashboardSubHeaderStyle"
android:text="@string/osmo"/>
<ProgressBar
android:id="@+id/progress"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"/>
<Button
android:id="@+id/manage"
style="?attr/dashboardGeneralButtonStyle"
android:text="@string/osm_editing_manage"/>
</LinearLayout> </LinearLayout>
<LinearLayout android:orientation="vertical" <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
<LinearLayout android:orientation="horizontal" android:orientation="vertical">
android:layout_width="fill_parent"
android:layout_height="@dimen/dashHeaderHeight"> <LinearLayout
<TextView android:text="@string/shared_string_my_location" android:layout_width="fill_parent"
style="?attr/dashboardSubHeaderStyle" android:layout_height="@dimen/dashHeaderHeight"
android:layout_weight="1"/> android:orientation="horizontal">
<Button android:id="@+id/share"
android:text="@string/shared_string_show_all" <TextView
style="?attr/dashboardGeneralButtonStyle"/> style="?attr/dashboardSubHeaderStyle"
<include layout="@layout/check_item_rel" /> android:layout_weight="1"
android:text="@string/shared_string_my_location"/>
<ImageButton
android:id="@+id/share"
style="?attr/dashboardGeneralButtonStyle"
android:text="@string/shared_string_show_all"/>
<include layout="@layout/check_item_rel"/>
</LinearLayout> </LinearLayout>
<View <View
android:background="?attr/dashboard_divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp"/> android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout android:orientation="horizontal" <LinearLayout
android:layout_width="match_parent" android:visibility="gone"
android:layout_height="wrap_content"> android:layout_width="match_parent"
<ImageView android:id="@+id/points_icon" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/subHeaderMarginLeft" android:orientation="horizontal">
android:src="@drawable/ic_small_point"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/points_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView android:id="@+id/distance_icon" <ImageView
android:src="@drawable/ic_small_distance" android:id="@+id/points_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"
<TextView android:id="@+id/distance" android:layout_marginLeft="@dimen/subHeaderMarginLeft"
android:layout_width="wrap_content" android:src="@drawable/ic_small_point"/>
android:layout_height="wrap_content"/>
<ImageView android:id="@+id/time_icon" <TextView
android:src="@drawable/ic_small_time" android:id="@+id/points_count"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
<TextView android:id="@+id/time"
android:layout_width="wrap_content" <ImageView
android:layout_height="wrap_content" android:id="@+id/distance_icon"
android:layout_marginRight="@dimen/showAllButtonMarginRight"/> android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_small_distance"/>
<TextView
android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView
android:id="@+id/time_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_small_time"/>
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/showAllButtonMarginRight"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout android:orientation="vertical" <LinearLayout
android:id="@+id/items" android:id="@+id/items"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"
android:orientation="vertical"/>
</LinearLayout> </LinearLayout>

View file

@ -7,6 +7,7 @@
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/parking_header"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dash_parking_height" android:layout_height="@dimen/dash_parking_height"
android:background="?attr/dash_parking_bg" android:background="?attr/dash_parking_bg"
@ -62,6 +63,7 @@
<TextView <TextView
android:id="@+id/left_lbl" android:id="@+id/left_lbl"
android:layout_gravity="right"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/osmand_parking_time_left" android:text="@string/osmand_parking_time_left"

View file

@ -1,101 +1,96 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent"
android:paddingBottom="@dimen/dialog_content_bottom_margin"
android:paddingLeft="@dimen/dialog_content_margin"
android:paddingRight="@dimen/dialog_content_margin"
android:paddingTop="@dimen/dialog_content_bottom_margin">
<TableLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="7dp" android:orientation="vertical"
android:paddingRight="7dp" android:paddingLeft="7dp"
android:stretchColumns="1"> android:paddingRight="7dp"
android:stretchColumns="1">
<TableRow> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/osmo_group_name"/>
<TextView <EditText
android:paddingLeft="3dp" android:id="@+id/Name"
android:layout_span="2" android:layout_width="fill_parent"
android:layout_width="wrap_content" android:layout_height="wrap_content"/>
android:layout_height="wrap_content"
android:id="@+id/osmo_group_create_info"
android:textSize="18sp"
android:drawableRight="@drawable/ic_action_info_dark"
android:text="@string/osmo_group_information" />
</TableRow>
<TableRow>
<TextView
android:paddingLeft="3dp"
android:id="@+id/osmo_group_create_dinfo"
android:textSize="16sp"
android:layout_span="2"
android:minLines="3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/osmo_group_information_desc"
android:animateLayoutChanges="true"
android:visibility="gone" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/osmo_group_name" />
<EditText
android:id="@+id/Name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="3dp" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/osmo_group_description" />
<EditText
android:id="@+id/Description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:lines="3"
android:paddingLeft="3dp" />
</TableRow>
<TableRow> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/osmo_group_description"/>
<TextView <EditText
android:layout_width="wrap_content" android:id="@+id/Description"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:text="@string/osmo_group_by_invite" /> android:layout_height="wrap_content"/>
<CheckBox <TextView
android:id="@+id/OnlyByInvite" android:layout_width="wrap_content"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:text="@string/osmo_group_policy"/>
android:paddingLeft="3dp" />
</TableRow>
<TableRow> <EditText
android:id="@+id/Policy"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/osmo_group_policy" /> android:orientation="horizontal">
<EditText <TextView
android:id="@+id/Policy" android:layout_width="wrap_content"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:text="@string/osmo_group_by_invite"/>
android:lines="2"
android:paddingLeft="3dp" /> <CheckBox
</TableRow> android:id="@+id/OnlyByInvite"
</TableLayout> android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/osmo_group_create_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/osmo_group_information"
android:textSize="18sp"/>
<ImageButton
android:id="@+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/options_button_background"
android:src="@drawable/ic_action_info_dark"/>
</LinearLayout>
<TextView
android:id="@+id/osmo_group_create_dinfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/osmo_group_information_desc"
android:textSize="16sp"
android:visibility="gone"/>
</LinearLayout>
</ScrollView> </ScrollView>

View file

@ -2,8 +2,10 @@
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="7dp" android:paddingBottom="@dimen/dialog_content_bottom_margin"
android:paddingRight="7dp" android:paddingTop="@dimen/dialog_content_bottom_margin"
android:paddingLeft="@dimen/dialog_content_margin"
android:paddingRight="@dimen/dialog_content_margin"
android:stretchColumns="1"> android:stretchColumns="1">
<TableRow> <TableRow>

View file

@ -1,37 +1,36 @@
<?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" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/expandable_category_color" android:paddingBottom="5dp"
android:paddingBottom="5dp" android:paddingLeft="3dp"
android:paddingLeft="3dp" android:paddingRight="4dp"
android:paddingRight="4dp" android:paddingTop="5dp">
android:paddingTop="5dp">
<ImageView <ImageView
android:id="@+id/explist_indicator" android:id="@+id/explist_indicator"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:paddingLeft="6dp" android:paddingLeft="6dp"
android:src="@drawable/expandable_category_unpushed" /> android:src="@drawable/expandable_category_unpushed"/>
<TextView <TextView
android:id="@+id/category_name" android:id="@+id/category_name"
style="@style/ListText" style="@style/ListText"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:textColor="?android:textColorPrimary" android:layout_marginLeft="8dp"
android:layout_marginLeft="8dp" android:layout_marginTop="0dp"
android:layout_weight="1"
android:maxLines="1" android:maxLines="1"
tools:text="@string/lorem_ipsum" android:textColor="?android:textColorPrimary"
android:layout_marginTop="0dp" android:textSize="18sp"
android:layout_weight="1" tools:text="@string/lorem_ipsum"/>
android:textSize="18sp" />
<include layout="@layout/check_item_rel" /> <include layout="@layout/check_item_rel"/>
<ImageView <ImageView

View file

@ -25,4 +25,10 @@
android:layout_weight="1" android:layout_weight="1"
android:groupIndicator="@android:color/transparent"/> android:groupIndicator="@android:color/transparent"/>
<net.osmand.plus.activities.search.toolbar.SplitToolbar
android:id="@+id/bottomControls"
android:background="?attr/bottomToolBarColor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout> </LinearLayout>

View file

@ -1,36 +1,40 @@
<?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"
android:layout_width="fill_parent" xmlns:tools="http://schemas.android.com/tools"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:orientation="horizontal" android:layout_height="wrap_content"
android:paddingBottom="5dp" android:background="?attr/expandable_list_item_background"
android:paddingLeft="8dp" android:orientation="horizontal"
android:paddingRight="4dp" android:paddingBottom="5dp"
android:paddingTop="5dp"> android:paddingLeft="8dp"
android:paddingRight="4dp"
android:paddingTop="5dp">
<ImageView <ImageView
android:id="@+id/osmo_user_icon" android:id="@+id/osmo_user_icon"
android:layout_width="26dp" android:layout_width="26dp"
android:layout_height="26dp" android:layout_height="26dp"
android:paddingRight="2dp" android:paddingRight="2dp"
android:paddingTop="2dp" /> android:paddingTop="2dp"/>
<TextView <TextView
android:id="@+id/osmo_label" android:id="@+id/osmo_label"
style="@style/ListText" style="@style/ListText"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:maxLines="7" android:layout_weight="1"
android:layout_weight="1" /> android:maxLines="7"
tools:text="@string/abc_action_bar_home_description"
android:textColor="?android:textColorPrimary"/>
<TextView <TextView
android:id="@+id/osmo_label_time" android:id="@+id/osmo_label_time"
style="@style/ListText.Small" style="@style/ListText.Small"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" /> android:layout_marginLeft="3dp"/>
<!-- <include layout="@layout/check_item" /> --> <!-- <include layout="@layout/check_item" /> -->
</LinearLayout> </LinearLayout>

View file

@ -1,91 +1,95 @@
<?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"
android:layout_width="fill_parent" xmlns:tools="http://schemas.android.com/tools"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:layout_marginBottom="5dp" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:orientation="vertical">
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:background="?attr/osmo_header_background"
android:minHeight="@dimen/osmo_header_height"
android:orientation="horizontal"
android:paddingLeft="@dimen/dashboard_parking_left_margin"
android:paddingRight="@dimen/dashboard_parking_left_margin">
<ImageView <ImageView
android:id="@+id/osmo_status" android:id="@+id/osmo_status"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:paddingLeft="4dp" android:paddingLeft="4dp"
android:paddingRight="4dp" android:paddingRight="4dp"
android:src="@drawable/mon_osmo_conn_small" /> android:src="@drawable/mon_osmo_conn_small"/>
<CheckBox <CheckBox
android:id="@+id/enable_service" android:id="@+id/enable_service"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:focusable="false" android:layout_gravity="center_vertical"
android:gravity="center_vertical" android:focusable="false"
android:text="@string/osmo_start_service" /> android:textColor="@color/color_white"
</LinearLayout> android:text="@string/osmo_start_service"/>
</LinearLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/osmo_log_off_layout" android:id="@+id/osmo_log_off_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginLeft="@dimen/dashboard_parking_left_margin"
android:layout_marginTop="3dp"> android:layout_marginRight="@dimen/dashboard_parking_left_margin"
android:minHeight="@dimen/osmo_header_height">
<TextView <TextView
android:id="@+id/osmo_user_name_text_view" android:id="@+id/osmo_user_name_text_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:text="@string/anonymous_user" android:text="@string/anonymous_user"
android:textAppearance="?android:attr/textAppearance" /> android:textAppearance="?android:attr/textAppearance"/>
<CheckBox <CheckBox
android:id="@+id/osmo_login_logoff" android:id="@+id/osmo_login_logoff"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:focusable="false" android:focusable="false"
android:gravity="center_vertical" /> android:gravity="center_vertical"/>
<Button <Button
android:id="@+id/osmo_login_hint_button" android:id="@+id/osmo_login_hint_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_toRightOf="@id/osmo_user_name_text_view" android:layout_toRightOf="@id/osmo_user_name_text_view"
android:minHeight="0dp" android:minHeight="0dp"
android:minWidth="0dp" android:minWidth="0dp"
android:text="\?" android:text="\?"
android:textAppearance="?android:attr/textAppearance" /> android:textAppearance="?android:attr/textAppearance"/>
</RelativeLayout> </RelativeLayout>
<CheckBox <CheckBox
android:id="@+id/enable_tracker" android:id="@+id/enable_tracker"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:focusable="false" android:layout_marginLeft="@dimen/dashboard_parking_left_margin"
android:layout_marginLeft="3dp" android:layout_marginRight="@dimen/dashboard_parking_left_margin"
android:layout_marginTop="3dp" android:checked="false"
android:gravity="center_vertical" android:focusable="false"
android:text="@string/osmo_enable_tracker" /> android:gravity="center_vertical"
android:minHeight="@dimen/osmo_header_height"
android:text="@string/osmo_enable_tracker"/>
<TextView <TextView
android:id="@+id/motd" android:id="@+id/motd"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dip" android:autoLink="web"
android:autoLink="web" android:gravity="center"
android:gravity="center" android:textSize="18sp"/>
android:textSize="18sp" />
</LinearLayout> </LinearLayout>

View file

@ -1,48 +1,52 @@
<?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"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical"
android:paddingBottom="@dimen/dialog_content_bottom_margin"
android:paddingLeft="@dimen/dialog_content_margin"
android:paddingRight="@dimen/dialog_content_margin"
android:paddingTop="@dimen/dialog_content_bottom_margin">
<TextView <TextView
android:id="@+id/parkTime" android:id="@+id/parkTime"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="30dp" android:layout_height="30dp"
android:layout_gravity="center" android:layout_gravity="center"
android:text="@string/osmand_parking_position_description_add" /> android:text="@string/osmand_parking_position_description_add"/>
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:layout_gravity="center_horizontal"
android:layout_gravity="center_horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/textView1" android:id="@+id/textView1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:text="@string/osmand_parking_hours" /> android:text="@string/osmand_parking_hours"/>
<TimePicker <TimePicker
android:id="@+id/parking_time_picker" android:id="@+id/parking_time_picker"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"/>
<TextView <TextView
android:id="@+id/textView2" android:id="@+id/textView2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:text="@string/osmand_parking_minutes" /> android:text="@string/osmand_parking_minutes"/>
</LinearLayout> </LinearLayout>
<CheckBox <CheckBox
android:id="@+id/check_event_in_calendar" android:id="@+id/check_event_in_calendar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:checked="true" android:checked="true"
android:text="@string/osmand_parking_add_event" /> android:text="@string/osmand_parking_add_event"/>
</LinearLayout> </LinearLayout>

View file

@ -37,5 +37,5 @@
android:paddingLeft="4dp" android:paddingLeft="4dp"
android:paddingRight="8dp" android:paddingRight="8dp"
android:paddingTop="2dp" android:paddingTop="2dp"
android:src="@android:drawable/ic_input_get" /> android:src="@drawable/ic_action_filter_dark" />
</LinearLayout> </LinearLayout>

View file

@ -36,7 +36,8 @@
<attr name="expandable_list_background" format="color"/> <attr name="expandable_list_background" format="color"/>
<attr name="list_settings_icon" format="reference"/> <attr name="list_settings_icon" format="reference"/>
<attr name="size_progress_bar" format="reference"/> <attr name="size_progress_bar" format="reference"/>
<attr name="dash_parking_bg" format="color"/> <attr name="dash_parking_bg" format="reference"/>
<attr name="osmo_header_background" format="color"/>
</declare-styleable> </declare-styleable>
<declare-styleable name="PagerSlidingTabStrip"> <declare-styleable name="PagerSlidingTabStrip">

View file

@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="osmo_header_dark">#2d383d</color>
<color name="osmo_header_light">#b36d12</color>
<color name="parking_card_selected">#234DDE</color>
<color name="dashboard_parking_dark_color">#54778c</color>
<color name="dashboard_parking_dark_selected">#446072</color>
<color name="list_divider_dark">#1f2326</color> <color name="list_divider_dark">#1f2326</color>
<color name="list_divider_light">@color/color_white</color> <color name="list_divider_light">@color/color_white</color>
<color name="list_background_dark">#292f33</color> <color name="list_background_dark">#292f33</color>
@ -33,7 +40,7 @@
<color name="dashboard_subheader_text_light">#212121</color> <color name="dashboard_subheader_text_light">#212121</color>
<color name="dashboard_general_button_text_dark">#ff8f00</color> <color name="dashboard_general_button_text_dark">#ff8f00</color>
<color name="dashboard_general_button_text_light">#536DFE</color> <color name="dashboard_general_button_text_light">#536DFE</color>
<color name="dashboard_parking_dark">#54778c</color>
<color name="color_transparent">#00000000</color> <color name="color_transparent">#00000000</color>
<color name="widgettext_night">#ffC8C8C8</color> <color name="widgettext_night">#ffC8C8C8</color>

View file

@ -49,6 +49,7 @@
<dimen name="dashboard_parking_icon_size">48dp</dimen> <dimen name="dashboard_parking_icon_size">48dp</dimen>
<dimen name="map_button_size">40dp</dimen> <dimen name="map_button_size">40dp</dimen>
<dimen name="map_button_margin">8dp</dimen> <dimen name="map_button_margin">8dp</dimen>
<dimen name="osmo_header_height">56dp</dimen>
<!-- TextSizes --> <!-- TextSizes -->

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="osmand_parking_outdated">Outdated</string>
<string name="action_create">Action create</string> <string name="action_create">Action create</string>
<string name="action_modify">Action modify</string> <string name="action_modify">Action modify</string>
<string name="action_delete">Action delete</string> <string name="action_delete">Action delete</string>

View file

@ -165,7 +165,8 @@
<item name="expandable_list_background">@color/color_white</item> <item name="expandable_list_background">@color/color_white</item>
<item name="list_settings_icon">@drawable/ic_overflow_menu_light</item> <item name="list_settings_icon">@drawable/ic_overflow_menu_light</item>
<item name="size_progress_bar">@drawable/size_progressbar_light</item> <item name="size_progress_bar">@drawable/size_progressbar_light</item>
<item name="dash_parking_bg">@color/dashboard_blue</item> <item name="dash_parking_bg">@drawable/dash_parking_light</item>
<item name="osmo_header_background">@color/osmo_header_light</item>
</style> </style>
<style name="OsmandDarkTheme" parent="Theme.AppCompat"> <style name="OsmandDarkTheme" parent="Theme.AppCompat">
@ -209,7 +210,8 @@
<item name="expandable_list_background">@color/list_background_dark</item> <item name="expandable_list_background">@color/list_background_dark</item>
<item name="list_settings_icon">@drawable/ic_overflow_menu_dark</item> <item name="list_settings_icon">@drawable/ic_overflow_menu_dark</item>
<item name="size_progress_bar">@drawable/size_progressbar_dark</item> <item name="size_progress_bar">@drawable/size_progressbar_dark</item>
<item name="dash_parking_bg">@color/dashboard_parking_dark</item> <item name="dash_parking_bg">@drawable/dash_parking_dark</item>
<item name="osmo_header_background">@color/osmo_header_dark</item>
</style> </style>
<style name="Widget.Styled.ActionBarDark" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse"> <style name="Widget.Styled.ActionBarDark" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">

View file

@ -32,6 +32,7 @@ public class PointDescription {
public static final String POINT_TYPE_LOCATION = "location"; public static final String POINT_TYPE_LOCATION = "location";
public static final String POINT_TYPE_ALARM = "alarm"; public static final String POINT_TYPE_ALARM = "alarm";
public static final String POINT_TYPE_TARGET = "destination"; public static final String POINT_TYPE_TARGET = "destination";
public static final String POINT_TYPE_OSM_BUG = "bug";
public static final PointDescription LOCATION_POINT = new PointDescription(POINT_TYPE_LOCATION, ""); public static final PointDescription LOCATION_POINT = new PointDescription(POINT_TYPE_LOCATION, "");

View file

@ -39,7 +39,8 @@ public class IconsCache {
public Drawable getIcon(int id, int colorId) { public Drawable getIcon(int id, int colorId) {
return getDrawable(id, colorId); return getDrawable(id, colorId);
} }
public Drawable getContentIcon(int id) { public Drawable getContentIcon(int id) {
return getDrawable(id, app.getSettings().isLightContent() ? R.color.icon_color_light : 0); return getDrawable(id, app.getSettings().isLightContent() ? R.color.icon_color_light : 0);
} }

View file

@ -1,9 +1,12 @@
package net.osmand.plus.activities; package net.osmand.plus.activities;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View; import android.view.View;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import net.osmand.plus.R;
/** /**
* Created by Denis * Created by Denis
* on 23.01.15. * on 23.01.15.
@ -29,4 +32,23 @@ public class ActionBarProgressActivity extends OsmandActionBarActivity {
public void setSupportProgressBarIndeterminateVisibility(boolean visible) { public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
getSupportActionBar().getCustomView().setVisibility(visible ? View.VISIBLE : View.GONE); getSupportActionBar().getCustomView().setVisibility(visible ? View.VISIBLE : View.GONE);
} }
public Toolbar getClearToolbar(boolean visible) {
final Toolbar tb = (Toolbar) findViewById(R.id.bottomControls);
if (tb == null) {
return null;
}
tb.setTitle(null);
tb.getMenu().clear();
tb.setVisibility(visible? View.VISIBLE : View.GONE);
return tb;
}
public void setToolbarVisibility(boolean visible){
View toolbar = findViewById(R.id.bottomControls);
if (toolbar != null) {
toolbar.setVisibility(visible? View.VISIBLE : View.GONE);
}
}
} }

View file

@ -18,7 +18,6 @@ import net.osmand.plus.dashboard.NotifyingScrollView;
import net.osmand.plus.download.BaseDownloadActivity; import net.osmand.plus.download.BaseDownloadActivity;
import net.osmand.plus.download.IndexItem; import net.osmand.plus.download.IndexItem;
import net.osmand.plus.sherpafy.TourViewActivity; import net.osmand.plus.sherpafy.TourViewActivity;
import net.osmand.plus.views.controls.FloatingActionButton;
import android.app.Dialog; import android.app.Dialog;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
@ -53,7 +52,6 @@ public class MainMenuActivity extends BaseDownloadActivity implements OsmAndLoca
int defaultMargin; int defaultMargin;
private Drawable actionBarBackground; private Drawable actionBarBackground;
FloatingActionButton fabButton;
private NotifyingScrollView.OnScrollChangedListener onScrollChangedListener = new NotifyingScrollView.OnScrollChangedListener() { private NotifyingScrollView.OnScrollChangedListener onScrollChangedListener = new NotifyingScrollView.OnScrollChangedListener() {
public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
@ -69,18 +67,7 @@ public class MainMenuActivity extends BaseDownloadActivity implements OsmAndLoca
margintop, margintop,
r.getDisplayMetrics()); r.getDisplayMetrics());
int margin = px + defaultMargin; int margin = px + defaultMargin;
if (headerHeight < t - margin){ if (headerHeight >= t - margin){
//hiding action bar - showing floating button
//getSupportActionBar().hide();
if (fabButton != null) {
fabButton.showFloatingActionButton();
}
} else {
//getSupportActionBar().show();
if (fabButton != null) {
fabButton.hideFloatingActionButton();
}
//makes other cards to move on top of the map card to make it look like android animations //makes other cards to move on top of the map card to make it look like android animations
View fragments = findViewById(R.id.fragments); View fragments = findViewById(R.id.fragments);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
@ -158,22 +145,6 @@ public class MainMenuActivity extends BaseDownloadActivity implements OsmAndLoca
startMapActivity(); startMapActivity();
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
fabButton = new FloatingActionButton.Builder(this)
.withDrawable(getResources().getDrawable(R.drawable.ic_action_map))
.withButtonColor(Color.parseColor("#ff8f00"))
.withGravity(Gravity.BOTTOM | Gravity.RIGHT)
.withMargins(0, 0, 16, 16)
.create();
fabButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startMapActivity();
}
});
fabButton.hideFloatingActionButton();
}
getLocationProvider().addCompassListener(this); getLocationProvider().addCompassListener(this);
getLocationProvider().registerOrUnregisterCompassListener(true); getLocationProvider().registerOrUnregisterCompassListener(true);

View file

@ -6,7 +6,9 @@ import android.support.v7.app.ActionBarActivity;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.widget.ExpandableListView; import android.widget.ExpandableListView;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import android.app.ActionBar; import android.app.ActionBar;
import android.graphics.Shader.TileMode; import android.graphics.Shader.TileMode;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
@ -17,7 +19,7 @@ import android.view.View;
public abstract class OsmandExpandableListActivity extends public abstract class OsmandExpandableListActivity extends
ActionBarProgressActivity { ActionBarProgressActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this); ((OsmandApplication) getApplication()).applyTheme(this);
@ -27,22 +29,22 @@ public abstract class OsmandExpandableListActivity extends
public OsmandApplication getMyApplication() { public OsmandApplication getMyApplication() {
return (OsmandApplication)getApplication(); return (OsmandApplication) getApplication();
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId(); int itemId = item.getItemId();
switch (itemId) { switch (itemId) {
case android.R.id.home: case android.R.id.home:
finish(); finish();
return true; return true;
} }
return false; return false;
} }
public MenuItem createMenuItem(Menu m, int id, int titleRes, int iconLight, int iconDark, int menuItemType) { public MenuItem createMenuItem(Menu m, int id, int titleRes, int iconLight, int iconDark, int menuItemType) {
int r = isLightActionBar() ? iconLight : iconDark; int r = isLightActionBar() ? iconLight : iconDark;
MenuItem menuItem = m.add(0, id, 0, titleRes); MenuItem menuItem = m.add(0, id, 0, titleRes);
@ -58,7 +60,11 @@ public abstract class OsmandExpandableListActivity extends
MenuItemCompat.setShowAsAction(menuItem, menuItemType); MenuItemCompat.setShowAsAction(menuItem, menuItemType);
return menuItem; return menuItem;
} }
public MenuItem createMenuItem(Menu m, int id, int titleRes, int icon, int menuItemType) {
return createMenuItem(m, id, titleRes, icon, icon, menuItemType);
}
public void fixBackgroundRepeat(View view) { public void fixBackgroundRepeat(View view) {
Drawable bg = view.getBackground(); Drawable bg = view.getBackground();
if (bg != null) { if (bg != null) {
@ -69,18 +75,18 @@ public abstract class OsmandExpandableListActivity extends
} }
} }
} }
public void setListAdapter(OsmandBaseExpandableListAdapter adapter){
((ExpandableListView)findViewById(android.R.id.list)).setAdapter(adapter); public void setListAdapter(OsmandBaseExpandableListAdapter adapter) {
((ExpandableListView) findViewById(android.R.id.list)).setAdapter(adapter);
} }
public ExpandableListView getExpandableListView() { public ExpandableListView getExpandableListView() {
return (ExpandableListView)findViewById(android.R.id.list); return (ExpandableListView) findViewById(android.R.id.list);
} }
public void setOnChildClickListener(ExpandableListView.OnChildClickListener childClickListener){ public void setOnChildClickListener(ExpandableListView.OnChildClickListener childClickListener) {
((ExpandableListView)findViewById(android.R.id.list)).setOnChildClickListener(childClickListener); ((ExpandableListView) findViewById(android.R.id.list)).setOnChildClickListener(childClickListener);
} }
public boolean isLightActionBar() { public boolean isLightActionBar() {

View file

@ -148,10 +148,11 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv
} }
TextView label = (TextView) row.findViewById(R.id.folder_label); TextView label = (TextView) row.findViewById(R.id.folder_label);
ImageView icon = (ImageView) row.findViewById(R.id.folder_icon); ImageView icon = (ImageView) row.findViewById(R.id.folder_icon);
OsmandApplication app = getMyApplication();
final PoiLegacyFilter model = getItem(position); final PoiLegacyFilter model = getItem(position);
label.setText(model.getName()); label.setText(model.getName());
if(model.getFilterId().equals(PoiLegacyFilter.CUSTOM_FILTER_ID)) { if(model.getFilterId().equals(PoiLegacyFilter.CUSTOM_FILTER_ID)) {
icon.setImageResource(android.R.drawable.ic_input_get); icon.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_action_filter_dark));
} else if (model.getFilterId().equals(PoiLegacyFilter.BY_NAME_FILTER_ID)) { } else if (model.getFilterId().equals(PoiLegacyFilter.BY_NAME_FILTER_ID)) {
icon.setImageResource(android.R.drawable.ic_search_category_default); icon.setImageResource(android.R.drawable.ic_search_category_default);
} else { } else {
@ -191,4 +192,8 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv
public void locationUpdate(LatLon l) { public void locationUpdate(LatLon l) {
} }
public OsmandApplication getMyApplication() {
return (OsmandApplication) getActivity().getApplication();
}
} }

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -45,13 +46,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() { (view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Activity activity = getActivity(); startFavoritesActivity(FavoritesActivity.NOTES_TAB);
Class<FavoritesActivity> fa = getMyApplication().getAppCustomization().getFavoritesActivity();
final Intent favorites = new Intent(activity, fa);
favorites.putExtra("TAB", "AUDIO");
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.NOTES_TAB);
activity.startActivity(favorites);
} }
}); });
return view; return view;

View file

@ -1,10 +1,14 @@
package net.osmand.plus.dashboard; package net.osmand.plus.dashboard;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.location.Location; import android.location.Location;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.myplaces.FavoritesActivity;
/** /**
* Created by Denis on 24.11.2014. * Created by Denis on 24.11.2014.
@ -63,4 +67,13 @@ public abstract class DashBaseFragment extends Fragment {
} }
} }
protected void startFavoritesActivity(int tab) {
Activity activity = getActivity();
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity());
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().FAVORITES_TAB.set(tab);
activity.startActivity(favorites);
}
} }

View file

@ -31,7 +31,8 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
/** /**
* Created by Denis on 24.11.2014. * Created by Denis
* on 24.11.2014.
*/ */
public class DashFavoritesFragment extends DashLocationFragment { public class DashFavoritesFragment extends DashLocationFragment {
public static final String TAG = "DASH_FAVORITES_FRAGMENT"; public static final String TAG = "DASH_FAVORITES_FRAGMENT";
@ -47,12 +48,7 @@ public class DashFavoritesFragment extends DashLocationFragment {
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() { (view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Activity activity = getActivity(); startFavoritesActivity(FavoritesActivity.FAVORITES_TAB);
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity());
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.FAVORITES_TAB);
activity.startActivity(favorites);
} }
}); });
return view; return view;

View file

@ -9,6 +9,7 @@ import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.views.DirectionDrawable; import net.osmand.plus.views.DirectionDrawable;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
@ -31,34 +32,34 @@ public abstract class DashLocationFragment extends DashBaseFragment {
private static final int ORIENTATION_180 = 2; private static final int ORIENTATION_180 = 2;
protected List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>(); protected List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
private int screenOrientation; private int screenOrientation;
public static class DashLocationView { public static class DashLocationView {
public ImageView arrow; public ImageView arrow;
public TextView txt; public TextView txt;
public LatLon loc; public LatLon loc;
public int arrowResId; public int arrowResId;
public boolean paint = true;
public DashLocationView(ImageView arrow, TextView txt, LatLon loc) { public DashLocationView(ImageView arrow, TextView txt, LatLon loc) {
super(); super();
this.arrow = arrow; this.arrow = arrow;
this.txt = txt; this.txt = txt;
this.loc = loc; this.loc = loc;
} }
} }
@Override @Override
public void onOpenDash() { public void onOpenDash() {
//Hardy: getRotation() is the correction if device's screen orientation != the default display's standard orientation //Hardy: getRotation() is the correction if device's screen orientation != the default display's standard orientation
screenOrientation = getScreenOrientation(getActivity()); screenOrientation = getScreenOrientation(getActivity());
} }
public static int getScreenOrientation(Activity a) { public static int getScreenOrientation(Activity a) {
int screenOrientation = ((WindowManager) a.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation(); int screenOrientation = ((WindowManager) a.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
switch (screenOrientation) switch (screenOrientation) {
{
case ORIENTATION_0: // Device default (normally portrait) case ORIENTATION_0: // Device default (normally portrait)
screenOrientation = 0; screenOrientation = 0;
break; break;
@ -73,16 +74,16 @@ public abstract class DashLocationFragment extends DashBaseFragment {
break; break;
} }
//Looks like screenOrientation correction must not be applied for devices without compass? //Looks like screenOrientation correction must not be applied for devices without compass?
Sensor compass = ((SensorManager) a.getSystemService(Context.SENSOR_SERVICE)).getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); Sensor compass = ((SensorManager) a.getSystemService(Context.SENSOR_SERVICE)).getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
if (compass == null) { if (compass == null) {
screenOrientation = 0; screenOrientation = 0;
} }
return screenOrientation; return screenOrientation;
} }
public LatLon getDefaultLocation() { public LatLon getDefaultLocation() {
DashboardOnMap d = dashboard; DashboardOnMap d = dashboard;
if(d == null) { if (d == null) {
return null; return null;
} }
return d.getMapViewLocation(); return d.getMapViewLocation();
@ -90,7 +91,7 @@ public abstract class DashLocationFragment extends DashBaseFragment {
public void updateAllWidgets() { public void updateAllWidgets() {
DashboardOnMap d = dashboard; DashboardOnMap d = dashboard;
if(d == null) { if (d == null) {
return; return;
} }
float head = d.getHeading(); float head = d.getHeading();
@ -103,19 +104,20 @@ public abstract class DashLocationFragment extends DashBaseFragment {
LatLon loc = (useCenter ? mw : myLoc); LatLon loc = (useCenter ? mw : myLoc);
float h = useCenter ? -mapRotation : head; float h = useCenter ? -mapRotation : head;
for (DashLocationView lv : distances) { for (DashLocationView lv : distances) {
updateLocationView(useCenter, loc, h, lv.arrow, lv.arrowResId, lv.txt, lv.loc.getLatitude(), lv.loc.getLongitude(), updateLocationView(useCenter, loc, h, lv.arrow, lv.arrowResId, lv.txt, lv.loc.getLatitude(), lv.loc.getLongitude(),
screenOrientation, getMyApplication(), getActivity()); screenOrientation, getMyApplication(), getActivity(), lv.paint);
} }
} }
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h, public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, TextView txt, double toLat, double toLon, ImageView arrow, TextView txt, double toLat, double toLon,
int screenOrientation, OsmandApplication app, Context ctx) { int screenOrientation, OsmandApplication app, Context ctx) {
updateLocationView(useCenter, fromLoc, h, arrow, 0, txt, toLat, toLon, screenOrientation, app, ctx); updateLocationView(useCenter, fromLoc, h, arrow, 0, txt, toLat, toLon, screenOrientation, app, ctx, true);
} }
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, TextView txt, double toLat, double toLon, public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
int screenOrientation, OsmandApplication app, Context ctx) { ImageView arrow, int arrowResId, TextView txt, double toLat, double toLon,
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) {
float[] mes = new float[2]; float[] mes = new float[2];
if (fromLoc != null) { if (fromLoc != null) {
Location.distanceBetween(toLat, toLon, fromLoc.getLatitude(), fromLoc.getLongitude(), mes); Location.distanceBetween(toLat, toLon, fromLoc.getLatitude(), fromLoc.getLongitude(), mes);
@ -129,7 +131,11 @@ public abstract class DashLocationFragment extends DashBaseFragment {
arrowResId = R.drawable.ic_destination_arrow_white; arrowResId = R.drawable.ic_destination_arrow_white;
} }
DirectionDrawable dd = (DirectionDrawable) arrow.getDrawable(); DirectionDrawable dd = (DirectionDrawable) arrow.getDrawable();
dd.setImage(arrowResId, useCenter ? R.color.color_distance : R.color.color_myloc_distance); if (paint) {
dd.setImage(arrowResId, useCenter ? R.color.color_distance : R.color.color_myloc_distance);
} else {
dd.setImage(arrowResId);
}
if (fromLoc == null || h == null) { if (fromLoc == null || h == null) {
dd.setAngle(0); dd.setAngle(0);
} else { } else {
@ -139,8 +145,10 @@ public abstract class DashLocationFragment extends DashBaseFragment {
} }
if (txt != null) { if (txt != null) {
if (fromLoc != null) { if (fromLoc != null) {
txt.setTextColor(app.getResources().getColor( if (paint) {
useCenter ? R.color.color_distance : R.color.color_myloc_distance)); txt.setTextColor(app.getResources().getColor(
useCenter ? R.color.color_distance : R.color.color_myloc_distance));
}
txt.setText(OsmAndFormatter.getFormattedDistance(mes[0], app)); txt.setText(OsmAndFormatter.getFormattedDistance(mes[0], app));
} else { } else {
txt.setText(""); txt.setText("");
@ -149,7 +157,7 @@ public abstract class DashLocationFragment extends DashBaseFragment {
} }
public void updateLocation(boolean centerChanged, boolean locationChanged, boolean compassChanged) { public void updateLocation(boolean centerChanged, boolean locationChanged, boolean compassChanged) {
if(compassChanged && !dashboard.isMapLinkedToLocation()) { if (compassChanged && !dashboard.isMapLinkedToLocation()) {
return; return;
} }
updateAllWidgets(); updateAllWidgets();

View file

@ -1,9 +1,26 @@
package net.osmand.plus.dashboard; package net.osmand.plus.dashboard;
import java.lang.ref.WeakReference; import android.content.Context;
import java.util.Iterator; import android.content.Intent;
import java.util.LinkedList; import android.support.v4.app.Fragment;
import java.util.List; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.Toolbar;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ScrollView;
import com.software.shell.fab.ActionButton;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -16,29 +33,16 @@ import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.helpers.ScreenOrientationHelper;
import net.osmand.plus.monitoring.DashTrackFragment; import net.osmand.plus.monitoring.DashTrackFragment;
import net.osmand.plus.osmo.DashOsmoFragment;
import net.osmand.plus.parkingpoint.DashParkingFragment; import net.osmand.plus.parkingpoint.DashParkingFragment;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.DownloadedRegionsLayer; import net.osmand.plus.views.DownloadedRegionsLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.controls.FloatingActionButton;
import android.content.Intent; import java.lang.ref.WeakReference;
import android.os.Build; import java.util.Iterator;
import android.support.v4.app.Fragment; import java.util.LinkedList;
import android.support.v4.app.FragmentManager; import java.util.List;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ScrollView;
/** /**
* Created by Denis * Created by Denis
@ -52,8 +56,7 @@ public class DashboardOnMap {
private static final int CONFIGURE_SCREEN_ID = 3; private static final int CONFIGURE_SCREEN_ID = 3;
private static final int SETTINGS_ID = 4; private static final int SETTINGS_ID = 4;
private MapActivity mapActivity; private MapActivity mapActivity;
FloatingActionButton fabButton; ActionButton actionButton;
boolean floatingButtonVisible = true;
private FrameLayout dashboardView; private FrameLayout dashboardView;
private boolean visible = false; private boolean visible = false;
@ -97,29 +100,30 @@ public class DashboardOnMap {
mapActivity.getMapActions().toggleDrawer(); mapActivity.getMapActions().toggleDrawer();
} }
}); });
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
fabButton = new FloatingActionButton.Builder(mapActivity) actionButton = new ActionButton(mapActivity);
.withDrawable(mapActivity.getResources().getDrawable(R.drawable.ic_action_map)) FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
.withButtonColor(mapActivity.getResources().getColor(R.color.color_myloc_distance)) int marginRight = convertPixelsToDp(16, mapActivity);
.withGravity(landscape ? Gravity.BOTTOM | Gravity.RIGHT : Gravity.TOP | Gravity.RIGHT) params.setMargins(0, landscape ? 0 : convertPixelsToDp(164, mapActivity), marginRight, landscape ? marginRight : 0);
.withMargins(0, landscape ? 0 : 160, 16, landscape ? 16 : 0).create();
fabButton.setOnClickListener(new View.OnClickListener() { params.gravity = landscape ? Gravity.BOTTOM | Gravity.RIGHT : Gravity.TOP | Gravity.RIGHT;
@Override actionButton.setLayoutParams(params);
public void onClick(View view) { actionButton.setImageDrawable(mapActivity.getResources().getDrawable(R.drawable.ic_action_map));
if (getMyApplication().accessibilityEnabled()) { actionButton.setButtonColor(mapActivity.getResources().getColor(R.color.color_myloc_distance));
mapActivity.getMapActions().whereAmIDialog(); actionButton.hide();
} else { actionButton.setOnClickListener(new View.OnClickListener() {
mapActivity.getMapViewTrackingUtilities().backToLocationImpl(); @Override
} public void onClick(View v) {
setDashboardVisibility(false); if (getMyApplication().accessibilityEnabled()) {
mapActivity.getMapActions().whereAmIDialog();
} else {
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
} }
}); setDashboardVisibility(false);
fabButton.hideFloatingActionButton(); }
} });
dashboardView.addView(actionButton);
if (ScreenOrientationHelper.isOrientationPortrait(mapActivity)) { if (ScreenOrientationHelper.isOrientationPortrait(mapActivity)) {
((NotifyingScrollView) dashboardView.findViewById(R.id.main_scroll)) ((NotifyingScrollView) dashboardView.findViewById(R.id.main_scroll))
@ -127,6 +131,11 @@ public class DashboardOnMap {
} }
} }
public static int convertPixelsToDp(float dp, Context context){
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
}
public net.osmand.Location getMyLocation() { public net.osmand.Location getMyLocation() {
return myLocation; return myLocation;
@ -165,7 +174,8 @@ public class DashboardOnMap {
setupActionBar(); setupActionBar();
updateDownloadBtn(); updateDownloadBtn();
dashboardView.setVisibility(View.VISIBLE); dashboardView.setVisibility(View.VISIBLE);
fabButton.showFloatingActionButton(); actionButton.show();
//fabButton.showFloatingActionButton();
open(dashboardView.findViewById(R.id.animateContent)); open(dashboardView.findViewById(R.id.animateContent));
mapActivity.getMapActions().disableDrawer(); mapActivity.getMapActions().disableDrawer();
@ -179,7 +189,8 @@ public class DashboardOnMap {
hide(dashboardView.findViewById(R.id.animateContent)); hide(dashboardView.findViewById(R.id.animateContent));
mapActivity.findViewById(R.id.MapInfoControls).setVisibility(View.VISIBLE); mapActivity.findViewById(R.id.MapInfoControls).setVisibility(View.VISIBLE);
mapActivity.findViewById(R.id.MapButtons).setVisibility(View.VISIBLE); mapActivity.findViewById(R.id.MapButtons).setVisibility(View.VISIBLE);
fabButton.hideFloatingActionButton(); actionButton.hide();
//fabButton.hideFloatingActionButton();
for (WeakReference<DashBaseFragment> df : fragList) { for (WeakReference<DashBaseFragment> df : fragList) {
if (df.get() != null) { if (df.get() != null) {
df.get().onCloseDash(); df.get().onCloseDash();
@ -350,6 +361,8 @@ public class DashboardOnMap {
showFragment(manager, fragmentTransaction, DashFavoritesFragment.TAG, DashFavoritesFragment.class); showFragment(manager, fragmentTransaction, DashFavoritesFragment.TAG, DashFavoritesFragment.class);
showFragment(manager, fragmentTransaction, DashAudioVideoNotesFragment.TAG, DashAudioVideoNotesFragment.class); showFragment(manager, fragmentTransaction, DashAudioVideoNotesFragment.TAG, DashAudioVideoNotesFragment.class);
showFragment(manager, fragmentTransaction, DashTrackFragment.TAG, DashTrackFragment.class); showFragment(manager, fragmentTransaction, DashTrackFragment.TAG, DashTrackFragment.class);
showFragment(manager, fragmentTransaction, DashOsmoFragment.TAG, DashOsmoFragment.class);
//showFragment(manager, fragmentTransaction, DashOsmEditsFragment.TAG, DashOsmEditsFragment.class);
// showFragment(manager, fragmentTransaction, DashUpdatesFragment.TAG, DashUpdatesFragment.class); // showFragment(manager, fragmentTransaction, DashUpdatesFragment.TAG, DashUpdatesFragment.class);
showFragment(manager, fragmentTransaction, DashPluginsFragment.TAG, DashPluginsFragment.class); showFragment(manager, fragmentTransaction, DashPluginsFragment.TAG, DashPluginsFragment.class);
@ -385,9 +398,9 @@ public class DashboardOnMap {
public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
int sy = who.getScrollY(); int sy = who.getScrollY();
double scale = who.getContext().getResources().getDisplayMetrics().density; double scale = who.getContext().getResources().getDisplayMetrics().density;
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) fabButton.getLayoutParams(); FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) actionButton.getLayoutParams();
lp.topMargin = (int) Math.max(30 * scale, 160 * scale - sy); lp.topMargin = (int) Math.max(30 * scale, 160 * scale - sy);
((FrameLayout) fabButton.getParent()).updateViewLayout(fabButton, lp); ((FrameLayout) actionButton.getParent()).updateViewLayout(actionButton, lp);
} }
}; };

View file

@ -1,45 +1,5 @@
package net.osmand.plus.myplaces; package net.osmand.plus.myplaces;
import java.io.File;
import java.text.Collator;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import net.osmand.IndexConstants;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
import net.osmand.plus.activities.OsmandExpandableListFragment;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.download.LocalIndexesFragment;
import net.osmand.plus.helpers.ScreenOrientationHelper;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.util.Algorithms;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
@ -77,6 +37,47 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.IndexConstants;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
import net.osmand.plus.activities.OsmandExpandableListFragment;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.download.LocalIndexesFragment;
import net.osmand.plus.helpers.ScreenOrientationHelper;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.util.Algorithms;
import java.io.File;
import java.text.Collator;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
public class AvailableGPXFragment extends OsmandExpandableListFragment { public class AvailableGPXFragment extends OsmandExpandableListFragment {
public static final int SEARCH_ID = -1; public static final int SEARCH_ID = -1;
@ -349,12 +350,12 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
return true; return true;
} }
}; };
optionsMenuAdapter.item(R.string.shared_string_show_on_map).icons(R.drawable.ic_show_on_map, R.drawable.ic_show_on_map) optionsMenuAdapter.item(R.string.shared_string_show_on_map).icon(R.drawable.ic_show_on_map)
.listen(listener).reg(); .listen(listener).reg();
optionsMenuAdapter.item(R.string.shared_string_delete) optionsMenuAdapter.item(R.string.shared_string_delete)
.icons(R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_dark).listen(listener).reg(); .icon(R.drawable.ic_action_delete_dark).listen(listener).reg();
optionsMenuAdapter.item(R.string.local_index_mi_reload) optionsMenuAdapter.item(R.string.local_index_mi_reload)
.icons(R.drawable.ic_action_refresh_dark, R.drawable.ic_action_refresh_dark).listen(listener).reg(); .icon(R.drawable.ic_action_refresh_dark).listen(listener).reg();
OsmandPlugin.onOptionsMenuActivity(getActivity(), this, optionsMenuAdapter); OsmandPlugin.onOptionsMenuActivity(getActivity(), this, optionsMenuAdapter);
for (int j = 0; j < optionsMenuAdapter.length(); j++) { for (int j = 0; j < optionsMenuAdapter.length(); j++) {
final MenuItem item; final MenuItem item;

View file

@ -16,6 +16,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.FavoritesTreeFragment; import net.osmand.plus.activities.FavoritesTreeFragment;
import net.osmand.plus.activities.TabActivity; import net.osmand.plus.activities.TabActivity;
import net.osmand.plus.myplaces.AvailableGPXFragment; import net.osmand.plus.myplaces.AvailableGPXFragment;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.views.controls.PagerSlidingTabStrip; import net.osmand.plus.views.controls.PagerSlidingTabStrip;
import android.app.Activity; import android.app.Activity;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -73,7 +74,6 @@ public class FavoritesActivity extends TabActivity {
ViewPager mViewPager = (ViewPager) findViewById(R.id.pager); ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
List<TabItem> mTabs = new ArrayList<TabItem>(); List<TabItem> mTabs = new ArrayList<TabItem>();
// mTabs.add(new TabItem("\t\t\t", FavoritesTreeFragment.class));
mTabs.add(getTabIndicator(R.string.shared_string_my_favorites, FavoritesTreeFragment.class)); mTabs.add(getTabIndicator(R.string.shared_string_my_favorites, FavoritesTreeFragment.class));
if (hasGpx) { if (hasGpx) {
mTabs.add(getTabIndicator(R.string.shared_string_my_tracks, AvailableGPXFragment.class)); mTabs.add(getTabIndicator(R.string.shared_string_my_tracks, AvailableGPXFragment.class));
@ -82,9 +82,14 @@ public class FavoritesActivity extends TabActivity {
Integer tab = settings.FAVORITES_TAB.get(); Integer tab = settings.FAVORITES_TAB.get();
if (tab == NOTES_TAB) { if (tab == NOTES_TAB) {
tab = mTabs.size() -1; if (OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class) != null){
tab = mTabs.size() - 2;
} else {
tab = mTabs.size() - 1;
}
} else if (tab == OSM_EDITS_TAB) { } else if (tab == OSM_EDITS_TAB) {
//TODO implement method of counting position for other plugins tab = mTabs.size() - 1;
} }
setViewPagerAdapter(mViewPager, mTabs); setViewPagerAdapter(mViewPager, mTabs);
@ -93,7 +98,7 @@ public class FavoritesActivity extends TabActivity {
if (tab > mTabs.size() - 1){ if (tab > mTabs.size() - 1){
tab = 0; tab = 0;
} }
mViewPager.setCurrentItem(tab ); mViewPager.setCurrentItem(tab);
// setupHomeButton(); // setupHomeButton();
} }
@ -122,18 +127,6 @@ public class FavoritesActivity extends TabActivity {
} }
public Toolbar getClearToolbar(boolean visible) {
final Toolbar tb = (Toolbar) findViewById(R.id.bottomControls);
tb.setTitle(null);
tb.getMenu().clear();
tb.setVisibility(visible? View.VISIBLE : View.GONE);
return tb;
}
public void setToolbarVisibility(boolean visible){
findViewById(R.id.bottomControls).setVisibility(visible? View.VISIBLE : View.GONE);
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId(); int itemId = item.getItemId();

View file

@ -1,22 +1,38 @@
package net.osmand.plus.osmedit; package net.osmand.plus.osmedit;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.ProgressImplementation;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashBaseFragment; import net.osmand.plus.dashboard.DashBaseFragment;
import net.osmand.plus.helpers.FontCache; import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.myplaces.FavoritesActivity;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
/** /**
* Created by Denis * Created by Denis
* on 20.01.2015. * on 20.01.2015.
*/ */
public class DashOsmEditsFragment extends DashBaseFragment { public class DashOsmEditsFragment extends DashBaseFragment implements OsmEditsUploadListener {
public static final String TAG = "DASH_OSM_EDITS_FRAGMENT";
OsmEditingPlugin plugin; OsmEditingPlugin plugin;
@Override @Override
@ -31,6 +47,12 @@ public class DashOsmEditsFragment extends DashBaseFragment {
Button manage = ((Button) view.findViewById(R.id.show_all)); Button manage = ((Button) view.findViewById(R.id.show_all));
manage.setTypeface(typeface); manage.setTypeface(typeface);
manage.setText(R.string.osm_editing_manage); manage.setText(R.string.osm_editing_manage);
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startFavoritesActivity(FavoritesActivity.OSM_EDITS_TAB);
}
});
return view; return view;
} }
@ -44,12 +66,113 @@ public class DashOsmEditsFragment extends DashBaseFragment {
setupEditings(); setupEditings();
} }
private void setupEditings() { private void setupEditings() {
View mainView = getView(); View mainView = getView();
if (plugin == null){ if (plugin == null){
mainView.setVisibility(View.GONE); mainView.setVisibility(View.GONE);
return; return;
} }
ArrayList<OsmPoint> dataPoints = new ArrayList<>();
getOsmPoints(dataPoints);
if (dataPoints.size() == 0){
mainView.setVisibility(View.GONE);
return;
} else {
mainView.setVisibility(View.VISIBLE);
}
LinearLayout osmLayout = (LinearLayout) mainView.findViewById(R.id.notes);
osmLayout.removeAllViews();
for (final OsmPoint point : dataPoints){
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.note, null, false);
OsmEditsFragment.getOsmEditView(view, point, getMyApplication());
ImageButton send =(ImageButton) view.findViewById(R.id.play);
send.setImageDrawable(getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_gup_dark));
send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
OpenstreetmapRemoteUtil remotepoi = new OpenstreetmapRemoteUtil(getActivity(), getActivity().getWindow().getDecorView());
OsmPoint[] toUpload = new OsmPoint[]{point};
OsmBugsRemoteUtil remotebug = new OsmBugsRemoteUtil(getMyApplication());
ProgressDialog dialog = ProgressImplementation.createProgressDialog(
getActivity(),
getString(R.string.uploading),
getString(R.string.local_openstreetmap_uploading),
ProgressDialog.STYLE_HORIZONTAL).getDialog();
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog,DashOsmEditsFragment.this, remotepoi,
remotebug, toUpload.length);
uploadTask.execute(toUpload);
dialog.show();
}
});
view.findViewById(R.id.options).setVisibility(View.GONE);
view.findViewById(R.id.divider).setVisibility(View.VISIBLE);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean poi = point.getGroup() == OsmPoint.Group.POI;
String name = poi ?
((OpenstreetmapPoint) point).getName() : ((OsmNotesPoint) point).getText();
getMyApplication().getSettings().setMapLocationToShow(point.getLatitude(), point.getLongitude(),
15, new PointDescription(poi ? PointDescription.POINT_TYPE_POI : PointDescription.POINT_TYPE_OSM_BUG, name), true,
point); //$NON-NLS-1$
MapActivity.launchMapActivityMoveToTop(getActivity());
}
});
osmLayout.addView(view);
}
}
private void getOsmPoints(ArrayList<OsmPoint> dataPoints) {
OpenstreetmapsDbHelper dbpoi = new OpenstreetmapsDbHelper(getActivity());
OsmBugsDbHelper dbbug = new OsmBugsDbHelper(getActivity());
List<OpenstreetmapPoint> l1 = dbpoi.getOpenstreetmapPoints();
List<OsmNotesPoint> l2 = dbbug.getOsmbugsPoints();
if (l1.isEmpty()){
int i = 0;
for(OsmPoint point : l2){
if (i > 2) {
break;
}
dataPoints.add(point);
i++;
}
} else if (l2.isEmpty()) {
int i = 0;
for(OsmPoint point : l1){
if (i > 2) {
break;
}
dataPoints.add(point);
i++;
}
} else {
dataPoints.add(l1.get(0));
dataPoints.add(l2.get(0));
if (l1.size() > 1){
dataPoints.add(l1.get(1));
} else if (l2.size() > 1){
dataPoints.add(l2.get(1));
}
}
}
@Override
public void uploadUpdated(OsmPoint point) {
if (!this.isDetached()){
onOpenDash();
}
}
@Override
public void uploadEnded(Integer result) {
if (!this.isDetached()){
onOpenDash();
}
} }
} }

View file

@ -88,11 +88,11 @@ public class LocalOpenstreetmapActivity extends OsmandListActivity {
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
createMenuItem(menu, UPLOAD_ID, R.string.local_openstreetmap_uploadall, R.drawable.ic_action_gup_light, R.drawable.ic_action_gup_dark, createMenuItem(menu, UPLOAD_ID, R.string.local_openstreetmap_uploadall, R.drawable.ic_action_gup_dark, R.drawable.ic_action_gup_dark,
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
createMenuItem(menu, BACKUP_ID, R.string.local_osm_changes_backup, R.drawable.ic_action_gsave_light, R.drawable.ic_action_gsave_dark, createMenuItem(menu, BACKUP_ID, R.string.local_osm_changes_backup, R.drawable.ic_action_gsave_dark, R.drawable.ic_action_gsave_dark,
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
createMenuItem(menu, DELETE_ID, R.string.shared_string_delete_all, R.drawable.ic_action_gdiscard_light, R.drawable.ic_action_gdiscard_dark, createMenuItem(menu, DELETE_ID, R.string.shared_string_delete_all, R.drawable.ic_action_gdiscard_dark, R.drawable.ic_action_gdiscard_dark,
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
return super.onCreateOptionsMenu(menu); return super.onCreateOptionsMenu(menu);
} }

View file

@ -1,9 +1,14 @@
package net.osmand.plus.osmedit; package net.osmand.plus.osmedit;
import android.app.AlertDialog;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.ListFragment; import android.support.v4.app.ListFragment;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.PopupMenu; import android.support.v7.widget.PopupMenu;
import android.util.Xml;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -15,6 +20,9 @@ import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
@ -22,16 +30,24 @@ import net.osmand.plus.ProgressImplementation;
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.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.helpers.ScreenOrientationHelper;
import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.myplaces.FavoritesActivity;
import org.xmlpull.v1.XmlSerializer;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
/** /**
* Created by Denis * Created by Denis
* on 06.03.2015. * on 06.03.2015.
*/ */
public class OsmEditsFragment extends ListFragment { public class OsmEditsFragment extends ListFragment implements OsmEditsUploadListener {
OsmEditingPlugin plugin; OsmEditingPlugin plugin;
private ArrayList<OsmPoint> dataPoints; private ArrayList<OsmPoint> dataPoints;
private OsmEditsAdapter listAdapter; private OsmEditsAdapter listAdapter;
@ -39,8 +55,13 @@ public class OsmEditsFragment extends ListFragment {
private OpenstreetmapsDbHelper dbpoi; private OpenstreetmapsDbHelper dbpoi;
private OsmBugsDbHelper dbbug; private OsmBugsDbHelper dbbug;
private OpenstreetmapRemoteUtil remotepoi;
private OsmBugsRemoteUtil remotebug;
protected OsmPoint[] toUpload = new OsmPoint[0]; protected OsmPoint[] toUpload = new OsmPoint[0];
ProgressDialog dialog;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setHasOptionsMenu(true); setHasOptionsMenu(true);
@ -51,13 +72,73 @@ public class OsmEditsFragment extends ListFragment {
dbpoi = new OpenstreetmapsDbHelper(getActivity()); dbpoi = new OpenstreetmapsDbHelper(getActivity());
dbbug = new OsmBugsDbHelper(getActivity()); dbbug = new OsmBugsDbHelper(getActivity());
remotepoi = new OpenstreetmapRemoteUtil(getActivity(), getActivity().getWindow().getDecorView());
remotebug = new OsmBugsRemoteUtil(getMyApplication());
return view; return view;
} }
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear(); menu.clear();
((FavoritesActivity) getActivity()).getClearToolbar(false);
if (ScreenOrientationHelper.isOrientationPortrait(getActivity())) {
menu = ((FavoritesActivity) getActivity()).getClearToolbar(true).getMenu();
} else {
((FavoritesActivity) getActivity()).getClearToolbar(false);
}
MenuItem item = menu.add(R.string.local_openstreetmap_uploadall).
setIcon(R.drawable.ic_action_export);
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
toUpload = dataPoints.toArray(new OsmPoint[0]);
showUploadItemsDialog();
return true;
}
});
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
item = menu.add(R.string.local_osm_changes_backup).
setIcon(R.drawable.ic_action_gsave_dark);
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
new BackupOpenstreetmapPointAsyncTask().execute(dataPoints.toArray(new OsmPoint[0]));
return true;
}
});
item = menu.add(R.string.shared_string_delete_all).
setIcon(R.drawable.ic_action_delete_dark);
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
b.setMessage(getString(R.string.local_osm_changes_delete_all_confirm, dataPoints.size()));
b.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Iterator<OsmPoint> it = dataPoints.iterator();
while(it.hasNext()) {
OsmPoint info = it.next();
if (info.getGroup() == OsmPoint.Group.POI) {
dbpoi.deletePOI((OpenstreetmapPoint) info);
} else if (info.getGroup() == OsmPoint.Group.BUG) {
dbbug.deleteAllBugModifications((OsmNotesPoint) info);
}
it.remove();
listAdapter.delete(info);
}
listAdapter.notifyDataSetChanged();
}
});
b.setNegativeButton(R.string.shared_string_cancel, null);
b.show();
return true;
}
});
} }
@Override @Override
@ -76,12 +157,36 @@ public class OsmEditsFragment extends ListFragment {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
OsmPoint it = listAdapter.getItem(position); OsmPoint it = listAdapter.getItem(position);
openPopUpMenu(view, it); openPopUpMenu(view, it);
} }
}); });
} }
public static void getOsmEditView(View v, OsmPoint child, OsmandApplication app){
TextView viewName = ((TextView) v.findViewById(R.id.name));
ImageView icon = (ImageView) v.findViewById(R.id.icon);
String idPrefix = (child.getGroup() == OsmPoint.Group.POI ? "POI " : "Bug ") + " id: " + child.getId();
if (child.getGroup() == OsmPoint.Group.POI) {
viewName.setText(idPrefix + " (" + ((OpenstreetmapPoint) child).getSubtype() + ") " + ((OpenstreetmapPoint) child).getName());
icon.setImageDrawable(app.getIconsCache().
getIcon(R.drawable.ic_type_info, R.color.color_distance));
} else if (child.getGroup() == OsmPoint.Group.BUG) {
viewName.setText(idPrefix + " (" + ((OsmNotesPoint) child).getAuthor() + ") " + ((OsmNotesPoint) child).getText());
icon.setImageDrawable(app.getIconsCache().
getIcon(R.drawable.ic_type_bug, R.color.color_distance));
}
TextView descr = (TextView) v.findViewById(R.id.descr);
if (child.getAction() == OsmPoint.Action.CREATE) {
descr.setText(R.string.action_create);
} else if (child.getAction() == OsmPoint.Action.MODIFY) {
descr.setText(R.string.action_modify);
} else if (child.getAction() == OsmPoint.Action.DELETE) {
descr.setText(R.string.action_delete);
}
}
protected class OsmEditsAdapter extends ArrayAdapter<OsmPoint> { protected class OsmEditsAdapter extends ArrayAdapter<OsmPoint> {
public OsmEditsAdapter(List<OsmPoint> points) { public OsmEditsAdapter(List<OsmPoint> points) {
@ -102,29 +207,10 @@ public class OsmEditsFragment extends ListFragment {
LayoutInflater inflater = getActivity().getLayoutInflater(); LayoutInflater inflater = getActivity().getLayoutInflater();
v = inflater.inflate(net.osmand.plus.R.layout.note, parent, false); v = inflater.inflate(net.osmand.plus.R.layout.note, parent, false);
} }
TextView viewName = ((TextView) v.findViewById(R.id.name)); getOsmEditView(v, child, getMyApplication());
ImageView icon = (ImageView) v.findViewById(R.id.icon);
v.findViewById(R.id.play).setVisibility(View.GONE); v.findViewById(R.id.play).setVisibility(View.GONE);
String idPrefix = (child.getGroup() == OsmPoint.Group.POI ? "POI " : "Bug ") + " id: " + child.getId();
if (child.getGroup() == OsmPoint.Group.POI) {
viewName.setText(idPrefix + " (" + ((OpenstreetmapPoint) child).getSubtype() + ") " + ((OpenstreetmapPoint) child).getName());
icon.setImageDrawable(getMyApplication().getIconsCache().
getIcon(R.drawable.ic_type_info, R.color.color_distance));
} else if (child.getGroup() == OsmPoint.Group.BUG) {
viewName.setText(idPrefix + " (" + ((OsmNotesPoint) child).getAuthor() + ") " + ((OsmNotesPoint) child).getText());
icon.setImageDrawable(getMyApplication().getIconsCache().
getIcon(R.drawable.ic_type_bug, R.color.color_distance));
}
TextView descr = (TextView) v.findViewById(R.id.descr);
if (child.getAction() == OsmPoint.Action.CREATE) {
descr.setText(R.string.action_create);
} else if (child.getAction() == OsmPoint.Action.MODIFY) {
descr.setText(R.string.action_modify);
} else if (child.getAction() == OsmPoint.Action.DELETE) {
descr.setText(R.string.action_delete);
}
v.findViewById(R.id.options).setOnClickListener(new View.OnClickListener() { v.findViewById(R.id.options).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -166,17 +252,12 @@ public class OsmEditsFragment extends ListFragment {
} }
}); });
item = optionsMenu.getMenu().add(R.string.local_openstreetmap_upload). item = optionsMenu.getMenu().add(R.string.local_openstreetmap_upload).
setIcon(app.getIconsCache().getContentIcon(R.drawable.ic_action_gup_dark)); setIcon(app.getIconsCache().getContentIcon(R.drawable.ic_action_export));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
toUpload = new OsmPoint[]{info}; toUpload = new OsmPoint[]{info};
ProgressDialog implementation = ProgressImplementation.createProgressDialog( showUploadItemsDialog();
getActivity(),
getString(R.string.uploading),
getString(R.string.local_openstreetmap_uploading),
ProgressDialog.STYLE_HORIZONTAL).getDialog();
implementation.show();
return true; return true;
} }
}); });
@ -187,4 +268,133 @@ public class OsmEditsFragment extends ListFragment {
return (OsmandApplication) getActivity().getApplication(); return (OsmandApplication) getActivity().getApplication();
} }
private void showUploadItemsDialog(){
dialog = ProgressImplementation.createProgressDialog(
getActivity(),
getString(R.string.uploading),
getString(R.string.local_openstreetmap_uploading),
ProgressDialog.STYLE_HORIZONTAL).getDialog();
UploadOpenstreetmapPointAsyncTask uploadTask = new UploadOpenstreetmapPointAsyncTask(dialog, this, remotepoi,
remotebug, toUpload.length);
uploadTask.execute(toUpload);
dialog.show();
}
public class BackupOpenstreetmapPointAsyncTask extends AsyncTask<OsmPoint, OsmPoint, String> {
private File osmchange;
public BackupOpenstreetmapPointAsyncTask() {
OsmandApplication app = (OsmandApplication) getActivity().getApplication();
osmchange = app.getAppPath("poi_modification.osc");
}
@Override
protected String doInBackground(OsmPoint... points) {
FileOutputStream out = null;
try {
out = new FileOutputStream(osmchange);
XmlSerializer sz = Xml.newSerializer();
sz.setOutput(out, "UTF-8");
sz.startDocument("UTF-8", true);
sz.startTag("", "osmChange");
sz.attribute("", "generator", "OsmAnd");
sz.attribute("", "version", "0.6");
sz.startTag("", "create");
writeContent(sz, points, OsmPoint.Action.CREATE);
sz.endTag("", "create");
sz.startTag("", "modify");
writeContent(sz, points, OsmPoint.Action.MODIFY);
sz.endTag("", "modify");
sz.startTag("", "delete");
writeContent(sz, points, OsmPoint.Action.DELETE);
sz.endTag("", "delete");
sz.endTag("", "osmChange");
sz.endDocument();
} catch (Exception e) {
return e.getMessage();
} finally {
try {
if(out!= null) out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
private void writeContent(XmlSerializer sz, OsmPoint[] points, OsmPoint.Action a) throws IllegalArgumentException, IllegalStateException, IOException {
for (OsmPoint point : points) {
if (point.getGroup() == OsmPoint.Group.POI) {
OpenstreetmapPoint p = (OpenstreetmapPoint) point;
if (p.getAction() == a) {
sz.startTag("", "node");
sz.attribute("", "lat", p.getLatitude() + "");
sz.attribute("", "lon", p.getLongitude() + "");
sz.attribute("", "id", p.getId() + "");
sz.attribute("", "version", "1");
for (String tag : p.getEntity().getTagKeySet()) {
String val = p.getEntity().getTag(tag);
sz.startTag("", "tag");
sz.attribute("", "k", tag);
sz.attribute("", "v", val);
sz.endTag("", "tag");
}
sz.endTag("", "node");
}
} else if (point.getGroup() == OsmPoint.Group.BUG) {
OsmNotesPoint p = (OsmNotesPoint) point;
if (p.getAction() == a) {
sz.startTag("", "note");
sz.attribute("", "lat", p.getLatitude() + "");
sz.attribute("", "lon", p.getLongitude() + "");
sz.attribute("", "id", p.getId() + "");
sz.startTag("", "comment");
sz.attribute("", "text", p.getText() +"");
sz.endTag("", "comment");
sz.endTag("", "note");
}
}
}
}
@Override
protected void onPreExecute() {
getActivity().setProgressBarIndeterminateVisibility(true);
}
@Override
protected void onPostExecute(String result) {
getActivity().setProgressBarIndeterminateVisibility(false);
if (result != null) {
AccessibleToast.makeText(getActivity(), getString(R.string.local_osm_changes_backup_failed) + " " + result, Toast.LENGTH_LONG).show();
} else {
AccessibleToast.makeText(getActivity(), getString(R.string.local_osm_changes_backup_successful, osmchange.getAbsolutePath()), Toast.LENGTH_LONG).show();
}
}
}
@Override
public void uploadUpdated(OsmPoint point){
listAdapter.delete(point);
}
@Override
public void uploadEnded(Integer result){
listAdapter.notifyDataSetChanged();
if (result != null) {
AccessibleToast.makeText(getActivity(),
MessageFormat.format(getString(R.string.local_openstreetmap_were_uploaded), result), Toast.LENGTH_LONG)
.show();
}
dialog.dismiss();
}
} }

View file

@ -0,0 +1,12 @@
package net.osmand.plus.osmedit;
/**
* Created by Denis
* on 11.03.2015.
*/
public interface OsmEditsUploadListener {
public void uploadUpdated(OsmPoint point);
public void uploadEnded(Integer result);
}

View file

@ -0,0 +1,127 @@
package net.osmand.plus.osmedit;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.support.v4.app.Fragment;
import android.widget.Toast;
import net.osmand.access.AccessibleToast;
import net.osmand.osm.edit.EntityInfo;
import net.osmand.osm.edit.Node;
import net.osmand.plus.R;
import java.text.MessageFormat;
/**
* Created by Denis
* on 11.03.2015.
*/
public class UploadOpenstreetmapPointAsyncTask extends AsyncTask<OsmPoint, OsmPoint, Integer> {
private ProgressDialog progress;
private OpenstreetmapRemoteUtil remotepoi;
private OsmBugsRemoteUtil remotebug;
private OpenstreetmapsDbHelper dbpoi;
private OsmBugsDbHelper dbbug;
private int listSize = 0;
private boolean interruptUploading = false;
private Fragment ctx;
public UploadOpenstreetmapPointAsyncTask(ProgressDialog progress,Fragment ctx, OpenstreetmapRemoteUtil remotepoi, OsmBugsRemoteUtil remotebug,
int listSize) {
this.progress = progress;
this.remotepoi = remotepoi;
this.remotebug = remotebug;
this.listSize = listSize;
dbpoi = new OpenstreetmapsDbHelper(ctx.getActivity());
dbbug = new OsmBugsDbHelper(ctx.getActivity());
}
@Override
protected Integer doInBackground(OsmPoint... points) {
int uploaded = 0;
for (OsmPoint point : points) {
if (interruptUploading)
break;
if (point.getGroup() == OsmPoint.Group.POI) {
OpenstreetmapPoint p = (OpenstreetmapPoint) point;
EntityInfo entityInfo = null;
if (OsmPoint.Action.CREATE != p.getAction()) {
entityInfo = remotepoi.loadNode(p.getEntity());
}
Node n = remotepoi.commitNodeImpl(p.getAction(), p.getEntity(), entityInfo, p.getComment(), false);
if (n != null) {
dbpoi.deletePOI(p);
publishProgress(p);
uploaded++;
}
} else if (point.getGroup() == OsmPoint.Group.BUG) {
OsmNotesPoint p = (OsmNotesPoint) point;
boolean success = false;
if (p.getAction() == OsmPoint.Action.CREATE) {
success = remotebug.createNewBug(p.getLatitude(), p.getLongitude(), p.getText()) == null;
} else if (p.getAction() == OsmPoint.Action.MODIFY) {
success = remotebug.addingComment(p.getId(), p.getText()) == null;
} else if (p.getAction() == OsmPoint.Action.DELETE) {
success = remotebug.closingBug(p.getId(), p.getText()) == null;
}
if (success) {
dbbug.deleteAllBugModifications(p);
uploaded++;
publishProgress(p);
}
}
}
return uploaded;
}
@Override
protected void onPreExecute() {
interruptUploading = false;
progress.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
UploadOpenstreetmapPointAsyncTask.this.setInterruptUploading(true);
}
});
progress.setIndeterminate(false);
progress.setMax(listSize);
progress.setProgress(0);
}
@Override
protected void onPostExecute(Integer result) {
if (ctx instanceof OsmEditsUploadListener){
((OsmEditsUploadListener)ctx).uploadEnded(result);
}
}
public void setInterruptUploading(boolean b) {
interruptUploading = b;
}
@Override
protected void onProgressUpdate(OsmPoint... points) {
for(OsmPoint p : points) {
if (ctx instanceof OsmEditsUploadListener){
((OsmEditsUploadListener)ctx).uploadUpdated(p);
}
progress.incrementProgressBy(1);
}
}
}

View file

@ -1,22 +1,32 @@
package net.osmand.plus.osmo; package net.osmand.plus.osmo;
import net.osmand.plus.OsmandPlugin; import android.content.Intent;
import net.osmand.plus.R;
import net.osmand.plus.dashboard.DashBaseFragment;
import net.osmand.plus.helpers.FontCache;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.plus.IconsCache;
import net.osmand.plus.NavigationService;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.dashboard.DashBaseFragment;
import net.osmand.plus.helpers.FontCache;
/** /**
* Created by Denis * Created by Denis
* on 20.01.2015. * on 20.01.2015.
*/ */
public class DashOsmoFragment extends DashBaseFragment { public class DashOsmoFragment extends DashBaseFragment {
public static final String TAG = "DASH_OSMO_FRAGMENT";
OsMoPlugin plugin; OsMoPlugin plugin;
@Override @Override
@ -26,14 +36,105 @@ public class DashOsmoFragment extends DashBaseFragment {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_osmo_fragment, container, false); View view = getActivity().getLayoutInflater().inflate(R.layout.dash_osmo_fragment, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity()); Typeface typeface = FontCache.getRobotoMedium(getActivity());
((TextView) view.findViewById(R.id.osmo_text)).setTypeface(typeface); ((TextView) view.findViewById(R.id.osmo_text)).setTypeface(typeface);
Button manage = (Button) view.findViewById(R.id.manage); view.findViewById(R.id.manage).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), OsMoGroupsActivity.class);
getActivity().startActivity(intent);
}
});
setupHader(view);
return view; return view;
} }
@Override @Override
public void onOpenDash() { public void onOpenDash() {
plugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class); plugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class);
setupOsMoView();
}
private void setupOsMoView() {
View mainView = getView();
boolean show = plugin != null;
if (show) {
show = plugin.getService().isEnabled();
}
if (!show) {
mainView.setVisibility(View.GONE);
return;
} else {
mainView.setVisibility(View.VISIBLE);
}
updateStatus();
}
private void setupHader(final View header) {
CompoundButton trackr = (CompoundButton) header.findViewById(R.id.check_item);
final OsmandApplication app = getMyApplication();
trackr.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked) {
if (plugin != null && plugin.getTracker() != null){
plugin.getTracker().enableTracker();
}
app.startNavigationService(NavigationService.USED_BY_LIVE);
//interval setting not needed here, handled centrally in app.startNavigationService
//app.getSettings().SERVICE_OFF_INTERVAL.set(0);
} else {
if (plugin != null && plugin.getTracker() != null){
plugin.getTracker().disableTracker();
}
if (app.getNavigationService() != null) {
app.getNavigationService().stopIfNeeded(app,NavigationService.USED_BY_LIVE);
}
}
updateStatus();
}
});
ImageButton share = (ImageButton) header.findViewById(R.id.share);
IconsCache cache = getMyApplication().getIconsCache();
share.setImageDrawable(cache.getContentIcon(R.drawable.ic_action_gshare_dark));
share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
OsMoGroupsActivity.shareSessionUrl(plugin, getActivity());
}
});
updateStatus();
}
private void updateStatus(){
View header = getView();
if(getView() == null) {
return;
}
CompoundButton trackr = (CompoundButton) header.findViewById(R.id.check_item);
if(plugin != null && plugin.getTracker() != null){
trackr.setChecked(plugin.getTracker().isEnabledTracker());
}
}
private void synchronizeGroups(boolean clear){
View mainView = getView();
LinearLayout items = (LinearLayout) mainView.findViewById(R.id.items);
items.removeAllViews();
if (clear) {
return;
}
}
private void showProgress(boolean show) {
if (getView() != null){
getView().findViewById(R.id.progress).setVisibility(show ? View.VISIBLE : View.GONE);
}
} }
} }

View file

@ -3,21 +3,61 @@
*/ */
package net.osmand.plus.osmo; package net.osmand.plus.osmo;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.MenuItemCompat; import android.support.v4.view.MenuItemCompat;
import android.support.v7.view.ActionMode; import android.support.v7.view.ActionMode;
import android.view.*; import android.text.Spannable;
import gnu.trove.list.array.TIntArrayList; import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import java.text.Collator; import android.text.style.ForegroundColorSpan;
import java.util.ArrayList; import android.util.DisplayMetrics;
import java.util.Collections; import android.util.TypedValue;
import java.util.Comparator; import android.view.LayoutInflater;
import java.util.Date; import android.view.Menu;
import java.util.LinkedHashMap; import android.view.MenuItem;
import java.util.List; import android.view.MotionEvent;
import java.util.Map; import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.Location; import net.osmand.Location;
@ -38,53 +78,23 @@ import net.osmand.plus.activities.OsmandExpandableListActivity;
import net.osmand.plus.activities.actions.ShareDialog; import net.osmand.plus.activities.actions.ShareDialog;
import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.helpers.ColorDialogs; import net.osmand.plus.helpers.ColorDialogs;
import net.osmand.plus.helpers.ScreenOrientationHelper;
import net.osmand.plus.osmo.OsMoGroups.OsMoGroupsUIListener; import net.osmand.plus.osmo.OsMoGroups.OsMoGroupsUIListener;
import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice; import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice;
import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoGroup; import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoGroup;
import net.osmand.plus.osmo.OsMoService.SessionInfo; import net.osmand.plus.osmo.OsMoService.SessionInfo;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import android.annotation.SuppressLint;
import android.app.AlertDialog; import java.text.Collator;
import android.app.AlertDialog.Builder; import java.util.ArrayList;
import android.content.Context; import java.util.Collections;
import android.content.DialogInterface; import java.util.Comparator;
import android.content.DialogInterface.OnCancelListener; import java.util.Date;
import android.content.DialogInterface.OnClickListener; import java.util.LinkedHashMap;
import android.content.Intent; import java.util.List;
import android.graphics.Canvas; import java.util.Map;
import android.graphics.Color;
import android.graphics.ColorFilter; import gnu.trove.list.array.TIntArrayList;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Spannable;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ForegroundColorSpan;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
/** /**
* *
@ -433,31 +443,31 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
MenuItemCompat.SHOW_AS_ACTION_ALWAYS); MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
} }
if (device != null && device.getLastLocation() != null) { if (device != null && device.getLastLocation() != null) {
createMenuItem(menu, SHOW_ON_MAP_ID, R.string.shared_string_show_on_map, R.drawable.ic_action_marker_light, R.drawable.ic_action_marker_dark, createMenuItem(menu, SHOW_ON_MAP_ID, R.string.shared_string_show_on_map, R.drawable.ic_action_marker_dark,
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
} }
createMenuItem(menu, SHARE_ID, R.string.shared_string_share, R.drawable.ic_action_gshare_light, R.drawable.ic_action_gshare_dark, createMenuItem(menu, SHARE_ID, R.string.shared_string_share, R.drawable.ic_action_gshare_dark,
// there is a bug in Android 4.2 layout // there is a bug in Android 4.2 layout
device != null && device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER : MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); device != null && device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER : MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
/// ///
if (device != null) { if (device != null) {
createMenuItem(menu, SETTINGS_DEV_ID, R.string.shared_string_settings, R.drawable.ic_action_settings_enabled_light, R.drawable.ic_action_settings_enabled_dark, createMenuItem(menu, SETTINGS_DEV_ID, R.string.shared_string_settings, R.drawable.ic_action_settings_enabled_dark,
// there is a bug in Android 4.2 layout // there is a bug in Android 4.2 layout
device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER : MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER : MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
} }
if (device != null && device.getLastLocation() != null) { if (device != null && device.getLastLocation() != null) {
MenuItem menuItem = createMenuItem(menu, TRACK_DEV_ID, R.string.osmo_set_moving_target, R.drawable.ic_action_flage_light, R.drawable.ic_action_flage_dark, MenuItem menuItem = createMenuItem(menu, TRACK_DEV_ID, R.string.osmo_set_moving_target, R.drawable.ic_action_flage_dark,
// there is a bug in Android 4.2 layout // there is a bug in Android 4.2 layout
device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER : MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER : MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
menuItem.setTitleCondensed(getString(R.string.osmo_follow)); menuItem.setTitleCondensed(getString(R.string.osmo_follow));
} }
if (group != null) { if (group != null) {
createMenuItem(menu, GROUP_INFO, R.string.osmo_group_info, R.drawable.ic_action_info_light, R.drawable.ic_action_info_dark, createMenuItem(menu, GROUP_INFO, R.string.osmo_group_info, R.drawable.ic_action_info_dark,
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
} }
if ((group != null && !group.isMainGroup()) || (device != null && device.getGroup().isMainGroup())) { if ((group != null && !group.isMainGroup()) || (device != null && device.getGroup().isMainGroup())) {
createMenuItem(menu, DELETE_ACTION_ID, R.string.shared_string_delete, createMenuItem(menu, DELETE_ACTION_ID, R.string.shared_string_delete,
R.drawable.ic_action_delete_light, R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_dark,
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
} }
@ -664,7 +674,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if (which == 0) { if (which == 0) {
shareSessionUrl(); shareSessionUrl(osMoPlugin, OsMoGroupsActivity.this);
} else { } else {
OsMoService service = osMoPlugin.getService(); OsMoService service = osMoPlugin.getService();
SessionInfo ci = service.getCurrentSessionInfo(); SessionInfo ci = service.getCurrentSessionInfo();
@ -676,15 +686,15 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
bld.show(); bld.show();
} }
private void shareSessionUrl() { public static void shareSessionUrl(OsMoPlugin osMoPlugin, Activity ctx) {
String sessionURL = osMoPlugin.getTracker().getSessionURL(); String sessionURL = osMoPlugin.getTracker().getSessionURL();
if(sessionURL == null ) { if(sessionURL == null ) {
AccessibleToast.makeText(this, R.string.osmo_session_not_available, Toast.LENGTH_SHORT).show(); AccessibleToast.makeText(ctx, R.string.osmo_session_not_available, Toast.LENGTH_SHORT).show();
} else { } else {
ShareDialog dlg = new ShareDialog(this); ShareDialog dlg = new ShareDialog(ctx);
dlg.setTitle(getString(R.string.osmo_share_session)); dlg.setTitle(ctx.getString(R.string.osmo_share_session));
dlg.viewContent(sessionURL); dlg.viewContent(sessionURL);
dlg.shareURLOrText(sessionURL, getString(R.string.osmo_session_id_share, sessionURL), null); dlg.shareURLOrText(sessionURL, ctx.getString(R.string.osmo_session_id_share, sessionURL), null);
dlg.showDialog(); dlg.showDialog();
} }
} }
@ -850,7 +860,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
final EditText description = (EditText) v.findViewById(R.id.Description); final EditText description = (EditText) v.findViewById(R.id.Description);
final EditText name = (EditText) v.findViewById(R.id.Name); final EditText name = (EditText) v.findViewById(R.id.Name);
final CheckBox onlyByInvite = (CheckBox) v.findViewById(R.id.OnlyByInvite); final CheckBox onlyByInvite = (CheckBox) v.findViewById(R.id.OnlyByInvite);
final TextView warnCreate = (TextView) v.findViewById(R.id.osmo_group_create_info);
final TextView warnCreateDesc = (TextView) v.findViewById(R.id.osmo_group_create_dinfo); final TextView warnCreateDesc = (TextView) v.findViewById(R.id.osmo_group_create_dinfo);
View.OnClickListener click = new View.OnClickListener() { View.OnClickListener click = new View.OnClickListener() {
@ -860,7 +870,9 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
warnCreateDesc.setVisibility(vls == View.VISIBLE? View.GONE : View.VISIBLE); warnCreateDesc.setVisibility(vls == View.VISIBLE? View.GONE : View.VISIBLE);
} }
}; };
warnCreate.setOnClickListener(click); ImageButton info = (ImageButton) v.findViewById(R.id.info);
info.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_action_info_dark));
info.setOnClickListener(click);
warnCreateDesc.setOnClickListener(click); warnCreateDesc.setOnClickListener(click);
builder.setView(v); builder.setView(v);
@ -957,18 +969,26 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
menu.clear();
Menu oldMenu = menu;
boolean portrait = ScreenOrientationHelper.isOrientationPortrait(this);
if (portrait) {
menu = getClearToolbar(true).getMenu();
} else {
getClearToolbar(false);
}
createMenuItem(menu, CONNECT_TO, R.string.osmo_connect, createMenuItem(menu, CONNECT_TO, R.string.osmo_connect,
0, 0,/*R.drawable.ic_action_marker_light,*/ 0, 0,/*R.drawable.ic_action_marker_light,*/
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
createMenuItem(menu, SHARE_SESSION, R.string.osmo_share_session, createMenuItem(menu, SHARE_SESSION, R.string.osmo_share_session,
R.drawable.ic_action_gshare_dark, R.drawable.ic_action_gshare_dark, R.drawable.ic_action_gshare_dark,
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
createMenuItem(menu, CREATE_GROUP, R.string.osmo_create_group, createMenuItem(menu, CREATE_GROUP, R.string.osmo_create_group,
R.drawable.ic_action_plus_dark, R.drawable.ic_action_plus_dark, R.drawable.ic_group_add,
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
createMenuItem(menu, SETTINGS_ID, R.string.shared_string_settings, createMenuItem(oldMenu, SETTINGS_ID, R.string.shared_string_settings,
R.drawable.ic_action_settings_enabled_dark, R.drawable.ic_action_settings_enabled_dark, R.drawable.ic_action_settings_enabled_dark,
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
return super.onCreateOptionsMenu(menu); return super.onCreateOptionsMenu(menu);
} }
@ -1220,7 +1240,11 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
if(selectedObject == model) { if(selectedObject == model) {
row.setBackgroundColor(getResources().getColor(R.color.row_selection_color)); row.setBackgroundColor(getResources().getColor(R.color.row_selection_color));
} else { } else {
row.setBackgroundColor(Color.TRANSPARENT); if (app.getSettings().isLightContent()){
row.setBackgroundResource(R.drawable.expandable_list_item_background_light);
} else {
row.setBackgroundResource(R.drawable.expandable_list_item_background_dark);
}
} }
TextView label = (TextView) row.findViewById(R.id.osmo_label); TextView label = (TextView) row.findViewById(R.id.osmo_label);
TextView labelTime = (TextView) row.findViewById(R.id.osmo_label_time); TextView labelTime = (TextView) row.findViewById(R.id.osmo_label_time);

View file

@ -2,26 +2,23 @@ package net.osmand.plus.parkingpoint;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.graphics.Color;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.util.TimeUtils;
import android.text.format.DateFormat;
import android.text.format.DateUtils;
import android.text.format.Time;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.Location;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.OsmAndFormatter; import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashLocationFragment; import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.helpers.FontCache; import net.osmand.plus.helpers.FontCache;
import net.osmand.util.MapUtils;
import java.util.Calendar; import java.util.Calendar;
@ -52,6 +49,16 @@ public class DashParkingFragment extends DashLocationFragment {
}); });
remove.setTypeface(typeface); remove.setTypeface(typeface);
view.findViewById(R.id.parking_header).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LatLon point = plugin.getParkingPosition();
getMyApplication().getSettings().setMapLocationToShow(point.getLatitude(), point.getLongitude(),
15, new PointDescription(PointDescription.POINT_TYPE_FAVORITE, plugin.getParkingDescription(getActivity())), true,
point); //$NON-NLS-1$
MapActivity.launchMapActivityMoveToTop(getActivity());
}
});
return view; return view;
} }
@ -75,29 +82,41 @@ public class DashParkingFragment extends DashLocationFragment {
LatLon loc = getDefaultLocation(); LatLon loc = getDefaultLocation();
LatLon position = plugin.getParkingPosition(); LatLon position = plugin.getParkingPosition();
boolean limited = plugin.getParkingType(); boolean limited = plugin.getParkingType();
String parking_name = limited ? String parking_name = limited ?
getString(R.string.parking_place_limited) : getString(R.string.parking_place); getString(R.string.parking_place_limited) : getString(R.string.parking_place);
if (limited) { if (limited) {
long endtime = plugin.getParkingTime(); long endtime = plugin.getParkingTime();
long currTime = Calendar.getInstance().getTimeInMillis(); long currTime = Calendar.getInstance().getTimeInMillis();
String time = getFormattedTime(endtime - currTime); long timeDiff = endtime - currTime;
((TextView)mainView.findViewById(R.id.time_left)).setText(time); String time = getFormattedTime(timeDiff);
TextView timeLeft = (TextView) mainView.findViewById(R.id.time_left);
TextView leftLabel = (TextView) mainView.findViewById(R.id.left_lbl);
timeLeft.setText(time);
if (timeDiff < 0) {
timeLeft.setTextColor(Color.RED);
leftLabel.setTextColor(Color.RED);
leftLabel.setText(R.string.osmand_parking_outdated);
} else {
timeLeft.setTextColor(Color.WHITE);
leftLabel.setTextColor(Color.WHITE);
leftLabel.setText(R.string.osmand_parking_time_left);
}
mainView.findViewById(R.id.left_lbl).setVisibility(View.VISIBLE); mainView.findViewById(R.id.left_lbl).setVisibility(View.VISIBLE);
} else { } else {
((TextView)mainView.findViewById(R.id.time_left)).setText(""); ((TextView) mainView.findViewById(R.id.time_left)).setText("");
mainView.findViewById(R.id.left_lbl).setVisibility(View.GONE); mainView.findViewById(R.id.left_lbl).setVisibility(View.GONE);
} }
((TextView) mainView.findViewById(R.id.name)).setText(parking_name); ((TextView) mainView.findViewById(R.id.name)).setText(parking_name);
ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon); ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon);
if (loc != null){ if (loc != null) {
DashLocationView dv = new DashLocationView(direction, (TextView) mainView.findViewById(R.id.distance), position); DashLocationView dv = new DashLocationView(direction, (TextView) mainView.findViewById(R.id.distance), position);
dv.paint = false;
dv.arrowResId = R.drawable.ic_parking_postion_arrow; dv.arrowResId = R.drawable.ic_parking_postion_arrow;
distances.add(dv); distances.add(dv);
} }
} }
String getFormattedTime(long timeInMillis) { String getFormattedTime(long timeInMillis) {
@ -106,16 +125,20 @@ public class DashParkingFragment extends DashLocationFragment {
} }
StringBuilder timeStringBuilder = new StringBuilder(); StringBuilder timeStringBuilder = new StringBuilder();
int hours = (int) timeInMillis / (1000 * 60 * 60); int hours = (int) timeInMillis / (1000 * 60 * 60);
int miutes = (int) timeInMillis / (1000 * 60 * 60 * 60); int minMills = (int) timeInMillis % (1000 * 60 * 60);
int minutes = minMills / (1000 * 60);
if (hours > 0) { if (hours > 0) {
timeStringBuilder.append(hours); timeStringBuilder.append(hours);
timeStringBuilder.append(" "); timeStringBuilder.append(" ");
timeStringBuilder.append(getResources().getString(R.string.osmand_parking_hour)); timeStringBuilder.append(getResources().getString(R.string.osmand_parking_hour));
} }
timeStringBuilder.append(" "); timeStringBuilder.append(" ");
timeStringBuilder.append(miutes); timeStringBuilder.append(minutes);
timeStringBuilder.append(" "); timeStringBuilder.append(" ");
timeStringBuilder.append(getResources().getString(R.string.osmand_parking_minute)); timeStringBuilder.append(getResources().getString(R.string.osmand_parking_minute));
return timeStringBuilder.toString(); return timeStringBuilder.toString();
} }
} }

View file

@ -136,45 +136,12 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
@Override @Override
public String getObjectDescription(Object o) { public String getObjectDescription(Object o) {
if (o instanceof LatLon) { return plugin.getParkingDescription(map);
StringBuilder timeLimitDesc = new StringBuilder();
timeLimitDesc.append(map.getString(R.string.osmand_parking_position_description_add_time) + " ");
timeLimitDesc.append(getFormattedTime(plugin.getStartParkingTime()) + ".");
if (plugin.getParkingType()) {
// long parkingTime = settings.getParkingTime();
// long parkingStartTime = settings.getStartParkingTime();
// Time time = new Time();
// time.set(parkingTime);
// timeLimitDesc.append(map.getString(R.string.osmand_parking_position_description_add) + " ");
// timeLimitDesc.append(time.hour);
// timeLimitDesc.append(":");
// int minute = time.minute;
// timeLimitDesc.append(minute<10 ? "0" + minute : minute);
// if (!DateFormat.is24HourFormat(map.getApplicationContext())) {
// timeLimitDesc.append(time.hour >= 12 ? map.getString(R.string.osmand_parking_pm) :
// map.getString(R.string.osmand_parking_am));
// }
timeLimitDesc.append(map.getString(R.string.osmand_parking_position_description_add) + " ");
timeLimitDesc.append(getFormattedTime(plugin.getParkingTime()));
}
return map.getString(R.string.osmand_parking_position_description, timeLimitDesc.toString());
}
return null;
} }
String getFormattedTime(long timeInMillis) { public String getFormattedTime(long time){
StringBuilder timeStringBuilder = new StringBuilder(); return plugin.getFormattedTime(time, map);
Time time = new Time();
time.set(timeInMillis);
timeStringBuilder.append(time.hour);
timeStringBuilder.append(":");
int minute = time.minute;
timeStringBuilder.append(minute < 10 ? "0" + minute : minute);
if (!DateFormat.is24HourFormat(map)) {
timeStringBuilder.append(time.hour >= 12 ? map.getString(R.string.osmand_parking_pm) : map
.getString(R.string.osmand_parking_am));
}
return timeStringBuilder.toString();
} }
@Override @Override

View file

@ -27,6 +27,8 @@ import android.app.Dialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.Paint; import android.graphics.Paint;
import android.text.format.DateFormat;
import android.text.format.Time;
import android.view.View; import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.CheckBox; import android.widget.CheckBox;
@ -524,4 +526,43 @@ public class ParkingPositionPlugin extends OsmandPlugin {
public int getLogoResourceId() { public int getLogoResourceId() {
return R.drawable.ic_action_parking_dark; return R.drawable.ic_action_parking_dark;
} }
String getFormattedTime(long timeInMillis, Activity ctx) {
StringBuilder timeStringBuilder = new StringBuilder();
Time time = new Time();
time.set(timeInMillis);
timeStringBuilder.append(time.hour);
timeStringBuilder.append(":");
int minute = time.minute;
timeStringBuilder.append(minute < 10 ? "0" + minute : minute);
if (!DateFormat.is24HourFormat(ctx)) {
timeStringBuilder.append(time.hour >= 12 ? ctx.getString(R.string.osmand_parking_pm) : ctx
.getString(R.string.osmand_parking_am));
}
return timeStringBuilder.toString();
}
public String getParkingDescription(Activity ctx) {
StringBuilder timeLimitDesc = new StringBuilder();
timeLimitDesc.append(ctx.getString(R.string.osmand_parking_position_description_add_time) + " ");
timeLimitDesc.append(getFormattedTime(getStartParkingTime(), ctx) + ".");
if (getParkingType()) {
// long parkingTime = settings.getParkingTime();
// long parkingStartTime = settings.getStartParkingTime();
// Time time = new Time();
// time.set(parkingTime);
// timeLimitDesc.append(map.getString(R.string.osmand_parking_position_description_add) + " ");
// timeLimitDesc.append(time.hour);
// timeLimitDesc.append(":");
// int minute = time.minute;
// timeLimitDesc.append(minute<10 ? "0" + minute : minute);
// if (!DateFormat.is24HourFormat(map.getApplicationContext())) {
// timeLimitDesc.append(time.hour >= 12 ? map.getString(R.string.osmand_parking_pm) :
// map.getString(R.string.osmand_parking_am));
// }
timeLimitDesc.append(ctx.getString(R.string.osmand_parking_position_description_add) + " ");
timeLimitDesc.append(getFormattedTime(getParkingTime(),ctx));
}
return ctx.getString(R.string.osmand_parking_position_description, timeLimitDesc.toString());
}
} }

View file

@ -33,6 +33,11 @@ public class DirectionDrawable extends Drawable {
arrowImage = iconsCache.getIcon(resourceId, clrId); arrowImage = iconsCache.getIcon(resourceId, clrId);
} }
public void setImage(int resourceId){
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache();
arrowImage = iconsCache.getIcon(resourceId, 0);
}
public DirectionDrawable(Context ctx, float width, float height) { public DirectionDrawable(Context ctx, float width, float height) {
this.ctx = ctx; this.ctx = ctx;

View file

@ -1,197 +0,0 @@
package net.osmand.plus.views.controls;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.OvershootInterpolator;
import android.widget.FrameLayout;
/*
* Created by John Hogan
* https://gist.github.com/Jogan/9def6110edf3247825c9
*/
@SuppressLint("NewApi")
public class FloatingActionButton extends View {
final static OvershootInterpolator overshootInterpolator = new OvershootInterpolator();
final static AccelerateInterpolator accelerateInterpolator = new AccelerateInterpolator();
Context context;
Paint mButtonPaint;
Paint mDrawablePaint;
Bitmap mBitmap;
boolean mHidden = false;
public FloatingActionButton(Context context) {
super(context);
this.context = context;
init(Color.WHITE);
}
public void setFloatingActionButtonColor(int FloatingActionButtonColor) {
init(FloatingActionButtonColor);
}
public void setFloatingActionButtonDrawable(Drawable FloatingActionButtonDrawable) {
mBitmap = ((BitmapDrawable) FloatingActionButtonDrawable).getBitmap();
invalidate();
}
public void init(int FloatingActionButtonColor) {
setWillNotDraw(false);
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
mButtonPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mButtonPaint.setColor(FloatingActionButtonColor);
mButtonPaint.setStyle(Paint.Style.FILL);
mButtonPaint.setShadowLayer(10.0f, 0.0f, 3.5f, Color.argb(100, 0, 0, 0));
mDrawablePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
invalidate();
}
@Override
protected void onDraw(Canvas canvas) {
setClickable(true);
canvas.drawCircle(getWidth() / 2, getHeight() / 2, (float) (getWidth() / 2.6), mButtonPaint);
canvas.drawBitmap(mBitmap, (getWidth() - mBitmap.getWidth()) / 2,
(getHeight() - mBitmap.getHeight()) / 2, mDrawablePaint);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
setAlpha(1.0f);
} else if (event.getAction() == MotionEvent.ACTION_DOWN) {
setAlpha(0.6f);
}
return super.onTouchEvent(event);
}
public void hideFloatingActionButton() {
if (!mHidden) {
ObjectAnimator scaleX = ObjectAnimator.ofFloat(this, "scaleX", 1, 0);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(this, "scaleY", 1, 0);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.playTogether(scaleX, scaleY);
animSetXY.setInterpolator(accelerateInterpolator);
animSetXY.setDuration(100);
animSetXY.start();
mHidden = true;
setVisibility(View.GONE);
}
}
public void showFloatingActionButton() {
if (mHidden) {
ObjectAnimator scaleX = ObjectAnimator.ofFloat(this, "scaleX", 0, 1);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(this, "scaleY", 0, 1);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.playTogether(scaleX, scaleY);
animSetXY.setInterpolator(overshootInterpolator);
animSetXY.setDuration(200);
animSetXY.start();
mHidden = false;
setVisibility(View.VISIBLE);
}
}
public boolean isHidden() {
return mHidden;
}
static public class Builder {
private FrameLayout.LayoutParams params;
private final Activity activity;
int gravity = Gravity.BOTTOM | Gravity.RIGHT; // default bottom right
Drawable drawable;
int color = Color.WHITE;
int size = 0;
float scale = 0;
public Builder(Activity context) {
scale = context.getResources().getDisplayMetrics().density;
size = convertToPixels(72, scale); // default size is 72dp by 72dp
params = new FrameLayout.LayoutParams(size, size);
params.gravity = gravity;
this.activity = context;
}
/**
* Sets the gravity for the FAB
*/
public Builder withGravity(int gravity) {
this.gravity = gravity;
return this;
}
/**
* Sets the margins for the FAB in dp
*/
public Builder withMargins(int left, int top, int right, int bottom) {
params.setMargins(
convertToPixels(left, scale),
convertToPixels(top, scale),
convertToPixels(right, scale),
convertToPixels(bottom, scale));
return this;
}
/**
* Sets the FAB drawable
*/
public Builder withDrawable(final Drawable drawable) {
this.drawable = drawable;
return this;
}
/**
* Sets the FAB color
*/
public Builder withButtonColor(final int color) {
this.color = color;
return this;
}
/**
* Sets the FAB size in dp
*/
public Builder withButtonSize(int size) {
size = convertToPixels(size, scale);
params = new FrameLayout.LayoutParams(size, size);
return this;
}
public FloatingActionButton create() {
final FloatingActionButton button = new FloatingActionButton(activity);
button.setFloatingActionButtonColor(this.color);
button.setFloatingActionButtonDrawable(this.drawable);
params.gravity = this.gravity;
ViewGroup root = (ViewGroup) activity.findViewById(android.R.id.content);
root.addView(button, params);
return button;
}
// The calculation (value * scale + 0.5f) is a widely used to convert to dps to pixel units
// based on density scale
// see developer.android.com (Supporting Multiple Screen Sizes)
private int convertToPixels(int dp, float scale){
return (int) (dp * scale + 0.5f) ;
}
}
}