Skip to content

Commit

Permalink
Go to GitHub releases when checking for updates if Play Store isn't a…
Browse files Browse the repository at this point in the history
…vailable
  • Loading branch information
farmerbb committed Oct 29, 2018
1 parent 7b42946 commit b37f436
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void onCreate(Bundle savedInstanceState) {
else
addPreferencesFromResource(R.xml.display_settings);

if(isPlayStoreInstalled(getActivity())
if(U.isPlayStoreInstalled(getActivity())
&& U.isPlayStoreRelease(getActivity())
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
addPreferencesFromResource(R.xml.desktop_optimization);
Expand Down Expand Up @@ -879,13 +879,4 @@ private void disablePreference(SharedPreferences prefNew, String preferenceName,
if(preference instanceof CheckBoxPreference)
((CheckBoxPreference) preference).setChecked(false);
}

public static boolean isPlayStoreInstalled(Context context) {
try {
context.getPackageManager().getPackageInfo("com.android.vending", 0);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
}
19 changes: 16 additions & 3 deletions app/src/main/java/com/farmerbb/secondscreen/util/U.java
Original file line number Diff line number Diff line change
Expand Up @@ -1007,9 +1007,13 @@ public static boolean castScreenActive(Context context) {
// Directs the user to check for updates
public static void checkForUpdates(Context context) {
String url;
if(isPlayStoreRelease(context))
url = "https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID;
else
if(isPlayStoreRelease(context)) {
if(BuildConfig.APPLICATION_ID.equals("com.farmerbb.secondscreen.free")
&& !isPlayStoreInstalled(context))
url = "https://github.com/farmerbb/SecondScreen/releases";
else
url = "https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID;
} else
url = "https://f-droid.org/repository/browse/?fdid=" + BuildConfig.APPLICATION_ID;

Intent intent = new Intent(Intent.ACTION_VIEW);
Expand Down Expand Up @@ -1430,4 +1434,13 @@ public static boolean hasSupportLibrary(Context context) {
return false;
}
}

public static boolean isPlayStoreInstalled(Context context) {
try {
context.getPackageManager().getPackageInfo("com.android.vending", 0);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
}

0 comments on commit b37f436

Please sign in to comment.