Java Code Examples for com.getcapacitor.JSObject#getString()
The following examples show how to use
com.getcapacitor.JSObject#getString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhoneProviderHandler.java From capacitor-firebase-auth with MIT License | 6 votes |
@Override public void signIn(PluginCall call) { if (!call.getData().has("data")) { call.reject("The auth data is required"); return; } JSObject data = call.getObject("data", new JSObject()); String phone = data.getString("phone", ""); if (phone.equalsIgnoreCase("null") || phone.equalsIgnoreCase("")) { call.reject("The phone number is required"); return; } String code = data.getString("verificationCode", ""); if(code.equalsIgnoreCase("null") || code.equalsIgnoreCase("")) { PhoneAuthProvider.getInstance().verifyPhoneNumber (phone, 60, TimeUnit.SECONDS, this.plugin.getActivity(), this.mCallbacks); } else { AuthCredential credential = PhoneAuthProvider.getCredential(this.mVerificationId, code); this.mVerificationCode = code; plugin.handleAuthCredentials(credential); } }
Example 2
Source File: PushNotifications.java From OsmGo with MIT License | 5 votes |
private void createChannel(JSObject channel) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { NotificationChannel notificationChannelChannel = new NotificationChannel(channel.getString(CHANNEL_ID), channel.getString(CHANNEL_NAME), channel.getInteger(CHANNEL_IMPORTANCE)); notificationChannelChannel.setDescription(channel.getString(CHANNEL_DESCRIPTION, "")); notificationChannelChannel.setLockscreenVisibility(channel.getInteger(CHANNEL_VISIBILITY, 0)); notificationManager.createNotificationChannel(notificationChannelChannel); } }
Example 3
Source File: LocalNotificationSchedule.java From OsmGo with MIT License | 5 votes |
private void buildAtElement(JSObject schedule) throws ParseException { this.repeats = schedule.getBool("repeats"); String dateString = schedule.getString("at"); if (dateString != null) { SimpleDateFormat sdf = new SimpleDateFormat(JS_DATE_FORMAT); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); this.at = sdf.parse(dateString); } }
Example 4
Source File: NotificationAction.java From OsmGo with MIT License | 5 votes |
public static Map<String, NotificationAction[]> buildTypes(JSArray types) { Map<String, NotificationAction[]> actionTypeMap = new HashMap<>(); try { List<JSONObject> objects = types.toList(); for (JSONObject obj : objects) { JSObject jsObject = JSObject.fromJSONObject(obj); String actionGroupId = jsObject.getString("id"); if (actionGroupId == null) { return null; } JSONArray actions = jsObject.getJSONArray("actions"); if (actions != null) { NotificationAction[] typesArray = new NotificationAction[actions.length()]; for (int i = 0; i < typesArray.length; i++) { NotificationAction notificationAction = new NotificationAction(); JSObject action = JSObject.fromJSONObject(actions.getJSONObject(i)); notificationAction.setId(action.getString("id")); notificationAction.setTitle(action.getString("title")); notificationAction.setInput(action.getBool("input")); typesArray[i] = notificationAction; } actionTypeMap.put(actionGroupId, typesArray); } } } catch (Exception e) { Log.e(LogUtils.getPluginTag("LN"), "Error when building action types", e); } return actionTypeMap; }
Example 5
Source File: LocalNotificationSchedule.java From OsmGo with MIT License | 4 votes |
private void buildEveryElement(JSObject schedule) { // 'year'|'month'|'two-weeks'|'week'|'day'|'hour'|'minute'|'second'; this.every = schedule.getString("every"); }
Example 6
Source File: ModalsBottomSheetDialogFragment.java From OsmGo with MIT License | 4 votes |
@Override @SuppressLint("RestrictedApi") public void setupDialog(Dialog dialog, int style) { super.setupDialog(dialog, style); if (options == null) { return; } Window w = dialog.getWindow(); final float scale = getResources().getDisplayMetrics().density; float layoutPaddingDp16 = 16.0f; float layoutPaddingDp12 = 12.0f; float layoutPaddingDp8 = 8.0f; int layoutPaddingPx16 = (int) (layoutPaddingDp16 * scale + 0.5f); int layoutPaddingPx12 = (int) (layoutPaddingDp12 * scale + 0.5f); int layoutPaddingPx8 = (int) (layoutPaddingDp8 * scale + 0.5f); CoordinatorLayout parentLayout = new CoordinatorLayout(getContext()); LinearLayout layout = new LinearLayout(getContext()); layout.setOrientation(LinearLayout.VERTICAL); layout.setPadding(layoutPaddingPx16, layoutPaddingPx16, layoutPaddingPx16, layoutPaddingPx16); try { List<Object> optionsList = options.toList(); for (int i = 0; i < optionsList.size(); i++) { final int optionIndex = i; JSObject o = JSObject.fromJSONObject((JSONObject) optionsList.get(i)); String styleOption = o.getString("style", "DEFAULT"); String titleOption = o.getString("title", ""); TextView tv = new TextView(getContext()); tv.setTextColor(Color.parseColor("#000000")); tv.setPadding(layoutPaddingPx12, layoutPaddingPx12, layoutPaddingPx12, layoutPaddingPx12); //tv.setBackgroundColor(Color.parseColor("#80000000")); tv.setText(titleOption); tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d(LogUtils.getCoreTag(), "CliCKED: " + optionIndex); if (listener != null) { listener.onSelected(optionIndex); } } }); layout.addView(tv); } parentLayout.addView(layout.getRootView()); dialog.setContentView(parentLayout.getRootView()); //dialog.getWindow().getDecorView().setBackgroundColor(Color.parseColor("#000000")); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) parentLayout.getParent()).getLayoutParams(); CoordinatorLayout.Behavior behavior = params.getBehavior(); if (behavior != null && behavior instanceof BottomSheetBehavior) { ((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback); } } catch (JSONException ex) { Log.e(LogUtils.getCoreTag(), "JSON error processing an option for showActions", ex); } }