Skip to content

Commit 602de6c

Browse files
committed
Remove getVibrate / getSoundEnabled apis and logics
* Remove getVibrate and enableVibrate apis * Remove getSoundEnabled and enableSound apis * Remove logics using them
1 parent ae81bba commit 602de6c

File tree

3 files changed

+4
-68
lines changed

3 files changed

+4
-68
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/GenerateNotification.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,11 @@ private static void setAlertnessOptions(JSONObject fcmJson, NotificationCompat.B
240240
} catch (Throwable t) {
241241
notificationDefaults |= Notification.DEFAULT_LIGHTS;
242242
} // Can throw if an old android support lib is used or parse error.
243-
}
244-
else
243+
} else {
245244
notificationDefaults |= Notification.DEFAULT_LIGHTS;
245+
}
246246

247-
if (OneSignal.getVibrate() && fcmJson.optInt("vib", 1) == 1) {
247+
if (fcmJson.optInt("vib", 1) == 1) {
248248
if (fcmJson.has("vib_pt")) {
249249
long[] vibrationPattern = OSUtils.parseVibrationPattern(fcmJson);
250250
if (vibrationPattern != null)
@@ -931,9 +931,7 @@ private static int getDrawableId(String name) {
931931

932932
private static boolean isSoundEnabled(JSONObject fcmJson) {
933933
String sound = fcmJson.optString("sound", null);
934-
if ("null".equals(sound) || "nil".equals(sound))
935-
return false;
936-
return OneSignal.getSoundEnabled();
934+
return !"null".equals(sound) && !"nil".equals(sound);
937935
}
938936

939937
// Android 5.0 accent color to use, only works when AndroidManifest.xml is targetSdkVersion >= 21

OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignal.java

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,60 +2241,6 @@ static boolean isUserPrivacyConsentRequired() {
22412241
}
22422242
// End Remote params getters
22432243

2244-
// If true(default) - Device will always vibrate unless the device is in silent mode.
2245-
// If false - Device will only vibrate when the device is set on it's vibrate only mode.
2246-
/**
2247-
* By default OneSignal always vibrates the device when a notification is displayed unless the
2248-
* device is in a total silent mode.
2249-
* <br/><br/>
2250-
* <i>You can link this action to a UI button to give your user a vibration option for your notifications.</i>
2251-
* @param enable Passing {@code false} means that the device will only vibrate lightly when the device is in it's vibrate only mode.
2252-
*/
2253-
public static void enableVibrate(boolean enable) {
2254-
if (appContext == null) {
2255-
logger.error("enableVibrate called before initWithContext!");
2256-
return;
2257-
}
2258-
2259-
OneSignalPrefs.saveBool(
2260-
OneSignalPrefs.PREFS_ONESIGNAL,
2261-
OneSignalPrefs.PREFS_GT_VIBRATE_ENABLED,
2262-
enable);
2263-
}
2264-
2265-
static boolean getVibrate() {
2266-
return OneSignalPrefs.getBool(
2267-
OneSignalPrefs.PREFS_ONESIGNAL,
2268-
OneSignalPrefs.PREFS_GT_VIBRATE_ENABLED,
2269-
true);
2270-
}
2271-
2272-
// If true(default) - Sound plays when receiving notification. Vibrates when device is on vibrate only mode.
2273-
// If false - Only vibrates unless EnableVibrate(false) was set.
2274-
/**
2275-
* By default OneSignal plays the system's default notification sound when the
2276-
* device's notification system volume is turned on.
2277-
* <br/><br/>
2278-
* <i>You can link this action to a UI button to give your user a different sound option for your notifications.</i>
2279-
* @param enable Passing {@code false} means that the device will only vibrate unless the device is set to a total silent mode.
2280-
*/
2281-
public static void enableSound(boolean enable) {
2282-
if (appContext == null) {
2283-
logger.error("enableSound called before initWithContext!");
2284-
return;
2285-
}
2286-
2287-
OneSignalPrefs.saveBool(OneSignalPrefs.PREFS_ONESIGNAL,
2288-
OneSignalPrefs.PREFS_GT_SOUND_ENABLED,enable);
2289-
}
2290-
2291-
static boolean getSoundEnabled() {
2292-
return OneSignalPrefs.getBool(
2293-
OneSignalPrefs.PREFS_ONESIGNAL,
2294-
OneSignalPrefs.PREFS_GT_SOUND_ENABLED,
2295-
true);
2296-
}
2297-
22982244
static void setLastSessionTime(long time) {
22992245
OneSignalPrefs.saveLong(
23002246
OneSignalPrefs.PREFS_ONESIGNAL,

OneSignalSDK/unittest/src/test/java/com/test/onesignal/MainOneSignalClassRunner.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2659,8 +2659,6 @@ public void testMethodCalls_withSetAppIdCalledBeforeMethodCalls() throws Excepti
26592659
OneSignal.deleteTag("key");
26602660
OneSignal.deleteTags("[\"key1\", \"key2\"]");
26612661
OneSignal.disablePush(false);
2662-
OneSignal.enableVibrate(false);
2663-
OneSignal.enableSound(false);
26642662
OneSignal.promptLocation();
26652663
OneSignal.postNotification("{}", new OneSignal.PostNotificationResponseHandler() {
26662664
@Override
@@ -2691,8 +2689,6 @@ public void testMethodCalls_withInitWithContextCalledBeforeMethodCalls() throws
26912689
OneSignal.deleteTag("key");
26922690
OneSignal.deleteTags("[\"key1\", \"key2\"]");
26932691
OneSignal.disablePush(false);
2694-
OneSignal.enableVibrate(false);
2695-
OneSignal.enableSound(false);
26962692
OneSignal.promptLocation();
26972693
OneSignal.postNotification("{}", new OneSignal.PostNotificationResponseHandler() {
26982694
@Override
@@ -2721,8 +2717,6 @@ public void testMethodCalls_withInitWithContextAndSetAppId() throws Exception {
27212717
OneSignal.deleteTag("key");
27222718
OneSignal.deleteTags("[\"key1\", \"key2\"]");
27232719
OneSignal.disablePush(false);
2724-
OneSignal.enableVibrate(false);
2725-
OneSignal.enableSound(false);
27262720
OneSignal.promptLocation();
27272721
OneSignal.postNotification("{}", new OneSignal.PostNotificationResponseHandler() {
27282722
@Override
@@ -2751,8 +2745,6 @@ public void testMethodCalls_withSetAppIdAndInitWithContext() throws Exception {
27512745
OneSignal.deleteTag("key");
27522746
OneSignal.deleteTags("[\"key1\", \"key2\"]");
27532747
OneSignal.disablePush(false);
2754-
OneSignal.enableVibrate(false);
2755-
OneSignal.enableSound(false);
27562748
OneSignal.promptLocation();
27572749
OneSignal.postNotification("{}", new OneSignal.PostNotificationResponseHandler() {
27582750
@Override

0 commit comments

Comments
 (0)