Skip to content

Update modal behaviour android #7761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@ public void finishNativeInitialization() {
BraveSyncReflectionUtils.showInformers();
BraveAndroidSyncDisabledInformer.showInformers();

if (!PackageUtils.isFirstInstall(this)
&& !OnboardingPrefManager.getInstance().isP3AEnabledForExistingUsers()) {
BravePrefServiceBridge.getInstance().setP3AEnabled(true);
OnboardingPrefManager.getInstance().setP3AEnabledForExistingUsers(true);
}

if (BraveConfig.P3A_ENABLED
&& !OnboardingPrefManager.getInstance().isP3aOnboardingShown()) {
Intent p3aOnboardingIntent = new Intent(this, P3aOnboardingActivity.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ protected Pair<Bitmap, Bitmap> doInBackground() {
inputStream.close();
} catch(IOException exc) {
Log.e("NTP", exc.getMessage());
} catch (IllegalArgumentException exc) {
Log.e("NTP", exc.getMessage());
} finally {
try {
if (inputStream != null) {
inputStream.close();
try {
if (inputStream != null) {
inputStream.close();
}
} catch (IOException exception) {
Log.e("NTP", exception.getMessage());
}
} catch (IOException exception) {
Log.e("NTP", exception.getMessage());
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ public static Bitmap getWallpaperBitmap(NTPImage ntpImage, int layoutWidth, int
inputStream.close();
} catch (IOException exc) {
Log.e("NTP", exc.getMessage());
} catch (IllegalArgumentException exc) {
Log.e("NTP", exc.getMessage());
} finally {
try {
if (inputStream != null) {
Expand Down Expand Up @@ -376,15 +378,30 @@ public static Bitmap getCalculatedBitmap(Bitmap imageBitmap, float centerPointX,
}
}

imageBitmap = Bitmap.createScaledBitmap(imageBitmap, newImageWidth, newImageHeight, true);
Bitmap newBitmap = null;
Bitmap bitmapWithGradient = null;
try {
imageBitmap =
Bitmap.createScaledBitmap(imageBitmap, newImageWidth, newImageHeight, true);

Bitmap newBitmap = Bitmap.createBitmap(imageBitmap, (startX + layoutWidth) <= imageBitmap.getWidth() ? startX : 0, (startY + (int) layoutHeight) <= imageBitmap.getHeight() ? startY : 0, layoutWidth, (int) layoutHeight);
Bitmap bitmapWithGradient = ImageUtils.addGradient(newBitmap);
newBitmap = Bitmap.createBitmap(imageBitmap,
(startX + layoutWidth) <= imageBitmap.getWidth() ? startX : 0,
(startY + (int) layoutHeight) <= imageBitmap.getHeight() ? startY : 0,
layoutWidth, (int) layoutHeight);
bitmapWithGradient = ImageUtils.addGradient(newBitmap);

imageBitmap.recycle();
newBitmap.recycle();
if (imageBitmap != null && !imageBitmap.isRecycled()) imageBitmap.recycle();
if (newBitmap != null && !newBitmap.isRecycled()) newBitmap.recycle();

return bitmapWithGradient;
return bitmapWithGradient;
} catch (Exception exc) {
exc.printStackTrace();
Log.e("NTP", exc.getMessage());
return null;
} finally {
if (imageBitmap != null && !imageBitmap.isRecycled()) imageBitmap.recycle();
if (newBitmap != null && !newBitmap.isRecycled()) newBitmap.recycle();
}
}

public static Bitmap getTopSiteBitmap(String iconPath) {
Expand All @@ -397,6 +414,7 @@ public static Bitmap getTopSiteBitmap(String iconPath) {
topSiteIcon = BitmapFactory.decodeStream(inputStream);
inputStream.close();
} catch (IOException exc) {
exc.printStackTrace();
Log.e("NTP", exc.getMessage());
topSiteIcon = null;
} finally {
Expand All @@ -405,6 +423,7 @@ public static Bitmap getTopSiteBitmap(String iconPath) {
inputStream.close();
}
} catch (IOException exception) {
exception.printStackTrace();
Log.e("NTP", exception.getMessage());
topSiteIcon = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
public class OnboardingPrefManager {
private static final String PREF_ONBOARDING = "onboarding";
private static final String PREF_P3A_ONBOARDING = "p3a_onboarding";
private static final String PREF_P3A_ENABLED_FOR_EXISTING_USERS =
"p3a_enabled_for_existing_users";
private static final String PREF_CROSS_PROMO_MODAL = "cross_promo_modal";
private static final String PREF_ONBOARDING_V2 = "onboarding_v2";
private static final String PREF_NEXT_ONBOARDING_DATE = "next_onboarding_date";
Expand Down Expand Up @@ -106,6 +108,16 @@ public void setOnboardingShown(boolean isShown) {
sharedPreferencesEditor.apply();
}

public boolean isP3AEnabledForExistingUsers() {
return mSharedPreferences.getBoolean(PREF_P3A_ENABLED_FOR_EXISTING_USERS, false);
}

public void setP3AEnabledForExistingUsers(boolean isShown) {
SharedPreferences.Editor sharedPreferencesEditor = mSharedPreferences.edit();
sharedPreferencesEditor.putBoolean(PREF_P3A_ENABLED_FOR_EXISTING_USERS, isShown);
sharedPreferencesEditor.apply();
}

/**
* Returns the user preference for whether the onboarding is shown.
*/
Expand Down
Loading