List of usage examples for android.content.res Resources getString
@NonNull public String getString(@StringRes int id) throws NotFoundException
From source file:com.scigames.registration.ProfileActivity.java
/** Called with the activity is first created. */ @Override/*from ww w . ja v a 2 s.c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); Log.d(TAG, "super.OnCreate"); Intent i = getIntent(); Log.d(TAG, "getIntent"); firstNameIn = i.getStringExtra("fName"); lastNameIn = i.getStringExtra("lName"); // passwordIn = i.getStringExtra("password"); // massIn = i.getStringExtra("mass"); // emailIn = i.getStringExtra("email"); // classIdIn = i.getStringExtra("classId"); studentIdIn = i.getStringExtra("studentId"); visitIdIn = i.getStringExtra("visitId"); // rfidIn = i.getStringExtra("rfid"); photoUrl = i.getStringExtra("photoUrl"); photoUrl = "http://db.scigam.es/" + photoUrl; // slideLevel = i.getStringExtra("slideLevel"); // cartLevel = i.getStringExtra("cartLevel"); Log.d(TAG, "...getStringExtra"); // Inflate our UI from its XML layout description. setContentView(R.layout.profile_page); Log.d(TAG, "...setContentView"); //display name and profile info Resources res = getResources(); greets = (TextView) findViewById(R.id.student_name); greets.setText(String.format(res.getString(R.string.profile_name), firstNameIn, lastNameIn)); setTextViewFont(Museo700Regular, greets); //schoolname = (TextView)findViewById(R.id.school_name); //schoolname.setText(String.format(res.getString(R.string.profile_school_name), "from DB")); teachername = (TextView) findViewById(R.id.teacher_name); //teachername.setText(String.format(res.getString(R.string.profile_teacher_name), "from DB")); classname = (TextView) findViewById(R.id.class_name); classid = (TextView) findViewById(R.id.class_id); //classid.setText(String.format(res.getString(R.string.profile_classid), classIdIn)); mpass = (TextView) findViewById(R.id.password); //mpass.setText(String.format(res.getString(R.string.profile_password), passwordIn)); Log.d(TAG, "...Profile Info"); ExistenceLightOtf = Typeface.createFromAsset(getAssets(), "fonts/Existence-Light.ttf"); Typeface Museo300Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo300-Regular.otf"); Museo500Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo500-Regular.otf"); Museo700Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo700-Regular.otf"); // TextView welcome = (TextView)findViewById(R.id.welcome); // TextView notascigamersentence = (TextView)findViewById(R.id.notascigamersentence); // Hook up button presses to the appropriate event handler. //((Button) findViewById(R.id.back)).setOnClickListener(mBackListener); //((Button) findViewById(R.id.clear)).setOnClickListener(mClearListener); Log.d(TAG, "...instantiateButtons"); Done = (Button) findViewById(R.id.done); Done.setOnClickListener(mDone); setButtonFont(ExistenceLightOtf, Done); alertDialog = new AlertDialog.Builder(ProfileActivity.this).create(); // Setting Dialog Title alertDialog.setTitle("alert title"); // Setting Dialog Message alertDialog.setMessage("alert message"); // Setting Icon to Dialog //alertDialog.setIcon(R.drawable.tick); alertDialog.setButton(RESULT_OK, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to execute after dialog closed //Toast.makeText(getApplicationContext(), "Check your login info!", Toast.LENGTH_SHORT).show(); } }); //set listener task.setOnResultsListener(this); //push picture back.-- photo task.cancel(true); //create a new async task for every time you hit login (each can only run once ever) task = new SciGamesHttpPoster(ProfileActivity.this, "http://db.scigam.es/pull/return_profile.php"); //set listener task.setOnResultsListener(ProfileActivity.this); //prepare key value pairs to send String[] keyVals = { "student_id", studentIdIn, "visit_id", visitIdIn }; //create AsyncTask, then execute @SuppressWarnings("unused") AsyncTask<String, Void, JSONObject> serverResponse = null; serverResponse = task.execute(keyVals); Log.d(TAG, "...task.execute(keyVals)"); }
From source file:com.brewcrewfoo.performance.fragments.Advanced.java
public void openDialog(String title, final int min, final int max, final Preference pref, final String path, final String key) { Resources res = context.getResources(); String cancel = res.getString(R.string.cancel); String ok = res.getString(R.string.ok); final EditText settingText; LayoutInflater factory = LayoutInflater.from(context); final View alphaDialog = factory.inflate(R.layout.seekbar_dialog, null); final SeekBar seekbar = (SeekBar) alphaDialog.findViewById(R.id.seek_bar); seekbar.setMax(max - min);//from www.j a v a 2 s . c o m int currentProgress = min; if (key.equals("pref_viber")) { currentProgress = Integer.parseInt(vib.get_val(path)); } else { currentProgress = Integer.parseInt(Helpers.readOneLine(path)); } if (currentProgress > max) currentProgress = max - min; else if (currentProgress < min) currentProgress = 0; else currentProgress = currentProgress - min; seekbar.setProgress(currentProgress); settingText = (EditText) alphaDialog.findViewById(R.id.setting_text); settingText.setText(Integer.toString(currentProgress + min)); settingText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { int val = Integer.parseInt(settingText.getText().toString()) - min; seekbar.setProgress(val); return true; } return false; } }); settingText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { try { int val = Integer.parseInt(s.toString()); if (val > max) { s.replace(0, s.length(), Integer.toString(max)); val = max; } seekbar.setProgress(val - min); } catch (NumberFormatException ex) { } } }); OnSeekBarChangeListener seekBarChangeListener = new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) { final int mSeekbarProgress = seekbar.getProgress(); if (fromUser) { settingText.setText(Integer.toString(mSeekbarProgress + min)); } } @Override public void onStopTrackingTouch(SeekBar seekbar) { } @Override public void onStartTrackingTouch(SeekBar seekbar) { } }; seekbar.setOnSeekBarChangeListener(seekBarChangeListener); new AlertDialog.Builder(context).setTitle(title).setView(alphaDialog) .setNegativeButton(cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // nothing } }).setPositiveButton(ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int val = min; if (!settingText.getText().toString().equals("")) val = Integer.parseInt(settingText.getText().toString()); if (val < min) val = min; seekbar.setProgress(val - min); int newProgress = seekbar.getProgress() + min; new CMDProcessor().su .runWaitFor("busybox echo " + Integer.toString(newProgress) + " > " + path); String v; if (key.equals("pref_viber")) { v = vib.get_val(path); Vibrator vb = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vb.vibrate(1000); } else { v = Helpers.readOneLine(path); } final SharedPreferences.Editor editor = mPreferences.edit(); editor.putInt(key, Integer.parseInt(v)).commit(); pref.setSummary(v); } }).create().show(); }
From source file:br.com.frs.foodrestrictions.MessageVegan.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.activity_message_vegan, container, false); String language = getArguments().getString(MessageLanguageSelector.ARG_LANGUAGE); TextView tv = (TextView) v.findViewById(R.id.tvVegegan); /* //TODO - Find a better way of doing it * I don't believe that this is the best approach to handle this problem but it is * the only way I found to do it so far. Do you have any better idea? * please help me here :D/*from www.j a v a 2 s . c om*/ */ /* Getting the current resource and config info */ Resources rsc = v.getContext().getResources(); Configuration config = rsc.getConfiguration(); /* Saving the original locale before changing to the new one * just to show the texts */ Locale orgLocale = config.locale; if (language != null) { config.locale = new Locale(language); } /* Setting the new locale */ rsc.updateConfiguration(config, rsc.getDisplayMetrics()); /* Updating the layout with the new selected language */ tv.setText(rsc.getString(R.string.msg_vegan)); /* Return to last locale to keep the app as it was before */ config.locale = orgLocale; rsc.updateConfiguration(config, rsc.getDisplayMetrics()); return v; }
From source file:br.com.frs.foodrestrictions.MessageVegetarian.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.activity_message_vegetarian, container, false); String language = getArguments().getString(MessageLanguageSelector.ARG_LANGUAGE); TextView tv = (TextView) v.findViewById(R.id.tvVegetarian); /* //TODO - Find a better way of doing it * I don't believe that this is the best approach to handle this problem but it is * the only way I found to do it so far. Do you have any better idea? * please help me here :D//from www.j a va2 s . c om */ /* Getting the current resource and config info */ Resources rsc = v.getContext().getResources(); Configuration config = rsc.getConfiguration(); /* Saving the original locale before changing to the new one * just to show the texts */ Locale orgLocale = config.locale; if (language != null) { config.locale = new Locale(language); } /* Setting the new locale */ rsc.updateConfiguration(config, rsc.getDisplayMetrics()); /* Updating the layout with the new selected language */ tv.setText(rsc.getString(R.string.msg_veget)); /* Return to last locale to keep the app as it was before */ config.locale = orgLocale; rsc.updateConfiguration(config, rsc.getDisplayMetrics()); return v; }
From source file:com.ichi2.anki.dialogs.CustomStudyDialog.java
private HashMap<Integer, String> getKeyValueMap() { Resources res = getResources(); HashMap<Integer, String> keyValueMap = new HashMap<>(); keyValueMap.put(CONTEXT_MENU_STANDARD, res.getString(R.string.custom_study)); keyValueMap.put(CUSTOM_STUDY_NEW, res.getString(R.string.custom_study_increase_new_limit)); keyValueMap.put(CUSTOM_STUDY_REV, res.getString(R.string.custom_study_increase_review_limit)); keyValueMap.put(CUSTOM_STUDY_FORGOT, res.getString(R.string.custom_study_review_forgotten)); keyValueMap.put(CUSTOM_STUDY_AHEAD, res.getString(R.string.custom_study_review_ahead)); keyValueMap.put(CUSTOM_STUDY_RANDOM, res.getString(R.string.custom_study_random_selection)); keyValueMap.put(CUSTOM_STUDY_PREVIEW, res.getString(R.string.custom_study_preview_new)); keyValueMap.put(CUSTOM_STUDY_TAGS, res.getString(R.string.custom_study_limit_tags)); keyValueMap.put(DECK_OPTIONS, res.getString(R.string.study_options)); keyValueMap.put(MORE_OPTIONS, res.getString(R.string.more_options)); return keyValueMap; }
From source file:com.brewcrewfoo.performance.fragments.MemSettings.java
public void ProcEditDialog(final String key, String title, String msg, String path, Boolean type) { Resources res = getActivity().getResources(); final String cancel = res.getString(R.string.cancel); final String ok = res.getString(R.string.ps_volt_save); LayoutInflater factory = LayoutInflater.from(getActivity()); final View alphaDialog = factory.inflate(R.layout.sh_dialog, null); final String namespath = path; settingText = (EditText) alphaDialog.findViewById(R.id.shText); settingText.setText(mPreferences.getString(key, "")); settingText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override/* ww w . j a v a2 s .co m*/ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { return true; } }); settingText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); new AlertDialog.Builder(getActivity()).setTitle(title).setMessage(msg).setView(alphaDialog) .setNegativeButton(cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { /* nothing */ } }).setPositiveButton(ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final SharedPreferences.Editor editor = mPreferences.edit(); editor.putString(key, settingText.getText().toString()).commit(); new CMDProcessor().su.runWaitFor("busybox echo " + mPreferences.getString(key, Helpers.readOneLine(namespath)) + " > " + namespath); } }).create().show(); }
From source file:com.ichi2.anki.dialogs.CustomStudyDialog.java
private String getText2() { Resources res = AnkiDroidApp.getAppResources(); switch (getArguments().getInt("id")) { case CUSTOM_STUDY_NEW: return res.getString(R.string.custom_study_new_extend); case CUSTOM_STUDY_REV: return res.getString(R.string.custom_study_rev_extend); case CUSTOM_STUDY_FORGOT: return res.getString(R.string.custom_study_forgotten); case CUSTOM_STUDY_AHEAD: return res.getString(R.string.custom_study_ahead); case CUSTOM_STUDY_RANDOM: return res.getString(R.string.custom_study_random); case CUSTOM_STUDY_PREVIEW: return res.getString(R.string.custom_study_preview); default:/*from w w w . j av a 2s .co m*/ return ""; } }
From source file:com.amazon.appstream.fireclient.ConnectDialogFragment.java
/** * Update all the fields to be correctly VISIBLE or GONE based * on the state flags. Also updates some text that changes on * change of state./*from w w w . jav a 2 s .co m*/ */ public void updateFields() { mReconnect.setVisibility(View.GONE); if (mShowingProgress) { mProgressBar.setVisibility(View.VISIBLE); mTextEntryFields.setVisibility(View.GONE); } else { int visibility = mUseAppServer ? View.GONE : View.VISIBLE; mProgressBar.setVisibility(View.GONE); mTextEntryFields.setVisibility(View.VISIBLE); mAppIdField.setVisibility(visibility); mUserIdField.setVisibility(visibility); mSpace1.setVisibility(visibility); mSpace2.setVisibility(visibility); mAppIdTitle.setVisibility(visibility); mUserIdTitle.setVisibility(visibility); Resources r = getActivity().getResources(); if (mUseAppServer) { if (mServerAddress != null) { mAddressField.setText(mServerAddress); } mAddressField.setHint(r.getString(R.string.address_hint_app)); mAddressTitle.setText(R.string.address_label_app); } else { if (mDESServerAddress != null) { mAddressField.setText(mDESServerAddress); } mAddressField.setHint(r.getString(R.string.address_hint)); mAddressTitle.setText(R.string.address_label); } if (mErrorMessage == null) { mErrorMessageField.setVisibility(View.GONE); } else { mErrorMessageField.setText(mErrorMessage); mErrorMessageField.setVisibility(View.VISIBLE); } } }
From source file:com.android.launcher3.allapps.AllAppsGridAdapter.java
/** * Sets the last search query that was made, used to show when there are no results and to also * seed the intent for searching the market. *///from ww w . j a v a 2s . com public void setLastSearchQuery(String query) { Resources res = mLauncher.getResources(); String formatStr = res.getString(R.string.all_apps_no_search_results); mEmptySearchMessage = String.format(formatStr, query); if (mMarketAppName != null) { mMarketSearchMessage = String.format(res.getString(R.string.all_apps_search_market_message), mMarketAppName); mMarketSearchIntent = mSearchController.createMarketSearchIntent(query); } }
From source file:com.codetroopers.betterpickers.radialtimepicker.RadialSelectorView.java
/** * Initialize this selector with the state of the picker. * * @param context Current context. * @param is24HourMode Whether the selector is in 24-hour mode, which will tell us whether the circle's center is * moved up slightly to make room for the AM/PM circles. * @param hasInnerCircle Whether we have both an inner and an outer circle of numbers that may be selected. Should * be true for 24-hour mode in the hours circle. * @param disappearsOut Whether the numbers' animation will have them disappearing out or disappearing in. * @param selectionDegrees The initial degrees to be selected. * @param isInnerCircle Whether the initial selection is in the inner or outer circle. Will be ignored when * hasInnerCircle is false. *///from w ww . j a v a 2 s. c o m public void initialize(Context context, boolean is24HourMode, boolean hasInnerCircle, boolean disappearsOut, int selectionDegrees, boolean isInnerCircle) { if (mIsInitialized) { Log.e(TAG, "This RadialSelectorView may only be initialized once."); return; } Resources res = context.getResources(); mPaint.setAntiAlias(true); // Calculate values for the circle radius size. mIs24HourMode = is24HourMode; if (is24HourMode) { mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.circle_radius_multiplier_24HourMode)); } else { mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.circle_radius_multiplier)); mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.ampm_circle_radius_multiplier)); } // Calculate values for the radius size(s) of the numbers circle(s). mHasInnerCircle = hasInnerCircle; if (hasInnerCircle) { mInnerNumbersRadiusMultiplier = Float .parseFloat(res.getString(R.string.numbers_radius_multiplier_inner)); mOuterNumbersRadiusMultiplier = Float .parseFloat(res.getString(R.string.numbers_radius_multiplier_outer)); } else { mNumbersRadiusMultiplier = Float.parseFloat(res.getString(R.string.numbers_radius_multiplier_normal)); } mSelectionRadiusMultiplier = Float.parseFloat(res.getString(R.string.selection_radius_multiplier)); // Calculate values for the transition mid-way states. mAnimationRadiusMultiplier = 1; mTransitionMidRadiusMultiplier = 1f + (0.05f * (disappearsOut ? -1 : 1)); mTransitionEndRadiusMultiplier = 1f + (0.3f * (disappearsOut ? 1 : -1)); mInvalidateUpdateListener = new InvalidateUpdateListener(); setSelection(selectionDegrees, isInnerCircle, false); mIsInitialized = true; }