From f8a02ba5444340ebe2cddb09755f5538aea3b60a Mon Sep 17 00:00:00 2001 From: evermind Date: Thu, 1 Aug 2024 07:29:39 +0200 Subject: [PATCH] brave dialog stuff merge that --- app/build.gradle | 6 +++--- app/src/brave/res/values-de/strings.xml | 1 + app/src/brave/res/values/strings.xml | 1 + .../schabi/newpipe/BraveNewVersionWorkerHelper.java | 5 ++++- .../org/schabi/newpipe/BraveUpgradeActivity.java | 13 ++++++++++++- .../java/org/schabi/newpipe/BraveUpgradeInfo.kt | 3 ++- .../java/org/schabi/newpipe/NewVersionWorker.kt | 3 ++- 7 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 50e7c3d6e..c2b5be332 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -342,9 +342,9 @@ dependencies { // Date and time formatting implementation "org.ocpsoft.prettytime:prettytime:5.0.7.Final" - // upgrade helper - implementation 'com.github.evermind-zz.AppUpdater:app-dialog:26ad672227' - implementation 'com.github.evermind-zz.AppUpdater:app-updater:26ad672227' + // apk upgrade dialog/downloader + implementation 'com.github.evermind-zz.AppUpdater:app-dialog:1.2.0-1.2.0' + implementation 'com.github.evermind-zz.AppUpdater:app-updater:1.2.0-1.2.0' /** Debugging **/ // Memory leak detection diff --git a/app/src/brave/res/values-de/strings.xml b/app/src/brave/res/values-de/strings.xml index 2906cdacb..98ff89d2e 100644 --- a/app/src/brave/res/values-de/strings.xml +++ b/app/src/brave/res/values-de/strings.xml @@ -81,5 +81,6 @@ Aktualisieren + Neue Version: %s diff --git a/app/src/brave/res/values/strings.xml b/app/src/brave/res/values/strings.xml index bf6943d27..e55e23597 100644 --- a/app/src/brave/res/values/strings.xml +++ b/app/src/brave/res/values/strings.xml @@ -116,5 +116,6 @@ Update + New version %s diff --git a/app/src/main/java/org/schabi/newpipe/BraveNewVersionWorkerHelper.java b/app/src/main/java/org/schabi/newpipe/BraveNewVersionWorkerHelper.java index de80a487e..8419a7c12 100644 --- a/app/src/main/java/org/schabi/newpipe/BraveNewVersionWorkerHelper.java +++ b/app/src/main/java/org/schabi/newpipe/BraveNewVersionWorkerHelper.java @@ -44,16 +44,19 @@ public static JsonObject getVersionInfo( * Create the intent do launch the Activity/Dialog that will download the new APK. * * @param context android context + * @param versionName the new version string * @param apkLocationUrl the url of the apk * @param changeLog a short summary of what has changed * @return the intent described above */ public static Intent getUpgradeActivityIntent( final Context context, + final String versionName, final String apkLocationUrl, final String changeLog ) { - final BraveUpgradeInfo upgradeInfo = new BraveUpgradeInfo(apkLocationUrl, changeLog); + final BraveUpgradeInfo upgradeInfo = + new BraveUpgradeInfo(versionName, apkLocationUrl, changeLog); final Intent intent = new Intent(context, BraveUpgradeActivity.class); intent.putExtra(BraveUpgradeActivity.UPGRADE_INFO, upgradeInfo); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); diff --git a/app/src/main/java/org/schabi/newpipe/BraveUpgradeActivity.java b/app/src/main/java/org/schabi/newpipe/BraveUpgradeActivity.java index e23e014ce..6fda5ecbf 100644 --- a/app/src/main/java/org/schabi/newpipe/BraveUpgradeActivity.java +++ b/app/src/main/java/org/schabi/newpipe/BraveUpgradeActivity.java @@ -5,6 +5,7 @@ import android.content.Intent; import android.os.Bundle; import android.view.View; +import android.widget.Toast; import com.king.app.dialog.AppDialog; import com.king.app.dialog.AppDialogConfig; @@ -23,6 +24,9 @@ import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage; +/** + * This is a transparent activity with the only purpose to launch the upgrade dialogFragment. + */ public class BraveUpgradeActivity extends AppCompatActivity { public static final String UPGRADE_INFO = "upgrade_info"; @@ -45,8 +49,15 @@ private void setupAppUpdaterDialog( final BraveUpgradeInfo braveUpgradeInfo, final FragmentManager supportManager ) { + if (braveUpgradeInfo == null) { + Toast.makeText(context, BraveUpgradeInfo.class.getName() + " was null", + Toast.LENGTH_LONG).show(); + NewVersionWorker.enqueueNewVersionCheckingWork(context, true); + return; + } + final AppDialogConfig config = new AppDialogConfig(context); - config.setTitle("BraveNewPipe - ChangeLog") + config.setTitle(getString(R.string.update_new_version, braveUpgradeInfo.getVersionName())) .setCancel(context.getString(R.string.cancel)) .setConfirm(context.getString(R.string.update)) .setContent(braveUpgradeInfo.getChangeLog()) diff --git a/app/src/main/java/org/schabi/newpipe/BraveUpgradeInfo.kt b/app/src/main/java/org/schabi/newpipe/BraveUpgradeInfo.kt index 7189f36ce..12a1bd9d1 100644 --- a/app/src/main/java/org/schabi/newpipe/BraveUpgradeInfo.kt +++ b/app/src/main/java/org/schabi/newpipe/BraveUpgradeInfo.kt @@ -6,6 +6,7 @@ import kotlinx.parcelize.Parcelize @Parcelize class BraveUpgradeInfo( + val versionName: String?, val apkUrl: String?, - val changeLog: String, + val changeLog: String?, ) : Parcelable diff --git a/app/src/main/java/org/schabi/newpipe/NewVersionWorker.kt b/app/src/main/java/org/schabi/newpipe/NewVersionWorker.kt index 04587c333..25430a554 100644 --- a/app/src/main/java/org/schabi/newpipe/NewVersionWorker.kt +++ b/app/src/main/java/org/schabi/newpipe/NewVersionWorker.kt @@ -39,7 +39,7 @@ class NewVersionWorker( versionName: String, apkLocationUrl: String?, versionCode: Int, - changeLog: String // from BraveNewPipe's json + changeLog: String? // from BraveNewPipe's json ) { if (BuildConfig.VERSION_CODE >= versionCode) { if (inputData.getBoolean(IS_MANUAL, false)) { @@ -59,6 +59,7 @@ class NewVersionWorker( if (BraveNewVersionWorkerHelper.isBraveUpdateBehaviourEnabled(applicationContext)) { intent = BraveNewVersionWorkerHelper.getUpgradeActivityIntent( applicationContext, + versionName, apkLocationUrl, changeLog )