Make small refactoring
This commit is contained in:
parent
964dbc2bc4
commit
16a8c21f79
4 changed files with 25 additions and 21 deletions
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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