List of usage examples for android.util Base64 URL_SAFE
int URL_SAFE
To view the source code for android.util Base64 URL_SAFE.
Click Source Link
From source file:keyboard.ecloga.com.eclogakeyboard.EclogaKeyboard.java
@Override public void onStartInputView(EditorInfo info, boolean restarting) { initializeKeyboard();//from w w w. j a v a2s.c om onRotate(); if (mVoiceRecognitionTrigger != null) { mVoiceRecognitionTrigger.onStartInputView(); } vbListenerPause = false; if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("random")) { Random rand = new Random(); int randInt = rand.nextInt(25); switch (randInt) { case 1: kv.setBackgroundColor(getResources().getColor(R.color.white)); break; case 2: kv.setBackgroundColor(getResources().getColor(R.color.black)); break; case 3: kv.setBackgroundColor(getResources().getColor(R.color.purple)); break; case 4: kv.setBackgroundColor(getResources().getColor(R.color.red)); break; case 5: kv.setBackgroundColor(getResources().getColor(R.color.pink)); break; case 6: kv.setBackgroundColor(getResources().getColor(R.color.blue)); break; case 7: kv.setBackgroundColor(getResources().getColor(R.color.green)); break; case 8: kv.setBackgroundColor(getResources().getColor(R.color.yellow)); break; case 9: kv.setBackgroundColor(getResources().getColor(R.color.orange)); break; case 10: kv.setBackgroundColor(getResources().getColor(R.color.grey)); break; case 11: kv.setBackgroundColor(getResources().getColor(R.color.lightpurple)); break; case 12: kv.setBackgroundColor(getResources().getColor(R.color.lightred)); break; case 13: kv.setBackgroundColor(getResources().getColor(R.color.lightpink)); break; case 14: kv.setBackgroundColor(getResources().getColor(R.color.lightblue)); break; case 15: kv.setBackgroundColor(getResources().getColor(R.color.lightgreen)); break; case 16: kv.setBackgroundColor(getResources().getColor(R.color.lightyellow)); break; case 17: kv.setBackgroundColor(getResources().getColor(R.color.lightgrey)); break; case 18: kv.setBackgroundColor(getResources().getColor(R.color.lightorange)); break; case 19: kv.setBackgroundColor(getResources().getColor(R.color.darkpurple)); break; case 20: kv.setBackgroundColor(getResources().getColor(R.color.darkorange)); break; case 21: kv.setBackgroundColor(getResources().getColor(R.color.darkblue)); break; case 22: kv.setBackgroundColor(getResources().getColor(R.color.darkgreen)); break; case 23: kv.setBackgroundColor(getResources().getColor(R.color.darkred)); break; case 24: kv.setBackgroundColor(getResources().getColor(R.color.darkyellow)); break; case 25: kv.setBackgroundColor(getResources().getColor(R.color.darkpink)); break; } } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_1")) { kv.setBackgroundResource(R.drawable.pattern_1); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_2")) { kv.setBackgroundResource(R.drawable.pattern_2); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_3")) { kv.setBackgroundResource(R.drawable.pattern_3); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_4")) { kv.setBackgroundResource(R.drawable.pattern_4); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_5")) { kv.setBackgroundResource(R.drawable.pattern_5); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_6")) { kv.setBackgroundResource(R.drawable.pattern_6); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_7")) { kv.setBackgroundResource(R.drawable.pattern_7); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_8")) { kv.setBackgroundResource(R.drawable.pattern_8); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_9")) { kv.setBackgroundResource(R.drawable.pattern_9); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_10")) { kv.setBackgroundResource(R.drawable.pattern_10); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_11")) { kv.setBackgroundResource(R.drawable.pattern_11); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_12")) { kv.setBackgroundResource(R.drawable.pattern_12); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_13")) { kv.setBackgroundResource(R.drawable.pattern_13); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_14")) { kv.setBackgroundResource(R.drawable.pattern_14); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_15")) { kv.setBackgroundResource(R.drawable.pattern_15); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_16")) { kv.setBackgroundResource(R.drawable.pattern_16); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_17")) { kv.setBackgroundResource(R.drawable.pattern_17); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_1")) { kv.setBackgroundResource(R.drawable.nature_1); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_2")) { kv.setBackgroundResource(R.drawable.nature_2); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_3")) { kv.setBackgroundResource(R.drawable.nature_3); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_4")) { kv.setBackgroundResource(R.drawable.nature_4); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_5")) { kv.setBackgroundResource(R.drawable.nature_5); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_6")) { kv.setBackgroundResource(R.drawable.nature_6); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_7")) { kv.setBackgroundResource(R.drawable.nature_7); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_8")) { kv.setBackgroundResource(R.drawable.nature_8); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_9")) { kv.setBackgroundResource(R.drawable.nature_9); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_10")) { kv.setBackgroundResource(R.drawable.nature_10); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_11")) { kv.setBackgroundResource(R.drawable.nature_11); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_12")) { kv.setBackgroundResource(R.drawable.nature_12); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_13")) { kv.setBackgroundResource(R.drawable.nature_13); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_14")) { kv.setBackgroundResource(R.drawable.nature_14); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("black")) { kv.setBackgroundColor(getResources().getColor(R.color.black)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("white")) { kv.setBackgroundColor(getResources().getColor(R.color.white)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("transparent")) { kv.setBackgroundColor(getResources().getColor(R.color.transparent)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_1")) { kv.setBackgroundResource(R.drawable.gradient_1); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_2")) { kv.setBackgroundResource(R.drawable.gradient_2); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_3")) { kv.setBackgroundResource(R.drawable.gradient_3); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_4")) { kv.setBackgroundResource(R.drawable.gradient_4); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_5")) { kv.setBackgroundResource(R.drawable.gradient_5); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_6")) { kv.setBackgroundResource(R.drawable.gradient_6); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_7")) { kv.setBackgroundResource(R.drawable.gradient_7); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_8")) { kv.setBackgroundResource(R.drawable.gradient_8); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_9")) { kv.setBackgroundResource(R.drawable.gradient_9); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_10")) { kv.setBackgroundResource(R.drawable.gradient_10); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("red")) { kv.setBackgroundColor(getResources().getColor(R.color.red)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pink")) { kv.setBackgroundColor(getResources().getColor(R.color.pink)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("purple")) { kv.setBackgroundColor(getResources().getColor(R.color.purple)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("blue")) { kv.setBackgroundColor(getResources().getColor(R.color.blue)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("green")) { kv.setBackgroundColor(getResources().getColor(R.color.green)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("yellow")) { kv.setBackgroundColor(getResources().getColor(R.color.yellow)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("orange")) { kv.setBackgroundColor(getResources().getColor(R.color.orange)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("grey")) { kv.setBackgroundColor(getResources().getColor(R.color.grey)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightred")) { kv.setBackgroundColor(getResources().getColor(R.color.lightred)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightpink")) { kv.setBackgroundColor(getResources().getColor(R.color.lightpink)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightpurple")) { kv.setBackgroundColor(getResources().getColor(R.color.lightpurple)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightblue")) { kv.setBackgroundColor(getResources().getColor(R.color.lightblue)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightgreen")) { kv.setBackgroundColor(getResources().getColor(R.color.lightgreen)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightyellow")) { kv.setBackgroundColor(getResources().getColor(R.color.lightyellow)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightorange")) { kv.setBackgroundColor(getResources().getColor(R.color.lightorange)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightgrey")) { kv.setBackgroundColor(getResources().getColor(R.color.lightgrey)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkred")) { kv.setBackgroundColor(getResources().getColor(R.color.darkred)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkpink")) { kv.setBackgroundColor(getResources().getColor(R.color.darkpink)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkpurple")) { kv.setBackgroundColor(getResources().getColor(R.color.darkpurple)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkblue")) { kv.setBackgroundColor(getResources().getColor(R.color.darkblue)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkgreen")) { kv.setBackgroundColor(getResources().getColor(R.color.darkgreen)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkyellow")) { kv.setBackgroundColor(getResources().getColor(R.color.darkyellow)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkorange")) { kv.setBackgroundColor(getResources().getColor(R.color.darkorange)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkgrey")) { kv.setBackgroundColor(getResources().getColor(R.color.darkgrey)); } else { String uploadString = Preferences.getDefaults("bgcolor", getApplicationContext()); byte[] decodedString = Base64.decode(uploadString, Base64.URL_SAFE); Bitmap photo = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length); BitmapDrawable bdrawable = new BitmapDrawable(getApplication().getResources(), photo); kv.setBackgroundDrawable(bdrawable); } if (Preferences.getDefaults("autocapitalize", getApplicationContext()).equals("true")) { autoCapitalize = true; } else if (Preferences.getDefaults("autocapitalize", getApplicationContext()).equals("false")) { autoCapitalize = false; } if (Preferences.getDefaults("volumebuttons", getApplicationContext()).equals("true")) { volumeButtons = true; } else if (Preferences.getDefaults("volumebuttons", getApplicationContext()).equals("false")) { volumeButtons = false; } if (Preferences.getDefaults("allcaps", getApplicationContext()).equals("true")) { allCaps = true; } else if (Preferences.getDefaults("allcaps", getApplicationContext()).equals("false")) { allCaps = false; } if (Preferences.getDefaults("autospacing", getApplicationContext()).equals("true")) { autoSpacing = true; } else if (Preferences.getDefaults("autospacing", getApplicationContext()).equals("false")) { autoSpacing = false; } if (Preferences.getDefaults("changekeyboard", getApplicationContext()).equals("true")) { changeKeyboard = true; } else if (Preferences.getDefaults("changekeyboard", getApplicationContext()).equals("false")) { changeKeyboard = false; } if (Preferences.getDefaults("shakedelete", getApplicationContext()).equals("true")) { shakeDelete = true; } else if (Preferences.getDefaults("shakedelete", getApplicationContext()).equals("false")) { shakeDelete = false; } if (Preferences.getDefaults("doublespace", getApplicationContext()).equals("true")) { spaceDot = true; } else if (Preferences.getDefaults("doublespace", getApplicationContext()).equals("false")) { spaceDot = false; } if (Preferences.getDefaults("voiceinput", getApplicationContext()).equals("true")) { voiceInput = true; } else if (Preferences.getDefaults("voiceinout", getApplicationContext()).equals("false")) { voiceInput = false; } if (Preferences.getDefaults("popup", getApplicationContext()).equals("true")) { popupKeypress = true; } else if (Preferences.getDefaults("popup", getApplicationContext()).equals("false")) { popupKeypress = false; } if (Preferences.getDefaults("oppositecase", getApplicationContext()).equals("true")) { oppositeCase = true; } else if (Preferences.getDefaults("oppositecase", getApplicationContext()).equals("false")) { oppositeCase = false; } if (changeKeyboard) { MovementDetector.getInstance(getApplicationContext()).start(); MovementDetector.getInstance(getApplicationContext()).addListener(new MovementDetector.Listener() { @Override public void onMotionDetected(SensorEvent event, float acceleration) { if (MovementDetector.direction[1].equals("LEFT")) { playSwipeH(); onSwipeLeft(); } else if (MovementDetector.direction[1].equals("RIGHT")) { playSwipeH(); onSwipeRight(); } if (MovementDetector.direction[0].equals("UP")) { playSwipeV(); onSwipeUp(); } else if (MovementDetector.direction[0].equals("DOWN")) { playSwipeV(); onSwipeDown(); } } }); } keypresscounter1 = Preferences.getDefaults("keypresscounter1", getApplicationContext()); keypresscounter2 = Preferences.getDefaults("keypresscounter2", getApplicationContext()); keypresscounter3 = Preferences.getDefaults("keypresscounter3", getApplicationContext()); keyPressCounter = Integer.parseInt(Preferences.getDefaults("keypresses", getApplicationContext())); time1 = Preferences.getDefaults("time1", getApplicationContext()); time2 = Preferences.getDefaults("time2", getApplicationContext()); time3 = Preferences.getDefaults("time3", getApplicationContext()); time = Integer.parseInt(Preferences.getDefaults("time", getApplicationContext())); tTime = new CountDownTimer(60000, 1000) { @Override public void onTick(long millisUntilFinished) { time = time + 1; if (time > 300 && time <= 960 && time1.equals("false")) { NotificationManager notif = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Notification notify = new Notification(R.drawable.notify, "Ecloga Keyboard", System.currentTimeMillis()); PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(getApplicationContext(), Home.class), 0); notify.setLatestEventInfo(getApplicationContext(), "Warming up!", "Type more than 360 seconds", pending); notif.notify(0, notify); Preferences.setDefaults("time1", "true", getApplicationContext()); } else if (time > 960 && time <= 3600 && time2.equals("false")) { NotificationManager notif = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Notification notify = new Notification(R.drawable.notify, "Ecloga Keyboard", System.currentTimeMillis()); PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(getApplicationContext(), Home.class), 0); notify.setLatestEventInfo(getApplicationContext(), "Keep it up!", "Type more than 960 seconds", pending); notif.notify(0, notify); Preferences.setDefaults("time2", "true", getApplicationContext()); } else if (time > 3600 && time3.equals("false")) { NotificationManager notif = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Notification notify = new Notification(R.drawable.notify, "Ecloga Keyboard", System.currentTimeMillis()); PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(getApplicationContext(), Home.class), 0); notify.setLatestEventInfo(getApplicationContext(), "Typing master!", "Type more than 3600 seconds", pending); notif.notify(0, notify); Preferences.setDefaults("time3", "true", getApplicationContext()); } Preferences.setDefaults("time", String.valueOf(time), getApplicationContext()); } @Override public void onFinish() { tTime.start(); } }.start(); if (popupKeypress) { kv.setPreviewEnabled(true); } else { kv.setPreviewEnabled(false); } if (shakeDelete) { mShaker = new ShakeListener(this); mShaker.setOnShakeListener(new ShakeListener.OnShakeListener() { public void onShake() { InputConnection ic = getCurrentInputConnection(); ic.deleteSurroundingText(500, 500); } }); } super.onStartInputView(info, restarting); }
From source file:com.facebook.Settings.java
public static String getApplicationSignature(Context context) { if (context == null) { return null; }//from www .j av a2 s . co m PackageManager packageManager = context.getPackageManager(); if (packageManager == null) { return null; } String packageName = context.getPackageName(); PackageInfo pInfo; try { pInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES); } catch (PackageManager.NameNotFoundException e) { return null; } Signature[] signatures = pInfo.signatures; if (signatures == null || signatures.length == 0) { return null; } MessageDigest md; try { md = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { return null; } md.update(pInfo.signatures[0].toByteArray()); return Base64.encodeToString(md.digest(), Base64.URL_SAFE | Base64.NO_PADDING); }
From source file:com.microsoft.aad.adal.Oauth2.java
public String encodeProtocolState() { String state = String.format("a=%s&r=%s", mRequest.getAuthority(), mRequest.getResource()); return Base64.encodeToString(state.getBytes(), Base64.NO_PADDING | Base64.URL_SAFE); }
From source file:com.facebook.FacebookSdk.java
/** * Internal call please don't use directly. * @param context The application context. * @return The application signature./* ww w. j av a 2s . c o m*/ */ public static String getApplicationSignature(Context context) { Validate.sdkInitialized(); if (context == null) { return null; } PackageManager packageManager = context.getPackageManager(); if (packageManager == null) { return null; } String packageName = context.getPackageName(); PackageInfo pInfo; try { pInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES); } catch (PackageManager.NameNotFoundException e) { return null; } Signature[] signatures = pInfo.signatures; if (signatures == null || signatures.length == 0) { return null; } MessageDigest md; try { md = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { return null; } md.update(pInfo.signatures[0].toByteArray()); return Base64.encodeToString(md.digest(), Base64.URL_SAFE | Base64.NO_PADDING); }
From source file:net.openid.appauth.AuthorizationRequest.java
private static String generateRandomState() { SecureRandom sr = new SecureRandom(); byte[] random = new byte[STATE_LENGTH]; sr.nextBytes(random);//from w ww. j a v a2 s .co m return Base64.encodeToString(random, Base64.NO_WRAP | Base64.NO_PADDING | Base64.URL_SAFE); }
From source file:org.deviceconnect.android.localoauth.LocalOAuth2Main.java
/** * ??????.//w ww. j a v a 2 s .c o m * * @param client * @param authCode ??(TokenManager.sessions???) * @param applicationName ?? * @return not null: / null: ? */ private String callAccessTokenServerResource(final Client client, final String authCode, final String applicationName) { Request request = new Request(); ClientInfo clientInfo = new ClientInfo(); org.restlet.security.User user = new org.restlet.security.User(client.getClientId()); clientInfo.setUser(user); request.setClientInfo(clientInfo); Response response = new Response(request); AccessTokenServerResource.init(request, response); // (???base64?) String base64ApplicationName = Base64.encodeToString(applicationName.getBytes(), Base64.URL_SAFE | Base64.NO_WRAP); StringRepresentation input = new StringRepresentation("grant_type=authorization_code&code=" + authCode + "&" + AccessTokenServerResource.REDIR_URI + "=" + DUMMY_REDIRECT_URI + "&" + AccessTokenServerResource.APPLICATION_NAME + "=" + base64ApplicationName); try { ResultRepresentation resultRepresentation = (ResultRepresentation) AccessTokenServerResource .requestToken(input); if (resultRepresentation.getResult()) { return resultRepresentation.getText(); } } catch (JSONException | OAuthException e) { e.printStackTrace(); } return null; }