Commit 5e5d585b authored by Francisco Cunha's avatar Francisco Cunha

P4A-1022 - Move KeyImportActivity constants and extension functions to companion object

parent 70095c53
......@@ -50,8 +50,8 @@ import security.pEp.permissions.PermissionChecker
import security.pEp.permissions.PermissionRequester
import security.pEp.ui.about.AboutActivity
import security.pEp.ui.intro.startWelcomeMessage
import security.pEp.ui.keyimport.ANDROID_FILE_MANAGER_MARKET_URL
import security.pEp.ui.keyimport.showImportKeyDialog
import security.pEp.ui.keyimport.KeyImportActivity.Companion.ANDROID_FILE_MANAGER_MARKET_URL
import security.pEp.ui.keyimport.KeyImportActivity.Companion.showImportKeyDialog
import security.pEp.ui.resources.ResourcesProvider
import timber.log.Timber
import java.util.*
......@@ -654,7 +654,7 @@ class SettingsActivity : PEpImporterActivity(), PreferenceFragmentCompat.OnPrefe
private fun onImportPGPKeyFromFileSystem(realAccount: Account) {
currentAccount = realAccount.email
showImportKeyDialog(currentAccount)
showImportKeyDialog(this@SettingsActivity, currentAccount)
}
......
......@@ -31,7 +31,7 @@ import org.koin.android.architecture.ext.sharedViewModel
import org.koin.android.ext.android.inject
import org.openintents.openpgp.OpenPgpApiManager
import org.openintents.openpgp.util.OpenPgpProviderUtil
import security.pEp.ui.keyimport.showImportKeyDialog
import security.pEp.ui.keyimport.KeyImportActivity.Companion.showImportKeyDialog
class AccountSettingsFragment : PreferenceFragmentCompat() {
private val viewModel: AccountSettingsViewModel by sharedViewModel()
......@@ -177,7 +177,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
}
private fun onKeyImportClicked() {
activity?.showImportKeyDialog(accountUuid)
showImportKeyDialog(activity, accountUuid)
}
private fun hideKeySyncOptions() {
......
......@@ -14,11 +14,6 @@ import security.pEp.ui.dialog.showProgressDialog
import javax.inject.Inject
const val ACCOUNT_EXTRA = "ACCOUNT_EXTRA"
const val ACTIVITY_REQUEST_PICK_KEY_FILE = 8
const val ANDROID_FILE_MANAGER_MARKET_URL = "https://play.google.com/store/apps/details?id=org.openintents.filemanager"
class KeyImportActivity : WizardActivity(), KeyImportView {
@Inject
......@@ -70,7 +65,7 @@ class KeyImportActivity : WizardActivity(), KeyImportView {
.setNegativeButton(R.string.close) { dialogInterface, _ -> dialogInterface.dismiss() }
.setPositiveButton(R.string.open_market) { dialogInterface, _ ->
dialogInterface.dismiss()
openMarketIntent()
openMarketIntent(this@KeyImportActivity)
}
.create()
.show()
......@@ -121,18 +116,25 @@ class KeyImportActivity : WizardActivity(), KeyImportView {
super.onActivityResult(requestCode, resultCode, data)
presenter.onActivityResult(requestCode, resultCode, data)
}
}
companion object {
const val ACCOUNT_EXTRA = "ACCOUNT_EXTRA"
const val ACTIVITY_REQUEST_PICK_KEY_FILE = 8
const val ANDROID_FILE_MANAGER_MARKET_URL = "https://play.google.com/store/apps/details?id=org.openintents.filemanager"
private fun Activity.openMarketIntent() {
val uri = Uri.parse(ANDROID_FILE_MANAGER_MARKET_URL)
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)
}
private fun openMarketIntent(activity: Activity) {
val uri = Uri.parse(ANDROID_FILE_MANAGER_MARKET_URL)
val intent = Intent(Intent.ACTION_VIEW, uri)
activity.startActivity(intent)
}
fun Activity.showImportKeyDialog(account: String) {
val intent = Intent(this, KeyImportActivity::class.java)
intent.putExtra(ACCOUNT_EXTRA, account)
startActivity(intent)
fun showImportKeyDialog(activity: Activity?, account: String) {
val intent = Intent(activity, KeyImportActivity::class.java)
intent.putExtra(ACCOUNT_EXTRA, account)
activity?.startActivity(intent)
}
}
}
......@@ -12,6 +12,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import org.apache.commons.io.IOUtils
import security.pEp.ui.keyimport.KeyImportActivity.Companion.ACTIVITY_REQUEST_PICK_KEY_FILE
import timber.log.Timber
import java.io.FileNotFoundException
import java.io.IOException
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment