Add compatibility with OsmAnd Nightly

This commit is contained in:
Alex Sytnyk 2018-09-03 14:30:40 +03:00
parent 9c28f7d131
commit fb40853153
3 changed files with 17 additions and 3 deletions

View file

@ -330,19 +330,29 @@ class TelegramSettings(private val app: TelegramApplication) {
@DrawableRes val iconId: Int,
@DrawableRes val whiteIconId: Int,
val title: String,
val appPackage: String
val appPackage: String,
val showOnlyInstalled: Boolean
) {
OSMAND_PLUS(
R.drawable.ic_logo_osmand_plus,
R.drawable.ic_action_osmand_plus,
"OsmAnd+",
OsmandAidlHelper.OSMAND_PLUS_PACKAGE_NAME
OsmandAidlHelper.OSMAND_PLUS_PACKAGE_NAME,
false
),
OSMAND_FREE(
R.drawable.ic_logo_osmand_free,
R.drawable.ic_action_osmand_free,
"OsmAnd",
OsmandAidlHelper.OSMAND_FREE_PACKAGE_NAME
OsmandAidlHelper.OSMAND_FREE_PACKAGE_NAME,
false
),
OSMAND_NIGHTLY(
R.drawable.ic_logo_osmand_free,
R.drawable.ic_action_osmand_free,
"OsmAnd Nightly",
OsmandAidlHelper.OSMAND_NIGHTLY_PACKAGE_NAME,
true
);
companion object {

View file

@ -51,6 +51,7 @@ class OsmandAidlHelper(private val app: TelegramApplication) {
companion object {
const val OSMAND_FREE_PACKAGE_NAME = "net.osmand"
const val OSMAND_PLUS_PACKAGE_NAME = "net.osmand.plus"
const val OSMAND_NIGHTLY_PACKAGE_NAME = "net.osmand.dev"
const val UPDATE_TIME_MS = 5000L
}

View file

@ -56,6 +56,9 @@ class SettingsDialogFragment : BaseDialogFragment() {
for (appConn in TelegramSettings.AppConnect.values()) {
val pack = appConn.appPackage
val installed = AndroidUtils.isAppInstalled(context!!, pack)
if (!installed && appConn.showOnlyInstalled) {
continue
}
inflater.inflate(R.layout.item_with_rb_and_btn, container, false).apply {
findViewById<ImageView>(R.id.icon).setImageDrawable(uiUtils.getIcon(appConn.iconId))
findViewById<TextView>(R.id.title).text = appConn.title