List of usage examples for android.content.res Resources getString
@NonNull public String getString(@StringRes int id) throws NotFoundException
From source file:com.borax12.materialdaterangepicker.date.DatePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.range_date_picker_dialog, container, false); tabHost = (TabHost) view.findViewById(R.id.tabHost); tabHost.findViewById(R.id.tabHost);/*from w ww .jav a2 s.c o m*/ tabHost.setup(); final Activity activity = getActivity(); TabHost.TabSpec startDatePage = tabHost.newTabSpec("start"); startDatePage.setContent(R.id.start_date_group); startDatePage.setIndicator((startTitle != null && !startTitle.isEmpty()) ? startTitle : activity.getResources().getString(R.string.mdtrp_from)); TabHost.TabSpec endDatePage = tabHost.newTabSpec("end"); endDatePage.setContent(R.id.end_date_group); endDatePage.setIndicator((endTitle != null && !endTitle.isEmpty()) ? endTitle : activity.getResources().getString(R.string.mdtrp_to)); tabHost.addTab(startDatePage); tabHost.addTab(endDatePage); mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header); mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day); mMonthAndDayViewEnd = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day_end); mMonthAndDayView.setOnClickListener(this); mMonthAndDayViewEnd.setOnClickListener(this); mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month); mSelectedMonthTextViewEnd = (TextView) view.findViewById(R.id.date_picker_month_end); mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day); mSelectedDayTextViewEnd = (TextView) view.findViewById(R.id.date_picker_day_end); mYearView = (TextView) view.findViewById(R.id.date_picker_year); mYearViewEnd = (TextView) view.findViewById(R.id.date_picker_year_end); mYearView.setOnClickListener(this); mYearViewEnd.setOnClickListener(this); int listPosition = -1; int listPositionOffset = 0; int listPositionEnd = -1; int listPositionOffsetEnd = 0; int currentView = MONTH_AND_DAY_VIEW; int currentViewEnd = MONTH_AND_DAY_VIEW; if (savedInstanceState != null) { mWeekStart = savedInstanceState.getInt(KEY_WEEK_START); mWeekStartEnd = savedInstanceState.getInt(KEY_WEEK_START_END); mMinYear = savedInstanceState.getInt(KEY_YEAR_START); mMaxYear = savedInstanceState.getInt(KEY_MAX_YEAR); currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW); currentViewEnd = savedInstanceState.getInt(KEY_CURRENT_VIEW_END); listPosition = savedInstanceState.getInt(KEY_LIST_POSITION); listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET); listPositionEnd = savedInstanceState.getInt(KEY_LIST_POSITION_END); listPositionOffsetEnd = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET_END); mMinDate = (Calendar) savedInstanceState.getSerializable(KEY_MIN_DATE); mMaxDate = (Calendar) savedInstanceState.getSerializable(KEY_MAX_DATE); mMinDateEnd = (Calendar) savedInstanceState.getSerializable(KEY_MIN_DATE_END); mMaxDateEnd = (Calendar) savedInstanceState.getSerializable(KEY_MAX_DATE_END); highlightedDays = (Calendar[]) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS); selectableDays = (Calendar[]) savedInstanceState.getSerializable(KEY_SELECTABLE_DAYS); highlightedDaysEnd = (Calendar[]) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS_END); selectableDaysEnd = (Calendar[]) savedInstanceState.getSerializable(KEY_SELECTABLE_DAYS_END); mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK); mAccentColor = savedInstanceState.getInt(KEY_ACCENT); mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE); mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS); } mDayPickerView = new com.borax12.materialdaterangepicker.date.SimpleDayPickerView(activity, this); mYearPickerView = new com.borax12.materialdaterangepicker.date.YearPickerView(activity, this); mDayPickerViewEnd = new com.borax12.materialdaterangepicker.date.SimpleDayPickerView(activity, this); mYearPickerViewEnd = new com.borax12.materialdaterangepicker.date.YearPickerView(activity, this); Resources res = getResources(); mDayPickerDescription = res.getString(R.string.mdtrp_day_picker_description); mSelectDay = res.getString(R.string.mdtrp_select_day); mYearPickerDescription = res.getString(R.string.mdtrp_year_picker_description); mSelectYear = res.getString(R.string.mdtrp_select_year); int bgColorResource = mThemeDark ? R.color.mdtrp_date_picker_view_animator_dark_theme : R.color.mdtrp_date_picker_view_animator; view.setBackgroundColor(ContextCompat.getColor(activity, bgColorResource)); mAnimator = (com.borax12.materialdaterangepicker.date.AccessibleDateAnimator) view .findViewById(R.id.animator); mAnimatorEnd = (com.borax12.materialdaterangepicker.date.AccessibleDateAnimator) view .findViewById(R.id.animator_end); mAnimator.addView(mDayPickerView); mAnimator.addView(mYearPickerView); mAnimator.setDateMillis(mCalendar.getTimeInMillis()); // TODO: Replace with animation decided upon by the design team. Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(ANIMATION_DURATION); mAnimator.setInAnimation(animation); // TODO: Replace with animation decided upon by the design team. Animation animation2 = new AlphaAnimation(1.0f, 0.0f); animation2.setDuration(ANIMATION_DURATION); mAnimator.setOutAnimation(animation2); mAnimatorEnd.addView(mDayPickerViewEnd); mAnimatorEnd.addView(mYearPickerViewEnd); mAnimatorEnd.setDateMillis(mCalendarEnd.getTimeInMillis()); // TODO: Replace with animation decided upon by the design team. Animation animationEnd = new AlphaAnimation(0.0f, 1.0f); animationEnd.setDuration(ANIMATION_DURATION); mAnimatorEnd.setInAnimation(animation); // TODO: Replace with animation decided upon by the design team. Animation animation2End = new AlphaAnimation(1.0f, 0.0f); animation2End.setDuration(ANIMATION_DURATION); mAnimatorEnd.setOutAnimation(animation2); Button okButton = (Button) view.findViewById(R.id.ok); okButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); if (mCallBack != null) { mCallBack.onDateSet(DatePickerDialog.this, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH), mCalendarEnd.get(Calendar.YEAR), mCalendarEnd.get(Calendar.MONTH), mCalendarEnd.get(Calendar.DAY_OF_MONTH)); } dismiss(); } }); okButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); Button cancelButton = (Button) view.findViewById(R.id.cancel); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); if (getDialog() != null) getDialog().cancel(); } }); cancelButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); cancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE); //If an accent color has not been set manually, try and get it from the context if (mAccentColor == -1) { int accentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity()); if (accentColor != -1) { mAccentColor = accentColor; } } if (mAccentColor != -1) { if (mDayOfWeekView != null) mDayOfWeekView.setBackgroundColor(Utils.darkenColor(mAccentColor)); view.findViewById(R.id.day_picker_selected_date_layout).setBackgroundColor(mAccentColor); view.findViewById(R.id.day_picker_selected_date_layout_end).setBackgroundColor(mAccentColor); okButton.setTextColor(mAccentColor); cancelButton.setTextColor(mAccentColor); mYearPickerView.setAccentColor(mAccentColor); mDayPickerView.setAccentColor(mAccentColor); mYearPickerViewEnd.setAccentColor(mAccentColor); mDayPickerViewEnd.setAccentColor(mAccentColor); } updateDisplay(false); setCurrentView(currentView); if (listPosition != -1) { if (currentView == MONTH_AND_DAY_VIEW) { mDayPickerView.postSetSelection(listPosition); } else if (currentView == YEAR_VIEW) { mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset); } } if (listPositionEnd != -1) { if (currentViewEnd == MONTH_AND_DAY_VIEW) { mDayPickerViewEnd.postSetSelection(listPositionEnd); } else if (currentViewEnd == YEAR_VIEW) { mYearPickerViewEnd.postSetSelectionFromTop(listPositionEnd, listPositionOffsetEnd); } } mHapticFeedbackController = new HapticFeedbackController(activity); tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tabId) { com.borax12.materialdaterangepicker.date.MonthAdapter.CalendarDay calendarDay; if (tabId.equals("start")) { calendarDay = new com.borax12.materialdaterangepicker.date.MonthAdapter.CalendarDay( mCalendar.getTimeInMillis()); mDayPickerView.goTo(calendarDay, true, true, false); } else { calendarDay = new com.borax12.materialdaterangepicker.date.MonthAdapter.CalendarDay( mCalendarEnd.getTimeInMillis()); mDayPickerViewEnd.goTo(calendarDay, true, true, false); } } }); return view; }
From source file:com.customdatepicker.date.DatePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { int listPosition = -1; int listPositionOffset = 0; int currentView = mDefaultView; if (savedInstanceState != null) { mWeekStart = savedInstanceState.getInt(KEY_WEEK_START); currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW); listPosition = savedInstanceState.getInt(KEY_LIST_POSITION); listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET); //noinspection unchecked highlightedDays = (HashSet<Calendar>) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS); mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK); mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED); mAccentColor = savedInstanceState.getInt(KEY_ACCENT); mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE); mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS); mAutoDismiss = savedInstanceState.getBoolean(KEY_AUTO_DISMISS); mTitle = savedInstanceState.getString(KEY_TITLE); mOkResid = savedInstanceState.getInt(KEY_OK_RESID); mOkString = savedInstanceState.getString(KEY_OK_STRING); mOkColor = savedInstanceState.getInt(KEY_OK_COLOR); mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID); mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING); mCancelColor = savedInstanceState.getInt(KEY_CANCEL_COLOR); mVersion = (Version) savedInstanceState.getSerializable(KEY_VERSION); mTimezone = (TimeZone) savedInstanceState.getSerializable(KEY_TIMEZONE); mDateRangeLimiter = savedInstanceState.getParcelable(KEY_DATERANGELIMITER); /*//from w w w. j av a 2s .c o m If the user supplied a custom limiter, we need to create a new default one to prevent null pointer exceptions on the configuration methods If the user did not supply a custom limiter we need to ensure both mDefaultLimiter and mDateRangeLimiter are the same reference, so that the config methods actually ffect the behaviour of the picker (in the unlikely event the user reconfigures the picker when it is shown) */ if (mDateRangeLimiter instanceof DefaultDateRangeLimiter) { mDefaultLimiter = (DefaultDateRangeLimiter) mDateRangeLimiter; } else { mDefaultLimiter = new DefaultDateRangeLimiter(); } } mDefaultLimiter.setController(this); int viewRes = mVersion == Version.VERSION_1 ? R.layout.mdtp_date_picker_dialog : R.layout.mdtp_date_picker_dialog_v2; View view = inflater.inflate(viewRes, container, false); // All options have been set at this point: round the initial selection if necessary mCalendar = mDateRangeLimiter.setToNearestDate(mCalendar); mDatePickerHeaderView = (TextView) view.findViewById(R.id.mdtp_date_picker_header); mImageViewLeft = (ImageView) view.findViewById(R.id.imageViewLeft); mImageViewRight = (ImageView) view.findViewById(R.id.imageViewRight); mMonthAndDayView = (LinearLayout) view.findViewById(R.id.mdtp_date_picker_month_and_day); mMonthAndDayView.setOnClickListener(this); mSelectedMonthTextView = (TextView) view.findViewById(R.id.mdtp_date_picker_month); mSelectedDayTextView = (TextView) view.findViewById(R.id.mdtp_date_picker_day); mYearView = (TextView) view.findViewById(R.id.mdtp_date_picker_year); mYearView.setOnClickListener(this); mImageViewLeft.setOnClickListener(this); mImageViewRight.setOnClickListener(this); final Activity activity = getActivity(); mDayPickerView = new SimpleDayPickerView(activity, this); mYearPickerView = new YearPickerView(activity, this); // if theme mode has not been set by java code, check if it is specified in Style.xml if (!mThemeDarkChanged) { mThemeDark = Utils.isDarkTheme(activity, mThemeDark); } Resources res = getResources(); mDayPickerDescription = res.getString(R.string.mdtp_day_picker_description); mSelectDay = res.getString(R.string.mdtp_select_day); mYearPickerDescription = res.getString(R.string.mdtp_year_picker_description); mSelectYear = res.getString(R.string.mdtp_select_year); int bgColorResource = mThemeDark ? R.color.mdtp_date_picker_view_animator_dark_theme : R.color.mdtp_date_picker_view_animator; view.setBackgroundColor(ContextCompat.getColor(activity, bgColorResource)); mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.mdtp_animator); mAnimator.addView(mDayPickerView); mAnimator.addView(mYearPickerView); mAnimator.setDateMillis(mCalendar.getTimeInMillis()); // TODO: Replace with animation decided upon by the design team. Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(ANIMATION_DURATION); mAnimator.setInAnimation(animation); // TODO: Replace with animation decided upon by the design team. Animation animation2 = new AlphaAnimation(1.0f, 0.0f); animation2.setDuration(ANIMATION_DURATION); mAnimator.setOutAnimation(animation2); Button okButton = (Button) view.findViewById(R.id.mdtp_ok); okButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); notifyOnDateListener(); dismiss(); } }); okButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); if (mOkString != null) okButton.setText(mOkString); else okButton.setText(mOkResid); Button cancelButton = (Button) view.findViewById(R.id.mdtp_cancel); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); if (getDialog() != null) getDialog().cancel(); } }); cancelButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); if (mCancelString != null) cancelButton.setText(mCancelString); else cancelButton.setText(mCancelResid); cancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE); // If an accent color has not been set manually, get it from the context if (mAccentColor == -1) { mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity()); } if (mDatePickerHeaderView != null) mDatePickerHeaderView.setBackgroundColor(Utils.darkenColor(mAccentColor)); view.findViewById(R.id.mdtp_day_picker_selected_date_layout).setBackgroundColor(mAccentColor); // Buttons can have a different color if (mOkColor != -1) okButton.setTextColor(mOkColor); else okButton.setTextColor(mAccentColor); if (mCancelColor != -1) cancelButton.setTextColor(mCancelColor); else cancelButton.setTextColor(mAccentColor); if (getDialog() == null) { view.findViewById(R.id.mdtp_done_background).setVisibility(View.GONE); } updateDisplay(false); setCurrentView(currentView); if (listPosition != -1) { if (currentView == MONTH_AND_DAY_VIEW) { mDayPickerView.postSetSelection(listPosition); } else if (currentView == YEAR_VIEW) { mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset); } } mHapticFeedbackController = new HapticFeedbackController(activity); return view; }
From source file:com.scigames.slidegame.ReviewActivity.java
@Override public void onResultsSucceeded(String[] student, String[] slide_session, String[] slide_level, String[] objective_images, String[] fabric, String[] result_images, String[] score_images, String attempts, boolean no_session, JSONObject serverResponseJSON) throws JSONException { Log.d(TAG, ">>> slide_level results: "); for (int i = 0; i < slide_level.length; i++) { Log.d(TAG, slide_level[i].toString()); }//from ww w.ja va 2s. c o m Log.d(TAG, ">>> result_images: " + result_images.toString()); for (int i = 0; i < result_images.length; i++) { Log.d(TAG, result_images[i].toString()); } if (no_session == true) { needSlideDataDialog.setTitle("No Slide Data Today! "); needSlideDataDialog.setMessage("Go play on the slide before checking your last score!"); needSlideDataDialog.show(); } else { if (debug) { infoDialog.setTitle("onResults Succeded: "); infoDialog.setMessage(serverResponseJSON.toString()); infoDialog.show(); } //Set local variables for deciding and displaying some stuff Log.d(TAG, "thermalGoal: " + slide_level[2]); Log.d(TAG, "kineticGoal: " + slide_level[1]); Log.d(TAG, "thermalMade: " + slide_session[6]); Log.d(TAG, "kineticMade: " + slide_session[5]); //get all the slide session data! score = slide_session[4]; levelCompleted = Boolean.parseBoolean(slide_session[3]); thermalGoal = (float) Integer.parseInt(slide_level[2]); kineticGoal = (float) Integer.parseInt(slide_level[1]); thermalMade = Float.parseFloat(slide_session[6]); //5 in kin kineticMade = Float.parseFloat(slide_session[5]); potentialMade = Float.parseFloat(slide_session[7]); // if(levelCompleted && !checkCompletion){ //this is temporary!! // if (isNetworkAvailable()){ // task.cancel(true); // //create a new async task for every time you hit login (each can only run once ever) // task = new SciGamesHttpPoster(ReviewActivity.this,"http://mysweetwebsite.com/pull/slide_results.php"); // //set listener // task.setOnResultsListener(ReviewActivity.this); // //prepare key value pairs to send // String[] keyVals = {"rfid", rfidIn}; // //create AsyncTask, then execute // AsyncTask<String, Void, JSONObject> serverResponse = null; // serverResponse = task.execute(keyVals); // checkCompletion = true; // } else { // alertDialog.setMessage("You're not connected to the internet. Make sure this tablet is logged into a working Wifi Network."); // alertDialog.show(); // } // } /** update all text fields **/ //locate textViews in this layout Resources res = getResources(); title = (TextView) findViewById(R.id.title); mLevel = (TextView) findViewById(R.id.level); mScore = (TextView) findViewById(R.id.score); //mScoreFinal = (TextView)findViewById(R.id.score_final); mFabric = (TextView) findViewById(R.id.fabric); mAttempt = (TextView) findViewById(R.id.attempt); //Set the TextView values for first review page mScore.setText(String.format(res.getString(R.string.score), score)); //mScoreFinal.setText(String.format(res.getString(R.string.score), score)); mFabric.setText(String.format(res.getString(R.string.fabric), fabric[0])); //for the level and attempt we add 1 here bc the database starts at level 0. mAttempt.setText(String.format(res.getString(R.string.attempt), String.valueOf(Integer.parseInt(slide_session[1]) + 1))); mLevel.setText(String.format(res.getString(R.string.level), String.valueOf(Integer.parseInt(slide_session[2]) + 1))); setTextViewFont(Museo700Regular, title); setTextViewFont(Museo500Regular, mLevel, mScore, mFabric, mAttempt); //set them to visible title.setVisibility(View.VISIBLE); mLevel.setVisibility(View.VISIBLE); mScore.setVisibility(View.VISIBLE); //mScoreFinal.setVisibility(View.INVISIBLE); mFabric.setVisibility(View.VISIBLE); mAttempt.setVisibility(View.VISIBLE); //calculate ratios kineticToThermalRatioGoal = ((float) kineticGoal / (float) thermalGoal); kineticToThermalRatioMade = ((float) kineticMade / (float) thermalMade); if (kineticToThermalRatioGoal > kineticToThermalRatioMade) { tooMuchOomph = false; } else if (kineticToThermalRatioGoal < kineticToThermalRatioMade) { tooMuchOomph = true; } //print out everything we got and calculated. Log.d(TAG, "score: " + score); Log.d(TAG, "levelCompleted: " + levelCompleted); Log.d(TAG, "thermalGoal: " + String.valueOf(thermalGoal)); Log.d(TAG, "kineticGoal: " + String.valueOf(kineticGoal)); Log.d(TAG, "thermalMade: " + String.valueOf(thermalMade)); Log.d(TAG, "kineticMade: " + String.valueOf(kineticMade)); Log.d(TAG, "kineticToThermalRatioGoal: " + String.valueOf(kineticToThermalRatioGoal)); Log.d(TAG, "kineticToThermalRatioMade: " + String.valueOf(kineticToThermalRatioMade)); Log.d(TAG, "tooMuchOomph: " + String.valueOf(tooMuchOomph)); resultImg = result_images; Log.d(TAG, ">>> RESULT_IMGS RECEIVED:"); for (int i = 0; i < resultImg.length; i++) { Log.d(TAG, resultImg[i].toString()); } scoreImg = score_images; Log.d(TAG, ">>> SCORE_IMGS RECEIVED:"); for (int i = 0; i < scoreImg.length; i++) { Log.d(TAG, scoreImg[i].toString()); } } }
From source file:com.google.samples.apps.iosched.service.SessionAlarmService.java
/** * A starred session is about to end. Notify the user to provide session feedback. * Constructs and triggers a system notification. Does nothing if the session has already * concluded.//w w w . ja va 2 s. c o m */ private void notifySessionFeedback(boolean debug) { LOGD(TAG, "Considering firing notification for session feedback."); if (debug) { LOGW(TAG, "Note: this is a debug notification."); } // Don't fire notification if this feature is disabled in settings if (!SettingsUtils.shouldShowSessionFeedbackReminders(this)) { LOGD(TAG, "Skipping session feedback notification. Disabled in settings."); return; } Cursor c = null; try { c = getContentResolver().query(ScheduleContract.Sessions.CONTENT_MY_SCHEDULE_URI, SessionsNeedingFeedbackQuery.PROJECTION, SessionsNeedingFeedbackQuery.WHERE_CLAUSE, null, null); if (c == null) { return; } FeedbackHelper feedbackHelper = new FeedbackHelper(this); List<String> needFeedbackIds = new ArrayList<String>(); List<String> needFeedbackTitles = new ArrayList<String>(); while (c.moveToNext()) { String sessionId = c.getString(SessionsNeedingFeedbackQuery.SESSION_ID); String sessionTitle = c.getString(SessionsNeedingFeedbackQuery.SESSION_TITLE); // Avoid repeated notifications. if (feedbackHelper.isFeedbackNotificationFiredForSession(sessionId)) { LOGD(TAG, "Skipping repeated session feedback notification for session '" + sessionTitle + "'"); continue; } needFeedbackIds.add(sessionId); needFeedbackTitles.add(sessionTitle); } if (needFeedbackIds.size() == 0) { // the user has already been notified of all sessions needing feedback return; } LOGD(TAG, "Going forward with session feedback notification for " + needFeedbackIds.size() + " session(s)."); final Resources res = getResources(); // this is used to synchronize deletion of notifications on phone and wear Intent dismissalIntent = new Intent(ACTION_NOTIFICATION_DISMISSAL); // TODO: fix Wear dismiss integration //dismissalIntent.putExtra(KEY_SESSION_ID, sessionId); PendingIntent dismissalPendingIntent = PendingIntent.getService(this, (int) new Date().getTime(), dismissalIntent, PendingIntent.FLAG_UPDATE_CURRENT); String provideFeedbackTicker = res.getString(R.string.session_feedback_notification_ticker); NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this) .setColor(getResources().getColor(R.color.theme_primary)).setContentText(provideFeedbackTicker) .setTicker(provideFeedbackTicker) .setLights(SessionAlarmService.NOTIFICATION_ARGB_COLOR, SessionAlarmService.NOTIFICATION_LED_ON_MS, SessionAlarmService.NOTIFICATION_LED_OFF_MS) .setSmallIcon(R.drawable.ic_stat_notification).setPriority(Notification.PRIORITY_LOW) .setLocalOnly(true) // make it local to the phone .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setDeleteIntent(dismissalPendingIntent).setAutoCancel(true); if (needFeedbackIds.size() == 1) { // Only 1 session needs feedback Uri sessionUri = ScheduleContract.Sessions.buildSessionUri(needFeedbackIds.get(0)); PendingIntent pi = TaskStackBuilder.create(this) .addNextIntent(new Intent(this, MyScheduleActivity.class)) .addNextIntent( new Intent(Intent.ACTION_VIEW, sessionUri, this, SessionFeedbackActivity.class)) .getPendingIntent(1, PendingIntent.FLAG_CANCEL_CURRENT); notifBuilder.setContentTitle(needFeedbackTitles.get(0)).setContentIntent(pi); } else { // Show information about several sessions that need feedback PendingIntent pi = TaskStackBuilder.create(this) .addNextIntent(new Intent(this, MyScheduleActivity.class)) .getPendingIntent(1, PendingIntent.FLAG_CANCEL_CURRENT); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); inboxStyle.setBigContentTitle(provideFeedbackTicker); for (String title : needFeedbackTitles) { inboxStyle.addLine(title); } notifBuilder .setContentTitle(getResources().getQuantityString(R.plurals.session_plurals, needFeedbackIds.size(), needFeedbackIds.size())) .setStyle(inboxStyle).setContentIntent(pi); } NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); LOGD(TAG, "Now showing session feedback notification!"); nm.notify(FEEDBACK_NOTIFICATION_ID, notifBuilder.build()); for (int i = 0; i < needFeedbackIds.size(); i++) { setupNotificationOnWear(needFeedbackIds.get(i), null, needFeedbackTitles.get(i), null); feedbackHelper.setFeedbackNotificationAsFiredForSession(needFeedbackIds.get(i)); } } finally { if (c != null) { try { c.close(); } catch (Exception ignored) { } } } }
From source file:com.android.datetimepicker.time.AmPmCirclesView.java
public void initialize(Context context, TimePickerController controller, int amOrPm) { if (mIsInitialized) { Log.e(TAG, "AmPmCirclesView may only be initialized once."); return;//from ww w. j ava2s. co m } Resources res = context.getResources(); if (controller.isThemeDark()) { mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_circle_background_dark_theme); mAmPmTextColor = ContextCompat.getColor(context, R.color.mdtp_white); mAmPmDisabledTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled_dark_theme); mSelectedAlpha = SELECTED_ALPHA_THEME_DARK; } else { mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_white); mAmPmTextColor = ContextCompat.getColor(context, R.color.mdtp_ampm_text_color); mAmPmDisabledTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled); mSelectedAlpha = SELECTED_ALPHA; } mSelectedColor = controller.getAccentColor(); mTouchedColor = Utils.darkenColor(mSelectedColor); mAmPmSelectedTextColor = ContextCompat.getColor(context, R.color.mdtp_white); String typefaceFamily = res.getString(R.string.mdtp_sans_serif); Typeface tf = Typeface.create(typefaceFamily, Typeface.NORMAL); mPaint.setTypeface(tf); mPaint.setAntiAlias(true); mPaint.setTextAlign(Align.CENTER); mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier)); mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier)); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0]; mPmText = amPmTexts[1]; mAmDisabled = controller.isAmDisabled(); mPmDisabled = controller.isPmDisabled(); setAmOrPm(amOrPm); mAmOrPmPressed = -1; mIsInitialized = true; }
From source file:com.scigames.slidereview.ReviewActivity.java
@Override public void onResultsSucceeded(String[] student, String[] slide_session, String[] slide_level, String[] objective_images, String[] fabric, String[] result_images, String[] score_images, String attempts, boolean no_session, JSONObject serverResponseJSON) throws JSONException { Log.d(TAG, ">>> slide_level results: "); for (int i = 0; i < slide_level.length; i++) { Log.d(TAG, slide_level[i].toString()); }/*from w w w.ja v a2 s . com*/ Log.d(TAG, ">>> result_images: " + result_images.toString()); for (int i = 0; i < result_images.length; i++) { Log.d(TAG, result_images[i].toString()); } if (no_session == true) { needSlideDataDialog.setTitle("No Slide Data Today! "); needSlideDataDialog.setMessage("Go play on the slide before checking your last score!"); needSlideDataDialog.show(); } else { if (debug) { infoDialog.setTitle("onResults Succeded: "); infoDialog.setMessage(serverResponseJSON.toString()); infoDialog.show(); } //Set local variables for deciding and displaying some stuff Log.d(TAG, "thermalGoal: " + slide_level[2]); Log.d(TAG, "kineticGoal: " + slide_level[1]); Log.d(TAG, "thermalMade: " + slide_session[6]); Log.d(TAG, "kineticMade: " + slide_session[5]); Log.d(TAG, "session_valid: " + slide_session[9]); //get all the slide session data! score = slide_session[4]; levelCompleted = Boolean.parseBoolean(slide_session[3]); thermalGoal = (float) Integer.parseInt(slide_level[2]); kineticGoal = (float) Integer.parseInt(slide_level[1]); thermalMade = Float.parseFloat(slide_session[6]); //5 in kin kineticMade = Float.parseFloat(slide_session[5]); potentialMade = Float.parseFloat(slide_session[7]); sessionValid = slide_session[9]; Log.d(TAG, "session_valid_BOOL: " + String.valueOf(sessionValid)); if (sessionValid.equals("false")) { needSlideDataDialog.setTitle("Oops!"); needSlideDataDialog.setMessage( "It looks like something went wrong during your turn. Go back up and try your turn again!"); needSlideDataDialog.show(); } else { // if(levelCompleted && !checkCompletion){ //this is temporary!! // if (isNetworkAvailable()){ // task.cancel(true); // //create a new async task for every time you hit login (each can only run once ever) // task = new SciGamesHttpPoster(ReviewActivity.this,"http://mysweetwebsite.com/pull/slide_results.php"); // //set listener // task.setOnResultsListener(ReviewActivity.this); // //prepare key value pairs to send // String[] keyVals = {"rfid", rfidIn}; // //create AsyncTask, then execute // AsyncTask<String, Void, JSONObject> serverResponse = null; // serverResponse = task.execute(keyVals); // checkCompletion = true; // } else { // alertDialog.setMessage("You're not connected to the internet. Make sure this tablet is logged into a working Wifi Network."); // alertDialog.show(); // } // } /** update all text fields **/ //locate textViews in this layout Resources res = getResources(); title = (TextView) findViewById(R.id.title); mLevel = (TextView) findViewById(R.id.level); mScore = (TextView) findViewById(R.id.score); //mScoreFinal = (TextView)findViewById(R.id.score_final); mFabric = (TextView) findViewById(R.id.fabric); mAttempt = (TextView) findViewById(R.id.attempt); //Set the TextView values for first review page mScore.setText(String.format(res.getString(R.string.score), score)); //mScoreFinal.setText(String.format(res.getString(R.string.score), score)); mFabric.setText(String.format(res.getString(R.string.fabric), fabric[0])); //for the level and attempt we add 1 here bc the database starts at level 0. mAttempt.setText(String.format(res.getString(R.string.attempt), String.valueOf(Integer.parseInt(slide_session[1]) + 1))); mLevel.setText(String.format(res.getString(R.string.level), String.valueOf(Integer.parseInt(slide_session[2]) + 1))); setTextViewFont(Museo700Regular, title); setTextViewFont(Museo500Regular, mLevel, mScore, mFabric, mAttempt); //set them to visible title.setVisibility(View.VISIBLE); mLevel.setVisibility(View.VISIBLE); mScore.setVisibility(View.VISIBLE); //mScoreFinal.setVisibility(View.INVISIBLE); mFabric.setVisibility(View.VISIBLE); mAttempt.setVisibility(View.VISIBLE); //calculate ratios kineticToThermalRatioGoal = ((float) kineticGoal / (float) thermalGoal); kineticToThermalRatioMade = ((float) kineticMade / (float) thermalMade); if (kineticToThermalRatioGoal > kineticToThermalRatioMade) { tooMuchOomph = false; } else if (kineticToThermalRatioGoal < kineticToThermalRatioMade) { tooMuchOomph = true; } //print out everything we got and calculated. Log.d(TAG, "score: " + score); Log.d(TAG, "levelCompleted: " + levelCompleted); Log.d(TAG, "thermalGoal: " + String.valueOf(thermalGoal)); Log.d(TAG, "kineticGoal: " + String.valueOf(kineticGoal)); Log.d(TAG, "thermalMade: " + String.valueOf(thermalMade)); Log.d(TAG, "kineticMade: " + String.valueOf(kineticMade)); Log.d(TAG, "kineticToThermalRatioGoal: " + String.valueOf(kineticToThermalRatioGoal)); Log.d(TAG, "kineticToThermalRatioMade: " + String.valueOf(kineticToThermalRatioMade)); Log.d(TAG, "tooMuchOomph: " + String.valueOf(tooMuchOomph)); resultImg = result_images; Log.d(TAG, ">>> RESULT_IMGS RECEIVED:"); for (int i = 0; i < resultImg.length; i++) { Log.d(TAG, resultImg[i].toString()); } scoreImg = score_images; Log.d(TAG, ">>> SCORE_IMGS RECEIVED:"); for (int i = 0; i < scoreImg.length; i++) { Log.d(TAG, scoreImg[i].toString()); } } } }
From source file:com.android.contacts.list.DefaultContactBrowseListFragment.java
private void setSyncOffMsg(int reason) { final Resources resources = getResources(); switch (reason) { case SyncUtil.SYNC_SETTING_GLOBAL_SYNC_OFF: mAlertText.setText(resources.getString(R.string.auto_sync_off)); break;/*from www .j ava 2 s .c o m*/ case SyncUtil.SYNC_SETTING_ACCOUNT_SYNC_OFF: mAlertText.setText(resources.getString(R.string.account_sync_off)); break; default: } }
From source file:com.hichinaschool.flashcards.anki.Feedback.java
private void refreshInterface() { if (mAllowFeedback) { Resources res = getResources(); Button btnSend = (Button) findViewById(R.id.btnFeedbackSend); Button btnKeepLatest = (Button) findViewById(R.id.btnFeedbackKeepLatest); Button btnClearAll = (Button) findViewById(R.id.btnFeedbackClearAll); ProgressBar pbSpinner = (ProgressBar) findViewById(R.id.pbFeedbackSpinner); int numErrors = mErrorReports.size(); if (numErrors == 0 || mErrorsSent) { if (!mErrorsSent) { mLvErrorList.setVisibility(View.GONE); }//from w ww . java 2 s. c o m btnKeepLatest.setVisibility(View.GONE); btnClearAll.setVisibility(View.GONE); btnSend.setText(res.getString(R.string.feedback_send_feedback)); } else { mLvErrorList.setVisibility(View.VISIBLE); btnKeepLatest.setVisibility(View.VISIBLE); btnClearAll.setVisibility(View.VISIBLE); btnSend.setText(res.getString(R.string.feedback_send_feedback_and_errors)); refreshErrorListView(); if (numErrors == 1) { btnKeepLatest.setEnabled(false); } else { btnKeepLatest.setEnabled(true); } } if (mPostingFeedback) { int buttonHeight = btnSend.getHeight(); btnSend.setVisibility(View.GONE); pbSpinner.setVisibility(View.VISIBLE); LinearLayout topLine = (LinearLayout) findViewById(R.id.llFeedbackTopLine); topLine.setMinimumHeight(buttonHeight); mEtFeedbackText.setEnabled(false); mImm.hideSoftInputFromWindow(mEtFeedbackText.getWindowToken(), 0); } else { btnSend.setVisibility(View.VISIBLE); pbSpinner.setVisibility(View.GONE); mEtFeedbackText.setEnabled(true); } } }
From source file:com.kjsaw.alcosys.ibacapp.IBAC.java
private void showAppVersion() { try {//from w w w. j ava2 s .c o m PackageManager manager = this.getPackageManager(); Resources resource = this.getResources(); String versionLabel = resource.getString(R.string.app_version_label) + " "; PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0); String versionNumber = info.versionName; textViewAppVersion.setText(versionLabel + versionNumber); } catch (NameNotFoundException e) { Logging.d("AppVersionNotFound: " + e.getMessage()); } }
From source file:com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (getShowsDialog()) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); }/*w ww . j a v a 2 s .co m*/ View view = inflater.inflate(R.layout.radial_time_picker_dialog, null); KeyboardListener keyboardListener = new KeyboardListener(); view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener); Resources res = getResources(); TypedArray themeColors = getActivity().obtainStyledAttributes(mStyleResId, R.styleable.BetterPickersRadialTimePickerDialog); mHourPickerDescription = res.getString(R.string.hour_picker_description); mSelectHours = res.getString(R.string.select_hours); mMinutePickerDescription = res.getString(R.string.minute_picker_description); mSelectMinutes = res.getString(R.string.select_minutes); mSelectedColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpAccentColor, R.color.bpBlue); mUnselectedColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainTextColor, R.color.numbers_text_color); mHourView = (TextView) view.findViewById(R.id.hours); mHourView.setOnKeyListener(keyboardListener); mHourSpaceView = (TextView) view.findViewById(R.id.hour_space); mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space); mMinuteView = (TextView) view.findViewById(R.id.minutes); mMinuteView.setOnKeyListener(keyboardListener); mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label); mAmPmTextView.setOnKeyListener(keyboardListener); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0]; mPmText = amPmTexts[1]; mHapticFeedbackController = new HapticFeedbackController(getActivity()); mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker); mTimePicker.setOnValueSelectedListener(this); mTimePicker.setOnKeyListener(keyboardListener); mTimePicker.initialize(getActivity(), mHapticFeedbackController, mInitialHourOfDay, mInitialMinute, mIs24HourMode); int currentItemShowing = HOUR_INDEX; if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) { currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING); } setCurrentItemShowing(currentItemShowing, false, true, true); mTimePicker.invalidate(); mHourView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(HOUR_INDEX, true, false, true); tryVibrate(); } }); mMinuteView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(MINUTE_INDEX, true, false, true); tryVibrate(); } }); mDoneButton = (TextView) view.findViewById(R.id.done_button); if (mDoneText != null) { mDoneButton.setText(mDoneText); } mDoneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mInKbMode && isTypedTimeFullyLegal()) { finishKbMode(false); } else { tryVibrate(); } if (mCallback != null) { mCallback.onTimeSet(RadialTimePickerDialog.this, mTimePicker.getHours(), mTimePicker.getMinutes()); } dismiss(); } }); mDoneButton.setOnKeyListener(keyboardListener); // Enable or disable the AM/PM view. mAmPmHitspace = view.findViewById(R.id.ampm_hitspace); if (mIs24HourMode) { mAmPmTextView.setVisibility(View.GONE); RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT); TextView separatorView = (TextView) view.findViewById(R.id.separator); separatorView.setLayoutParams(paramsSeparator); } else { mAmPmTextView.setVisibility(View.VISIBLE); updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM); mAmPmHitspace.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); int amOrPm = mTimePicker.getIsCurrentlyAmOrPm(); if (amOrPm == AM) { amOrPm = PM; } else if (amOrPm == PM) { amOrPm = AM; } updateAmPmDisplay(amOrPm); mTimePicker.setAmOrPm(amOrPm); } }); } mAllowAutoAdvance = true; setHour(mInitialHourOfDay, true); setMinute(mInitialMinute); // Set up for keyboard mode. mDoublePlaceholderText = res.getString(R.string.time_placeholder); mDeletedKeyFormat = res.getString(R.string.deleted_key); mPlaceholderText = mDoublePlaceholderText.charAt(0); mAmKeyCode = mPmKeyCode = -1; generateLegalTimesTree(); if (mInKbMode) { mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES); tryStartingKbMode(-1); mHourView.invalidate(); } else if (mTypedTimes == null) { mTypedTimes = new ArrayList<Integer>(); } // Set the theme at the end so that the initialize()s above don't counteract the theme. mTimePicker.setTheme(themeColors); // Prepare some colors to use. int mainColor1 = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainColor1, R.color.bpWhite); int mainColor2 = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainColor2, R.color.circle_background); int lineColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpLineColor, R.color.bpLine_background); int mainTextColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainTextColor, R.color.numbers_text_color); ColorStateList doneTextColor = themeColors .getColorStateList(R.styleable.BetterPickersRadialTimePickerDialog_bpDoneTextColor); int doneBackground = themeColors.getResourceId( R.styleable.BetterPickersRadialTimePickerDialog_bpDoneBackgroundColor, R.drawable.done_background_color); // Set the colors for each view based on the theme. view.findViewById(R.id.time_display_background).setBackgroundColor(mainColor1); view.findViewById(R.id.time_display).setBackgroundColor(mainColor1); ((TextView) view.findViewById(R.id.separator)).setTextColor(mainTextColor); ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mainTextColor); view.findViewById(R.id.line).setBackgroundColor(lineColor); mDoneButton.setTextColor(doneTextColor); mTimePicker.setBackgroundColor(mainColor2); mDoneButton.setBackgroundResource(doneBackground); return view; }