コード例 #1
0
  private void customizePictureViewer() {

    final AlertDialog.Builder dialogBuilder =
        new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());

    View dialogLayout = getLayoutInflater().inflate(R.layout.dialog_media_viewer_theme, null);
    final SwitchCompat swApplyTheme_Viewer =
        (SwitchCompat) dialogLayout.findViewById(R.id.apply_theme_3th_act_enabled);

    ((CardView) dialogLayout.findViewById(R.id.third_act_theme_card))
        .setCardBackgroundColor(getCardBackgroundColor());
    dialogLayout
        .findViewById(R.id.third_act_theme_title)
        .setBackgroundColor(getPrimaryColor()); // or Getprimary
    ((TextView) dialogLayout.findViewById(R.id.apply_theme_3thAct_title))
        .setTextColor(getTextColor());
    ((TextView) dialogLayout.findViewById(R.id.apply_theme_3thAct_title_Sub))
        .setTextColor(getSubTextColor());
    ((IconicsImageView) dialogLayout.findViewById(R.id.ll_apply_theme_3thAct_icon))
        .setColor(getIconColor());

    swApplyTheme_Viewer.setChecked(isApplyThemeOnImgAct());
    swApplyTheme_Viewer.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateSwitchColor(swApplyTheme_Viewer, getAccentColor());
          }
        });
    updateSwitchColor(swApplyTheme_Viewer, getAccentColor());

    final LineColorPicker transparencyColorPicker =
        (LineColorPicker) dialogLayout.findViewById(R.id.pickerTransparent);
    transparencyColorPicker.setColors(ColorPalette.getTransparencyShadows(getPrimaryColor()));
    transparencyColorPicker.setSelectedColor(
        ColorPalette.getTransparentColor(getPrimaryColor(), getTransparency()));

    /** TEXT VIEWS* */
    ((TextView) dialogLayout.findViewById(R.id.seek_bar_alpha_title)).setTextColor(getTextColor());
    ((TextView) dialogLayout.findViewById(R.id.seek_bar_alpha_title_Sub))
        .setTextColor(getSubTextColor());

    dialogBuilder.setView(dialogLayout);
    dialogBuilder.setNeutralButton(getString(R.string.cancel), null);
    dialogBuilder.setPositiveButton(
        getString(R.string.ok_action),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            SharedPreferences.Editor editor = SP.edit();
            editor.putBoolean(
                getString(R.string.preference_apply_theme_pager), swApplyTheme_Viewer.isChecked());
            int c = Color.alpha(transparencyColorPicker.getColor());
            editor.putInt(getString(R.string.preference_transparency), 255 - c);
            editor.apply();
            updateTheme();
          }
        });

    dialogBuilder.show();
  }