From c09a15a3158f3a1627ef39be311f69265fbf8680 Mon Sep 17 00:00:00 2001 From: Pouya Date: Mon, 30 Jul 2018 20:33:47 +0430 Subject: [PATCH 1/2] updated sdk versions , added setTypeface method to set typeface from java code --- .idea/caches/build_file_checksums.ser | Bin 0 -> 553 bytes .idea/codeStyles/Project.xml | 29 ++++++++++++++++++ .idea/misc.xml | 3 -- .idea/modules.xml | 3 ++ app/build.gradle | 10 +++--- .../com/kingja/switchbutton/MainActivity.java | 5 +-- build.gradle | 4 ++- config.gradle | 8 ++--- gradle/wrapper/gradle-wrapper.properties | 4 +-- libk-switchbutton/build.gradle | 6 ++-- .../switchbutton/SwitchMultiButton.java | 12 ++++++++ 11 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 .idea/caches/build_file_checksums.ser create mode 100644 .idea/codeStyles/Project.xml diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser new file mode 100644 index 0000000000000000000000000000000000000000..9ca71203c541aaf8ac9f7971724e2aa47845dd18 GIT binary patch literal 553 zcmZ4UmVvdnh`~NNKUXg?FQq6yGexf?KR>5fFEb@IQ7^qHF(oHeub?PDD>b=9F91S2 zm1gFoxMk*~I%lLNXBU^|7Q2L-Ts|(GuF1r}l-a(W(##Th_( zR`y#54~r#SWM*J;W8likPfT%3OfJbU@?_vF$tX%K&dAS6sVJ~_U;qK0atQb`UUx=m5KULujwOvSddy&l9^guTExH2z_zyOYkOxc*3?K(F2waiv zx!KRKiREPj=ZrT$oa%rMFHS8f$;?YHh8k5`$WX_?22wlgSGZ#RAI+nVFV{q@EJ<2a z!XTHEnUt+tT%K8yoRL&oQj(vip9Bg-46U<|3O%aduC)A{QsA-2ejB(;7zA?ilM{15 zQ2=uw+@640xpyxJY!6U*E$MBiU{hYgAc*N5xN14q+nyY5Q)9ck?mkV<`f~_qbYejP Z4tKD=YdshALw(Dv?GH5{Yv{hO006dz#Zv$P literal 0 HcmV?d00001 diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..30aa626 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 0a0c222..c856c59 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,8 +1,5 @@ - - - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 35b2f51..d7650c0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 + compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { @@ -24,9 +24,9 @@ android { } dependencies { - compile fileTree(include: ['*.jar'], dir: 'libs') - testCompile 'junit:junit:4.12' - compile project(':libk-switchbutton') + implementation fileTree(include: ['*.jar'], dir: 'libs') + testImplementation 'junit:junit:4.12' + implementation project(':libk-switchbutton') // compile 'lib.kingja.switchbutton:switchbutton:1.1.6' - compile "com.android.support:appcompat-v7:$rootProject.ext.supportVersion" + implementation "com.android.support:appcompat-v7:$rootProject.ext.supportVersion" } diff --git a/app/src/main/java/com/kingja/switchbutton/MainActivity.java b/app/src/main/java/com/kingja/switchbutton/MainActivity.java index 849b3a6..fb4d808 100644 --- a/app/src/main/java/com/kingja/switchbutton/MainActivity.java +++ b/app/src/main/java/com/kingja/switchbutton/MainActivity.java @@ -17,6 +17,7 @@ package com.kingja.switchbutton; +import android.graphics.Typeface; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.Toast; @@ -43,8 +44,8 @@ public class MainActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - - ((SwitchMultiButton) findViewById(R.id.switchmultibutton1)).setText(tabTexts1).setOnSwitchListener(onSwitchListener); + Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/tielanti.ttf"); + ((SwitchMultiButton) findViewById(R.id.switchmultibutton1)).setText(tabTexts1).setOnSwitchListener(onSwitchListener).setTypeface(typeface); ((SwitchMultiButton) findViewById(R.id.switchmultibutton2)).setText("点个Star", "狠心拒绝").setOnSwitchListener(onSwitchListener); ((SwitchMultiButton) findViewById(switchmultibutton3)).setOnSwitchListener(onSwitchListener).setSelectedTab(1); ((SwitchMultiButton) findViewById(R.id.switchmultibutton4)).setText(tabTexts4).setOnSwitchListener(onSwitchListener); diff --git a/build.gradle b/build.gradle index eb1fe92..53b376d 100644 --- a/build.gradle +++ b/build.gradle @@ -3,15 +3,17 @@ apply from:'config.gradle' buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' + classpath 'com.android.tools.build:gradle:3.1.3' } } allprojects { repositories { jcenter() + google() } } diff --git a/config.gradle b/config.gradle index bec55a9..af309cf 100644 --- a/config.gradle +++ b/config.gradle @@ -1,10 +1,10 @@ ext { - compileSdkVersion = 25 - buildToolsVersion = "25.0.3" + compileSdkVersion = 27 + buildToolsVersion = "27.0.3" minSdkVersion = 14 - targetSdkVersion = 25 + targetSdkVersion = 27 versionCode = 5 versionName = "1.1.5" - supportVersion = '25.3.1' + supportVersion = '27.1.1' } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aedaf6f..69aadc3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Jul 09 18:58:12 CST 2017 +#Mon Jul 30 19:31:53 IRDT 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/libk-switchbutton/build.gradle b/libk-switchbutton/build.gradle index 043dd79..2a88013 100644 --- a/libk-switchbutton/build.gradle +++ b/libk-switchbutton/build.gradle @@ -18,7 +18,7 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - testCompile 'junit:junit:4.12' - compile "com.android.support:appcompat-v7:$rootProject.ext.supportVersion" + implementation fileTree(dir: 'libs', include: ['*.jar']) + testImplementation 'junit:junit:4.12' + implementation "com.android.support:appcompat-v7:$rootProject.ext.supportVersion" } diff --git a/libk-switchbutton/src/main/java/lib/kingja/switchbutton/SwitchMultiButton.java b/libk-switchbutton/src/main/java/lib/kingja/switchbutton/SwitchMultiButton.java index d939c37..411fee9 100644 --- a/libk-switchbutton/src/main/java/lib/kingja/switchbutton/SwitchMultiButton.java +++ b/libk-switchbutton/src/main/java/lib/kingja/switchbutton/SwitchMultiButton.java @@ -395,6 +395,18 @@ public SwitchMultiButton setText(String... tagTexts) { throw new IllegalArgumentException("the size of tagTexts should greater then 1"); } } + + /** + * set Typeface for buttons from java code + * + * @param typeface + */ + public void setTypeface(Typeface typeface) { + this.typeface = typeface; + mSelectedTextPaint.setTypeface(typeface); + mUnselectedTextPaint.setTypeface(typeface); + invalidate(); + } /*======================================save and restore======================================*/ @Override From 296eff25477f21feefad348cbb3d8dc0716c6823 Mon Sep 17 00:00:00 2001 From: Pouya Date: Mon, 30 Jul 2018 20:57:59 +0430 Subject: [PATCH 2/2] updated sdk versions , added setTypeface method to set typeface from java code , added google repository --- .idea/caches/build_file_checksums.ser | Bin 553 -> 0 bytes .idea/codeStyles/Project.xml | 29 -------------------------- .idea/misc.xml | 3 +++ .idea/modules.xml | 3 --- 4 files changed, 3 insertions(+), 32 deletions(-) delete mode 100644 .idea/caches/build_file_checksums.ser delete mode 100644 .idea/codeStyles/Project.xml diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser deleted file mode 100644 index 9ca71203c541aaf8ac9f7971724e2aa47845dd18..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 553 zcmZ4UmVvdnh`~NNKUXg?FQq6yGexf?KR>5fFEb@IQ7^qHF(oHeub?PDD>b=9F91S2 zm1gFoxMk*~I%lLNXBU^|7Q2L-Ts|(GuF1r}l-a(W(##Th_( zR`y#54~r#SWM*J;W8likPfT%3OfJbU@?_vF$tX%K&dAS6sVJ~_U;qK0atQb`UUx=m5KULujwOvSddy&l9^guTExH2z_zyOYkOxc*3?K(F2waiv zx!KRKiREPj=ZrT$oa%rMFHS8f$;?YHh8k5`$WX_?22wlgSGZ#RAI+nVFV{q@EJ<2a z!XTHEnUt+tT%K8yoRL&oQj(vip9Bg-46U<|3O%aduC)A{QsA-2ejB(;7zA?ilM{15 zQ2=uw+@640xpyxJY!6U*E$MBiU{hYgAc*N5xN14q+nyY5Q)9ck?mkV<`f~_qbYejP Z4tKD=YdshALw(Dv?GH5{Yv{hO006dz#Zv$P diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml deleted file mode 100644 index 30aa626..0000000 --- a/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index c856c59..0a0c222 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,8 @@ + + + \ No newline at end of file