Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into master
Browse files Browse the repository at this point in the history
# Conflicts:
#	singledateandtimepicker/src/main/java/com/github/florent37/singledateandtimepicker/widget/WheelDayPicker.java
#	singledateandtimepicker/src/main/java/com/github/florent37/singledateandtimepicker/widget/WheelPicker.java
  • Loading branch information
Abdul Khaliq authored and Abdul Khaliq committed Nov 6, 2020
2 parents 32b9b69 + 5c703d6 commit d77606c
Show file tree
Hide file tree
Showing 45 changed files with 1,180 additions and 368 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ko_fi: FlorentChampigny
github: florent37
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ freeline/
freeline_project_description.json
SingleDateAndTimePicker.iml
app/app.iml
# OS specific (mac)
.DS_Store
95 changes: 69 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@ You can now select a date and a time with only one widget !
new SingleDateAndTimePickerDialog.Builder(context)
//.bottomSheet()
//.curved()
//.minutesStep(15)

//.stepSizeMinutes(15)
//.displayHours(false)
//.displayMinutes(false)

//.todayText("aujourd'hui")

.displayListener(new SingleDateAndTimePickerDialog.DisplayListener() {
@Override
public void onDisplayed(SingleDateAndTimePicker picker) {
//retrieve the SingleDateAndTimePicker
}
})

@Override
public void onDisplayed(SingleDateAndTimePicker picker) {
// Retrieve the SingleDateAndTimePicker
}

@Override
public void onClosed(SingleDateAndTimePicker picker) {
// On dialog closed
}
})
.title("Simple")
.listener(new SingleDateAndTimePickerDialog.Listener() {
@Override
Expand All @@ -48,7 +49,7 @@ new SingleDateAndTimePickerDialog.Builder(context)
new DoubleDateAndTimePickerDialog.Builder(context)
//.bottomSheet()
//.curved()
//.minutesStep(15)
//.stepSizeMinutes(15)
.title("Double")
.tab0Text("Depart")
.tab1Text("Return")
Expand All @@ -66,7 +67,6 @@ new DoubleDateAndTimePickerDialog.Builder(context)

```java
new SingleDateAndTimePickerDialog.Builder(this)

.bottomSheet()
.curved()
.displayMinutes(false)
Expand All @@ -88,7 +88,6 @@ new SingleDateAndTimePickerDialog.Builder(this)
android:layout_height="230dp"
app:picker_curved="true"
app:picker_cyclic="true"
app:picker_canBeOnPast="false"
app:picker_visibleItemCount="7"
/>
```
Expand Down Expand Up @@ -116,9 +115,7 @@ new DoubleDateAndTimePickerDialog.Builder(context)
You can change the minutes steps (default : 5min)
```java
new SingleDateAndTimePickerDialog.Builder(context)

.minutesStep(15)

.stepSizeMinutes(15)
.display();
```

Expand All @@ -128,53 +125,99 @@ And change some colors

```java
new SingleDateAndTimePickerDialog.Builder(context)

.backgroundColor(Color.BLACK)
.mainColor(Color.GREEN)
.titleColor(Color.WHITE)

.display();
```

# Date range

Force user to select a date between a range
Require user to select a date between a range

```java
new SingleDateAndTimePickerDialog.Builder(context)

.defaultDate(defaultDate)
.minDateRange(minDate)
.maxDateRange(maxDate)

.display();
```

Or simply force user to select a future date
Or simply require user to select a future date

```java
new SingleDateAndTimePickerDialog.Builder(context)

.mustBeOnFuture()

.display();
```

# Changing typeface

```java
final SingleDateAndTimePicker singleDateAndTimePicker2 = findViewById(R.id.single_day_picker2);
singleDateAndTimePicker2.setTypeface(ResourcesCompat.getFont(this, R.font.dinot_regular));
```

Or pass it as an attribute in the XML layout. (See XML section on how to use it.)

# XML

Some/most options are also available via XML:

```
<com.github.florent37.singledateandtimepicker.SingleDateAndTimePicker
android:id="@+id/single_day_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:picker_itemSpacing="6dp"
app:picker_curvedMaxAngle="45"
app:picker_curved="true"
app:picker_selectorColor="@android:color/transparent"
app:picker_stepSizeHours="2"
app:picker_stepSizeMinutes="5"
app:picker_cyclic="false"
app:picker_dayCount="31"
app:picker_mustBeOnFuture="true"
app:picker_visibleItemCount="7"
app:fontFamily="@font/dinot_bold"
/>
```

* picker_itemSpacing: Margin between items. Only has effect with
height=wrap-content
* picker_curvedMaxAngle sets the max angle of top/bottom items. If 45
then the visible 'window' of the wheel is a 'quarter' of the circle.
If 90 (default) its rolling on a half-circle
* `app:fontFamily` or `android:fontFamily` sets the typeface/font to be
used with the date picker.
Note - For api below v-16 use `app:fontFamily`

Get divider lines around selected by overwriting one or more of
```
<color name="picker_default_divider_color">@android:color/transparent</color>
<dimen name="picker_default_divider_height">1dp</dimen>
<drawable name="picker_default_divider">@drawable/picker_divider</drawable>
```
Use in conjuction with
`app:picker_selectorColor="@android:color/transparent"` on layout.

# Download

<a href='https://ko-fi.com/A160LCC' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>

In your module [![Download](https://api.bintray.com/packages/florent37/maven/SingleDateAndTimePicker/images/download.svg)](https://bintray.com/florent37/maven/SingleDateAndTimePicker/_latestVersion)
```groovy
compile 'com.github.florent37:singledateandtimepicker:(last version)'
implementation 'com.github.florent37:singledateandtimepicker:2.2.7'
//compatible with androidX
```

# Credits

Author: Florent Champigny [http://www.florentchampigny.com/](http://www.florentchampigny.com/)
Author: Florent Champigny

Blog : [http://www.tutos-android-france.com/](http://www.tutos-android-france.com/)

Fiches Plateau Moto : [https://www.fiches-plateau-moto.fr/](https://www.fiches-plateau-moto.fr/)

<a href="https://goo.gl/WXW8Dc">
<img alt="Android app on Google Play" src="https://developer.android.com/images/brand/en_app_rgb_wo_45.png" />
Expand Down
14 changes: 9 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}

// The demo-app uses butterknife which require java8
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
android {
lintOptions {
abortOnError false
Expand All @@ -24,9 +28,9 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:' + project.supportVersion
implementation 'com.android.support:design:' + project.supportVersion
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation "androidx.appcompat:appcompat:1.1.0"
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
implementation project(':singledateandtimepicker')
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.github.florent37.sample.singledateandtimepicker;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.res.ResourcesCompat;

import com.github.florent37.singledateandtimepicker.SingleDateAndTimePicker;
import java.util.Date;

public class SingleDatePickerMainActivity extends AppCompatActivity {

Expand All @@ -14,19 +15,22 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.single_date_picker_activity_main);

final SingleDateAndTimePicker singleDateAndTimePicker = (SingleDateAndTimePicker) findViewById(R.id.single_day_picker);
singleDateAndTimePicker.addOnDateChangedListener(new SingleDateAndTimePicker.OnDateChangedListener() {
@Override
public void onDateChanged(String displayed, Date date) {
display(displayed);
}
});
final SingleDateAndTimePicker singleDateAndTimePicker = findViewById(R.id.single_day_picker);
final SingleDateAndTimePicker singleDateAndTimePicker2 = findViewById(R.id.single_day_picker2);
// Example for setting default selected date to yesterday
// Calendar instance = Calendar.getInstance();
// instance.add(Calendar.DATE, -1 );
// singleDateAndTimePicker.setDefaultDate(instance.getTime());
SingleDateAndTimePicker.OnDateChangedListener changeListener = (displayed, date) -> display(displayed);
singleDateAndTimePicker.addOnDateChangedListener(changeListener);
singleDateAndTimePicker2.addOnDateChangedListener(changeListener);

//singleDateAndTimePicker.setTypeface(Typeface.DEFAULT);
singleDateAndTimePicker2.setTypeface(ResourcesCompat.getFont(this, R.font.dinot_regular));

findViewById(R.id.toggleEnabled).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
singleDateAndTimePicker.setEnabled(!singleDateAndTimePicker.isEnabled());
}
findViewById(R.id.toggleEnabled).setOnClickListener(v -> {
singleDateAndTimePicker.setEnabled(!singleDateAndTimePicker.isEnabled());
singleDateAndTimePicker2.setEnabled(!singleDateAndTimePicker2.isEnabled());
});
}

Expand Down
Loading

0 comments on commit d77606c

Please sign in to comment.