Skip to content

Commit a984166

Browse files
committed
In app alert button changed from "Close" to "Ok".
* Also onesignal_in_app_alert_ok_button_text string key option to change text.
1 parent 6ffa24c commit a984166

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565

6666
import com.onesignal.OneSignalDbContract.NotificationTable;
6767

68+
import static com.onesignal.OSUtils.getResourceString;
69+
6870
class GenerateNotification {
6971
private static Context currentContext = null;
7072
private static String packageName = null;
@@ -110,7 +112,7 @@ public void run() {
110112
List<String> buttonsLabels = new ArrayList<String>();
111113
List<String> buttonIds = new ArrayList<String>();
112114

113-
addAlertButtons(gcmJson, buttonsLabels, buttonIds);
115+
addAlertButtons(activity, gcmJson, buttonsLabels, buttonIds);
114116

115117
final List<String> finalButtonIds = buttonIds;
116118

@@ -735,7 +737,7 @@ else if (gcmBundle.has("grp"))
735737
}
736738
}
737739

738-
private static void addAlertButtons(JSONObject gcmBundle, List<String> buttonsLabels, List<String> buttonsIds) {
740+
private static void addAlertButtons(Context context, JSONObject gcmBundle, List<String> buttonsLabels, List<String> buttonsIds) {
739741
try {
740742
JSONObject customJson = new JSONObject(gcmBundle.optString("custom"));
741743

@@ -755,7 +757,7 @@ private static void addAlertButtons(JSONObject gcmBundle, List<String> buttonsLa
755757
}
756758

757759
if (buttonsLabels.size() < 3) {
758-
buttonsLabels.add("Close");
760+
buttonsLabels.add(getResourceString(context, "onesignal_in_app_alert_ok_button_text", "Ok"));
759761
buttonsIds.add(NotificationBundleProcessor.DEFAULT_ACTION);
760762
}
761763
} catch (Throwable t) {

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import android.content.Context;
3131
import android.content.pm.ApplicationInfo;
3232
import android.content.pm.PackageManager;
33+
import android.content.res.Resources;
3334
import android.net.ConnectivityManager;
3435
import android.net.NetworkInfo;
3536
import android.os.Bundle;
@@ -81,6 +82,14 @@ static String getManifestMeta(Context context, String metaName) {
8182
return null;
8283
}
8384

85+
static String getResourceString(Context context, String key, String defaultStr) {
86+
Resources resources = context.getResources();
87+
int bodyResId = resources.getIdentifier(key, "string", context.getPackageName());
88+
if (bodyResId != 0)
89+
return resources.getString(bodyResId);
90+
return defaultStr;
91+
}
92+
8493
static String getCorrectedLanguage() {
8594
String lang = Locale.getDefault().getLanguage();
8695

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444

4545
import java.io.IOException;
4646

47+
import static com.onesignal.OSUtils.getResourceString;
48+
4749
public class PushRegistratorGPS implements PushRegistrator {
4850

4951
private Context appContext;
@@ -107,13 +109,7 @@ private boolean checkPlayServices() {
107109
return true;
108110
}
109111

110-
private String getResourceString(Context context, String key, String defaultStr) {
111-
Resources resources = context.getResources();
112-
int bodyResId = resources.getIdentifier(key, "string", context.getPackageName());
113-
if (bodyResId != 0)
114-
return resources.getString(bodyResId);
115-
return defaultStr;
116-
}
112+
117113

118114
private void ShowUpdateGPSDialog(final int resultCode) {
119115
OneSignal.runOnUiThread(new Runnable() {

0 commit comments

Comments
 (0)