Skip to content

Added options to set texts of more buttons via the dialog and the preference: transparency, select, custom, presets #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 13 additions & 47 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,49 +1,15 @@
########### Specifies intentionally untracked files to ignore ###########

### Gradle
.gradle/
build/

### IntelliJ IDEA
/.idea
*.iml
*.iws
captures/
.navigation/
local.properties
bin/
gen/
out/
*.apk
*.ap_

### Android
*.jks
*.dex

### Java
*.class
hs_err_pid*

### Windows
Desktop.ini
Thumbs.db
ehthumbs.db

### OSX
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store

### Linux
*~
.fuse_hidden*
.directory
.Trash-*

### Logs
*.log

### Crashlytics
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions .idea/codeStyles

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,21 @@ Note: Using AndroidX's `PreferenceFragmentCompat`? Then use `com.jaredrummler.an

You can add attributes to customize the `ColorPreference`:

| name | type | documentation |
|---------------------|-----------|---------------------------------------------------------------------------------------|
| cpv_dialogType | enum | "custom" to show the color picker, "preset" to show pre-defined colors |
| cpv_showAlphaSlider | boolean | Show a slider for changing the alpha of a color (adding transparency) |
| cpv_colorShape | enum | "square" or "circle" for the shape of the color preview |
| cpv_colorPresets | reference | An int-array of pre-defined colors to show in the dialog |
| cpv_dialogTitle | reference | The string resource id for the dialog title. By default the title is "Select a Color" |
| cpv_showColorShades | boolean | true to show different shades of the selected color |
| cpv_allowPresets | boolean | true to add a button to toggle to the custom color picker |
| cpv_allowCustom | boolean | true to add a button to toggle to the presets color picker |
| cpv_showDialog | boolean | true to let the ColorPreference handle showing the dialog |
| name | type | documentation |
|------------------------------|-----------|-------------------------------------------------------------------------------------------|
| cpv_dialogType | enum | "custom" to show the color picker, "preset" to show pre-defined colors |
| cpv_showAlphaSlider | boolean | Show a slider for changing the alpha of a color (adding transparency) |
| cpv_colorShape | enum | "square" or "circle" for the shape of the color preview |
| cpv_colorPresets | reference | An int-array of pre-defined colors to show in the dialog |
| cpv_dialogTitle | reference | The string resource id for the dialog title. By default the title is "Select a Color" |
| cpv_dialogPresetsActionText | reference | The string resource id for the dialog button that has "Presets" by default |
| cpv_dialogSelectActionText | reference | The string resource id for the dialog button that has "Select" by default |
| cpv_dialogCustomActionText | reference | The string resource id for the dialog button that has "Custom" by default |
| cpv_dialogTransparencyActionText | reference | The string resource id for the dialog button that has "Transparency" by default |
| cpv_showColorShades | boolean | true to show different shades of the selected color |
| cpv_allowPresets | boolean | true to add a button to toggle to the custom color picker |
| cpv_allowCustom | boolean | true to add a button to toggle to the presets color picker |
| cpv_showDialog | boolean | true to let the ColorPreference handle showing the dialog |

You can also show a `ColorPickerDialog` without using the `ColorPreference`:

Expand Down
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
42 changes: 42 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
}

android {
namespace 'com.jaredrummler.android.colorpicker.demo'
compileSdk 34

defaultConfig {
applicationId "com.jaredrummler.android.colorpicker.demo"
minSdk 21
targetSdk 34
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {

implementation libs.androidx.core.ktx
implementation libs.androidx.appcompat
implementation libs.material
implementation project(':library')

api("androidx.preference:preference-ktx:1.2.1")

}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

Expand All @@ -38,4 +38,4 @@
android:screenOrientation="portrait"/>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract class BasePreferenceFragment extends PreferenceFragmentCompat {
if (preference instanceof PreferenceCategory) {
setZeroPaddingToLayoutChildren(holder.itemView);
} else {
View iconFrame = holder.itemView.findViewById(R.id.icon_frame);
View iconFrame = holder.itemView.findViewById(android.R.id.icon_frame);
if (iconFrame != null) {
iconFrame.setVisibility(preference.getIcon() == null ? View.GONE : View.VISIBLE);
}
Expand All @@ -54,4 +54,4 @@ private void setZeroPaddingToLayoutChildren(View view) {
}
}
}
}
}
Loading