mirror of
https://github.com/deltazefiro/Amarok-Hider.git
synced 2026-05-26 14:40:35 +00:00
chore: Remove in-app auto-update for FOSS builds (#254)
This commit is contained in:
+8
@@ -121,6 +121,14 @@ public class UpdateUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String getStorePageUrl() {
|
||||
throw new UnsupportedOperationException("AppCenter build has in-app updates");
|
||||
}
|
||||
|
||||
private static boolean isNewerVersion(@NonNull String current, @NonNull String newVersion) {
|
||||
current = current.replaceFirst("^v", "");
|
||||
newVersion = newVersion.replaceFirst("^v", "");
|
||||
@@ -0,0 +1,35 @@
|
||||
package deltazero.amarok.utils;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class UpdateUtil {
|
||||
|
||||
public enum UpdateChannel {
|
||||
RELEASE, BETA;
|
||||
|
||||
public static UpdateChannel fromString(String value) {
|
||||
try {
|
||||
return valueOf(value.toUpperCase());
|
||||
} catch (Exception e) {
|
||||
return RELEASE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public record Release(String version, String url) {
|
||||
}
|
||||
|
||||
public static void checkAndNotify(@NonNull Context context, boolean silent) {
|
||||
// No-op: F-Droid manages updates for this build
|
||||
}
|
||||
|
||||
public static boolean isAvailable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getStorePageUrl() {
|
||||
return "https://f-droid.org/en/packages/deltazero.amarok.foss/";
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class MainActivity extends AmarokActivity {
|
||||
});
|
||||
|
||||
// Check for updates
|
||||
if (PrefMgr.getEnableAutoUpdate()) {
|
||||
if (UpdateUtil.isAvailable() && PrefMgr.getEnableAutoUpdate()) {
|
||||
UpdateUtil.checkAndNotify(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package deltazero.amarok.ui.settings;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
@@ -30,36 +32,48 @@ public class UpdateCategory extends BaseCategory {
|
||||
checkUpdatePref.setTitle(R.string.check_update);
|
||||
checkUpdatePref.setIcon(R.drawable.update_black_24dp);
|
||||
checkUpdatePref.setSummary(activity.getString(R.string.check_update_description, appVersionName));
|
||||
checkUpdatePref.setOnPreferenceClickListener(preference -> {
|
||||
UpdateUtil.checkAndNotify(activity, false);
|
||||
return true;
|
||||
});
|
||||
if (UpdateUtil.isAvailable()) {
|
||||
checkUpdatePref.setOnPreferenceClickListener(preference -> {
|
||||
UpdateUtil.checkAndNotify(activity, false);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
// Store-managed build: open the store page instead
|
||||
checkUpdatePref.setOnPreferenceClickListener(preference -> {
|
||||
activity.startActivity(new Intent(Intent.ACTION_VIEW,
|
||||
Uri.parse(UpdateUtil.getStorePageUrl())));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
addPreference(checkUpdatePref);
|
||||
|
||||
// Update channel preference
|
||||
var updateChannelPref = new DropDownPreference(activity);
|
||||
updateChannelPref.setKey(PrefMgr.UPDATE_CHANNEL);
|
||||
updateChannelPref.setIcon(R.drawable.alt_route_24dp_1f1f1f_fill0_wght400_grad0_opsz24);
|
||||
updateChannelPref.setTitle(R.string.update_channel);
|
||||
updateChannelPref.setSummary("%s");
|
||||
updateChannelPref.setEntries(new CharSequence[]{
|
||||
activity.getString(R.string.update_channel_release),
|
||||
activity.getString(R.string.update_channel_beta)
|
||||
});
|
||||
updateChannelPref.setEntryValues(new CharSequence[]{
|
||||
UpdateUtil.UpdateChannel.RELEASE.name(),
|
||||
UpdateUtil.UpdateChannel.BETA.name()
|
||||
});
|
||||
updateChannelPref.setDefaultValue(UpdateUtil.UpdateChannel.RELEASE.name());
|
||||
addPreference(updateChannelPref);
|
||||
// Update channel and auto-update are only shown for self-updating builds
|
||||
if (UpdateUtil.isAvailable()) {
|
||||
// Update channel preference
|
||||
var updateChannelPref = new DropDownPreference(activity);
|
||||
updateChannelPref.setKey(PrefMgr.UPDATE_CHANNEL);
|
||||
updateChannelPref.setIcon(R.drawable.alt_route_24dp_1f1f1f_fill0_wght400_grad0_opsz24);
|
||||
updateChannelPref.setTitle(R.string.update_channel);
|
||||
updateChannelPref.setSummary("%s");
|
||||
updateChannelPref.setEntries(new CharSequence[]{
|
||||
activity.getString(R.string.update_channel_release),
|
||||
activity.getString(R.string.update_channel_beta)
|
||||
});
|
||||
updateChannelPref.setEntryValues(new CharSequence[]{
|
||||
UpdateUtil.UpdateChannel.RELEASE.name(),
|
||||
UpdateUtil.UpdateChannel.BETA.name()
|
||||
});
|
||||
updateChannelPref.setDefaultValue(UpdateUtil.UpdateChannel.RELEASE.name());
|
||||
addPreference(updateChannelPref);
|
||||
|
||||
// Auto update switch
|
||||
var autoUpdatePref = new MaterialSwitchPreference(activity);
|
||||
autoUpdatePref.setKey(PrefMgr.IS_ENABLE_AUTO_UPDATE);
|
||||
autoUpdatePref.setIcon(R.drawable.autorenew_black_24dp);
|
||||
autoUpdatePref.setTitle(R.string.check_update_on_start);
|
||||
autoUpdatePref.setSummary(R.string.check_update_on_start_description);
|
||||
autoUpdatePref.setDefaultValue(true);
|
||||
addPreference(autoUpdatePref);
|
||||
// Auto update switch
|
||||
var autoUpdatePref = new MaterialSwitchPreference(activity);
|
||||
autoUpdatePref.setKey(PrefMgr.IS_ENABLE_AUTO_UPDATE);
|
||||
autoUpdatePref.setIcon(R.drawable.autorenew_black_24dp);
|
||||
autoUpdatePref.setTitle(R.string.check_update_on_start);
|
||||
autoUpdatePref.setSummary(R.string.check_update_on_start_description);
|
||||
autoUpdatePref.setDefaultValue(true);
|
||||
addPreference(autoUpdatePref);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package deltazero.amarok.utils;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class UpdateUtil {
|
||||
|
||||
public enum UpdateChannel {
|
||||
RELEASE, BETA;
|
||||
|
||||
public static UpdateChannel fromString(String value) {
|
||||
try {
|
||||
return valueOf(value.toUpperCase());
|
||||
} catch (Exception e) {
|
||||
return RELEASE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public record Release(String version, String url) {
|
||||
}
|
||||
|
||||
public static void checkAndNotify(@NonNull Context context, boolean silent) {
|
||||
// No-op: Play Store manages updates for this build
|
||||
}
|
||||
|
||||
public static boolean isAvailable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getStorePageUrl() {
|
||||
// Play store is not ready yet
|
||||
return "https://github.com/deltazefiro/Amarok-Hider/releases";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user