Skip to content

Commit a01735e

Browse files
Text Selected/Unselected Color (#6)
* Add option for unselected text color * update README.md
1 parent ba24237 commit a01735e

File tree

11 files changed

+129
-93
lines changed

11 files changed

+129
-93
lines changed

README.md

+25-23
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Add the dependency
2626

2727
```groovy
2828
dependencies {
29-
implementation 'com.github.DavidProdinger:weekdays-selector:1.1.0'
29+
implementation 'com.github.DavidProdinger:weekdays-selector:1.1.1'
3030
}
3131
```
3232

@@ -49,7 +49,7 @@ Add the dependency
4949
<dependency>
5050
<groupId>com.github.DavidProdinger</groupId>
5151
<artifactId>weekdays-selector</artifactId>
52-
<version>1.1.0</version>
52+
<version>1.1.1</version>
5353
</dependency>
5454
```
5555

@@ -98,6 +98,7 @@ public class MainActivity extends AppCompatActivity {
9898
* `highlight_color`: Color of selected days and unselected Text (default=Color.RED)
9999
* `background_color`: Background-Color of unselected days (default=Color.LTGRAY)
100100
* `text_color`: Color of selected days text (default=Color.WHITE)
101+
* `text_unselected_color`: Color of unselected days text (default=`highlight_color`)
101102
* `sunday_first_day`: Starting with Sunday or Monday (default=true)
102103
* `show_weekend`: Display weekend (Satuarday and Sunday) (default=true)
103104
* `weekenddarker`: Allows that weekend has another color (default=false)
@@ -120,32 +121,32 @@ WeekdaysPicker widget = (WeekdaysPicker) findViewById(R.id.weekdays);
120121

121122
```java
122123
widget.setOnWeekdaysChangeListener(new OnWeekdaysChangeListener() {
123-
@Override
124-
public void onChange(View view, int clickedDayOfWeek, List<Integer> selectedDays) {
125-
// Do Something
126-
}
127-
});
124+
@Override
125+
public void onChange(View view, int clickedDayOfWeek, List<Integer> selectedDays) {
126+
// Do Something
127+
}
128+
});
128129
```
129130

130131
#### OnWeekRecurrenceChange Listener
131132
```java
132133
widget.setOnWeekRecurrenceChangeListener(new OnWeekRecurrenceChangeListener() {
133-
@Override
134-
public void onWeekChange(View view, List<Integer> selectedDays, int even_week) {
135-
// Do something else
136-
switch (even_week) {
137-
case WeekdaysPicker.ALL:
138-
// if all weeks selected
139-
break;
140-
case WeekdaysPicker.ODD:
141-
// if odd weeks selected
142-
break;
143-
case WeekdaysPicker.EVEN:
144-
// if even weeks selected
145-
break;
146-
}
147-
}
148-
});
134+
@Override
135+
public void onWeekChange(View view, List<Integer> selectedDays, int even_week) {
136+
// Do something else
137+
switch (even_week) {
138+
case WeekdaysPicker.ALL:
139+
// if all weeks selected
140+
break;
141+
case WeekdaysPicker.ODD:
142+
// if odd weeks selected
143+
break;
144+
case WeekdaysPicker.EVEN:
145+
// if even weeks selected
146+
break;
147+
}
148+
}
149+
});
149150
```
150151

151152
### Get selected Days
@@ -272,6 +273,7 @@ widget.setHighlightColor(Color.RED);
272273
widget.setBackgroundColor(Color.LTGRAY);
273274
widget.setWeekendColor(Color.GRAY);
274275
widget.setTextColor(Color.WHITE);
276+
widget.setTextUnselectedColor(Color.WHITE);
275277
widget.setSundayFirstDay(true);
276278
widget.setShowWeekend(true);
277279
widget.setRecurrence(true);

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
google()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.2.1'
9+
classpath 'com.android.tools.build:gradle:4.0.0'
1010

1111
// NOTE: Do not place your application dependencies here; they belong
1212
// in the individual module build.gradle files

gradle.properties

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# http://www.gradle.org/docs/current/userguide/build_environment.html
77
# Specifies the JVM arguments used for the daemon process.
88
# The setting is particularly useful for tweaking memory settings.
9+
android.enableJetifier=true
10+
android.useAndroidX=true
911
org.gradle.jvmargs=-Xmx1536m
1012
# When configured, Gradle will run in incubating parallel mode.
1113
# This option should only be used with decoupled projects. More details, visit
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Apr 04 16:14:46 CEST 2018
1+
#Sun Jun 07 15:37:41 CEST 2020
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

sample/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 28
5-
buildToolsVersion '28.0.3'
4+
compileSdkVersion 29
5+
buildToolsVersion '29.0.3'
66
defaultConfig {
77
applicationId "com.dpro.weekdaysselector"
88
minSdkVersion 14
9-
targetSdkVersion 28
9+
targetSdkVersion 29
1010
versionCode 1
1111
versionName "1.0"
1212
}
@@ -20,6 +20,6 @@ android {
2020

2121
dependencies {
2222
implementation fileTree(dir: 'libs', include: ['*.jar'])
23-
implementation 'com.android.support:appcompat-v7:28.0.0'
23+
implementation 'androidx.appcompat:appcompat:1.1.0'
2424
implementation project(":weekdaysselector")
2525
}

sample/src/main/java/com/dpro/weekdaysselector/MainActivity.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
import android.graphics.Color;
44
import android.os.Bundle;
5-
import android.support.v7.app.AppCompatActivity;
65
import android.view.View;
76
import android.widget.CompoundButton;
87
import android.widget.LinearLayout;
98
import android.widget.Switch;
109
import android.widget.TextView;
1110

11+
import androidx.appcompat.app.AppCompatActivity;
12+
1213
import com.dpro.widgets.OnWeekRecurrenceChangeListener;
1314
import com.dpro.widgets.OnWeekdaysChangeListener;
1415
import com.dpro.widgets.WeekdaysPicker;
1516

1617
import java.util.Arrays;
17-
import java.util.Calendar;
1818
import java.util.LinkedHashMap;
1919
import java.util.List;
2020

@@ -23,6 +23,7 @@
2323
import static java.util.Calendar.SUNDAY;
2424
import static java.util.Calendar.THURSDAY;
2525
import static java.util.Calendar.TUESDAY;
26+
import static java.util.Calendar.WEDNESDAY;
2627

2728
public class MainActivity extends AppCompatActivity implements CompoundButton.OnCheckedChangeListener {
2829

@@ -37,7 +38,7 @@ protected void onCreate(Bundle savedInstanceState) {
3738
super.onCreate(savedInstanceState);
3839
setContentView(R.layout.activity_main);
3940

40-
selected_days = Arrays.asList(Calendar.SATURDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.SUNDAY);
41+
selected_days = Arrays.asList(SATURDAY, WEDNESDAY, THURSDAY, SUNDAY);
4142

4243
mp.put(SUNDAY, true);
4344
mp.put(SATURDAY, true);
@@ -80,6 +81,7 @@ public void onWeekChange(View view, List<Integer> selectedDays, int even_week) {
8081
((Switch) findViewById(R.id.sw_background_color)).setOnCheckedChangeListener(this);
8182
((Switch) findViewById(R.id.sw_weekend_color)).setOnCheckedChangeListener(this);
8283
((Switch) findViewById(R.id.sw_text_color)).setOnCheckedChangeListener(this);
84+
((Switch) findViewById(R.id.sw_text_unselected_color)).setOnCheckedChangeListener(this);
8385
((Switch) findViewById(R.id.sw_sunday_first)).setOnCheckedChangeListener(this);
8486
((Switch) findViewById(R.id.sw_show_weekend)).setOnCheckedChangeListener(this);
8587
((Switch) findViewById(R.id.sw_recurrence)).setOnCheckedChangeListener(this);
@@ -120,6 +122,9 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
120122
case R.id.sw_text_color:
121123
widget.setTextColor(isChecked ? Color.BLUE : Color.WHITE);
122124
break;
125+
case R.id.sw_text_unselected_color:
126+
widget.setTextUnselectedColor(isChecked ? Color.GRAY : Color.RED);
127+
break;
123128
case R.id.sw_sunday_first:
124129
widget.setSundayFirstDay(isChecked);
125130
break;

sample/src/main/res/layout/activity_main.xml

+7-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@
7676
android:id="@+id/sw_text_color"
7777
android:layout_width="match_parent"
7878
android:layout_height="wrap_content"
79-
android:text="Text highlight Color" />
79+
android:text="Text selected Color" />
80+
81+
<Switch
82+
android:id="@+id/sw_text_unselected_color"
83+
android:layout_width="match_parent"
84+
android:layout_height="wrap_content"
85+
android:text="Text unselected Color" />
8086

8187
<Switch
8288
android:id="@+id/sw_sunday_first"

weekdaysselector/build.gradle

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 28
5-
buildToolsVersion '28.0.3'
4+
compileSdkVersion 29
5+
buildToolsVersion '29.0.3'
66

77
defaultConfig {
88
minSdkVersion 11
9-
targetSdkVersion 28
9+
targetSdkVersion 29
1010
versionCode 1
1111
versionName "1.0"
1212

@@ -23,6 +23,5 @@ dependencies {
2323
implementation fileTree(dir: 'libs', include: ['*.jar'])
2424
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
2525

26-
implementation 'com.android.support:support-v13:28.0.0'
27-
//implementation 'com.android.support:appcompat-v7:26.+'
26+
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
2827
}

weekdaysselector/src/main/java/com/dpro/widgets/OnWeekdaysChangeListener.java

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* <p>
1010
* Created by David Prodinger <dprodinger@aon.at> on 24.10.2017.
1111
*/
12-
1312
public interface OnWeekdaysChangeListener {
1413
/**
1514
* @param view View of Weekdayspicker

0 commit comments

Comments
 (0)