Skip to content

Commit

Permalink
Merge pull request #29 from ChilliBits/beta
Browse files Browse the repository at this point in the history
Release of version 2.2.1
  • Loading branch information
marcauberer authored May 25, 2020
2 parents 870f8df + 1eae3af commit 6ab1d69
Show file tree
Hide file tree
Showing 28 changed files with 230 additions and 82 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Workflow for Android CI debug build

name: Android CI

on:
push:
branches: [ master, beta ]
pull_request:
branches: [ master, beta ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Android Build
uses: vgaidarji/[email protected]
with:
args: "./gradlew assembleDebug"
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
## 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)
[![Build Status](https://travis-ci.com/ChilliBits/color-converter.svg?branch=master)](https://travis-ci.com/ChilliBits/color-converter)
![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)

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

Download Color Converter from [Google Play](https://play.google.com/store/apps/details?id=com.mrgames13.jimdo.colorconverter)!

More info on our homepage: [https://chillibits.com/color-converter](https://chillibits.com/colorconverter)
More information on our homepage: [https://chillibits.com/colorconverter](https://chillibits.com/colorconverter)

## Features

- Pick colors
- Get name of picked colors
- Display picked colors in different formats (ARGB, HEX, HSV)
Expand All @@ -23,8 +22,7 @@ More info on our homepage: [https://chillibits.com/color-converter](https://chil

## Contribute to this project
You can contribute to this project by doing following things:

- If you want to contribute new features, please fork this repository to your own GitHub account. Then build your awesome feature and post a pull request back to this repo. We will check your changes and merge your contribution asap.
- If you want to contribute new features, please fork this repository to your own GitHub account. Then build your awesome feature and open a pull request back to this repo. We will check your changes and merge your contribution asap.
- If you want to add a new translation language or improve an existing translation, please write an email to: [[email protected]](mailto:[email protected]&subject=Add%20translation)
- If you want to submit a request for a new feature, please also write an email to: [[email protected]](mailto:[email protected]&subject=Feature%20request)

Expand All @@ -38,4 +36,4 @@ Thanks to following people:

Thanks to all contributors and translators!

© ChilliBits 2017-2020 (Designed and developed by Marc Auberer)
© ChilliBits 2017-2020 (Designed and developed by Marc Auberer)
16 changes: 8 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId "com.mrgames13.jimdo.colorconverter"
minSdkVersion 21
targetSdkVersion 29
versionCode 2200
versionName "2.2.0"
versionCode 2201
versionName "2.2.1"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -36,11 +36,11 @@ android {
dependencies {
// base dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
implementation 'androidx.core:core-ktx:1.3.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta5'
implementation 'androidx.appcompat:appcompat:1.3.0-alpha01'
implementation 'androidx.core:core-ktx:1.4.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta6'
implementation 'com.google.android.instantapps:instantapps:1.1.0'
implementation 'com.google.android.play:core:1.7.2'
implementation 'com.google.android.play:core:1.7.3'
implementation 'androidx.palette:palette-ktx:1.0.0'
implementation 'com.google.android.material:material:1.2.0-alpha06'

Expand All @@ -56,8 +56,8 @@ dependencies {

// dependencies for testing
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2-beta01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-beta01'
androidTestImplementation 'androidx.test.ext:junit:1.1.2-beta02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-beta02'
}

// Task for downloading all translation files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ object Constants {
const val EXTRA_ACTION = "action"
const val EXTRA_CHOOSE_COLOR = "ChooseColor"
const val EXTRA_IMAGE_URI = "ImageUri"
const val EXTRA_INSTANT_INSTALLED = "InstantInstalled"
const val EXTRA_COLOR = "Color"
const val EXTRA_SELECTED_COLOR = "SelectedColor"

// Other constants
const val COLOR_ANIMATION_DURATION = 500L
const val NAME_SELECTED_COLOR = "Selection"
const val HSV_FORMAT_STRING = "%.02f"
const val SHARED_PREFERENCES_NAME = "com.mrgames13.jimdo.colorconverter_preferences"
const val ARGB_REMEMBER = "ArgbRemember"
const val ARGB_REMEMBER_SELECTION = "ArgbRememberSelection"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,29 @@

package com.chillibits.colorconverter.tools

import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.res.ColorStateList
import android.content.res.Resources
import android.widget.ImageView
import android.widget.Toast
import androidx.core.widget.ImageViewCompat
import com.mrgames13.jimdo.colorconverter.R

fun ImageView.setTint(color: Int) =
ImageViewCompat.setImageTintList(this, ColorStateList.valueOf(color))

fun dpToPx(dp: Int) = (dp * Resources.getSystem().displayMetrics.density).toInt()
fun dpToPx(dp: Int) = (dp * Resources.getSystem().displayMetrics.density).toInt()

fun Context.copyTextToClipboard(key: String, value: String) {
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clipboard.setPrimaryClip(ClipData.newPlainText(key, value))
Toast.makeText(this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show()
}

fun Double.round(decimals: Int): Double {
var multiplier = 1.0
repeat(decimals) { multiplier *= 10 }
return kotlin.math.round(this * multiplier) / multiplier
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ class StorageTools(val context: Context): SQLiteOpenHelper(context, "database.db
// ------------------------------------ Shared Preference --------------------------------------

fun putBoolean(name: String, value: Boolean) {
val prefs = context.getSharedPreferences("com.mrgames13.jimdo.colorconverter_preferences", Context.MODE_PRIVATE)
val prefs = context.getSharedPreferences(Constants.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)
prefs.edit().putBoolean(name, value).apply()
}

fun getBoolean(name: String, default: Boolean = false): Boolean {
val prefs = context.getSharedPreferences("com.mrgames13.jimdo.colorconverter_preferences", Context.MODE_PRIVATE)
val prefs = context.getSharedPreferences(Constants.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)
return prefs.getBoolean(name, default)
}

Expand All @@ -44,7 +44,7 @@ class StorageTools(val context: Context): SQLiteOpenHelper(context, "database.db
fun addColor(color: Color) {
try {
val values = ContentValues()
values.put("id", loadColors().size)
values.put("id", color.color)
values.put("name", color.name)
values.put("alpha", color.alpha)
values.put("red", color.red)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ class ImageActivity : AppCompatActivity() {
selectedColor.background.colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, BlendModeCompat.SRC_IN)
if(speakItem != null && speakItem!!.isChecked) speakColor()
}
image.flagView = DetailedFlagView(this, R.layout.flag_layout)
image.flagView = DetailedFlagView(this, R.layout.flag_layout).apply {
isFlipAble = false
}

selectedColor.setOnClickListener { finishWithResult(valueSelectedColor) }
vibrantColor.setOnClickListener { finishWithResult(valueVibrantColor) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ package com.chillibits.colorconverter.ui.activity

import android.animation.ValueAnimator
import android.app.Activity
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
Expand All @@ -31,10 +29,7 @@ import androidx.core.graphics.*
import androidx.core.widget.doAfterTextChanged
import com.chillibits.colorconverter.model.Color
import com.chillibits.colorconverter.tools.*
import com.chillibits.colorconverter.ui.dialog.showInstantAppInstallDialog
import com.chillibits.colorconverter.ui.dialog.showRatingDialog
import com.chillibits.colorconverter.ui.dialog.showRecommendationDialog
import com.chillibits.colorconverter.ui.dialog.showTransparencyWarning
import com.chillibits.colorconverter.ui.dialog.*
import com.google.android.instantapps.InstantApps
import com.mrgames13.jimdo.colorconverter.R
import kotlinx.android.synthetic.main.activity_main.*
Expand Down Expand Up @@ -147,7 +142,18 @@ class MainActivity : AppCompatActivity() {
copyTextToClipboard(getString(R.string.color_name), displayName.text.toString())
}
copyArgb.setOnClickListener {
copyTextToClipboard(getString(R.string.argb_code), String.format(getString(R.string.argb_clipboard), selectedColor.alpha, selectedColor.red, selectedColor.green, selectedColor.blue))
// Show multiple choice dialog
if(!st.getBoolean(Constants.ARGB_REMEMBER, false)) {
showArgbExportDialog(selectedColor.alpha, selectedColor.red, selectedColor.green, selectedColor.blue)
} else {
if(st.getBoolean(Constants.ARGB_REMEMBER_SELECTION, false)) {
copyTextToClipboard(getString(R.string.argb_code), String.format(getString(R.string.argb_clipboard),
selectedColor.alpha, selectedColor.red, selectedColor.green, selectedColor.blue))
} else {
copyTextToClipboard(getString(R.string.argb_code), String.format(getString(R.string.rgba_clipboard),
selectedColor.red, selectedColor.green, selectedColor.blue, (selectedColor.alpha / 255.0).round(3)))
}
}
}
copyHex.setOnClickListener {
copyTextToClipboard(getString(R.string.hex_code), "%08X".format(selectedColor.color).toUpperCase())
Expand Down Expand Up @@ -204,15 +210,8 @@ class MainActivity : AppCompatActivity() {
}

// Check if app was installed
if (intent.getBooleanExtra(Constants.EXTRA_INSTANT_INSTALLED, false)) {
AlertDialog.Builder(this)
.setTitle(R.string.instant_installed_t)
.setMessage(R.string.instant_installed_m)
.setPositiveButton(R.string.ok, null)
.show()
} else if (Intent.ACTION_SEND == intent.action && intent.type != null && intent.type!!.startsWith("image/")) {
if (Intent.ACTION_SEND == intent.action && intent.type != null && intent.type!!.startsWith("image/"))
pickColorFromImage(intent.getParcelableExtra(Intent.EXTRA_STREAM))
}
}

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
Expand Down Expand Up @@ -416,12 +415,6 @@ class MainActivity : AppCompatActivity() {
colorPicker.show()
}

private fun copyTextToClipboard(key: String, value: String) {
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clipboard.setPrimaryClip(ClipData.newPlainText(key, value))
Toast.makeText(this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show()
}

private fun updateDisplays(color: Color) {
// Update all views that are not animated
displayAlpha.text = color.alpha.toString()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright © Marc Auberer 2020. All rights reserved
*/

package com.chillibits.colorconverter.ui.dialog

import android.content.Context
import android.view.LayoutInflater
import androidx.appcompat.app.AlertDialog
import com.chillibits.colorconverter.tools.Constants
import com.chillibits.colorconverter.tools.StorageTools
import com.chillibits.colorconverter.tools.copyTextToClipboard
import com.chillibits.colorconverter.tools.round
import com.mrgames13.jimdo.colorconverter.R
import kotlinx.android.synthetic.main.dialog_export_argb.view.*

fun Context.showArgbExportDialog(alpha: Int, red: Int, green: Int, blue: Int) {
val st = StorageTools(this)
val view = LayoutInflater.from(this).inflate(R.layout.dialog_export_argb, null)

val dialog = AlertDialog.Builder(this)
.setView(view)
.show()

view.formatArgb.setOnClickListener {
if(view.rememberSelection.isChecked) st.putBoolean(Constants.ARGB_REMEMBER_SELECTION, true)
copyTextToClipboard(getString(R.string.argb_code),
String.format(getString(R.string.argb_clipboard), alpha, red, green, blue))
dialog.dismiss()
}
view.formatRgba.setOnClickListener {
if(view.rememberSelection.isChecked) st.putBoolean(Constants.ARGB_REMEMBER_SELECTION, false)
copyTextToClipboard(getString(R.string.argb_code),
String.format(getString(R.string.rgba_clipboard), red, green, blue, (alpha / 255.0).round(3)))
dialog.dismiss()
}
view.rememberSelection.setOnCheckedChangeListener { _, isChecked ->
st.putBoolean(Constants.ARGB_REMEMBER, isChecked)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ fun Activity.showInstantAppInstallDialog(@StringRes message: Int) {
.setNegativeText(R.string.cancel)
.onPositive {
Intent(this, MainActivity::class.java).run {
putExtra(Constants.EXTRA_INSTANT_INSTALLED, true)
InstantApps.showInstallPrompt(this@showInstantAppInstallDialog, this, Constants.REQ_INSTANT_INSTALL, "")
}
}
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/drawable/css_logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--
~ Copyright © Marc Auberer 2020. All rights reserved
-->

<vector android:height="212dp" android:viewportHeight="1024"
android:viewportWidth="726" android:width="150.30469dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#000000"
android:pathData="M170,69l0,69 55.5,-0 55.5,-0 0,-23 0,-23 -32,-0 -32,-0 0,-23 0,-23 32,-0 32,-0 0,-23 0,-23 -55.5,-0 -55.5,-0 0,69z" android:strokeColor="#00000000"/>
<path android:fillColor="#000000"
android:pathData="M302,45l0,45 32,-0 32,-0 0,4 0,4 -32,-0 -32,-0 0,21 0,21 55.5,-0 55.5,-0 0,-46 0,-46 -32,-0 -32,-0 0,-4 0,-4 32,-0 32,-0 0,-20 0,-20 -55.5,-0 -55.5,-0 0,45z" android:strokeColor="#00000000"/>
<path android:fillColor="#000000"
android:pathData="M434,45l0,45 32,-0 32,-0 0,4 0,4 -32,-0 -32,-0 0,21 0,21 55.5,-0 55.5,-0 0,-46 0,-46 -32,-0 -32,-0 0,-4 0,-4 32,-0 32,-0 0,-20 0,-20 -55.5,-0 -55.5,-0 0,45z" android:strokeColor="#00000000"/>
<path android:fillColor="#000000"
android:pathData="M0,203.2c-0.1,3.2 65.3,738.2 65.7,738.7 0.5,0.8 294.5,82.1 296.7,82.1 2.3,-0 295.6,-81 296.8,-81.9 0.4,-0.3 15.4,-164.9 33.3,-365.6 17.9,-200.8 32.8,-367.4 33.1,-370.3l0.6,-5.2 -363.1,-0 -363.1,-0 0,2.2zM590,353.7c0,1 -3.6,42.1 -8,91.3 -4.4,49.2 -13.7,152.7 -20.6,230 -6.9,77.2 -12.6,140.5 -12.7,140.6 -0.1,0.1 -42,11.7 -93.1,25.8l-93,25.8 -92.5,-25.7c-50.9,-14.1 -92.9,-26 -93.4,-26.4 -0.8,-0.8 -13.6,-141.1 -13,-142.4 0.6,-1 90.1,-0.9 90.7,0.2 0.4,0.5 2,16.8 3.7,36.3 1.8,19.4 3.3,35.4 3.4,35.6 0.1,0.1 22.8,6.3 50.4,13.8l50.3,13.5 49.2,-13.2c27,-7.2 49.8,-13.5 50.6,-14 1.2,-0.6 2.5,-11.9 6.7,-58.6 2.8,-31.8 5,-57.9 4.9,-58 -0.1,-0.2 -71,-0.6 -157.4,-0.9 -145.1,-0.7 -157.2,-0.9 -157.2,-2.4 0,-2.1 -6.8,-77.9 -7.5,-84.3l-0.6,-4.7 165.6,-0c110.9,-0 165.5,-0.3 165.5,-1 0,-0.6 1.8,-21.1 4,-45.7 2.2,-24.6 4,-44.9 4,-45 0,-0.2 -78.1,-0.3 -173.5,-0.3 -103.4,-0 -173.5,-0.4 -173.5,-0.9 0,-0.5 -1.8,-20.6 -4,-44.6 -2.2,-24 -4,-44.3 -4,-45.1 0,-1.2 32.5,-1.4 227.5,-1.4 216,-0 227.5,0.1 227.5,1.7z" android:strokeColor="#00000000"/>
</vector>
Loading

0 comments on commit 6ab1d69

Please sign in to comment.