Merge pull request #190 from gilbsgilbs/autoupdate-official
Bring back upstream code for release APK check
This commit is contained in:
commit
2f5fca649a
3 changed files with 16 additions and 1 deletions
|
@ -20,6 +20,7 @@ import org.schabi.newpipe.extractor.downloader.Response
|
||||||
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException
|
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException
|
||||||
import org.schabi.newpipe.util.ReleaseVersionUtil.coerceUpdateCheckExpiry
|
import org.schabi.newpipe.util.ReleaseVersionUtil.coerceUpdateCheckExpiry
|
||||||
import org.schabi.newpipe.util.ReleaseVersionUtil.isLastUpdateCheckExpired
|
import org.schabi.newpipe.util.ReleaseVersionUtil.isLastUpdateCheckExpired
|
||||||
|
import org.schabi.newpipe.util.ReleaseVersionUtil.isReleaseApk
|
||||||
import org.schabi.newpipe.util.Version
|
import org.schabi.newpipe.util.Version
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
|
@ -69,6 +70,11 @@ class NewVersionWorker(
|
||||||
|
|
||||||
@Throws(IOException::class, ReCaptchaException::class)
|
@Throws(IOException::class, ReCaptchaException::class)
|
||||||
private fun checkNewVersion() {
|
private fun checkNewVersion() {
|
||||||
|
// Check if the current apk is a github one or not.
|
||||||
|
if (!isReleaseApk()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext)
|
val prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext)
|
||||||
// Check if the last request has happened a certain time ago
|
// Check if the last request has happened a certain time ago
|
||||||
// to reduce the number of API requests.
|
// to reduce the number of API requests.
|
||||||
|
|
|
@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.schabi.newpipe.MainActivity;
|
import org.schabi.newpipe.MainActivity;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
import org.schabi.newpipe.util.ReleaseVersionUtil;
|
||||||
|
|
||||||
public class MainSettingsFragment extends BasePreferenceFragment {
|
public class MainSettingsFragment extends BasePreferenceFragment {
|
||||||
public static final boolean DEBUG = MainActivity.DEBUG;
|
public static final boolean DEBUG = MainActivity.DEBUG;
|
||||||
|
@ -21,6 +22,14 @@ public class MainSettingsFragment extends BasePreferenceFragment {
|
||||||
|
|
||||||
setHasOptionsMenu(true); // Otherwise onCreateOptionsMenu is not called
|
setHasOptionsMenu(true); // Otherwise onCreateOptionsMenu is not called
|
||||||
|
|
||||||
|
// Check if the app is updatable
|
||||||
|
if (!ReleaseVersionUtil.isReleaseApk()) {
|
||||||
|
getPreferenceScreen().removePreference(
|
||||||
|
findPreference(getString(R.string.update_pref_screen_key)));
|
||||||
|
|
||||||
|
defaultPreferences.edit().putBoolean(getString(R.string.update_app_key), false).apply();
|
||||||
|
}
|
||||||
|
|
||||||
// Hide debug preferences in RELEASE build variant
|
// Hide debug preferences in RELEASE build variant
|
||||||
if (!DEBUG) {
|
if (!DEBUG) {
|
||||||
getPreferenceScreen().removePreference(
|
getPreferenceScreen().removePreference(
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.time.format.DateTimeFormatter
|
||||||
object ReleaseVersionUtil {
|
object ReleaseVersionUtil {
|
||||||
// Public key of the certificate that is used in NewPipe release versions
|
// Public key of the certificate that is used in NewPipe release versions
|
||||||
private const val RELEASE_CERT_PUBLIC_KEY_SHA1 =
|
private const val RELEASE_CERT_PUBLIC_KEY_SHA1 =
|
||||||
"B0:2E:90:7C:1C:D6:FC:57:C3:35:F0:88:D0:8F:50:5F:94:E4:D2:15"
|
"7F:46:0D:D0:6A:2D:A0:6B:57:B5:2C:ED:73:06:B7:87:43:90:66:A9"
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun isReleaseApk(): Boolean {
|
fun isReleaseApk(): Boolean {
|
||||||
|
|
Loading…
Reference in a new issue