Add canary channels

Only show if user is already on canary channels
This commit is contained in:
topjohnwu 2019-03-08 06:23:13 -05:00
parent c134fb1939
commit 745865ee53
5 changed files with 24 additions and 0 deletions

View File

@ -73,6 +73,8 @@ public class Config {
public static final int STABLE_CHANNEL = 0;
public static final int BETA_CHANNEL = 1;
public static final int CUSTOM_CHANNEL = 2;
public static final int CANARY_CHANNEL = 3;
public static final int CANARY_DEBUG_CHANNEL = 4;
public static final int ROOT_ACCESS_DISABLED = 0;
public static final int ROOT_ACCESS_APPS_ONLY = 1;
public static final int ROOT_ACCESS_ADB_ONLY = 2;

View File

@ -63,6 +63,8 @@ public class Const {
}
public static final String STABLE_URL = getRaw("master", "stable.json");
public static final String BETA_URL = getRaw("master", "beta.json");
public static final String CANARY_URL = getRaw("master", "canary_builds/release.json");
public static final String CANARY_DEBUG_URL = getRaw("master", "canary_builds/canary.json");
public static final String REPO_URL = "https://api.github.com/users/Magisk-Modules-Repo/repos?per_page=100&sort=pushed&page=%d";
public static final String FILE_URL = "https://raw.githubusercontent.com/Magisk-Modules-Repo/%s/master/%s";
public static final String ZIP_URL = "https://github.com/Magisk-Modules-Repo/%s/archive/master.zip";

View File

@ -24,6 +24,12 @@ public class CheckUpdates {
case Config.Value.CUSTOM_CHANNEL:
url = Config.get(Config.Key.CUSTOM_CHANNEL);
break;
case Config.Value.CANARY_CHANNEL:
url = Const.Url.CANARY_URL;
break;
case Config.Value.CANARY_DEBUG_CHANNEL:
url = Const.Url.CANARY_DEBUG_URL;
break;
case Config.Value.STABLE_CHANNEL:
default:
url = Const.Url.STABLE_URL;

View File

@ -33,6 +33,7 @@ import com.topjohnwu.net.Networking;
import com.topjohnwu.superuser.Shell;
import java.io.IOException;
import java.util.Arrays;
import java.util.Locale;
public class SettingsFragment extends BasePreferenceFragment implements Topic.Subscriber {
@ -109,6 +110,15 @@ public class SettingsFragment extends BasePreferenceFragment implements Topic.Su
return true;
});
/* We only show canary channels if user is already on canary channel
* or the user have already chosen canary channel */
if (!BuildConfig.VERSION_NAME.contains("-") &&
(int) Config.get(Config.Key.UPDATE_CHANNEL) < Config.Value.CANARY_CHANNEL) {
// Remove the last 2 entries
CharSequence[] entries = updateChannel.getEntries();
updateChannel.setEntries(Arrays.copyOf(entries, entries.length - 2));
}
setSummary();
// Disable dangerous settings in secondary user

View File

@ -21,6 +21,7 @@
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
</string-array>
<string-array name="request_timeout">
@ -80,6 +81,9 @@
<item>@string/settings_update_stable</item>
<item>@string/settings_update_beta</item>
<item>@string/settings_update_custom</item>
<!-- Debug only, don't care to translate -->
<item>Canary</item>
<item>Canary (Debug)</item>
</string-array>
<string-array name="boot_formats">