X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2FBackupsActivity.java;h=2f81c6e43c24685fb27f88aabcfa4e9912a3ab70;hb=d327d3d2fc1ab854b5e90207af97fe7e0990af39;hp=9a1f706a718264f90cc2df3e39cc39802719df35;hpb=39eca7a036963be2e6dc4e6403961177f2c5267d;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/BackupsActivity.java b/app/src/main/java/net/ktnx/mobileledger/BackupsActivity.java index 9a1f706a..2f81c6e4 100644 --- a/app/src/main/java/net/ktnx/mobileledger/BackupsActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/BackupsActivity.java @@ -17,6 +17,8 @@ package net.ktnx.mobileledger; +import android.content.Context; +import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.MenuItem; @@ -33,6 +35,7 @@ import com.google.android.material.snackbar.Snackbar; import net.ktnx.mobileledger.async.ConfigReader; import net.ktnx.mobileledger.async.ConfigWriter; import net.ktnx.mobileledger.databinding.FragmentBackupsBinding; +import net.ktnx.mobileledger.model.Data; import java.io.IOException; import java.text.DateFormat; @@ -44,6 +47,10 @@ public class BackupsActivity extends AppCompatActivity { private FragmentBackupsBinding b; private ActivityResultLauncher backupChooserLauncher; private ActivityResultLauncher restoreChooserLauncher; + public static void start(Context context) { + Intent starter = new Intent(context, BackupsActivity.class); + context.startActivity(starter); + } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -67,6 +74,17 @@ public class BackupsActivity extends AppCompatActivity { restoreChooserLauncher = registerForActivityResult(new ActivityResultContracts.OpenDocument(), this::readConfig); + + Data.observeProfile(this, p -> { + if (p == null) { + b.backupButton.setEnabled(false); + b.backupExplanationText.setEnabled(false); + } + else { + b.backupButton.setEnabled(true); + b.backupExplanationText.setEnabled(true); + } + }); } @Override public boolean onOptionsItemSelected(MenuItem item) {