Skip to content

Commit

Permalink
New color picker
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Apr 24, 2018
1 parent f7be123 commit 3fdcc2e
Show file tree
Hide file tree
Showing 46 changed files with 13 additions and 468 deletions.
1 change: 1 addition & 0 deletions collect_app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ dependencies {
exclude group: 'org.apache.httpcomponents'
}

implementation group: 'com.rarepebble', name: 'colorpicker', version: '2.3.1'
implementation group: 'commons-io', name: 'commons-io', version: '2.5'
implementation group: 'net.sf.kxml', name: 'kxml2', version: '2.3.0'
implementation group: 'net.sf.opencsv', name: 'opencsv', version: '2.3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
import android.widget.ListView;

import com.google.common.collect.ImmutableList;
import com.rarepebble.colorpicker.ColorPickerView;

import org.odk.collect.android.R;
import org.odk.collect.android.adapters.IconMenuListAdapter;
import org.odk.collect.android.adapters.model.IconMenuItem;
import org.odk.collect.android.application.Collect;
import org.odk.collect.android.utilities.AnimateUtils;
import org.odk.collect.android.utilities.ColorPickerDialog;
import org.odk.collect.android.utilities.DialogUtils;
import org.odk.collect.android.utilities.FileUtils;
import org.odk.collect.android.views.DrawView;
Expand Down Expand Up @@ -361,14 +361,17 @@ public void close(View view) {
public void setColor(View view) {
if (view.getVisibility() == View.VISIBLE) {
fabActions.performClick();
ColorPickerDialog cpd = new ColorPickerDialog(this,
new ColorPickerDialog.OnColorChangedListener() {
public void colorChanged(String key, int color) {
drawView.setColor(color);
}
}, "key", drawView.getColor(), drawView.getColor(),
getString(R.string.select_drawing_color));
cpd.show();

final ColorPickerView picker = new ColorPickerView(this);
picker.setColor(drawView.getColor());
picker.showAlpha(false);
picker.showHex(false);

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder
.setView(picker)
.setPositiveButton(R.string.ok, (dialog, which) -> drawView.setColor(picker.getColor()))
.show();
}
}
}
Loading

0 comments on commit 3fdcc2e

Please sign in to comment.