|
9 | 9 | import android.app.Application; |
10 | 10 |
|
11 | 11 | import com.instabug.library.Instabug; |
| 12 | +import com.instabug.library.internal.module.InstabugLocale; |
12 | 13 | import com.instabug.library.invocation.InstabugInvocationEvent; |
| 14 | +import com.instabug.library.ui.onboarding.WelcomeMessage; |
13 | 15 |
|
14 | 16 | import java.lang.reflect.Array; |
15 | 17 | import java.lang.reflect.InvocationTargetException; |
|
21 | 23 | import java.util.HashMap; |
22 | 24 | import java.util.Iterator; |
23 | 25 | import java.util.List; |
| 26 | +import java.util.Locale; |
24 | 27 | import java.util.Map; |
25 | 28 |
|
26 | 29 | import android.os.Handler; |
27 | 30 | import android.os.Looper; |
28 | 31 | import android.util.Log; |
29 | 32 |
|
| 33 | + |
30 | 34 | // import com.instabug.library.InstabugColorTheme; |
31 | 35 | // import com.instabug.library.InstabugCustomTextPlaceHolder; |
32 | 36 | // import com.instabug.library.internal.module.InstabugLocale; |
@@ -100,13 +104,96 @@ public void start(Application application, String token, ArrayList<String> invoc |
100 | 104 | new Instabug.Builder(application, token).setInvocationEvents(invocationEventsArray).build(); |
101 | 105 | } |
102 | 106 |
|
| 107 | + |
| 108 | + /** |
| 109 | + * Shows the welcome message in a specific mode. |
| 110 | + * |
| 111 | + * @param welcomeMessageMode An enum to set the welcome message mode to |
| 112 | + * live, or beta. |
| 113 | + */ |
| 114 | + public void showWelcomeMessageWithMode(String welcomeMessageMode) { |
| 115 | + Instabug.showWelcomeMessage((WelcomeMessage.State) constants.get(welcomeMessageMode)); |
| 116 | + } |
| 117 | + |
| 118 | + /** |
| 119 | + * Set the user identity. |
| 120 | + * |
| 121 | + * @param userName Username. |
| 122 | + * @param userEmail User's default email |
| 123 | + */ |
| 124 | + public void identifyUserWithEmail(String userEmail, String userName) { |
| 125 | + Instabug.identifyUser(userEmail, userName); |
| 126 | + } |
| 127 | + |
| 128 | + /** |
| 129 | + * Sets the default value of the user's email to null and show email field and remove user |
| 130 | + * name from all reports |
| 131 | + * It also reset the chats on device and removes user attributes, user data and completed |
| 132 | + * surveys. |
| 133 | + */ |
| 134 | + public void logOut() { |
| 135 | + Instabug.logoutUser(); |
| 136 | + } |
| 137 | + |
| 138 | + /** |
| 139 | + * Change Locale of Instabug UI elements(defaults to English) |
| 140 | + * |
| 141 | + * @param instabugLocale |
| 142 | + */ |
| 143 | + public void setLocale(String instabugLocale) { |
| 144 | + Instabug.changeLocale((Locale) constants.get(instabugLocale)); |
| 145 | + } |
| 146 | + |
| 147 | + |
103 | 148 | public Map<String, Object> getConstants() { |
104 | 149 | final Map<String, Object> constants = new HashMap<>(); |
105 | 150 | constants.put("InvocationEvent.none", InstabugInvocationEvent.NONE); |
106 | 151 | constants.put("InvocationEvent.screenshot", InstabugInvocationEvent.SCREENSHOT); |
107 | 152 | constants.put("InvocationEvent.twoFingersSwipeLeft", InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFT); |
108 | 153 | constants.put("InvocationEvent.floatingButton", InstabugInvocationEvent.FLOATING_BUTTON); |
109 | 154 | constants.put("InvocationEvent.shake", InstabugInvocationEvent.SHAKE); |
| 155 | + |
| 156 | + constants.put("WelcomeMessageMode.live", WelcomeMessage.State.LIVE); |
| 157 | + constants.put("WelcomeMessageMode.beta", WelcomeMessage.State.BETA); |
| 158 | + constants.put("WelcomeMessageMode.disabled", WelcomeMessage.State.DISABLED); |
| 159 | + |
| 160 | + constants.put("Locale.Arabic", |
| 161 | + new Locale(InstabugLocale.ARABIC.getCode(), InstabugLocale.ARABIC.getCountry())); |
| 162 | + constants.put("Locale.ChineseSimplified", |
| 163 | + new Locale(InstabugLocale.SIMPLIFIED_CHINESE.getCode(), InstabugLocale.SIMPLIFIED_CHINESE.getCountry())); |
| 164 | + constants.put("Locale.ChineseTraditional", |
| 165 | + new Locale(InstabugLocale.TRADITIONAL_CHINESE.getCode(), InstabugLocale.TRADITIONAL_CHINESE.getCountry())); |
| 166 | + constants.put("Locale.Czech", |
| 167 | + new Locale(InstabugLocale.CZECH.getCode(), InstabugLocale.CZECH.getCountry())); |
| 168 | + constants.put("Locale.Danish", |
| 169 | + new Locale(InstabugLocale.DANISH.getCode(), InstabugLocale.DANISH.getCountry())); |
| 170 | + constants.put("Locale.Dutch", |
| 171 | + new Locale(InstabugLocale.NETHERLANDS.getCode(), InstabugLocale.NETHERLANDS.getCountry())); |
| 172 | + constants.put("Locale.English", |
| 173 | + new Locale(InstabugLocale.ENGLISH.getCode(), InstabugLocale.ENGLISH.getCountry())); |
| 174 | + constants.put("Locale.French", |
| 175 | + new Locale(InstabugLocale.FRENCH.getCode(), InstabugLocale.FRENCH.getCountry())); |
| 176 | + constants.put("Locale.German", |
| 177 | + new Locale(InstabugLocale.GERMAN.getCode(), InstabugLocale.GERMAN.getCountry())); |
| 178 | + constants.put("Locale.Italian", |
| 179 | + new Locale(InstabugLocale.ITALIAN.getCode(), InstabugLocale.ITALIAN.getCountry())); |
| 180 | + constants.put("Locale.Japanese", |
| 181 | + new Locale(InstabugLocale.JAPANESE.getCode(), InstabugLocale.JAPANESE.getCountry())); |
| 182 | + constants.put("Locale.Korean", |
| 183 | + new Locale(InstabugLocale.KOREAN.getCode(), InstabugLocale.KOREAN.getCountry())); |
| 184 | + constants.put("Locale.Polish", |
| 185 | + new Locale(InstabugLocale.POLISH.getCode(), InstabugLocale.POLISH.getCountry())); |
| 186 | + constants.put("Locale.PortugueseBrazil", |
| 187 | + new Locale(InstabugLocale.PORTUGUESE_BRAZIL.getCode(), InstabugLocale.PORTUGUESE_BRAZIL.getCountry())); |
| 188 | + constants.put("Locale.Russian", |
| 189 | + new Locale(InstabugLocale.RUSSIAN.getCode(), InstabugLocale.RUSSIAN.getCountry())); |
| 190 | + constants.put("Locale.Spanish", |
| 191 | + new Locale(InstabugLocale.SPANISH.getCode(), InstabugLocale.SPANISH.getCountry())); |
| 192 | + constants.put("Locale.Swedish", |
| 193 | + new Locale(InstabugLocale.SWEDISH.getCode(), InstabugLocale.SWEDISH.getCountry())); |
| 194 | + constants.put("Locale.Turkish", |
| 195 | + new Locale(InstabugLocale.TURKISH.getCode(), InstabugLocale.TURKISH.getCountry())); |
| 196 | + |
110 | 197 | return constants; |
111 | 198 | } |
112 | 199 | } |
0 commit comments