/** * Internal Method to create new File in internal memory for each provider and save accessGrant * * @param auth AuthProvider */ private void writeToken(AuthProvider auth) { AccessGrant accessGrant = auth.getAccessGrant(); String key = accessGrant.getKey(); String secret = accessGrant.getSecret(); String providerid = accessGrant.getProviderId(); Map<String, Object> attributes = accessGrant.getAttributes(); Editor edit = PreferenceManager.getDefaultSharedPreferences(getContext()).edit(); edit.putString(mProviderName.toString() + " key", key); edit.putString(mProviderName.toString() + " secret", secret); edit.putString(mProviderName.toString() + " providerid", providerid); if (attributes != null) { for (Map.Entry entry : attributes.entrySet()) { System.out.println(entry.getKey() + ", " + entry.getValue()); } for (String s : attributes.keySet()) { edit.putString( mProviderName.toString() + "attribute " + s, String.valueOf(attributes.get(s))); } } edit.commit(); }
/** Sets title and icon of provider */ private void setUpTitle() { requestWindowFeature(Window.FEATURE_NO_TITLE); mTitle = new TextView(getContext()); int res = getContext() .getResources() .getIdentifier(mProviderName.toString(), "drawable", getContext().getPackageName()); icon = getContext().getResources().getDrawable(res); StringBuilder sb = new StringBuilder(); sb.append(mProviderName.toString().substring(0, 1).toUpperCase()); sb.append(mProviderName.toString().substring(1, mProviderName.toString().length())); mTitle.setText(sb.toString()); mTitle.setGravity(Gravity.CENTER_VERTICAL); mTitle.setTextColor(Color.WHITE); mTitle.setTypeface(Typeface.DEFAULT_BOLD); mTitle.setBackgroundColor(BLUE); mTitle.setPadding(MARGIN + PADDING, MARGIN, MARGIN, MARGIN); mTitle.setCompoundDrawablePadding(MARGIN + PADDING); mTitle.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); if (!titleStatus) mContent.addView(mTitle); }
/** * Internal Method to create new Create accessGrant * * @param params */ private AccessGrant createAccessGrant(Map<String, String> params) { AccessGrant accessGrant = new AccessGrant(); if (params.get("access_token") != null) { String accessToken = params.get("access_token"); Integer expires = null; if (params.get("expires") != null) { expires = new Integer(params.get("expires")); } accessGrant.setKey(accessToken); accessGrant.setAttribute("expires", expires); } accessGrant.setProviderId(mProviderName.toString()); return accessGrant; }