Switched to QuadFlask colorpicker

This commit is contained in:
M66B 2019-09-29 16:31:13 +02:00
parent 97bc466942
commit fc3866f908
16 changed files with 79 additions and 107 deletions

3
.gitmodules vendored
View File

@ -1,6 +1,3 @@
[submodule "colorpicker"]
path = colorpicker
url = https://github.com/M66B/colorpicker.git
[submodule "qcolorpicker"]
path = qcolorpicker
url = https://github.com/QuadFlask/colorpicker.git

View File

@ -6,7 +6,6 @@ FairEmail uses:
* [jsoup](https://jsoup.org/). Copyright © 2009 - 2017 Jonathan Hedley. [MIT license](https://jsoup.org/license).
* [Android Support Library](https://developer.android.com/tools/support-library/). Copyright (C) 2011 The Android Open Source Project. [Apache license 2.0](https://android.googlesource.com/platform/frameworks/support/+/master/LICENSE.txt).
* [Android Architecture Components](https://developer.android.com/topic/libraries/architecture/). Copyright 2018 The Android Open Source Project, Inc. [Apache license 2.0](https://github.com/googlesamples/android-architecture-components/blob/master/LICENSE).
* [colorpicker](https://android.googlesource.com/platform/frameworks/opt/colorpicker). Copyright (C) 2013 The Android Open Source Project. [Apache license 2.0](https://android.googlesource.com/platform/frameworks/opt/colorpicker/+/master/src/com/android/colorpicker/ColorPickerDialog.java).
* [dnsjava](http://www.xbill.org/dnsjava/). Copyright (c) 1998-2011, Brian Wellington. [BSD License](https://sourceforge.net/p/dnsjava/code/HEAD/tree/trunk/LICENSE).
* [OpenPGP API library](https://github.com/open-keychain/openpgp-api). Copyright (C) 2014-2015 Dominik Schürmann. [Apache License 2.0](https://github.com/open-keychain/openpgp-api/blob/master/LICENSE).
* [Android SQLite support library](https://github.com/requery/sqlite-android). Copyright (C) 2017 requery.io. [Apache License 2.0](https://github.com/requery/sqlite-android/blob/master/LICENSE).
@ -18,3 +17,4 @@ FairEmail uses:
* [PhotoView](https://github.com/chrisbanes/PhotoView). Copyright 2018 Chris Banes. [Apache License 2.0](https://github.com/chrisbanes/PhotoView/blob/master/LICENSE).
* [ReLinker](https://github.com/KeepSafe/ReLinker). Copyright 2015 - 2016 KeepSafe Software, Inc. [Apache License 2.0](https://github.com/KeepSafe/ReLinker/blob/master/LICENSE).
* [Markwon](https://github.com/noties/Markwon). Copyright 2019 Dimitry Ivanov. [Apache License 2.0](https://github.com/noties/Markwon/blob/master/LICENSE).
* [Color Picker](https://github.com/QuadFlask/colorpicker). Copyright 2014-2017 QuadFlask. [Apache License 2.0](https://github.com/QuadFlask/colorpicker#user-content-license).

View File

@ -312,6 +312,5 @@ dependencies {
// https://github.com/noties/Markwon
implementation "io.noties.markwon:core:$markwon_version"
// git clone https://android.googlesource.com/platform/frameworks/opt/colorpicker
implementation project(path: ':colorpicker')
implementation project(':qcolorpicker')
}

View File

@ -6,7 +6,6 @@ FairEmail uses:
* [jsoup](https://jsoup.org/). Copyright © 2009 - 2017 Jonathan Hedley. [MIT license](https://jsoup.org/license).
* [Android Support Library](https://developer.android.com/tools/support-library/). Copyright (C) 2011 The Android Open Source Project. [Apache license 2.0](https://android.googlesource.com/platform/frameworks/support/+/master/LICENSE.txt).
* [Android Architecture Components](https://developer.android.com/topic/libraries/architecture/). Copyright 2018 The Android Open Source Project, Inc. [Apache license 2.0](https://github.com/googlesamples/android-architecture-components/blob/master/LICENSE).
* [colorpicker](https://android.googlesource.com/platform/frameworks/opt/colorpicker). Copyright (C) 2013 The Android Open Source Project. [Apache license 2.0](https://android.googlesource.com/platform/frameworks/opt/colorpicker/+/master/src/com/android/colorpicker/ColorPickerDialog.java).
* [dnsjava](http://www.xbill.org/dnsjava/). Copyright (c) 1998-2011, Brian Wellington. [BSD License](https://sourceforge.net/p/dnsjava/code/HEAD/tree/trunk/LICENSE).
* [OpenPGP API library](https://github.com/open-keychain/openpgp-api). Copyright (C) 2014-2015 Dominik Schürmann. [Apache License 2.0](https://github.com/open-keychain/openpgp-api/blob/master/LICENSE).
* [Android SQLite support library](https://github.com/requery/sqlite-android). Copyright (C) 2017 requery.io. [Apache License 2.0](https://github.com/requery/sqlite-android/blob/master/LICENSE).
@ -18,3 +17,4 @@ FairEmail uses:
* [PhotoView](https://github.com/chrisbanes/PhotoView). Copyright 2018 Chris Banes. [Apache License 2.0](https://github.com/chrisbanes/PhotoView/blob/master/LICENSE).
* [ReLinker](https://github.com/KeepSafe/ReLinker). Copyright 2015 - 2016 KeepSafe Software, Inc. [Apache License 2.0](https://github.com/KeepSafe/ReLinker/blob/master/LICENSE).
* [Markwon](https://github.com/noties/Markwon). Copyright 2019 Dimitry Ivanov. [Apache License 2.0](https://github.com/noties/Markwon/blob/master/LICENSE).
* [Color Picker](https://github.com/QuadFlask/colorpicker). Copyright 2014-2017 QuadFlask. [Apache License 2.0](https://github.com/QuadFlask/colorpicker#user-content-license).

View File

@ -2882,13 +2882,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void onMenuColoredStar(final TupleMessageEx message) {
int color = (message.color == null ? Color.TRANSPARENT : message.color);
Bundle args = new Bundle();
args.putLong("id", message.id);
args.putInt("color", message.color == null ? Color.TRANSPARENT : message.color);
args.putString("title", context.getString(R.string.title_flag_color));
FragmentDialogColor fragment = new FragmentDialogColor();
fragment.initialize(R.string.title_flag_color, color, args, context);
fragment.setArguments(args);
fragment.setTargetFragment(parentFragment, FragmentMessages.REQUEST_MESSAGE_COLOR);
fragment.show(parentFragment.getFragmentManager(), "message:color");
}

View File

@ -303,8 +303,12 @@ public class FragmentAccount extends FragmentBase {
btnColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle args = new Bundle();
args.putInt("color", btnColor.getColor());
args.putString("title", getString(R.string.title_color));
FragmentDialogColor fragment = new FragmentDialogColor();
fragment.initialize(R.string.title_color, btnColor.getColor(), new Bundle(), getContext());
fragment.setArguments(args);
fragment.setTargetFragment(FragmentAccount.this, REQUEST_COLOR);
fragment.show(getFragmentManager(), "account:color");
}

View File

@ -1040,8 +1040,12 @@ public class FragmentCompose extends FragmentBase {
Log.i("Style action=" + action);
if (action == R.id.menu_color) {
Bundle args = new Bundle();
args.putInt("color", Color.TRANSPARENT);
args.putString("title", getString(R.string.title_style_color));
FragmentDialogColor fragment = new FragmentDialogColor();
fragment.initialize(R.string.title_style_color, Color.TRANSPARENT, new Bundle(), getContext());
fragment.setArguments(args);
fragment.setTargetFragment(FragmentCompose.this, REQUEST_COLOR);
fragment.show(getFragmentManager(), "account:color");
return true;

View File

@ -19,49 +19,51 @@ package eu.faircode.email;
Copyright 2018-2019 by Marcel Bokhorst (M66B)
*/
import android.content.Context;
import android.content.Intent;
import android.app.Dialog;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.colorpicker.ColorPickerDialog;
import com.flask.colorpicker.ColorPickerView;
import com.flask.colorpicker.builder.ColorPickerClickListener;
import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
import static android.app.Activity.RESULT_OK;
public class FragmentDialogColor extends ColorPickerDialog {
private Bundle args;
public void initialize(int title, int color, Bundle args, Context context) {
this.args = args;
int[] colors = context.getResources().getIntArray(R.array.colorPicker);
super.initialize(title, colors, color, 4, colors.length);
}
public class FragmentDialogColor extends FragmentDialogBase {
@NonNull
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null)
this.args = savedInstanceState.getBundle("fair:extra");
}
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
int color = getArguments().getInt("color");
String title = getArguments().getString("title");
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putBundle("fair:extra", args);
super.onSaveInstanceState(outState);
}
if (color == Color.TRANSPARENT)
color = Color.BLUE;
@Override
public void onColorSelected(int color) {
Fragment target = getTargetFragment();
if (target != null) {
args.putInt("color", color);
Intent data = new Intent();
data.putExtra("args", args);
target.onActivityResult(getTargetRequestCode(), RESULT_OK, data);
}
dismiss();
return ColorPickerDialogBuilder
.with(getContext())
.setTitle(title)
.initialColor(color)
.wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
.density(12)
.lightnessSliderOnly()
.setPositiveButton(android.R.string.ok, new ColorPickerClickListener() {
@Override
public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
getArguments().putInt("color", selectedColor);
sendResult(RESULT_OK);
}
})
.setNegativeButton(R.string.title_reset, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
getArguments().putInt("color", Color.TRANSPARENT);
sendResult(RESULT_OK);
}
})
.build();
}
}

View File

@ -286,8 +286,12 @@ public class FragmentIdentity extends FragmentBase {
btnColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle args = new Bundle();
args.putInt("color", btnColor.getColor());
args.putString("title", getString(R.string.title_color));
FragmentDialogColor fragment = new FragmentDialogColor();
fragment.initialize(R.string.title_flag_color, btnColor.getColor(), new Bundle(), getContext());
fragment.setArguments(args);
fragment.setTargetFragment(FragmentIdentity.this, REQUEST_COLOR);
fragment.show(getFragmentManager(), "identity:color");
}

View File

@ -1589,13 +1589,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
private void onMenuColor() {
int color = (message.color == null ? Color.TRANSPARENT : message.color);
Bundle args = new Bundle();
args.putLong("id", message.id);
args.putInt("color", message.color == null ? Color.TRANSPARENT : message.color);
args.putString("title", getString(R.string.title_flag_color));
FragmentDialogColor fragment = new FragmentDialogColor();
fragment.initialize(R.string.title_flag_color, color, args, getContext());
fragment.setArguments(args);
fragment.setTargetFragment(FragmentMessages.this, FragmentMessages.REQUEST_MESSAGE_COLOR);
fragment.show(getFragmentManager(), "message:color");
}
@ -1973,8 +1973,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
private void onActionFlagColorSelection() {
Bundle args = new Bundle();
args.putInt("color", Color.TRANSPARENT);
args.putString("title", getString(R.string.title_flag_color));
FragmentDialogColor fragment = new FragmentDialogColor();
fragment.initialize(R.string.title_flag_color, Color.TRANSPARENT, new Bundle(), getContext());
fragment.setArguments(args);
fragment.setTargetFragment(FragmentMessages.this, REQUEST_MESSAGES_COLOR);
fragment.show(getFragmentManager(), "messages:color");
}

View File

@ -132,8 +132,12 @@ public class FragmentPop extends FragmentBase {
btnColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle args = new Bundle();
args.putInt("color", btnColor.getColor());
args.putString("title", getString(R.string.title_color));
FragmentDialogColor fragment = new FragmentDialogColor();
fragment.initialize(R.string.title_color, btnColor.getColor(), new Bundle(), getContext());
fragment.setArguments(args);
fragment.setTargetFragment(FragmentPop.this, REQUEST_COLOR);
fragment.show(getFragmentManager(), "account:color");
}

View File

@ -366,8 +366,12 @@ public class FragmentRule extends FragmentBase {
btnColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle args = new Bundle();
args.putInt("color", btnColor.getColor());
args.putString("title", getString(R.string.title_flag_color));
FragmentDialogColor fragment = new FragmentDialogColor();
fragment.initialize(R.string.title_flag_color, btnColor.getColor(), new Bundle(), getContext());
fragment.setArguments(args);
fragment.setTargetFragment(FragmentRule.this, REQUEST_COLOR);
fragment.show(getFragmentManager(), "rule:color");
}

View File

@ -59,26 +59,4 @@
<color name="white">#ffffffff</color>
<color name="black">#ff000000</color>
<color name="transparent">#00000000</color>
<!-- color picker -->
<color name="red">#F6402C</color>
<color name="pink">#EB1460</color>
<color name="purple">#9C1AB1</color>
<color name="deep_purple">#6633B9</color>
<color name="indigo">#3D4DB7</color>
<color name="blue">#1093F5</color>
<color name="light_blue">#00A6F6</color>
<color name="cyan">#00BBD5</color>
<color name="teal">#009687</color>
<color name="green">#46AF4A</color>
<color name="light_green">#88C440</color>
<color name="lime">#CCDD1E</color>
<color name="yellow">#FFEC16</color>
<color name="amber">#FFC100</color>
<color name="orange">#FF9800</color>
<color name="deep_orange">#FF5505</color>
<color name="brown">#7A5547</color>
<color name="blue_grey">#5E7C8B</color>
<color name="grey">#9D9D9D</color>
<color name="dark_grey">#696969</color>
</resources>

View File

@ -1017,35 +1017,6 @@
<item>At the end</item>
</string-array>
<array name="colorPicker">
<item>@color/red</item>
<item>@color/pink</item>
<item>@color/purple</item>
<item>@color/deep_purple</item>
<item>@color/indigo</item>
<item>@color/blue</item>
<item>@color/light_blue</item>
<item>@color/cyan</item>
<item>@color/teal</item>
<item>@color/green</item>
<item>@color/light_green</item>
<item>@color/lime</item>
<item>@color/yellow</item>
<item>@color/amber</item>
<item>@color/orange</item>
<item>@color/deep_orange</item>
<item>@color/brown</item>
<item>@color/blue_grey</item>
<item>@color/grey</item>
<item>@color/dark_grey</item>
<item>@android:color/transparent</item>
</array>
<string name="fingerprint" translatable="false">17BA15C1AF55D925F98B99CEA4375D4CDF4C174B</string>
<string name="public_key" translatable="false">MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtFbxEbzL8u5accPGgBw/XdyiSS5BBE6ZQ9ELpKyJ/OQN+kdYniCAOw3lsQ/GuJScy4Y2HobqbBgLL8GLHG+Yu2EHC9dLjA3v2Mc25vvnfn86BsrpQvz1poN2n+roTBdq09FWbtebJ8m0hDBVmtfRi7RhTKIL4No3kodLhksdnucKjcFheubebWKgpmvbmw7NwuELhaZmyhw8WTtnQ4rZPMhjY1JJZgzwNExXgD7zzg4pJPkuQlfkuRkkvBpHpi3C7VDnYjrBlLHngI4wv3wxQBVwJqlvAT9PmX8dOVnTsWWdJdLQBZVWphuqVY54kjBIovN+o8w03WjsV9QiOQq+XwIDAQAB</string>
</resources>

@ -1 +0,0 @@
Subproject commit f006b17cfdbb59a59a755290d9b7b529ba102f32

View File

@ -1 +1,3 @@
include ':app', ':colorpicker'
include ':app', ':qcolorpicker'
project(':qcolorpicker').projectDir = new File('qcolorpicker/library')