mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-11-13 21:47:11 +00:00
Removed updates options from settings in case of non github apk.
This commit is contained in:
@@ -38,11 +38,10 @@ import java.security.cert.X509Certificate;
|
||||
*/
|
||||
public class CheckForNewAppVersionTask extends AsyncTask<Void, Void, String> {
|
||||
|
||||
private Application app = App.getContext();
|
||||
|
||||
private String GITHUB_APK_SHA1 = "B0:2E:90:7C:1C:D6:FC:57:C3:35:F0:88:D0:8F:50:5F:94:E4:D2:15";
|
||||
private String newPipeApiUrl = "https://newpipe.schabi.org/api/data.json";
|
||||
private int timeoutPeriod = 10000;
|
||||
private static final Application app = App.getContext();
|
||||
private static final String GITHUB_APK_SHA1 = "B0:2E:90:7C:1C:D6:FC:57:C3:35:F0:88:D0:8F:50:5F:94:E4:D2:15";
|
||||
private static final String newPipeApiUrl = "https://newpipe.schabi.org/api/data.json";
|
||||
private static final int timeoutPeriod = 10000;
|
||||
|
||||
private SharedPreferences mPrefs;
|
||||
|
||||
@@ -54,7 +53,7 @@ public class CheckForNewAppVersionTask extends AsyncTask<Void, Void, String> {
|
||||
// Check if user has enabled/ disabled update checking
|
||||
// and if the current apk is a github one or not.
|
||||
if (!mPrefs.getBoolean(app.getString(R.string.update_app_key), true)
|
||||
|| !getCertificateSHA1Fingerprint().equals(GITHUB_APK_SHA1)) {
|
||||
|| !isGithubApk()) {
|
||||
this.cancel(true);
|
||||
}
|
||||
}
|
||||
@@ -179,7 +178,7 @@ public class CheckForNewAppVersionTask extends AsyncTask<Void, Void, String> {
|
||||
* Method to get the apk's SHA1 key.
|
||||
* https://stackoverflow.com/questions/9293019/get-certificate-fingerprint-from-android-app#22506133
|
||||
*/
|
||||
private String getCertificateSHA1Fingerprint() {
|
||||
private static String getCertificateSHA1Fingerprint() {
|
||||
|
||||
PackageManager pm = app.getPackageManager();
|
||||
String packageName = app.getPackageName();
|
||||
@@ -240,4 +239,9 @@ public class CheckForNewAppVersionTask extends AsyncTask<Void, Void, String> {
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
public static boolean isGithubApk() {
|
||||
|
||||
return getCertificateSHA1Fingerprint().equals(GITHUB_APK_SHA1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.os.Bundle;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import org.schabi.newpipe.BuildConfig;
|
||||
import org.schabi.newpipe.CheckForNewAppVersionTask;
|
||||
import org.schabi.newpipe.R;
|
||||
|
||||
public class MainSettingsFragment extends BasePreferenceFragment {
|
||||
@@ -13,6 +14,13 @@ public class MainSettingsFragment extends BasePreferenceFragment {
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.main_settings);
|
||||
|
||||
if (!CheckForNewAppVersionTask.isGithubApk()) {
|
||||
final Preference update = findPreference(getString(R.string.update_pref_screen_key));
|
||||
getPreferenceScreen().removePreference(update);
|
||||
|
||||
defaultPreferences.edit().putBoolean(getString(R.string.update_app_key), false).apply();
|
||||
}
|
||||
|
||||
if (!DEBUG) {
|
||||
final Preference debug = findPreference(getString(R.string.debug_pref_screen_key));
|
||||
getPreferenceScreen().removePreference(debug);
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import org.schabi.newpipe.CheckForNewAppVersionTask;
|
||||
import org.schabi.newpipe.R;
|
||||
|
||||
public class UpdateSettingsFragment extends BasePreferenceFragment {
|
||||
|
||||
Reference in New Issue
Block a user