Merge branch 'master' of ssh://github.com/osmandapp/Osmand into MyLocationSharingMode
This commit is contained in:
commit
37111025f5
12 changed files with 397 additions and 23 deletions
|
@ -1,8 +1,108 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/card_bg_color">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/action_bar_height">
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_settings"
|
||||
android:textColor="@color/app_bar_title_light"
|
||||
android:textSize="@dimen/title_text_size"
|
||||
app:typeface="@string/font_roboto_mono_bold"/>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/list_item_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/card_bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/list_header_height"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="@dimen/content_padding_standard"
|
||||
android:paddingRight="@dimen/content_padding_standard"
|
||||
android:text="@string/gps_and_location"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/list_item_title_text_size"
|
||||
app:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/gps_and_loc_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/list_item_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/card_bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/list_header_height"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="@dimen/content_padding_standard"
|
||||
android:paddingRight="@dimen/content_padding_standard"
|
||||
android:text="@string/osmand_connect"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/list_item_title_text_size"
|
||||
app:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/osmand_connect_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/card_bottom_divider"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/list_item_bottom_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="@dimen/content_padding_standard"
|
||||
android:paddingRight="@dimen/content_padding_standard"
|
||||
tools:background="@color/card_bg_light">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/content_padding_big"
|
||||
android:layout_marginRight="@dimen/content_padding_big"
|
||||
tools:src="@drawable/ic_action_live_now"
|
||||
tools:tint="@color/icon_light"/>
|
||||
|
||||
<LinearLayout
|
||||
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:orientation="vertical">
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/title_text_size"
|
||||
app:typeface="@string/font_roboto_regular"
|
||||
tools:text="Some title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/descr_text_size"
|
||||
tools:text="Some long description"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:id="@+id/value"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textColor="?attr/ctrl_active_color"
|
||||
app:typeface="@string/font_roboto_medium"
|
||||
tools:text="Value"/>
|
||||
|
||||
</LinearLayout>
|
46
OsmAnd-telegram/res/layout/item_with_rb_and_btn.xml
Normal file
46
OsmAnd-telegram/res/layout/item_with_rb_and_btn.xml
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/list_item_bottom_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/content_padding_standard"
|
||||
android:paddingRight="@dimen/content_padding_standard"
|
||||
tools:background="@color/card_bg_light">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/content_padding_big"
|
||||
android:layout_marginRight="@dimen/content_padding_big"
|
||||
tools:src="@drawable/ic_action_live_now"
|
||||
tools:tint="@color/icon_light"/>
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:id="@+id/title"
|
||||
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:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/title_text_size"
|
||||
app:typeface="@string/font_roboto_regular"
|
||||
tools:text="Some title"/>
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radio_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<include
|
||||
layout="@layout/primary_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -18,6 +18,8 @@
|
|||
android:gravity="center"
|
||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="@dimen/content_padding_standard"
|
||||
android:paddingRight="@dimen/content_padding_standard"
|
||||
android:textColor="?attr/primary_btn_text_color"
|
||||
android:textSize="@dimen/text_button_text_size"
|
||||
app:typeface="@string/font_roboto_medium"
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
android:gravity="center"
|
||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="@dimen/content_padding_standard"
|
||||
android:paddingRight="@dimen/content_padding_standard"
|
||||
android:textColor="?attr/ctrl_active_color"
|
||||
android:textSize="@dimen/text_button_text_size"
|
||||
app:typeface="@string/font_roboto_medium"
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
<dimen name="dialog_welcome_title_bottom_padding">70dp</dimen>
|
||||
<dimen name="dialog_welcome_title_top_margin">85dp</dimen>
|
||||
|
||||
<dimen name="list_header_height">48dp</dimen>
|
||||
|
||||
<dimen name="list_item_height">56dp</dimen>
|
||||
<dimen name="list_item_height_min">48dp</dimen>
|
||||
<dimen name="list_item_height_big">64dp</dimen>
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
<resources>
|
||||
<string name="osmand_connect">OsmAnd connect</string>
|
||||
<string name="location_history_desc">Hide contacts that are not updated their location after the specified period of time.</string>
|
||||
<string name="location_history">Location history</string>
|
||||
<string name="stale_location_desc">Time when contact last time sent an update to its location.</string>
|
||||
<string name="stale_location">Stale location</string>
|
||||
<string name="send_my_location_desc">Set minimum interval for location sharing.</string>
|
||||
<string name="send_my_location">Send my location</string>
|
||||
<string name="gps_and_location">GPS & location</string>
|
||||
<string name="sharing_time">Sharing time:</string>
|
||||
<string name="ending_in">Stop in:</string>
|
||||
<string name="stop_sharing_all">Sharing is enabled (disable)</string>
|
||||
|
|
|
@ -47,8 +47,8 @@ import java.util.*
|
|||
class OsmandAidlHelper(private val app: Application) {
|
||||
|
||||
companion object {
|
||||
private const val OSMAND_FREE_PACKAGE_NAME = "net.osmand"
|
||||
private const val OSMAND_PLUS_PACKAGE_NAME = "net.osmand.plus"
|
||||
const val OSMAND_FREE_PACKAGE_NAME = "net.osmand"
|
||||
const val OSMAND_PLUS_PACKAGE_NAME = "net.osmand.plus"
|
||||
var OSMAND_PACKAGE_NAME = OSMAND_PLUS_PACKAGE_NAME
|
||||
private set
|
||||
}
|
||||
|
|
|
@ -2,29 +2,32 @@ package net.osmand.telegram.ui
|
|||
|
||||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.graphics.Rect
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.support.annotation.StringRes
|
||||
import android.support.v4.app.DialogFragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v7.widget.AppCompatImageView
|
||||
import android.text.Editable
|
||||
import android.text.Html
|
||||
import android.text.TextUtils
|
||||
import android.text.TextWatcher
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.*
|
||||
import android.widget.Button
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import net.osmand.PlatformUtil
|
||||
import net.osmand.telegram.R
|
||||
import net.osmand.telegram.utils.AndroidUtils
|
||||
import studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||
import android.content.Intent
|
||||
import android.graphics.Rect
|
||||
import android.net.Uri
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.view.*
|
||||
import android.view.ViewGroup
|
||||
import android.text.Editable
|
||||
import android.text.Html
|
||||
import android.text.TextWatcher
|
||||
import android.util.TypedValue
|
||||
|
||||
|
||||
class LoginDialogFragment : DialogFragment() {
|
||||
|
@ -284,9 +287,8 @@ class LoginDialogFragment : DialogFragment() {
|
|||
val getTelegramButton: ImageView? = view.findViewById(R.id.google_play_button)
|
||||
getTelegramButton?.setImageResource(R.drawable.img_google_play_badge)
|
||||
getTelegramButton?.setOnClickListener {
|
||||
val app = getMainActivity()?.application
|
||||
if (app != null) {
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(AndroidUtils.getPlayMarketLink(app, TELEGRAM_PACKAGE))))
|
||||
context?.also { ctx ->
|
||||
startActivity(AndroidUtils.getPlayMarketIntent(ctx, TELEGRAM_PACKAGE))
|
||||
}
|
||||
}
|
||||
view.findViewById<Button>(R.id.continue_button).visibility = View.GONE
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package net.osmand.telegram.ui
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.BottomNavigationView
|
||||
import android.support.v4.app.DialogFragment
|
||||
|
@ -19,6 +17,7 @@ import android.widget.Toast
|
|||
import net.osmand.PlatformUtil
|
||||
import net.osmand.telegram.R
|
||||
import net.osmand.telegram.TelegramApplication
|
||||
import net.osmand.telegram.helpers.OsmandAidlHelper
|
||||
import net.osmand.telegram.helpers.TelegramHelper
|
||||
import net.osmand.telegram.helpers.TelegramHelper.*
|
||||
import net.osmand.telegram.ui.LoginDialogFragment.LoginDialogType
|
||||
|
@ -318,9 +317,9 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene
|
|||
builder.setView(R.layout.install_osmand_dialog)
|
||||
.setNegativeButton(R.string.shared_string_cancel, null)
|
||||
.setPositiveButton(R.string.shared_string_install) { _, _ ->
|
||||
val intent = Intent()
|
||||
intent.data = Uri.parse("market://details?id=net.osmand.plus")
|
||||
startActivity(intent)
|
||||
context?.also {
|
||||
startActivity(AndroidUtils.getPlayMarketIntent(it, OsmandAidlHelper.OSMAND_PLUS_PACKAGE_NAME))
|
||||
}
|
||||
}
|
||||
return builder.create()
|
||||
}
|
||||
|
|
|
@ -1,15 +1,37 @@
|
|||
package net.osmand.telegram.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.annotation.DrawableRes
|
||||
import android.support.annotation.StringRes
|
||||
import android.support.v4.app.DialogFragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v7.widget.ListPopupWindow
|
||||
import android.support.v7.widget.Toolbar
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import net.osmand.telegram.R
|
||||
import net.osmand.telegram.TelegramApplication
|
||||
import net.osmand.telegram.helpers.OsmandAidlHelper
|
||||
import net.osmand.telegram.utils.AndroidUtils
|
||||
import net.osmand.telegram.utils.OsmandFormatter
|
||||
|
||||
class SettingsDialogFragment : DialogFragment() {
|
||||
|
||||
private val app: TelegramApplication
|
||||
get() = activity?.application as TelegramApplication
|
||||
|
||||
private val uiUtils get() = app.uiUtils
|
||||
private val telegramHelper get() = app.telegramHelper
|
||||
private val settings get() = app.settings
|
||||
|
||||
private val gpsAndLocPrefs = listOf(SendMyLocPref(), StaleLocPref(), LocHistoryPref())
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setStyle(android.support.v4.app.DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar)
|
||||
|
@ -17,10 +39,139 @@ class SettingsDialogFragment : DialogFragment() {
|
|||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
parent: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
return inflater.inflate(R.layout.fragement_settings_dialog, container)
|
||||
val mainView = inflater.inflate(R.layout.fragement_settings_dialog, parent)
|
||||
|
||||
mainView.findViewById<Toolbar>(R.id.toolbar).apply {
|
||||
navigationIcon = uiUtils.getThemedIcon(R.drawable.ic_arrow_back)
|
||||
setNavigationOnClickListener { dismiss() }
|
||||
}
|
||||
|
||||
var container = mainView.findViewById<ViewGroup>(R.id.gps_and_loc_container)
|
||||
for (pref in gpsAndLocPrefs) {
|
||||
inflater.inflate(R.layout.item_with_desc_and_right_value, container, false).apply {
|
||||
findViewById<ImageView>(R.id.icon).setImageDrawable(uiUtils.getThemedIcon(pref.iconId))
|
||||
findViewById<TextView>(R.id.title).setText(pref.titleId)
|
||||
findViewById<TextView>(R.id.description).setText(pref.descriptionId)
|
||||
val valueView = findViewById<TextView>(R.id.value)
|
||||
valueView.text = pref.getCurrentValue()
|
||||
setOnClickListener {
|
||||
showPopupMenu(pref, valueView)
|
||||
}
|
||||
container.addView(this)
|
||||
}
|
||||
}
|
||||
|
||||
container = mainView.findViewById(R.id.osmand_connect_container)
|
||||
for (appConn in AppConnect.values()) {
|
||||
inflater.inflate(R.layout.item_with_rb_and_btn, container, false).apply {
|
||||
findViewById<ImageView>(R.id.icon).setImageDrawable(uiUtils.getThemedIcon(appConn.iconId))
|
||||
findViewById<TextView>(R.id.title).text = appConn.title
|
||||
// FIXME
|
||||
container.addView(this)
|
||||
}
|
||||
}
|
||||
|
||||
return mainView
|
||||
}
|
||||
|
||||
private fun showPopupMenu(pref: DurationPref, valueView: TextView) {
|
||||
val menuList = pref.getMenuItems()
|
||||
val ctx = valueView.context
|
||||
ListPopupWindow(ctx).apply {
|
||||
isModal = true
|
||||
anchorView = valueView
|
||||
setContentWidth(AndroidUtils.getPopupMenuWidth(ctx, menuList))
|
||||
setDropDownGravity(Gravity.END or Gravity.TOP)
|
||||
setAdapter(ArrayAdapter(ctx, R.layout.popup_list_text_item, menuList))
|
||||
setOnItemClickListener { _, _, position, _ ->
|
||||
pref.setCurrentValue(position)
|
||||
valueView.text = pref.getCurrentValue()
|
||||
dismiss()
|
||||
}
|
||||
show()
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME
|
||||
private inner class SendMyLocPref : DurationPref(
|
||||
R.drawable.ic_action_share_location,
|
||||
R.string.send_my_location,
|
||||
R.string.send_my_location_desc,
|
||||
listOf(30 * 60, 60 * 60, 90 * 60)
|
||||
) {
|
||||
|
||||
override fun getCurrentValue() = OsmandFormatter.getFormattedDuration(app, values[0])
|
||||
|
||||
override fun setCurrentValue(index: Int) {
|
||||
val value = OsmandFormatter.getFormattedDuration(app, values[index])
|
||||
Toast.makeText(context, value, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME
|
||||
private inner class StaleLocPref : DurationPref(
|
||||
R.drawable.ic_action_share_location,
|
||||
R.string.stale_location,
|
||||
R.string.stale_location_desc,
|
||||
listOf(30 * 60, 60 * 60, 90 * 60)
|
||||
) {
|
||||
|
||||
override fun getCurrentValue() = OsmandFormatter.getFormattedDuration(app, values[0])
|
||||
|
||||
override fun setCurrentValue(index: Int) {
|
||||
val value = OsmandFormatter.getFormattedDuration(app, values[index])
|
||||
Toast.makeText(context, value, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME
|
||||
private inner class LocHistoryPref : DurationPref(
|
||||
R.drawable.ic_action_time_span,
|
||||
R.string.location_history,
|
||||
R.string.location_history_desc,
|
||||
listOf(30 * 60, 60 * 60, 90 * 60)
|
||||
) {
|
||||
|
||||
override fun getCurrentValue() = OsmandFormatter.getFormattedDuration(app, values[0])
|
||||
|
||||
override fun setCurrentValue(index: Int) {
|
||||
val value = OsmandFormatter.getFormattedDuration(app, values[index])
|
||||
Toast.makeText(context, value, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
private abstract inner class DurationPref(
|
||||
@DrawableRes val iconId: Int,
|
||||
@StringRes val titleId: Int,
|
||||
@StringRes val descriptionId: Int,
|
||||
val values: List<Int>
|
||||
) {
|
||||
|
||||
abstract fun getCurrentValue(): String
|
||||
|
||||
abstract fun setCurrentValue(index: Int)
|
||||
|
||||
fun getMenuItems() = values.map { OsmandFormatter.getFormattedDuration(app, it) }
|
||||
}
|
||||
|
||||
private enum class AppConnect(
|
||||
@DrawableRes val iconId: Int,
|
||||
val title: String,
|
||||
val appPackage: String
|
||||
) {
|
||||
OSMAND_PLUS(
|
||||
R.drawable.ic_action_osmand_plus,
|
||||
"OsmAnd+",
|
||||
OsmandAidlHelper.OSMAND_PLUS_PACKAGE_NAME
|
||||
),
|
||||
OSMAND_FREE(
|
||||
R.drawable.ic_action_osmand_free,
|
||||
"OsmAnd",
|
||||
OsmandAidlHelper.OSMAND_FREE_PACKAGE_NAME
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -123,6 +123,9 @@ object AndroidUtils {
|
|||
return true
|
||||
}
|
||||
|
||||
fun getPlayMarketIntent(ctx: Context, packageName: String) =
|
||||
Intent(Intent.ACTION_VIEW, Uri.parse(AndroidUtils.getPlayMarketLink(ctx, packageName)))
|
||||
|
||||
fun getPlayMarketLink(ctx: Context, packageName: String): String {
|
||||
if (isGooglePlayInstalled(ctx)) {
|
||||
return "market://details?id=$packageName"
|
||||
|
|
Loading…
Reference in a new issue