Skip to content

Commit

Permalink
Fixed some issues related with "Rate" notification
Browse files Browse the repository at this point in the history
  • Loading branch information
artemiv4nov committed Sep 29, 2019
1 parent 826bac8 commit fcec4bb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions adguard_cb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ android {
minSdkVersion 21
targetSdkVersion 28
applicationId 'com.adguard.android.contentblocker'
versionCode 22000002
versionName '2.5.1'
versionCode 22000003
versionName '2.5.2'
signingConfig signingConfigs.config
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,23 @@ public static String getVersionName(Context context) {
return "1.0";
}

/**
* Checks Google Play Store is installed or not
*
* @param context App context
* @return Google Play Store is installed or not
*/
public static boolean isPlayStoreInstalled(Context context){
try {
context.getPackageManager().getPackageInfo("com.android.vending", 0);
return true;
} catch (Exception ignored) {
return false;
}
}

@SuppressLint("HardwareIds")
public static String getApplicationId(Context context) {
static String getApplicationId(Context context) {
final String androidId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
return androidId != null ? androidId : "Android";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import androidx.core.content.ContextCompat;

import com.adguard.android.contentblocker.ServiceLocator;
import com.adguard.android.contentblocker.commons.PackageUtils;
import com.adguard.android.contentblocker.service.NotificationService;
import com.adguard.android.contentblocker.ui.MainActivity;
import com.adguard.android.contentblocker.R;
Expand Down Expand Up @@ -99,6 +100,14 @@ public static void openWebSite(Context from, String url) {
* @param context Application context
*/
public static void redirectToPlayMarket(Context context) {
// We redirect to Google Play Store if it exists on device
if (PackageUtils.isPlayStoreInstalled(context)) {
try {
context.startActivity(createPlayMarketIntent(context, PLAY_MARKET_PREFIX_HTTP_SCHEME));
return;
} catch (ActivityNotFoundException ignored) { }
}

try {
context.startActivity(createPlayMarketIntent(context, PLAY_MARKET_PREFIX_CUSTOM_SCHEME));
} catch (ActivityNotFoundException e) {
Expand All @@ -115,7 +124,7 @@ public static void redirectToPlayMarket(Context context) {
*/
private static Intent createPlayMarketIntent(Context context, String prefix) {
Uri uri = Uri.parse(prefix + context.getPackageName());
return new Intent(Intent.ACTION_VIEW, uri);
return new Intent(Intent.ACTION_VIEW, uri).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}

private static void redirectUsingCustomTab(Context context, String url) {
Expand Down

0 comments on commit fcec4bb

Please sign in to comment.