diff --git a/ReadMe.md b/ReadMe.md index 8c6a5a3..53fc4bd 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -8,9 +8,6 @@ SwitchDateTime Picker is a library for select a *Date* object in dialog with a D -For change color of title and icon, add -`#494949` to your resources **colors.xml** file. - ## Installation Add the JitPack repository in your build.gradle at the end of repositories: ``` @@ -24,16 +21,42 @@ Add the JitPack repository in your build.gradle at the end of repositories: And add the dependency ``` dependencies { - compile 'com.github.Kunzisoft:Android-SwitchDateTimePicker:v1.0-rc.3' + compile 'com.github.Kunzisoft:Android-SwitchDateTimePicker:v1.0-rc.4' } ``` ## Usage + +### Colors +For colors, add attributes : +` +dateTimeColorBackground, dateTimeColorLabel, dateTimeColorValue, dateTimeColorIcon +` +in your **styles.xml**, for example : +``` + + + + +``` +Note : *colorAccent* change DatePicker and TimePicker color. + +### SimpleDateFormat +You can specify a particular [*SimpleDateFormat*](https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html) for value of DateTime with **setSimpleDateFormat(SimpleDateFormat format)** + +### Sample You can see https://github.com/J-Jamet/Android-SwitchDateTimePicker/blob/master/sample/src/main/java/com/kunzisoft/switchdatetimesample/Sample.java for complete sample. - - ``` // Initialize SwitchDateTimeDialogFragment dateTimeDialogFragment = SwitchDateTimeDialogFragment.newInstance( @@ -41,14 +64,17 @@ SwitchDateTimeDialogFragment dateTimeDialogFragment = SwitchDateTimeDialogFragme getString(R.string.positive_button_datetime_picker), getString(R.string.negative_button_datetime_picker) ); + // Assign values dateTimeDialogFragment.setYear(2016); dateTimeDialogFragment.setMonth(12); -dateTimeDialogFragment.setMonth(10); +dateTimeDialogFragment.setDay(1); dateTimeDialogFragment.setHour(1); dateTimeDialogFragment.setMinute(20); + // Set SimpleDateFormat dateTimeDialogFragment.setSimpleDateFormat(new SimpleDateFormat("d MMM yyyy HH:mm", java.util.Locale.getDefault())); + // Set listener dateTimeDialogFragment.setOnButtonClickListener(new SwitchDateTimeDialogFragment.OnButtonClickListener() { @Override @@ -62,6 +88,7 @@ dateTimeDialogFragment.setOnButtonClickListener(new SwitchDateTimeDialogFragment // Date is get on negative button click } }); + // Show dateTimeDialogFragment.show(getSupportFragmentManager(), "dialog_time"); ``` diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index 068b9ee..1f25a4c 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -7,7 +7,7 @@ android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" - android:theme="@style/AppTheme2"> + android:theme="@style/SwitchDateTimeTheme"> diff --git a/sample/src/main/java/com/kunzisoft/switchdatetimesample/Sample.java b/sample/src/main/java/com/kunzisoft/switchdatetimesample/Sample.java index d2bdc94..8be73f3 100644 --- a/sample/src/main/java/com/kunzisoft/switchdatetimesample/Sample.java +++ b/sample/src/main/java/com/kunzisoft/switchdatetimesample/Sample.java @@ -44,6 +44,7 @@ protected void onCreate(Bundle savedInstanceState) { final SimpleDateFormat myDateFormat = new SimpleDateFormat("d MMM yyyy HH:mm", java.util.Locale.getDefault()); dateTimeFragment.setSimpleDateFormat(myDateFormat); dateTimeFragment.setHour(0); + dateTimeFragment.setDay(4); dateTimeFragment.setMinute(20); // Set listener for get Date dateTimeFragment.setOnButtonClickListener(new SwitchDateTimeDialogFragment.OnButtonClickListener() { diff --git a/sample/src/main/res/values/colors.xml b/sample/src/main/res/values/colors.xml index 2065dcc..3ab3e9c 100644 --- a/sample/src/main/res/values/colors.xml +++ b/sample/src/main/res/values/colors.xml @@ -3,6 +3,4 @@ #3F51B5 #303F9F #FF4081 - - @color/colorAccent diff --git a/sample/src/main/res/values/styles.xml b/sample/src/main/res/values/styles.xml index 450babc..0d90e00 100644 --- a/sample/src/main/res/values/styles.xml +++ b/sample/src/main/res/values/styles.xml @@ -1,9 +1,13 @@ - diff --git a/switchdatetime/src/main/AndroidManifest.xml b/switchdatetime/src/main/AndroidManifest.xml index 40503df..5bb4f05 100644 --- a/switchdatetime/src/main/AndroidManifest.xml +++ b/switchdatetime/src/main/AndroidManifest.xml @@ -4,7 +4,8 @@ + android:supportsRtl="true" + android:theme="@style/SwitchDateTimeTheme"> diff --git a/switchdatetime/src/main/res/layout-land/dialog_switch_datetime_picker.xml b/switchdatetime/src/main/res/layout-land/dialog_switch_datetime_picker.xml index 6bb4727..0d165a7 100644 --- a/switchdatetime/src/main/res/layout-land/dialog_switch_datetime_picker.xml +++ b/switchdatetime/src/main/res/layout-land/dialog_switch_datetime_picker.xml @@ -26,8 +26,9 @@ @@ -56,7 +59,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/label_datetime_dialog" - android:textColor="@color/dateTimeColorAccent" + android:textColor="?attr/dateTimeColorLabel" android:textStyle="bold" android:padding="5dp" android:gravity="center" diff --git a/switchdatetime/src/main/res/layout/dialog_switch_datetime_picker.xml b/switchdatetime/src/main/res/layout/dialog_switch_datetime_picker.xml index ed208bc..88543ba 100644 --- a/switchdatetime/src/main/res/layout/dialog_switch_datetime_picker.xml +++ b/switchdatetime/src/main/res/layout/dialog_switch_datetime_picker.xml @@ -6,6 +6,7 @@ android:orientation="vertical" > @@ -14,7 +15,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/label_datetime_dialog" - android:textColor="@color/dateTimeColorAccent" + android:textColor="?attr/dateTimeColorLabel" android:textStyle="bold" android:padding="5dp" android:layout_centerVertical="true" @@ -28,6 +29,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5dp" + android:textColor="?attr/dateTimeColorValue" android:layout_centerVertical="true" android:gravity="center_vertical" android:layout_toRightOf="@+id/label" @@ -39,7 +41,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_calendar_32dp" - android:tint="@color/dateTimeColorAccent" + android:tint="?attr/dateTimeColorIcon" android:contentDescription="@string/img_datetime" android:layout_centerVertical="true" android:layout_alignParentRight="true" diff --git a/switchdatetime/src/main/res/values/attrs.xml b/switchdatetime/src/main/res/values/attrs.xml new file mode 100644 index 0000000..a81bd2d --- /dev/null +++ b/switchdatetime/src/main/res/values/attrs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/switchdatetime/src/main/res/values/colors.xml b/switchdatetime/src/main/res/values/colors.xml deleted file mode 100644 index 0d9a9cd..0000000 --- a/switchdatetime/src/main/res/values/colors.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - #494949 - diff --git a/switchdatetime/src/main/res/values/styles.xml b/switchdatetime/src/main/res/values/styles.xml new file mode 100644 index 0000000..524db1f --- /dev/null +++ b/switchdatetime/src/main/res/values/styles.xml @@ -0,0 +1,13 @@ + + + +