Skip to content

Commit

Permalink
Merge pull request #193 from chillibits/dev
Browse files Browse the repository at this point in the history
Release of version 2.7.0
  • Loading branch information
marcauberer authored Jul 31, 2021
2 parents 59d53e0 + 13e43aa commit 64eb2f9
Show file tree
Hide file tree
Showing 20 changed files with 166 additions and 125 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Color Converter
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/cb98dbe7ca6d46af8b385dadd618c446)](https://app.codacy.com/gh/ChilliBits/color-converter?utm_source=github.com&utm_medium=referral&utm_content=ChilliBits/color-converter&utm_campaign=Badge_Grade_Dashboard)
![Android CI](https://github.com/chillibits/color-converter/workflows/Android%20CI/badge.svg)
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/chillibits/color-converter?include_prereleases)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)

Color Converter is an Android app to pick, display and convert colors.

Expand All @@ -19,6 +19,7 @@ More information on the projects website: [https://chillibits.com/colorconverter
- Save / load colors
- Export saved colors to Adobe color exchange formats (ACO / ASE)
- Copy colors to clipboard
- Dark mode

## Screenshots (Android 11)
<img src="media/1.png" width="275" title="Screenshot 1"> <img src="media/2.png" width="275" title="Screenshot 2"> <img src="media/3.png" width="275" title="Screenshot 3">
Expand All @@ -37,6 +38,7 @@ Thanks to following people:
- [ColorPickerView](https://github.com/skydoves/ColorPickerView) by Jaewoong Eum
- [AndroidIconics](https://github.com/mikepenz/Android-Iconics) by Mike Penz
- [MaterialStyledDialogs](https://github.com/javiersantos/MaterialStyledDialogs) by Javier Santos
- [FiveStarMe](https://github.com/numerative/Five-Star-Me) by Michael Hathi
- [SimpleSettings](https://github.com/marcauberer/simple-settings) by Marc Auberer
- [AdobeColorTool](https://github.com/marcauberer/adobe-color-tool) by Marc Auberer

Expand Down
23 changes: 12 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ android {
applicationId "com.mrgames13.jimdo.colorconverter"
minSdkVersion 21
targetSdkVersion 30
versionCode 2602
versionName "2.6.2"
versionCode 2700
versionName "2.7.0"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -45,27 +45,28 @@ android {

dependencies {
// base dependencies
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.core:core-ktx:1.6.0-beta02'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'com.google.android.instantapps:instantapps:1.1.0'
implementation 'com.google.android.play:core:1.10.0'
implementation 'androidx.palette:palette-ktx:1.0.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.fragment:fragment-ktx:1.3.4'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.fragment:fragment-ktx:1.3.6'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'

// External dependencies
implementation 'net.margaritov.preference.colorpicker.ColorPickerPreference:ColorPickerPreference:1.0.0'
implementation 'com.fxn769:pix:1.5.6'
implementation 'com.github.skydoves:colorpickerview:2.2.3'
implementation 'com.mikepenz:iconics-core:5.2.8'
implementation 'com.mikepenz:iconics-core:5.3.0'
implementation 'com.mikepenz:material-design-iconic-typeface:2.2.0.8-kotlin@aar'
implementation 'com.github.javiersantos:MaterialStyledDialogs:3.0.2'
implementation 'com.github.numerative:Five-Star-Me:2.1.1'

// ChilliBits dependencies
implementation 'com.chillibits:simplesettings:1.3.0'
implementation 'com.chillibits:simplesettings:1.3.1'
implementation 'com.chillibits:adobecolortool:1.0.1'

// Room dependencies
Expand All @@ -79,8 +80,8 @@ dependencies {

// dependencies for testing
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

// Task for downloading all translation files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ClipboardTools(
private val ct: ColorTools
) {

fun copyNameToClipboard(name: String) = context.copyTextToClipboard(context.getString(R.string.color_name), name)
fun copyNameToClipboard(name: String) = context.copyTextToClipboard(context.getString(R.string.name), name)

fun copyArgbToClipboard(color: Color) = context.run {
if (getPrefBooleanValue(Constants.ENABLE_ALPHA, true)) {
Expand Down Expand Up @@ -54,9 +54,9 @@ class ClipboardTools(
copyTextToClipboard(
getString(R.string.hex_code),
if (getPrefBooleanValue(Constants.ENABLE_ALPHA, true))
"#%08X".format(color.color).toUpperCase(Locale.getDefault())
"#%08X".format(color.color).uppercase(Locale.getDefault())
else
"#%06X".format(0xFFFFFF and color.color).toUpperCase(Locale.getDefault())
"#%06X".format(0xFFFFFF and color.color).uppercase(Locale.getDefault())
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.chillibits.simplesettings.tool.getPrefObserver
import com.google.android.instantapps.InstantApps
import com.mrgames13.jimdo.colorconverter.R
import dagger.hilt.android.AndroidEntryPoint
import five.star.me.FiveStarMe
import kotlinx.android.synthetic.main.activity_image.*
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.dialog_edit_hex.view.*
Expand Down Expand Up @@ -76,11 +77,23 @@ class MainActivity : AppCompatActivity(), ColorsAdapter.ColorSelectionListener,
initializeButtonSection()
setDefaultComponentValues()

// Check if the in-app rating dialog can be displayed
FiveStarMe.with(this)
.setInstallDays(7)
.setLaunchTimes(10)
.monitor()

// Redirect to ImageActivity, if needed
if (intent.hasExtra(Constants.EXTRA_ACTION) && intent.getStringExtra(Constants.EXTRA_ACTION) == "image") pickColorFromImage()
if (intent.hasExtra(Constants.EXTRA_ACTION) &&
intent.getStringExtra(Constants.EXTRA_ACTION) == "image") {
pickColorFromImage()
} else {
// Show in-app rating dialog
FiveStarMe.showRateDialogIfMeetsConditions(this)
}

// Set to choose color mode, if required
if(intent.hasExtra(Constants.EXTRA_CHOOSE_COLOR)) {
if (intent.hasExtra(Constants.EXTRA_CHOOSE_COLOR)) {
finishWithColor.setOnClickListener { finishWithSelectedColor() }
val color = intent.getIntExtra(Constants.EXTRA_CHOOSE_COLOR, android.graphics.Color.BLACK)
updateDisplays(Color(0, Constants.NAME_SELECTED_COLOR, color, -1))
Expand Down Expand Up @@ -196,10 +209,14 @@ class MainActivity : AppCompatActivity(), ColorsAdapter.ColorSelectionListener,
val dialogView = LayoutInflater.from(this).inflate(R.layout.dialog_edit_hex, container, false)
val hexValue = dialogView.dialogHex
if(!isAlphaEnabled)
hexValue.setText(String.format(getString(R.string.hex_format, "%06X".format((0xFFFFFF and vm.selectedColor.color)).toUpperCase(Locale.getDefault()))))
hexValue.setText(String.format(getString(R.string.hex_format,
"%06X".format((0xFFFFFF and vm.selectedColor.color)).uppercase(Locale.getDefault())
)))
else
hexValue.setText(String.format(getString(R.string.hex_format), "%08X".format(vm.selectedColor.color).toUpperCase(Locale.getDefault())))
Selection.setSelection(hexValue.text, hexValue.text.length)
hexValue.setText(String.format(getString(R.string.hex_format),
"%08X".format(vm.selectedColor.color).uppercase(Locale.getDefault())
))
Selection.setSelection(hexValue.text, hexValue.text.toString().length)

// Create dialog
val dialog = AlertDialog.Builder(this)
Expand Down Expand Up @@ -229,7 +246,7 @@ class MainActivity : AppCompatActivity(), ColorsAdapter.ColorSelectionListener,
val value = s.toString()
if(!value.startsWith("#")) {
hexValue.setText("#")
Selection.setSelection(hexValue.text, hexValue.text.length)
Selection.setSelection(hexValue.text, hexValue.text.toString().length)
} else {
if(value.length > 1 && !value.matches("#[a-fA-F0-9]+".toRegex())) s?.delete(value.length -1, value.length)
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = if(isAlphaEnabled) {
Expand Down Expand Up @@ -279,15 +296,18 @@ class MainActivity : AppCompatActivity(), ColorsAdapter.ColorSelectionListener,

container.dialogH.doAfterTextChanged { s ->
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled =
s.toString().isNotEmpty() && container.dialogS.text.isNotEmpty() && container.dialogV.text.isNotEmpty()
s.toString().isNotEmpty() && container.dialogS.text.toString().isNotEmpty() &&
container.dialogV.text.toString().isNotEmpty()
}
container.dialogS.doAfterTextChanged { s ->
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled =
container.dialogH.text.isNotEmpty() && s.toString().isNotEmpty() && container.dialogV.text.isNotEmpty()
container.dialogH.text.toString().isNotEmpty() && s.toString().isNotEmpty() &&
container.dialogV.text.toString().isNotEmpty()
}
container.dialogV.doAfterTextChanged { s ->
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled =
container.dialogH.text.isNotEmpty() && container.dialogS.text.isNotEmpty() && s.toString().isNotEmpty()
container.dialogH.text.toString().isNotEmpty() &&
container.dialogS.text.toString().isNotEmpty() && s.toString().isNotEmpty()
}

container.dialogH.requestFocus()
Expand Down Expand Up @@ -322,9 +342,13 @@ class MainActivity : AppCompatActivity(), ColorsAdapter.ColorSelectionListener,
}
// Update HEX TextView
displayHex.text = if(isAlphaEnabled) {
String.format(getString(R.string.hex_), "%08X".format(color.color).toUpperCase(Locale.getDefault()))
String.format(getString(R.string.hex_),
"%08X".format(color.color).uppercase(Locale.getDefault())
)
} else {
String.format(getString(R.string.hex_), "%06X".format(0xFFFFFF and color.color).toUpperCase(Locale.getDefault()))
String.format(getString(R.string.hex_),
"%06X".format(0xFFFFFF and color.color).uppercase(Locale.getDefault())
)
}
// Update HSV TextView
val hsv = FloatArray(3)
Expand Down Expand Up @@ -394,8 +418,11 @@ class MainActivity : AppCompatActivity(), ColorsAdapter.ColorSelectionListener,
getString(R.string.argb_),
vm.selectedColor.alpha, vm.selectedColor.red, vm.selectedColor.green, vm.selectedColor.blue
)
displayHex.text = String.format(getString(R.string.hex_), "%08X".format(vm.selectedColor.color).toUpperCase(
Locale.getDefault()))
displayHex.text = String.format(getString(R.string.hex_),
"%08X".format(vm.selectedColor.color).uppercase(
Locale.getDefault()
)
)
val hsv = FloatArray(3)
android.graphics.Color.RGBToHSV(vm.selectedColor.red, vm.selectedColor.green, vm.selectedColor.blue, hsv)
displayHsv.text = String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@

package com.chillibits.colorconverter.ui.dialog

import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import com.chillibits.simplesettings.tool.openGooglePlayAppSite
import com.github.javiersantos.materialstyleddialogs.MaterialStyledDialog
import com.github.javiersantos.materialstyleddialogs.enums.Style
import com.mikepenz.iconics.IconicsDrawable
import com.mikepenz.iconics.typeface.library.materialdesigniconic.MaterialDesignIconic
import com.mikepenz.iconics.utils.colorInt
import com.mrgames13.jimdo.colorconverter.R

fun Context.showRatingDialog() {
fun AppCompatActivity.showRatingDialog() {
MaterialStyledDialog.Builder(this)
.setStyle(Style.HEADER_WITH_ICON)
.setHeaderColorInt(ContextCompat.getColor(this, R.color.googlePlayHeaderColor))
Expand All @@ -29,12 +27,6 @@ fun Context.showRatingDialog() {
.setDescription(R.string.rate_m)
.setPositiveText(R.string.rate)
.setNegativeText(R.string.cancel)
.onPositive {
try {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$packageName")))
} catch (e: ActivityNotFoundException) {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=$packageName")))
}
}
.onPositive { openGooglePlayAppSite() }
.show()
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
package com.chillibits.colorconverter.ui.dialog

import android.content.Context
import android.text.InputType
import android.view.LayoutInflater
import android.view.WindowManager
import android.widget.EditText
import android.widget.FrameLayout
import androidx.appcompat.app.AlertDialog
import androidx.core.widget.doAfterTextChanged
import com.chillibits.colorconverter.tools.ColorNameTools
import com.chillibits.colorconverter.viewmodel.MainViewModel
import com.mrgames13.jimdo.colorconverter.R
import kotlinx.android.synthetic.main.dialog_rename.view.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand All @@ -22,26 +21,16 @@ fun Context.showSaveColorDialog(cnt: ColorNameTools, vm: MainViewModel) {
val defaultName = cnt.getColorNameFromColor(vm.selectedColor)

// Initialize views
val container = FrameLayout(this)
val containerParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT).apply {
marginStart = resources.getDimensionPixelSize(R.dimen.dialog_margin)
marginEnd = resources.getDimensionPixelSize(R.dimen.dialog_margin)
}
val editTextName = EditText(this).apply {
hint = getString(R.string.choose_name)
setText(defaultName)
inputType = InputType.TYPE_TEXT_VARIATION_URI
layoutParams = containerParams
}
container.addView(editTextName)
val dialogView = LayoutInflater.from(this).inflate(R.layout.dialog_rename, null)
dialogView.dialogName.setText(defaultName)

// Create dialog
val dialog = AlertDialog.Builder(this)
.setTitle(R.string.save_color)
.setView(container)
.setView(dialogView)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.save) { _, _ ->
vm.selectedColor.name = editTextName.text.toString().trim()
vm.selectedColor.name = dialogView.dialogName.text.toString().trim()
if (vm.selectedColor.name == defaultName) vm.selectedColor.name = ""
vm.selectedColor.creationTimestamp = System.currentTimeMillis()
// Insert color into local db
Expand All @@ -50,7 +39,7 @@ fun Context.showSaveColorDialog(cnt: ColorNameTools, vm: MainViewModel) {
.show()

// Prepare views
editTextName.run {
dialogView.dialogName.run {
doAfterTextChanged {
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = it.toString().isNotEmpty()
}
Expand Down
22 changes: 14 additions & 8 deletions app/src/main/res/layout/dialog_edit_hex.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">

<EditText
android:id="@+id/dialogHex"
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/dialogHexContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:inputType="textCapCharacters"
android:hint="@string/hex_code"
android:maxLength="9"
android:importantForAutofill="no"/>
android:layout_marginHorizontal="20dp"
android:hint="@string/hex_code">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/dialogHex"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:maxLength="9"
android:inputType="textCapCharacters"
android:importantForAutofill="no"/>
</com.google.android.material.textfield.TextInputLayout>
</FrameLayout>
Loading

0 comments on commit 64eb2f9

Please sign in to comment.