Merge pull request #73 from grote/notification-fix
Fix Notification icon and hide navigation bar in SetupWizard
This commit is contained in:
commit
60e84808c5
6 changed files with 25 additions and 18 deletions
|
@ -53,20 +53,9 @@ class BackupNotificationManager(private val context: Context) {
|
|||
return NotificationChannel(CHANNEL_ID_RESTORE_ERROR, title, IMPORTANCE_HIGH)
|
||||
}
|
||||
|
||||
private val observerBuilder = Builder(context, CHANNEL_ID_OBSERVER).apply {
|
||||
setSmallIcon(R.drawable.ic_cloud_upload)
|
||||
}
|
||||
|
||||
private val errorBuilder = Builder(context, CHANNEL_ID_ERROR).apply {
|
||||
setSmallIcon(R.drawable.ic_cloud_error)
|
||||
}
|
||||
|
||||
private val restoreErrorBuilder = Builder(context, CHANNEL_ID_RESTORE_ERROR).apply {
|
||||
setSmallIcon(R.drawable.ic_cloud_error)
|
||||
}
|
||||
|
||||
fun onBackupUpdate(app: CharSequence, transferred: Int, expected: Int, userInitiated: Boolean) {
|
||||
val notification = observerBuilder.apply {
|
||||
val notification = Builder(context, CHANNEL_ID_OBSERVER).apply {
|
||||
setSmallIcon(R.drawable.ic_cloud_upload)
|
||||
setContentTitle(context.getString(R.string.notification_title))
|
||||
setContentText(app)
|
||||
setOngoing(true)
|
||||
|
@ -92,13 +81,13 @@ class BackupNotificationManager(private val context: Context) {
|
|||
action = ACTION_APP_STATUS_LIST
|
||||
}
|
||||
val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0)
|
||||
val notification = observerBuilder.apply {
|
||||
val notification = Builder(context, CHANNEL_ID_OBSERVER).apply {
|
||||
setSmallIcon(iconRes)
|
||||
setContentTitle(context.getString(titleRes))
|
||||
setContentText(contentText)
|
||||
setOngoing(false)
|
||||
setShowWhen(true)
|
||||
setAutoCancel(true)
|
||||
setSmallIcon(iconRes)
|
||||
setContentIntent(pendingIntent)
|
||||
setWhen(System.currentTimeMillis())
|
||||
setProgress(0, 0, false)
|
||||
|
@ -112,7 +101,8 @@ class BackupNotificationManager(private val context: Context) {
|
|||
val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0)
|
||||
val actionText = context.getString(R.string.notification_error_action)
|
||||
val action = Action(R.drawable.ic_storage, actionText, pendingIntent)
|
||||
val notification = errorBuilder.apply {
|
||||
val notification = Builder(context, CHANNEL_ID_ERROR).apply {
|
||||
setSmallIcon(R.drawable.ic_cloud_error)
|
||||
setContentTitle(context.getString(R.string.notification_error_title))
|
||||
setContentText(context.getString(R.string.notification_error_text))
|
||||
setWhen(System.currentTimeMillis())
|
||||
|
@ -141,7 +131,8 @@ class BackupNotificationManager(private val context: Context) {
|
|||
val pendingIntent = PendingIntent.getBroadcast(context, REQUEST_CODE_UNINSTALL, intent, FLAG_UPDATE_CURRENT)
|
||||
val actionText = context.getString(R.string.notification_restore_error_action)
|
||||
val action = Action(R.drawable.ic_warning, actionText, pendingIntent)
|
||||
val notification = restoreErrorBuilder.apply {
|
||||
val notification = Builder(context, CHANNEL_ID_RESTORE_ERROR).apply {
|
||||
setSmallIcon(R.drawable.ic_cloud_error)
|
||||
setContentTitle(context.getString(R.string.notification_restore_error_title, appName))
|
||||
setContentText(context.getString(R.string.notification_restore_error_text, storageName))
|
||||
setWhen(System.currentTimeMillis())
|
||||
|
|
|
@ -19,6 +19,8 @@ class RestoreActivity : RequireProvisioningActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
if (isSetupWizard) hideSystemUI()
|
||||
|
||||
setContentView(R.layout.activity_fragment_container)
|
||||
|
||||
viewModel.displayFragment.observeEvent(this, LiveEventHandler { fragment ->
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.stevesoltys.seedvault.ui
|
||||
|
||||
import android.view.MenuItem
|
||||
import android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
|
@ -24,4 +25,8 @@ abstract class BackupActivity : AppCompatActivity() {
|
|||
fragmentTransaction.commit()
|
||||
}
|
||||
|
||||
protected fun hideSystemUI() {
|
||||
window.decorView.systemUiVisibility = SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ private val TAG = RequireProvisioningActivity::class.java.name
|
|||
*/
|
||||
abstract class RequireProvisioningActivity : BackupActivity() {
|
||||
|
||||
private val isSetupWizard: Boolean
|
||||
protected val isSetupWizard: Boolean
|
||||
get() = intent?.action == ACTION_SETUP_WIZARD
|
||||
|
||||
protected abstract fun getViewModel(): RequireProvisioningViewModel
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.view.MenuItem
|
|||
import com.stevesoltys.seedvault.R
|
||||
import com.stevesoltys.seedvault.ui.BackupActivity
|
||||
import com.stevesoltys.seedvault.ui.INTENT_EXTRA_IS_RESTORE
|
||||
import com.stevesoltys.seedvault.ui.INTENT_EXTRA_IS_SETUP_WIZARD
|
||||
import com.stevesoltys.seedvault.ui.LiveEventHandler
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
|
@ -15,6 +16,8 @@ class RecoveryCodeActivity : BackupActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
if (isSetupWizard()) hideSystemUI()
|
||||
|
||||
setContentView(R.layout.activity_recovery_code)
|
||||
|
||||
viewModel.isRestore = isRestore()
|
||||
|
@ -62,4 +65,8 @@ class RecoveryCodeActivity : BackupActivity() {
|
|||
return intent?.getBooleanExtra(INTENT_EXTRA_IS_RESTORE, false) ?: false
|
||||
}
|
||||
|
||||
private fun isSetupWizard(): Boolean {
|
||||
return intent?.getBooleanExtra(INTENT_EXTRA_IS_SETUP_WIZARD, false) ?: false
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,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()) {
|
||||
|
|
Loading…
Reference in a new issue