Skip to content

Commit

Permalink
Convert colorpicker into a library
Browse files Browse the repository at this point in the history
&  modernize gradle files

Signed-off-by: sunilpaulmathew <[email protected]>
  • Loading branch information
sunilpaulmathew committed Jan 13, 2025
1 parent acf0d4a commit 4fd29c1
Show file tree
Hide file tree
Showing 29 changed files with 146 additions and 95 deletions.
32 changes: 17 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.application'
plugins {
alias(libs.plugins.androidApplication)
}

def keystoreFile = rootProject.file("app/sp.jks")

Expand Down Expand Up @@ -72,20 +74,20 @@ android {
}

dependencies {
implementation 'androidx.biometric:biometric:1.1.0'
implementation 'androidx.multidex:multidex:2.0.1'
playImplementation 'com.android.billingclient:billing:7.1.1'
api(project(":colorpicker"))
implementation libs.biometric
implementation libs.multidex
playImplementation libs.billing

def sCommon_Version = 'efc9dce669'
implementation "com.github.sunilpaulmathew.sCommon:adapters:${sCommon_Version}"
implementation "com.github.sunilpaulmathew.sCommon:credits:${sCommon_Version}"
implementation "com.github.sunilpaulmathew.sCommon:crashreporter:${sCommon_Version}"
implementation "com.github.sunilpaulmathew.sCommon:fileutils:${sCommon_Version}"
implementation "com.github.sunilpaulmathew.sCommon:permissionutils:${sCommon_Version}"
implementation "com.github.sunilpaulmathew.sCommon:themeutils:${sCommon_Version}"
implementation "com.github.sunilpaulmathew.sCommon:translatorutils:${sCommon_Version}"
implementation libs.adapters
implementation libs.credits
implementation libs.crashreporter
implementation libs.fileutils
implementation libs.permissionutils
implementation libs.themeutils
implementation libs.translatorutils

implementation "com.google.android.material:material:1.12.0"
implementation "com.google.code.gson:gson:2.10.1"
implementation 'me.dm7.barcodescanner:zxing:1.9.8'
implementation libs.material
implementation libs.gson
implementation libs.zxing
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
import com.google.android.material.textview.MaterialTextView;
import com.sunilpaulmathew.snotz.R;
import com.sunilpaulmathew.snotz.adapters.ColorCustomizationsAdapter;
import com.sunilpaulmathew.snotz.colorpicker.ColorPickerDialog;
import com.sunilpaulmathew.snotz.utils.Security;
import com.sunilpaulmathew.snotz.utils.sNotzColor;
import com.sunilpaulmathew.snotz.utils.serializableItems.CheckListItems;

import java.util.ArrayList;

import in.sunilpaulmathew.colorpicker.ColorPickerDialog;
import in.sunilpaulmathew.sCommon.CommonUtils.sCommonUtils;

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.google.android.material.textview.MaterialTextView;
import com.sunilpaulmathew.snotz.R;
import com.sunilpaulmathew.snotz.adapters.CheckListAdapter;
import com.sunilpaulmathew.snotz.colorpicker.ColorPickerDialog;
import com.sunilpaulmathew.snotz.utils.AppSettings;
import com.sunilpaulmathew.snotz.utils.CheckLists;
import com.sunilpaulmathew.snotz.utils.Utils;
Expand All @@ -38,6 +37,7 @@
import java.util.List;
import java.util.Objects;

import in.sunilpaulmathew.colorpicker.ColorPickerDialog;
import in.sunilpaulmathew.sCommon.CommonUtils.sCommonUtils;

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.google.gson.JsonObject;
import com.sunilpaulmathew.snotz.R;
import com.sunilpaulmathew.snotz.adapters.CheckListAdapter;
import com.sunilpaulmathew.snotz.colorpicker.ColorPickerDialog;
import com.sunilpaulmathew.snotz.utils.AppSettings;
import com.sunilpaulmathew.snotz.utils.CheckLists;
import com.sunilpaulmathew.snotz.utils.Utils;
Expand All @@ -49,6 +48,7 @@
import java.util.List;
import java.util.Objects;

import in.sunilpaulmathew.colorpicker.ColorPickerDialog;
import in.sunilpaulmathew.sCommon.CommonUtils.sCommonUtils;
import in.sunilpaulmathew.sCommon.CommonUtils.sExecutor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.sunilpaulmathew.snotz.BuildConfig;
import com.sunilpaulmathew.snotz.R;
import com.sunilpaulmathew.snotz.adapters.SettingsAdapter;
import com.sunilpaulmathew.snotz.colorpicker.ColorPickerDialog;
import com.sunilpaulmathew.snotz.utils.AppSettings;
import com.sunilpaulmathew.snotz.utils.Billing;
import com.sunilpaulmathew.snotz.utils.CheckLists;
Expand All @@ -43,6 +42,7 @@
import java.util.Objects;
import java.util.concurrent.Executor;

import in.sunilpaulmathew.colorpicker.ColorPickerDialog;
import in.sunilpaulmathew.sCommon.CommonUtils.sCommonUtils;
import in.sunilpaulmathew.sCommon.Credits.sCreditsUtils;
import in.sunilpaulmathew.sCommon.FileUtils.sFileUtils;
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
<item name="android:windowIsTranslucent">true</item>
</style>

<style name="Divider" >
<item name="android:background">?android:attr/listDivider</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">2dp</item>
</style>

<style name="AppTheme.Title" parent="AppTheme">
<item name="android:textSize">35sp</item>
<item name="android:gravity">start|center</item>
<item name="android:layout_gravity">start|center</item>
<item name="android:layout_marginStart">15dp</item>
<item name="android:textStyle">bold</item>
</style>

<style name="Divider" >
<item name="android:background">?android:attr/listDivider</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">2dp</item>
</style>
</resources>
25 changes: 3 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.3.2'
}
}

allprojects {
repositories {
google()
mavenCentral()
maven {
url "https://jitpack.io"
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
plugins {
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidLibrary) apply false
}
1 change: 1 addition & 0 deletions colorpicker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
17 changes: 17 additions & 0 deletions colorpicker/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
alias(libs.plugins.androidLibrary)
}

android {
namespace 'in.sunilpaulmathew.colorpicker'
compileSdk 34

defaultConfig {
minSdk 19
consumerProguardFiles("proguard-rules.pro")
}
}

dependencies {
implementation libs.material
}
2 changes: 2 additions & 0 deletions colorpicker/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest />
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sunilpaulmathew.snotz.colorpicker;
package in.sunilpaulmathew.colorpicker;

import android.content.Context;
import android.content.DialogInterface;
Expand All @@ -9,12 +9,12 @@
import androidx.appcompat.widget.LinearLayoutCompat;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.sunilpaulmathew.snotz.R;
import com.sunilpaulmathew.snotz.colorpicker.interfaces.ColorPickerClickListener;
import com.sunilpaulmathew.snotz.colorpicker.interfaces.OnColorSelectedListener;
import com.sunilpaulmathew.snotz.colorpicker.views.AlphaSlider;
import com.sunilpaulmathew.snotz.colorpicker.views.ColorPickerView;
import com.sunilpaulmathew.snotz.colorpicker.views.LightnessSlider;

import in.sunilpaulmathew.colorpicker.interfaces.ColorPickerClickListener;
import in.sunilpaulmathew.colorpicker.interfaces.OnColorSelectedListener;
import in.sunilpaulmathew.colorpicker.views.AlphaSlider;
import in.sunilpaulmathew.colorpicker.views.ColorPickerView;
import in.sunilpaulmathew.colorpicker.views.LightnessSlider;

public class ColorPickerDialog {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sunilpaulmathew.snotz.colorpicker.interfaces;
package in.sunilpaulmathew.colorpicker.interfaces;

import android.content.DialogInterface;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.sunilpaulmathew.snotz.colorpicker.interfaces;
package in.sunilpaulmathew.colorpicker.interfaces;

import android.graphics.Canvas;

import com.sunilpaulmathew.snotz.colorpicker.utils.ColorCircle;
import in.sunilpaulmathew.colorpicker.utils.ColorCircle;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sunilpaulmathew.snotz.colorpicker.interfaces;
package in.sunilpaulmathew.colorpicker.interfaces;

public interface OnColorSelectedListener {
void onColorSelected(int selectedColor);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sunilpaulmathew.snotz.colorpicker.interfaces;
package in.sunilpaulmathew.colorpicker.interfaces;

public interface OnValueChangedListener {
void onValueChanged(float value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.sunilpaulmathew.snotz.colorpicker.renderer;
package in.sunilpaulmathew.colorpicker.renderer;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

import com.sunilpaulmathew.snotz.colorpicker.interfaces.ColorWheelRenderer;
import com.sunilpaulmathew.snotz.colorpicker.utils.ColorCircle;
import com.sunilpaulmathew.snotz.colorpicker.utils.PaintBuilder;
import in.sunilpaulmathew.colorpicker.interfaces.ColorWheelRenderer;
import in.sunilpaulmathew.colorpicker.utils.ColorCircle;
import in.sunilpaulmathew.colorpicker.utils.PaintBuilder;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sunilpaulmathew.snotz.colorpicker.utils;
package in.sunilpaulmathew.colorpicker.utils;

import android.graphics.Color;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sunilpaulmathew.snotz.colorpicker.utils;
package in.sunilpaulmathew.colorpicker.utils;

import android.graphics.Canvas;
import android.graphics.Paint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sunilpaulmathew.snotz.colorpicker.utils;
package in.sunilpaulmathew.colorpicker.utils;

import android.graphics.Color;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sunilpaulmathew.snotz.colorpicker.utils;
package in.sunilpaulmathew.colorpicker.utils;

import android.graphics.Bitmap;
import android.graphics.BitmapShader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sunilpaulmathew.snotz.colorpicker.views;
package in.sunilpaulmathew.colorpicker.views;

import android.content.Context;
import android.content.res.TypedArray;
Expand All @@ -12,8 +12,8 @@
import androidx.annotation.DimenRes;
import androidx.annotation.NonNull;

import com.sunilpaulmathew.snotz.R;
import com.sunilpaulmathew.snotz.colorpicker.interfaces.OnValueChangedListener;
import in.sunilpaulmathew.colorpicker.R;
import in.sunilpaulmathew.colorpicker.interfaces.OnValueChangedListener;

public abstract class AbsCustomSlider extends View {
protected Bitmap bitmap;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sunilpaulmathew.snotz.colorpicker.views;
package in.sunilpaulmathew.colorpicker.views;

import android.content.Context;
import android.graphics.Bitmap;
Expand All @@ -7,8 +7,8 @@
import android.graphics.PorterDuff;
import android.util.AttributeSet;

import com.sunilpaulmathew.snotz.colorpicker.utils.PaintBuilder;
import com.sunilpaulmathew.snotz.colorpicker.utils.ColorPickerUtils;
import in.sunilpaulmathew.colorpicker.utils.PaintBuilder;
import in.sunilpaulmathew.colorpicker.utils.ColorPickerUtils;

public class AlphaSlider extends AbsCustomSlider {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sunilpaulmathew.snotz.colorpicker.views;
package in.sunilpaulmathew.colorpicker.views;

import android.annotation.SuppressLint;
import android.content.Context;
Expand All @@ -16,17 +16,18 @@
import androidx.appcompat.widget.AppCompatImageView;

import com.google.android.material.textfield.TextInputEditText;
import com.sunilpaulmathew.snotz.R;
import com.sunilpaulmathew.snotz.colorpicker.utils.PaintBuilder;
import com.sunilpaulmathew.snotz.colorpicker.interfaces.ColorWheelRenderer;
import com.sunilpaulmathew.snotz.colorpicker.interfaces.OnColorSelectedListener;
import com.sunilpaulmathew.snotz.colorpicker.renderer.FlowerColorWheelRenderer;
import com.sunilpaulmathew.snotz.colorpicker.utils.ColorCircle;
import com.sunilpaulmathew.snotz.colorpicker.utils.ColorCircleDrawable;
import com.sunilpaulmathew.snotz.colorpicker.utils.ColorPickerUtils;

import java.util.ArrayList;

import in.sunilpaulmathew.colorpicker.R;
import in.sunilpaulmathew.colorpicker.interfaces.ColorWheelRenderer;
import in.sunilpaulmathew.colorpicker.interfaces.OnColorSelectedListener;
import in.sunilpaulmathew.colorpicker.renderer.FlowerColorWheelRenderer;
import in.sunilpaulmathew.colorpicker.utils.ColorCircle;
import in.sunilpaulmathew.colorpicker.utils.ColorCircleDrawable;
import in.sunilpaulmathew.colorpicker.utils.ColorPickerUtils;
import in.sunilpaulmathew.colorpicker.utils.PaintBuilder;

public class ColorPickerView extends View {

private static final float STROKE_RATIO = 1.5f;
Expand Down Expand Up @@ -98,9 +99,9 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
super.onLayout(changed, left, top, right, bottom);

if (alphaSliderViewId != 0)
setAlphaSlider((AlphaSlider) getRootView().findViewById(alphaSliderViewId));
setAlphaSlider(getRootView().findViewById(alphaSliderViewId));
if (lightnessSliderViewId != 0)
setLightnessSlider((LightnessSlider) getRootView().findViewById(lightnessSliderViewId));
setLightnessSlider(getRootView().findViewById(lightnessSliderViewId));

updateColorWheel();
currentColorCircle = findNearestByColor(initialColor);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sunilpaulmathew.snotz.colorpicker.views;
package in.sunilpaulmathew.colorpicker.views;

import android.content.Context;
import android.graphics.Canvas;
Expand All @@ -7,8 +7,8 @@
import android.graphics.PorterDuff;
import android.util.AttributeSet;

import com.sunilpaulmathew.snotz.colorpicker.utils.PaintBuilder;
import com.sunilpaulmathew.snotz.colorpicker.utils.ColorPickerUtils;
import in.sunilpaulmathew.colorpicker.utils.PaintBuilder;
import in.sunilpaulmathew.colorpicker.utils.ColorPickerUtils;

public class LightnessSlider extends AbsCustomSlider {
private int color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@
<resources>
<declare-styleable name="ColorPickerPreference">
<attr name="alphaSlider" format="boolean"/>
<attr name="alphaSliderView" format="reference"/>
<attr name="lightnessSlider" format="boolean"/>
<attr name="border" format="boolean"/>
<attr name="density" format="integer"/>
<attr name="initialColor" format="integer"/>
<attr name="lightnessSliderView" format="reference"/>
<attr name="alphaSliderView" format="reference"/>
<attr name="pickerColorEdit" format="boolean"/>
<attr name="pickerColorEditTextColor" format="integer"/>
<attr name="pickerTitle" format="reference|string"/>
<attr name="pickerButtonOk" format="reference|string"/>
<attr name="pickerButtonCancel" format="reference|string"/>
</declare-styleable>

<declare-styleable name="AbsCustomSlider">
Expand Down
File renamed without changes.
Loading

0 comments on commit 4fd29c1

Please sign in to comment.