Skip to content

Commit

Permalink
update restore height
Browse files Browse the repository at this point in the history
  • Loading branch information
WooKeyWallet committed Jun 29, 2022
1 parent 71e1578 commit 1878da6
Show file tree
Hide file tree
Showing 25 changed files with 389 additions and 53 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ output.json
*.class

*/src/androidTest
*/src/test
*.a
*/src/test
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
/release
11 changes: 6 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ apply plugin: 'kotlin-kapt'
apply plugin: 'kotlinx-serialization'

static def computeVersionCode() {
112
211
}

static def computeVersionName() {
return "2.1.0"
return "2.1.1"
}

android {
compileSdkVersion 29
defaultConfig {
applicationId "io.wookey.wallet.monero"
minSdkVersion 21
minSdkVersion 23
targetSdkVersion 29
versionCode computeVersionCode()
versionName computeVersionName()
Expand All @@ -35,8 +35,9 @@ android {
versionNameSuffix ' D'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

Expand Down
19 changes: 19 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,22 @@
-keepclasseswithmembers class io.wookey.wallet.** { # <-- change package name to your app's
kotlinx.serialization.KSerializer serializer(...);
}

-dontwarn io.wookey.monero.**
-keep class io.wookey.monero.** { *; }
-keep interface io.wookey.monero.** { *; }

-assumenosideeffects class android.util.Log {
public static *** v(...);
public static *** d(...);
public static *** i(...);
public static *** w(...);
public static *** e(...);
}

-assumenosideeffects class java.io.PrintStream {
public void print(%);
public void print(**);
public void println(%);
public void println(**);
}
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@

<application
android:name=".App"
android:allowBackup="true"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="false"
android:theme="@style/AppTheme"
android:taskAffinity=""
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".SplashActivity"
Expand Down Expand Up @@ -116,6 +117,7 @@
<activity
android:name=".feature.setting.WebViewActivity"
android:configChanges="orientation|keyboardHidden"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".feature.setting.ContactUsActivity"
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/io/wookey/wallet/ActivityStackManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,14 @@ class ActivityStackManager private constructor() {
}
}

fun finishAll() {
synchronized(activityStack) {
val iterator = activityStack.iterator()
while (iterator.hasNext()) {
val next = iterator.next()
next.finish()
}
}
}

}
25 changes: 22 additions & 3 deletions app/src/main/java/io/wookey/wallet/SplashActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package io.wookey.wallet

import android.content.Intent
import android.os.Bundle
import android.util.Log
import io.wookey.wallet.base.BaseActivity
import io.wookey.wallet.data.AppDatabase
import io.wookey.wallet.dialog.PrivacyDialog
import io.wookey.wallet.feature.generate.WalletActivity
import io.wookey.wallet.feature.generate.create.BackupMnemonicActivity
import io.wookey.wallet.support.extensions.putBoolean
import io.wookey.wallet.support.extensions.sharedPreferences
import kotlinx.coroutines.*

Expand All @@ -17,8 +20,22 @@ class SplashActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)
val agreePrivacy = sharedPreferences().getBoolean("agreePrivacy", false)
if (agreePrivacy) {
startApp()
} else {
PrivacyDialog.display(supportFragmentManager, {
sharedPreferences().putBoolean("agreePrivacy", true)
startApp()
}) {
ActivityStackManager.getInstance().finishAll()
}
}
}

private fun startApp() {
uiScope.launch {
delay(1500)
// delay(1500)
val walletId = sharedPreferences().getInt("walletId", -1)
val activeWallet = withContext(Dispatchers.IO) {
val wallets = AppDatabase.getInstance().walletDao().getWallets()
Expand All @@ -27,12 +44,14 @@ class SplashActivity : BaseActivity() {
} else {
val activeWallets = AppDatabase.getInstance().walletDao().getActiveWallets()
if (activeWallets.isNullOrEmpty()) {
AppDatabase.getInstance().walletDao().updateWallets(wallets[0].apply { isActive = true })
AppDatabase.getInstance().walletDao()
.updateWallets(wallets[0].apply { isActive = true })
wallets[0]
} else {
activeWallets.forEachIndexed { index, wallet ->
if (index > 0) {
AppDatabase.getInstance().walletDao().updateWallets(wallet.apply { isActive = false })
AppDatabase.getInstance().walletDao()
.updateWallets(wallet.apply { isActive = false })
}
}
activeWallets[0]
Expand Down
20 changes: 9 additions & 11 deletions app/src/main/java/io/wookey/wallet/data/remote/RetrofitManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ import javax.net.ssl.SSLSession

object RetrofitManager {
const val CHANGELLY_API = "https://api.changelly.com/"

// modify to your's
const val API_KEY = "your changelly api key"
const val SECRET = "your changelly api secret"
const val API_KEY = "fbdbc96e3a9f42d99b6ef07b01f46c50"
const val SECRET = "fd1f3f7abd5a942ae03c6b00b81cbb7e557638270f5070e58bcbfcb019dfd7c7"

fun retrofit(okHttpClient: OkHttpClient = okHttpClient()): Retrofit =
Retrofit.Builder()
Expand Down Expand Up @@ -54,13 +52,13 @@ object RetrofitManager {
level = HttpLoggingInterceptor.Level.BODY
})

try {
val ssl = SSLSocketFactoryImpl(KeyStore.getInstance(KeyStore.getDefaultType()))
clientBuilder.sslSocketFactory(ssl.sSlContext.socketFactory, ssl.trustManager)
clientBuilder.hostnameVerifier { hostname, session -> session.verify() }
} catch (e: Exception) {
e.printStackTrace()
}
// try {
// val ssl = SSLSocketFactoryImpl(KeyStore.getInstance(KeyStore.getDefaultType()))
// clientBuilder.sslSocketFactory(ssl.sSlContext.socketFactory, ssl.trustManager)
// clientBuilder.hostnameVerifier { hostname, session -> session.verify() }
// } catch (e: Exception) {
// e.printStackTrace()
// }
return clientBuilder.build()
}

Expand Down
120 changes: 120 additions & 0 deletions app/src/main/java/io/wookey/wallet/dialog/PrivacyDialog.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package io.wookey.wallet.dialog

import android.content.Intent
import android.os.Bundle
import android.text.SpannableString
import android.text.method.LinkMovementMethod
import android.text.method.ScrollingMovementMethod
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import androidx.core.content.ContextCompat
import androidx.fragment.app.DialogFragment
import io.wookey.wallet.R
import io.wookey.wallet.feature.setting.WebViewActivity
import io.wookey.wallet.support.BackgroundHelper
import io.wookey.wallet.support.extensions.clickableSpan
import io.wookey.wallet.support.extensions.dp2px
import io.wookey.wallet.support.extensions.getCurrentLocale
import io.wookey.wallet.support.extensions.screenWidth
import kotlinx.android.synthetic.main.dialog_privacy.*

class PrivacyDialog : DialogFragment() {

private var confirmListener: (() -> Unit)? = null
private var cancelListener: (() -> Unit)? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NO_TITLE, R.style.CustomDialog)
isCancelable = false
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.dialog_privacy, container, false)
}

override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)

val layoutParams = dialogContainer.layoutParams
layoutParams.width = (screenWidth() * 0.85).toInt()
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT

dialogContainer.background =
BackgroundHelper.getBackground(context, R.color.color_FFFFFF, dp2px(5))
confirm.background = BackgroundHelper.getButtonBackground(context)

val agreement = getString(R.string.user_agreement)
val privacy = getString(R.string.privacy)
val contentText = getString(R.string.dialog_content_privacy, agreement, privacy)

val start1 = contentText.indexOf(agreement)
val end1 = start1 + agreement.length
val start2 = contentText.indexOf(privacy)
val end2 = start2 + privacy.length

val style = SpannableString(contentText)
style.clickableSpan(start1..end1, ContextCompat.getColor(activity!!, R.color.color_2179FF)) {
startActivity(Intent(activity, WebViewActivity::class.java).apply {
putExtra("url", "https://wallet.wookey.io/service-docs/terms-of-service.html")
})
}
style.clickableSpan(start2..end2, ContextCompat.getColor(activity!!, R.color.color_2179FF)) {
startActivity(Intent(activity, WebViewActivity::class.java).apply {
putExtra("url", "https://wallet.wookey.io/service-docs/privacy-policy.html?lang=${activity?.getCurrentLocale()}")
})
}

content.text = style
content.movementMethod = LinkMovementMethod.getInstance()

confirm.setOnClickListener {
confirmListener?.invoke()
hide()
}

cancel.setOnClickListener {
hide()
cancelListener?.invoke()
}
}

fun hide() {
val activity = activity
if (activity != null && !activity.isFinishing && !activity.isDestroyed) {
dismiss()
}
}

companion object {
private const val TAG = "PrivacyDialog"
fun newInstance(): PrivacyDialog {
val fragment = PrivacyDialog()
return fragment
}

fun display(
fm: androidx.fragment.app.FragmentManager,
confirmListener: (() -> Unit)?,
cancelListener: (() -> Unit)?
) {
val ft = fm.beginTransaction()
val prev = fm.findFragmentByTag(TAG)
if (prev != null) {
ft.remove(prev)
}
ft.addToBackStack(null)
newInstance().apply {
this.confirmListener = confirmListener
this.cancelListener = cancelListener
}.show(ft, TAG)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ import io.wookey.wallet.feature.generate.recovery.RecoveryWalletActivity
import io.wookey.wallet.feature.setting.WebViewActivity
import io.wookey.wallet.support.BackgroundHelper
import io.wookey.wallet.support.LengthFilter
import io.wookey.wallet.support.extensions.afterTextChanged
import io.wookey.wallet.support.extensions.clickableSpan
import io.wookey.wallet.support.extensions.dp2px
import io.wookey.wallet.support.extensions.toast
import io.wookey.wallet.support.extensions.*
import kotlinx.android.synthetic.main.activity_generate_wallet.*

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

val term = getString(R.string.agreement_term)
val s = "${getString(R.string.agreement_prompt)} $term"
val start = s.indexOf(term)
val end = start + term.length
val term1 = getString(R.string.user_agreement)
val term2 = getString(R.string.privacy)

val s = getString(R.string.agreement_prompt, term1, term2)
val start1 = s.indexOf(term1)
val end1 = start1 + term1.length
val start2 = s.indexOf(term2)
val end2 = start2 + term2.length
val style = SpannableString(s)
style.clickableSpan(start..end, ContextCompat.getColor(this, R.color.color_2179FF)) {
startActivity(Intent(this, WebViewActivity::class.java))
style.clickableSpan(start1..end1, ContextCompat.getColor(this, R.color.color_2179FF)) {
startActivity(Intent(this, WebViewActivity::class.java).apply {
putExtra("url", "https://wallet.wookey.io/service-docs/terms-of-service.html")
})
}
style.clickableSpan(start2..end2, ContextCompat.getColor(this, R.color.color_2179FF)) {
startActivity(Intent(this, WebViewActivity::class.java).apply {
putExtra("url", "https://wallet.wookey.io/service-docs/privacy-policy.html?lang=${getCurrentLocale()}")
})
}
agreement.text = style
agreement.movementMethod = LinkMovementMethod.getInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import io.wookey.wallet.R
import io.wookey.wallet.base.BaseTitleSecondActivity
import io.wookey.wallet.support.BackgroundHelper
import io.wookey.wallet.support.extensions.dp2px
import io.wookey.wallet.support.extensions.getCurrentLocale
import io.wookey.wallet.support.extensions.openBrowser
import io.wookey.wallet.support.extensions.versionName
import kotlinx.android.synthetic.main.activity_about.*
Expand All @@ -26,7 +27,15 @@ class AboutActivity : BaseTitleSecondActivity() {
}

agreement.setOnClickListener {
startActivity(Intent(this, WebViewActivity::class.java))
startActivity(Intent(this, WebViewActivity::class.java).apply {
putExtra("url", "https://wallet.wookey.io/service-docs/terms-of-service.html")
})
}

privacy.setOnClickListener {
startActivity(Intent(this, WebViewActivity::class.java).apply {
putExtra("url", "https://wallet.wookey.io/service-docs/privacy-policy.html?lang=${getCurrentLocale()}")
})
}
}

Expand Down
Loading

0 comments on commit 1878da6

Please sign in to comment.