diff --git a/README.md b/README.md index a2c0c9c..fdd577d 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,6 @@ This is a nice and simple color picker for Android. It allows to show any number ## Example code -### Use as a dialog - To show the dialog, just get an instance, add a number of palettes and call the show method. ```java ColorPickerDialogFragment d = new ColorPickerDialogFragment(); @@ -43,31 +41,6 @@ The calling activity or fragment should implement `ColorPickerDialogFragment.Col // handle cancelled color picker dialog } ``` -### Use via Intent - -Alternatively you can use the picker via `Intent`. To do so just include the following dependency - -``` -implementation "com.github.dmfs.color-picker:colorpicker-activity:1.1" -``` - -and call the dialog like: -```java - ColorPickerActivity.start(context, CODE_PICK_COLOR); -``` -This will call an intent with the action `org.openintents.action.PICK_COLOR` allowing the user to use his preferred color picker (if it supports the Open Intent). - -In `onActivityResult(int, int, Intent)` you can get the picked color like this: -```java - @Override - protected void onActivityResult(int code, int result, Intent data) - { - if (result == RESULT_OK && code == CODE_PICK_COLOR) - { - Integer color = ColorPickerActivity.getColor(data); - } - } -``` ## Screen shots @@ -84,4 +57,4 @@ In `onActivityResult(int, int, Intent)` you can get the picked color like this: ## License -Copyright (c) dmfs GmbH 2017, licensed under Apache 2 (see `LICENSE`). +Copyright (c) dmfs GmbH 2018, licensed under Apache 2 (see `LICENSE`). diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index d73e6e6..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,22 +0,0 @@ -apply plugin: 'com.android.application' - -android { - compileSdkVersion 26 - - defaultConfig { - applicationId "org.dmfs.android.colorpicker" - minSdkVersion 15 - targetSdkVersion 26 - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' - } - } -} - -dependencies { - compile project(':colorpicker-activity') -} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml deleted file mode 100644 index 132363c..0000000 --- a/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable-hdpi/ic_launcher.png b/app/src/main/res/drawable-hdpi/ic_launcher.png deleted file mode 100644 index 96a442e..0000000 Binary files a/app/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/ic_launcher.png b/app/src/main/res/drawable-mdpi/ic_launcher.png deleted file mode 100644 index 359047d..0000000 Binary files a/app/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/ic_launcher.png b/app/src/main/res/drawable-xhdpi/ic_launcher.png deleted file mode 100644 index 71c6d76..0000000 Binary files a/app/src/main/res/drawable-xhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml deleted file mode 100644 index 40b9eff..0000000 --- a/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Simple Color Picker - - diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml deleted file mode 100644 index 47e8bad..0000000 --- a/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - \ No newline at end of file diff --git a/build.gradle b/build.gradle index 73766cb..474619f 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.android.tools.build:gradle:3.2.1' } } diff --git a/colorpicker-activity/.gitignore b/colorpicker-activity/.gitignore deleted file mode 100644 index 796b96d..0000000 --- a/colorpicker-activity/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/colorpicker-activity/build.gradle b/colorpicker-activity/build.gradle deleted file mode 100644 index a22a0f8..0000000 --- a/colorpicker-activity/build.gradle +++ /dev/null @@ -1,26 +0,0 @@ -apply plugin: 'com.android.library' - -android { - compileSdkVersion 26 - - defaultConfig { - minSdkVersion 15 - targetSdkVersion 26 - - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - -} - -dependencies { - api project(':colorpicker') - implementation 'com.android.support:appcompat-v7:26.1.0' -} diff --git a/colorpicker-activity/proguard-rules.pro b/colorpicker-activity/proguard-rules.pro deleted file mode 100644 index f1b4245..0000000 --- a/colorpicker-activity/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile diff --git a/colorpicker-activity/src/main/AndroidManifest.xml b/colorpicker-activity/src/main/AndroidManifest.xml deleted file mode 100644 index c2df129..0000000 --- a/colorpicker-activity/src/main/AndroidManifest.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - diff --git a/colorpicker-activity/src/main/java/org/dmfs/android/colorpicker/activity/ColorPickerActivity.java b/colorpicker-activity/src/main/java/org/dmfs/android/colorpicker/activity/ColorPickerActivity.java deleted file mode 100644 index d77133d..0000000 --- a/colorpicker-activity/src/main/java/org/dmfs/android/colorpicker/activity/ColorPickerActivity.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2017 dmfs GmbH - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.dmfs.android.colorpicker.activity; - -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; - -import org.dmfs.android.colorpicker.ColorPickerDialogFragment; -import org.dmfs.android.colorpicker.ColorPickerDialogFragment.ColorDialogResultListener; -import org.dmfs.android.colorpicker.palettes.ArrayPalette; -import org.dmfs.android.colorpicker.palettes.ColorFactory; -import org.dmfs.android.colorpicker.palettes.ColorShadeFactory; -import org.dmfs.android.colorpicker.palettes.CombinedColorFactory; -import org.dmfs.android.colorpicker.palettes.FactoryPalette; -import org.dmfs.android.colorpicker.palettes.Palette; -import org.dmfs.android.colorpicker.palettes.RainbowColorFactory; -import org.dmfs.android.retentionmagic.FragmentActivity; -import org.dmfs.android.retentionmagic.annotations.Retain; - - -/** - * An activity that prompts the user to pick a color. - * - * @author Marten Gajda - */ -public final class ColorPickerActivity extends FragmentActivity implements ColorDialogResultListener -{ - /** - * Color picker action. - */ - public final static String ACTION_PICK_COLOR = "org.openintents.action.PICK_COLOR"; - - /** - * The extra that contains the picked color. - */ - public final static String EXTRA_COLOR = "org.openintents.extra.COLOR"; - - private final static int[] MATERIAL_COLORS_PRIMARY = { - 0xffe91e63, 0xfff44336, 0xffff5722, 0xffff9800, 0xffffc107, 0xffffeb3b, 0xffcddc39, 0xff8bc34a, - 0xff4caf50, 0xff009688, 0xff00bcd4, 0xff03a9f4, 0xff2196f3, 0xff3f51b5, 0xff673ab7, 0xff9c27b0 }; - - private static final int MATERIAL_COLORS_DARK[] = { - 0xffad1457, 0xffc62828, 0xffd84315, 0xffef6c00, 0xffff8f00, 0xfff9a825, 0xff9e9d24, 0xff558b2f, - 0xff2e7d32, 0xff00695c, 0xff00838f, 0xff0277bd, 0xff1565c0, 0xff283593, 0xff4527a0, 0xff6a1b9a }; - /** - * The palettes to show. - */ - private final static Palette[] PALETTES = { - new ArrayPalette("material_primary", "Material Colors", MATERIAL_COLORS_PRIMARY), - new ArrayPalette("material_secondary", "Dark Material Colors", MATERIAL_COLORS_DARK), - new FactoryPalette("red", "Red", new CombinedColorFactory(new ColorShadeFactory(340), ColorFactory.RED), 16), - new FactoryPalette("orange", "Orange", new CombinedColorFactory(new ColorShadeFactory(18), ColorFactory.ORANGE), 16), - new FactoryPalette("yellow", "Yellow", new CombinedColorFactory(new ColorShadeFactory(53), ColorFactory.YELLOW), 16), - new FactoryPalette("green", "Green", new CombinedColorFactory(new ColorShadeFactory(80), ColorFactory.GREEN), 16), - new FactoryPalette("cyan", "Cyan", new CombinedColorFactory(new ColorShadeFactory(150), ColorFactory.CYAN), 16), - new FactoryPalette("blue", "Blue", new CombinedColorFactory(new ColorShadeFactory(210), ColorFactory.BLUE), 16), - new FactoryPalette("purple", "Purple", new CombinedColorFactory(new ColorShadeFactory(265), ColorFactory.PURPLE), 16), - new FactoryPalette("pink", "Pink", new CombinedColorFactory(new ColorShadeFactory(300), ColorFactory.PINK), 16), - new FactoryPalette("grey", "Grey", ColorFactory.GREY, 16), new FactoryPalette("pastel", "Pastel", ColorFactory.PASTEL, 16), - new FactoryPalette("rainbow", "Rainbow", ColorFactory.RAINBOW, 16), - new FactoryPalette("dark_rainbow", "Dark Rainbow", new RainbowColorFactory(0.5f, 0.5f), 16) }; - - /** - * The id of the palette - */ - @Retain(classNS = "ColorPickerActivity", key = "palette", permanent = true) - private String mPaletteId = null; - - - /** - * Start the {@link ColorPickerActivity} with the given request code. - * - * @param context - * A {@link Context}. - * @param requestCode - * The request code. - */ - public static void start(android.app.Activity context, int requestCode) - { - Intent intent = new Intent(ACTION_PICK_COLOR); - context.startActivityForResult(intent, requestCode); - } - - - /** - * Returns the color from the given result intent or null if there was no color. - * - * @param result - * The intent to get the color from. - * - * @return the color or null. - */ - public static Integer getColor(Intent result) - { - return result != null && result.hasExtra(EXTRA_COLOR) ? result.getIntExtra(EXTRA_COLOR, 0) : null; - } - - - @Override - protected void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - showColorPickerDialog(); - - } - - - private void showColorPickerDialog() - { - ColorPickerDialogFragment d = new ColorPickerDialogFragment(); - d.setPalettes(PALETTES); - d.setTitle(org.dmfs.android.colorpicker.R.string.org_dmfs_colorpicker_pick_a_color); - d.selectPaletteId(mPaletteId); - d.show(getSupportFragmentManager(), ""); - } - - - @Override - public void onColorChanged(int color, String paletteId, String colorName, String paletteName) - { - mPaletteId = paletteId; - Intent intent = getIntent(); - intent.putExtra(EXTRA_COLOR, color); - setResult(RESULT_OK, intent); - finish(); - } - - - @Override - public void onColorDialogCancelled() - { - setResult(RESULT_CANCELED); - finish(); - } -} diff --git a/colorpicker-activity/src/main/res/values/styles.xml b/colorpicker-activity/src/main/res/values/styles.xml deleted file mode 100644 index a3a1568..0000000 --- a/colorpicker-activity/src/main/res/values/styles.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - \ No newline at end of file diff --git a/colorpicker/build.gradle b/colorpicker/build.gradle index 29b2175..cefa976 100644 --- a/colorpicker/build.gradle +++ b/colorpicker/build.gradle @@ -20,6 +20,8 @@ dependencies { implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support:support-v4:26.1.0' implementation 'com.github.dmfs.bolts:color-bolts:2b1b95d' - compile files('libs/android-retention-magic-1.2.2.jar') + implementation 'com.github.dmfs:retention-magic:1.3' + + // TODO: replace or covert to Gradle project so we can pull it from Maven compile files('libs/drawablepagertabstrip.jar') } diff --git a/colorpicker/libs/android-retention-magic-1.2.2.jar b/colorpicker/libs/android-retention-magic-1.2.2.jar deleted file mode 100644 index 1c332f6..0000000 Binary files a/colorpicker/libs/android-retention-magic-1.2.2.jar and /dev/null differ diff --git a/colorpicker/src/main/AndroidManifest.xml b/colorpicker/src/main/AndroidManifest.xml index 2cea184..0942adc 100644 --- a/colorpicker/src/main/AndroidManifest.xml +++ b/colorpicker/src/main/AndroidManifest.xml @@ -1,4 +1,2 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/colorpicker/src/main/java/org/dmfs/android/colorpicker/ColorPickerDialogFragment.java b/colorpicker/src/main/java/org/dmfs/android/colorpicker/ColorPickerDialogFragment.java index 8f41787..10c6249 100644 --- a/colorpicker/src/main/java/org/dmfs/android/colorpicker/ColorPickerDialogFragment.java +++ b/colorpicker/src/main/java/org/dmfs/android/colorpicker/ColorPickerDialogFragment.java @@ -141,7 +141,7 @@ public void setTitle(int title) @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.org_dmfs_colorpickerdialog_fragment, container); + View view = inflater.inflate(R.layout.dmfs_colorpickerdialog_fragment, container); mPager = view.findViewById(R.id.pager); mPagerAdapter = new PalettesPagerAdapter(getResources(), getChildFragmentManager(), mPalettes); mPagerAdapter.notifyDataSetChanged(); @@ -175,7 +175,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) if (Build.VERSION.SDK_INT >= 21) { // set a background with round corners - result.getWindow().setBackgroundDrawable(ContextCompat.getDrawable(getContext(), R.drawable.colorpicker_dialog_background)); + result.getWindow().setBackgroundDrawable(ContextCompat.getDrawable(getContext(), R.drawable.dmfs_colorpicker_dialog_background)); // ensure we still have the right drop shadow in place ViewCompat.setElevation(result.getWindow().getDecorView(), 24); } diff --git a/colorpicker/src/main/java/org/dmfs/android/colorpicker/PaletteFragment.java b/colorpicker/src/main/java/org/dmfs/android/colorpicker/PaletteFragment.java index 7f9c3e2..3a21d4f 100644 --- a/colorpicker/src/main/java/org/dmfs/android/colorpicker/PaletteFragment.java +++ b/colorpicker/src/main/java/org/dmfs/android/colorpicker/PaletteFragment.java @@ -69,7 +69,7 @@ public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bun /* * TODO: build the layout programmatically to get rid of the resources, so we can distribute this in a single jar */ - final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.org_dmfs_colorpickerdialog_palette_grid, container, false); + final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.dmfs_colorpickerdialog_palette_grid, container, false); final GridView gridview = (GridView) rootView.findViewById(android.R.id.content); mAdapter = new PaletteGridAdapter(getActivity(), mPalette); diff --git a/colorpicker/src/main/java/org/dmfs/android/colorpicker/PaletteGridAdapter.java b/colorpicker/src/main/java/org/dmfs/android/colorpicker/PaletteGridAdapter.java index 6c583d3..98ed5a7 100644 --- a/colorpicker/src/main/java/org/dmfs/android/colorpicker/PaletteGridAdapter.java +++ b/colorpicker/src/main/java/org/dmfs/android/colorpicker/PaletteGridAdapter.java @@ -87,7 +87,7 @@ public View getView(int position, View convertView, ViewGroup parent) View view = convertView; if (view == null) { - view = mLayoutInflater.inflate(R.layout.org_dmfs_colorpickerdialog_palette_field, null); + view = mLayoutInflater.inflate(R.layout.dmfs_colorpickerdialog_palette_field, null); } // set the background to a colored circle diff --git a/colorpicker/src/main/res/drawable-v21/colorpicker_dialog_background.xml b/colorpicker/src/main/res/drawable-v21/dmfs_colorpicker_dialog_background.xml similarity index 100% rename from colorpicker/src/main/res/drawable-v21/colorpicker_dialog_background.xml rename to colorpicker/src/main/res/drawable-v21/dmfs_colorpicker_dialog_background.xml diff --git a/colorpicker/src/main/res/layout/org_dmfs_colorpickerdialog_fragment.xml b/colorpicker/src/main/res/layout/dmfs_colorpickerdialog_fragment.xml similarity index 96% rename from colorpicker/src/main/res/layout/org_dmfs_colorpickerdialog_fragment.xml rename to colorpicker/src/main/res/layout/dmfs_colorpickerdialog_fragment.xml index cbf00da..fe40636 100644 --- a/colorpicker/src/main/res/layout/org_dmfs_colorpickerdialog_fragment.xml +++ b/colorpicker/src/main/res/layout/dmfs_colorpickerdialog_fragment.xml @@ -1,6 +1,5 @@ - - + package="org.dmfs.android.colorpicker.demo" + android:versionCode="1" + android:versionName="1.0"> + android:allowBackup="true" + android:icon="@drawable/ic_launcher" + android:label="@string/app_name" + android:theme="@style/AppTheme"> + android:name="org.dmfs.android.colorpicker.demo.DemoActivity" + android:label="@string/app_name"> - + - + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 08ae105..8d58d5c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Dec 12 09:29:26 CET 2017 +#Tue Nov 13 09:52:19 CET 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip diff --git a/settings.gradle b/settings.gradle index 919106d..4f9c7ed 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,2 @@ -include ':colorpicker', ':colorpicker-activity' +include ':colorpicker' include ':demo' -include ':app'