diff --git a/CHANGELOG.md b/CHANGELOG.md
index 02af9da..c654dbb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+### Release 1.0.11 (20030501)
+
+- Minor improvements
+
### Release 1.0.10 (20021301)
- Stability improvements
diff --git a/app/build.gradle b/app/build.gradle
index 486064d..150ec1e 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -6,7 +6,7 @@ apply plugin: 'org.jetbrains.kotlin.android.extensions'
int MAJOR_VERSION = 1
int MINOR_VERSION = 0
-int MICRO_VERSION = 10
+int MICRO_VERSION = 11
int BUILD_FOR_TODAY = 1
def secretsPropertiesFile = rootProject.file("secrets.properties")
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index aaeca36..2e1a653 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -14,8 +14,11 @@
+ android:name="com.myetherwallet.mewconnect.ACCESS_DANGEROUS_DATA"
+ android:description="@string/import_permission_description"
+ android:icon="@drawable/notification_icon"
+ android:label="@string/import_permission_label"
+ android:protectionLevel="dangerous" />
+
+
+ android:permission="com.myetherwallet.mewconnect.ACCESS_DANGEROUS_DATA" />
diff --git a/app/src/main/java/com/myetherwallet/mewconnect/content/provider/BaseMewContentProvider.kt b/app/src/main/java/com/myetherwallet/mewconnect/content/provider/BaseMewContentProvider.kt
new file mode 100644
index 0000000..4fe8ed0
--- /dev/null
+++ b/app/src/main/java/com/myetherwallet/mewconnect/content/provider/BaseMewContentProvider.kt
@@ -0,0 +1,20 @@
+package com.myetherwallet.mewconnect.content.provider
+
+import android.content.ContentProvider
+import android.database.Cursor
+import android.database.MatrixCursor
+
+/**
+ * Created by BArtWell on 27.02.2020.
+ */
+
+abstract class BaseMewContentProvider : ContentProvider() {
+
+ protected fun createOneItemCursor(data: T): Cursor {
+ val cursor = MatrixCursor(arrayOf("_id", "data"))
+ cursor.newRow()
+ .add(0)
+ .add(data)
+ return cursor
+ }
+}
diff --git a/app/src/main/java/com/myetherwallet/mewconnect/content/provider/MewInfoContentProvider.kt b/app/src/main/java/com/myetherwallet/mewconnect/content/provider/MewInfoContentProvider.kt
new file mode 100644
index 0000000..71d26d8
--- /dev/null
+++ b/app/src/main/java/com/myetherwallet/mewconnect/content/provider/MewInfoContentProvider.kt
@@ -0,0 +1,72 @@
+package com.myetherwallet.mewconnect.content.provider
+
+import android.content.ContentValues
+import android.content.UriMatcher
+import android.database.Cursor
+import android.net.Uri
+import com.myetherwallet.mewconnect.BuildConfig
+import com.myetherwallet.mewconnect.MewApplication
+import com.myetherwallet.mewconnect.core.persist.prefenreces.PreferencesManager
+import com.myetherwallet.mewconnect.core.utils.MewLog
+import javax.inject.Inject
+
+private const val TAG = "MewContentProvider"
+private const val AUTHORITY = "com.myetherwallet.mewconnect.info"
+private const val PATH_VERSION = "version"
+private const val ID_VERSION = 0
+private const val PATH_IS_WALLET_AVAILABLE = "is_wallet_available"
+private const val ID_IS_AVAILABLE = 1
+
+class MewInfoContentProvider : BaseMewContentProvider() {
+
+ @Inject
+ lateinit var preferences: PreferencesManager
+ private val uriMatcher = UriMatcher(UriMatcher.NO_MATCH)
+
+ override fun onCreate(): Boolean {
+ MewLog.d(TAG, "onCreate")
+ (context?.applicationContext as MewApplication?)?.appComponent?.inject(this)
+ uriMatcher.addURI(AUTHORITY, PATH_VERSION, ID_VERSION)
+ uriMatcher.addURI(AUTHORITY, PATH_IS_WALLET_AVAILABLE, ID_IS_AVAILABLE)
+ return true
+ }
+
+ override fun query(uri: Uri, projection: Array?, selection: String?, selectionArgs: Array?, sortOrder: String?): Cursor? {
+ MewLog.d(TAG, "query")
+ when (uriMatcher.match(uri)) {
+ ID_VERSION -> {
+ MewLog.d(TAG, "Version")
+ return createOneItemCursor(BuildConfig.VERSION_CODE)
+ }
+ ID_IS_AVAILABLE -> {
+ MewLog.d(TAG, "Is wallet available")
+ val data = if (preferences.getCurrentWalletPreferences().isWalletExists() &&
+ !preferences.applicationPreferences.wasExportedToMewWallet() &&
+ !preferences.applicationPreferences.isExportToMewWalletDenied()) {
+ 1
+ } else {
+ 0
+ }
+ return createOneItemCursor(data)
+ }
+ }
+ return null
+ }
+
+ override fun delete(uri: Uri, selection: String?, selectionArgs: Array?): Int {
+ return 0
+ }
+
+ override fun getType(uri: Uri): String? {
+ return null
+ }
+
+ override fun insert(uri: Uri, values: ContentValues?): Uri? {
+ return null
+ }
+
+ override fun update(uri: Uri, values: ContentValues?, selection: String?,
+ selectionArgs: Array?): Int {
+ return 0
+ }
+}
diff --git a/app/src/main/java/com/myetherwallet/mewconnect/content/provider/MewContentProvider.kt b/app/src/main/java/com/myetherwallet/mewconnect/content/provider/MewSecretContentProvider.kt
similarity index 64%
rename from app/src/main/java/com/myetherwallet/mewconnect/content/provider/MewContentProvider.kt
rename to app/src/main/java/com/myetherwallet/mewconnect/content/provider/MewSecretContentProvider.kt
index fddbdb6..e09af60 100644
--- a/app/src/main/java/com/myetherwallet/mewconnect/content/provider/MewContentProvider.kt
+++ b/app/src/main/java/com/myetherwallet/mewconnect/content/provider/MewSecretContentProvider.kt
@@ -1,12 +1,9 @@
package com.myetherwallet.mewconnect.content.provider
-import android.content.ContentProvider
import android.content.ContentValues
import android.content.UriMatcher
import android.database.Cursor
-import android.database.MatrixCursor
import android.net.Uri
-import com.myetherwallet.mewconnect.BuildConfig
import com.myetherwallet.mewconnect.MewApplication
import com.myetherwallet.mewconnect.core.persist.prefenreces.KeyStore
import com.myetherwallet.mewconnect.core.persist.prefenreces.PreferencesManager
@@ -16,13 +13,11 @@ import javax.inject.Inject
private const val TAG = "MewContentProvider"
private const val AUTHORITY = "com.myetherwallet.mewconnect.secret"
-private const val PATH_VERSION = "version"
-private const val ID_VERSION = 0
private const val PATH_GET_MNEMONIC = "mnemonic"
-private const val ID_MNEMONIC = 1
+private const val ID_MNEMONIC = 0
private const val QUERY_PASSWORD = "password"
-class MewContentProvider : ContentProvider() {
+class MewSecretContentProvider : BaseMewContentProvider() {
@Inject
lateinit var preferences: PreferencesManager
@@ -31,7 +26,6 @@ class MewContentProvider : ContentProvider() {
override fun onCreate(): Boolean {
MewLog.d(TAG, "onCreate")
(context?.applicationContext as MewApplication?)?.appComponent?.inject(this)
- uriMatcher.addURI(AUTHORITY, PATH_VERSION, ID_VERSION)
uriMatcher.addURI(AUTHORITY, PATH_GET_MNEMONIC, ID_MNEMONIC)
return true
}
@@ -39,18 +33,20 @@ class MewContentProvider : ContentProvider() {
override fun query(uri: Uri, projection: Array?, selection: String?, selectionArgs: Array?, sortOrder: String?): Cursor? {
MewLog.d(TAG, "query")
when (uriMatcher.match(uri)) {
- ID_VERSION -> {
- MewLog.d(TAG, "Version")
- return createOneItemCursor(BuildConfig.VERSION_CODE)
- }
ID_MNEMONIC -> {
MewLog.d(TAG, "Mnemonic")
- val password = uri.getQueryParameter(QUERY_PASSWORD)
- if (!password.isNullOrEmpty()) {
- val keystoreHelper = PasswordKeystoreHelper(password)
- val mnemonic = keystoreHelper.decrypt(preferences.applicationPreferences.getWalletMnemonic(KeyStore.PASSWORD))
- if (mnemonic.isNotEmpty()) {
- return createOneItemCursor(mnemonic)
+ if (!preferences.applicationPreferences.wasExportedToMewWallet() &&
+ !preferences.applicationPreferences.isExportToMewWalletDenied()) {
+ val password = uri.getQueryParameter(QUERY_PASSWORD)
+ if (!password.isNullOrEmpty()) {
+ val keystoreHelper = PasswordKeystoreHelper(password)
+ val mnemonic = keystoreHelper.decrypt(preferences.applicationPreferences.getWalletMnemonic(KeyStore.PASSWORD))
+ if (mnemonic.isEmpty()) {
+ preferences.applicationPreferences.updateExportToMewWalletDenied()
+ } else {
+ preferences.applicationPreferences.setWasExportedToMewWallet(true)
+ return createOneItemCursor(mnemonic)
+ }
}
}
}
@@ -58,14 +54,6 @@ class MewContentProvider : ContentProvider() {
return null
}
- private fun createOneItemCursor(data: T): Cursor {
- val cursor = MatrixCursor(arrayOf("_id", "data"))
- cursor.newRow()
- .add(0)
- .add(data)
- return cursor
- }
-
override fun delete(uri: Uri, selection: String?, selectionArgs: Array?): Int {
return 0
}
diff --git a/app/src/main/java/com/myetherwallet/mewconnect/core/di/ApplicationComponent.kt b/app/src/main/java/com/myetherwallet/mewconnect/core/di/ApplicationComponent.kt
index 3f56390..78bd9c0 100644
--- a/app/src/main/java/com/myetherwallet/mewconnect/core/di/ApplicationComponent.kt
+++ b/app/src/main/java/com/myetherwallet/mewconnect/core/di/ApplicationComponent.kt
@@ -1,7 +1,8 @@
package com.myetherwallet.mewconnect.core.di
import com.myetherwallet.mewconnect.MewApplication
-import com.myetherwallet.mewconnect.content.provider.MewContentProvider
+import com.myetherwallet.mewconnect.content.provider.MewInfoContentProvider
+import com.myetherwallet.mewconnect.content.provider.MewSecretContentProvider
import com.myetherwallet.mewconnect.core.di.viewmodel.ViewModelModule
import com.myetherwallet.mewconnect.core.persist.database.DatabaseModule
import com.myetherwallet.mewconnect.core.persist.prefenreces.PreferencesModule
@@ -97,5 +98,7 @@ interface ApplicationComponent {
fun inject(view: StaticToolbar)
- fun inject(provider: MewContentProvider)
+ fun inject(provider: MewSecretContentProvider)
+
+ fun inject(provider: MewInfoContentProvider)
}
diff --git a/app/src/main/java/com/myetherwallet/mewconnect/core/persist/prefenreces/ApplicationPreferences.kt b/app/src/main/java/com/myetherwallet/mewconnect/core/persist/prefenreces/ApplicationPreferences.kt
index 6d39a7c..75bc7cf 100644
--- a/app/src/main/java/com/myetherwallet/mewconnect/core/persist/prefenreces/ApplicationPreferences.kt
+++ b/app/src/main/java/com/myetherwallet/mewconnect/core/persist/prefenreces/ApplicationPreferences.kt
@@ -26,6 +26,8 @@ private const val AUTH_TIMER_TIME = "auth_timer_time"
private const val WHATS_NEW_DIALOG_VERSION = "whats_new_dialog_version"
private const val IS_BIOMETRIC_PROMO_SHOWN = "is_biometric_promo_shown"
private const val SIMPLEX_USER_ID = "simplex_user_id"
+private const val WAS_EXPORTED_TO_MEW_WALLET = "was_exported_to_mew_wallet"
+private const val EXPORT_TO_MEW_WALLET_DENIED_COUNT = "export_to_mew_wallet_denied_count"
private const val DEPRECATED_WALLET_MNEMONIC = "wallet_mnemonic"
@@ -141,6 +143,18 @@ class ApplicationPreferences(context: Context, private val preferences: SharedPr
fun resetAuthTimerTime() = preferences.edit().remove(AUTH_TIMER_TIME).apply()
+ fun wasExportedToMewWallet() = preferences.getBoolean(WAS_EXPORTED_TO_MEW_WALLET, false)
+
+ fun setWasExportedToMewWallet(was: Boolean) = preferences.edit().putBoolean(WAS_EXPORTED_TO_MEW_WALLET, was).apply()
+
+ fun isExportToMewWalletDenied() = getExportToMewWalletDeniedCount() > 20
+
+ private fun getExportToMewWalletDeniedCount() = preferences.getInt(EXPORT_TO_MEW_WALLET_DENIED_COUNT, 0)
+
+ fun updateExportToMewWalletDenied() {
+ preferences.edit().putInt(EXPORT_TO_MEW_WALLET_DENIED_COUNT, getExportToMewWalletDeniedCount() + 1).apply()
+ }
+
fun shouldShowWhatsNewDialog(): Boolean {
val current = preferences.getInt(WHATS_NEW_DIALOG_VERSION, 0)
preferences.edit().putInt(WHATS_NEW_DIALOG_VERSION, BuildConfig.VERSION_CODE).apply()
diff --git a/app/src/main/java/com/myetherwallet/mewconnect/feature/register/fragment/GeneratingFragment.kt b/app/src/main/java/com/myetherwallet/mewconnect/feature/register/fragment/GeneratingFragment.kt
index f4c5b4d..ea85303 100644
--- a/app/src/main/java/com/myetherwallet/mewconnect/feature/register/fragment/GeneratingFragment.kt
+++ b/app/src/main/java/com/myetherwallet/mewconnect/feature/register/fragment/GeneratingFragment.kt
@@ -50,4 +50,4 @@ class GeneratingFragment : BaseViewModelFragment() {
override fun inject(appComponent: ApplicationComponent) {
appComponent.inject(this)
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 7c812a3..3df39d3 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -245,4 +245,7 @@
Fingerprint unlock is now enabled
What’s new
+
+ Import wallet data
+ to import your account from MEWconnect app