diff --git a/ReadMe.md b/ReadMe.md index 2145be5..617a1ec 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -50,84 +50,32 @@ before the "show" ### Style You can customize the style to change color, bold, etc... of each element. -In your *styles.xml*, for example +You need to use a Theme.AppCompat theme (or descendant) with SwitchDateTime's activity. (`compile 'com.android.support:appcompat-v7:25.0.1'` in gradle) + + + +In your *styles.xml*, you can redefine each style separately, but you must keep each item, for example : change size of "year label" ``` - - - - - - - - - - - - - - - - - + + + ``` +Styles elements : https://github.com/Kunzisoft/Android-SwitchDateTimePicker/blob/master/switchdatetime/src/main/res/values/styles.xml ### Sample You can see diff --git a/art/screen1.jpg b/art/screen1.jpg new file mode 100644 index 0000000..6bee40d Binary files /dev/null and b/art/screen1.jpg differ diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index 251f789..8efba52 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -7,10 +7,10 @@ android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" + android:theme="@style/MyAppCustomTheme" android:supportsRtl="true"> + android:name="com.kunzisoft.switchdatetimesample.Sample" > diff --git a/sample/src/main/res/values/styles.xml b/sample/src/main/res/values/styles.xml index 2c0ef90..5400e62 100644 --- a/sample/src/main/res/values/styles.xml +++ b/sample/src/main/res/values/styles.xml @@ -1,15 +1,17 @@ - - - diff --git a/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/SwitchDateTimeDialogFragment.java b/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/SwitchDateTimeDialogFragment.java index bc21284..5037d61 100644 --- a/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/SwitchDateTimeDialogFragment.java +++ b/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/SwitchDateTimeDialogFragment.java @@ -101,8 +101,6 @@ public void setOnButtonClickListener(OnButtonClickListener onButtonClickListener this.mListener = onButtonClickListener; } - - @Override public void onSaveInstanceState(Bundle savedInstanceState) { // Save the current datetime @@ -143,6 +141,8 @@ public void onSaveInstanceState(Bundle savedInstanceState) { assignAllValuesToCalendar(); LayoutInflater inflater = LayoutInflater.from(getActivity()); + getActivity().getTheme().applyStyle(R.style.Theme_SwitchDateTime, false); + //getActivity().setTheme(R.style.Theme_SwitchDateTime); View dateTimeLayout = inflater.inflate(R.layout.dialog_switch_datetime_picker, (ViewGroup) getActivity().findViewById(R.id.datetime_picker)); @@ -240,7 +240,6 @@ public void onTimeSelected(int hourOfDayTime, int minuteTime) { timePicker = new SwitchTimePicker(getContext(), onTimeSelectedListener); else timePicker = new SwitchTimePicker(getContext(), onTimeSelectedListener, savedInstanceState); - timePicker = new SwitchTimePicker(getContext(), onTimeSelectedListener, savedInstanceState); timePicker.setIs24HourMode(is24HoursMode); timePicker.setHourOfDay(hourOfDay); timePicker.setMinute(minute); @@ -290,7 +289,7 @@ public void onYearSelected(View view, int yearPicker) { }); // Assign buttons - AlertDialog.Builder db = new AlertDialog.Builder(getActivity()); + AlertDialog.Builder db = new AlertDialog.Builder(getContext()); db.setView(dateTimeLayout); if(mPositiveButton == null) mPositiveButton = getString(R.string.positive_button_datetime_picker); diff --git a/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/time/SwitchTimePicker.java b/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/time/SwitchTimePicker.java index ed5a97c..207e8e7 100644 --- a/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/time/SwitchTimePicker.java +++ b/switchdatetime/src/main/java/com/kunzisoft/switchdatetime/time/SwitchTimePicker.java @@ -78,8 +78,8 @@ public class SwitchTimePicker implements RadialPickerLayout.OnValueSelectedListe private View mAmPmHitspace; private RadialPickerLayout mTimePicker; - private int mColorAccent; - private int mColor; + //private int mColorAccent; + //private int mColor; private String mAmText; private String mPmText; @@ -107,8 +107,6 @@ public class SwitchTimePicker implements RadialPickerLayout.OnValueSelectedListe // Enable/Disable Vibrations private boolean mVibrate = true; - private boolean mCloseOnSingleTapMinute; - public SwitchTimePicker(Context context, OnTimeSelectedListener callback) { mContext = context; @@ -167,10 +165,6 @@ public void setVibrate(boolean vibrate) { mTimePicker.setVibrate(vibrate); } - public void setCloseOnSingleTapMinute(boolean closeOnSingleTapMinute) { - mCloseOnSingleTapMinute = closeOnSingleTapMinute; - } - public View onCreateView(final View view, Bundle savedInstanceState) { KeyboardListener keyboardListener = new KeyboardListener(); @@ -194,10 +188,10 @@ public View onCreateView(final View view, TypedValue typedValueColorAccent = new TypedValue(); TypedValue typedValueColor = new TypedValue(); Resources.Theme theme = mContext.getTheme(); - theme.resolveAttribute(com.kunzisoft.switchdatetime.R.attr.timeLabelColorAccent, typedValueColorAccent, true); - theme.resolveAttribute(com.kunzisoft.switchdatetime.R.attr.timeLabelColor, typedValueColor, true); - mColorAccent = typedValueColorAccent.data; - mColor = typedValueColor.data; + theme.resolveAttribute(R.attr.dateTimeLabelAccentColor, typedValueColorAccent, true); + theme.resolveAttribute(R.attr.dateTimeLabelColor, typedValueColor, true); + //mColorAccent = typedValueColorAccent.data; + //mColor = typedValueColor.data; if (Build.VERSION.SDK_INT <= 14) { @@ -419,10 +413,12 @@ private void setCurrentItemShowing(int index, boolean animateCircle, boolean del labelToAnimate = mMinuteView; } + /* int hourColor = (index == HOUR_INDEX) ? mColorAccent : mColor; int minuteColor = (index == MINUTE_INDEX) ? mColorAccent : mColor; mHourView.setTextColor(hourColor); mMinuteView.setTextColor(minuteColor); + */ ObjectAnimator pulseAnimator = Utils.getPulseAnimator(labelToAnimate, 0.85f, 1.1f); if (delayLabelAnimate) { @@ -639,10 +635,10 @@ private void updateDisplay(boolean allowEmptyDisplay) { String.format(minuteFormat, values[1]).replace(' ', mPlaceholderText); mHourView.setText(hourStr); mHourSpaceView.setText(hourStr); - mHourView.setTextColor(mColor); + //mHourView.setTextColor(mColor); mMinuteView.setText(minuteStr); mMinuteSpaceView.setText(minuteStr); - mMinuteView.setTextColor(mColor); + //mMinuteView.setTextColor(mColor); if (!mIs24HourMode) { updateAmPmDisplay(values[2]); } 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 83d2a69..e4418ae 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 @@ -7,14 +7,14 @@ + switch:timeCircleColor="?attr/timeCircleColor" + switch:timeCenterColor="?attr/timeSelectorColor" + switch:timeSelectorColor="?attr/timeSelectorColor" + switch:timeCircularNumbersColor="?attr/timeCircularNumbersColor" + switch:amPmBackgroundColor="?attr/timeAmPmBackgroundColor" + switch:amPmSelectBackgroundColor="?attr/timeAmPmSelectBackgroundColor" + switch:amPmTextColor="?attr/timeAmPmTextColor"/> 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 e603eca..bcef2b3 100644 --- a/switchdatetime/src/main/res/layout/dialog_switch_datetime_picker.xml +++ b/switchdatetime/src/main/res/layout/dialog_switch_datetime_picker.xml @@ -7,14 +7,14 @@ android:orientation="vertical"> + switch:timeCircleColor="?attr/timeCircleColor" + switch:timeCenterColor="?attr/timeSelectorColor" + switch:timeSelectorColor="?attr/timeSelectorColor" + switch:timeCircularNumbersColor="?attr/timeCircularNumbersColor" + switch:amPmBackgroundColor="?attr/timeAmPmBackgroundColor" + switch:amPmSelectBackgroundColor="?attr/timeAmPmSelectBackgroundColor" + switch:amPmTextColor="?attr/timeAmPmTextColor"/> - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - + + @@ -54,7 +44,7 @@ - + diff --git a/switchdatetime/src/main/res/values/styles.xml b/switchdatetime/src/main/res/values/styles.xml index 96660a1..f3565b6 100644 --- a/switchdatetime/src/main/res/values/styles.xml +++ b/switchdatetime/src/main/res/values/styles.xml @@ -1,65 +1,59 @@ + - + - + - +