Skip to content

Commit

Permalink
accent line color picker issue resolved (#2347)
Browse files Browse the repository at this point in the history
* accent line color picker issue resolved

* Delete .travis.yml.swp
  • Loading branch information
krishna-k03 authored and sauravvishal8797 committed Jan 1, 2019
1 parent a05a579 commit ca765f6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -749,22 +749,15 @@ private void accentColorPiker(){

final View dialogLayout = getLayoutInflater().inflate(R.layout.color_piker_accent, null);
final LineColorPicker colorPicker = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_accent);
final LineColorPicker colorPicker2=(LineColorPicker)dialogLayout.findViewById(R.id.color_picker_accent_2);
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());
setColor2(colorPicker,colorPicker2,dialogTitle);
dialogTitle.setBackgroundColor(getAccentColor());

colorPicker.setOnColorChangedListener(new OnColorChangedListener() {
@Override
public void onColorChanged(int c) {
dialogTitle.setBackgroundColor(c);
updateViewswithAccentColor(colorPicker.getColor());

}
});
dialogBuilder.setView(dialogLayout);

dialogBuilder.setNeutralButton(getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {
Expand All @@ -776,7 +769,7 @@ public void onClick(DialogInterface dialog, int which) {
});
dialogBuilder.setPositiveButton(getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
SP.putInt(getString(R.string.preference_accent_color), colorPicker.getColor());
SP.putInt(getString(R.string.preference_accent_color), colorPicker2.getColor());
updateTheme();
updateViewswithAccentColor(getAccentColor());
}
Expand All @@ -791,6 +784,35 @@ public void onDismiss(DialogInterface dialog) {
alertDialog.show();
AlertDialogsHelper.setButtonTextColor(new int[]{DialogInterface.BUTTON_POSITIVE, DialogInterface.BUTTON_NEGATIVE, DialogInterface.BUTTON_NEUTRAL}, getAccentColor(), alertDialog);
}
private void setColor2(final LineColorPicker colorPicker, final LineColorPicker colorPicker2, final TextView dialogTitle) {
colorPicker.setColors(ColorPalette.getBaseColors(getApplicationContext()));
for (int i : colorPicker.getColors())
for (int i2 : ColorPalette.getColors(getBaseContext(), i))
if (i2 == getAccentColor()) {
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) {
dialogTitle.setBackgroundColor(c);
updateViewswithAccentColor(c);
colorPicker2.setColors(ColorPalette.getColors(getApplicationContext(), colorPicker.getColor()));
colorPicker2.setSelectedColor(colorPicker.getColor());
}
});
colorPicker2.setOnColorChangedListener(new OnColorChangedListener() {
@Override
public void onColorChanged(int c) {
dialogTitle.setBackgroundColor(c);
updateViewswithAccentColor(c);
}
});
}

private void customizePictureViewer(){

Expand Down
13 changes: 11 additions & 2 deletions app/src/main/res/layout/color_piker_accent.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
android:textSize="18sp"
android:textStyle="bold" />

<RelativeLayout
<LinearLayout
android:id="@+id/container_edit_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand All @@ -46,8 +46,17 @@
android:layout_height="60dp"
app:orientation="horizontal"
app:selectedColorIndex="0" />
<uz.shift.colorpicker.LineColorPicker
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/color_picker_accent_2"
android:layout_width="match_parent"
android:layout_height="40dp"
app:orientation="horizontal"
app:selectedColorIndex="0"
android:layout_marginTop="10dp"
/>

</RelativeLayout>
</LinearLayout>

</LinearLayout>
</ScrollView>
Expand Down

0 comments on commit ca765f6

Please sign in to comment.