-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redesign: Add Large/Small PIN and Upgrade Support (#323)
- Loading branch information
1 parent
e237a37
commit 89b0e1d
Showing
17 changed files
with
477 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<solid android:color="@color/dash_white" /> | ||
|
||
<corners android:radius="10dp" /> | ||
|
||
<padding | ||
android:bottom="0dp" | ||
android:left="0dp" | ||
android:right="0dp" | ||
android:top="0dp" /> | ||
|
||
</shape> |
14 changes: 14 additions & 0 deletions
14
wallet/res/drawable/custom_pin_preview_background_gray.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<solid android:color="@color/dash_light_gray" /> | ||
|
||
<corners android:radius="10dp" /> | ||
|
||
<padding | ||
android:bottom="0dp" | ||
android:left="0dp" | ||
android:right="0dp" | ||
android:top="0dp" /> | ||
|
||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="oval"> | ||
|
||
<solid android:color="#000000" /> | ||
|
||
<size | ||
android:width="24dp" | ||
android:height="24dp" /> | ||
|
||
<stroke | ||
android:width="10dp" | ||
android:color="@android:color/transparent" /> | ||
|
||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tool="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
tool:background="@drawable/splash_activity_background"> | ||
|
||
<androidx.constraintlayout.widget.Guideline | ||
android:id="@+id/logo_guideline" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:orientation="horizontal" | ||
app:layout_constraintGuide_percent="0.10" /> | ||
|
||
<androidx.constraintlayout.widget.Guideline | ||
android:id="@+id/v_center_guideline" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:orientation="vertical" | ||
app:layout_constraintGuide_percent="0.50" /> | ||
|
||
<androidx.constraintlayout.widget.Guideline | ||
android:id="@+id/h_center_guideline" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:orientation="horizontal" | ||
app:layout_constraintGuide_percent="0.50" /> | ||
|
||
<ImageView | ||
android:id="@+id/dash_logo" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintBottom_toTopOf="@id/logo_guideline" | ||
app:layout_constraintEnd_toEndOf="@id/v_center_guideline" | ||
app:layout_constraintStart_toStartOf="@id/v_center_guideline" | ||
app:layout_constraintTop_toTopOf="@id/logo_guideline" | ||
app:layout_constraintWidth_percent="0.4" | ||
app:srcCompat="@drawable/ic_dash_logo_white" | ||
tool:ignore="ContentDescription" /> | ||
|
||
<LinearLayout | ||
android:id="@+id/title_pane" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="@dimen/lock_screen_content_margin_bottom" | ||
android:gravity="center" | ||
android:orientation="vertical" | ||
app:layout_constraintBottom_toTopOf="@id/h_center_guideline" | ||
app:layout_constraintTop_toTopOf="@id/h_center_guideline"> | ||
|
||
<TextView | ||
android:id="@+id/action_title" | ||
style="@style/MontserratMedium.PageTitle" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/lock_unlock_with_fingerprint" | ||
android:textColor="@color/dash_white" /> | ||
|
||
<TextView | ||
android:id="@+id/action_subtitle" | ||
style="@style/MontserratMedium.BodyText" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:text="@string/wallet_lock_try_again" | ||
android:textColor="@color/dash_white" /> | ||
|
||
</LinearLayout> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
wallet/src/de/schildbach/wallet/ui/AppUpgradeActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* Copyright 2020 Dash Core Group | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package de.schildbach.wallet.ui | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.os.Handler | ||
import android.view.View | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.lifecycle.Observer | ||
import androidx.lifecycle.ViewModelProviders | ||
import de.schildbach.wallet.WalletApplication | ||
import de.schildbach.wallet.ui.preference.PinRetryController | ||
import de.schildbach.wallet.ui.security.SecurityGuard | ||
import de.schildbach.wallet.ui.widget.PinPreviewView | ||
import de.schildbach.wallet_test.R | ||
import kotlinx.android.synthetic.main.activity_app_update.* | ||
import org.dash.wallet.common.Configuration | ||
import java.util.concurrent.TimeUnit | ||
|
||
class AppUpgradeActivity : AppCompatActivity() { | ||
|
||
companion object { | ||
@JvmStatic | ||
fun createIntent(context: Context): Intent { | ||
return Intent(context, AppUpgradeActivity::class.java) | ||
} | ||
} | ||
|
||
lateinit var configuration: Configuration | ||
private lateinit var pinRetryController: PinRetryController | ||
|
||
private val temporaryLockCheckHandler = Handler() | ||
private val temporaryLockCheckInterval = TimeUnit.SECONDS.toMillis(10) | ||
private val temporaryLockCheckRunnable = Runnable { | ||
if (pinRetryController.isLocked) { | ||
walletLocked() | ||
} else { | ||
askForPin() | ||
} | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_app_update) | ||
|
||
configuration = WalletApplication.getInstance().configuration | ||
configuration.pinLength = PinPreviewView.CUSTOM_PIN_LENGTH | ||
|
||
pinRetryController = PinRetryController.getInstance() | ||
|
||
temporaryLockCheckRunnable.run() | ||
} | ||
|
||
private fun askForPin() { | ||
title_pane.visibility = View.INVISIBLE | ||
dash_logo.visibility = View.INVISIBLE | ||
val checkPinSharedModel = ViewModelProviders.of(this)[CheckPinSharedModel::class.java] | ||
checkPinSharedModel.onCorrectPinCallback.observe(this, Observer<Pair<Int?, String?>> { (_, pin) -> | ||
onCorrectPin(pin!!) | ||
}) | ||
checkPinSharedModel.onCancelCallback.observe(this, Observer<Void> { | ||
temporaryLockCheckRunnable.run() | ||
}) | ||
CheckPinDuringUpgradeDialog.show(this, 0) | ||
} | ||
|
||
private fun onCorrectPin(pin: String) { | ||
val securityGuard = SecurityGuard() | ||
securityGuard.savePin(pin) | ||
securityGuard.savePassword(pin) | ||
configuration.pinLength = pin.length | ||
startActivity(WalletActivity.createIntent(this)) | ||
} | ||
|
||
private fun walletLocked() { | ||
title_pane.visibility = View.VISIBLE | ||
dash_logo.visibility = View.VISIBLE | ||
temporaryLockCheckHandler.postDelayed(temporaryLockCheckRunnable, temporaryLockCheckInterval) | ||
action_title.setText(R.string.wallet_lock_wallet_disabled) | ||
action_subtitle.text = pinRetryController.getWalletTemporaryLockedMessage(this) | ||
} | ||
|
||
override fun finish() { | ||
super.finish() | ||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) | ||
} | ||
} |
Oops, something went wrong.