Skip to content

Commit 1878da6

Browse files
committed
update restore height
1 parent 71e1578 commit 1878da6

File tree

25 files changed

+389
-53
lines changed

25 files changed

+389
-53
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,4 @@ output.json
4848
*.class
4949

5050
*/src/androidTest
51-
*/src/test
52-
*.a
51+
*/src/test

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/build
2+
/release

app/build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ apply plugin: 'kotlin-kapt'
55
apply plugin: 'kotlinx-serialization'
66

77
static def computeVersionCode() {
8-
112
8+
211
99
}
1010

1111
static def computeVersionName() {
12-
return "2.1.0"
12+
return "2.1.1"
1313
}
1414

1515
android {
1616
compileSdkVersion 29
1717
defaultConfig {
1818
applicationId "io.wookey.wallet.monero"
19-
minSdkVersion 21
19+
minSdkVersion 23
2020
targetSdkVersion 29
2121
versionCode computeVersionCode()
2222
versionName computeVersionName()
@@ -35,8 +35,9 @@ android {
3535
versionNameSuffix ' D'
3636
}
3737
release {
38-
minifyEnabled false
39-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
38+
minifyEnabled true
39+
shrinkResources true
40+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
4041
}
4142
}
4243

app/proguard-rules.pro

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,22 @@
238238
-keepclasseswithmembers class io.wookey.wallet.** { # <-- change package name to your app's
239239
kotlinx.serialization.KSerializer serializer(...);
240240
}
241+
242+
-dontwarn io.wookey.monero.**
243+
-keep class io.wookey.monero.** { *; }
244+
-keep interface io.wookey.monero.** { *; }
245+
246+
-assumenosideeffects class android.util.Log {
247+
public static *** v(...);
248+
public static *** d(...);
249+
public static *** i(...);
250+
public static *** w(...);
251+
public static *** e(...);
252+
}
253+
254+
-assumenosideeffects class java.io.PrintStream {
255+
public void print(%);
256+
public void print(**);
257+
public void println(%);
258+
public void println(**);
259+
}

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99

1010
<application
1111
android:name=".App"
12-
android:allowBackup="true"
12+
android:allowBackup="false"
1313
android:icon="@mipmap/ic_launcher"
1414
android:label="@string/app_name"
1515
android:networkSecurityConfig="@xml/network_security_config"
1616
android:supportsRtl="false"
1717
android:theme="@style/AppTheme"
18+
android:taskAffinity=""
1819
tools:ignore="GoogleAppIndexingWarning">
1920
<activity
2021
android:name=".SplashActivity"
@@ -116,6 +117,7 @@
116117
<activity
117118
android:name=".feature.setting.WebViewActivity"
118119
android:configChanges="orientation|keyboardHidden"
120+
android:exported="false"
119121
android:screenOrientation="portrait" />
120122
<activity
121123
android:name=".feature.setting.ContactUsActivity"

app/src/main/java/io/wookey/wallet/ActivityStackManager.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,14 @@ class ActivityStackManager private constructor() {
104104
}
105105
}
106106

107+
fun finishAll() {
108+
synchronized(activityStack) {
109+
val iterator = activityStack.iterator()
110+
while (iterator.hasNext()) {
111+
val next = iterator.next()
112+
next.finish()
113+
}
114+
}
115+
}
116+
107117
}

app/src/main/java/io/wookey/wallet/SplashActivity.kt

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ package io.wookey.wallet
22

33
import android.content.Intent
44
import android.os.Bundle
5+
import android.util.Log
56
import io.wookey.wallet.base.BaseActivity
67
import io.wookey.wallet.data.AppDatabase
8+
import io.wookey.wallet.dialog.PrivacyDialog
79
import io.wookey.wallet.feature.generate.WalletActivity
810
import io.wookey.wallet.feature.generate.create.BackupMnemonicActivity
11+
import io.wookey.wallet.support.extensions.putBoolean
912
import io.wookey.wallet.support.extensions.sharedPreferences
1013
import kotlinx.coroutines.*
1114

@@ -17,8 +20,22 @@ class SplashActivity : BaseActivity() {
1720
override fun onCreate(savedInstanceState: Bundle?) {
1821
super.onCreate(savedInstanceState)
1922
setContentView(R.layout.activity_splash)
23+
val agreePrivacy = sharedPreferences().getBoolean("agreePrivacy", false)
24+
if (agreePrivacy) {
25+
startApp()
26+
} else {
27+
PrivacyDialog.display(supportFragmentManager, {
28+
sharedPreferences().putBoolean("agreePrivacy", true)
29+
startApp()
30+
}) {
31+
ActivityStackManager.getInstance().finishAll()
32+
}
33+
}
34+
}
35+
36+
private fun startApp() {
2037
uiScope.launch {
21-
delay(1500)
38+
// delay(1500)
2239
val walletId = sharedPreferences().getInt("walletId", -1)
2340
val activeWallet = withContext(Dispatchers.IO) {
2441
val wallets = AppDatabase.getInstance().walletDao().getWallets()
@@ -27,12 +44,14 @@ class SplashActivity : BaseActivity() {
2744
} else {
2845
val activeWallets = AppDatabase.getInstance().walletDao().getActiveWallets()
2946
if (activeWallets.isNullOrEmpty()) {
30-
AppDatabase.getInstance().walletDao().updateWallets(wallets[0].apply { isActive = true })
47+
AppDatabase.getInstance().walletDao()
48+
.updateWallets(wallets[0].apply { isActive = true })
3149
wallets[0]
3250
} else {
3351
activeWallets.forEachIndexed { index, wallet ->
3452
if (index > 0) {
35-
AppDatabase.getInstance().walletDao().updateWallets(wallet.apply { isActive = false })
53+
AppDatabase.getInstance().walletDao()
54+
.updateWallets(wallet.apply { isActive = false })
3655
}
3756
}
3857
activeWallets[0]

app/src/main/java/io/wookey/wallet/data/remote/RetrofitManager.kt

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ import javax.net.ssl.SSLSession
1717

1818
object RetrofitManager {
1919
const val CHANGELLY_API = "https://api.changelly.com/"
20-
21-
// modify to your's
22-
const val API_KEY = "your changelly api key"
23-
const val SECRET = "your changelly api secret"
20+
const val API_KEY = "fbdbc96e3a9f42d99b6ef07b01f46c50"
21+
const val SECRET = "fd1f3f7abd5a942ae03c6b00b81cbb7e557638270f5070e58bcbfcb019dfd7c7"
2422

2523
fun retrofit(okHttpClient: OkHttpClient = okHttpClient()): Retrofit =
2624
Retrofit.Builder()
@@ -54,13 +52,13 @@ object RetrofitManager {
5452
level = HttpLoggingInterceptor.Level.BODY
5553
})
5654

57-
try {
58-
val ssl = SSLSocketFactoryImpl(KeyStore.getInstance(KeyStore.getDefaultType()))
59-
clientBuilder.sslSocketFactory(ssl.sSlContext.socketFactory, ssl.trustManager)
60-
clientBuilder.hostnameVerifier { hostname, session -> session.verify() }
61-
} catch (e: Exception) {
62-
e.printStackTrace()
63-
}
55+
// try {
56+
// val ssl = SSLSocketFactoryImpl(KeyStore.getInstance(KeyStore.getDefaultType()))
57+
// clientBuilder.sslSocketFactory(ssl.sSlContext.socketFactory, ssl.trustManager)
58+
// clientBuilder.hostnameVerifier { hostname, session -> session.verify() }
59+
// } catch (e: Exception) {
60+
// e.printStackTrace()
61+
// }
6462
return clientBuilder.build()
6563
}
6664

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
package io.wookey.wallet.dialog
2+
3+
import android.content.Intent
4+
import android.os.Bundle
5+
import android.text.SpannableString
6+
import android.text.method.LinkMovementMethod
7+
import android.text.method.ScrollingMovementMethod
8+
import android.util.Log
9+
import android.view.LayoutInflater
10+
import android.view.View
11+
import android.view.ViewGroup
12+
import android.view.WindowManager
13+
import androidx.core.content.ContextCompat
14+
import androidx.fragment.app.DialogFragment
15+
import io.wookey.wallet.R
16+
import io.wookey.wallet.feature.setting.WebViewActivity
17+
import io.wookey.wallet.support.BackgroundHelper
18+
import io.wookey.wallet.support.extensions.clickableSpan
19+
import io.wookey.wallet.support.extensions.dp2px
20+
import io.wookey.wallet.support.extensions.getCurrentLocale
21+
import io.wookey.wallet.support.extensions.screenWidth
22+
import kotlinx.android.synthetic.main.dialog_privacy.*
23+
24+
class PrivacyDialog : DialogFragment() {
25+
26+
private var confirmListener: (() -> Unit)? = null
27+
private var cancelListener: (() -> Unit)? = null
28+
29+
override fun onCreate(savedInstanceState: Bundle?) {
30+
super.onCreate(savedInstanceState)
31+
setStyle(STYLE_NO_TITLE, R.style.CustomDialog)
32+
isCancelable = false
33+
}
34+
35+
override fun onCreateView(
36+
inflater: LayoutInflater,
37+
container: ViewGroup?,
38+
savedInstanceState: Bundle?
39+
): View? {
40+
return inflater.inflate(R.layout.dialog_privacy, container, false)
41+
}
42+
43+
override fun onActivityCreated(savedInstanceState: Bundle?) {
44+
super.onActivityCreated(savedInstanceState)
45+
46+
val layoutParams = dialogContainer.layoutParams
47+
layoutParams.width = (screenWidth() * 0.85).toInt()
48+
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT
49+
50+
dialogContainer.background =
51+
BackgroundHelper.getBackground(context, R.color.color_FFFFFF, dp2px(5))
52+
confirm.background = BackgroundHelper.getButtonBackground(context)
53+
54+
val agreement = getString(R.string.user_agreement)
55+
val privacy = getString(R.string.privacy)
56+
val contentText = getString(R.string.dialog_content_privacy, agreement, privacy)
57+
58+
val start1 = contentText.indexOf(agreement)
59+
val end1 = start1 + agreement.length
60+
val start2 = contentText.indexOf(privacy)
61+
val end2 = start2 + privacy.length
62+
63+
val style = SpannableString(contentText)
64+
style.clickableSpan(start1..end1, ContextCompat.getColor(activity!!, R.color.color_2179FF)) {
65+
startActivity(Intent(activity, WebViewActivity::class.java).apply {
66+
putExtra("url", "https://wallet.wookey.io/service-docs/terms-of-service.html")
67+
})
68+
}
69+
style.clickableSpan(start2..end2, ContextCompat.getColor(activity!!, R.color.color_2179FF)) {
70+
startActivity(Intent(activity, WebViewActivity::class.java).apply {
71+
putExtra("url", "https://wallet.wookey.io/service-docs/privacy-policy.html?lang=${activity?.getCurrentLocale()}")
72+
})
73+
}
74+
75+
content.text = style
76+
content.movementMethod = LinkMovementMethod.getInstance()
77+
78+
confirm.setOnClickListener {
79+
confirmListener?.invoke()
80+
hide()
81+
}
82+
83+
cancel.setOnClickListener {
84+
hide()
85+
cancelListener?.invoke()
86+
}
87+
}
88+
89+
fun hide() {
90+
val activity = activity
91+
if (activity != null && !activity.isFinishing && !activity.isDestroyed) {
92+
dismiss()
93+
}
94+
}
95+
96+
companion object {
97+
private const val TAG = "PrivacyDialog"
98+
fun newInstance(): PrivacyDialog {
99+
val fragment = PrivacyDialog()
100+
return fragment
101+
}
102+
103+
fun display(
104+
fm: androidx.fragment.app.FragmentManager,
105+
confirmListener: (() -> Unit)?,
106+
cancelListener: (() -> Unit)?
107+
) {
108+
val ft = fm.beginTransaction()
109+
val prev = fm.findFragmentByTag(TAG)
110+
if (prev != null) {
111+
ft.remove(prev)
112+
}
113+
ft.addToBackStack(null)
114+
newInstance().apply {
115+
this.confirmListener = confirmListener
116+
this.cancelListener = cancelListener
117+
}.show(ft, TAG)
118+
}
119+
}
120+
}

app/src/main/java/io/wookey/wallet/feature/generate/GenerateWalletActivity.kt

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ import io.wookey.wallet.feature.generate.recovery.RecoveryWalletActivity
1616
import io.wookey.wallet.feature.setting.WebViewActivity
1717
import io.wookey.wallet.support.BackgroundHelper
1818
import io.wookey.wallet.support.LengthFilter
19-
import io.wookey.wallet.support.extensions.afterTextChanged
20-
import io.wookey.wallet.support.extensions.clickableSpan
21-
import io.wookey.wallet.support.extensions.dp2px
22-
import io.wookey.wallet.support.extensions.toast
19+
import io.wookey.wallet.support.extensions.*
2320
import kotlinx.android.synthetic.main.activity_generate_wallet.*
2421

2522
class GenerateWalletActivity : BaseTitleSecondActivity() {
@@ -41,13 +38,24 @@ class GenerateWalletActivity : BaseTitleSecondActivity() {
4138
agree.buttonDrawable = BackgroundHelper.getCheckBoxButton(this)
4239
next.background = BackgroundHelper.getButtonBackground(this)
4340

44-
val term = getString(R.string.agreement_term)
45-
val s = "${getString(R.string.agreement_prompt)} $term"
46-
val start = s.indexOf(term)
47-
val end = start + term.length
41+
val term1 = getString(R.string.user_agreement)
42+
val term2 = getString(R.string.privacy)
43+
44+
val s = getString(R.string.agreement_prompt, term1, term2)
45+
val start1 = s.indexOf(term1)
46+
val end1 = start1 + term1.length
47+
val start2 = s.indexOf(term2)
48+
val end2 = start2 + term2.length
4849
val style = SpannableString(s)
49-
style.clickableSpan(start..end, ContextCompat.getColor(this, R.color.color_2179FF)) {
50-
startActivity(Intent(this, WebViewActivity::class.java))
50+
style.clickableSpan(start1..end1, ContextCompat.getColor(this, R.color.color_2179FF)) {
51+
startActivity(Intent(this, WebViewActivity::class.java).apply {
52+
putExtra("url", "https://wallet.wookey.io/service-docs/terms-of-service.html")
53+
})
54+
}
55+
style.clickableSpan(start2..end2, ContextCompat.getColor(this, R.color.color_2179FF)) {
56+
startActivity(Intent(this, WebViewActivity::class.java).apply {
57+
putExtra("url", "https://wallet.wookey.io/service-docs/privacy-policy.html?lang=${getCurrentLocale()}")
58+
})
5159
}
5260
agreement.text = style
5361
agreement.movementMethod = LinkMovementMethod.getInstance()

0 commit comments

Comments
 (0)