Merge branch 'master' into app_profiles_2
|
@ -35,12 +35,20 @@
|
|||
android:layout_marginStart="@dimen/list_item_icon_margin_left"
|
||||
tools:src="@drawable/img_user_picture"/>
|
||||
|
||||
<LinearLayout
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/content_padding_standard"
|
||||
android:layout_marginRight="@dimen/content_padding_standard"
|
||||
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">
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
|
@ -51,7 +59,6 @@
|
|||
android:maxLines="1"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/list_item_title_text_size"
|
||||
android:paddingTop="@dimen/content_padding_half"
|
||||
app:typeface="@string/font_roboto_regular"
|
||||
tools:text="Share location"/>
|
||||
|
||||
|
@ -117,7 +124,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:paddingBottom="@dimen/content_padding_half"
|
||||
tools:visibility="visible">
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
|
@ -137,6 +143,8 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/check_box"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -64,11 +64,13 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
|
|||
if (usedBy and usageIntent > 0) {
|
||||
usedBy -= usageIntent
|
||||
}
|
||||
if (usedBy == 0) {
|
||||
when {
|
||||
usedBy == 0 -> {
|
||||
shouldCleanupResources = false
|
||||
val serviceIntent = Intent(ctx, TelegramService::class.java)
|
||||
ctx.stopService(serviceIntent)
|
||||
} else if (isUsedByMyLocation(usedBy)) {
|
||||
}
|
||||
isUsedByMyLocation(usedBy) -> {
|
||||
val app = app()
|
||||
if (app.settings.sendMyLocInterval >= OFF_INTERVAL_THRESHOLD && serviceOffInterval == 0L) {
|
||||
serviceOffInterval = app.settings.sendMyLocInterval
|
||||
|
@ -77,12 +79,15 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
|
|||
}
|
||||
app.notificationHelper.refreshNotification(NotificationType.LOCATION)
|
||||
}
|
||||
isUsedByUsersLocations(usedBy) -> removeLocationUpdates()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
||||
val app = app()
|
||||
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)
|
||||
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()
|
||||
}
|
||||
|
||||
|
||||
override fun onProviderEnabled(provider: String) {}
|
||||
|
||||
|
||||
override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {}
|
||||
|
||||
override fun onTaskRemoved(rootIntent: Intent) {
|
||||
|
|
|
@ -45,7 +45,7 @@ private const val TIMELINE_TAB_POS = 2
|
|||
|
||||
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 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 android:state_enabled="false">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/activity_background_dark" />
|
||||
<solid android:color="@color/card_and_list_background_dark" />
|
||||
<corners android:radius="4dp" />
|
||||
</shape>
|
||||
</item>
|
||||
|
@ -16,7 +16,7 @@
|
|||
<shape android:shape="rectangle">
|
||||
<solid android:color="@null" />
|
||||
<corners android:radius="4dp" />
|
||||
<stroke android:width="1dp" android:color="@color/divider_dark" />
|
||||
<stroke android:width="1dp" android:color="@color/inactive_pages_dark" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
|
@ -16,7 +16,7 @@
|
|||
<shape android:shape="rectangle">
|
||||
<solid android:color="@null" />
|
||||
<corners android:radius="4dp" />
|
||||
<stroke android:width="1dp" android:color="@color/divider_light" />
|
||||
<stroke android:width="1dp" android:color="@color/profile_button_gray" />
|
||||
</shape>
|
||||
</item>
|
||||
</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">
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@color/inactive_buttons_and_links_dark"/>
|
||||
<solid android:color="@color/inactive_pages_dark"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@color/inactive_buttons_and_links_light"/>
|
||||
<solid android:color="@color/inactive_pages_light"/>
|
||||
</shape>
|
||||
</item>
|
||||
</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"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -17,8 +15,7 @@
|
|||
android:id="@+id/scrollable_items_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/bottom_sheet_content_padding_small"/>
|
||||
android:orientation="vertical" />
|
||||
|
||||
</ScrollView>
|
||||
|
||||
|
@ -27,68 +24,33 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/bottom_row_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
android:visibility="gone" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/buttons_container"
|
||||
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:layout_width="0dp"
|
||||
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>
|
||||
layout="@layout/bottom_sheet_dialog_button" />
|
||||
|
||||
<View
|
||||
android:id="@+id/bottom_buttons_divider"
|
||||
android:layout_width="1dp"
|
||||
android:id="@+id/buttons_divider"
|
||||
android:layout_width="@dimen/content_padding"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/dashboard_divider"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"/>
|
||||
tools:visibility="visible" />
|
||||
|
||||
<FrameLayout
|
||||
<include
|
||||
android:id="@+id/right_bottom_button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
layout="@layout/bottom_sheet_dialog_button"
|
||||
android:visibility="gone"
|
||||
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>
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/profile_settings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/setting_profile_item_height"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
@ -12,25 +13,24 @@
|
|||
android:id="@+id/icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="@dimen/setting_profile_image_margin"
|
||||
tools:src="@drawable/ic_action_bicycle_dark"/>
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/favorites_icon_right_margin"
|
||||
tools:src="@drawable/ic_action_bicycle_dark" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="63dp"
|
||||
android:layout_height="@dimen/setting_profile_item_height"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="3"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
@ -38,57 +38,50 @@
|
|||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textColor="@color/main_font_dark"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="Bicycle"/>
|
||||
tools:text="Bicycle" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
tools:text="Type: Bicycle"/>
|
||||
tools:text="Type: Bicycle" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:id="@+id/menu_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
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:paddingEnd="10dp"
|
||||
android:paddingLeft="@dimen/setting_profile_item_switch_margin"
|
||||
android:paddingEnd="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:src="@drawable/ic_action_additional_option"
|
||||
android:tint="?attr/primary_icon_color"/>
|
||||
android:tint="?attr/primary_icon_color" />
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/compound_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
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:clickable="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"/>
|
||||
</LinearLayout>
|
||||
android:focusableInTouchMode="true"
|
||||
android:padding="@dimen/content_padding" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -96,8 +89,7 @@
|
|||
android:id="@+id/divider_bottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/settings_divider"/>
|
||||
|
||||
android:background="@color/settings_divider" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -114,6 +114,11 @@
|
|||
<attr name="card_and_list_background_basic" format="reference" />
|
||||
<attr name="activity_background_basic" 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 name="PagerSlidingTabStrip">
|
||||
|
|
|
@ -478,12 +478,25 @@
|
|||
<color name="additional_description_light">#b3b3b3</color>
|
||||
<color name="active_buttons_and_links_light">#237bff</color>
|
||||
<color name="active_buttons_and_links_dark">#d28521</color>
|
||||
<color name="inactive_buttons_and_links_light">#cccccc</color>
|
||||
<color name="inactive_buttons_and_links_dark">#505050</color>
|
||||
<color name="active_buttons_and_links_pressed_light">#0F67EB</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_dark">#66d28521</color>
|
||||
<color name="settings_divider">#dcdcdc</color>
|
||||
<color name="profile_button_gray">#EFEFEF</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>
|
|
@ -18,6 +18,7 @@
|
|||
<dimen name="card_button_progress_size">32dp</dimen>
|
||||
<dimen name="card_button_progress_size_small">24dp</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_border">6dp</dimen>
|
||||
|
@ -342,9 +343,7 @@
|
|||
<dimen name="pages_item_padding">3dp</dimen>
|
||||
<dimen name="pages_item_margin">4dp</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>
|
||||
|
||||
</resources>
|
|
@ -3164,5 +3164,6 @@
|
|||
<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_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>
|
||||
|
|
|
@ -246,6 +246,11 @@
|
|||
<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="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 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="activity_background_basic">@color/activity_background_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 name="FreeVersionBanner" parent="OsmandDarkTheme">
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.database.Cursor;
|
|||
import android.database.DatabaseUtils;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.provider.Settings;
|
||||
|
||||
import net.osmand.AndroidNetworkUtils;
|
||||
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 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_FINISH_DATE = "finishDate";
|
||||
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>();
|
||||
additionalData.put(PARAM_OS, "android");
|
||||
additionalData.put(PARAM_START_DATE, String.valueOf(d.startDate));
|
||||
additionalData.put(PARAM_FINISH_DATE, String.valueOf(d.finishDate));
|
||||
additionalData.put(PARAM_VERSION, Version.getFullVersion(ctx));
|
||||
additionalData.put(PARAM_LANG, ctx.getLanguage() + "");
|
||||
additionalData.put(PARAM_FIRST_INSTALL_DAYS, String.valueOf(ctx.getAppInitializer().getFirstInstalledDays()));
|
||||
additionalData.put(PARAM_NUMBER_OF_STARTS, String.valueOf(ctx.getAppInitializer().getNumberOfStarts()));
|
||||
try {
|
||||
additionalData.put(PARAM_USER_ID, Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
additionalData.put(PARAM_USER_ID, ctx.getUserAndroidId());
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
for (Map.Entry<String, String> entry : additionalData.entrySet()) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
|
@ -15,6 +16,7 @@ import android.os.AsyncTask;
|
|||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.support.multidex.MultiDex;
|
||||
import android.support.multidex.MultiDexApplication;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
@ -77,6 +79,7 @@ import java.io.PrintStream;
|
|||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import btools.routingapp.BRouterServiceConnection;
|
||||
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) {
|
||||
try {
|
||||
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) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(ctx);
|
||||
bld.setMessage(R.string.restart_is_required);
|
||||
|
@ -981,6 +1012,8 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
PlatformUtil.getLog(ErrorBottomSheetDialog.class).error("", e);
|
||||
}
|
||||
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<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<String> USER_ANDROID_ID = new StringPreference("user_android_id", "").makeGlobal();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
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 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.GPXFile;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
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.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
|
@ -447,7 +447,7 @@ public class TrackActivity extends TabActivity {
|
|||
result = app.getSavingTrackHelper().getCurrentGpx();
|
||||
} else {
|
||||
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();
|
||||
} else {
|
||||
result = GPXUtilities.loadGPXFile(file);
|
||||
|
@ -472,8 +472,16 @@ public class TrackActivity extends TabActivity {
|
|||
TrackActivity activity = getTrackActivity();
|
||||
if (activity != null) {
|
||||
activity.setSupportProgressBarIndeterminateVisibility(false);
|
||||
if (showTemporarily && result != null) {
|
||||
app.getSelectedGpxHelper().selectGpxFile(result, false, false);
|
||||
if (result != null) {
|
||||
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) {
|
||||
activity.onGPXFileReady(result);
|
||||
|
|
|
@ -75,6 +75,11 @@ public abstract class BottomSheetDialogFragment extends DialogFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
protected OsmandApplication requiredMyApplication() {
|
||||
return (OsmandApplication) requireActivity().getApplication();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Drawable getIcon(@DrawableRes int drawableRes, @ColorRes int color) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.base;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
@ -10,6 +11,7 @@ import android.support.annotation.DrawableRes;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -19,13 +21,13 @@ import android.view.ViewTreeObserver;
|
|||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.widgets.TextViewEx;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -44,6 +46,12 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
|
||||
private LinearLayout itemsContainer;
|
||||
|
||||
public enum DialogButtonType {
|
||||
PRIMARY,
|
||||
SECONDARY,
|
||||
STROKED
|
||||
}
|
||||
|
||||
@StringRes
|
||||
protected int dismissButtonStringRes = R.string.shared_string_cancel;
|
||||
|
||||
|
@ -57,7 +65,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
if (savedInstanceState != null) {
|
||||
usedOnMap = savedInstanceState.getBoolean(USED_ON_MAP_KEY);
|
||||
}
|
||||
nightMode = isNightMode();
|
||||
nightMode = isNightMode(requiredMyApplication());
|
||||
themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
}
|
||||
|
||||
|
@ -65,10 +73,8 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
|
||||
createMenuItems(savedInstanceState);
|
||||
|
||||
OsmandApplication app = getMyApplication();
|
||||
|
||||
View mainView = View.inflate(new ContextThemeWrapper(app, themeRes), R.layout.bottom_sheet_menu_base, null);
|
||||
Context ctx = requireContext();
|
||||
View mainView = View.inflate(new ContextThemeWrapper(ctx, themeRes), R.layout.bottom_sheet_menu_base, null);
|
||||
if (useScrollableItemsContainer()) {
|
||||
itemsContainer = (LinearLayout) mainView.findViewById(R.id.scrollable_items_container);
|
||||
} else {
|
||||
|
@ -79,12 +85,9 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
|
||||
inflateMenuItems();
|
||||
|
||||
int bottomDividerColorId = getBottomDividerColorId();
|
||||
if (bottomDividerColorId != DEFAULT_VALUE) {
|
||||
mainView.findViewById(R.id.bottom_row_divider).setBackgroundColor(getResolvedColor(bottomDividerColorId));
|
||||
}
|
||||
|
||||
mainView.findViewById(R.id.dismiss_button).setOnClickListener(new View.OnClickListener() {
|
||||
View dismissButton = mainView.findViewById(R.id.dismiss_button);
|
||||
setupDialogButton(dismissButton, DialogButtonType.STROKED, getDismissButtonTextId());
|
||||
dismissButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onDismissButtonClickAction();
|
||||
|
@ -92,19 +95,13 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
}
|
||||
});
|
||||
if (hideButtonsContainer()) {
|
||||
mainView.findViewById(R.id.bottom_row_divider).setVisibility(View.GONE);
|
||||
mainView.findViewById(R.id.buttons_container).setVisibility(View.GONE);
|
||||
} else {
|
||||
((TextView) mainView.findViewById(R.id.dismiss_button_text)).setText(getDismissButtonTextId());
|
||||
|
||||
int rightBottomButtonTextId = getRightBottomButtonTextId();
|
||||
if (rightBottomButtonTextId != DEFAULT_VALUE) {
|
||||
View buttonsDivider = mainView.findViewById(R.id.bottom_buttons_divider);
|
||||
buttonsDivider.setVisibility(View.VISIBLE);
|
||||
if (bottomDividerColorId != DEFAULT_VALUE) {
|
||||
buttonsDivider.setBackgroundColor(getResolvedColor(bottomDividerColorId));
|
||||
}
|
||||
mainView.findViewById(R.id.buttons_divider).setVisibility(View.VISIBLE);
|
||||
View rightButton = mainView.findViewById(R.id.right_bottom_button);
|
||||
setupDialogButton(rightButton, DialogButtonType.PRIMARY, rightBottomButtonTextId);
|
||||
rightButton.setVisibility(View.VISIBLE);
|
||||
rightButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -112,25 +109,25 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
onRightBottomButtonClick();
|
||||
}
|
||||
});
|
||||
((TextView) rightButton.findViewById(R.id.right_bottom_button_text)).setText(rightBottomButtonTextId);
|
||||
}
|
||||
}
|
||||
|
||||
setupHeightAndBackground(mainView);
|
||||
|
||||
return mainView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (!AndroidUiHelper.isOrientationPortrait(getActivity())) {
|
||||
FragmentActivity activity = requireActivity();
|
||||
if (!AndroidUiHelper.isOrientationPortrait(activity)) {
|
||||
final Window window = getDialog().getWindow();
|
||||
if (window != null) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
|
@ -147,9 +144,41 @@ 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);
|
||||
|
||||
protected void inflateMenuItems(){
|
||||
protected void inflateMenuItems() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
for (BaseBottomSheetItem item : items) {
|
||||
item.inflate(app, itemsContainer, nightMode);
|
||||
|
@ -172,7 +201,8 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
|
||||
@ColorInt
|
||||
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) {
|
||||
|
@ -187,6 +217,13 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
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;
|
||||
if (contentView.getHeight() > contentHeight) {
|
||||
if (useScrollableItemsContainer()) {
|
||||
|
@ -207,22 +244,13 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
} else {
|
||||
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) {
|
||||
int customHeight = getCustomHeight();
|
||||
int maxHeight = availableScreenHeight
|
||||
- AndroidUtils.dpToPx(getContext(), 1) // divider height
|
||||
- getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
||||
int maxHeight = availableScreenHeight - getResources().getDimensionPixelSize(R.dimen.dialog_button_ex_height);
|
||||
if (customHeight != DEFAULT_VALUE && customHeight <= maxHeight) {
|
||||
return customHeight;
|
||||
}
|
||||
|
@ -242,7 +270,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
}
|
||||
|
||||
@ColorRes
|
||||
protected int getBottomDividerColorId() {
|
||||
protected int getDividerColorId() {
|
||||
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;
|
||||
}
|
||||
|
||||
private boolean isNightMode() {
|
||||
private boolean isNightMode(@NonNull OsmandApplication app) {
|
||||
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();
|
||||
items.add(replaceStartItem);
|
||||
|
||||
items.add(new DividerHalfItem(getContext(), getBottomDividerColorId()));
|
||||
items.add(new DividerHalfItem(getContext(), getDividerColorId()));
|
||||
|
||||
BaseBottomSheetItem subsequentDestItem = new BottomSheetItemWithDescription.Builder()
|
||||
.setDescription(getString(R.string.subsequent_dest_description))
|
||||
|
@ -130,7 +130,7 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
|
|||
}
|
||||
|
||||
@Override
|
||||
protected int getBottomDividerColorId() {
|
||||
protected int getDividerColorId() {
|
||||
return nightMode ? R.color.route_info_bottom_view_bg_dark : -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -534,7 +534,6 @@ public class DownloadIndexesThread {
|
|||
boolean result = downloadFile(item, filesToReindex, forceWifi);
|
||||
success = result || success;
|
||||
if (result) {
|
||||
checkDownload(item);
|
||||
if (DownloadActivityType.isCountedInDownloads(item)) {
|
||||
downloads.set(downloads.get() + 1);
|
||||
}
|
||||
|
@ -664,8 +663,16 @@ public class DownloadIndexesThread {
|
|||
LOG.error("Copy exception", e);
|
||||
}
|
||||
} else {
|
||||
long start = System.currentTimeMillis();
|
||||
app.logMapDownloadEvent("start", item);
|
||||
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;
|
||||
}
|
||||
|
@ -678,7 +685,6 @@ public class DownloadIndexesThread {
|
|||
}
|
||||
|
||||
private void checkDownload(IndexItem item) {
|
||||
app.logMapDownloadEvent("done", item);
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("file_name", item.fileName);
|
||||
params.put("file_size", item.size);
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.content.res.Resources;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
@ -28,10 +27,10 @@ import android.widget.TextView;
|
|||
|
||||
import net.osmand.AndroidNetworkUtils;
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion;
|
||||
|
@ -283,7 +282,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
|||
protected String doInBackground(Void... params) {
|
||||
try {
|
||||
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);
|
||||
|
||||
return AndroidNetworkUtils.sendRequest(getMyApplication(),
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
|
|||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.provider.Settings;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
@ -677,11 +676,7 @@ public class InAppPurchaseHelper {
|
|||
parameters.put("lang", ctx.getLanguage() + "");
|
||||
parameters.put("nd", ctx.getAppInitializer().getFirstInstalledDays() + "");
|
||||
parameters.put("ns", ctx.getAppInitializer().getNumberOfStarts() + "");
|
||||
try {
|
||||
parameters.put("aid", Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
parameters.put("aid", ctx.getUserAndroidId());
|
||||
}
|
||||
|
||||
// Callback for when a purchase is finished
|
||||
|
|
|
@ -23,11 +23,12 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
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;
|
||||
|
||||
public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||
|
@ -40,7 +41,7 @@ public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
|
|||
private ProfileMenuAdapter adapter;
|
||||
private RecyclerView recyclerView;
|
||||
|
||||
private ProfileListener listener;
|
||||
private ProfileMenuAdapterListener listener;
|
||||
private UpdateMapRouteMenuListener updateMapRouteMenuListener;
|
||||
|
||||
@Override
|
||||
|
@ -55,7 +56,7 @@ public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
|
|||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent,
|
||||
Bundle savedInstanceState) {
|
||||
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 = (RecyclerView) View
|
||||
.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.recyclerview, null);
|
||||
|
@ -75,19 +76,20 @@ public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
listener = new ProfileListener() {
|
||||
if (listener == null) {
|
||||
listener = new ProfileMenuAdapterListener() {
|
||||
@Override
|
||||
public void changeProfileStatus(ApplicationMode item, boolean isSelected) {
|
||||
if (isSelected) {
|
||||
public void onProfileSelected(ApplicationMode item, boolean selected) {
|
||||
if (selected) {
|
||||
selectedModes.add(item);
|
||||
} else {
|
||||
selectedModes.remove(item);
|
||||
}
|
||||
ApplicationMode.changeProfileStatus(item, isSelected, getMyApplication());
|
||||
ApplicationMode.changeProfileStatus(item, selected, getMyApplication());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editProfile(ApplicationMode item) {
|
||||
public void onProfilePressed(ApplicationMode item) {
|
||||
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
|
||||
intent.putExtra(PROFILE_STRING_KEY, item.getStringKey());
|
||||
if (!Algorithms.isEmpty(item.getUserProfileName())) {
|
||||
|
@ -95,7 +97,16 @@ public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
|
|||
}
|
||||
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);
|
||||
allModes = ApplicationMode.allPossibleValues();
|
||||
allModes.remove(ApplicationMode.DEFAULT);
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
package net.osmand.plus.profiles;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
@ -26,22 +29,25 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
|||
|
||||
private List<Object> items = new ArrayList<>();
|
||||
private Set<ApplicationMode> selectedItems;
|
||||
private ProfileListener listener;
|
||||
@Nullable
|
||||
private ProfileMenuAdapterListener listener;
|
||||
private final OsmandApplication app;
|
||||
@ColorRes
|
||||
private int selectedIconColorRes;
|
||||
private boolean isBottomSheet = false;
|
||||
private static final String MANAGE_BTN = "manage_button";
|
||||
private boolean bottomButton;
|
||||
private String bottomButtonText;
|
||||
private static final String BUTTON_ITEM = "button_item";
|
||||
|
||||
public ProfileMenuAdapter(List<ApplicationMode> items, Set<ApplicationMode> selectedItems,
|
||||
OsmandApplication app, boolean isBottomSheet) {
|
||||
OsmandApplication app, String bottomButtonText) {
|
||||
this.items.addAll(items);
|
||||
if (isBottomSheet) {
|
||||
this.items.add(MANAGE_BTN);
|
||||
if (bottomButton) {
|
||||
this.items.add(BUTTON_ITEM);
|
||||
}
|
||||
this.app = app;
|
||||
this.selectedItems = selectedItems;
|
||||
this.isBottomSheet = isBottomSheet;
|
||||
this.bottomButton = !Algorithms.isEmpty(bottomButtonText);
|
||||
this.bottomButtonText = bottomButtonText;
|
||||
selectedIconColorRes = isNightMode(app)
|
||||
? R.color.active_buttons_and_links_dark
|
||||
: R.color.active_buttons_and_links_light;
|
||||
|
@ -51,12 +57,7 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
|||
return items;
|
||||
}
|
||||
|
||||
public void addItem(ApplicationMode profileItem) {
|
||||
items.add(profileItem);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setListener(ProfileListener listener) {
|
||||
public void setListener(@Nullable ProfileMenuAdapterListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
|
@ -64,8 +65,8 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
|||
this.items.clear();
|
||||
this.selectedItems.clear();
|
||||
this.items.addAll(newList);
|
||||
if (isBottomSheet) {
|
||||
items.add(MANAGE_BTN);
|
||||
if (bottomButton) {
|
||||
items.add(BUTTON_ITEM);
|
||||
}
|
||||
this.selectedItems.addAll(selectedItems);
|
||||
notifyDataSetChanged();
|
||||
|
@ -79,55 +80,22 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
|||
@NonNull
|
||||
@Override
|
||||
public ProfileViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View itemView = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.profile_list_item, parent, false);
|
||||
final ProfileViewHolder holder = 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;
|
||||
View itemView =
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.profile_list_item, parent, false);
|
||||
return new ProfileViewHolder(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final ProfileViewHolder holder, int position) {
|
||||
Object obj = items.get(position);
|
||||
|
||||
if (obj instanceof ApplicationMode) {
|
||||
holder.divider.setVisibility(View.VISIBLE);
|
||||
holder.icon.setVisibility(View.VISIBLE);
|
||||
holder.descr.setVisibility(View.VISIBLE);
|
||||
holder.aSwitch.setVisibility(View.VISIBLE);
|
||||
holder.switcher.setVisibility(View.VISIBLE);
|
||||
holder.menuIcon.setVisibility(View.VISIBLE);
|
||||
final ApplicationMode item = (ApplicationMode) obj;
|
||||
if (isBottomSheet) {
|
||||
if (bottomButton) {
|
||||
holder.divider.setBackgroundColor(isNightMode(app)
|
||||
? app.getResources().getColor(R.color.divider_dark)
|
||||
: 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_light));
|
||||
|
||||
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)) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
holder.initSwitcher = true;
|
||||
holder.switcher.setChecked(selectedItems.contains(item));
|
||||
holder.initSwitcher = false;
|
||||
updateViewHolder(holder, item);
|
||||
} else {
|
||||
final String title = (String) obj;
|
||||
if (title.equals("manage_button"))
|
||||
if (title.equals(BUTTON_ITEM)) {
|
||||
holder.divider.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
holder.icon.setVisibility(View.INVISIBLE);
|
||||
holder.descr.setVisibility(View.GONE);
|
||||
holder.aSwitch.setVisibility(View.GONE);
|
||||
holder.switcher.setVisibility(View.GONE);
|
||||
holder.menuIcon.setVisibility(View.GONE);
|
||||
holder.title.setTextColor(app.getResources().getColor(selectedIconColorRes));
|
||||
holder.title.setText(R.string.shared_string_manage);
|
||||
holder.profileOptions.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
app.startActivity(new Intent(app, SettingsProfileActivity.class));
|
||||
}
|
||||
});
|
||||
holder.title.setText(bottomButtonText);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,6 +141,18 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
|||
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) {
|
||||
return !ctx.getSettings().isLightContent();
|
||||
}
|
||||
|
@ -204,28 +160,65 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
|
|||
class ProfileViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView title, descr;
|
||||
SwitchCompat aSwitch;
|
||||
SwitchCompat switcher;
|
||||
ImageView icon, menuIcon;
|
||||
LinearLayout profileOptions;
|
||||
View divider;
|
||||
|
||||
boolean initSwitcher;
|
||||
|
||||
ProfileViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
title = itemView.findViewById(R.id.title);
|
||||
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);
|
||||
profileOptions = itemView.findViewById(R.id.profile_settings);
|
||||
divider = itemView.findViewById(R.id.divider_bottom);
|
||||
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.R;
|
||||
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.util.Algorithms;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -43,7 +43,7 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
|
|||
private RecyclerView recyclerView;
|
||||
private LinearLayout addNewProfileBtn;
|
||||
|
||||
ProfileListener listener = null;
|
||||
ProfileMenuAdapterListener listener = null;
|
||||
SelectProfileListener typeListener = null;
|
||||
|
||||
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.setAdapter(adapter);
|
||||
return view;
|
||||
|
@ -95,19 +95,19 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
if (listener == null) {
|
||||
listener = new ProfileListener() {
|
||||
listener = new ProfileMenuAdapterListener() {
|
||||
@Override
|
||||
public void changeProfileStatus(ApplicationMode am, boolean isSelected) {
|
||||
if(isSelected) {
|
||||
public void onProfileSelected(ApplicationMode am, boolean selected) {
|
||||
if(selected) {
|
||||
availableAppModes.add(am);
|
||||
} else {
|
||||
availableAppModes.remove(am);
|
||||
}
|
||||
ApplicationMode.changeProfileStatus(am, isSelected, getMyApplication());
|
||||
ApplicationMode.changeProfileStatus(am, selected, getMyApplication());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editProfile(ApplicationMode item) {
|
||||
public void onProfilePressed(ApplicationMode item) {
|
||||
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
|
||||
intent.putExtra(PROFILE_STRING_KEY, item.getStringKey());
|
||||
if (!Algorithms.isEmpty(item.getUserProfileName())) {
|
||||
|
@ -115,6 +115,10 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onButtonPressed() {
|
||||
}
|
||||
};
|
||||
}
|
||||
adapter.setListener(listener);
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
public class MapStyleAction extends SwitchableAction<String> {
|
||||
|
||||
|
@ -42,8 +43,8 @@ public class MapStyleAction extends SwitchableAction<String> {
|
|||
|
||||
@Override
|
||||
public void execute(MapActivity activity) {
|
||||
|
||||
List<String> mapStyles = getFilteredStyles();
|
||||
if (!Algorithms.isEmpty(mapStyles)) {
|
||||
boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG));
|
||||
if (showBottomSheetStyles) {
|
||||
showChooseDialog(activity.getSupportFragmentManager());
|
||||
|
@ -57,6 +58,11 @@ public class MapStyleAction extends SwitchableAction<String> {
|
|||
nextStyle = mapStyles.get(index + 1);
|
||||
}
|
||||
executeWithParams(activity, nextStyle);
|
||||
} else {
|
||||
Toast.makeText(activity, R.string.quick_action_need_to_add_item_to_list,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -181,9 +187,8 @@ public class MapStyleAction extends SwitchableAction<String> {
|
|||
|
||||
@Override
|
||||
public boolean fillParams(View root, MapActivity activity) {
|
||||
super.fillParams(root, activity);
|
||||
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
||||
return true;
|
||||
return super.fillParams(root, activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,6 +62,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
private Bitmap bigIconBg;
|
||||
private Bitmap bigIconBgStale;
|
||||
private Bitmap bigIconBgSelected;
|
||||
private Bitmap bigIconBgSelectedStale;
|
||||
private Bitmap placeholder;
|
||||
|
||||
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);
|
||||
bigIconBgSelected = BitmapFactory.decodeResource(res, night
|
||||
? 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);
|
||||
|
||||
smallIconSize = AndroidUtils.dpToPx(map, SMALL_ICON_SIZE_DP);
|
||||
|
@ -171,7 +174,8 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
image = placeholder;
|
||||
}
|
||||
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) {
|
||||
int radius = getRadiusPoi(tb);
|
||||
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);
|
||||
setQuickActionButtonMargin();
|
||||
isLayerOn = quickActionRegistry.isQuickActionOn();
|
||||
nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||
nightMode = app.getDaynightHelper().isNightMode();
|
||||
updateQuickActionButton(false);
|
||||
quickActionButton.setContentDescription(mapActivity.getString(R.string.configure_screen_quick_action));
|
||||
quickActionButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -375,7 +375,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings settings) {
|
||||
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||
boolean nightMode = app.getDaynightHelper().isNightMode();
|
||||
if (isInMovingMarkerMode()) {
|
||||
canvas.translate(box.getCenterPixelX() - contextMarker.getWidth() / 2, box.getCenterPixelY() - contextMarker.getHeight());
|
||||
contextMarker.draw(canvas);
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.graphics.PointF;
|
|||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
@ -97,6 +98,8 @@ public class RulerControlLayer extends OsmandMapLayer {
|
|||
private Path redCompassLines = new Path();
|
||||
|
||||
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 float cachedHeading = 0;
|
||||
|
@ -450,8 +453,7 @@ public class RulerControlLayer extends OsmandMapLayer {
|
|||
double maxCircleRadius = maxRadius;
|
||||
int i = 1;
|
||||
while ((maxCircleRadius -= radius) > 0) {
|
||||
cacheDistances.add(OsmAndFormatter
|
||||
.getFormattedDistance((float) roundedDist * i++, app, false).replaceAll(" ", ""));
|
||||
cacheDistances.add(OsmAndFormatter.getFormattedDistance((float) roundedDist * i++, app, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -460,7 +462,7 @@ public class RulerControlLayer extends OsmandMapLayer {
|
|||
if (!tb.isZoomAnimated()) {
|
||||
float circleRadius = radius * circleNumber;
|
||||
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.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);
|
||||
}
|
||||
|
||||
private float[] calculateDistanceTextCoords(String text, float drawingTextRadius, QuadPoint center, RenderingLineAttributes attrs) {
|
||||
Rect bounds = new Rect();
|
||||
attrs.paint2.getTextBounds(text, 0, text.length(), bounds);
|
||||
private float[] calculateTextCoords(String topOrLeftText, String rightOrBottomText, float drawingTextRadius, QuadPoint center, RenderingLineAttributes attrs) {
|
||||
Rect boundsDistance = new Rect();
|
||||
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
|
||||
float x1 = 0;
|
||||
|
@ -489,15 +499,15 @@ public class RulerControlLayer extends OsmandMapLayer {
|
|||
float y2 = 0;
|
||||
|
||||
if (textSide == TextSide.VERTICAL) {
|
||||
x1 = center.x - bounds.width() / 2;
|
||||
y1 = center.y - drawingTextRadius + bounds.height() / 2;
|
||||
x2 = center.x - bounds.width() / 2;
|
||||
y2 = center.y + drawingTextRadius + bounds.height() / 2;
|
||||
x1 = center.x - boundsHeading.width() / 2f;
|
||||
y1 = center.y - drawingTextRadius + boundsHeading.height() / 2f;
|
||||
x2 = center.x - boundsDistance.width() / 2f;
|
||||
y2 = center.y + drawingTextRadius + boundsDistance.height() / 2f;
|
||||
} else if (textSide == TextSide.HORIZONTAL) {
|
||||
x1 = center.x - drawingTextRadius - bounds.width() / 2;
|
||||
y1 = center.y + bounds.height() / 2;
|
||||
x2 = center.x + drawingTextRadius - bounds.width() / 2;
|
||||
y2 = center.y + bounds.height() / 2;
|
||||
x1 = center.x - drawingTextRadius - boundsHeading.width() / 2f;
|
||||
y1 = center.y + boundsHeading.height() / 2f;
|
||||
x2 = center.x + drawingTextRadius - boundsDistance.width() / 2f;
|
||||
y2 = center.y + boundsDistance.height() / 2f;
|
||||
}
|
||||
return new float[]{x1, y1, x2, y2};
|
||||
}
|
||||
|
@ -531,10 +541,18 @@ public class RulerControlLayer extends OsmandMapLayer {
|
|||
canvas.drawPath(arrow, triangleHeadingPaint);
|
||||
canvas.rotate(-cachedHeading, center.x, center.y);
|
||||
|
||||
String text = cacheDistances.get(COMPASS_CIRCLE_ID - 1);
|
||||
float[] textCoords = calculateDistanceTextCoords(text, radiusLength + AndroidUtils.dpToPx(app, 16), center, attrs);
|
||||
String distance = cacheDistances.get(COMPASS_CIRCLE_ID - 1);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -583,7 +601,7 @@ public class RulerControlLayer extends OsmandMapLayer {
|
|||
compass.moveTo(lineStartX, lineStartY);
|
||||
compass.lineTo(lineStopX, lineStopY);
|
||||
}
|
||||
if (i % 9 == 0 && i % 6 != 0) {
|
||||
if (i % 9 == 0 && i != 18) {
|
||||
redCompassLines.moveTo(lineStartX, lineStartY);
|
||||
redCompassLines.lineTo(lineStopX, lineStopY);
|
||||
}
|
||||
|
@ -604,6 +622,7 @@ public class RulerControlLayer extends OsmandMapLayer {
|
|||
float textMargin = AndroidUtils.dpToPx(app, 14);
|
||||
attrs.paint2.setTextAlign(Paint.Align.CENTER);
|
||||
attrs.paint3.setTextAlign(Paint.Align.CENTER);
|
||||
setAttrsPaintsTypeface(attrs, Typeface.DEFAULT_BOLD);
|
||||
|
||||
for (int i = 0; i < degrees.length; i += 9) {
|
||||
String cardinalDirection = getCardinalDirection(i);
|
||||
|
@ -612,15 +631,23 @@ public class RulerControlLayer extends OsmandMapLayer {
|
|||
|
||||
canvas.save();
|
||||
canvas.translate(center.x, center.y);
|
||||
canvas.rotate(i * 5 + 90);
|
||||
canvas.rotate(-i * 5 - 90);
|
||||
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.paint2);
|
||||
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) {
|
||||
|
@ -631,25 +658,37 @@ public class RulerControlLayer extends OsmandMapLayer {
|
|||
|
||||
private String getCardinalDirection(int i) {
|
||||
if (i == 0) {
|
||||
return "E";
|
||||
return cardinalDirections[2];
|
||||
} else if (i == 9) {
|
||||
return "NE";
|
||||
return cardinalDirections[1];
|
||||
} else if (i == 18) {
|
||||
return "N";
|
||||
return cardinalDirections[0];
|
||||
} else if (i == 27) {
|
||||
return "NW";
|
||||
return cardinalDirections[7];
|
||||
} else if (i == 36) {
|
||||
return "W";
|
||||
return cardinalDirections[6];
|
||||
} else if (i == 45) {
|
||||
return "SW";
|
||||
return cardinalDirections[5];
|
||||
} else if (i == 54) {
|
||||
return "S";
|
||||
return cardinalDirections[4];
|
||||
} else if (i == 63) {
|
||||
return "SE";
|
||||
return cardinalDirections[3];
|
||||
}
|
||||
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 {
|
||||
VERTICAL,
|
||||
HORIZONTAL
|
||||
|
|
|
@ -17,8 +17,6 @@ import android.support.annotation.NonNull;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.router.TurnType;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class TurnPathHelper {
|
||||
|
||||
//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 firstTurnType = TurnType.valueOf(firstTurn, leftSide).getValue();
|
||||
|
@ -621,20 +619,8 @@ public class TurnPathHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
Path p = cache.get(turnResource);
|
||||
if (p == null) {
|
||||
int size = res.getDimensionPixelSize(R.dimen.widget_turn_lane_size);
|
||||
p = 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;
|
||||
return getPathFromTurnResource(turnResource, size, smallArrow);
|
||||
}
|
||||
|
||||
private static Path getPathFromTurnResource(TurnResource turnResource, int size, boolean smallArrow) {
|
||||
|
|
|
@ -195,7 +195,7 @@ public class NextTurnInfoWidget extends TextInfoWidget {
|
|||
if(textPaint != null ) {
|
||||
if (turnType != null && !mini && turnType.getExitOut() > 0) {
|
||||
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.OsmandMapTileView;
|
||||
import net.osmand.plus.views.TurnPathHelper;
|
||||
import net.osmand.plus.views.TurnPathHelper.TurnResource;
|
||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WidgetState;
|
||||
import net.osmand.router.RouteResultPreparation;
|
||||
import net.osmand.router.TurnType;
|
||||
|
@ -59,9 +58,7 @@ import net.osmand.util.Algorithms;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RouteInfoWidgetsFactory {
|
||||
|
||||
|
@ -869,7 +866,6 @@ public class RouteInfoWidgetsFactory {
|
|||
int[] lanes = null;
|
||||
boolean imminent = false;
|
||||
private Context ctx;
|
||||
private Map<TurnResource, Path> pathsCache = new HashMap<>();
|
||||
private Paint paintBlack;
|
||||
private Paint paintRouteDirection;
|
||||
private Paint paintSecondTurn;
|
||||
|
@ -896,7 +892,7 @@ public class RouteInfoWidgetsFactory {
|
|||
paintBlack = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
paintBlack.setStyle(Style.STROKE);
|
||||
paintBlack.setColor(Color.BLACK);
|
||||
paintBlack.setStrokeWidth(3.5f);
|
||||
paintBlack.setStrokeWidth(scaleCoefficent);
|
||||
|
||||
paintRouteDirection = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
paintRouteDirection.setStyle(Style.FILL);
|
||||
|
@ -921,7 +917,7 @@ public class RouteInfoWidgetsFactory {
|
|||
|
||||
RectF imgBounds = new RectF();
|
||||
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);
|
||||
if (p != null) {
|
||||
RectF b = new RectF();
|
||||
|
@ -936,7 +932,7 @@ public class RouteInfoWidgetsFactory {
|
|||
}
|
||||
}
|
||||
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);
|
||||
if (p != null) {
|
||||
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);
|
||||
if (p != null) {
|
||||
RectF b = new RectF();
|
||||
|
@ -1037,7 +1033,7 @@ public class RouteInfoWidgetsFactory {
|
|||
Path firstTurnPath = null;
|
||||
|
||||
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);
|
||||
if (p != null) {
|
||||
RectF b = new RectF();
|
||||
|
@ -1053,7 +1049,7 @@ public class RouteInfoWidgetsFactory {
|
|||
}
|
||||
}
|
||||
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);
|
||||
if (p != null) {
|
||||
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);
|
||||
if (p != null) {
|
||||
RectF b = new RectF();
|
||||
|
|