List of usage examples for android.content Context getString
@NonNull public final String getString(@StringRes int resId)
From source file:com.scvngr.levelup.core.net.RequestUtilsTest.java
/** * Test {@link com.scvngr.levelup.core.net.RequestUtils#addApiKeyToRequestBody}. * * @throws org.json.JSONException from {@link org.json.JSONObject#put} *///from w w w. ja v a 2s . c o m @SmallTest public void testAddApiKeyToRequestBody() throws JSONException { final JSONObject object = new JSONObject(); final JSONObject expected = new JSONObject(); final Context context = NullUtils.nonNullContract(getContext()); expected.put(RequestUtils.PARAM_API_KEY, context.getString(R.string.levelup_api_key)); RequestUtils.addApiKeyToRequestBody(context, object); assertEquals(expected.toString(), object.toString()); }
From source file:de.ub0r.android.websms.connector.freenet.ConnectorFreenet.java
/** * {@inheritDoc}/*from w w w .j av a 2 s .c o m*/ */ @Override public final ConnectorSpec initSpec(final Context context) { final String name = context.getString(R.string.connector_freenet_name); ConnectorSpec c = new ConnectorSpec(name); c.setAuthor(context.getString(R.string.connector_freenet_author)); c.setBalance(null); c.setCapabilities(ConnectorSpec.CAPABILITIES_UPDATE | ConnectorSpec.CAPABILITIES_SEND | ConnectorSpec.CAPABILITIES_PREFS); c.addSubConnector(TAG, c.getName(), SubConnectorSpec.FEATURE_MULTIRECIPIENTS | SubConnectorSpec.FEATURE_FLASHSMS | SubConnectorSpec.FEATURE_CUSTOMSENDER); return c; }
From source file:com.ryan.ryanreader.common.General.java
public static RRError getGeneralErrorForFailure(Context context, final APIResponseHandler.APIFailureType type) { final int title, message; switch (type) { case INVALID_USER: title = R.string.error_403_title; message = R.string.error_403_message; break;/*from ww w.j a v a 2s . c o m*/ case BAD_CAPTCHA: title = R.string.error_bad_captcha_title; message = R.string.error_bad_captcha_message; break; case NOTALLOWED: title = R.string.error_403_title; message = R.string.error_403_message; break; case SUBREDDIT_REQUIRED: title = R.string.error_subreddit_required_title; message = R.string.error_subreddit_required_message; break; default: title = R.string.error_unknown_api_title; message = R.string.error_unknown_api_message; break; } return new RRError(context.getString(title), context.getString(message)); }
From source file:com.baxtern.android.websms.connector.exetel.ConnectorExetel.java
/** * {@inheritDoc}// w w w. j a v a 2 s. com */ @Override public final ConnectorSpec initSpec(final Context context) { final String name = context.getString(R.string.connector_exetel_name); final ConnectorSpec c = new ConnectorSpec(name); c.setAuthor(context.getString(R.string.connector_exetel_author)); c.setBalance(null); c.setLimitLength(MAX_MESSAGE_LENGTH); c.setCapabilities(ConnectorSpec.CAPABILITIES_UPDATE | ConnectorSpec.CAPABILITIES_SEND | ConnectorSpec.CAPABILITIES_PREFS); // The Connector supports multiple receipients and custom senders. c.addSubConnector(TAG, name, SubConnectorSpec.FEATURE_MULTIRECIPIENTS | SubConnectorSpec.FEATURE_CUSTOMSENDER); // TODO: Implement the sendlater feature. // | SubConnectorSpec.FEATURE_SENDLATER); return c; }
From source file:de.ub0r.android.websms.connector.sipgate.ConnectorSipgate.java
/** * Sets up and instance of {@link XMLRPCClient}. * /* w w w . ja v a 2 s. com*/ * @param context * {@link Context} * @return the initialized {@link XMLRPCClient} * @throws XMLRPCException * XMLRPCException */ private XMLRPCClient init(final Context context) throws XMLRPCException { Log.d(TAG, "init()"); final String version = context.getString(R.string.app_version); final String vendor = context.getString(R.string.connector_sipgate_author); XMLRPCClient client = null; final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); if (p.getBoolean(Preferences.PREFS_ENABLE_SIPGATE_TEAM, false)) { client = new XMLRPCClient(SIPGATE_TEAM_URL); } else { client = new XMLRPCClient(SIPGATE_URL); } client.setBasicAuthentication(p.getString(Preferences.PREFS_USER_SIPGATE, ""), p.getString(Preferences.PREFS_PASSWORD_SIPGATE, "")); Object back; try { Hashtable<String, String> ident = new Hashtable<String, String>(); ident.put("ClientName", TAG); ident.put("ClientVersion", version); ident.put("ClientVendor", vendor); back = client.call("samurai.ClientIdentify", ident); Log.d(TAG, back.toString()); return client; } catch (XMLRPCException e) { Log.e(TAG, "XMLRPCExceptin in init()", e); throw e; } }
From source file:com.pursuer.reader.easyrss.network.TagDataSyncer.java
private void syncTags() throws DataSyncerException { final Context context = dataMgr.getContext(); if (!NetworkUtils.checkSyncingNetworkStatus(context, networkConfig)) { return;//from w w w.ja va2 s. c om } notifyProgressChanged(context.getString(R.string.TxtSyncingTags), -1, -1); final InputStream stream = httpGetQueryStream(new TagListURL(isHttpsConnection)); final TagJSONParser parser = new TagJSONParser(stream); final long curTime = System.currentTimeMillis(); try { final TagListener listener = new TagListener(); parser.parse(listener); dataMgr.addTags(listener.getTags()); final int tAll = listener.getTags().size(); final int tAllRange = tAll / 10 * 10; GoogleAnalyticsMgr.getInstance().trackEvent(GoogleAnalyticsMgr.CATEGORY_SYNCING, GoogleAnalyticsMgr.ACTION_SYNCING_TAGS, tAllRange + "-" + (tAllRange + 9), tAll); } catch (final JsonParseException exception) { throw new DataSyncerException(exception); } catch (final IllegalStateException exception) { throw new DataSyncerException(exception); } catch (final IOException exception) { throw new DataSyncerException(exception); } finally { try { stream.close(); } catch (final IOException exception) { exception.printStackTrace(); } } dataMgr.removeOutdatedTags(curTime); }
From source file:de.ub0r.android.websms.connector.sms77.ConnectorSms77.java
/** * {@inheritDoc}/*from w ww . j a va 2s. c om*/ */ @Override public final ConnectorSpec initSpec(final Context context) { final String name = context.getString(R.string.connector_sms77_name); ConnectorSpec c = new ConnectorSpec(name); c.setAuthor(context.getString(R.string.connector_sms77_author)); c.setBalance(null); c.setSMSLengthCalculator(new BasicSMSLengthCalculator(new int[] { 160, 153 })); // FIXME: c.setLimitLength(MAX_CUSTOM_SENDER_LENGTH); c.setCapabilities(ConnectorSpec.CAPABILITIES_UPDATE | ConnectorSpec.CAPABILITIES_SEND | ConnectorSpec.CAPABILITIES_PREFS); SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); if (!p.getBoolean(PREFS_HIDE_WO_SENDER, false)) { c.addSubConnector(ID_WO_SENDER, context.getString(R.string.wo_sender), SubConnectorSpec.FEATURE_SENDLATER); } if (!p.getBoolean(PREFS_HIDE_QUALITY, false)) { c.addSubConnector(ID_QUALITY, context.getString(R.string.quality), SubConnectorSpec.FEATURE_CUSTOMSENDER | SubConnectorSpec.FEATURE_SENDLATER | SubConnectorSpec.FEATURE_FLASHSMS); } return c; }
From source file:de.ub0r.android.websms.connector.gmx.ConnectorGMX.java
/** * {@inheritDoc}//from ww w.j ava2 s. c om */ @Override public ConnectorSpec initSpec(final Context context) { final String name = context.getString(R.string.connector_gmx_name); ConnectorSpec c = new ConnectorSpec(name); c.setAuthor(context.getString(R.string.connector_gmx_author)); c.setAdUnitId(AD_UNITID); c.setSMSLengthCalculator(// . new CharacterTableSMSLengthCalculator(REPLACE)); c.setBalance(null); c.setCapabilities(ConnectorSpec.CAPABILITIES_UPDATE | ConnectorSpec.CAPABILITIES_SEND | ConnectorSpec.CAPABILITIES_PREFS); c.addSubConnector(TAG, c.getName(), SubConnectorSpec.FEATURE_SENDLATER); // SubConnectorSpec.FEATURE_MULTIRECIPIENTS); return c; }
From source file:com.zegoggles.smssync.auth.XOAuthConsumer.java
private String requestTokenEndpointUrl(Context context) { return String.format(REQUEST_TOKEN_URL, urlEncode(DEFAULT_SCOPE), urlEncode(context.getString(R.string.app_name))); }