Adapt UI and text to the different use-cases (backup vs. restore)

This commit is contained in:
Torsten Grote 2019-09-13 17:14:11 -03:00
parent 10ad6d6b2d
commit 55d92aec39
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF
11 changed files with 104 additions and 19 deletions

View file

@ -18,6 +18,8 @@ class RestoreActivity : RequireProvisioningActivity() {
viewModel = ViewModelProviders.of(this).get(RestoreViewModel::class.java)
super.onCreate(savedInstanceState)
if (isSetupWizard) hideSystemUI()
setContentView(R.layout.activity_fragment_container)
viewModel.chosenRestoreSet.observe(this, Observer { set ->

View file

@ -1,6 +1,7 @@
package com.stevesoltys.backup.ui
import android.view.MenuItem
import android.view.View
import androidx.annotation.CallSuper
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
@ -24,4 +25,10 @@ abstract class BackupActivity : AppCompatActivity() {
fragmentTransaction.commit()
}
protected fun hideSystemUI() {
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN)
}
}

View file

@ -12,6 +12,9 @@ const val REQUEST_CODE_BACKUP_LOCATION = 2
const val REQUEST_CODE_RECOVERY_CODE = 3
const val INTENT_EXTRA_IS_RESTORE = "isRestore"
const val INTENT_EXTRA_IS_SETUP_WIZARD = "isSetupWizard"
private const val ACTION_SETUP_WIZARD = "com.stevesoltys.backup.restore.RESTORE_BACKUP"
private val TAG = RequireProvisioningActivity::class.java.name
@ -21,6 +24,9 @@ private val TAG = RequireProvisioningActivity::class.java.name
*/
abstract class RequireProvisioningActivity : BackupActivity() {
protected val isSetupWizard: Boolean
get() = intent?.action == ACTION_SETUP_WIZARD
protected abstract fun getViewModel(): RequireProvisioningViewModel
@CallSuper
@ -52,17 +58,15 @@ abstract class RequireProvisioningActivity : BackupActivity() {
protected fun showStorageActivity() {
val intent = Intent(this, StorageActivity::class.java)
intent.putExtra(INTENT_EXTRA_IS_RESTORE, getViewModel().isRestoreOperation)
intent.putExtra(INTENT_EXTRA_IS_SETUP_WIZARD, isSetupWizard)
startActivityForResult(intent, REQUEST_CODE_BACKUP_LOCATION)
}
protected fun showRecoveryCodeActivity() {
val intent = Intent(this, RecoveryCodeActivity::class.java)
intent.putExtra(INTENT_EXTRA_IS_RESTORE, getViewModel().isRestoreOperation)
intent.putExtra(INTENT_EXTRA_IS_SETUP_WIZARD, isSetupWizard)
startActivityForResult(intent, REQUEST_CODE_RECOVERY_CODE)
}
protected fun isProvisioned(): Boolean {
return getViewModel().recoveryCodeIsSet() && getViewModel().validLocationIsSet()
}
}

View file

@ -2,19 +2,22 @@ package com.stevesoltys.backup.ui.recoverycode
import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProviders
import com.stevesoltys.backup.R
import com.stevesoltys.backup.ui.BackupActivity
import com.stevesoltys.backup.ui.INTENT_EXTRA_IS_RESTORE
import com.stevesoltys.backup.ui.INTENT_EXTRA_IS_SETUP_WIZARD
import com.stevesoltys.backup.ui.LiveEventHandler
class RecoveryCodeActivity : AppCompatActivity() {
class RecoveryCodeActivity : BackupActivity() {
private lateinit var viewModel: RecoveryCodeViewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (isSetupWizard()) hideSystemUI()
setContentView(R.layout.activity_recovery_code)
viewModel = ViewModelProviders.of(this).get(RecoveryCodeViewModel::class.java)
@ -63,4 +66,8 @@ class RecoveryCodeActivity : AppCompatActivity() {
return intent?.getBooleanExtra(INTENT_EXTRA_IS_RESTORE, false) ?: false
}
private fun isSetupWizard(): Boolean {
return intent?.getBooleanExtra(INTENT_EXTRA_IS_SETUP_WIZARD, false) ?: false
}
}

View file

@ -32,6 +32,8 @@ class RecoveryCodeInputFragment : Fragment() {
super.onActivityCreated(savedInstanceState)
viewModel = ViewModelProviders.of(requireActivity()).get(RecoveryCodeViewModel::class.java)
if (viewModel.isRestore) introText.setText(R.string.recovery_code_input_intro)
val adapter = getAdapter()
for (i in 0 until WORD_NUM) {

View file

@ -9,6 +9,7 @@ import androidx.lifecycle.ViewModelProviders
import com.stevesoltys.backup.R
import com.stevesoltys.backup.ui.BackupActivity
import com.stevesoltys.backup.ui.INTENT_EXTRA_IS_RESTORE
import com.stevesoltys.backup.ui.INTENT_EXTRA_IS_SETUP_WIZARD
import com.stevesoltys.backup.ui.LiveEventHandler
private val TAG = StorageActivity::class.java.name
@ -21,6 +22,8 @@ class StorageActivity : BackupActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (isSetupWizard()) hideSystemUI()
setContentView(R.layout.activity_fragment_container)
viewModel = if (isRestore()) {
@ -83,6 +86,10 @@ class StorageActivity : BackupActivity() {
return intent?.getBooleanExtra(INTENT_EXTRA_IS_RESTORE, false) ?: false
}
private fun isSetupWizard(): Boolean {
return intent?.getBooleanExtra(INTENT_EXTRA_IS_SETUP_WIZARD, false) ?: false
}
private fun getCheckFragmentTitle() = if (viewModel.isRestoreOperation) {
getString(R.string.storage_check_fragment_restore_title)
} else {

View file

@ -53,6 +53,10 @@ internal class StorageRootsFragment : Fragment(), StorageRootClickedListener {
titleView.text = getString(R.string.storage_fragment_restore_title)
backView.visibility = VISIBLE
backView.setOnClickListener { requireActivity().finishAfterTransition() }
} else {
warningIcon.visibility = VISIBLE
warningText.visibility = VISIBLE
divider.visibility = VISIBLE
}
listView.adapter = adapter

View file

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?android:attr/textColorSecondary"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M1,21h22L12,2 1,21zM13,18h-2v-2h2v2zM13,14h-2v-4h2v4z" />
</vector>

View file

@ -28,16 +28,56 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />
<ImageView
android:id="@+id/warningIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:src="@drawable/ic_warning"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/titleView"
tools:ignore="ContentDescription"
tools:visibility="visible" />
<TextView
android:id="@+id/warningText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="@string/storage_fragment_warning"
android:textSize="16sp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/warningIcon"
app:layout_constraintTop_toBottomOf="@+id/titleView"
tools:visibility="visible" />
<View
android:id="@+id/divider"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="16dp"
android:background="@color/divider"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/warningText"
tools:visibility="visible" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="16dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toTopOf="@+id/backView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/titleView"
app:layout_constraintTop_toBottomOf="@+id/divider"
app:layout_goneMarginTop="16dp"
tools:listitem="@layout/list_item_storage_root" />
<ProgressBar

View file

@ -26,7 +26,7 @@
android:completionThreshold="1"
android:imeOptions="actionNext|flagNavigateNext|flagNoPersonalizedLearning"
android:inputType="textAutoComplete"
android:nextFocusForward="@+id/wordInput3" />
android:nextFocusForward="@+id/wordInput2" />
</com.google.android.material.textfield.TextInputLayout>
@ -48,7 +48,7 @@
android:completionThreshold="1"
android:imeOptions="actionNext|flagNavigateNext|flagNoPersonalizedLearning"
android:inputType="textAutoComplete"
android:nextFocusForward="@+id/wordInput5" />
android:nextFocusForward="@+id/wordInput4" />
</com.google.android.material.textfield.TextInputLayout>
@ -70,7 +70,7 @@
android:completionThreshold="1"
android:imeOptions="actionNext|flagNavigateNext|flagNoPersonalizedLearning"
android:inputType="textAutoComplete"
android:nextFocusForward="@+id/wordInput7" />
android:nextFocusForward="@+id/wordInput6" />
</com.google.android.material.textfield.TextInputLayout>
@ -92,7 +92,7 @@
android:completionThreshold="1"
android:imeOptions="actionNext|flagNavigateNext|flagNoPersonalizedLearning"
android:inputType="textAutoComplete"
android:nextFocusForward="@+id/wordInput9" />
android:nextFocusForward="@+id/wordInput8" />
</com.google.android.material.textfield.TextInputLayout>
@ -114,7 +114,7 @@
android:completionThreshold="1"
android:imeOptions="actionNext|flagNavigateNext|flagNoPersonalizedLearning"
android:inputType="textAutoComplete"
android:nextFocusForward="@+id/wordInput11" />
android:nextFocusForward="@+id/wordInput10" />
</com.google.android.material.textfield.TextInputLayout>
@ -136,7 +136,7 @@
android:completionThreshold="1"
android:imeOptions="actionNext|flagNavigateNext|flagNoPersonalizedLearning"
android:inputType="textAutoComplete"
android:nextFocusForward="@+id/wordInput2" />
android:nextFocusForward="@+id/wordInput12" />
</com.google.android.material.textfield.TextInputLayout>
@ -159,7 +159,7 @@
android:completionThreshold="1"
android:imeOptions="actionNext|flagNavigateNext|flagNoPersonalizedLearning"
android:inputType="textAutoComplete"
android:nextFocusForward="@+id/wordInput4" />
android:nextFocusForward="@+id/wordInput3" />
</com.google.android.material.textfield.TextInputLayout>
@ -181,7 +181,7 @@
android:completionThreshold="1"
android:imeOptions="actionNext|flagNavigateNext|flagNoPersonalizedLearning"
android:inputType="textAutoComplete"
android:nextFocusForward="@+id/wordInput6" />
android:nextFocusForward="@+id/wordInput5" />
</com.google.android.material.textfield.TextInputLayout>
@ -203,7 +203,7 @@
android:completionThreshold="1"
android:imeOptions="actionNext|flagNavigateNext|flagNoPersonalizedLearning"
android:inputType="textAutoComplete"
android:nextFocusForward="@+id/wordInput8" />
android:nextFocusForward="@+id/wordInput7" />
</com.google.android.material.textfield.TextInputLayout>
@ -225,7 +225,7 @@
android:completionThreshold="1"
android:imeOptions="actionNext|flagNavigateNext|flagNoPersonalizedLearning"
android:inputType="textAutoComplete"
android:nextFocusForward="@+id/wordInput10" />
android:nextFocusForward="@+id/wordInput9" />
</com.google.android.material.textfield.TextInputLayout>
@ -247,7 +247,7 @@
android:completionThreshold="1"
android:imeOptions="actionNext|flagNavigateNext|flagNoPersonalizedLearning"
android:inputType="textAutoComplete"
android:nextFocusForward="@+id/wordInput12" />
android:nextFocusForward="@+id/wordInput11" />
</com.google.android.material.textfield.TextInputLayout>

View file

@ -39,6 +39,7 @@
<!-- Storage -->
<string name="storage_fragment_backup_title">Choose where to store backups</string>
<string name="storage_fragment_restore_title">Where to find your backups?</string>
<string name="storage_fragment_warning">People with access to your storage location can learn which apps you use, but do not get access to the apps\' data.</string>
<string name="storage_fake_drive_title">USB Flash Drive</string>
<string name="storage_fake_drive_summary">Needs to be plugged in</string>
<string name="storage_available_bytes"><xliff:g id="size" example="1 GB">%1$s</xliff:g> free</string>
@ -54,6 +55,7 @@
<string name="recovery_code_write_it_down">Write it down on paper now!</string>
<string name="recovery_code_confirm_button">Confirm Code</string>
<string name="recovery_code_confirm_intro">Enter your 12-word recovery code to ensure that it will work when you need it.</string>
<string name="recovery_code_input_intro">Enter your 12-word recovery code that you wrote down when setting up backups.</string>
<string name="recovery_code_done_button">Done</string>
<string name="recovery_code_input_hint_1">Word 1</string>
<string name="recovery_code_input_hint_2">Word 2</string>