Merge branch 'master' into app_profiles_2
|
@ -35,12 +35,20 @@
|
||||||
android:layout_marginStart="@dimen/list_item_icon_margin_left"
|
android:layout_marginStart="@dimen/list_item_icon_margin_left"
|
||||||
tools:src="@drawable/img_user_picture"/>
|
tools:src="@drawable/img_user_picture"/>
|
||||||
|
|
||||||
<LinearLayout
|
<FrameLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="@dimen/content_padding_standard"
|
android:layout_marginEnd="@dimen/content_padding_standard"
|
||||||
android:layout_marginRight="@dimen/content_padding_standard"
|
android:layout_marginRight="@dimen/content_padding_standard"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:minHeight="@dimen/list_item_height"
|
||||||
|
android:paddingTop="@dimen/content_padding_half"
|
||||||
|
android:paddingBottom="@dimen/content_padding_half">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<net.osmand.telegram.ui.views.TextViewEx
|
<net.osmand.telegram.ui.views.TextViewEx
|
||||||
|
@ -51,7 +59,6 @@
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
android:textSize="@dimen/list_item_title_text_size"
|
android:textSize="@dimen/list_item_title_text_size"
|
||||||
android:paddingTop="@dimen/content_padding_half"
|
|
||||||
app:typeface="@string/font_roboto_regular"
|
app:typeface="@string/font_roboto_regular"
|
||||||
tools:text="Share location"/>
|
tools:text="Share location"/>
|
||||||
|
|
||||||
|
@ -117,7 +124,6 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:paddingBottom="@dimen/content_padding_half"
|
|
||||||
tools:visibility="visible">
|
tools:visibility="visible">
|
||||||
|
|
||||||
<net.osmand.telegram.ui.views.TextViewEx
|
<net.osmand.telegram.ui.views.TextViewEx
|
||||||
|
@ -137,6 +143,8 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/check_box"
|
android:id="@+id/check_box"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
@ -64,11 +64,13 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
|
||||||
if (usedBy and usageIntent > 0) {
|
if (usedBy and usageIntent > 0) {
|
||||||
usedBy -= usageIntent
|
usedBy -= usageIntent
|
||||||
}
|
}
|
||||||
if (usedBy == 0) {
|
when {
|
||||||
|
usedBy == 0 -> {
|
||||||
shouldCleanupResources = false
|
shouldCleanupResources = false
|
||||||
val serviceIntent = Intent(ctx, TelegramService::class.java)
|
val serviceIntent = Intent(ctx, TelegramService::class.java)
|
||||||
ctx.stopService(serviceIntent)
|
ctx.stopService(serviceIntent)
|
||||||
} else if (isUsedByMyLocation(usedBy)) {
|
}
|
||||||
|
isUsedByMyLocation(usedBy) -> {
|
||||||
val app = app()
|
val app = app()
|
||||||
if (app.settings.sendMyLocInterval >= OFF_INTERVAL_THRESHOLD && serviceOffInterval == 0L) {
|
if (app.settings.sendMyLocInterval >= OFF_INTERVAL_THRESHOLD && serviceOffInterval == 0L) {
|
||||||
serviceOffInterval = app.settings.sendMyLocInterval
|
serviceOffInterval = app.settings.sendMyLocInterval
|
||||||
|
@ -77,12 +79,15 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
|
||||||
}
|
}
|
||||||
app.notificationHelper.refreshNotification(NotificationType.LOCATION)
|
app.notificationHelper.refreshNotification(NotificationType.LOCATION)
|
||||||
}
|
}
|
||||||
|
isUsedByUsersLocations(usedBy) -> removeLocationUpdates()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
||||||
val app = app()
|
val app = app()
|
||||||
handler = Handler()
|
handler = Handler()
|
||||||
usedBy = intent.getIntExtra(USAGE_INTENT, 0)
|
val usageIntent = intent.getIntExtra(USAGE_INTENT, 0)
|
||||||
|
usedBy = usageIntent or usedBy
|
||||||
|
|
||||||
serviceOffInterval = intent.getLongExtra(USAGE_OFF_INTERVAL, 0)
|
serviceOffInterval = intent.getLongExtra(USAGE_OFF_INTERVAL, 0)
|
||||||
sendLocationInterval = intent.getLongExtra(SEND_LOCATION_INTERVAL, 0)
|
sendLocationInterval = intent.getLongExtra(SEND_LOCATION_INTERVAL, 0)
|
||||||
|
@ -259,10 +264,8 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
|
||||||
Toast.makeText(this, getString(R.string.location_service_no_gps_available), Toast.LENGTH_LONG).show()
|
Toast.makeText(this, getString(R.string.location_service_no_gps_available), Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onProviderEnabled(provider: String) {}
|
override fun onProviderEnabled(provider: String) {}
|
||||||
|
|
||||||
|
|
||||||
override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {}
|
override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {}
|
||||||
|
|
||||||
override fun onTaskRemoved(rootIntent: Intent) {
|
override fun onTaskRemoved(rootIntent: Intent) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ private const val TIMELINE_TAB_POS = 2
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListener, TelegramIncomingMessagesListener {
|
class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListener, TelegramIncomingMessagesListener {
|
||||||
|
|
||||||
private val log = PlatformUtil.getLog(TelegramHelper::class.java)
|
private val log = PlatformUtil.getLog(MainActivity::class.java)
|
||||||
|
|
||||||
private var telegramAuthorizationRequestHandler: TelegramAuthorizationRequestHandler? = null
|
private var telegramAuthorizationRequestHandler: TelegramAuthorizationRequestHandler? = null
|
||||||
private var paused: Boolean = false
|
private var paused: Boolean = false
|
||||||
|
|
4
OsmAnd/res/color-v21/dlg_btn_secondary_text_dark.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:color="@color/active_buttons_and_links_text_disabled_dark" android:state_enabled="false" />
|
||||||
|
<item android:color="@color/active_buttons_and_links_dark" />
|
||||||
|
</selector>
|
4
OsmAnd/res/color-v21/dlg_btn_secondary_text_light.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:color="@color/active_buttons_and_links_text_disabled_light" android:state_enabled="false" />
|
||||||
|
<item android:color="@color/active_buttons_and_links_light" />
|
||||||
|
</selector>
|
5
OsmAnd/res/color/dlg_btn_primary_text_dark.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:color="@color/active_buttons_and_links_text_dark" android:state_pressed="true" />
|
||||||
|
<item android:color="@color/active_buttons_and_links_text_disabled_dark" android:state_enabled="false" />
|
||||||
|
<item android:color="@color/active_buttons_and_links_text_dark" />
|
||||||
|
</selector>
|
5
OsmAnd/res/color/dlg_btn_primary_text_light.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:color="@color/active_buttons_and_links_text_light" android:state_pressed="true" />
|
||||||
|
<item android:color="@color/active_buttons_and_links_text_disabled_light" android:state_enabled="false" />
|
||||||
|
<item android:color="@color/active_buttons_and_links_text_light" />
|
||||||
|
</selector>
|
5
OsmAnd/res/color/dlg_btn_secondary_text_dark.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:color="@color/active_buttons_and_links_text_dark" android:state_pressed="true" />
|
||||||
|
<item android:color="@color/active_buttons_and_links_text_disabled_dark" android:state_enabled="false" />
|
||||||
|
<item android:color="@color/active_buttons_and_links_dark" />
|
||||||
|
</selector>
|
5
OsmAnd/res/color/dlg_btn_secondary_text_light.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:color="@color/active_buttons_and_links_text_light" android:state_pressed="true" />
|
||||||
|
<item android:color="@color/active_buttons_and_links_text_disabled_light" android:state_enabled="false" />
|
||||||
|
<item android:color="@color/active_buttons_and_links_light" />
|
||||||
|
</selector>
|
BIN
OsmAnd/res/drawable-hdpi/img_crash.webp
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
OsmAnd/res/drawable-hdpi/img_feedback.webp
Normal file
After Width: | Height: | Size: 4 KiB |
BIN
OsmAnd/res/drawable-hdpi/img_rate_us.webp
Normal file
After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 5 KiB After Width: | Height: | Size: 7.4 KiB |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 7.3 KiB |
BIN
OsmAnd/res/drawable-mdpi/img_crash.webp
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
OsmAnd/res/drawable-mdpi/img_feedback.webp
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
OsmAnd/res/drawable-mdpi/img_rate_us.webp
Normal file
After Width: | Height: | Size: 2.9 KiB |
13
OsmAnd/res/drawable-v21/dlg_btn_primary_dark.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:state_enabled="false"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/inactive_buttons_and_links_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/active_buttons_and_links_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
|
||||||
|
</selector>
|
13
OsmAnd/res/drawable-v21/dlg_btn_primary_light.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:state_enabled="false"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/inactive_buttons_and_links_light" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/active_buttons_and_links_light" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
|
||||||
|
</selector>
|
13
OsmAnd/res/drawable-v21/dlg_btn_secondary_dark.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:state_enabled="false"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/inactive_buttons_and_links_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/inactive_buttons_and_links_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
|
||||||
|
</selector>
|
13
OsmAnd/res/drawable-v21/dlg_btn_secondary_light.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:state_enabled="false"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/inactive_buttons_and_links_light" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/profile_button_gray" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
|
||||||
|
</selector>
|
24
OsmAnd/res/drawable-v21/dlg_btn_stroked_dark.xml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:state_pressed="true">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<stroke android:width="1dp" android:color="@color/active_buttons_and_links_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item android:state_enabled="false">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/inactive_buttons_and_links_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<stroke android:width="1dp" android:color="@color/inactive_pages_dark" />
|
||||||
|
<solid android:color="@color/stroked_buttons_and_links_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
</selector>
|
23
OsmAnd/res/drawable-v21/dlg_btn_stroked_light.xml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_pressed="true">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<stroke android:width="1dp" android:color="@color/active_buttons_and_links_light" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item android:state_enabled="false">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/inactive_buttons_and_links_light" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<stroke android:width="1dp" android:color="@color/profile_button_gray" />
|
||||||
|
<solid android:color="@color/stroked_buttons_and_links_light" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
</selector>
|
BIN
OsmAnd/res/drawable-xhdpi/img_crash.webp
Normal file
After Width: | Height: | Size: 8.4 KiB |
BIN
OsmAnd/res/drawable-xhdpi/img_feedback.webp
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
OsmAnd/res/drawable-xhdpi/img_rate_us.webp
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/img_crash.webp
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/img_feedback.webp
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/img_rate_us.webp
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
OsmAnd/res/drawable-xxxhdpi/img_crash.webp
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
OsmAnd/res/drawable-xxxhdpi/img_feedback.webp
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
OsmAnd/res/drawable-xxxhdpi/img_rate_us.webp
Normal file
After Width: | Height: | Size: 22 KiB |
|
@ -8,7 +8,7 @@
|
||||||
</item>
|
</item>
|
||||||
<item android:state_enabled="false">
|
<item android:state_enabled="false">
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<solid android:color="@color/activity_background_dark" />
|
<solid android:color="@color/card_and_list_background_dark" />
|
||||||
<corners android:radius="4dp" />
|
<corners android:radius="4dp" />
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<solid android:color="@null" />
|
<solid android:color="@null" />
|
||||||
<corners android:radius="4dp" />
|
<corners android:radius="4dp" />
|
||||||
<stroke android:width="1dp" android:color="@color/divider_dark" />
|
<stroke android:width="1dp" android:color="@color/inactive_pages_dark" />
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
</selector>
|
</selector>
|
|
@ -16,7 +16,7 @@
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<solid android:color="@null" />
|
<solid android:color="@null" />
|
||||||
<corners android:radius="4dp" />
|
<corners android:radius="4dp" />
|
||||||
<stroke android:width="1dp" android:color="@color/divider_light" />
|
<stroke android:width="1dp" android:color="@color/profile_button_gray" />
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
</selector>
|
</selector>
|
17
OsmAnd/res/drawable/dlg_btn_primary_dark.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:state_pressed="true"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/active_buttons_and_links_pressed_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item android:state_enabled="false"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/inactive_buttons_and_links_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/active_buttons_and_links_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
|
||||||
|
</selector>
|
16
OsmAnd/res/drawable/dlg_btn_primary_light.xml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_pressed="true"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/active_buttons_and_links_pressed_light" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item android:state_enabled="false"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/inactive_buttons_and_links_light" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/active_buttons_and_links_light" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
|
||||||
|
</selector>
|
17
OsmAnd/res/drawable/dlg_btn_secondary_dark.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:state_pressed="true"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/active_buttons_and_links_pressed_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item android:state_enabled="false"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/inactive_buttons_and_links_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/inactive_buttons_and_links_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
|
||||||
|
</selector>
|
17
OsmAnd/res/drawable/dlg_btn_secondary_light.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:state_pressed="true"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/active_buttons_and_links_pressed_light" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item android:state_enabled="false"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/inactive_buttons_and_links_light" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/profile_button_gray" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
|
||||||
|
</selector>
|
18
OsmAnd/res/drawable/dlg_btn_stroked_dark.xml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:state_pressed="true"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/active_buttons_and_links_pressed_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item android:state_enabled="false"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/inactive_buttons_and_links_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item><shape android:shape="rectangle">
|
||||||
|
<stroke android:color="@color/inactive_pages_dark" android:width="1dp" />
|
||||||
|
<solid android:color="@color/stroked_buttons_and_links_dark" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
|
||||||
|
</selector>
|
18
OsmAnd/res/drawable/dlg_btn_stroked_light.xml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:state_pressed="true"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/active_buttons_and_links_pressed_light" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item android:state_enabled="false"><shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/inactive_buttons_and_links_light" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
<item><shape android:shape="rectangle">
|
||||||
|
<stroke android:color="@color/profile_button_gray" android:width="1dp" />
|
||||||
|
<solid android:color="@color/stroked_buttons_and_links_light" />
|
||||||
|
<corners android:radius="@dimen/dlg_button_rect_rad" />
|
||||||
|
</shape></item>
|
||||||
|
|
||||||
|
</selector>
|
|
@ -2,7 +2,7 @@
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item>
|
<item>
|
||||||
<shape android:shape="oval">
|
<shape android:shape="oval">
|
||||||
<solid android:color="@color/inactive_buttons_and_links_dark"/>
|
<solid android:color="@color/inactive_pages_dark"/>
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
</layer-list>
|
</layer-list>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item>
|
<item>
|
||||||
<shape android:shape="oval">
|
<shape android:shape="oval">
|
||||||
<solid android:color="@color/inactive_buttons_and_links_light"/>
|
<solid android:color="@color/inactive_pages_light"/>
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
</layer-list>
|
</layer-list>
|
||||||
|
|
9
OsmAnd/res/drawable/ripple_solid_dark.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:color="@color/solid_ripple_color">
|
||||||
|
<item android:id="@android:id/mask">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/active_buttons_and_links_dark" />
|
||||||
|
<corners android:radius="4dp" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</ripple>
|
9
OsmAnd/res/drawable/ripple_solid_light.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:color="@color/solid_ripple_color">
|
||||||
|
<item android:id="@android:id/mask">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/active_buttons_and_links_light" />
|
||||||
|
<corners android:radius="4dp" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</ripple>
|
29
OsmAnd/res/layout/bottom_sheet_dialog_button.xml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/button_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:ignore="UselessParent">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/button_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="@dimen/content_padding_small"
|
||||||
|
android:paddingRight="@dimen/content_padding_small"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:text="Button" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -1,7 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -17,8 +15,7 @@
|
||||||
android:id="@+id/scrollable_items_container"
|
android:id="@+id/scrollable_items_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical" />
|
||||||
android:paddingBottom="@dimen/bottom_sheet_content_padding_small"/>
|
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
@ -29,66 +26,31 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/bottom_row_divider"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:background="?attr/dashboard_divider"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/buttons_container"
|
android:id="@+id/buttons_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/bottom_sheet_cancel_button_height">
|
android:layout_height="@dimen/dialog_button_ex_height"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/content_padding">
|
||||||
|
|
||||||
<FrameLayout
|
<include
|
||||||
android:id="@+id/dismiss_button"
|
android:id="@+id/dismiss_button"
|
||||||
android:layout_width="0dp"
|
layout="@layout/bottom_sheet_dialog_button" />
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="?attr/selectableItemBackground">
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
|
||||||
android:id="@+id/dismiss_button_text"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:textAllCaps="true"
|
|
||||||
android:textColor="?attr/color_dialog_buttons"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:text="Cancel"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/bottom_buttons_divider"
|
android:id="@+id/buttons_divider"
|
||||||
android:layout_width="1dp"
|
android:layout_width="@dimen/content_padding"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/dashboard_divider"
|
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<FrameLayout
|
<include
|
||||||
android:id="@+id/right_bottom_button"
|
android:id="@+id/right_bottom_button"
|
||||||
android:layout_width="0dp"
|
layout="@layout/bottom_sheet_dialog_button"
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible">
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
|
||||||
android:id="@+id/right_bottom_button_text"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:textAllCaps="true"
|
|
||||||
android:textColor="?attr/color_dialog_buttons"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:text="Some Action"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/profile_settings"
|
android:id="@+id/profile_settings"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/setting_profile_item_height"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:descendantFocusability="blocksDescendants"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
@ -12,25 +13,24 @@
|
||||||
android:id="@+id/icon"
|
android:id="@+id/icon"
|
||||||
android:layout_width="@dimen/standard_icon_size"
|
android:layout_width="@dimen/standard_icon_size"
|
||||||
android:layout_height="@dimen/standard_icon_size"
|
android:layout_height="@dimen/standard_icon_size"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
android:layout_marginRight="@dimen/setting_profile_image_margin"
|
android:layout_marginRight="@dimen/favorites_icon_right_margin"
|
||||||
tools:src="@drawable/ic_action_bicycle_dark" />
|
tools:src="@drawable/ic_action_bicycle_dark" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="63dp"
|
android:layout_height="@dimen/setting_profile_item_height"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="3"
|
android:layout_weight="1"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:maxLines="2"
|
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
android:textColor="@color/main_font_dark"
|
android:textColor="@color/main_font_dark"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
tools:text="Bicycle" />
|
tools:text="Bicycle" />
|
||||||
|
@ -48,26 +48,26 @@
|
||||||
android:id="@+id/description"
|
android:id="@+id/description"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
tools:text="Type: Bicycle" />
|
tools:text="Type: Bicycle" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<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:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<android.support.v7.widget.AppCompatImageView
|
||||||
android:id="@+id/menu_image"
|
android:id="@+id/menu_image"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingTop="@dimen/setting_profile_item_switch_margin"
|
|
||||||
android:paddingBottom="@dimen/setting_profile_item_switch_margin"
|
|
||||||
android:paddingStart="@dimen/setting_profile_item_switch_margin"
|
android:paddingStart="@dimen/setting_profile_item_switch_margin"
|
||||||
android:paddingEnd="10dp"
|
|
||||||
android:paddingLeft="@dimen/setting_profile_item_switch_margin"
|
android:paddingLeft="@dimen/setting_profile_item_switch_margin"
|
||||||
|
android:paddingEnd="10dp"
|
||||||
android:paddingRight="10dp"
|
android:paddingRight="10dp"
|
||||||
android:src="@drawable/ic_action_additional_option"
|
android:src="@drawable/ic_action_additional_option"
|
||||||
android:tint="?attr/primary_icon_color" />
|
android:tint="?attr/primary_icon_color" />
|
||||||
|
@ -75,20 +75,13 @@
|
||||||
<android.support.v7.widget.SwitchCompat
|
<android.support.v7.widget.SwitchCompat
|
||||||
android:id="@+id/compound_button"
|
android:id="@+id/compound_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical|end"
|
android:layout_gravity="center_vertical|end"
|
||||||
android:paddingTop="@dimen/setting_profile_item_switch_margin"
|
|
||||||
android:paddingBottom="@dimen/setting_profile_item_switch_margin"
|
|
||||||
android:paddingStart="16dp"
|
|
||||||
android:paddingEnd="16dp"
|
|
||||||
android:paddingLeft="16dp"
|
|
||||||
android:paddingRight="16dp"
|
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
android:clickable="false"
|
android:focusableInTouchMode="true"
|
||||||
android:focusable="false"
|
android:padding="@dimen/content_padding" />
|
||||||
android:focusableInTouchMode="false"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -98,7 +91,6 @@
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="@color/settings_divider" />
|
android:background="@color/settings_divider" />
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -114,6 +114,11 @@
|
||||||
<attr name="card_and_list_background_basic" format="reference" />
|
<attr name="card_and_list_background_basic" format="reference" />
|
||||||
<attr name="activity_background_basic" format="reference" />
|
<attr name="activity_background_basic" format="reference" />
|
||||||
<attr name="pages_bg" format="reference"/>
|
<attr name="pages_bg" format="reference"/>
|
||||||
|
<attr name="dlg_btn_primary" format="reference" />
|
||||||
|
<attr name="dlg_btn_primary_text" format="reference" />
|
||||||
|
<attr name="dlg_btn_secondary" format="reference" />
|
||||||
|
<attr name="dlg_btn_secondary_text" format="reference" />
|
||||||
|
<attr name="dlg_btn_stroked" format="reference" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="PagerSlidingTabStrip">
|
<declare-styleable name="PagerSlidingTabStrip">
|
||||||
|
|
|
@ -478,12 +478,25 @@
|
||||||
<color name="additional_description_light">#b3b3b3</color>
|
<color name="additional_description_light">#b3b3b3</color>
|
||||||
<color name="active_buttons_and_links_light">#237bff</color>
|
<color name="active_buttons_and_links_light">#237bff</color>
|
||||||
<color name="active_buttons_and_links_dark">#d28521</color>
|
<color name="active_buttons_and_links_dark">#d28521</color>
|
||||||
<color name="inactive_buttons_and_links_light">#cccccc</color>
|
<color name="active_buttons_and_links_pressed_light">#0F67EB</color>
|
||||||
<color name="inactive_buttons_and_links_dark">#505050</color>
|
<color name="active_buttons_and_links_pressed_dark">#B87114</color>
|
||||||
|
<color name="inactive_buttons_and_links_light">#F0F0F0</color>
|
||||||
|
<color name="inactive_buttons_and_links_dark">#222526</color>
|
||||||
|
<color name="stroked_buttons_and_links_light">#ffffff</color>
|
||||||
|
<color name="stroked_buttons_and_links_dark">#17181A</color>
|
||||||
|
<color name="inactive_pages_light">#cccccc</color>
|
||||||
|
<color name="inactive_pages_dark">#505050</color>
|
||||||
<color name="active_buttons_and_links_trans_light">#66237bff</color>
|
<color name="active_buttons_and_links_trans_light">#66237bff</color>
|
||||||
<color name="active_buttons_and_links_trans_dark">#66d28521</color>
|
<color name="active_buttons_and_links_trans_dark">#66d28521</color>
|
||||||
<color name="settings_divider">#dcdcdc</color>
|
<color name="settings_divider">#dcdcdc</color>
|
||||||
<color name="profile_button_gray">#EFEFEF</color>
|
<color name="profile_button_gray">#EFEFEF</color>
|
||||||
<color name="profile_button_gray_pressed">#ababab</color>
|
<color name="profile_button_gray_pressed">#ababab</color>
|
||||||
|
<color name="solid_ripple_color">#505050</color>
|
||||||
|
|
||||||
|
<color name="active_buttons_and_links_text_disabled_light">#727272</color>
|
||||||
|
<color name="active_buttons_and_links_text_disabled_dark">#727272</color>
|
||||||
|
<color name="active_buttons_and_links_text_light">#ffffff</color>
|
||||||
|
<color name="active_buttons_and_links_text_dark">#cccccc</color>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -18,6 +18,7 @@
|
||||||
<dimen name="card_button_progress_size">32dp</dimen>
|
<dimen name="card_button_progress_size">32dp</dimen>
|
||||||
<dimen name="card_button_progress_size_small">24dp</dimen>
|
<dimen name="card_button_progress_size_small">24dp</dimen>
|
||||||
<dimen name="card_padding">12dp</dimen>
|
<dimen name="card_padding">12dp</dimen>
|
||||||
|
<dimen name="dlg_button_rect_rad">3dp</dimen>
|
||||||
|
|
||||||
<dimen name="widget_turn_lane_size">36dp</dimen>
|
<dimen name="widget_turn_lane_size">36dp</dimen>
|
||||||
<dimen name="widget_turn_lane_border">6dp</dimen>
|
<dimen name="widget_turn_lane_border">6dp</dimen>
|
||||||
|
@ -342,9 +343,7 @@
|
||||||
<dimen name="pages_item_padding">3dp</dimen>
|
<dimen name="pages_item_padding">3dp</dimen>
|
||||||
<dimen name="pages_item_margin">4dp</dimen>
|
<dimen name="pages_item_margin">4dp</dimen>
|
||||||
|
|
||||||
|
|
||||||
<dimen name="setting_profile_item_height">64dp</dimen>
|
<dimen name="setting_profile_item_height">64dp</dimen>
|
||||||
<dimen name="setting_profile_image_margin">24dp</dimen>
|
|
||||||
<dimen name="setting_profile_item_switch_margin">18dp</dimen>
|
<dimen name="setting_profile_item_switch_margin">18dp</dimen>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -3164,5 +3164,6 @@
|
||||||
<string name="run_full_osmand_header">Launch OsmAnd?</string>
|
<string name="run_full_osmand_header">Launch OsmAnd?</string>
|
||||||
<string name="routing_attr_avoid_sett_name">Avoid cobblestone and sett</string>
|
<string name="routing_attr_avoid_sett_name">Avoid cobblestone and sett</string>
|
||||||
<string name="routing_attr_avoid_sett_description">Avoid cobblestone and sett</string>
|
<string name="routing_attr_avoid_sett_description">Avoid cobblestone and sett</string>
|
||||||
|
<string name="quick_action_need_to_add_item_to_list">You need to add at least one Item to list in Quick Action\' Settings</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -246,6 +246,11 @@
|
||||||
<item name="card_and_list_background_basic">@color/card_and_list_background_light</item>
|
<item name="card_and_list_background_basic">@color/card_and_list_background_light</item>
|
||||||
<item name="activity_background_basic">@color/activity_background_light</item>
|
<item name="activity_background_basic">@color/activity_background_light</item>
|
||||||
<item name="pages_bg">@drawable/pages_bg_light</item>
|
<item name="pages_bg">@drawable/pages_bg_light</item>
|
||||||
|
<item name="dlg_btn_primary">@drawable/dlg_btn_primary_light</item>
|
||||||
|
<item name="dlg_btn_primary_text">@color/dlg_btn_primary_text_light</item>
|
||||||
|
<item name="dlg_btn_secondary">@drawable/dlg_btn_secondary_light</item>
|
||||||
|
<item name="dlg_btn_secondary_text">@color/dlg_btn_secondary_text_light</item>
|
||||||
|
<item name="dlg_btn_stroked">@drawable/dlg_btn_stroked_light</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="OverflowMenuButton" parent="@style/Widget.AppCompat.ActionButton.Overflow">
|
<style name="OverflowMenuButton" parent="@style/Widget.AppCompat.ActionButton.Overflow">
|
||||||
|
@ -478,6 +483,11 @@
|
||||||
<item name="card_and_list_background_basic">@color/card_and_list_background_dark</item>
|
<item name="card_and_list_background_basic">@color/card_and_list_background_dark</item>
|
||||||
<item name="activity_background_basic">@color/activity_background_dark</item>
|
<item name="activity_background_basic">@color/activity_background_dark</item>
|
||||||
<item name="pages_bg">@drawable/pages_bg_dark</item>
|
<item name="pages_bg">@drawable/pages_bg_dark</item>
|
||||||
|
<item name="dlg_btn_primary">@drawable/dlg_btn_primary_dark</item>
|
||||||
|
<item name="dlg_btn_primary_text">@color/dlg_btn_primary_text_dark</item>
|
||||||
|
<item name="dlg_btn_secondary">@drawable/dlg_btn_secondary_dark</item>
|
||||||
|
<item name="dlg_btn_secondary_text">@color/dlg_btn_secondary_text_dark</item>
|
||||||
|
<item name="dlg_btn_stroked">@drawable/dlg_btn_stroked_dark</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="FreeVersionBanner" parent="OsmandDarkTheme">
|
<style name="FreeVersionBanner" parent="OsmandDarkTheme">
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.database.Cursor;
|
||||||
import android.database.DatabaseUtils;
|
import android.database.DatabaseUtils;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
import android.provider.Settings;
|
|
||||||
|
|
||||||
import net.osmand.AndroidNetworkUtils;
|
import net.osmand.AndroidNetworkUtils;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
@ -34,6 +33,7 @@ public class AnalyticsHelper extends SQLiteOpenHelper {
|
||||||
private final static int DATA_PARCEL_SIZE = 500; // 500 events
|
private final static int DATA_PARCEL_SIZE = 500; // 500 events
|
||||||
private final static int SUBMIT_DATA_INTERVAL = 60 * 60 * 1000; // 1 hour
|
private final static int SUBMIT_DATA_INTERVAL = 60 * 60 * 1000; // 1 hour
|
||||||
|
|
||||||
|
private final static String PARAM_OS = "os";
|
||||||
private final static String PARAM_START_DATE = "startDate";
|
private final static String PARAM_START_DATE = "startDate";
|
||||||
private final static String PARAM_FINISH_DATE = "finishDate";
|
private final static String PARAM_FINISH_DATE = "finishDate";
|
||||||
private final static String PARAM_FIRST_INSTALL_DAYS = "nd";
|
private final static String PARAM_FIRST_INSTALL_DAYS = "nd";
|
||||||
|
@ -153,17 +153,14 @@ public class AnalyticsHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> additionalData = new LinkedHashMap<String, String>();
|
Map<String, String> additionalData = new LinkedHashMap<String, String>();
|
||||||
|
additionalData.put(PARAM_OS, "android");
|
||||||
additionalData.put(PARAM_START_DATE, String.valueOf(d.startDate));
|
additionalData.put(PARAM_START_DATE, String.valueOf(d.startDate));
|
||||||
additionalData.put(PARAM_FINISH_DATE, String.valueOf(d.finishDate));
|
additionalData.put(PARAM_FINISH_DATE, String.valueOf(d.finishDate));
|
||||||
additionalData.put(PARAM_VERSION, Version.getFullVersion(ctx));
|
additionalData.put(PARAM_VERSION, Version.getFullVersion(ctx));
|
||||||
additionalData.put(PARAM_LANG, ctx.getLanguage() + "");
|
additionalData.put(PARAM_LANG, ctx.getLanguage() + "");
|
||||||
additionalData.put(PARAM_FIRST_INSTALL_DAYS, String.valueOf(ctx.getAppInitializer().getFirstInstalledDays()));
|
additionalData.put(PARAM_FIRST_INSTALL_DAYS, String.valueOf(ctx.getAppInitializer().getFirstInstalledDays()));
|
||||||
additionalData.put(PARAM_NUMBER_OF_STARTS, String.valueOf(ctx.getAppInitializer().getNumberOfStarts()));
|
additionalData.put(PARAM_NUMBER_OF_STARTS, String.valueOf(ctx.getAppInitializer().getNumberOfStarts()));
|
||||||
try {
|
additionalData.put(PARAM_USER_ID, ctx.getUserAndroidId());
|
||||||
additionalData.put(PARAM_USER_ID, Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID));
|
|
||||||
} catch (Exception e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
for (Map.Entry<String, String> entry : additionalData.entrySet()) {
|
for (Map.Entry<String, String> entry : additionalData.entrySet()) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.plus;
|
package net.osmand.plus;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
@ -15,6 +16,7 @@ import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.support.multidex.MultiDex;
|
import android.support.multidex.MultiDex;
|
||||||
import android.support.multidex.MultiDexApplication;
|
import android.support.multidex.MultiDexApplication;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
@ -77,6 +79,7 @@ import java.io.PrintStream;
|
||||||
import java.lang.Thread.UncaughtExceptionHandler;
|
import java.lang.Thread.UncaughtExceptionHandler;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import btools.routingapp.BRouterServiceConnection;
|
import btools.routingapp.BRouterServiceConnection;
|
||||||
import btools.routingapp.IBRouterService;
|
import btools.routingapp.IBRouterService;
|
||||||
|
@ -919,6 +922,24 @@ public class OsmandApplication extends MultiDexApplication {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("HardwareIds")
|
||||||
|
public String getUserAndroidId() {
|
||||||
|
String userAndroidId = osmandSettings.USER_ANDROID_ID.get();
|
||||||
|
if (!Algorithms.isEmpty(userAndroidId)) {
|
||||||
|
return userAndroidId;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
userAndroidId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
if (userAndroidId == null || userAndroidId.length() < 16 || userAndroidId.equals("0000000000000000")) {
|
||||||
|
userAndroidId = UUID.randomUUID().toString();
|
||||||
|
}
|
||||||
|
osmandSettings.USER_ANDROID_ID.set(userAndroidId);
|
||||||
|
return userAndroidId;
|
||||||
|
}
|
||||||
|
|
||||||
public void logEvent(String event) {
|
public void logEvent(String event) {
|
||||||
try {
|
try {
|
||||||
if (osmandSettings.SEND_ANONYMOUS_APP_USAGE_DATA.get()) {
|
if (osmandSettings.SEND_ANONYMOUS_APP_USAGE_DATA.get()) {
|
||||||
|
@ -939,6 +960,16 @@ public class OsmandApplication extends MultiDexApplication {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void logMapDownloadEvent(String event, IndexItem item, long time) {
|
||||||
|
try {
|
||||||
|
if (osmandSettings.SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.get()) {
|
||||||
|
analyticsHelper.addEvent("map_download_" + event + ": " + item.getFileName() + " in " + time + " msec");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void restartApp(Context ctx) {
|
public void restartApp(Context ctx) {
|
||||||
AlertDialog.Builder bld = new AlertDialog.Builder(ctx);
|
AlertDialog.Builder bld = new AlertDialog.Builder(ctx);
|
||||||
bld.setMessage(R.string.restart_is_required);
|
bld.setMessage(R.string.restart_is_required);
|
||||||
|
@ -981,6 +1012,8 @@ public class OsmandApplication extends MultiDexApplication {
|
||||||
PlatformUtil.getLog(ErrorBottomSheetDialog.class).error("", e);
|
PlatformUtil.getLog(ErrorBottomSheetDialog.class).error("", e);
|
||||||
}
|
}
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, text.toString());
|
intent.putExtra(Intent.EXTRA_TEXT, text.toString());
|
||||||
startActivity(Intent.createChooser(intent, getString(R.string.send_report)));
|
Intent chooserIntent = Intent.createChooser(intent, getString(R.string.send_report));
|
||||||
|
chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(chooserIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1172,6 +1172,7 @@ public class OsmandSettings {
|
||||||
public final CommonPreference<Boolean> ENABLE_PROXY = new BooleanPreference("enable_proxy", false).makeGlobal();
|
public final CommonPreference<Boolean> ENABLE_PROXY = new BooleanPreference("enable_proxy", false).makeGlobal();
|
||||||
public final CommonPreference<String> PROXY_HOST = new StringPreference("proxy_host", "127.0.0.1").makeGlobal();
|
public final CommonPreference<String> PROXY_HOST = new StringPreference("proxy_host", "127.0.0.1").makeGlobal();
|
||||||
public final CommonPreference<Integer> PROXY_PORT = new IntPreference("proxy_port", 8118).makeGlobal();
|
public final CommonPreference<Integer> PROXY_PORT = new IntPreference("proxy_port", 8118).makeGlobal();
|
||||||
|
public final CommonPreference<String> USER_ANDROID_ID = new StringPreference("user_android_id", "").makeGlobal();
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public static final String SAVE_CURRENT_TRACK = "save_current_track"; //$NON-NLS-1$
|
public static final String SAVE_CURRENT_TRACK = "save_current_track"; //$NON-NLS-1$
|
||||||
|
|
|
@ -17,14 +17,14 @@ import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.data.LatLon;
|
|
||||||
import net.osmand.data.PointDescription;
|
|
||||||
import net.osmand.data.QuadRect;
|
|
||||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.TrkSegment;
|
import net.osmand.GPXUtilities.TrkSegment;
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.PointDescription;
|
||||||
|
import net.osmand.data.QuadRect;
|
||||||
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
|
@ -447,7 +447,7 @@ public class TrackActivity extends TabActivity {
|
||||||
result = app.getSavingTrackHelper().getCurrentGpx();
|
result = app.getSavingTrackHelper().getCurrentGpx();
|
||||||
} else {
|
} else {
|
||||||
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(file.getAbsolutePath());
|
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(file.getAbsolutePath());
|
||||||
if (selectedGpxFile != null && selectedGpxFile.getGpxFile() != null) {
|
if (selectedGpxFile != null && selectedGpxFile.getGpxFile() != null && selectedGpxFile.getGpxFile().modifiedTime == file.lastModified()) {
|
||||||
result = selectedGpxFile.getGpxFile();
|
result = selectedGpxFile.getGpxFile();
|
||||||
} else {
|
} else {
|
||||||
result = GPXUtilities.loadGPXFile(file);
|
result = GPXUtilities.loadGPXFile(file);
|
||||||
|
@ -472,8 +472,16 @@ public class TrackActivity extends TabActivity {
|
||||||
TrackActivity activity = getTrackActivity();
|
TrackActivity activity = getTrackActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.setSupportProgressBarIndeterminateVisibility(false);
|
activity.setSupportProgressBarIndeterminateVisibility(false);
|
||||||
if (showTemporarily && result != null) {
|
if (result != null) {
|
||||||
app.getSelectedGpxHelper().selectGpxFile(result, false, false);
|
final GpxSelectionHelper helper = app.getSelectedGpxHelper();
|
||||||
|
if (showTemporarily) {
|
||||||
|
helper.selectGpxFile(result, false, false);
|
||||||
|
} else {
|
||||||
|
final SelectedGpxFile selectedGpx = helper.getSelectedFileByPath(result.path);
|
||||||
|
if (selectedGpx != null && result.error == null) {
|
||||||
|
selectedGpx.setGpxFile(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!activity.stopped) {
|
if (!activity.stopped) {
|
||||||
activity.onGPXFileReady(result);
|
activity.onGPXFileReady(result);
|
||||||
|
|
|
@ -75,6 +75,11 @@ public abstract class BottomSheetDialogFragment extends DialogFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
protected OsmandApplication requiredMyApplication() {
|
||||||
|
return (OsmandApplication) requireActivity().getApplication();
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
protected Drawable getIcon(@DrawableRes int drawableRes, @ColorRes int color) {
|
protected Drawable getIcon(@DrawableRes int drawableRes, @ColorRes int color) {
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.osmand.plus.base;
|
package net.osmand.plus.base;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -10,6 +11,7 @@ import android.support.annotation.DrawableRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.annotation.StringRes;
|
import android.support.annotation.StringRes;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -19,13 +21,13 @@ import android.view.ViewTreeObserver;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -44,6 +46,12 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
|
|
||||||
private LinearLayout itemsContainer;
|
private LinearLayout itemsContainer;
|
||||||
|
|
||||||
|
public enum DialogButtonType {
|
||||||
|
PRIMARY,
|
||||||
|
SECONDARY,
|
||||||
|
STROKED
|
||||||
|
}
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
protected int dismissButtonStringRes = R.string.shared_string_cancel;
|
protected int dismissButtonStringRes = R.string.shared_string_cancel;
|
||||||
|
|
||||||
|
@ -57,7 +65,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
usedOnMap = savedInstanceState.getBoolean(USED_ON_MAP_KEY);
|
usedOnMap = savedInstanceState.getBoolean(USED_ON_MAP_KEY);
|
||||||
}
|
}
|
||||||
nightMode = isNightMode();
|
nightMode = isNightMode(requiredMyApplication());
|
||||||
themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,10 +73,8 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
|
||||||
createMenuItems(savedInstanceState);
|
createMenuItems(savedInstanceState);
|
||||||
|
Context ctx = requireContext();
|
||||||
OsmandApplication app = getMyApplication();
|
View mainView = View.inflate(new ContextThemeWrapper(ctx, themeRes), R.layout.bottom_sheet_menu_base, null);
|
||||||
|
|
||||||
View mainView = View.inflate(new ContextThemeWrapper(app, themeRes), R.layout.bottom_sheet_menu_base, null);
|
|
||||||
if (useScrollableItemsContainer()) {
|
if (useScrollableItemsContainer()) {
|
||||||
itemsContainer = (LinearLayout) mainView.findViewById(R.id.scrollable_items_container);
|
itemsContainer = (LinearLayout) mainView.findViewById(R.id.scrollable_items_container);
|
||||||
} else {
|
} else {
|
||||||
|
@ -79,12 +85,9 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
|
|
||||||
inflateMenuItems();
|
inflateMenuItems();
|
||||||
|
|
||||||
int bottomDividerColorId = getBottomDividerColorId();
|
View dismissButton = mainView.findViewById(R.id.dismiss_button);
|
||||||
if (bottomDividerColorId != DEFAULT_VALUE) {
|
setupDialogButton(dismissButton, DialogButtonType.STROKED, getDismissButtonTextId());
|
||||||
mainView.findViewById(R.id.bottom_row_divider).setBackgroundColor(getResolvedColor(bottomDividerColorId));
|
dismissButton.setOnClickListener(new View.OnClickListener() {
|
||||||
}
|
|
||||||
|
|
||||||
mainView.findViewById(R.id.dismiss_button).setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
onDismissButtonClickAction();
|
onDismissButtonClickAction();
|
||||||
|
@ -92,19 +95,13 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (hideButtonsContainer()) {
|
if (hideButtonsContainer()) {
|
||||||
mainView.findViewById(R.id.bottom_row_divider).setVisibility(View.GONE);
|
|
||||||
mainView.findViewById(R.id.buttons_container).setVisibility(View.GONE);
|
mainView.findViewById(R.id.buttons_container).setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
((TextView) mainView.findViewById(R.id.dismiss_button_text)).setText(getDismissButtonTextId());
|
|
||||||
|
|
||||||
int rightBottomButtonTextId = getRightBottomButtonTextId();
|
int rightBottomButtonTextId = getRightBottomButtonTextId();
|
||||||
if (rightBottomButtonTextId != DEFAULT_VALUE) {
|
if (rightBottomButtonTextId != DEFAULT_VALUE) {
|
||||||
View buttonsDivider = mainView.findViewById(R.id.bottom_buttons_divider);
|
mainView.findViewById(R.id.buttons_divider).setVisibility(View.VISIBLE);
|
||||||
buttonsDivider.setVisibility(View.VISIBLE);
|
|
||||||
if (bottomDividerColorId != DEFAULT_VALUE) {
|
|
||||||
buttonsDivider.setBackgroundColor(getResolvedColor(bottomDividerColorId));
|
|
||||||
}
|
|
||||||
View rightButton = mainView.findViewById(R.id.right_bottom_button);
|
View rightButton = mainView.findViewById(R.id.right_bottom_button);
|
||||||
|
setupDialogButton(rightButton, DialogButtonType.PRIMARY, rightBottomButtonTextId);
|
||||||
rightButton.setVisibility(View.VISIBLE);
|
rightButton.setVisibility(View.VISIBLE);
|
||||||
rightButton.setOnClickListener(new View.OnClickListener() {
|
rightButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -112,25 +109,25 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
onRightBottomButtonClick();
|
onRightBottomButtonClick();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
((TextView) rightButton.findViewById(R.id.right_bottom_button_text)).setText(rightBottomButtonTextId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setupHeightAndBackground(mainView);
|
setupHeightAndBackground(mainView);
|
||||||
|
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
if (!AndroidUiHelper.isOrientationPortrait(getActivity())) {
|
FragmentActivity activity = requireActivity();
|
||||||
|
if (!AndroidUiHelper.isOrientationPortrait(activity)) {
|
||||||
final Window window = getDialog().getWindow();
|
final Window window = getDialog().getWindow();
|
||||||
|
if (window != null) {
|
||||||
WindowManager.LayoutParams params = window.getAttributes();
|
WindowManager.LayoutParams params = window.getAttributes();
|
||||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
params.width = activity.getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
||||||
window.setAttributes(params);
|
window.setAttributes(params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
@ -147,6 +144,38 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupDialogButton(View buttonView, DialogButtonType buttonType, @StringRes int buttonTextId) {
|
||||||
|
Context ctx = buttonView.getContext();
|
||||||
|
TextViewEx buttonTextView = (TextViewEx) buttonView.findViewById(R.id.button_text);
|
||||||
|
boolean v21 = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
|
||||||
|
View buttonContainer = buttonView.findViewById(R.id.button_container);
|
||||||
|
switch (buttonType) {
|
||||||
|
case PRIMARY:
|
||||||
|
if (v21) {
|
||||||
|
AndroidUtils.setBackground(ctx, buttonContainer, nightMode, R.drawable.ripple_solid_light, R.drawable.ripple_solid_dark);
|
||||||
|
}
|
||||||
|
AndroidUtils.setBackground(ctx, buttonView, nightMode, R.drawable.dlg_btn_primary_light, R.drawable.dlg_btn_primary_dark);
|
||||||
|
buttonTextView.setTextColor(ContextCompat.getColorStateList(ctx, nightMode ? R.color.dlg_btn_primary_text_dark : R.color.dlg_btn_primary_text_light));
|
||||||
|
break;
|
||||||
|
case SECONDARY:
|
||||||
|
if (v21) {
|
||||||
|
AndroidUtils.setBackground(ctx, buttonContainer, nightMode, R.drawable.ripple_solid_light, R.drawable.ripple_solid_dark);
|
||||||
|
}
|
||||||
|
AndroidUtils.setBackground(ctx, buttonView, nightMode, R.drawable.dlg_btn_secondary_light, R.drawable.dlg_btn_secondary_dark);
|
||||||
|
buttonTextView.setTextColor(ContextCompat.getColorStateList(ctx, nightMode ? R.color.dlg_btn_secondary_text_dark : R.color.dlg_btn_secondary_text_light));
|
||||||
|
break;
|
||||||
|
case STROKED:
|
||||||
|
if (v21) {
|
||||||
|
AndroidUtils.setBackground(ctx, buttonContainer, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
|
||||||
|
}
|
||||||
|
AndroidUtils.setBackground(ctx, buttonView, nightMode, R.drawable.dlg_btn_stroked_light, R.drawable.dlg_btn_stroked_dark);
|
||||||
|
buttonTextView.setTextColor(ContextCompat.getColorStateList(ctx, nightMode ? R.color.dlg_btn_secondary_text_dark : R.color.dlg_btn_secondary_text_light));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buttonTextView.setText(buttonTextId);
|
||||||
|
buttonTextView.setEnabled(buttonView.isEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void createMenuItems(Bundle savedInstanceState);
|
public abstract void createMenuItems(Bundle savedInstanceState);
|
||||||
|
|
||||||
protected void inflateMenuItems() {
|
protected void inflateMenuItems() {
|
||||||
|
@ -172,7 +201,8 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
protected int getResolvedColor(@ColorRes int colorId) {
|
protected int getResolvedColor(@ColorRes int colorId) {
|
||||||
return ContextCompat.getColor(getContext(), colorId);
|
Context ctx = getContext();
|
||||||
|
return ctx != null ? ContextCompat.getColor(ctx, colorId) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupHeightAndBackground(final View mainView) {
|
protected void setupHeightAndBackground(final View mainView) {
|
||||||
|
@ -187,6 +217,13 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onGlobalLayout() {
|
public void onGlobalLayout() {
|
||||||
|
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
|
obs.removeOnGlobalLayoutListener(this);
|
||||||
|
} else {
|
||||||
|
obs.removeGlobalOnLayoutListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
final View contentView = useScrollableItemsContainer() ? mainView.findViewById(R.id.scroll_view) : itemsContainer;
|
final View contentView = useScrollableItemsContainer() ? mainView.findViewById(R.id.scroll_view) : itemsContainer;
|
||||||
if (contentView.getHeight() > contentHeight) {
|
if (contentView.getHeight() > contentHeight) {
|
||||||
if (useScrollableItemsContainer()) {
|
if (useScrollableItemsContainer()) {
|
||||||
|
@ -207,22 +244,13 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
} else {
|
} else {
|
||||||
mainView.setBackgroundResource(showTopShadow ? getLandscapeTopsidesBgResId() : getLandscapeSidesBgResId());
|
mainView.setBackgroundResource(showTopShadow ? getLandscapeTopsidesBgResId() : getLandscapeSidesBgResId());
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
||||||
obs.removeOnGlobalLayoutListener(this);
|
|
||||||
} else {
|
|
||||||
obs.removeGlobalOnLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getContentHeight(int availableScreenHeight) {
|
private int getContentHeight(int availableScreenHeight) {
|
||||||
int customHeight = getCustomHeight();
|
int customHeight = getCustomHeight();
|
||||||
int maxHeight = availableScreenHeight
|
int maxHeight = availableScreenHeight - getResources().getDimensionPixelSize(R.dimen.dialog_button_ex_height);
|
||||||
- AndroidUtils.dpToPx(getContext(), 1) // divider height
|
|
||||||
- getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
|
||||||
if (customHeight != DEFAULT_VALUE && customHeight <= maxHeight) {
|
if (customHeight != DEFAULT_VALUE && customHeight <= maxHeight) {
|
||||||
return customHeight;
|
return customHeight;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +270,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
}
|
}
|
||||||
|
|
||||||
@ColorRes
|
@ColorRes
|
||||||
protected int getBottomDividerColorId() {
|
protected int getDividerColorId() {
|
||||||
return DEFAULT_VALUE;
|
return DEFAULT_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,10 +316,10 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
return nightMode ? R.drawable.bg_bottom_sheet_sides_landscape_dark : R.drawable.bg_bottom_sheet_sides_landscape_light;
|
return nightMode ? R.drawable.bg_bottom_sheet_sides_landscape_dark : R.drawable.bg_bottom_sheet_sides_landscape_light;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNightMode() {
|
private boolean isNightMode(@NonNull OsmandApplication app) {
|
||||||
if (usedOnMap) {
|
if (usedOnMap) {
|
||||||
return getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
return app.getDaynightHelper().isNightModeForMapControls();
|
||||||
}
|
}
|
||||||
return !getMyApplication().getSettings().isLightContent();
|
return !app.getSettings().isLightContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
|
||||||
.create();
|
.create();
|
||||||
items.add(replaceStartItem);
|
items.add(replaceStartItem);
|
||||||
|
|
||||||
items.add(new DividerHalfItem(getContext(), getBottomDividerColorId()));
|
items.add(new DividerHalfItem(getContext(), getDividerColorId()));
|
||||||
|
|
||||||
BaseBottomSheetItem subsequentDestItem = new BottomSheetItemWithDescription.Builder()
|
BaseBottomSheetItem subsequentDestItem = new BottomSheetItemWithDescription.Builder()
|
||||||
.setDescription(getString(R.string.subsequent_dest_description))
|
.setDescription(getString(R.string.subsequent_dest_description))
|
||||||
|
@ -130,7 +130,7 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getBottomDividerColorId() {
|
protected int getDividerColorId() {
|
||||||
return nightMode ? R.color.route_info_bottom_view_bg_dark : -1;
|
return nightMode ? R.color.route_info_bottom_view_bg_dark : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -534,7 +534,6 @@ public class DownloadIndexesThread {
|
||||||
boolean result = downloadFile(item, filesToReindex, forceWifi);
|
boolean result = downloadFile(item, filesToReindex, forceWifi);
|
||||||
success = result || success;
|
success = result || success;
|
||||||
if (result) {
|
if (result) {
|
||||||
checkDownload(item);
|
|
||||||
if (DownloadActivityType.isCountedInDownloads(item)) {
|
if (DownloadActivityType.isCountedInDownloads(item)) {
|
||||||
downloads.set(downloads.get() + 1);
|
downloads.set(downloads.get() + 1);
|
||||||
}
|
}
|
||||||
|
@ -664,8 +663,16 @@ public class DownloadIndexesThread {
|
||||||
LOG.error("Copy exception", e);
|
LOG.error("Copy exception", e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
app.logMapDownloadEvent("start", item);
|
app.logMapDownloadEvent("start", item);
|
||||||
res = downloadFileHelper.downloadFile(de, this, filesToReindex, this, forceWifi);
|
res = downloadFileHelper.downloadFile(de, this, filesToReindex, this, forceWifi);
|
||||||
|
long time = System.currentTimeMillis() - start;
|
||||||
|
if (res) {
|
||||||
|
app.logMapDownloadEvent("done", item, time);
|
||||||
|
checkDownload(item);
|
||||||
|
} else {
|
||||||
|
app.logMapDownloadEvent("failed", item, time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -678,7 +685,6 @@ public class DownloadIndexesThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkDownload(IndexItem item) {
|
private void checkDownload(IndexItem item) {
|
||||||
app.logMapDownloadEvent("done", item);
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("file_name", item.fileName);
|
params.put("file_name", item.fileName);
|
||||||
params.put("file_size", item.size);
|
params.put("file_size", item.size);
|
||||||
|
|
|
@ -7,7 +7,6 @@ import android.content.res.Resources;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
@ -28,10 +27,10 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidNetworkUtils;
|
import net.osmand.AndroidNetworkUtils;
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.UiUtilities;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
||||||
import net.osmand.plus.download.DownloadActivity;
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
import net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion;
|
import net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion;
|
||||||
|
@ -283,7 +282,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
||||||
protected String doInBackground(Void... params) {
|
protected String doInBackground(Void... params) {
|
||||||
try {
|
try {
|
||||||
Map<String, String> parameters = new HashMap<>();
|
Map<String, String> parameters = new HashMap<>();
|
||||||
parameters.put("aid", Settings.Secure.getString(activity.getContentResolver(), Settings.Secure.ANDROID_ID));
|
parameters.put("aid", getMyApplication().getUserAndroidId());
|
||||||
parameters.put("email", email);
|
parameters.put("email", email);
|
||||||
|
|
||||||
return AndroidNetworkUtils.sendRequest(getMyApplication(),
|
return AndroidNetworkUtils.sendRequest(getMyApplication(),
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.provider.Settings;
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
@ -677,11 +676,7 @@ public class InAppPurchaseHelper {
|
||||||
parameters.put("lang", ctx.getLanguage() + "");
|
parameters.put("lang", ctx.getLanguage() + "");
|
||||||
parameters.put("nd", ctx.getAppInitializer().getFirstInstalledDays() + "");
|
parameters.put("nd", ctx.getAppInitializer().getFirstInstalledDays() + "");
|
||||||
parameters.put("ns", ctx.getAppInitializer().getNumberOfStarts() + "");
|
parameters.put("ns", ctx.getAppInitializer().getNumberOfStarts() + "");
|
||||||
try {
|
parameters.put("aid", ctx.getUserAndroidId());
|
||||||
parameters.put("aid", Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID));
|
|
||||||
} catch (Exception e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback for when a purchase is finished
|
// Callback for when a purchase is finished
|
||||||
|
|
|
@ -23,11 +23,12 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||||
import net.osmand.plus.profiles.ProfileMenuAdapter.ProfileListener;
|
import net.osmand.plus.profiles.ProfileMenuAdapter.ProfileMenuAdapterListener;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
@ -40,7 +41,7 @@ public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
|
||||||
private ProfileMenuAdapter adapter;
|
private ProfileMenuAdapter adapter;
|
||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
|
|
||||||
private ProfileListener listener;
|
private ProfileMenuAdapterListener listener;
|
||||||
private UpdateMapRouteMenuListener updateMapRouteMenuListener;
|
private UpdateMapRouteMenuListener updateMapRouteMenuListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,7 +56,7 @@ public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent,
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||||
adapter = new ProfileMenuAdapter(allModes, selectedModes, getMyApplication(), true);
|
adapter = new ProfileMenuAdapter(allModes, selectedModes, getMyApplication(), getString(R.string.shared_string_manage));
|
||||||
recyclerView = new RecyclerView(getContext());
|
recyclerView = new RecyclerView(getContext());
|
||||||
recyclerView = (RecyclerView) View
|
recyclerView = (RecyclerView) View
|
||||||
.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.recyclerview, null);
|
.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.recyclerview, null);
|
||||||
|
@ -75,19 +76,20 @@ public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
listener = new ProfileListener() {
|
if (listener == null) {
|
||||||
|
listener = new ProfileMenuAdapterListener() {
|
||||||
@Override
|
@Override
|
||||||
public void changeProfileStatus(ApplicationMode item, boolean isSelected) {
|
public void onProfileSelected(ApplicationMode item, boolean selected) {
|
||||||
if (isSelected) {
|
if (selected) {
|
||||||
selectedModes.add(item);
|
selectedModes.add(item);
|
||||||
} else {
|
} else {
|
||||||
selectedModes.remove(item);
|
selectedModes.remove(item);
|
||||||
}
|
}
|
||||||
ApplicationMode.changeProfileStatus(item, isSelected, getMyApplication());
|
ApplicationMode.changeProfileStatus(item, selected, getMyApplication());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void editProfile(ApplicationMode item) {
|
public void onProfilePressed(ApplicationMode item) {
|
||||||
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
|
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
|
||||||
intent.putExtra(PROFILE_STRING_KEY, item.getStringKey());
|
intent.putExtra(PROFILE_STRING_KEY, item.getStringKey());
|
||||||
if (!Algorithms.isEmpty(item.getUserProfileName())) {
|
if (!Algorithms.isEmpty(item.getUserProfileName())) {
|
||||||
|
@ -95,7 +97,16 @@ public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
|
||||||
}
|
}
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onButtonPressed() {
|
||||||
|
OsmandApplication app = requiredMyApplication();
|
||||||
|
Intent intent = new Intent(app, SettingsProfileActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
app.startActivity(intent);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
adapter.setListener(listener);
|
adapter.setListener(listener);
|
||||||
allModes = ApplicationMode.allPossibleValues();
|
allModes = ApplicationMode.allPossibleValues();
|
||||||
allModes.remove(ApplicationMode.DEFAULT);
|
allModes.remove(ApplicationMode.DEFAULT);
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
package net.osmand.plus.profiles;
|
package net.osmand.plus.profiles;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.support.annotation.ColorRes;
|
import android.support.annotation.ColorRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.SwitchCompat;
|
import android.support.v7.widget.SwitchCompat;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -26,22 +29,25 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
||||||
|
|
||||||
private List<Object> items = new ArrayList<>();
|
private List<Object> items = new ArrayList<>();
|
||||||
private Set<ApplicationMode> selectedItems;
|
private Set<ApplicationMode> selectedItems;
|
||||||
private ProfileListener listener;
|
@Nullable
|
||||||
|
private ProfileMenuAdapterListener listener;
|
||||||
private final OsmandApplication app;
|
private final OsmandApplication app;
|
||||||
@ColorRes
|
@ColorRes
|
||||||
private int selectedIconColorRes;
|
private int selectedIconColorRes;
|
||||||
private boolean isBottomSheet = false;
|
private boolean bottomButton;
|
||||||
private static final String MANAGE_BTN = "manage_button";
|
private String bottomButtonText;
|
||||||
|
private static final String BUTTON_ITEM = "button_item";
|
||||||
|
|
||||||
public ProfileMenuAdapter(List<ApplicationMode> items, Set<ApplicationMode> selectedItems,
|
public ProfileMenuAdapter(List<ApplicationMode> items, Set<ApplicationMode> selectedItems,
|
||||||
OsmandApplication app, boolean isBottomSheet) {
|
OsmandApplication app, String bottomButtonText) {
|
||||||
this.items.addAll(items);
|
this.items.addAll(items);
|
||||||
if (isBottomSheet) {
|
if (bottomButton) {
|
||||||
this.items.add(MANAGE_BTN);
|
this.items.add(BUTTON_ITEM);
|
||||||
}
|
}
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.selectedItems = selectedItems;
|
this.selectedItems = selectedItems;
|
||||||
this.isBottomSheet = isBottomSheet;
|
this.bottomButton = !Algorithms.isEmpty(bottomButtonText);
|
||||||
|
this.bottomButtonText = bottomButtonText;
|
||||||
selectedIconColorRes = isNightMode(app)
|
selectedIconColorRes = isNightMode(app)
|
||||||
? R.color.active_buttons_and_links_dark
|
? R.color.active_buttons_and_links_dark
|
||||||
: R.color.active_buttons_and_links_light;
|
: R.color.active_buttons_and_links_light;
|
||||||
|
@ -51,12 +57,7 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItem(ApplicationMode profileItem) {
|
public void setListener(@Nullable ProfileMenuAdapterListener listener) {
|
||||||
items.add(profileItem);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setListener(ProfileListener listener) {
|
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,8 +65,8 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
this.selectedItems.clear();
|
this.selectedItems.clear();
|
||||||
this.items.addAll(newList);
|
this.items.addAll(newList);
|
||||||
if (isBottomSheet) {
|
if (bottomButton) {
|
||||||
items.add(MANAGE_BTN);
|
items.add(BUTTON_ITEM);
|
||||||
}
|
}
|
||||||
this.selectedItems.addAll(selectedItems);
|
this.selectedItems.addAll(selectedItems);
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
|
@ -79,55 +80,22 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public ProfileViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public ProfileViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
View itemView = LayoutInflater.from(parent.getContext())
|
View itemView =
|
||||||
.inflate(R.layout.profile_list_item, parent, false);
|
LayoutInflater.from(parent.getContext()).inflate(R.layout.profile_list_item, parent, false);
|
||||||
final ProfileViewHolder holder = new ProfileViewHolder(itemView);
|
return new ProfileViewHolder(itemView);
|
||||||
holder.itemView.findViewById(R.id.compound_button).setOnClickListener(
|
|
||||||
new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
int pos = holder.getAdapterPosition();
|
|
||||||
if ( pos != RecyclerView.NO_POSITION) {
|
|
||||||
Object o = items.get(pos);
|
|
||||||
if (o instanceof ApplicationMode) {
|
|
||||||
final ApplicationMode item = (ApplicationMode) o;
|
|
||||||
int iconRes = item.getParent() == null
|
|
||||||
? item.getSmallIconDark()
|
|
||||||
: item.getIconRes(app);
|
|
||||||
|
|
||||||
if (iconRes == 0 || iconRes == -1) {
|
|
||||||
iconRes = R.drawable.ic_action_world_globe;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!selectedItems.contains(item)) {
|
|
||||||
selectedItems.add(item);
|
|
||||||
holder.icon.setImageDrawable(
|
|
||||||
app.getUIUtilities().getIcon(iconRes, selectedIconColorRes));
|
|
||||||
} else {
|
|
||||||
selectedItems.remove(item);
|
|
||||||
holder.icon.setImageDrawable(
|
|
||||||
app.getUIUtilities().getIcon(iconRes, R.color.icon_color));
|
|
||||||
}
|
|
||||||
listener.changeProfileStatus(item, holder.aSwitch.isChecked());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return holder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull final ProfileViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull final ProfileViewHolder holder, int position) {
|
||||||
Object obj = items.get(position);
|
Object obj = items.get(position);
|
||||||
|
|
||||||
if (obj instanceof ApplicationMode) {
|
if (obj instanceof ApplicationMode) {
|
||||||
holder.divider.setVisibility(View.VISIBLE);
|
holder.divider.setVisibility(View.VISIBLE);
|
||||||
holder.icon.setVisibility(View.VISIBLE);
|
holder.icon.setVisibility(View.VISIBLE);
|
||||||
holder.descr.setVisibility(View.VISIBLE);
|
holder.descr.setVisibility(View.VISIBLE);
|
||||||
holder.aSwitch.setVisibility(View.VISIBLE);
|
holder.switcher.setVisibility(View.VISIBLE);
|
||||||
holder.menuIcon.setVisibility(View.VISIBLE);
|
holder.menuIcon.setVisibility(View.VISIBLE);
|
||||||
final ApplicationMode item = (ApplicationMode) obj;
|
final ApplicationMode item = (ApplicationMode) obj;
|
||||||
if (isBottomSheet) {
|
if (bottomButton) {
|
||||||
holder.divider.setBackgroundColor(isNightMode(app)
|
holder.divider.setBackgroundColor(isNightMode(app)
|
||||||
? app.getResources().getColor(R.color.divider_dark)
|
? app.getResources().getColor(R.color.divider_dark)
|
||||||
: app.getResources().getColor(R.color.divider_light));
|
: app.getResources().getColor(R.color.divider_light));
|
||||||
|
@ -150,45 +118,21 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
||||||
? R.color.main_font_dark
|
? R.color.main_font_dark
|
||||||
: R.color.main_font_light));
|
: R.color.main_font_light));
|
||||||
|
|
||||||
int iconRes = item.getParent() == null
|
holder.initSwitcher = true;
|
||||||
? item.getSmallIconDark()
|
holder.switcher.setChecked(selectedItems.contains(item));
|
||||||
: item.getIconRes(app);
|
holder.initSwitcher = false;
|
||||||
|
updateViewHolder(holder, item);
|
||||||
if (iconRes == 0 || iconRes == -1) {
|
|
||||||
iconRes = R.drawable.ic_action_world_globe;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedItems.contains(item)) {
|
|
||||||
holder.aSwitch.setChecked(true);
|
|
||||||
holder.icon
|
|
||||||
.setImageDrawable(app.getUIUtilities().getIcon(iconRes, selectedIconColorRes));
|
|
||||||
} else {
|
|
||||||
holder.aSwitch.setChecked(false);
|
|
||||||
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, R.color.icon_color));
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.profileOptions.setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
listener.editProfile(item);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
final String title = (String) obj;
|
final String title = (String) obj;
|
||||||
if (title.equals("manage_button"))
|
if (title.equals(BUTTON_ITEM)) {
|
||||||
holder.divider.setVisibility(View.INVISIBLE);
|
holder.divider.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
holder.icon.setVisibility(View.INVISIBLE);
|
holder.icon.setVisibility(View.INVISIBLE);
|
||||||
holder.descr.setVisibility(View.GONE);
|
holder.descr.setVisibility(View.GONE);
|
||||||
holder.aSwitch.setVisibility(View.GONE);
|
holder.switcher.setVisibility(View.GONE);
|
||||||
holder.menuIcon.setVisibility(View.GONE);
|
holder.menuIcon.setVisibility(View.GONE);
|
||||||
holder.title.setTextColor(app.getResources().getColor(selectedIconColorRes));
|
holder.title.setTextColor(app.getResources().getColor(selectedIconColorRes));
|
||||||
holder.title.setText(R.string.shared_string_manage);
|
holder.title.setText(bottomButtonText);
|
||||||
holder.profileOptions.setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
app.startActivity(new Intent(app, SettingsProfileActivity.class));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,6 +141,18 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
||||||
return items.size();
|
return items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateViewHolder(ProfileViewHolder holder, ApplicationMode mode) {
|
||||||
|
int iconRes = mode.getParent() == null ? mode.getSmallIconDark() : mode.getIconRes(app);
|
||||||
|
if (iconRes == 0 || iconRes == -1) {
|
||||||
|
iconRes = R.drawable.ic_action_world_globe;
|
||||||
|
}
|
||||||
|
if (selectedItems.contains(mode)) {
|
||||||
|
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, selectedIconColorRes));
|
||||||
|
} else {
|
||||||
|
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes, R.color.icon_color));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isNightMode(OsmandApplication ctx) {
|
private static boolean isNightMode(OsmandApplication ctx) {
|
||||||
return !ctx.getSettings().isLightContent();
|
return !ctx.getSettings().isLightContent();
|
||||||
}
|
}
|
||||||
|
@ -204,28 +160,65 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
||||||
class ProfileViewHolder extends RecyclerView.ViewHolder {
|
class ProfileViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
TextView title, descr;
|
TextView title, descr;
|
||||||
SwitchCompat aSwitch;
|
SwitchCompat switcher;
|
||||||
ImageView icon, menuIcon;
|
ImageView icon, menuIcon;
|
||||||
LinearLayout profileOptions;
|
LinearLayout profileOptions;
|
||||||
View divider;
|
View divider;
|
||||||
|
|
||||||
|
boolean initSwitcher;
|
||||||
|
|
||||||
ProfileViewHolder(View itemView) {
|
ProfileViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
title = itemView.findViewById(R.id.title);
|
title = itemView.findViewById(R.id.title);
|
||||||
descr = itemView.findViewById(R.id.description);
|
descr = itemView.findViewById(R.id.description);
|
||||||
aSwitch = itemView.findViewById(R.id.compound_button);
|
switcher = itemView.findViewById(R.id.compound_button);
|
||||||
icon = itemView.findViewById(R.id.icon);
|
icon = itemView.findViewById(R.id.icon);
|
||||||
profileOptions = itemView.findViewById(R.id.profile_settings);
|
profileOptions = itemView.findViewById(R.id.profile_settings);
|
||||||
divider = itemView.findViewById(R.id.divider_bottom);
|
divider = itemView.findViewById(R.id.divider_bottom);
|
||||||
menuIcon = itemView.findViewById(R.id.menu_image);
|
menuIcon = itemView.findViewById(R.id.menu_image);
|
||||||
|
|
||||||
|
profileOptions.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
int pos = getAdapterPosition();
|
||||||
|
if (pos != RecyclerView.NO_POSITION && listener != null) {
|
||||||
|
Object o = items.get(pos);
|
||||||
|
if (o instanceof ApplicationMode) {
|
||||||
|
listener.onProfilePressed((ApplicationMode) o);
|
||||||
|
} else {
|
||||||
|
listener.onButtonPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
switcher.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
int pos = getAdapterPosition();
|
||||||
|
if (pos != RecyclerView.NO_POSITION && listener != null && !initSwitcher) {
|
||||||
|
Object o = items.get(pos);
|
||||||
|
if (o instanceof ApplicationMode) {
|
||||||
|
final ApplicationMode item = (ApplicationMode) o;
|
||||||
|
if (isChecked) {
|
||||||
|
selectedItems.add(item);
|
||||||
|
} else {
|
||||||
|
selectedItems.remove(item);
|
||||||
|
}
|
||||||
|
updateViewHolder(ProfileViewHolder.this, item);
|
||||||
|
listener.onProfileSelected(item, isChecked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ProfileListener {
|
public interface ProfileMenuAdapterListener {
|
||||||
|
|
||||||
void changeProfileStatus(ApplicationMode item, boolean isSelected);
|
void onProfileSelected(ApplicationMode item, boolean selected);
|
||||||
|
|
||||||
void editProfile(ApplicationMode item);
|
void onProfilePressed(ApplicationMode item);
|
||||||
|
|
||||||
|
void onButtonPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.profiles.ProfileMenuAdapter.ProfileListener;
|
import net.osmand.plus.profiles.ProfileMenuAdapter.ProfileMenuAdapterListener;
|
||||||
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SelectProfileListener;
|
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SelectProfileListener;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -43,7 +43,7 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
|
||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
private LinearLayout addNewProfileBtn;
|
private LinearLayout addNewProfileBtn;
|
||||||
|
|
||||||
ProfileListener listener = null;
|
ProfileMenuAdapterListener listener = null;
|
||||||
SelectProfileListener typeListener = null;
|
SelectProfileListener typeListener = null;
|
||||||
|
|
||||||
private List<ApplicationMode> allAppModes;
|
private List<ApplicationMode> allAppModes;
|
||||||
|
@ -85,7 +85,7 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
adapter = new ProfileMenuAdapter(allAppModes, availableAppModes, getMyApplication(), false);
|
adapter = new ProfileMenuAdapter(allAppModes, availableAppModes, getMyApplication(), null);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
return view;
|
return view;
|
||||||
|
@ -95,19 +95,19 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (listener == null) {
|
if (listener == null) {
|
||||||
listener = new ProfileListener() {
|
listener = new ProfileMenuAdapterListener() {
|
||||||
@Override
|
@Override
|
||||||
public void changeProfileStatus(ApplicationMode am, boolean isSelected) {
|
public void onProfileSelected(ApplicationMode am, boolean selected) {
|
||||||
if(isSelected) {
|
if(selected) {
|
||||||
availableAppModes.add(am);
|
availableAppModes.add(am);
|
||||||
} else {
|
} else {
|
||||||
availableAppModes.remove(am);
|
availableAppModes.remove(am);
|
||||||
}
|
}
|
||||||
ApplicationMode.changeProfileStatus(am, isSelected, getMyApplication());
|
ApplicationMode.changeProfileStatus(am, selected, getMyApplication());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void editProfile(ApplicationMode item) {
|
public void onProfilePressed(ApplicationMode item) {
|
||||||
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
|
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
|
||||||
intent.putExtra(PROFILE_STRING_KEY, item.getStringKey());
|
intent.putExtra(PROFILE_STRING_KEY, item.getStringKey());
|
||||||
if (!Algorithms.isEmpty(item.getUserProfileName())) {
|
if (!Algorithms.isEmpty(item.getUserProfileName())) {
|
||||||
|
@ -115,6 +115,10 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onButtonPressed() {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
adapter.setListener(listener);
|
adapter.setListener(listener);
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
public class MapStyleAction extends SwitchableAction<String> {
|
public class MapStyleAction extends SwitchableAction<String> {
|
||||||
|
|
||||||
|
@ -42,8 +43,8 @@ public class MapStyleAction extends SwitchableAction<String> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(MapActivity activity) {
|
public void execute(MapActivity activity) {
|
||||||
|
|
||||||
List<String> mapStyles = getFilteredStyles();
|
List<String> mapStyles = getFilteredStyles();
|
||||||
|
if (!Algorithms.isEmpty(mapStyles)) {
|
||||||
boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG));
|
boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG));
|
||||||
if (showBottomSheetStyles) {
|
if (showBottomSheetStyles) {
|
||||||
showChooseDialog(activity.getSupportFragmentManager());
|
showChooseDialog(activity.getSupportFragmentManager());
|
||||||
|
@ -57,6 +58,11 @@ public class MapStyleAction extends SwitchableAction<String> {
|
||||||
nextStyle = mapStyles.get(index + 1);
|
nextStyle = mapStyles.get(index + 1);
|
||||||
}
|
}
|
||||||
executeWithParams(activity, nextStyle);
|
executeWithParams(activity, nextStyle);
|
||||||
|
} else {
|
||||||
|
Toast.makeText(activity, R.string.quick_action_need_to_add_item_to_list,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -181,9 +187,8 @@ public class MapStyleAction extends SwitchableAction<String> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean fillParams(View root, MapActivity activity) {
|
public boolean fillParams(View root, MapActivity activity) {
|
||||||
super.fillParams(root, activity);
|
|
||||||
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
||||||
return true;
|
return super.fillParams(root, activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
private Bitmap bigIconBg;
|
private Bitmap bigIconBg;
|
||||||
private Bitmap bigIconBgStale;
|
private Bitmap bigIconBgStale;
|
||||||
private Bitmap bigIconBgSelected;
|
private Bitmap bigIconBgSelected;
|
||||||
|
private Bitmap bigIconBgSelectedStale;
|
||||||
private Bitmap placeholder;
|
private Bitmap placeholder;
|
||||||
|
|
||||||
private int smallIconSize;
|
private int smallIconSize;
|
||||||
|
@ -112,6 +113,8 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
? R.drawable.map_pin_user_stale_location_night : R.drawable.map_pin_user_stale_location_day);
|
? R.drawable.map_pin_user_stale_location_night : R.drawable.map_pin_user_stale_location_day);
|
||||||
bigIconBgSelected = BitmapFactory.decodeResource(res, night
|
bigIconBgSelected = BitmapFactory.decodeResource(res, night
|
||||||
? R.drawable.map_pin_user_location_selected_night : R.drawable.map_pin_user_location_selected_day);
|
? R.drawable.map_pin_user_location_selected_night : R.drawable.map_pin_user_location_selected_day);
|
||||||
|
bigIconBgSelectedStale = BitmapFactory.decodeResource(res, night
|
||||||
|
? R.drawable.map_pin_user_stale_location_selected_night : R.drawable.map_pin_user_stale_location_selected_day);
|
||||||
placeholder = BitmapFactory.decodeResource(res, R.drawable.img_user_picture);
|
placeholder = BitmapFactory.decodeResource(res, R.drawable.img_user_picture);
|
||||||
|
|
||||||
smallIconSize = AndroidUtils.dpToPx(map, SMALL_ICON_SIZE_DP);
|
smallIconSize = AndroidUtils.dpToPx(map, SMALL_ICON_SIZE_DP);
|
||||||
|
@ -171,7 +174,8 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
image = placeholder;
|
image = placeholder;
|
||||||
}
|
}
|
||||||
if (selected) {
|
if (selected) {
|
||||||
drawBigIcon(canvas, x, y, image, bigIconBgSelected);
|
Bitmap bg = isStale(point) ? bigIconBgSelectedStale : bigIconBgSelected;
|
||||||
|
drawBigIcon(canvas, x, y, image, bg);
|
||||||
} else if (pointsType == PointsType.STANDARD) {
|
} else if (pointsType == PointsType.STANDARD) {
|
||||||
int radius = getRadiusPoi(tb);
|
int radius = getRadiusPoi(tb);
|
||||||
float density = tb.getDensity();
|
float density = tb.getDensity();
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
quickActionButton = (ImageButton) mapActivity.findViewById(R.id.map_quick_actions_button);
|
quickActionButton = (ImageButton) mapActivity.findViewById(R.id.map_quick_actions_button);
|
||||||
setQuickActionButtonMargin();
|
setQuickActionButtonMargin();
|
||||||
isLayerOn = quickActionRegistry.isQuickActionOn();
|
isLayerOn = quickActionRegistry.isQuickActionOn();
|
||||||
nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
nightMode = app.getDaynightHelper().isNightMode();
|
||||||
updateQuickActionButton(false);
|
updateQuickActionButton(false);
|
||||||
quickActionButton.setContentDescription(mapActivity.getString(R.string.configure_screen_quick_action));
|
quickActionButton.setContentDescription(mapActivity.getString(R.string.configure_screen_quick_action));
|
||||||
quickActionButton.setOnClickListener(new View.OnClickListener() {
|
quickActionButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -375,7 +375,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings settings) {
|
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings settings) {
|
||||||
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
boolean nightMode = app.getDaynightHelper().isNightMode();
|
||||||
if (isInMovingMarkerMode()) {
|
if (isInMovingMarkerMode()) {
|
||||||
canvas.translate(box.getCenterPixelX() - contextMarker.getWidth() / 2, box.getCenterPixelY() - contextMarker.getHeight());
|
canvas.translate(box.getCenterPixelX() - contextMarker.getWidth() / 2, box.getCenterPixelY() - contextMarker.getHeight());
|
||||||
contextMarker.draw(canvas);
|
contextMarker.draw(canvas);
|
||||||
|
|
|
@ -13,6 +13,7 @@ import android.graphics.PointF;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.graphics.Shader;
|
import android.graphics.Shader;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
@ -97,6 +98,8 @@ public class RulerControlLayer extends OsmandMapLayer {
|
||||||
private Path redCompassLines = new Path();
|
private Path redCompassLines = new Path();
|
||||||
|
|
||||||
private double[] degrees = new double[72];
|
private double[] degrees = new double[72];
|
||||||
|
private String[] cardinalDirections = {"N", "NE", "E", "SE", "S", "SW", "W", "NW"};
|
||||||
|
|
||||||
private int[] arcColors = {Color.parseColor("#00237BFF"), Color.parseColor("#237BFF"), Color.parseColor("#00237BFF")};
|
private int[] arcColors = {Color.parseColor("#00237BFF"), Color.parseColor("#237BFF"), Color.parseColor("#00237BFF")};
|
||||||
|
|
||||||
private float cachedHeading = 0;
|
private float cachedHeading = 0;
|
||||||
|
@ -450,8 +453,7 @@ public class RulerControlLayer extends OsmandMapLayer {
|
||||||
double maxCircleRadius = maxRadius;
|
double maxCircleRadius = maxRadius;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while ((maxCircleRadius -= radius) > 0) {
|
while ((maxCircleRadius -= radius) > 0) {
|
||||||
cacheDistances.add(OsmAndFormatter
|
cacheDistances.add(OsmAndFormatter.getFormattedDistance((float) roundedDist * i++, app, false));
|
||||||
.getFormattedDistance((float) roundedDist * i++, app, false).replaceAll(" ", ""));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +462,7 @@ public class RulerControlLayer extends OsmandMapLayer {
|
||||||
if (!tb.isZoomAnimated()) {
|
if (!tb.isZoomAnimated()) {
|
||||||
float circleRadius = radius * circleNumber;
|
float circleRadius = radius * circleNumber;
|
||||||
String text = cacheDistances.get(circleNumber - 1);
|
String text = cacheDistances.get(circleNumber - 1);
|
||||||
float[] textCoords = calculateDistanceTextCoords(text, circleRadius, center, attrs);
|
float[] textCoords = calculateTextCoords(text, text, circleRadius, center, attrs);
|
||||||
|
|
||||||
canvas.rotate(-tb.getRotate(), center.x, center.y);
|
canvas.rotate(-tb.getRotate(), center.x, center.y);
|
||||||
canvas.drawCircle(center.x, center.y, radius * circleNumber, attrs.shadowPaint);
|
canvas.drawCircle(center.x, center.y, radius * circleNumber, attrs.shadowPaint);
|
||||||
|
@ -477,9 +479,17 @@ public class RulerControlLayer extends OsmandMapLayer {
|
||||||
canvas.drawText(text, textCoords[2], textCoords[3], attrs.paint2);
|
canvas.drawText(text, textCoords[2], textCoords[3], attrs.paint2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float[] calculateDistanceTextCoords(String text, float drawingTextRadius, QuadPoint center, RenderingLineAttributes attrs) {
|
private float[] calculateTextCoords(String topOrLeftText, String rightOrBottomText, float drawingTextRadius, QuadPoint center, RenderingLineAttributes attrs) {
|
||||||
Rect bounds = new Rect();
|
Rect boundsDistance = new Rect();
|
||||||
attrs.paint2.getTextBounds(text, 0, text.length(), bounds);
|
Rect boundsHeading;
|
||||||
|
|
||||||
|
if (topOrLeftText.equals(rightOrBottomText)) {
|
||||||
|
boundsHeading = boundsDistance;
|
||||||
|
} else {
|
||||||
|
boundsHeading = new Rect();
|
||||||
|
attrs.paint2.getTextBounds(rightOrBottomText, 0, rightOrBottomText.length(), boundsHeading);
|
||||||
|
}
|
||||||
|
attrs.paint2.getTextBounds(topOrLeftText, 0, topOrLeftText.length(), boundsDistance);
|
||||||
|
|
||||||
// coords of left or top text
|
// coords of left or top text
|
||||||
float x1 = 0;
|
float x1 = 0;
|
||||||
|
@ -489,15 +499,15 @@ public class RulerControlLayer extends OsmandMapLayer {
|
||||||
float y2 = 0;
|
float y2 = 0;
|
||||||
|
|
||||||
if (textSide == TextSide.VERTICAL) {
|
if (textSide == TextSide.VERTICAL) {
|
||||||
x1 = center.x - bounds.width() / 2;
|
x1 = center.x - boundsHeading.width() / 2f;
|
||||||
y1 = center.y - drawingTextRadius + bounds.height() / 2;
|
y1 = center.y - drawingTextRadius + boundsHeading.height() / 2f;
|
||||||
x2 = center.x - bounds.width() / 2;
|
x2 = center.x - boundsDistance.width() / 2f;
|
||||||
y2 = center.y + drawingTextRadius + bounds.height() / 2;
|
y2 = center.y + drawingTextRadius + boundsDistance.height() / 2f;
|
||||||
} else if (textSide == TextSide.HORIZONTAL) {
|
} else if (textSide == TextSide.HORIZONTAL) {
|
||||||
x1 = center.x - drawingTextRadius - bounds.width() / 2;
|
x1 = center.x - drawingTextRadius - boundsHeading.width() / 2f;
|
||||||
y1 = center.y + bounds.height() / 2;
|
y1 = center.y + boundsHeading.height() / 2f;
|
||||||
x2 = center.x + drawingTextRadius - bounds.width() / 2;
|
x2 = center.x + drawingTextRadius - boundsDistance.width() / 2f;
|
||||||
y2 = center.y + bounds.height() / 2;
|
y2 = center.y + boundsDistance.height() / 2f;
|
||||||
}
|
}
|
||||||
return new float[]{x1, y1, x2, y2};
|
return new float[]{x1, y1, x2, y2};
|
||||||
}
|
}
|
||||||
|
@ -531,10 +541,18 @@ public class RulerControlLayer extends OsmandMapLayer {
|
||||||
canvas.drawPath(arrow, triangleHeadingPaint);
|
canvas.drawPath(arrow, triangleHeadingPaint);
|
||||||
canvas.rotate(-cachedHeading, center.x, center.y);
|
canvas.rotate(-cachedHeading, center.x, center.y);
|
||||||
|
|
||||||
String text = cacheDistances.get(COMPASS_CIRCLE_ID - 1);
|
String distance = cacheDistances.get(COMPASS_CIRCLE_ID - 1);
|
||||||
float[] textCoords = calculateDistanceTextCoords(text, radiusLength + AndroidUtils.dpToPx(app, 16), center, attrs);
|
String heading = OsmAndFormatter.getFormattedAzimuth(cachedHeading, app) + " " + getCardinalDirectionForDegrees(cachedHeading);
|
||||||
|
float[] textCoords = calculateTextCoords(distance, heading, radiusLength + AndroidUtils.dpToPx(app, 16), center, attrs);
|
||||||
canvas.rotate(-tileBox.getRotate(), center.x, center.y);
|
canvas.rotate(-tileBox.getRotate(), center.x, center.y);
|
||||||
drawTextCoords(canvas, text, textCoords, attrs);
|
|
||||||
|
setAttrsPaintsTypeface(attrs, Typeface.DEFAULT_BOLD);
|
||||||
|
canvas.drawText(heading, textCoords[0], textCoords[1], attrs.paint3);
|
||||||
|
canvas.drawText(heading, textCoords[0], textCoords[1], attrs.paint2);
|
||||||
|
setAttrsPaintsTypeface(attrs, null);
|
||||||
|
|
||||||
|
canvas.drawText(distance, textCoords[2], textCoords[3], attrs.paint3);
|
||||||
|
canvas.drawText(distance, textCoords[2], textCoords[3], attrs.paint2);
|
||||||
canvas.rotate(tileBox.getRotate(), center.x, center.y);
|
canvas.rotate(tileBox.getRotate(), center.x, center.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -583,7 +601,7 @@ public class RulerControlLayer extends OsmandMapLayer {
|
||||||
compass.moveTo(lineStartX, lineStartY);
|
compass.moveTo(lineStartX, lineStartY);
|
||||||
compass.lineTo(lineStopX, lineStopY);
|
compass.lineTo(lineStopX, lineStopY);
|
||||||
}
|
}
|
||||||
if (i % 9 == 0 && i % 6 != 0) {
|
if (i % 9 == 0 && i != 18) {
|
||||||
redCompassLines.moveTo(lineStartX, lineStartY);
|
redCompassLines.moveTo(lineStartX, lineStartY);
|
||||||
redCompassLines.lineTo(lineStopX, lineStopY);
|
redCompassLines.lineTo(lineStopX, lineStopY);
|
||||||
}
|
}
|
||||||
|
@ -604,6 +622,7 @@ public class RulerControlLayer extends OsmandMapLayer {
|
||||||
float textMargin = AndroidUtils.dpToPx(app, 14);
|
float textMargin = AndroidUtils.dpToPx(app, 14);
|
||||||
attrs.paint2.setTextAlign(Paint.Align.CENTER);
|
attrs.paint2.setTextAlign(Paint.Align.CENTER);
|
||||||
attrs.paint3.setTextAlign(Paint.Align.CENTER);
|
attrs.paint3.setTextAlign(Paint.Align.CENTER);
|
||||||
|
setAttrsPaintsTypeface(attrs, Typeface.DEFAULT_BOLD);
|
||||||
|
|
||||||
for (int i = 0; i < degrees.length; i += 9) {
|
for (int i = 0; i < degrees.length; i += 9) {
|
||||||
String cardinalDirection = getCardinalDirection(i);
|
String cardinalDirection = getCardinalDirection(i);
|
||||||
|
@ -612,15 +631,23 @@ public class RulerControlLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.translate(center.x, center.y);
|
canvas.translate(center.x, center.y);
|
||||||
canvas.rotate(i * 5 + 90);
|
canvas.rotate(-i * 5 - 90);
|
||||||
canvas.translate(0, radiusLength - textMargin - textWidth / 2);
|
canvas.translate(0, radiusLength - textMargin - textWidth / 2);
|
||||||
canvas.rotate(-i * 5 - tileBox.getRotate() - 90);
|
canvas.rotate(i * 5 - tileBox.getRotate() + 90);
|
||||||
|
|
||||||
canvas.drawText(cardinalDirection, 0, 0, attrs.paint3);
|
canvas.drawText(cardinalDirection, 0, 0, attrs.paint3);
|
||||||
canvas.drawText(cardinalDirection, 0, 0, attrs.paint2);
|
canvas.drawText(cardinalDirection, 0, 0, attrs.paint2);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
attrs.paint2.setTextAlign(Paint.Align.LEFT);
|
||||||
|
attrs.paint3.setTextAlign(Paint.Align.LEFT);
|
||||||
|
setAttrsPaintsTypeface(attrs, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAttrsPaintsTypeface(RenderingLineAttributes attrs, Typeface typeface) {
|
||||||
|
attrs.paint2.setTypeface(typeface);
|
||||||
|
attrs.paint3.setTypeface(typeface);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateArcShader(float radiusLength, QuadPoint center) {
|
private void updateArcShader(float radiusLength, QuadPoint center) {
|
||||||
|
@ -631,25 +658,37 @@ public class RulerControlLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private String getCardinalDirection(int i) {
|
private String getCardinalDirection(int i) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
return "E";
|
return cardinalDirections[2];
|
||||||
} else if (i == 9) {
|
} else if (i == 9) {
|
||||||
return "NE";
|
return cardinalDirections[1];
|
||||||
} else if (i == 18) {
|
} else if (i == 18) {
|
||||||
return "N";
|
return cardinalDirections[0];
|
||||||
} else if (i == 27) {
|
} else if (i == 27) {
|
||||||
return "NW";
|
return cardinalDirections[7];
|
||||||
} else if (i == 36) {
|
} else if (i == 36) {
|
||||||
return "W";
|
return cardinalDirections[6];
|
||||||
} else if (i == 45) {
|
} else if (i == 45) {
|
||||||
return "SW";
|
return cardinalDirections[5];
|
||||||
} else if (i == 54) {
|
} else if (i == 54) {
|
||||||
return "S";
|
return cardinalDirections[4];
|
||||||
} else if (i == 63) {
|
} else if (i == 63) {
|
||||||
return "SE";
|
return cardinalDirections[3];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getCardinalDirectionForDegrees(double degrees) {
|
||||||
|
while (degrees < 0) {
|
||||||
|
degrees += 360;
|
||||||
|
}
|
||||||
|
int index = (int) Math.floor(((degrees + 22.5) % 360) / 45);
|
||||||
|
if (index >= 0 && cardinalDirections.length > index) {
|
||||||
|
return cardinalDirections[index];
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private enum TextSide {
|
private enum TextSide {
|
||||||
VERTICAL,
|
VERTICAL,
|
||||||
HORIZONTAL
|
HORIZONTAL
|
||||||
|
|
|
@ -17,8 +17,6 @@ import android.support.annotation.NonNull;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.router.TurnType;
|
import net.osmand.router.TurnType;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class TurnPathHelper {
|
public class TurnPathHelper {
|
||||||
|
|
||||||
//Index of processed turn
|
//Index of processed turn
|
||||||
|
@ -568,7 +566,7 @@ public class TurnPathHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Path getPathFromTurnType(Resources res, Map<TurnResource, Path> cache, int firstTurn,
|
public static Path getPathFromTurnType(Resources res, int firstTurn,
|
||||||
int secondTurn, int thirdTurn, int turnIndex, float coef, boolean leftSide, boolean smallArrow) {
|
int secondTurn, int thirdTurn, int turnIndex, float coef, boolean leftSide, boolean smallArrow) {
|
||||||
|
|
||||||
int firstTurnType = TurnType.valueOf(firstTurn, leftSide).getValue();
|
int firstTurnType = TurnType.valueOf(firstTurn, leftSide).getValue();
|
||||||
|
@ -621,20 +619,8 @@ public class TurnPathHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Path p = cache.get(turnResource);
|
|
||||||
if (p == null) {
|
|
||||||
int size = res.getDimensionPixelSize(R.dimen.widget_turn_lane_size);
|
int size = res.getDimensionPixelSize(R.dimen.widget_turn_lane_size);
|
||||||
p = getPathFromTurnResource(turnResource, size, smallArrow);
|
return getPathFromTurnResource(turnResource, size, smallArrow);
|
||||||
cache.put(turnResource, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Maybe redundant scaling
|
|
||||||
/*
|
|
||||||
* float bRatio = (float)b.getWidth() / (float)b.getHeight(); float s = 72f * coef; int wq = Math.round(s /
|
|
||||||
* bRatio); int hq = Math.round(s); b = Bitmap.createScaledBitmap(b, wq, hq, false);
|
|
||||||
*/
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Path getPathFromTurnResource(TurnResource turnResource, int size, boolean smallArrow) {
|
private static Path getPathFromTurnResource(TurnResource turnResource, int size, boolean smallArrow) {
|
||||||
|
|
|
@ -195,7 +195,7 @@ public class NextTurnInfoWidget extends TextInfoWidget {
|
||||||
if(textPaint != null ) {
|
if(textPaint != null ) {
|
||||||
if (turnType != null && !mini && turnType.getExitOut() > 0) {
|
if (turnType != null && !mini && turnType.getExitOut() > 0) {
|
||||||
canvas.drawText(turnType.getExitOut() + "", centerText.x,
|
canvas.drawText(turnType.getExitOut() + "", centerText.x,
|
||||||
centerText.y - textPaint.ascent() / 2, textPaint);
|
centerText.y - (textPaint.descent() + textPaint.ascent()) / 2, textPaint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,6 @@ import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.plus.views.TurnPathHelper;
|
import net.osmand.plus.views.TurnPathHelper;
|
||||||
import net.osmand.plus.views.TurnPathHelper.TurnResource;
|
|
||||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WidgetState;
|
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WidgetState;
|
||||||
import net.osmand.router.RouteResultPreparation;
|
import net.osmand.router.RouteResultPreparation;
|
||||||
import net.osmand.router.TurnType;
|
import net.osmand.router.TurnType;
|
||||||
|
@ -59,9 +58,7 @@ import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class RouteInfoWidgetsFactory {
|
public class RouteInfoWidgetsFactory {
|
||||||
|
|
||||||
|
@ -869,7 +866,6 @@ public class RouteInfoWidgetsFactory {
|
||||||
int[] lanes = null;
|
int[] lanes = null;
|
||||||
boolean imminent = false;
|
boolean imminent = false;
|
||||||
private Context ctx;
|
private Context ctx;
|
||||||
private Map<TurnResource, Path> pathsCache = new HashMap<>();
|
|
||||||
private Paint paintBlack;
|
private Paint paintBlack;
|
||||||
private Paint paintRouteDirection;
|
private Paint paintRouteDirection;
|
||||||
private Paint paintSecondTurn;
|
private Paint paintSecondTurn;
|
||||||
|
@ -896,7 +892,7 @@ public class RouteInfoWidgetsFactory {
|
||||||
paintBlack = new Paint(Paint.ANTI_ALIAS_FLAG);
|
paintBlack = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
paintBlack.setStyle(Style.STROKE);
|
paintBlack.setStyle(Style.STROKE);
|
||||||
paintBlack.setColor(Color.BLACK);
|
paintBlack.setColor(Color.BLACK);
|
||||||
paintBlack.setStrokeWidth(3.5f);
|
paintBlack.setStrokeWidth(scaleCoefficent);
|
||||||
|
|
||||||
paintRouteDirection = new Paint(Paint.ANTI_ALIAS_FLAG);
|
paintRouteDirection = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
paintRouteDirection.setStyle(Style.FILL);
|
paintRouteDirection.setStyle(Style.FILL);
|
||||||
|
@ -921,7 +917,7 @@ public class RouteInfoWidgetsFactory {
|
||||||
|
|
||||||
RectF imgBounds = new RectF();
|
RectF imgBounds = new RectF();
|
||||||
if (thirdTurnType > 0) {
|
if (thirdTurnType > 0) {
|
||||||
Path p = TurnPathHelper.getPathFromTurnType(ctx.getResources(), pathsCache, turnType,
|
Path p = TurnPathHelper.getPathFromTurnType(ctx.getResources(), turnType,
|
||||||
secondTurnType, thirdTurnType, TurnPathHelper.THIRD_TURN, coef, leftSide, true);
|
secondTurnType, thirdTurnType, TurnPathHelper.THIRD_TURN, coef, leftSide, true);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
RectF b = new RectF();
|
RectF b = new RectF();
|
||||||
|
@ -936,7 +932,7 @@ public class RouteInfoWidgetsFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (secondTurnType > 0) {
|
if (secondTurnType > 0) {
|
||||||
Path p = TurnPathHelper.getPathFromTurnType(ctx.getResources(), pathsCache, turnType,
|
Path p = TurnPathHelper.getPathFromTurnType(ctx.getResources(), turnType,
|
||||||
secondTurnType, thirdTurnType, TurnPathHelper.SECOND_TURN, coef, leftSide, true);
|
secondTurnType, thirdTurnType, TurnPathHelper.SECOND_TURN, coef, leftSide, true);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
RectF b = new RectF();
|
RectF b = new RectF();
|
||||||
|
@ -950,7 +946,7 @@ public class RouteInfoWidgetsFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Path p = TurnPathHelper.getPathFromTurnType(ctx.getResources(), pathsCache, turnType,
|
Path p = TurnPathHelper.getPathFromTurnType(ctx.getResources(), turnType,
|
||||||
secondTurnType, thirdTurnType, TurnPathHelper.FIRST_TURN, coef, leftSide, true);
|
secondTurnType, thirdTurnType, TurnPathHelper.FIRST_TURN, coef, leftSide, true);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
RectF b = new RectF();
|
RectF b = new RectF();
|
||||||
|
@ -1037,7 +1033,7 @@ public class RouteInfoWidgetsFactory {
|
||||||
Path firstTurnPath = null;
|
Path firstTurnPath = null;
|
||||||
|
|
||||||
if (thirdTurnType > 0) {
|
if (thirdTurnType > 0) {
|
||||||
Path p = TurnPathHelper.getPathFromTurnType(ctx.getResources(), pathsCache, turnType,
|
Path p = TurnPathHelper.getPathFromTurnType(ctx.getResources(), turnType,
|
||||||
secondTurnType, thirdTurnType, TurnPathHelper.THIRD_TURN, coef, leftSide, true);
|
secondTurnType, thirdTurnType, TurnPathHelper.THIRD_TURN, coef, leftSide, true);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
RectF b = new RectF();
|
RectF b = new RectF();
|
||||||
|
@ -1053,7 +1049,7 @@ public class RouteInfoWidgetsFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (secondTurnType > 0) {
|
if (secondTurnType > 0) {
|
||||||
Path p = TurnPathHelper.getPathFromTurnType(ctx.getResources(), pathsCache, turnType,
|
Path p = TurnPathHelper.getPathFromTurnType(ctx.getResources(), turnType,
|
||||||
secondTurnType, thirdTurnType, TurnPathHelper.SECOND_TURN, coef, leftSide, true);
|
secondTurnType, thirdTurnType, TurnPathHelper.SECOND_TURN, coef, leftSide, true);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
RectF b = new RectF();
|
RectF b = new RectF();
|
||||||
|
@ -1068,7 +1064,7 @@ public class RouteInfoWidgetsFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Path p = TurnPathHelper.getPathFromTurnType(ctx.getResources(), pathsCache, turnType,
|
Path p = TurnPathHelper.getPathFromTurnType(ctx.getResources(), turnType,
|
||||||
secondTurnType, thirdTurnType, TurnPathHelper.FIRST_TURN, coef, leftSide, true);
|
secondTurnType, thirdTurnType, TurnPathHelper.FIRST_TURN, coef, leftSide, true);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
RectF b = new RectF();
|
RectF b = new RectF();
|
||||||
|
|