Skip to content

Commit

Permalink
Debug styles
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Jamet committed Nov 30, 2016
1 parent b17cc9b commit e29d2a9
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 166 deletions.
80 changes: 14 additions & 66 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<img src="https://raw.githubusercontent.com/J-Jamet/Android-SwitchDateTimePicker/master/art/screen1.jpg">

In your *styles.xml*, you can redefine each style separately, but you must keep each item, for example : change size of "year label"
```
<resources>
<!-- Base application theme. -->
<style name="SwitchDateTimeThemeCustom" parent="AlertDialog.AppCompat.Light">
<style name="MyAppCustomTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<!-- Custom SwitchDateTime style, each element is optional-->
<!-- Theme for SwitchDateTime -->
<style name="Theme.SwitchDateTime" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- DateTime -->
<item name="dateTimeColorBackground">#c94545</item>
<item name="dateTimeColorLabelBackground">#c94545</item>
<item name="dateTimeColorLabel">#cacaca</item>
<item name="dateTimeColorValue">#fff</item>
<item name="dateTimeColorIcon">#fff</item>
<!-- Time -->
<item name="timeLabelColorBackground">#c94545</item>
<item name="timeLabelColorAccent">#fff</item>
<item name="timeLabelColor">#fff</item>
<item name="timeColorBackground">#fff</item>
<item name="timeColorCircle">#e1e1e1</item>
<item name="timeColorCenter">#000</item>
<item name="timeColorNumbers">#494949</item>
<item name="timeColorSelector">#c94545</item>
<item name="timeAmPmColorBackground">#c94545</item>
<item name="timeAmPmColorSelectBackground">#c94545</item> <!-- Alpha is apply-->
<item name="timeAmPmColorText">#fff</item>
<!-- Date -->
<item name="dateLabelColorBackground">#c94545</item>
<item name="dateSelectDayColor">#c94545</item>
<!-- Year -->
<item name="dateSelectYearBackgroundColor">#c94545</item>
<item name="dateSelectYearTextColor">#fff</item>
</style>
<style name="Theme.SwitchDateTime.TitleDateTimeLabelText">
<item name="android:textSize">18sp</item>
<item name="android:textColor">#fff</item>
<item name="android:textStyle">bold</item>
</style>
<!-- Time precise -->
<style name="Theme.SwitchDateTime.TimeLabelText">
<item name="android:textSize">26sp</item>
<item name="android:textColor">#fff</item>
</style>
<style name="Theme.SwitchDateTime.TimeLabelAmPm">
<item name="android:textSize">12sp</item>
<item name="android:textColor">#fff</item>
<item name="android:textStyle">bold</item>
</style>
<!-- Date Precise -->
<style name="Theme.SwitchDateTime.DateLabelMonthAndDay">
<item name="android:textSize">26sp</item>
<item name="android:textColor">#fff</item>
</style>
<!-- Year Precise -->
<style name="Theme.SwitchDateTime.DateLabelYear">
<item name="android:textSize">16sp</item>
<item name="android:textColor">#fff</item>
<item name="android:textStyle">bold</item>
</style>
<!-- SwitchDateTime style is independent, each element is optional-->
<!-- Year Precise -->
<style name="Theme.SwitchDateTime.DateLabelYear">
<item name="android:textSize">58sp</item>
<item name="android:textColor">#fff</item>
<item name="android:textStyle">bold</item>
</style>
</resources>
```
Styles elements : https://github.com/Kunzisoft/Android-SwitchDateTimePicker/blob/master/switchdatetime/src/main/res/values/styles.xml

### Sample
You can see
Expand Down
Binary file added art/screen1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyAppCustomTheme"
android:supportsRtl="true">
<activity
android:name="com.kunzisoft.switchdatetimesample.Sample"
android:theme="@style/Theme.SwitchDateTime" >
android:name="com.kunzisoft.switchdatetimesample.Sample" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
10 changes: 6 additions & 4 deletions sample/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<resources>
<!-- Base application theme. -->
<style name="SwitchDateTimeThemeCustom" parent="AlertDialog.AppCompat.Light">
<style name="MyAppCustomTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

<!-- Custom SwitchDateTime style -->
<style name="Theme.SwitchDateTime.TitleDateTimeLabelText">
<item name="android:textSize">18sp</item>

<!-- SwitchDateTime style is independent, each element is optional-->
<!-- Year Precise -->
<style name="Theme.SwitchDateTime.DateLabelYear">
<item name="android:textSize">32sp</item>
<item name="android:textColor">#fff</item>
<item name="android:textStyle">bold</item>
</style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ public void setOnButtonClickListener(OnButtonClickListener onButtonClickListener
this.mListener = onButtonClickListener;
}



@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
// Save the current datetime
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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) {

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

<LinearLayout
android:id="@+id/section_add"
android:background="?attr/dateTimeColorBackground"
android:background="?attr/dateTimeBackgroundColor"
android:layout_width="@dimen/header_width"
android:layout_height="match_parent"
android:orientation="vertical">

<RelativeLayout
android:id="@+id/label_header"
android:background="?attr/dateTimeColorLabelBackground"
android:background="?attr/dateTimeLabelBackgroundColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
Expand All @@ -27,7 +27,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_view_carousel_black_32dp"
android:tint="?attr/dateTimeColorIcon"
android:tint="?attr/dateTimeIconColor"
android:contentDescription="@string/img_datetime"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
Expand Down Expand Up @@ -116,7 +116,6 @@
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?attr/timeColorBackground"
android:gravity="center">
<com.kunzisoft.switchdatetime.time.RadialPickerLayout
android:id="@+id/time_picker"
Expand All @@ -127,13 +126,13 @@
android:focusableInTouchMode="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
switch:timeCircleColor="?attr/timeColorCircle"
switch:timeCenterColor="?attr/timeColorNumbers"
switch:timeSelectorColor="?attr/timeColorSelector"
switch:timeCircularNumbersColor="?attr/timeColorNumbers"
switch:amPmBackgroundColor="?attr/timeAmPmColorBackground"
switch:amPmSelectBackgroundColor="?attr/timeAmPmColorSelectBackground"
switch:amPmTextColor="?attr/timeAmPmColorText"/>
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"/>
</RelativeLayout>
</RelativeLayout>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
android:orientation="vertical">
<LinearLayout
android:id="@+id/section_add"
android:background="?attr/dateTimeColorBackground"
android:background="?attr/dateTimeBackgroundColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<RelativeLayout
android:id="@+id/label_header"
android:background="?attr/dateTimeColorLabelBackground"
android:background="?attr/dateTimeLabelBackgroundColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
Expand All @@ -27,7 +27,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_view_carousel_black_32dp"
android:tint="?attr/dateTimeColorIcon"
android:tint="?attr/dateTimeIconColor"
android:contentDescription="@string/img_datetime"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
Expand Down Expand Up @@ -98,13 +98,11 @@
android:id="@+id/dateSwitcher"
android:layout_width="match_parent"
android:layout_height="wrap_content"

android:inAnimation="@anim/dialog_enter_from_right"
android:outAnimation="@anim/dialog_leave_to_left"
android:layout_gravity="center">
<LinearLayout
android:id="@+id/timePicker"
android:background="?attr/timeColorBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
Expand All @@ -118,13 +116,13 @@
android:layout_gravity="center"
android:focusable="true"
android:focusableInTouchMode="true"
switch:timeCircleColor="?attr/timeColorCircle"
switch:timeCenterColor="?attr/timeColorNumbers"
switch:timeSelectorColor="?attr/timeColorSelector"
switch:timeCircularNumbersColor="?attr/timeColorNumbers"
switch:amPmBackgroundColor="?attr/timeAmPmColorBackground"
switch:amPmSelectBackgroundColor="?attr/timeAmPmColorSelectBackground"
switch:amPmTextColor="?attr/timeAmPmColorText"/>
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"/>
</LinearLayout>

<com.prolificinteractive.materialcalendarview.MaterialCalendarView
Expand Down
Loading

0 comments on commit e29d2a9

Please sign in to comment.