Skip to content

Commit

Permalink
fixed issue of default color accent to checkbox images. it was not wo…
Browse files Browse the repository at this point in the history
…rking with pre lollipop devices.
  • Loading branch information
vansikrishna authored and bhaskarxinthe committed Mar 6, 2017
1 parent 39bf5a7 commit 2be334b
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 12 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'

classpath 'io.fabric.tools:gradle:1.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
12 changes: 9 additions & 3 deletions example/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
compileSdkVersion 24
buildToolsVersion "25.0.0"

defaultConfig {
applicationId "com.vlk.multimager.example"
minSdkVersion 19
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.0.1"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand All @@ -25,6 +26,8 @@ android {
allprojects {
repositories {
maven { url "https://jitpack.io" }
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
}

Expand All @@ -37,6 +40,9 @@ dependencies {
compile('com.github.QuadFlask:colorpicker:0.0.10@aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
transitive = true;
}
testCompile 'junit:junit:4.12'
compile project(path: ':lib')
}
3 changes: 3 additions & 0 deletions example/fabric.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Contains API Secret used to validate your application. Commit to internal source control; avoid making secret public.
#Mon Mar 06 11:55:21 IST 2017
apiSecret=08862ee8c8cad7ce97da471d4b6ba49d16f9bf13840f964b1b25a55663f0f49a
5 changes: 4 additions & 1 deletion example/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vlk.multimager.example">

<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand All @@ -14,6 +14,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="d4f9088ec85f115eeba7c8499e34061bd168f69f" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.widget.TextView;
import android.widget.Toast;

import com.crashlytics.android.Crashlytics;
import com.flask.colorpicker.ColorPickerView;
import com.flask.colorpicker.OnColorSelectedListener;
import com.flask.colorpicker.builder.ColorPickerClickListener;
Expand All @@ -38,6 +39,7 @@
import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.fabric.sdk.android.Fabric;

/**
* Created by vansikrishna on 08/06/2016.
Expand Down Expand Up @@ -70,9 +72,18 @@ public class SampleActivity extends BaseActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
Fabric.with(this, new Crashlytics());
ButterKnife.bind(this);
selectedColor = fetchAccentColor();
darkenedColor = Utils.getDarkColor(selectedColor);
Utils.setViewsColorStateList(selectedColor, darkenedColor,
customThemeButton,
multiCaptureButton,
multiPickerButton,
callImageView,
messageImageView,
contactUsTextView,
appNameTextView);
}

private int fetchAccentColor() {
Expand Down
13 changes: 11 additions & 2 deletions lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'com.android.library'
apply plugin: 'io.fabric'

android {
compileSdkVersion 23
Expand All @@ -7,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 17
targetSdkVersion 23
versionCode 4
versionName "1.0.3"
versionCode 5
versionName "1.0.4"
}
buildTypes {
release {
Expand All @@ -18,11 +19,19 @@ android {
}
}

repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v13:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-annotations:24.2.1'
compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
transitive = true;
}
}
3 changes: 3 additions & 0 deletions lib/fabric.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Contains API Secret used to validate your application. Commit to internal source control; avoid making secret public.
#Fri Mar 03 15:38:49 IST 2017
apiSecret=08862ee8c8cad7ce97da471d4b6ba49d16f9bf13840f964b1b25a55663f0f49a
4 changes: 4 additions & 0 deletions lib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<uses-feature
android:name="android.hardware.camera.flash"
android:required="false" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:label="@string/app_name"
android:supportsRtl="true">
Expand All @@ -23,6 +24,9 @@
android:theme="@style/MultimagerTheme.NoActionBar"
android:screenOrientation="portrait">
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="d4f9088ec85f115eeba7c8499e34061bd168f69f" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;

import com.crashlytics.android.Crashlytics;
import com.vlk.multimager.views.CustomProgressDialog;

import java.util.ArrayList;
import java.util.List;

import io.fabric.sdk.android.Fabric;

/**
* Created by vansikrishna on 08/06/2016.
*/
Expand All @@ -27,6 +30,7 @@ public class BaseActivity extends AppCompatActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
}

public void showProgressDialog(String message){
Expand Down
8 changes: 5 additions & 3 deletions lib/src/main/java/com/vlk/multimager/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,15 @@ public static void setViewsColorStateList(View view, int normalColor, int darken
}

public static void setViewsColorStateList(int normalColor, int darkenedColor, View... views) {
int[][] states = new int[][] {new int[] { android.R.attr.state_enabled}, new int[] { android.R.attr.state_pressed}};
int[][] states = new int[][] {new int[0] , new int[] { android.R.attr.state_pressed}};
int[] colors = new int[]{normalColor, darkenedColor};
ColorStateList colorStateList = new ColorStateList(states, colors);
for (View view : views) {
if(view instanceof AppCompatButton){
((AppCompatButton)view).setSupportBackgroundTintList(colorStateList);
if(Build.VERSION.SDK_INT >= 21)
((AppCompatButton)view).setBackgroundTintList(colorStateList);
else
((AppCompatButton)view).setSupportBackgroundTintList(colorStateList);
}
if(view instanceof AppCompatImageView){
((AppCompatImageView)view).setColorFilter(normalColor);
Expand All @@ -139,7 +142,6 @@ public static void setViewsColorStateList(int normalColor, int darkenedColor, Vi
((AppCompatTextView)view).setTextColor(normalColor);
}
}

}

public static int getDarkColor(int color){
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/res/drawable/action_button_bg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false">
<solid android:color="?attr/colorAccent" />
<!--<solid android:color="?attr/colorAccent" />-->
<size
android:width="@dimen/margin_56"
android:height="@dimen/margin_56" />
Expand Down
3 changes: 2 additions & 1 deletion lib/src/main/res/drawable/checked_button_bg.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:shape="oval"
android:useLevel="false">
<padding android:left="@dimen/margin_2"
android:right="@dimen/margin_2"
android:top="@dimen/margin_2"
android:bottom="@dimen/margin_2"/>
<solid android:color="?attr/colorAccent" />
<!--<solid android:color="?attr:colorAccent" />-->
<size
android:width="@dimen/margin_32"
android:height="@dimen/margin_32" />
Expand Down

0 comments on commit 2be334b

Please sign in to comment.