List of usage examples for android.content Context getString
@NonNull public final String getString(@StringRes int resId)
From source file:com.kakao.kakaolink.KakaoLink.java
/** * ? ?? ./*from w w w . j av a 2s. com*/ * @param builder KakaoTalkLinkMessageBuilder * @param context ? context * @throws KakaoParameterException ? ? ? ? */ public void sendMessage(final KakaoTalkLinkMessageBuilder builder, final Context context) throws KakaoParameterException { final Intent intent = TalkProtocol.createKakakoTalkLinkIntent(context, builder.build()); if (intent == null) { //alert install dialog new AlertDialog.Builder(context).setIcon(android.R.drawable.ic_dialog_alert) .setMessage(context.getString(R.string.com_kakao_alert_install_kakaotalk)) .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent marketIntent; try { marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(KakaoTalkLinkProtocol.TALK_MARKET_URL_PREFIX + makeReferrer())); marketIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(marketIntent); } catch (ActivityNotFoundException e) { marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(KakaoTalkLinkProtocol.TALK_MARKET_URL_PREFIX_2 + makeReferrer())); marketIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(marketIntent); } } }).create().show(); } else { context.startActivity(intent); } }
From source file:com.rothconsulting.android.websms.connector.schoolnet.ConnectorSchoolnet.java
/** * {@inheritDoc}//from ww w .ja va 2 s . c om */ @Override public final ConnectorSpec initSpec(final Context context) { final String name = context.getString(R.string.connector_schoolnet_name); ConnectorSpec c = new ConnectorSpec(name); c.setAuthor(context.getString(R.string.connector_schoolnet_author)); c.setBalance(null); c.setAdUnitId(AD_UNITID); c.setCapabilities(ConnectorSpec.CAPABILITIES_BOOTSTRAP | ConnectorSpec.CAPABILITIES_UPDATE | ConnectorSpec.CAPABILITIES_SEND | ConnectorSpec.CAPABILITIES_PREFS); c.addSubConnector("schoolnet", c.getName(), SubConnectorSpec.FEATURE_MULTIRECIPIENTS); return c; }
From source file:com.nextgis.maplibui.formcontrol.DateTime.java
protected View.OnClickListener getDateUpdateWatcher(final int pickerType) { return new View.OnClickListener() { protected void setValue() { DateTime.this.setText(mDateFormat.format(mCalendar.getTime())); }//from w w w . j a v a 2 s . c om @Override public void onClick(View view) { Context context = DateTime.this.getContext(); String title = null; Type type = Type.ALL; switch (pickerType) { case GeoConstants.FTDate: title = context.getString(R.string.field_type_date); type = Type.YEAR_MONTH_DAY; break; case GeoConstants.FTTime: title = context.getString(R.string.field_type_time); type = Type.HOURS_MINS; break; case GeoConstants.FTDateTime: title = context.getString(R.string.field_type_datetime); type = Type.ALL; break; } OnDateSetListener onDateSetListener = new OnDateSetListener() { @Override public void onDateSet(TimePickerDialog timePickerView, long milliseconds) { mCalendar.setTimeInMillis(milliseconds); setValue(); } }; mTimeDialog = new TimePickerDialog.Builder().setCallBack(onDateSetListener).setTitleStringId(title) .setSureStringId(context.getString(android.R.string.ok)) .setCancelStringId(context.getString(android.R.string.cancel)) .setYearText(" " + context.getString(R.string.unit_year)) .setMonthText(" " + context.getString(R.string.unit_month)) .setDayText(" " + context.getString(R.string.unit_day)) .setHourText(" " + context.getString(R.string.unit_hour)) .setMinuteText(" " + context.getString(R.string.unit_min)).setType(type).setCyclic(false) .setMinMillseconds(1).setMaxMillseconds(Long.MAX_VALUE) .setCurrentMillseconds(mCalendar.getTimeInMillis()).setWheelItemTextSize(12) .setWheelItemTextNormalColor( ContextCompat.getColor(getContext(), R.color.timetimepicker_default_text_color)) .setWheelItemTextSelectorColor(ContextCompat.getColor(getContext(), R.color.accent)) .setThemeColor(ContextCompat.getColor(getContext(), R.color.primary_dark)).build(); AppCompatActivity activity = ControlHelper.getActivity(getContext()); if (activity != null) mTimeDialog.show(activity.getSupportFragmentManager(), "TimePickerDialog"); } }; }
From source file:org.herrlado.websms.connector.magtifunge.ConnectorMagtifun.java
/** * {@inheritDoc}/* w w w . java 2 s . co m*/ */ @Override public final ConnectorSpec initSpec(final Context context) { final String name = context.getString(R.string.con_name); final ConnectorSpec c = new ConnectorSpec(name); c.setAuthor(// . context.getString(R.string.con_author)); c.setBalance(null); // c.(context.getString(R.string.preferences)); c.setCapabilities(ConnectorSpec.CAPABILITIES_UPDATE | ConnectorSpec.CAPABILITIES_SEND | ConnectorSpec.CAPABILITIES_PREFS); c.addSubConnector(c.getName(), c.getName(), SubConnectorSpec.FEATURE_MULTIRECIPIENTS); return c; }
From source file:fr.shywim.antoinedaniel.utils.Utils.java
/** * Send a score only if it beats the user's best. * * @param context Any context.//from w w w. j ava 2 s .co m * @param resid Leaderboard's id. * @param score Player's score. */ public void sendScore(Context context, int resid, long score) { AppState appState = AppState.getInstance(); String id = context.getString(resid); if (apiClient != null && this.apiClient.isConnected() && (!AppState.getInstance().bestScores.containsKey(id) || (Long.parseLong(AppState.getInstance().bestScores.get(id)) < score))) { appState.bestScores.put(id, Long.toString(score)); appState.changed = true; Games.Leaderboards.submitScore(apiClient, id, score); } }
From source file:com.liato.bankdroid.banking.banks.Hors.java
public Hors(Context context) { super(context); super.TAG = TAG; super.NAME = NAME; super.NAME_SHORT = NAME_SHORT; super.BANKTYPE_ID = BANKTYPE_ID; super.URL = URL; super.DISPLAY_DECIMALS = DISPLAY_DECIMALS; super.INPUT_TYPE_USERNAME = InputType.TYPE_CLASS_TEXT | +InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; super.INPUT_HINT_USERNAME = context.getString(R.string.card_id); super.INPUT_HIDDEN_PASSWORD = true; }
From source file:android.support.v7.app.MediaRouteExpandCollapseButton.java
public MediaRouteExpandCollapseButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mExpandAnimationDrawable = (AnimationDrawable) ContextCompat.getDrawable(context, R.drawable.ic_expand); mCollapseAnimationDrawable = (AnimationDrawable) ContextCompat.getDrawable(context, R.drawable.ic_collapse); ColorFilter filter = new PorterDuffColorFilter( MediaRouterThemeHelper.getControllerColor(context, defStyleAttr), PorterDuff.Mode.SRC_IN); mExpandAnimationDrawable.setColorFilter(filter); mCollapseAnimationDrawable.setColorFilter(filter); mExpandGroupDescription = context.getString(R.string.mr_controller_expand_group); mCollapseGroupDescription = context.getString(R.string.mr_controller_collapse_group); setImageDrawable(mExpandAnimationDrawable.getFrame(0)); setContentDescription(mExpandGroupDescription); super.setOnClickListener(new OnClickListener() { @Override/* w w w . ja va 2 s. c om*/ public void onClick(View view) { mIsGroupExpanded = !mIsGroupExpanded; if (mIsGroupExpanded) { setImageDrawable(mExpandAnimationDrawable); mExpandAnimationDrawable.start(); setContentDescription(mCollapseGroupDescription); } else { setImageDrawable(mCollapseAnimationDrawable); mCollapseAnimationDrawable.start(); setContentDescription(mExpandGroupDescription); } if (mListener != null) { mListener.onClick(view); } } }); }
From source file:android_network.hetnet.vpn_service.Receiver.java
public static void notifyNewApplication(int uid, Context context) { if (uid < 0) return;//from w ww . j a v a2 s . c om SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); try { // Get application info String name = TextUtils.join(", ", Util.getApplicationNames(uid, context)); // Get application info PackageManager pm = context.getPackageManager(); String[] packages = pm.getPackagesForUid(uid); if (packages == null || packages.length < 1) throw new PackageManager.NameNotFoundException(Integer.toString(uid)); boolean internet = Util.hasInternet(uid, context); // Build notification Intent main = new Intent(context, MainActivity.class); main.putExtra(MainActivity.EXTRA_REFRESH, true); main.putExtra(MainActivity.EXTRA_SEARCH, Integer.toString(uid)); PendingIntent pi = PendingIntent.getActivity(context, uid, main, PendingIntent.FLAG_UPDATE_CURRENT); Util.setTheme(context); TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_security_white_24dp).setContentIntent(pi).setColor(tv.data) .setAutoCancel(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) builder.setContentTitle(name).setContentText(context.getString(R.string.msg_installed_n)); else builder.setContentTitle(context.getString(R.string.app_name)) .setContentText(context.getString(R.string.msg_installed, name)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setCategory(Notification.CATEGORY_STATUS).setVisibility(Notification.VISIBILITY_SECRET); } // Get defaults SharedPreferences prefs_wifi = context.getSharedPreferences("wifi", Context.MODE_PRIVATE); SharedPreferences prefs_other = context.getSharedPreferences("other", Context.MODE_PRIVATE); boolean wifi = prefs_wifi.getBoolean(packages[0], prefs.getBoolean("whitelist_wifi", true)); boolean other = prefs_other.getBoolean(packages[0], prefs.getBoolean("whitelist_other", true)); // Build Wi-Fi action Intent riWifi = new Intent(context, ServiceSinkhole.class); riWifi.putExtra(ServiceSinkhole.EXTRA_COMMAND, ServiceSinkhole.Command.set); riWifi.putExtra(ServiceSinkhole.EXTRA_NETWORK, "wifi"); riWifi.putExtra(ServiceSinkhole.EXTRA_UID, uid); riWifi.putExtra(ServiceSinkhole.EXTRA_PACKAGE, packages[0]); riWifi.putExtra(ServiceSinkhole.EXTRA_BLOCKED, !wifi); PendingIntent piWifi = PendingIntent.getService(context, uid, riWifi, PendingIntent.FLAG_UPDATE_CURRENT); builder.addAction(wifi ? R.drawable.wifi_on : R.drawable.wifi_off, context.getString(wifi ? R.string.title_allow : R.string.title_block), piWifi); // Build mobile action Intent riOther = new Intent(context, ServiceSinkhole.class); riOther.putExtra(ServiceSinkhole.EXTRA_COMMAND, ServiceSinkhole.Command.set); riOther.putExtra(ServiceSinkhole.EXTRA_NETWORK, "other"); riOther.putExtra(ServiceSinkhole.EXTRA_UID, uid); riOther.putExtra(ServiceSinkhole.EXTRA_PACKAGE, packages[0]); riOther.putExtra(ServiceSinkhole.EXTRA_BLOCKED, !other); PendingIntent piOther = PendingIntent.getService(context, uid + 10000, riOther, PendingIntent.FLAG_UPDATE_CURRENT); builder.addAction(other ? R.drawable.other_on : R.drawable.other_off, context.getString(other ? R.string.title_allow : R.string.title_block), piOther); // Show notification if (internet) NotificationManagerCompat.from(context).notify(uid, builder.build()); else { NotificationCompat.BigTextStyle expanded = new NotificationCompat.BigTextStyle(builder); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) expanded.bigText(context.getString(R.string.msg_installed_n)); else expanded.bigText(context.getString(R.string.msg_installed, name)); expanded.setSummaryText(context.getString(R.string.title_internet)); NotificationManagerCompat.from(context).notify(uid, expanded.build()); } } catch (PackageManager.NameNotFoundException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } }