Removed updates options from settings in case of non github apk.
This commit is contained in:
parent
54ac5e8940
commit
8ef702fa07
12 changed files with 68 additions and 9 deletions
8
app/src/debug/gen/org/schabi/newpipe/BuildConfig.java
Normal file
8
app/src/debug/gen/org/schabi/newpipe/BuildConfig.java
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
/*___Generated_by_IDEA___*/
|
||||||
|
|
||||||
|
package org.schabi.newpipe;
|
||||||
|
|
||||||
|
/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
|
||||||
|
public final class BuildConfig {
|
||||||
|
public final static boolean DEBUG = Boolean.parseBoolean(null);
|
||||||
|
}
|
7
app/src/debug/gen/org/schabi/newpipe/Manifest.java
Normal file
7
app/src/debug/gen/org/schabi/newpipe/Manifest.java
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
/*___Generated_by_IDEA___*/
|
||||||
|
|
||||||
|
package org.schabi.newpipe;
|
||||||
|
|
||||||
|
/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
|
||||||
|
public final class Manifest {
|
||||||
|
}
|
7
app/src/debug/gen/org/schabi/newpipe/R.java
Normal file
7
app/src/debug/gen/org/schabi/newpipe/R.java
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
/*___Generated_by_IDEA___*/
|
||||||
|
|
||||||
|
package org.schabi.newpipe;
|
||||||
|
|
||||||
|
/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
|
||||||
|
public final class R {
|
||||||
|
}
|
8
app/src/main/gen/org/schabi/newpipe/BuildConfig.java
Normal file
8
app/src/main/gen/org/schabi/newpipe/BuildConfig.java
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
/*___Generated_by_IDEA___*/
|
||||||
|
|
||||||
|
package org.schabi.newpipe;
|
||||||
|
|
||||||
|
/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
|
||||||
|
public final class BuildConfig {
|
||||||
|
public final static boolean DEBUG = Boolean.parseBoolean(null);
|
||||||
|
}
|
7
app/src/main/gen/org/schabi/newpipe/Manifest.java
Normal file
7
app/src/main/gen/org/schabi/newpipe/Manifest.java
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
/*___Generated_by_IDEA___*/
|
||||||
|
|
||||||
|
package org.schabi.newpipe;
|
||||||
|
|
||||||
|
/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
|
||||||
|
public final class Manifest {
|
||||||
|
}
|
7
app/src/main/gen/org/schabi/newpipe/R.java
Normal file
7
app/src/main/gen/org/schabi/newpipe/R.java
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
/*___Generated_by_IDEA___*/
|
||||||
|
|
||||||
|
package org.schabi.newpipe;
|
||||||
|
|
||||||
|
/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
|
||||||
|
public final class R {
|
||||||
|
}
|
|
@ -38,11 +38,10 @@ import java.security.cert.X509Certificate;
|
||||||
*/
|
*/
|
||||||
public class CheckForNewAppVersionTask extends AsyncTask<Void, Void, String> {
|
public class CheckForNewAppVersionTask extends AsyncTask<Void, Void, String> {
|
||||||
|
|
||||||
private Application app = App.getContext();
|
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 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 String newPipeApiUrl = "https://newpipe.schabi.org/api/data.json";
|
private static final int timeoutPeriod = 10000;
|
||||||
private int timeoutPeriod = 10000;
|
|
||||||
|
|
||||||
private SharedPreferences mPrefs;
|
private SharedPreferences mPrefs;
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ public class CheckForNewAppVersionTask extends AsyncTask<Void, Void, String> {
|
||||||
// Check if user has enabled/ disabled update checking
|
// Check if user has enabled/ disabled update checking
|
||||||
// and if the current apk is a github one or not.
|
// and if the current apk is a github one or not.
|
||||||
if (!mPrefs.getBoolean(app.getString(R.string.update_app_key), true)
|
if (!mPrefs.getBoolean(app.getString(R.string.update_app_key), true)
|
||||||
|| !getCertificateSHA1Fingerprint().equals(GITHUB_APK_SHA1)) {
|
|| !isGithubApk()) {
|
||||||
this.cancel(true);
|
this.cancel(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,7 +178,7 @@ public class CheckForNewAppVersionTask extends AsyncTask<Void, Void, String> {
|
||||||
* Method to get the apk's SHA1 key.
|
* Method to get the apk's SHA1 key.
|
||||||
* https://stackoverflow.com/questions/9293019/get-certificate-fingerprint-from-android-app#22506133
|
* https://stackoverflow.com/questions/9293019/get-certificate-fingerprint-from-android-app#22506133
|
||||||
*/
|
*/
|
||||||
private String getCertificateSHA1Fingerprint() {
|
private static String getCertificateSHA1Fingerprint() {
|
||||||
|
|
||||||
PackageManager pm = app.getPackageManager();
|
PackageManager pm = app.getPackageManager();
|
||||||
String packageName = app.getPackageName();
|
String packageName = app.getPackageName();
|
||||||
|
@ -240,4 +239,9 @@ public class CheckForNewAppVersionTask extends AsyncTask<Void, Void, String> {
|
||||||
}
|
}
|
||||||
return str.toString();
|
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 android.support.v7.preference.Preference;
|
||||||
|
|
||||||
import org.schabi.newpipe.BuildConfig;
|
import org.schabi.newpipe.BuildConfig;
|
||||||
|
import org.schabi.newpipe.CheckForNewAppVersionTask;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
|
||||||
public class MainSettingsFragment extends BasePreferenceFragment {
|
public class MainSettingsFragment extends BasePreferenceFragment {
|
||||||
|
@ -13,6 +14,13 @@ public class MainSettingsFragment extends BasePreferenceFragment {
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
addPreferencesFromResource(R.xml.main_settings);
|
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) {
|
if (!DEBUG) {
|
||||||
final Preference debug = findPreference(getString(R.string.debug_pref_screen_key));
|
final Preference debug = findPreference(getString(R.string.debug_pref_screen_key));
|
||||||
getPreferenceScreen().removePreference(debug);
|
getPreferenceScreen().removePreference(debug);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.CheckForNewAppVersionTask;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
|
||||||
public class UpdateSettingsFragment extends BasePreferenceFragment {
|
public class UpdateSettingsFragment extends BasePreferenceFragment {
|
||||||
|
|
|
@ -205,6 +205,7 @@
|
||||||
|
|
||||||
<!-- Updates -->
|
<!-- Updates -->
|
||||||
<string name="update_app_key" translatable="false">update_app_key</string>
|
<string name="update_app_key" translatable="false">update_app_key</string>
|
||||||
|
<string name="update_pref_screen_key" translatable="false">update_pref_screen_key</string>
|
||||||
|
|
||||||
<!-- alternatively, load these from some local android data store -->
|
<!-- alternatively, load these from some local android data store -->
|
||||||
<string-array name="language_codes" translatable="false">
|
<string-array name="language_codes" translatable="false">
|
||||||
|
|
|
@ -529,7 +529,7 @@
|
||||||
<string name="switch_view">Switch View</string>
|
<string name="switch_view">Switch View</string>
|
||||||
|
|
||||||
<!-- App update notification -->
|
<!-- App update notification -->
|
||||||
<string name="app_update_notification_content_title">NewPipe Update Available</string>
|
<string name="app_update_notification_content_title">NewPipe Update Available!</string>
|
||||||
<string name="app_update_notification_content_text">Tap to download</string>
|
<string name="app_update_notification_content_text">Tap to download</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -32,7 +32,8 @@
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:fragment="org.schabi.newpipe.settings.UpdateSettingsFragment"
|
android:fragment="org.schabi.newpipe.settings.UpdateSettingsFragment"
|
||||||
android:icon="?attr/ic_settings_update"
|
android:icon="?attr/ic_settings_update"
|
||||||
android:title="@string/settings_category_updates_title" />
|
android:title="@string/settings_category_updates_title"
|
||||||
|
android:key="update_pref_screen_key"/>
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:fragment="org.schabi.newpipe.settings.DebugSettingsFragment"
|
android:fragment="org.schabi.newpipe.settings.DebugSettingsFragment"
|
||||||
|
|
Loading…
Reference in a new issue