Skip to content

Commit

Permalink
Text Selected/Unselected Color (#6)
Browse files Browse the repository at this point in the history
* Add option for unselected text color

* update README.md
  • Loading branch information
DavidProdinger authored Jun 7, 2020
1 parent ba24237 commit a01735e
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 93 deletions.
48 changes: 25 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Add the dependency

```groovy
dependencies {
implementation 'com.github.DavidProdinger:weekdays-selector:1.1.0'
implementation 'com.github.DavidProdinger:weekdays-selector:1.1.1'
}
```

Expand All @@ -49,7 +49,7 @@ Add the dependency
<dependency>
<groupId>com.github.DavidProdinger</groupId>
<artifactId>weekdays-selector</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
</dependency>
```

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

```java
widget.setOnWeekdaysChangeListener(new OnWeekdaysChangeListener() {
@Override
public void onChange(View view, int clickedDayOfWeek, List<Integer> selectedDays) {
// Do Something
}
});
@Override
public void onChange(View view, int clickedDayOfWeek, List<Integer> selectedDays) {
// Do Something
}
});
```

#### OnWeekRecurrenceChange Listener
```java
widget.setOnWeekRecurrenceChangeListener(new OnWeekRecurrenceChangeListener() {
@Override
public void onWeekChange(View view, List<Integer> selectedDays, int even_week) {
// Do something else
switch (even_week) {
case WeekdaysPicker.ALL:
// if all weeks selected
break;
case WeekdaysPicker.ODD:
// if odd weeks selected
break;
case WeekdaysPicker.EVEN:
// if even weeks selected
break;
}
}
});
@Override
public void onWeekChange(View view, List<Integer> selectedDays, int even_week) {
// Do something else
switch (even_week) {
case WeekdaysPicker.ALL:
// if all weeks selected
break;
case WeekdaysPicker.ODD:
// if odd weeks selected
break;
case WeekdaysPicker.EVEN:
// if even weeks selected
break;
}
}
});
```

### Get selected Days
Expand Down Expand Up @@ -272,6 +273,7 @@ widget.setHighlightColor(Color.RED);
widget.setBackgroundColor(Color.LTGRAY);
widget.setWeekendColor(Color.GRAY);
widget.setTextColor(Color.WHITE);
widget.setTextUnselectedColor(Color.WHITE);
widget.setSundayFirstDay(true);
widget.setShowWeekend(true);
widget.setRecurrence(true);
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:4.0.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 04 16:14:46 CEST 2018
#Sun Jun 07 15:37:41 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
8 changes: 4 additions & 4 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
compileSdkVersion 29
buildToolsVersion '29.0.3'
defaultConfig {
applicationId "com.dpro.weekdaysselector"
minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
Expand All @@ -20,6 +20,6 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation project(":weekdaysselector")
}
11 changes: 8 additions & 3 deletions sample/src/main/java/com/dpro/weekdaysselector/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.dpro.widgets.OnWeekRecurrenceChangeListener;
import com.dpro.widgets.OnWeekdaysChangeListener;
import com.dpro.widgets.WeekdaysPicker;

import java.util.Arrays;
import java.util.Calendar;
import java.util.LinkedHashMap;
import java.util.List;

Expand All @@ -23,6 +23,7 @@
import static java.util.Calendar.SUNDAY;
import static java.util.Calendar.THURSDAY;
import static java.util.Calendar.TUESDAY;
import static java.util.Calendar.WEDNESDAY;

public class MainActivity extends AppCompatActivity implements CompoundButton.OnCheckedChangeListener {

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

selected_days = Arrays.asList(Calendar.SATURDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.SUNDAY);
selected_days = Arrays.asList(SATURDAY, WEDNESDAY, THURSDAY, SUNDAY);

mp.put(SUNDAY, true);
mp.put(SATURDAY, true);
Expand Down Expand Up @@ -80,6 +81,7 @@ public void onWeekChange(View view, List<Integer> selectedDays, int even_week) {
((Switch) findViewById(R.id.sw_background_color)).setOnCheckedChangeListener(this);
((Switch) findViewById(R.id.sw_weekend_color)).setOnCheckedChangeListener(this);
((Switch) findViewById(R.id.sw_text_color)).setOnCheckedChangeListener(this);
((Switch) findViewById(R.id.sw_text_unselected_color)).setOnCheckedChangeListener(this);
((Switch) findViewById(R.id.sw_sunday_first)).setOnCheckedChangeListener(this);
((Switch) findViewById(R.id.sw_show_weekend)).setOnCheckedChangeListener(this);
((Switch) findViewById(R.id.sw_recurrence)).setOnCheckedChangeListener(this);
Expand Down Expand Up @@ -120,6 +122,9 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
case R.id.sw_text_color:
widget.setTextColor(isChecked ? Color.BLUE : Color.WHITE);
break;
case R.id.sw_text_unselected_color:
widget.setTextUnselectedColor(isChecked ? Color.GRAY : Color.RED);
break;
case R.id.sw_sunday_first:
widget.setSundayFirstDay(isChecked);
break;
Expand Down
8 changes: 7 additions & 1 deletion sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@
android:id="@+id/sw_text_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text highlight Color" />
android:text="Text selected Color" />

<Switch
android:id="@+id/sw_text_unselected_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text unselected Color" />

<Switch
android:id="@+id/sw_sunday_first"
Expand Down
9 changes: 4 additions & 5 deletions weekdaysselector/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
compileSdkVersion 29
buildToolsVersion '29.0.3'

defaultConfig {
minSdkVersion 11
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"

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

implementation 'com.android.support:support-v13:28.0.0'
//implementation 'com.android.support:appcompat-v7:26.+'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* <p>
* Created by David Prodinger <[email protected]> on 24.10.2017.
*/

public interface OnWeekdaysChangeListener {
/**
* @param view View of Weekdayspicker
Expand Down
Loading

0 comments on commit a01735e

Please sign in to comment.