Skip to content

Commit

Permalink
Version 1.8 Merge 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Jamet committed Aug 14, 2017
2 parents ced3af9 + 73d5848 commit 5bded78
Show file tree
Hide file tree
Showing 14 changed files with 222 additions and 294 deletions.
31 changes: 30 additions & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Add the JitPack repository in your build.gradle at the end of repositories:
And add the dependency
```
dependencies {
compile 'com.github.Kunzisoft:Android-SwitchDateTimePicker:1.7'
compile 'com.github.Kunzisoft:Android-SwitchDateTimePicker:1.8'
}
```

Expand Down Expand Up @@ -137,6 +137,35 @@ dateTimeDialogFragment.setOnButtonClickListener(new SwitchDateTimeDialogFragment
// Show
dateTimeDialogFragment.show(getSupportFragmentManager(), "dialog_time");
```

#### Neutral button

<img src="https://raw.githubusercontent.com/Kunzisoft/Android-SwitchDateTimePicker/master/art/screen3.jpg" width="320">

To use with a neutral button, initialize with another parameter and implement the *OnButtonWithNeutralClickListener* :
```
SwitchDateTimeDialogFragment dateTimeDialogFragment = SwitchDateTimeDialogFragment.newInstance(
"Title example",
"OK",
"Cancel",
"Clean"
);
dateTimeFragment.setOnButtonClickListener(new SwitchDateTimeDialogFragment.OnButtonWithNeutralClickListener() {
@Override
public void onPositiveButtonClick(Date date) {
}
@Override
public void onNegativeButtonClick(Date date) {
}
@Override
public void onNeutralButtonClick(Date date) {
}
});
```

## Bonus
You can follow the project live on https://www.livecoding.tv/kunzisoft/

Expand Down
Binary file added art/screen3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 2 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "com.android.tools.build:gradle:2.3.3"
}
}

allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
}
}

Expand Down
19 changes: 8 additions & 11 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
apply plugin: 'com.android.application'
apply plugin: "com.android.application"

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.kunzisoft.switchdatetimepicker.sample"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
}

def supportVersion = "25.4.0"

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile project(path: ':switchdatetime')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:$supportVersion"
compile project(path: ":switchdatetime")
}
26 changes: 15 additions & 11 deletions sample/src/main/java/com/kunzisoft/switchdatetimesample/Sample.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,17 @@ protected void onCreate(Bundle savedInstanceState) {
dateTimeFragment = SwitchDateTimeDialogFragment.newInstance(
getString(R.string.label_datetime_dialog),
getString(android.R.string.ok),
getString(android.R.string.cancel)
getString(android.R.string.cancel),
getString(R.string.clean) // Optional
);
}

// Assign values we want
// Init format
final SimpleDateFormat myDateFormat = new SimpleDateFormat("d MMM yyyy HH:mm", java.util.Locale.getDefault());
dateTimeFragment.startAtCalendarView();
// Assign unmodifiable values
dateTimeFragment.set24HoursMode(false);
dateTimeFragment.setMinimumDateTime(new GregorianCalendar(2015, Calendar.JANUARY, 1).getTime());
dateTimeFragment.setMaximumDateTime(new GregorianCalendar(2025, Calendar.DECEMBER, 31).getTime());
dateTimeFragment.setDefaultDateTime(new GregorianCalendar(2017, Calendar.MARCH, 4, 15, 20).getTime());
// Or assign each element, default element is the current moment
// dateTimeFragment.setDefaultHourOfDay(15);
// dateTimeFragment.setDefaultMinute(20);
// dateTimeFragment.setDefaultDay(4);
// dateTimeFragment.setDefaultMonth(Calendar.MARCH);
// dateTimeFragment.setDefaultYear(2017);

// Define new day and month format
try {
Expand All @@ -73,14 +67,21 @@ protected void onCreate(Bundle savedInstanceState) {
}

// Set listener for date
dateTimeFragment.setOnButtonClickListener(new SwitchDateTimeDialogFragment.OnButtonClickListener() {
// Or use dateTimeFragment.setOnButtonClickListener(new SwitchDateTimeDialogFragment.OnButtonClickListener() {
dateTimeFragment.setOnButtonClickListener(new SwitchDateTimeDialogFragment.OnButtonWithNeutralClickListener() {
@Override
public void onPositiveButtonClick(Date date) {
textView.setText(myDateFormat.format(date));
}

@Override
public void onNegativeButtonClick(Date date) {
// Do nothing
}

@Override
public void onNeutralButtonClick(Date date) {
// Optional if neutral button does'nt exists
textView.setText("");
}
});
Expand All @@ -89,6 +90,9 @@ public void onNegativeButtonClick(Date date) {
buttonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Re-init each time
dateTimeFragment.startAtCalendarView();
dateTimeFragment.setDefaultDateTime(new GregorianCalendar(2017, Calendar.MARCH, 4, 15, 20).getTime());
dateTimeFragment.show(getSupportFragmentManager(), TAG_DATETIME_FRAGMENT);
}
});
Expand Down
2 changes: 2 additions & 0 deletions sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<resources>
<string name="switch_datetime_picker_name">Switch DateTime Picker</string>
<string name="open_datetime_dialog">Open DateTime Dialog</string>
<string name="open_datetime_dialog_with_neutral_button">Open DateTime Dialog with Neutral Button</string>
<string name="clean">Clean</string>
</resources>
23 changes: 10 additions & 13 deletions switchdatetime/build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
apply plugin: 'com.android.library'
apply plugin: "com.android.library"

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
buildToolsVersion "25.0.3"

defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"

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

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
}

def supportVersion = "25.4.0"

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.prolificinteractive:material-calendarview:1.4.3'
testCompile 'junit:junit:4.12'
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:$supportVersion"
compile "com.android.support:recyclerview-v7:$supportVersion"
compile "com.prolificinteractive:material-calendarview:1.4.3"
}
Loading

0 comments on commit 5bded78

Please sign in to comment.