Exemplo n.º 1
0
 /** Called when Android restores the activity. */
 @Override
 protected void onRestoreInstanceState(Parcelable state) {
   if (state == null || !state.getClass().equals(SavedState.class)) {
     super.onRestoreInstanceState(state);
     setTheTime(((SavedState) state).dateValue);
   } else {
     SavedState s = (SavedState) state;
     super.onRestoreInstanceState(s.getSuperState());
     setTheTime(s.dateValue);
   }
 }
Exemplo n.º 2
0
  @Override
  protected void onRestoreInstanceState(Parcelable state) {
    if (state == null || !state.getClass().equals(SavedState.class)) {
      // Didn't save state for us in onSaveInstanceState
      super.onRestoreInstanceState(state);
      return;
    }

    SavedState myState = (SavedState) state;
    super.onRestoreInstanceState(myState.getSuperState());
    setValue(myState.value);
  }
    @Override
    protected void onRestoreInstanceState(Parcelable state) {
      if (!(state instanceof SavedState)) {
        super.onRestoreInstanceState(state);
        return;
      }

      final SavedState myState = (SavedState) state;
      super.onRestoreInstanceState(myState.getSuperState());
      setSpinnerPosition(mSubtypeLocaleSpinner, myState.mSubtypeLocaleSelectedPos);
      setSpinnerPosition(mKeyboardLayoutSetSpinner, myState.mKeyboardLayoutSetSelectedPos);
      setSubtype(myState.mSubtype);
    }
  @Override
  protected void onRestoreInstanceState(Parcelable state) {
    // Check whether we saved the state in onSaveInstanceState
    if (state == null || !state.getClass().equals(SavedState.class)) {
      // Didn't save the state, so call superclass
      super.onRestoreInstanceState(state);
      return;
    }

    // Cast state to custom BaseSavedState and pass to superclass
    SavedState myState = (SavedState) state;
    super.onRestoreInstanceState(myState.getSuperState());
  }
Exemplo n.º 5
0
  @Override
  protected void onRestoreInstanceState(Parcelable state) {
    if (state == null || !state.getClass().equals(SavedState.class)) {
      // Didn't save state for us in onSaveInstanceState
      super.onRestoreInstanceState(state);
      return;
    }

    SavedState myState = (SavedState) state;
    super.onRestoreInstanceState(myState.getSuperState());
    if (myState.isDialogShowing) {
      showDialog(myState.dialogBundle);
    }
  }
Exemplo n.º 6
0
 /** Called when Android restores the activity. */
 @Override
 protected void onRestoreInstanceState(Parcelable state) {
   try {
     if (state == null || !state.getClass().equals(SavedState.class)) {
       super.onRestoreInstanceState(state);
       setTheTime(((SavedState) state).dateValue);
     } else {
       SavedState s = (SavedState) state;
       super.onRestoreInstanceState(s.getSuperState());
       setTheTime(s.dateValue);
     }
   } catch (Exception e) {
     Log.e(TimePreference.class.getSimpleName(), e.getMessage());
   }
 }
Exemplo n.º 7
0
  @Override
  public void onClick(DialogInterface dialog, int which) {
    switch (which) {
      case DialogInterface.BUTTON_POSITIVE:
        Editable text = mPunctuationCharacters.getText();
        String characters = null;
        int level;
        if (text != null) {
          characters = text.toString();
        }

        if (mNone.isChecked()) {
          level = SpeechSynthesis.PUNCT_NONE;
        } else if (characters == null || characters.isEmpty()) {
          level = mAll.isChecked() ? SpeechSynthesis.PUNCT_ALL : SpeechSynthesis.PUNCT_NONE;
        } else {
          level = mAll.isChecked() ? SpeechSynthesis.PUNCT_ALL : SpeechSynthesis.PUNCT_SOME;
        }

        onDataChanged(level, characters);

        if (shouldCommit()) {
          SharedPreferences.Editor editor = getEditor();
          if (editor != null) {
            editor.putString(VoiceSettings.PREF_PUNCTUATION_CHARACTERS, characters);
            editor.putString(VoiceSettings.PREF_PUNCTUATION_LEVEL, Integer.toString(level));
            editor.commit();
          }
        }
        break;
    }
    super.onClick(dialog, which);
  }
 @Override
 protected void onBindView(@NonNull final View view) {
   super.onBindView(view);
   final ImageView imageView = (ImageView) view.findViewById(R.id.color);
   imageView.setImageBitmap(
       TwidereColorUtils.getColorPreviewBitmap(getContext(), getValue(), false));
 }
Exemplo n.º 9
0
 @Override
 public void onPrepareDialogBuilder(final AlertDialog.Builder builder) {
   super.onPrepareDialogBuilder(builder);
   prefs = getSharedPreferences();
   if (prefs == null) return;
   final int length = mKeys.length;
   for (int i = 0; i < length; i++) {
     mValues[i] = prefs.getBoolean(mKeys[i], mDefaultValues[i]);
   }
   builder.setPositiveButton(android.R.string.ok, this);
   builder.setNegativeButton(android.R.string.cancel, null);
   builder.setMultiChoiceItems(mNames, mValues, this);
   if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT) {
     new Thread() {
       @Override
       public void run() {
         Dialog dialog = null;
         while (dialog == null) {
           dialog = getDialog();
           if (dialog != null) {
             final Message msg = new Message();
             msg.obj = dialog;
             mDialogWorkaroundHandler.sendMessage(msg);
           }
           try {
             sleep(50L);
           } catch (final InterruptedException e) {
           }
         }
       }
     }.start();
   }
 }
Exemplo n.º 10
0
 @Override
 protected void onDialogClosed(boolean positiveResult) {
   super.onDialogClosed(positiveResult);
   Log.d(
       TAG,
       "positiveResult = "
           + positiveResult
           + " mIndex = "
           + mIndex
           + " mClickedDialogEntryIndex = "
           + mClickedDialogEntryIndex);
   // / M: Dialog dismiss is asynchronous, so hot-swap may reset the
   // mEntryValues
   if (positiveResult
       && mIndex != mClickedDialogEntryIndex
       && mEntryValues.size() > mClickedDialogEntryIndex) {
     // get the selected values --- simId
     long simId = mEntryValues.get(mClickedDialogEntryIndex);
     // pass simId to onPreferenceChangeListener
     if (callChangeListener(simId)) {
       mIndex = mClickedDialogEntryIndex;
       mAdapter.notifyDataSetChanged();
     }
   }
 }
Exemplo n.º 11
0
  @Override
  protected void onBindDialogView(View view) {

    mEditTextPassword = (EditText) view.findViewById(R.id.etpPassword);

    super.onBindDialogView(view);
  }
Exemplo n.º 12
0
  @Override
  protected void onBindDialogView(View v) {
    super.onBindDialogView(v);

    picker.setCurrentHour(lastHour);
    picker.setCurrentMinute(lastMinute);
  }
  @Override
  protected void onBindDialogView(View view) {
    super.onBindDialogView(view);
    lv = (ListView) view.findViewById(R.id.appsList);
    lv.setOnItemClickListener(this);
    lv.setFastScrollEnabled(true);
    lv.setFadingEdgeLength(1);
    lv.setDivider(null);
    lv.setDividerHeight(0);
    lv.setScrollingCacheEnabled(false);
    pb = (ProgressBar) view.findViewById(R.id.progressBar);
    if (isSearch) {
      search = (EditText) view.findViewById(R.id.searchApp);
      search.setVisibility(View.VISIBLE);
      createList();
      search.addTextChangedListener(
          new TextWatcher() {

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
              appListAdapter.getFilter().filter(s);
            }

            @Override
            public void afterTextChanged(Editable s) {}
          });
    } else {
      createList();
    }
  }
 @Override
 protected void onBindView(View view) {
   super.onBindView(view);
   getAppIcon();
   prefAppIcon = (ImageView) view.findViewById(R.id.iconForApp);
   prefAppIcon.setImageDrawable(appIcon);
 }
Exemplo n.º 15
0
 @Override
 public void onClick(DialogInterface dialog, int which) {
   super.onClick(dialog, which);
   if (DialogInterface.BUTTON_POSITIVE == which) {
     Toast.makeText(mContext, "Send an Email", Toast.LENGTH_SHORT).show();
   }
 }
  @Override
  protected void onPrepareDialogBuilder(Builder builder) {
    super.onPrepareDialogBuilder(builder);
    OnColorChangedListener l =
        new OnColorChangedListener() {
          public void colorChanged(int color) {
            mCurrentColor = color;
            onDialogClosed(true);
            getDialog().dismiss();
          }
        };

    LinearLayout layout = new LinearLayout(getContext());
    layout.setPadding(20, 20, 20, 20);
    layout.setOrientation(LinearLayout.VERTICAL);
    mCPView = new ColorPickerView(getContext(), l, mCurrentColor);

    LinearLayout.LayoutParams params1 =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    params1.gravity = Gravity.CENTER;
    mCPView.setLayoutParams(params1);
    layout.addView(this.mCPView);
    layout.setId(android.R.id.widget_frame);
    builder.setView(layout);
  }
  @Override
  protected void onBindDialogView(View view) {
    super.onBindDialogView(view);

    ListView list = (ListView) view.findViewById(R.id.dialog_preference_storage_list);

    list.setAdapter(new StoragesAdapter(getContext()));
    list.setOnItemClickListener(
        new OnItemClickAdapter<StorageMount>() {
          @Override
          public void onItemClick(
              AdapterView<?> parent,
              View view,
              AbstractAdapter<StorageMount> adapter,
              int position,
              long id) {
            selectedPath = adapter.getItem(position).path;

            // if you select the one that was there before dismiss the dialog.
            if (ConfigurationManager.instance().getStoragePath().equals(selectedPath)) {
              dismissPreferenceDialog();
            } else {
              // if you select the SD Card option, show the confirmation dialog, with ok button
              // disabled.
              // will be enabled after user clicks on checkbox.
              confirmDlg = createConfirmDialog(getContext());
              confirmDlg.show();
              confirmDlg.getButton(Dialog.BUTTON_POSITIVE).setEnabled(false);
            }
          }
        });

    TextView warningText = (TextView) view.findViewById(R.id.dialog_preference_storage_warning);
    warningText.setVisibility(list.getCount() == 1 ? View.GONE : View.VISIBLE);
  }
Exemplo n.º 18
0
 @Override
 protected void onDialogClosed(boolean positiveResult) {
   super.onDialogClosed(positiveResult);
   if (positiveResult) {
     persistBoolean(!getPersistedBoolean(true));
   }
 }
Exemplo n.º 19
0
 @Override
 protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
   // we get rid of the default buttons (that close the dialog every time)
   builder.setPositiveButton(null, null);
   builder.setNegativeButton(null, null);
   super.onPrepareDialogBuilder(builder);
 }
  @Override
  protected void onBindDialogView(View view) {
    super.onBindDialogView(view);

    dialogEqualizer = (EqualizerSurface) view.findViewById(R.id.FrequencyResponse);
    dialogEqualizer.setOnTouchListener(
        new OnTouchListener() {
          public boolean onTouch(View v, MotionEvent event) {
            float x = event.getX();
            float y = event.getY();

            int band = dialogEqualizer.findClosest(x);

            int wy = v.getHeight();
            float level =
                (y / wy) * (EqualizerSurface.MIN_DB - EqualizerSurface.MAX_DB)
                    - EqualizerSurface.MIN_DB;
            if (level < EqualizerSurface.MIN_DB) {
              level = EqualizerSurface.MIN_DB;
            }
            if (level > EqualizerSurface.MAX_DB) {
              level = EqualizerSurface.MAX_DB;
            }

            dialogEqualizer.setBand(band, level);
            levels[band] = level;
            refreshPreference(levels);
            return true;
          }
        });

    for (int i = 0; i < levels.length; i++) {
      dialogEqualizer.setBand(i, levels[i]);
    }
  }
 @Override
 protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
   super.onPrepareDialogBuilder(builder);
   builder.setAdapter(new AppListAdapter(getContext()), null);
   mNewValues.clear();
   mNewValues.addAll(mValues);
 }
 @Override
 public void onClick(DialogInterface dialog, int which) {
   super.onClick(dialog, which);
   switch (which) {
     case DialogInterface.BUTTON_POSITIVE:
       final boolean isEditing = !isIncomplete();
       final SubtypeLocaleItem locale =
           (SubtypeLocaleItem) mSubtypeLocaleSpinner.getSelectedItem();
       final KeyboardLayoutSetItem layout =
           (KeyboardLayoutSetItem) mKeyboardLayoutSetSpinner.getSelectedItem();
       final InputMethodSubtype subtype =
           AdditionalSubtype.createAdditionalSubtype(locale.first, layout.first, ASCII_CAPABLE);
       setSubtype(subtype);
       notifyChanged();
       if (isEditing) {
         mProxy.onSavePressed(this);
       } else {
         mProxy.onAddPressed(this);
       }
       break;
     case DialogInterface.BUTTON_NEUTRAL:
       // Nothing to do
       break;
     case DialogInterface.BUTTON_NEGATIVE:
       mProxy.onRemovePressed(this);
       break;
   }
 }
 @Override
 protected void onRestoreInstanceState(Parcelable state) {
   SavedLevels levelsState = (SavedLevels) state;
   levels = levelsState.levels;
   initialLevels = levelsState.initialLevels;
   super.onRestoreInstanceState(levelsState.getSuperState());
 }
Exemplo n.º 24
0
  @Override
  protected void onDialogClosed(boolean positiveResult) {
    super.onDialogClosed(positiveResult);

    // Only if OK is pressed
    if (positiveResult) persistInt(mSeekBar.getProgress() + mMin);
  }
Exemplo n.º 25
0
 @Override
 protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
   super.onPrepareDialogBuilder(builder);
   builder.setNegativeButton(null, null);
   builder.setPositiveButton(null, null);
   builder.setTitle(null);
 }
  /** {@inheritDoc} */
  @Override
  protected void onPrepareDialogBuilder(Builder builder) {
    super.onPrepareDialogBuilder(builder);

    // Configure the dialog
    this.mColorDlg = new ColorDialogView(getContext());
    this.mColorDlg.setColor(this.mColor);
    this.mColorDlg.showAlphaSlider(true);
    this.mColorDlg.setAlphaSliderText(
        getContext().getString(R.string.color_picker_alpha_slider_text));
    this.mColorDlg.setCurrentColorText(getContext().getString(R.string.color_picker_current_text));
    this.mColorDlg.setNewColorText(getContext().getString(R.string.color_picker_new_text));
    this.mColorDlg.setColorLabelText(getContext().getString(R.string.color_picker_color));
    builder.setView(this.mColorDlg);

    // The color is selected by the user and confirmed by clicking ok
    builder.setPositiveButton(
        android.R.string.ok,
        new OnClickListener() {
          @Override
          @SuppressWarnings("synthetic-access")
          public void onClick(DialogInterface dialog, int which) {
            int color = ColorPickerPreference.this.mColorDlg.getColor();
            if (callChangeListener(Integer.valueOf(color))) {
              setColor(color);
            }
            dialog.dismiss();
          }
        });
  }
 @Override
 protected void onBindDialogView(View view) {
   super.onBindDialogView(view);
   mPicker = (NumberPicker) view.findViewById(R.id.pref_num_picker);
   mPicker.setRange(mStartRange, mEndRange);
   mPicker.setCurrent(getValue());
 }
 @Override
 protected void onBindDialogView(View view) {
   super.onBindDialogView(view);
   // Adjust SeekBar range to [0, VALUE_MAX - VALUE_MIN].
   mSeekBar.setMax(VALUE_MAX - VALUE_MIN);
   mSeekBar.setProgress(mValue - VALUE_MIN);
 }
 @Override
 protected void onDialogClosed(boolean positiveResult) {
   if (positiveResult) {
     persistInt(mColor);
   }
   super.onDialogClosed(positiveResult);
 }
Exemplo n.º 30
0
 @Override
 protected void onDialogClosed(boolean positiveResult) {
   if (positiveResult) {
     CPDecksDBHelper.clearCachedApiData();
     UrlImageViewHelper.cleanup(mContext, 1);
   }
   super.onDialogClosed(positiveResult);
 }