コード例 #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();
  }
コード例 #2
0
  private void accentColorPiker() {
    final AlertDialog.Builder dialogBuilder =
        new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());

    final View dialogLayout = getLayoutInflater().inflate(R.layout.color_piker_accent, null);
    final LineColorPicker colorPicker =
        (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_accent);
    final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.cp_accent_title);
    CardView cv = (CardView) dialogLayout.findViewById(R.id.cp_accent_card);
    cv.setCardBackgroundColor(getCardBackgroundColor());

    colorPicker.setColors(ColorPalette.getAccentColors(getApplicationContext()));
    colorPicker.setSelectedColor(getAccentColor());
    dialogTitle.setBackgroundColor(getAccentColor());

    colorPicker.setOnColorChangedListener(
        new OnColorChangedListener() {
          @Override
          public void onColorChanged(int c) {
            dialogTitle.setBackgroundColor(c);
            updateAccentViewsColor(colorPicker.getColor());
          }
        });
    dialogBuilder.setView(dialogLayout);

    dialogBuilder.setNeutralButton(
        getString(R.string.cancel),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
            updateAccentViewsColor(getAccentColor());
          }
        });
    dialogBuilder.setPositiveButton(
        getString(R.string.ok_action),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            SharedPreferences.Editor editor = SP.edit();
            editor.putInt(getString(R.string.preference_accent_color), colorPicker.getColor());
            editor.apply();
            updateTheme();
            updateAccentViewsColor(getAccentColor());
          }
        });
    dialogBuilder.setOnDismissListener(
        new DialogInterface.OnDismissListener() {
          @Override
          public void onDismiss(DialogInterface dialog) {
            updateAccentViewsColor(getAccentColor());
          }
        });
    dialogBuilder.show();
  }
コード例 #3
0
  private void primaryColorPiker() {
    final AlertDialog.Builder dialogBuilder =
        new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());

    final View dialogLayout = getLayoutInflater().inflate(R.layout.color_piker_primary, null);
    final LineColorPicker colorPicker =
        (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_primary);
    final LineColorPicker colorPicker2 =
        (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_primary_2);
    final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.cp_primary_title);
    CardView dialogCardView = (CardView) dialogLayout.findViewById(R.id.cp_primary_card);
    dialogCardView.setCardBackgroundColor(getCardBackgroundColor());

    colorPicker.setColors(ColorPalette.getBaseColors(getApplicationContext()));
    for (int i : colorPicker.getColors())
      for (int i2 : ColorPalette.getColors(getBaseContext(), i))
        if (i2 == getPrimaryColor()) {
          colorPicker.setSelectedColor(i);
          colorPicker2.setColors(ColorPalette.getColors(getBaseContext(), i));
          colorPicker2.setSelectedColor(i2);
          break;
        }

    dialogTitle.setBackgroundColor(getPrimaryColor());

    colorPicker.setOnColorChangedListener(
        new OnColorChangedListener() {
          @Override
          public void onColorChanged(int c) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
              if (isTranslucentStatusBar()) {
                getWindow().setStatusBarColor(ColorPalette.getOscuredColor(getPrimaryColor()));
              } else getWindow().setStatusBarColor(c);
            }

            toolbar.setBackgroundColor(c);
            dialogTitle.setBackgroundColor(c);
            colorPicker2.setColors(
                ColorPalette.getColors(getApplicationContext(), colorPicker.getColor()));
            colorPicker2.setSelectedColor(colorPicker.getColor());
          }
        });
    colorPicker2.setOnColorChangedListener(
        new OnColorChangedListener() {
          @Override
          public void onColorChanged(int c) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
              if (isTranslucentStatusBar()) {
                getWindow().setStatusBarColor(ColorPalette.getOscuredColor(c));
              } else getWindow().setStatusBarColor(c);
              if (isNavigationBarColored()) getWindow().setNavigationBarColor(c);
              else
                getWindow()
                    .setNavigationBarColor(
                        ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000));
            }
            toolbar.setBackgroundColor(c);
            dialogTitle.setBackgroundColor(c);
          }
        });
    dialogBuilder.setView(dialogLayout);

    dialogBuilder.setNeutralButton(
        getString(R.string.cancel),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
              if (isTranslucentStatusBar()) {
                getWindow().setStatusBarColor(ColorPalette.getOscuredColor(getPrimaryColor()));
              } else getWindow().setStatusBarColor(getPrimaryColor());
            }
            toolbar.setBackgroundColor(getPrimaryColor());
            dialog.cancel();
          }
        });

    dialogBuilder.setPositiveButton(
        getString(R.string.ok_action),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            SharedPreferences.Editor editor = SP.edit();
            editor.putInt(getString(R.string.preference_primary_color), colorPicker2.getColor());
            editor.apply();
            updateTheme();
            setNavBarColor();
            setScrollViewColor(scr);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
              if (isTranslucentStatusBar()) {
                getWindow().setStatusBarColor(ColorPalette.getOscuredColor(getPrimaryColor()));
              } else {
                getWindow().setStatusBarColor(getPrimaryColor());
              }
            }
          }
        });

    dialogBuilder.setOnDismissListener(
        new DialogInterface.OnDismissListener() {
          @Override
          public void onDismiss(DialogInterface dialog) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
              if (isTranslucentStatusBar()) {
                getWindow().setStatusBarColor(ColorPalette.getOscuredColor(getPrimaryColor()));
              } else getWindow().setStatusBarColor(getPrimaryColor());
              if (isNavigationBarColored()) getWindow().setNavigationBarColor(getPrimaryColor());
              else
                getWindow()
                    .setNavigationBarColor(
                        ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000));
            }
            toolbar.setBackgroundColor(getPrimaryColor());
          }
        });
    dialogBuilder.show();
  }