diff options
author | LuK1337 <priv.luk@gmail.com> | 2022-05-26 00:03:21 +0200 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2022-06-29 12:32:24 +0800 |
commit | 458f2a2e609feabb845c343d18442e4a69b9ddf5 (patch) | |
tree | ce2765ef5c716c150827f1fdcd30b388ab8d03c9 /src/org/lineageos/updater/UpdatesActivity.java | |
parent | d62aa86abfa996196528e58823a5760397713926 (diff) |
Updater: Unbreak "Export update" featureHEADsugisawa-mr1
Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/4736
Change-Id: I186a27d2e99098cf8ebb3dd5c7348cdb528baa78
Diffstat (limited to 'src/org/lineageos/updater/UpdatesActivity.java')
-rw-r--r-- | src/org/lineageos/updater/UpdatesActivity.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java index 1ff629b..b66f35c 100644 --- a/src/org/lineageos/updater/UpdatesActivity.java +++ b/src/org/lineageos/updater/UpdatesActivity.java @@ -16,6 +16,7 @@ package org.lineageos.updater; import android.annotation.SuppressLint; +import android.app.Activity; import android.app.UiModeManager; import android.content.BroadcastReceiver; import android.content.ComponentName; @@ -44,6 +45,8 @@ import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; +import androidx.activity.result.ActivityResultLauncher; +import androidx.activity.result.contract.ActivityResultContracts; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.SwitchCompat; @@ -87,6 +90,19 @@ public class UpdatesActivity extends UpdatesListActivity { private boolean mIsTV; + private UpdateInfo mToBeExported = null; + private final ActivityResultLauncher<Intent> mExportUpdate = registerForActivityResult( + new ActivityResultContracts.StartActivityForResult(), + result -> { + if (result.getResultCode() == Activity.RESULT_OK) { + Intent intent = result.getData(); + if (intent != null) { + Uri uri = intent.getData(); + exportUpdate(uri); + } + } + }); + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -402,6 +418,26 @@ public class UpdatesActivity extends UpdatesListActivity { } @Override + public void exportUpdate(UpdateInfo update) { + mToBeExported = update; + + Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + intent.setType("application/zip"); + intent.putExtra(Intent.EXTRA_TITLE, update.getName()); + + mExportUpdate.launch(intent); + } + + private void exportUpdate(Uri uri) { + Intent intent = new Intent(this, ExportUpdateService.class); + intent.setAction(ExportUpdateService.ACTION_START_EXPORTING); + intent.putExtra(ExportUpdateService.EXTRA_SOURCE_FILE, mToBeExported.getFile()); + intent.putExtra(ExportUpdateService.EXTRA_DEST_URI, uri); + startService(intent); + } + + @Override public void showSnackbar(int stringId, int duration) { Snackbar.make(findViewById(R.id.main_container), stringId, duration).show(); } |