Skip to content

Commit ca765f6

Browse files
krishna-k03sauravvishal8797
authored andcommitted
accent line color picker issue resolved (#2347)
* accent line color picker issue resolved * Delete .travis.yml.swp
1 parent a05a579 commit ca765f6

File tree

2 files changed

+43
-12
lines changed

2 files changed

+43
-12
lines changed

app/src/main/java/org/fossasia/phimpme/gallery/activities/SettingsActivity.java

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -749,22 +749,15 @@ private void accentColorPiker(){
749749

750750
final View dialogLayout = getLayoutInflater().inflate(R.layout.color_piker_accent, null);
751751
final LineColorPicker colorPicker = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_accent);
752+
final LineColorPicker colorPicker2=(LineColorPicker)dialogLayout.findViewById(R.id.color_picker_accent_2);
752753
final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.cp_accent_title);
753754
CardView cv = (CardView) dialogLayout.findViewById(R.id.cp_accent_card);
754755
cv.setCardBackgroundColor(getCardBackgroundColor());
755756

756-
colorPicker.setColors(ColorPalette.getAccentColors(getApplicationContext()));
757-
colorPicker.setSelectedColor(getAccentColor());
757+
setColor2(colorPicker,colorPicker2,dialogTitle);
758758
dialogTitle.setBackgroundColor(getAccentColor());
759759

760-
colorPicker.setOnColorChangedListener(new OnColorChangedListener() {
761-
@Override
762-
public void onColorChanged(int c) {
763-
dialogTitle.setBackgroundColor(c);
764-
updateViewswithAccentColor(colorPicker.getColor());
765760

766-
}
767-
});
768761
dialogBuilder.setView(dialogLayout);
769762

770763
dialogBuilder.setNeutralButton(getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {
@@ -776,7 +769,7 @@ public void onClick(DialogInterface dialog, int which) {
776769
});
777770
dialogBuilder.setPositiveButton(getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
778771
public void onClick(DialogInterface dialog, int which) {
779-
SP.putInt(getString(R.string.preference_accent_color), colorPicker.getColor());
772+
SP.putInt(getString(R.string.preference_accent_color), colorPicker2.getColor());
780773
updateTheme();
781774
updateViewswithAccentColor(getAccentColor());
782775
}
@@ -791,6 +784,35 @@ public void onDismiss(DialogInterface dialog) {
791784
alertDialog.show();
792785
AlertDialogsHelper.setButtonTextColor(new int[]{DialogInterface.BUTTON_POSITIVE, DialogInterface.BUTTON_NEGATIVE, DialogInterface.BUTTON_NEUTRAL}, getAccentColor(), alertDialog);
793786
}
787+
private void setColor2(final LineColorPicker colorPicker, final LineColorPicker colorPicker2, final TextView dialogTitle) {
788+
colorPicker.setColors(ColorPalette.getBaseColors(getApplicationContext()));
789+
for (int i : colorPicker.getColors())
790+
for (int i2 : ColorPalette.getColors(getBaseContext(), i))
791+
if (i2 == getAccentColor()) {
792+
colorPicker.setSelectedColor(i);
793+
colorPicker2.setColors(ColorPalette.getColors(getBaseContext(), i));
794+
colorPicker2.setSelectedColor(i2);
795+
break;}
796+
797+
dialogTitle.setBackgroundColor(getPrimaryColor());
798+
799+
colorPicker.setOnColorChangedListener(new OnColorChangedListener() {
800+
@Override
801+
public void onColorChanged(int c) {
802+
dialogTitle.setBackgroundColor(c);
803+
updateViewswithAccentColor(c);
804+
colorPicker2.setColors(ColorPalette.getColors(getApplicationContext(), colorPicker.getColor()));
805+
colorPicker2.setSelectedColor(colorPicker.getColor());
806+
}
807+
});
808+
colorPicker2.setOnColorChangedListener(new OnColorChangedListener() {
809+
@Override
810+
public void onColorChanged(int c) {
811+
dialogTitle.setBackgroundColor(c);
812+
updateViewswithAccentColor(c);
813+
}
814+
});
815+
}
794816

795817
private void customizePictureViewer(){
796818

app/src/main/res/layout/color_piker_accent.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
android:textSize="18sp"
3333
android:textStyle="bold" />
3434

35-
<RelativeLayout
35+
<LinearLayout
3636
android:id="@+id/container_edit_text"
3737
android:layout_width="match_parent"
3838
android:layout_height="match_parent"
@@ -46,8 +46,17 @@
4646
android:layout_height="60dp"
4747
app:orientation="horizontal"
4848
app:selectedColorIndex="0" />
49+
<uz.shift.colorpicker.LineColorPicker
50+
xmlns:app="http://schemas.android.com/apk/res-auto"
51+
android:id="@+id/color_picker_accent_2"
52+
android:layout_width="match_parent"
53+
android:layout_height="40dp"
54+
app:orientation="horizontal"
55+
app:selectedColorIndex="0"
56+
android:layout_marginTop="10dp"
57+
/>
4958

50-
</RelativeLayout>
59+
</LinearLayout>
5160

5261
</LinearLayout>
5362
</ScrollView>

0 commit comments

Comments
 (0)