Skip to content

Commit

Permalink
brave dialog stuff merge that
Browse files Browse the repository at this point in the history
  • Loading branch information
evermind-zz committed Aug 1, 2024
1 parent 6a3763c commit f8a02ba
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/src/brave/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@

<!-- begin BraveNewPipe Apk upgrade dialog -->
<string name="update">Aktualisieren</string>
<string name="update_new_version">Neue Version: %s</string>
<!-- end BraveNewPipe Apk upgrade dialog -->
</resources>
1 change: 1 addition & 0 deletions app/src/brave/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,6 @@

<!-- begin BraveNewPipe Apk upgrade dialog -->
<string name="update">Update</string>
<string name="update_new_version">New version %s</string>
<!-- end BraveNewPipe Apk upgrade dialog -->
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 12 additions & 1 deletion app/src/main/java/org/schabi/newpipe/BraveUpgradeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";

Expand All @@ -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())
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/org/schabi/newpipe/BraveUpgradeInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import kotlinx.parcelize.Parcelize
@Parcelize
class BraveUpgradeInfo(

val versionName: String?,
val apkUrl: String?,
val changeLog: String,
val changeLog: String?,
) : Parcelable
3 changes: 2 additions & 1 deletion app/src/main/java/org/schabi/newpipe/NewVersionWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -59,6 +59,7 @@ class NewVersionWorker(
if (BraveNewVersionWorkerHelper.isBraveUpdateBehaviourEnabled(applicationContext)) {
intent = BraveNewVersionWorkerHelper.getUpgradeActivityIntent(
applicationContext,
versionName,
apkLocationUrl,
changeLog
)
Expand Down

0 comments on commit f8a02ba

Please sign in to comment.