List of usage examples for android.widget RelativeLayout CENTER_IN_PARENT
int CENTER_IN_PARENT
To view the source code for android.widget RelativeLayout CENTER_IN_PARENT.
Click Source Link
From source file:com.grottworkshop.gwsdatetimepicker.TimePickerDialog.java
@SuppressWarnings("deprecation") @Override/* ww w.j ava2 s . c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); @SuppressLint("InflateParams") View view = inflater.inflate(R.layout.time_picker_dialog, null); KeyboardListener keyboardListener = new KeyboardListener(); view.setOnKeyListener(keyboardListener); Resources res = getResources(); 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); //TODO: getColor is depreciated mBlue = res.getColor(R.color.blue); //TODO: getColor is depreciated mBlack = res.getColor(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); if (Build.VERSION.SDK_INT <= 14) { mAmPmTextView.setTransformationMethod(new TransformationMethod() { private final Locale locale = getResources().getConfiguration().locale; @Override public CharSequence getTransformation(CharSequence source, View view) { return source != null ? source.toString().toUpperCase(locale) : null; } @Override public void onFocusChanged(View view, CharSequence sourceText, boolean focused, int direction, Rect previouslyFocusedRect) { } }); } String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0]; mPmText = amPmTexts[1]; mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker); mTimePicker.setOnValueSelectedListener(this); mTimePicker.setOnKeyListener(keyboardListener); mTimePicker.initialize(getActivity(), mInitialHourOfDay, mInitialMinute, mIs24HourMode, mVibrate); 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); mTimePicker.tryVibrate(); } }); mMinuteView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(MINUTE_INDEX, true, false, true); mTimePicker.tryVibrate(); } }); mDoneButton = (TextView) view.findViewById(R.id.done_button); mDoneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onDoneButtonClick(); } }); 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) { mTimePicker.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) { if (savedInstanceState != null) { mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES); } tryStartingKbMode(-1); mHourView.invalidate(); } else if (mTypedTimes == null) { mTypedTimes = new ArrayList<>(); } return view; }
From source file:com.azuyo.happybeing.fourmob.timepicker.TimePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.time_picker_dialog, null); KeyboardListener keyboardListener = new KeyboardListener(); view.setOnKeyListener(keyboardListener); Resources res = getResources(); 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); mBlue = res.getColor(R.color.app_blue); mBlack = res.getColor(R.color.numbers_text_color); mWhite = res.getColor(R.color.white); 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); if (Build.VERSION.SDK_INT <= 14) { mAmPmTextView.setTransformationMethod(new TransformationMethod() { private final Locale locale = getResources().getConfiguration().locale; @Override// ww w .ja v a 2 s. c o m public CharSequence getTransformation(CharSequence source, View view) { return source != null ? source.toString().toUpperCase(locale) : null; } @Override public void onFocusChanged(View view, CharSequence sourceText, boolean focused, int direction, Rect previouslyFocusedRect) { } }); } String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0]; mPmText = amPmTexts[1]; mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker); mTimePicker.setOnValueSelectedListener(this); mTimePicker.setOnKeyListener(keyboardListener); mTimePicker.initialize(getActivity(), mInitialHourOfDay, mInitialMinute, mIs24HourMode, mVibrate); 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); mTimePicker.tryVibrate(); } }); mMinuteView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(MINUTE_INDEX, true, false, true); mTimePicker.tryVibrate(); } }); mCancelButton = (TextView) view.findViewById(R.id.cancel_button); mDoneButton = (TextView) view.findViewById(R.id.done_button); mCancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); mCancelButton.setOnKeyListener(keyboardListener); mDoneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onDoneButtonClick(); } }); 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) { mTimePicker.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>(); } return view; }
From source file:com.example.pickerclickcar.time.TimePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.time_picker_dialog, null); KeyboardListener keyboardListener = new KeyboardListener(); view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener); Resources res = getResources(); 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 = res.getColor(mThemeDark ? R.color.red : R.color.white); mUnselectedColor = res.getColor(mThemeDark ? android.R.color.white : R.color.blue_focused); 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];//from w ww . ja va2 s .c om 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, mMinHour, mMaxHour, mMinMinute, mMaxMinute); 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); mDoneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mInKbMode && isTypedTimeFullyLegal()) { finishKbMode(false); } else { tryVibrate(); } if (mCallback != null) { mCallback.onTimeSet(mTimePicker, mTimePicker.getHours(), mTimePicker.getMinutes()); } dismiss(); } }); mCancelButton = (Button) view.findViewById(R.id.cancel_button); mCancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { 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(getActivity().getApplicationContext(), mThemeDark); // Prepare some colors to use. int white = res.getColor(R.color.mainblue); int sep = res.getColor(R.color.blue_focused); int circleBackground = res.getColor(R.color.white); int line = res.getColor(R.color.mainblue); int timeDisplay = res.getColor(R.color.numbers_text_color); ColorStateList doneTextColor = res.getColorStateList(R.color.done_text_color); int doneBackground = R.drawable.done_background_color; int darkGray = res.getColor(R.color.dark_gray); int lightGray = res.getColor(R.color.circle_background); int darkLine = res.getColor(R.color.mainblue); ColorStateList darkDoneTextColor = res.getColorStateList(R.color.mainblue); int darkDoneBackground = R.drawable.done_background_color_dark; // Set the colors for each view based on the theme. view.findViewById(R.id.time_display_background).setBackgroundColor(white); view.findViewById(R.id.time_display).setBackgroundColor(mThemeDark ? darkGray : white); ((TextView) view.findViewById(R.id.separator)).setTextColor(sep); ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mThemeDark ? white : timeDisplay); view.findViewById(R.id.line).setBackgroundColor(line); mDoneButton.setTextColor(white); mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground); mDoneButton.setBackgroundColor(circleBackground); mCancelButton.setBackgroundColor(circleBackground); return view; }
From source file:com.philliphsu.bottomsheetpickers.time.grid.GridTimePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); KeyboardListener keyboardListener = new KeyboardListener(); view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener); if (!mThemeSetAtRuntime) { mThemeDark = Utils.isDarkTheme(getActivity(), mThemeDark); }/* ww w .ja v a 2 s . c o m*/ final Resources res = getResources(); final Context ctx = getActivity(); 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 = getColor(ctx, android.R.color.white); mUnselectedColor = getColor(ctx, R.color.unselected_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]; // TODO: Restore // mHapticFeedbackController = new HapticFeedbackController(getActivity()); mTimePicker = (GridPickerLayout) 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 = (FloatingActionButton) view.findViewById(R.id.fab); mDoneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mInKbMode && isTypedTimeFullyLegal()) { finishKbMode(false); } else { tryVibrate(); } onTimeSet(mTimePicker, mTimePicker.getHours(), mTimePicker.getMinutes()); } }); mDoneButton.setOnKeyListener(keyboardListener); // TODO: setOnKeyListener? mFirstHalfDayToggle = (Button) view.findViewById(R.id.half_day_toggle_1); mFirstHalfDayToggle.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryToggleHalfDay(HALF_DAY_1); } }); // TODO: setOnKeyListener? mSecondHalfDayToggle = (Button) view.findViewById(R.id.half_day_toggle_2); mSecondHalfDayToggle.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryToggleHalfDay(HALF_DAY_2); } }); // 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); mFirstHalfDayToggle.setText(R.string.hours_00_11); mSecondHalfDayToggle.setText(R.string.hours_12_23); // We need different drawable resources for each case, not a single one that we // just tint differently, because the orientation of each one is different. final int icon1 = mThemeDark ? R.drawable.ic_half_day_1_dark_24dp : R.drawable.ic_half_day_1_24dp; final int icon2 = mThemeDark ? R.drawable.ic_half_day_2_dark_24dp : R.drawable.ic_half_day_2_24dp; mFirstHalfDayToggle.setCompoundDrawablesWithIntrinsicBounds(0, icon1, 0, 0); mSecondHalfDayToggle.setCompoundDrawablesWithIntrinsicBounds(0, icon2, 0, 0); } else { mAmPmTextView.setVisibility(View.VISIBLE); mAmPmHitspace.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); int amOrPm = mTimePicker.getIsCurrentlyAmOrPm(); if (amOrPm == HALF_DAY_1) { amOrPm = HALF_DAY_2; } else if (amOrPm == HALF_DAY_2) { amOrPm = HALF_DAY_1; } updateHalfDay(amOrPm); mTimePicker.setHalfDay(amOrPm); } }); mFirstHalfDayToggle.setText(mAmText); mSecondHalfDayToggle.setText(mPmText); } 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. // // If you decide to move the FAB and the half day toggles to the GridPickerLayout // class, you should remove getApplicationContext(). Otherwise, you would not // retrieve the correct accent color. mTimePicker.setTheme(getActivity().getApplicationContext(), mThemeDark); // Prepare some colors to use. final int white = getColor(ctx, android.R.color.white); final int darkGray = getColor(ctx, R.color.dark_gray); final int lightGray = getColor(ctx, R.color.light_gray); final int accentColor = Utils.getThemeAccentColor(getActivity()); final int sidebarDark = getColor(ctx, R.color.sidebar_color_dark); final int sidebarLight = getColor(ctx, R.color.sidebar_color_light); // Set the whole view's background color first view.setBackgroundColor(mThemeDark ? darkGray : white); // Set the colors for each view based on the theme. view.findViewById(R.id.time_display_background).setBackgroundColor(mThemeDark ? lightGray : accentColor); view.findViewById(R.id.time_display).setBackgroundColor(mThemeDark ? lightGray : accentColor); ((TextView) view.findViewById(R.id.separator)).setTextColor(mUnselectedColor); ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mUnselectedColor); view.findViewById(R.id.sidebar).setBackgroundColor(mThemeDark ? sidebarDark : sidebarLight); // Color in normal state mDoneButton.setBackgroundTintList(ColorStateList.valueOf(accentColor)); //TODO mDoneButton.setRippleColor(); mHalfDayToggleSelectedColor = accentColor; mHalfDayToggleUnselectedColor = getColor(ctx, mThemeDark ? R.color.text_color_primary_dark : R.color.text_color_primary_light); Utils.setColorControlHighlight(mFirstHalfDayToggle, accentColor); Utils.setColorControlHighlight(mSecondHalfDayToggle, accentColor); // Update the half day at the end when the state colors have been initialized updateHalfDay(mInitialHourOfDay < 12 ? HALF_DAY_1 : HALF_DAY_2); return view; }
From source file:com.doomonafireball.betterpickers.radialtimepicker.RadialTimePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (getShowsDialog()) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); }/* ww w.ja v a2s . c o 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(); 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 = res.getColor(mThemeDark ? R.color.red : R.color.blue); mUnselectedColor = res.getColor(mThemeDark ? R.color.white : 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(getActivity().getApplicationContext(), mThemeDark); // Prepare some colors to use. int white = res.getColor(R.color.white); int circleBackground = res.getColor(R.color.circle_background); int line = res.getColor(R.color.line_background); int timeDisplay = res.getColor(R.color.numbers_text_color); ColorStateList doneTextColor = res.getColorStateList(R.color.done_text_color); int doneBackground = R.drawable.done_background_color; int darkGray = res.getColor(R.color.dark_gray); int lightGray = res.getColor(R.color.light_gray); int darkLine = res.getColor(R.color.line_dark); ColorStateList darkDoneTextColor = res.getColorStateList(R.color.done_text_color_dark); int darkDoneBackground = R.drawable.done_background_color_dark; // Set the colors for each view based on the theme. view.findViewById(R.id.time_display_background).setBackgroundColor(mThemeDark ? darkGray : white); view.findViewById(R.id.time_display).setBackgroundColor(mThemeDark ? darkGray : white); ((TextView) view.findViewById(R.id.separator)).setTextColor(mThemeDark ? white : timeDisplay); ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mThemeDark ? white : timeDisplay); view.findViewById(R.id.line).setBackgroundColor(mThemeDark ? darkLine : line); mDoneButton.setTextColor(mThemeDark ? darkDoneTextColor : doneTextColor); mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground); mDoneButton.setBackgroundResource(mThemeDark ? darkDoneBackground : doneBackground); return view; }
From source file:com.philliphsu.hybridtimepicker.HybridTimePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.hybrid_time_picker_dialog, null); KeyboardListener keyboardListener = new KeyboardListener(); view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener); Resources res = getResources(); 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); // TODO: Rename variable to mAccentColor mSelectedColor = //res.getColor(mThemeDark? R.color.red : R.color.blue); Utils.getAccentColorFromThemeIfAvailable(getActivity()); mUnselectedColor = res.getColor(mThemeDark ? android.R.color.white : 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];/*from www . j av a 2s . c o m*/ mPmText = amPmTexts[1]; mHapticFeedbackController = new HapticFeedbackController(getActivity()); mGridPicker = (GridPickerLayout) view.findViewById(R.id.time_picker); mGridPicker.setOnValueSelectedListener(this); // TODO: Adapt to my GridPickerLayout // mTimePicker.setOnKeyListener(keyboardListener); mGridPicker.initialize(getActivity(), /*mHapticFeedbackController,*/ this, 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); mGridPicker.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(); } }); mCancelButton = (TextView) view.findViewById(R.id.cancel_button); mCancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mInKbMode && isTypedTimeFullyLegal()) { finishKbMode(false); } else { tryVibrate(); } // TODO: Do we need to fire a OnDialogCancel event? dismiss(); } }); mCancelButton.setOnKeyListener(keyboardListener); mDoneButton = (TextView) view.findViewById(R.id.done_button); mDoneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mInKbMode && isTypedTimeFullyLegal()) { finishKbMode(false); } else { tryVibrate(); } if (mCallback != null) { mCallback.onTimeSet(mGridPicker, mGridPicker.getHours(), mGridPicker.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 = mGridPicker.getIsCurrentlyAmOrPm(); if (amOrPm == AM) { amOrPm = PM; } else if (amOrPm == PM) { amOrPm = AM; } updateAmPmDisplay(amOrPm); mGridPicker.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. mGridPicker.setTheme(getActivity().getApplicationContext(), mThemeDark); // Prepare some colors to use. int white = res.getColor(android.R.color.white); // int circleBackground = res.getColor(R.color.circle_background); // int line = res.getColor(R.color.line_background); int timeDisplay = res.getColor(R.color.numbers_text_color); // We'll just use an actual color instead of a ColorStateList for the dialog buttons since // I don't see why we would ever need to disable them. // ColorStateList dialogButtonsTextColor = res.getColorStateList(R.color.dialog_buttons_text_color); int doneBackground = R.drawable.done_background_color; int darkGray = res.getColor(R.color.dark_gray); // int lightGray = res.getColor(R.color.light_gray); // int darkLine = res.getColor(R.color.line_dark); // TODO: We don't have an accent color variant for the dark theme, so leave it off for now. // ColorStateList darkDialogButtonsTextColor = res.getColorStateList(R.color.dialog_buttons_text_color_dark); int darkDoneBackground = R.drawable.done_background_color_dark; // Set the colors for each view based on the theme. view.findViewById(R.id.time_display_background).setBackgroundColor(mThemeDark ? darkGray : white); view.findViewById(R.id.time_display).setBackgroundColor(mThemeDark ? darkGray : white); ((TextView) view.findViewById(R.id.separator)).setTextColor(mThemeDark ? white : timeDisplay); ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mThemeDark ? white : timeDisplay); // view.findViewById(R.id.line).setBackgroundColor(mThemeDark? darkLine : line); mDoneButton.setTextColor(mSelectedColor); // accent color mCancelButton.setTextColor(mSelectedColor); // accent color mGridPicker.setBackgroundColor(mThemeDark ? darkGray : white); ((LinearLayout) view.findViewById(R.id.dialog_buttons)).setBackgroundColor(mThemeDark ? darkGray : white); return view; }
From source file:jp.seesaa.android.datetimepicker.time.TimePickerDialog.java
public View createView(LayoutInflater inflater, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.dtp_time_picker_dialog, null); KeyboardListener keyboardListener = new KeyboardListener(); view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener); Resources res = getResources(); mHourPickerDescription = res.getString(R.string.dtp_hour_picker_description); mSelectHours = res.getString(R.string.dtp_select_hours); mMinutePickerDescription = res.getString(R.string.dtp_minute_picker_description); mSelectMinutes = res.getString(R.string.dtp_select_minutes); mSelectedColor = res.getColor(mThemeDark ? R.color.dtp_red : R.color.dtp_blue); mUnselectedColor = res.getColor(mThemeDark ? R.color.dtp_white : R.color.dtp_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];/*from ww w . j a va 2 s . c o m*/ 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); // mDoneButton.setOnClickListener(new OnClickListener() { // @Override // public void onClick(View v) { // if (mInKbMode && isTypedTimeFullyLegal()) { // finishKbMode(false); // } else { // tryVibrate(); // } // if (mCallback != null) { // mCallback.onTimeSet(mTimePicker, // 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.dtp_time_placeholder); mDeletedKeyFormat = res.getString(R.string.dtp_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(getActivity().getApplicationContext(), mThemeDark); // Prepare some colors to use. int white = res.getColor(R.color.dtp_white); int circleBackground = res.getColor(R.color.dtp_circle_background); int line = res.getColor(R.color.dtp_line_background); int timeDisplay = res.getColor(R.color.dtp_numbers_text_color); ColorStateList doneTextColor = res.getColorStateList(R.color.dtp_done_text_color); int doneBackground = R.drawable.dtp_done_background_color; int darkGray = res.getColor(R.color.dtp_dark_gray); int lightGray = res.getColor(R.color.dtp_light_gray); int darkLine = res.getColor(R.color.dtp_line_dark); ColorStateList darkDoneTextColor = res.getColorStateList(R.color.dtp_done_text_color_dark); int darkDoneBackground = R.drawable.dtp_done_background_color_dark; // Set the colors for each view based on the theme. view.findViewById(R.id.time_display_background).setBackgroundColor(mThemeDark ? darkGray : white); view.findViewById(R.id.time_display).setBackgroundColor(mThemeDark ? darkGray : white); ((TextView) view.findViewById(R.id.separator)).setTextColor(mThemeDark ? white : timeDisplay); ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mThemeDark ? white : timeDisplay); // view.findViewById(R.id.line).setBackgroundColor(mThemeDark ? darkLine : line); // mDoneButton.setTextColor(mThemeDark ? darkDoneTextColor : doneTextColor); mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground); // mDoneButton.setBackgroundResource(mThemeDark ? darkDoneBackground : doneBackground); return view; }
From source file:com.example.damerap_ver1.IntroVideoActivity.java
/** * Create the view in which the video will be rendered. *///from ww w.j av a2 s . c o m private void setupView() { LinearLayout lLinLayout = new LinearLayout(this); lLinLayout.setId(1); lLinLayout.setOrientation(LinearLayout.VERTICAL); lLinLayout.setGravity(Gravity.CENTER); lLinLayout.setBackgroundColor(Color.BLACK); LayoutParams lLinLayoutParms = new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); lLinLayout.setLayoutParams(lLinLayoutParms); this.setContentView(lLinLayout); RelativeLayout lRelLayout = new RelativeLayout(this); lRelLayout.setId(2); lRelLayout.setGravity(Gravity.CENTER); lRelLayout.setBackgroundColor(Color.BLACK); android.widget.RelativeLayout.LayoutParams lRelLayoutParms = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); lRelLayout.setLayoutParams(lRelLayoutParms); lLinLayout.addView(lRelLayout); mVideoView = new VideoView(this); mVideoView.setId(3); android.widget.RelativeLayout.LayoutParams lVidViewLayoutParams = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lVidViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); mVideoView.setLayoutParams(lVidViewLayoutParams); lRelLayout.addView(mVideoView); mProgressBar = new ProgressBar(this); mProgressBar.setId(4); android.widget.RelativeLayout.LayoutParams lProgressBarLayoutParms = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lProgressBarLayoutParms.addRule(RelativeLayout.CENTER_IN_PARENT); mProgressBar.setLayoutParams(lProgressBarLayoutParms); lRelLayout.addView(mProgressBar); mProgressMessage = new TextView(this); mProgressMessage.setId(5); android.widget.RelativeLayout.LayoutParams lProgressMsgLayoutParms = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lProgressMsgLayoutParms.addRule(RelativeLayout.CENTER_HORIZONTAL); lProgressMsgLayoutParms.addRule(RelativeLayout.BELOW, 4); mProgressMessage.setLayoutParams(lProgressMsgLayoutParms); mProgressMessage.setTextColor(Color.LTGRAY); mProgressMessage.setTextSize(TypedValue.COMPLEX_UNIT_PT, 8); mProgressMessage.setText("..."); lRelLayout.addView(mProgressMessage); }
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 w w . j ava 2s . 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; }
From source file:org.onebusaway.android.ui.ArrivalsListAdapterStyleB.java
@Override protected void initView(final View view, CombinedArrivalInfoStyleB combinedArrivalInfoStyleB) { final ArrivalInfo stopInfo = combinedArrivalInfoStyleB.getArrivalInfoList().get(0); final ObaArrivalInfo arrivalInfo = stopInfo.getInfo(); final Context context = getContext(); LayoutInflater inflater = LayoutInflater.from(context); TextView routeName = (TextView) view.findViewById(R.id.routeName); TextView destination = (TextView) view.findViewById(R.id.routeDestination); // TableLayout that we will fill with TableRows of arrival times TableLayout arrivalTimesLayout = (TableLayout) view.findViewById(R.id.arrivalTimeLayout); arrivalTimesLayout.removeAllViews(); Resources r = view.getResources(); ImageButton starBtn = (ImageButton) view.findViewById(R.id.route_star); starBtn.setColorFilter(r.getColor(R.color.theme_primary)); ImageButton mapImageBtn = (ImageButton) view.findViewById(R.id.mapImageBtn); mapImageBtn.setColorFilter(r.getColor(R.color.theme_primary)); ImageButton routeMoreInfo = (ImageButton) view.findViewById(R.id.route_more_info); routeMoreInfo.setColorFilter(r.getColor(R.color.switch_thumb_normal_material_dark)); starBtn.setImageResource(/*from w ww. ja v a 2s. c o m*/ stopInfo.isRouteAndHeadsignFavorite() ? R.drawable.focus_star_on : R.drawable.focus_star_off); starBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Show dialog for setting route favorite RouteFavoriteDialogFragment dialog = new RouteFavoriteDialogFragment.Builder( stopInfo.getInfo().getRouteId(), stopInfo.getInfo().getHeadsign()) .setRouteShortName(stopInfo.getInfo().getShortName()) .setRouteLongName(stopInfo.getInfo().getRouteLongName()) .setStopId(stopInfo.getInfo().getStopId()) .setFavorite(!stopInfo.isRouteAndHeadsignFavorite()).build(); dialog.setCallback(new RouteFavoriteDialogFragment.Callback() { @Override public void onSelectionComplete(boolean savedFavorite) { if (savedFavorite) { mFragment.refreshLocal(); } } }); dialog.show(mFragment.getFragmentManager(), RouteFavoriteDialogFragment.TAG); } }); // Setup map mapImageBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mFragment.showRouteOnMap(stopInfo); } }); // Setup more routeMoreInfo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mFragment.showListItemMenu(view, stopInfo); } }); routeName.setText(arrivalInfo.getShortName()); destination.setText(MyTextUtils.toTitleCase(arrivalInfo.getHeadsign())); // Loop through the arrival times and create the TableRows that contains the data for (int i = 0; i < combinedArrivalInfoStyleB.getArrivalInfoList().size(); i++) { final ArrivalInfo arrivalRow = combinedArrivalInfoStyleB.getArrivalInfoList().get(i); final ObaArrivalInfo tempArrivalInfo = arrivalRow.getInfo(); long scheduledTime = tempArrivalInfo.getScheduledArrivalTime(); // Create a new row to be added final TableRow tr = (TableRow) inflater.inflate(R.layout.arrivals_list_tr_template_style_b, null); // Layout and views to inflate from XML templates RelativeLayout layout; TextView scheduleView, estimatedView, statusView; View divider; if (i == 0) { // Use larger styled layout/view for next arrival time layout = (RelativeLayout) inflater.inflate(R.layout.arrivals_list_rl_template_style_b_large, null); scheduleView = (TextView) inflater .inflate(R.layout.arrivals_list_tv_template_style_b_schedule_large, null); estimatedView = (TextView) inflater .inflate(R.layout.arrivals_list_tv_template_style_b_estimated_large, null); statusView = (TextView) inflater.inflate(R.layout.arrivals_list_tv_template_style_b_status_large, null); } else { // Use smaller styled layout/view for further out times layout = (RelativeLayout) inflater.inflate(R.layout.arrivals_list_rl_template_style_b_small, null); scheduleView = (TextView) inflater .inflate(R.layout.arrivals_list_tv_template_style_b_schedule_small, null); estimatedView = (TextView) inflater .inflate(R.layout.arrivals_list_tv_template_style_b_estimated_small, null); statusView = (TextView) inflater.inflate(R.layout.arrivals_list_tv_template_style_b_status_small, null); } // Set arrival times and status in views scheduleView.setText(DateUtils.formatDateTime(context, scheduledTime, DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT)); if (arrivalRow.getPredicted()) { long eta = arrivalRow.getEta(); if (eta == 0) { estimatedView.setText(R.string.stop_info_eta_now); } else { estimatedView.setText(eta + " min"); } } else { estimatedView.setText(R.string.stop_info_eta_unknown); } statusView.setText(arrivalRow.getStatusText()); int colorCode = arrivalRow.getColor(); statusView.setBackgroundResource(R.drawable.round_corners_style_b_status); GradientDrawable d = (GradientDrawable) statusView.getBackground(); d.setColor(context.getResources().getColor(colorCode)); int alpha; if (i == 0) { // Set next arrival alpha = (int) (1.0f * 255); // X percent transparency } else { // Set smaller rows alpha = (int) (.35f * 255); // X percent transparency } d.setAlpha(alpha); // Set padding on status view int pSides = UIUtils.dpToPixels(context, 5); int pTopBottom = UIUtils.dpToPixels(context, 2); statusView.setPadding(pSides, pTopBottom, pSides, pTopBottom); // Add TextViews to layout layout.addView(scheduleView); layout.addView(statusView); layout.addView(estimatedView); // Make sure the TextViews align left/center/right of parent relative layout RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) scheduleView.getLayoutParams(); params1.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params1.addRule(RelativeLayout.CENTER_VERTICAL); scheduleView.setLayoutParams(params1); RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) statusView.getLayoutParams(); params2.addRule(RelativeLayout.CENTER_IN_PARENT); // Give status view a little extra margin int p = UIUtils.dpToPixels(context, 3); params2.setMargins(p, p, p, p); statusView.setLayoutParams(params2); RelativeLayout.LayoutParams params3 = (RelativeLayout.LayoutParams) estimatedView.getLayoutParams(); params3.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params3.addRule(RelativeLayout.CENTER_VERTICAL); estimatedView.setLayoutParams(params3); // Add layout to TableRow tr.addView(layout); // Add the divider, if its not the first row if (i != 0) { int dividerHeight = UIUtils.dpToPixels(context, 1); divider = inflater.inflate(R.layout.arrivals_list_divider_template_style_b, null); divider.setLayoutParams( new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, dividerHeight)); arrivalTimesLayout.addView(divider); } // Add click listener tr.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mFragment.showListItemMenu(tr, arrivalRow); } }); // Add TableRow to container layout arrivalTimesLayout.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT)); } // Show or hide reminder for this trip ContentValues values = null; if (mTripsForStop != null) { values = mTripsForStop.getValues(arrivalInfo.getTripId()); } if (values != null) { String reminderName = values.getAsString(ObaContract.Trips.NAME); TextView reminder = (TextView) view.findViewById(R.id.reminder); if (reminderName.length() == 0) { reminderName = context.getString(R.string.trip_info_noname); } reminder.setText(reminderName); Drawable d = reminder.getCompoundDrawables()[0]; d = DrawableCompat.wrap(d); DrawableCompat.setTint(d.mutate(), view.getResources().getColor(R.color.theme_primary)); reminder.setCompoundDrawables(d, null, null, null); reminder.setVisibility(View.VISIBLE); } else { // Explicitly set reminder to invisible because we might be reusing // this view. View reminder = view.findViewById(R.id.reminder); reminder.setVisibility(View.GONE); } }