Merge pull request #723 from grote/allow-restore

Allow restore whenever the user feels like it
This commit is contained in:
Torsten Grote 2024-09-05 16:24:13 -03:00 committed by GitHub
commit dc9391deef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 3 additions and 62 deletions

View file

@ -4,8 +4,6 @@
SPDX-License-Identifier: Apache-2.0
-->
<resources>
<bool name="show_restore_in_settings">true</bool>
<string-array name="storage_authority_whitelist">
<item>com.android.externalstorage.documents</item>
<item>org.nextcloud.documents</item>

View file

@ -154,18 +154,6 @@
</intent-filter>
</receiver>
<receiver
android:name=".SecretCodeReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.telephony.action.SECRET_CODE" />
<!-- *#*#RESTORE#*#* -->
<data
android:host="7378673"
android:scheme="android_secret_code" />
</intent-filter>
</receiver>
<!-- Used by Workmanager to schedule our workers -->
<service
android:name="androidx.work.impl.foreground.SystemForegroundService"

View file

@ -1,28 +0,0 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.util.Log
import com.stevesoltys.seedvault.restore.RestoreActivity
private val TAG = BroadcastReceiver::class.java.simpleName
private const val RESTORE_SECRET_CODE = "7378673"
class SecretCodeReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.data?.host != RESTORE_SECRET_CODE) return
Log.d(TAG, "Restore secret code received.")
val i = Intent(context, RestoreActivity::class.java).apply {
flags = FLAG_ACTIVITY_NEW_TASK
}
context.startActivity(i)
}
}

View file

@ -209,9 +209,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
inflater.inflate(R.menu.settings_menu, menu)
menuBackupNow = menu.findItem(R.id.action_backup)
menuRestore = menu.findItem(R.id.action_restore)
if (resources.getBoolean(R.bool.show_restore_in_settings)) {
menuRestore?.isVisible = true
}
viewModel.backupPossible.observe(viewLifecycleOwner) { possible ->
menuBackupNow?.isEnabled = possible
menuRestore?.isEnabled = possible

View file

@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
SPDX-FileCopyrightText: 2020 The Calyx Institute
SPDX-License-Identifier: Apache-2.0
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_backup"
@ -17,9 +15,7 @@
android:id="@+id/action_restore"
android:enabled="false"
android:title="@string/restore_backup_button"
android:visible="false"
app:showAsAction="never"
tools:visible="true" />
app:showAsAction="never" />
<item
android:id="@+id/action_settings_expert"

View file

@ -4,16 +4,6 @@
SPDX-License-Identifier: Apache-2.0
-->
<resources xmlns:tools="http://schemas.android.com/tools">
<!--
Normally, restoring from backup is only available during initial device setup.
You can make it always available at your own risk.
Keep in mind that the Auto-Restore feature works independently from this.
Launch an intent with the action "com.stevesoltys.seedvault.RESTORE_BACKUP"
to trigger restore during device setup.
-->
<bool name="show_restore_in_settings">false</bool>
<!--
Add only storage here that is also available
when restoring from backup (e.g. initial device setup)