Search in sources :

Example 51 with Activity

use of android.app.Activity in project android-betterpickers by code-troopers.

the class ExpirationPickerDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.expiration_picker_dialog, container, false);
    Button doneButton = (Button) view.findViewById(R.id.done_button);
    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
    cancelButton.setTextColor(mTextColor);
    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            dismiss();
        }
    });
    doneButton.setTextColor(mTextColor);
    doneButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            for (ExpirationPickerDialogHandler handler : mExpirationPickerDialogHandlers) {
                handler.onDialogExpirationSet(mReference, mPicker.getYear(), mPicker.getMonthOfYear());
            }
            final Activity activity = getActivity();
            final Fragment fragment = getTargetFragment();
            if (activity instanceof ExpirationPickerDialogHandler) {
                final ExpirationPickerDialogHandler act = (ExpirationPickerDialogHandler) activity;
                act.onDialogExpirationSet(mReference, mPicker.getYear(), mPicker.getMonthOfYear());
            } else if (fragment instanceof ExpirationPickerDialogHandler) {
                final ExpirationPickerDialogHandler frag = (ExpirationPickerDialogHandler) fragment;
                frag.onDialogExpirationSet(mReference, mPicker.getYear(), mPicker.getMonthOfYear());
            }
            dismiss();
        }
    });
    mPicker = (ExpirationPicker) view.findViewById(R.id.expiration_picker);
    mPicker.setSetButton(doneButton);
    mPicker.setTheme(mTheme);
    if (mMinimumYear != 0) {
        mPicker.setMinYear(mMinimumYear);
    }
    if (mMonthOfYear != -1 || mYear != 0) {
        mPicker.setExpiration(mYear, mMonthOfYear);
    }
    getDialog().getWindow().setBackgroundDrawableResource(mDialogBackgroundResId);
    return view;
}
Also used : Button(android.widget.Button) Activity(android.app.Activity) View(android.view.View) Fragment(android.support.v4.app.Fragment) DialogFragment(android.support.v4.app.DialogFragment)

Example 52 with Activity

use of android.app.Activity in project android-betterpickers by code-troopers.

the class HmsPickerDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.hms_picker_dialog, container, false);
    Button doneButton = (Button) view.findViewById(R.id.done_button);
    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
    cancelButton.setTextColor(mTextColor);
    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            HmsPickerDialogFragment.this.dismiss();
        }
    });
    doneButton.setTextColor(mTextColor);
    doneButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            for (HmsPickerDialogHandlerV2 handler : mHmsPickerDialogHandlerV2s) {
                handler.onDialogHmsSet(mReference, mPicker.isNegative(), mPicker.getHours(), mPicker.getMinutes(), mPicker.getSeconds());
            }
            final Activity activity = getActivity();
            final Fragment fragment = getTargetFragment();
            if (activity instanceof HmsPickerDialogHandlerV2) {
                final HmsPickerDialogHandlerV2 act = (HmsPickerDialogHandlerV2) activity;
                act.onDialogHmsSet(mReference, mPicker.isNegative(), mPicker.getHours(), mPicker.getMinutes(), mPicker.getSeconds());
            } else if (fragment instanceof HmsPickerDialogHandlerV2) {
                final HmsPickerDialogHandlerV2 frag = (HmsPickerDialogHandlerV2) fragment;
                frag.onDialogHmsSet(mReference, mPicker.isNegative(), mPicker.getHours(), mPicker.getMinutes(), mPicker.getSeconds());
            }
            dismiss();
        }
    });
    mPicker = (HmsPicker) view.findViewById(R.id.hms_picker);
    mPicker.setSetButton(doneButton);
    mPicker.setTime(mHours, mMinutes, mSeconds);
    mPicker.setTheme(mTheme);
    mPicker.setPlusMinusVisibility(mPlusMinusVisibility);
    getDialog().getWindow().setBackgroundDrawableResource(mDialogBackgroundResId);
    return view;
}
Also used : Button(android.widget.Button) Activity(android.app.Activity) View(android.view.View) Fragment(android.support.v4.app.Fragment) DialogFragment(android.support.v4.app.DialogFragment)

Example 53 with Activity

use of android.app.Activity in project android-betterpickers by code-troopers.

the class NumberPickerDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.number_picker_dialog, container, false);
    Button doneButton = (Button) view.findViewById(R.id.done_button);
    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
    cancelButton.setTextColor(mTextColor);
    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            dismiss();
        }
    });
    doneButton.setTextColor(mTextColor);
    doneButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            BigDecimal number = mPicker.getEnteredNumber();
            if (mMinNumber != null && mMaxNumber != null && (isSmaller(number) || isBigger(number))) {
                String errorText = getString(R.string.min_max_error, mMinNumber, mMaxNumber);
                mPicker.getErrorView().setText(errorText);
                mPicker.getErrorView().show();
                return;
            } else if (mMinNumber != null && isSmaller(number)) {
                String errorText = getString(R.string.min_error, mMinNumber);
                mPicker.getErrorView().setText(errorText);
                mPicker.getErrorView().show();
                return;
            } else if (mMaxNumber != null && isBigger(number)) {
                String errorText = getString(R.string.max_error, mMaxNumber);
                mPicker.getErrorView().setText(errorText);
                mPicker.getErrorView().show();
                return;
            }
            for (NumberPickerDialogHandlerV2 handler : mNumberPickerDialogHandlersV2) {
                handler.onDialogNumberSet(mReference, mPicker.getNumber(), mPicker.getDecimal(), mPicker.getIsNegative(), number);
            }
            final Activity activity = getActivity();
            final Fragment fragment = getTargetFragment();
            if (activity instanceof NumberPickerDialogHandlerV2) {
                final NumberPickerDialogHandlerV2 act = (NumberPickerDialogHandlerV2) activity;
                act.onDialogNumberSet(mReference, mPicker.getNumber(), mPicker.getDecimal(), mPicker.getIsNegative(), number);
            } else if (fragment instanceof NumberPickerDialogHandlerV2) {
                final NumberPickerDialogHandlerV2 frag = (NumberPickerDialogHandlerV2) fragment;
                frag.onDialogNumberSet(mReference, mPicker.getNumber(), mPicker.getDecimal(), mPicker.getIsNegative(), number);
            }
            dismiss();
        }
    });
    mPicker = (NumberPicker) view.findViewById(R.id.number_picker);
    mPicker.setSetButton(doneButton);
    mPicker.setTheme(mTheme);
    mPicker.setDecimalVisibility(mDecimalVisibility);
    mPicker.setPlusMinusVisibility(mPlusMinusVisibility);
    mPicker.setLabelText(mLabelText);
    if (mMinNumber != null) {
        mPicker.setMin(mMinNumber);
    }
    if (mMaxNumber != null) {
        mPicker.setMax(mMaxNumber);
    }
    mPicker.setNumber(mCurrentNumber, mCurrentDecimal, mCurrentSign);
    getDialog().getWindow().setBackgroundDrawableResource(mDialogBackgroundResId);
    return view;
}
Also used : Button(android.widget.Button) Activity(android.app.Activity) View(android.view.View) Fragment(android.support.v4.app.Fragment) DialogFragment(android.support.v4.app.DialogFragment) BigDecimal(java.math.BigDecimal)

Example 54 with Activity

use of android.app.Activity in project Etar-Calendar by Etar-Group.

the class GeneralPreferences method showTimezoneDialog.

private void showTimezoneDialog() {
    final Activity activity = getActivity();
    if (activity == null) {
        return;
    }
    Bundle b = new Bundle();
    b.putLong(TimeZonePickerDialog.BUNDLE_START_TIME_MILLIS, System.currentTimeMillis());
    b.putString(TimeZonePickerDialog.BUNDLE_TIME_ZONE, Utils.getTimeZone(activity, null));
    FragmentManager fm = getActivity().getFragmentManager();
    TimeZonePickerDialog tzpd = (TimeZonePickerDialog) fm.findFragmentByTag(FRAG_TAG_TIME_ZONE_PICKER);
    if (tzpd != null) {
        tzpd.dismiss();
    }
    tzpd = new TimeZonePickerDialog();
    tzpd.setArguments(b);
    tzpd.setOnTimeZoneSetListener(this);
    tzpd.show(fm, FRAG_TAG_TIME_ZONE_PICKER);
}
Also used : FragmentManager(android.app.FragmentManager) Bundle(android.os.Bundle) Activity(android.app.Activity) TimeZonePickerDialog(com.android.timezonepicker.TimeZonePickerDialog)

Example 55 with Activity

use of android.app.Activity in project Etar-Calendar by Etar-Group.

the class OtherPreferences method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    PreferenceManager manager = getPreferenceManager();
    manager.setSharedPreferencesName(SHARED_PREFS_NAME);
    SharedPreferences prefs = manager.getSharedPreferences();
    addPreferencesFromResource(R.xml.other_preferences);
    mCopyDb = findPreference(KEY_OTHER_COPY_DB);
    mSkipReminders = (ListPreference) findPreference(KEY_OTHER_REMINDERS_RESPONDED);
    String skipPreferencesValue = null;
    if (mSkipReminders != null) {
        skipPreferencesValue = mSkipReminders.getValue();
        mSkipReminders.setOnPreferenceChangeListener(this);
    }
    updateSkipRemindersSummary(skipPreferencesValue);
    Activity activity = getActivity();
    if (activity == null) {
        Log.d(TAG, "Activity was null");
    }
    mIs24HourMode = DateFormat.is24HourFormat(activity);
    mQuietHours = (CheckBoxPreference) findPreference(KEY_OTHER_QUIET_HOURS);
    int startHour = prefs.getInt(KEY_OTHER_QUIET_HOURS_START_HOUR, QUIET_HOURS_DEFAULT_START_HOUR);
    int startMinute = prefs.getInt(KEY_OTHER_QUIET_HOURS_START_MINUTE, QUIET_HOURS_DEFAULT_START_MINUTE);
    mQuietHoursStart = findPreference(KEY_OTHER_QUIET_HOURS_START);
    mQuietHoursStartListener = new TimeSetListener(START_LISTENER);
    mQuietHoursStartDialog = new TimePickerDialog(activity, mQuietHoursStartListener, startHour, startMinute, mIs24HourMode);
    mQuietHoursStart.setSummary(formatTime(startHour, startMinute));
    int endHour = prefs.getInt(KEY_OTHER_QUIET_HOURS_END_HOUR, QUIET_HOURS_DEFAULT_END_HOUR);
    int endMinute = prefs.getInt(KEY_OTHER_QUIET_HOURS_END_MINUTE, QUIET_HOURS_DEFAULT_END_MINUTE);
    mQuietHoursEnd = findPreference(KEY_OTHER_QUIET_HOURS_END);
    mQuietHoursEndListener = new TimeSetListener(END_LISTENER);
    mQuietHoursEndDialog = new TimePickerDialog(activity, mQuietHoursEndListener, endHour, endMinute, mIs24HourMode);
    mQuietHoursEnd.setSummary(formatTime(endHour, endMinute));
}
Also used : SharedPreferences(android.content.SharedPreferences) Activity(android.app.Activity) TimePickerDialog(android.app.TimePickerDialog) PreferenceManager(android.preference.PreferenceManager)

Aggregations

Activity (android.app.Activity)3220 Intent (android.content.Intent)612 View (android.view.View)535 Test (org.junit.Test)456 TextView (android.widget.TextView)263 Context (android.content.Context)220 ArrayList (java.util.ArrayList)201 Bundle (android.os.Bundle)197 DialogInterface (android.content.DialogInterface)167 SettingsActivity (com.android.settings.SettingsActivity)167 ViewGroup (android.view.ViewGroup)133 ImageView (android.widget.ImageView)116 AlertDialog (android.app.AlertDialog)109 LayoutInflater (android.view.LayoutInflater)109 Preference (android.support.v7.preference.Preference)83 PackageManager (android.content.pm.PackageManager)76 Uri (android.net.Uri)76 EditText (android.widget.EditText)72 ComponentName (android.content.ComponentName)71 Handler (android.os.Handler)71