From bc27fcdb4c070d75534275d4635e7cf146d6df78 Mon Sep 17 00:00:00 2001 From: QIUJUER Date: Sun, 12 Aug 2018 12:41:49 +0800 Subject: [PATCH 1/2] Strengthening loading color acquisition rules --- caprice/app/build.gradle | 24 ++++---- caprice/build.gradle | 2 +- .../net/qiujuer/genius/ui/widget/Loading.java | 61 +++++++++++++------ 3 files changed, 55 insertions(+), 32 deletions(-) diff --git a/caprice/app/build.gradle b/caprice/app/build.gradle index 6b034ad..217e316 100644 --- a/caprice/app/build.gradle +++ b/caprice/app/build.gradle @@ -28,17 +28,17 @@ dependencies { api 'com.android.support:appcompat-v7:27.1.1' - //api project(':ui') - //api project(':res') - //api project(':graphics') - //api project(':kit-cmd') - //api project(':kit-reflect') - //api project(':kit-handler') + api project(':ui') + api project(':res') + api project(':graphics') + api project(':kit-cmd') + api project(':kit-reflect') + api project(':kit-handler') - api 'net.qiujuer.genius:ui:2.0.1' - api 'net.qiujuer.genius:res:2.0.1' - api 'net.qiujuer.genius:graphics:2.0.1' - api 'net.qiujuer.genius:kit-cmd:2.0.1' - api 'net.qiujuer.genius:kit-reflect:2.0.1' - api 'net.qiujuer.genius:kit-handler:2.0.1' + //api 'net.qiujuer.genius:ui:2.0.1' + //api 'net.qiujuer.genius:res:2.0.1' + //api 'net.qiujuer.genius:graphics:2.0.1' + //api 'net.qiujuer.genius:kit-cmd:2.0.1' + //api 'net.qiujuer.genius:kit-reflect:2.0.1' + //api 'net.qiujuer.genius:kit-handler:2.0.1' } diff --git a/caprice/build.gradle b/caprice/build.gradle index d8436cc..6f2e37a 100644 --- a/caprice/build.gradle +++ b/caprice/build.gradle @@ -4,7 +4,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.3' + classpath 'com.android.tools.build:gradle:3.1.4' } } diff --git a/caprice/ui/src/main/java/net/qiujuer/genius/ui/widget/Loading.java b/caprice/ui/src/main/java/net/qiujuer/genius/ui/widget/Loading.java index cbf20c5..0e92f27 100644 --- a/caprice/ui/src/main/java/net/qiujuer/genius/ui/widget/Loading.java +++ b/caprice/ui/src/main/java/net/qiujuer/genius/ui/widget/Loading.java @@ -23,6 +23,7 @@ import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Build; import android.util.AttributeSet; @@ -102,7 +103,43 @@ private void init(AttributeSet attrs, int defStyleAttr, int defStyleRes) { ColorStateList colorStateList = a.getColorStateList(R.styleable.Loading_gBackgroundColor); if (colorStateList != null) bgColor = colorStateList.getDefaultColor(); - int fgColorId = a.getResourceId(R.styleable.Loading_gForegroundColor, R.array.g_default_loading_fg); + + int fgColor = Color.BLACK; + int[] fgColorArray = null; + try { + fgColor = a.getColor(R.styleable.Loading_gForegroundColor, 0); + } catch (Exception ignored) { + int fgColorId = a.getResourceId(R.styleable.Loading_gForegroundColor, R.array.g_default_loading_fg); + // Check for IDE preview render + if (!isInEditMode()) { + TypedArray taColor = resource.obtainTypedArray(fgColorId); + int length = taColor.length(); + if (length > 0) { + fgColorArray = new int[length]; + for (int i = 0; i < length; i++) { + fgColorArray[i] = taColor.getColor(i, Color.BLACK); + } + } else { + String type = resource.getResourceTypeName(fgColorId); + try { + switch (type) { + case "color": + fgColor = resource.getColor(fgColorId); + break; + case "array": + fgColorArray = resource.getIntArray(fgColorId); + break; + default: + fgColorArray = resource.getIntArray(R.array.g_default_loading_fg); + break; + } + } catch (Exception e) { + fgColorArray = resource.getIntArray(R.array.g_default_loading_fg); + } + } + taColor.recycle(); + } + } int style = a.getInt(R.styleable.Loading_gProgressStyle, 1); boolean autoRun = a.getBoolean(R.styleable.Loading_gAutoRun, true); @@ -119,24 +156,10 @@ private void init(AttributeSet attrs, int defStyleAttr, int defStyleRes) { setForegroundLineSize(fgLineSize); setBackgroundColor(bgColor); - // Check for IDE preview render - if (!isInEditMode()) { - String type = resource.getResourceTypeName(fgColorId); - try { - switch (type) { - case "color": - setForegroundColor(resource.getColor(fgColorId)); - break; - case "array": - setForegroundColor(resource.getIntArray(fgColorId)); - break; - default: - setForegroundColor(resource.getIntArray(R.array.g_default_loading_fg)); - break; - } - } catch (Exception e) { - setForegroundColor(resource.getIntArray(R.array.g_default_loading_fg)); - } + if (fgColorArray == null) { + setForegroundColor(fgColor); + } else { + setForegroundColor(fgColorArray); } } From 21cf2ff82cc246c206f98667fb0cbe7b6ceefca4 Mon Sep 17 00:00:00 2001 From: QIUJUER Date: Sun, 12 Aug 2018 14:13:00 +0800 Subject: [PATCH 2/2] Publish new version 2.1.1 --- README-ZH.md | 12 ++++++------ README.md | 12 ++++++------ caprice/gradle.properties | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README-ZH.md b/README-ZH.md index cdf5220..005fcdc 100644 --- a/README-ZH.md +++ b/README-ZH.md @@ -41,18 +41,18 @@ ```groovy dependencies { // ui module - api 'net.qiujuer.genius:ui:2.1.0' - api 'net.qiujuer.genius:res:2.1.0' + api 'net.qiujuer.genius:ui:2.1.1' + api 'net.qiujuer.genius:res:2.1.1' // use to bitmap blur and more - api 'net.qiujuer.genius:graphics:2.1.0' + api 'net.qiujuer.genius:graphics:2.1.1' // ping/telnet/tracert/dns and run cmd - api 'net.qiujuer.genius:kit-cmd:2.1.0' + api 'net.qiujuer.genius:kit-cmd:2.1.1' // shuttle between ui-thread and child-thread - api 'net.qiujuer.genius:kit-handler:2.1.0' + api 'net.qiujuer.genius:kit-handler:2.1.1' // calss reflect - api 'net.qiujuer.genius:kit-reflect:2.1.0' + api 'net.qiujuer.genius:kit-reflect:2.1.1' } ``` diff --git a/README.md b/README.md index 59acaa8..a76b613 100644 --- a/README.md +++ b/README.md @@ -42,18 +42,18 @@ ```groovy dependencies { // ui module - api 'net.qiujuer.genius:ui:2.1.0' - api 'net.qiujuer.genius:res:2.1.0' + api 'net.qiujuer.genius:ui:2.1.1' + api 'net.qiujuer.genius:res:2.1.1' // use to bitmap blur and more - api 'net.qiujuer.genius:graphics:2.1.0' + api 'net.qiujuer.genius:graphics:2.1.1' // ping/telnet/tracert/dns and run cmd - api 'net.qiujuer.genius:kit-cmd:2.1.0' + api 'net.qiujuer.genius:kit-cmd:2.1.1' // shuttle between ui-thread and child-thread - api 'net.qiujuer.genius:kit-handler:2.1.0' + api 'net.qiujuer.genius:kit-handler:2.1.1' // calss reflect - api 'net.qiujuer.genius:kit-reflect:2.1.0' + api 'net.qiujuer.genius:kit-reflect:2.1.1' } ``` diff --git a/caprice/gradle.properties b/caprice/gradle.properties index 1b13c85..eb7d62f 100644 --- a/caprice/gradle.properties +++ b/caprice/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.1.0 +VERSION_NAME=2.1.1 POM_GROUP_ID=net.qiujuer.genius POM_DESCRIPTION=Genius Lib For Android POM_URL=https://github.com/qiujuer/Genius-Android