Skip to content

Commit

Permalink
Fixed OneSignal.
Browse files Browse the repository at this point in the history
  • Loading branch information
oldestlivingboy committed Mar 8, 2024
1 parent 4633d54 commit f7b7c4b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ dependencies {
implementation 'com.dtx12:actions:0.1.4'
implementation 'com.wbrawner.plausible:plausible-android:0.1.0-SNAPSHOT'
implementation 'com.google.firebase:firebase-functions:20.4.0'
implementation 'com.onesignal:OneSignal:5.1.4'
implementation 'com.onesignal:OneSignal:5.1.6'
testImplementation 'junit:junit:4.12'
}
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="com.samsung.android.sbrowser.permission.CONTENTBLOCKER" />
<queries>
<intent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
import com.rocketshipapps.adblockfast.utils.Ruleset;

public class MainActivity extends AppCompatActivity {
static final boolean IS_NOTIFICATIONS_PERMISSION_REQUIRED =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU;
// TODO: Refactor subscription constants
static final String RETRIEVED_ACCOUNT_PREF = "retrieved_account";
static final int REQUEST_PERMISSION_GET_ACCOUNTS = 1;
Expand Down Expand Up @@ -508,8 +510,22 @@ void onboardUser() {
Plausible.INSTANCE.event("Onboard", "/", "", null);

if (!AdblockFastApplication.prefs.contains(AdblockFastApplication.BLOCKING_MODE_KEY)) {
presentModes(() ->
presentNotificationsOptIn(() -> {
presentModes(() -> {
if (IS_NOTIFICATIONS_PERMISSION_REQUIRED) {
presentNotificationsOptIn(() -> {
if (hasSamsungBrowser) {
presentHelp(() ->
AdblockFastApplication
.prefs
.edit()
.putBoolean(AdblockFastApplication.IS_FIRST_RUN_KEY, false)
.apply()
);
} else {
presentHelp(this::onBackPressed);
}
});
} else {
if (hasSamsungBrowser) {
presentHelp(() ->
AdblockFastApplication
Expand All @@ -521,12 +537,13 @@ void onboardUser() {
} else {
presentHelp(this::onBackPressed);
}
})
);
}
});
} else if (
AdblockFastApplication
.prefs
.getInt(AdblockFastApplication.NOTIFICATIONS_REQUEST_COUNT_KEY, 0) == 0
IS_NOTIFICATIONS_PERMISSION_REQUIRED &&
AdblockFastApplication
.prefs
.getInt(AdblockFastApplication.NOTIFICATIONS_REQUEST_COUNT_KEY, 0) == 0
) {
presentNotificationsOptIn(() -> {
if (hasSamsungBrowser) {
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<string name="help_label">Help</string>
<string name="about_label">About</string>
<string name="mode_summary">
Block ads in just three steps, starting by choosing a blocking mode:
Block ads in just a couple steps, starting by choosing a blocking mode:
</string>
<string name="mode_details">
<![CDATA[<b>Fast</b> mode uses our default filtering rules.<br><br><b>Faster</b> (beta)
Expand Down

0 comments on commit f7b7c4b

Please sign in to comment.