Skip to content

Commit 0def9af

Browse files
author
michal_szwarc
committed
Change Checkobx to SwitchComapt. Add custom attrs. Update default themes. Update sample app.
1 parent 3320373 commit 0def9af

27 files changed

+253
-59
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ MaterialSettings - small library to create settings activity
33

44
Work in progress...
55

6-
![Nexus 9 preview](/screens/nex_5_device.png)
6+
![Default](/screens/theme_default.png)
7+
![Rec](/screens/theme_red.png)
8+
![Dark](/screens/theme_dark.png)

library/src/main/java/com/kenumir/materialsettings/views/CheckableLinearLayout.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.Context;
55
import android.content.res.TypedArray;
66
import android.util.AttributeSet;
7+
import android.view.MotionEvent;
78
import android.view.View;
89
import android.view.ViewGroup;
910
import android.widget.Checkable;
@@ -54,7 +55,13 @@ public void onClick(View v) {
5455
});
5556
}
5657
}
57-
58+
59+
// get all touch events
60+
@Override
61+
public boolean onInterceptTouchEvent(MotionEvent ev) {
62+
return true;
63+
}
64+
5865
@Override
5966
public void setEnabled(boolean enabled) {
6067
super.setEnabled(enabled);

library/src/main/res/drawable-v21/default_checkable_bg.xml renamed to library/src/main/res/drawable-v21/default_checkable_bg_dark.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:color="@color/hr_gray3">
3+
android:color="@color/ms_gray3">
44
<item>
55
<selector>
66
<item android:state_checked="true">
77
<shape>
8-
<solid android:color="@color/hr_gray2" />
8+
<solid android:color="@color/ms_gray2" />
99
</shape>
1010
</item>
1111

1212
<item>
1313
<shape>
14-
<solid android:color="@android:color/white" />
14+
<solid android:color="@color/ms_dark_window_bg" />
1515
</shape>
1616
</item>
1717
</selector>

library/src/main/res/drawable-v21/default_click_bg.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:color="@color/hr_gray3">
3+
android:color="@color/ms_gray3">
44
<item>
55
<selector>
66
<item>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:color="@color/ms_gray3">
4+
<item>
5+
<selector>
6+
<item>
7+
<shape>
8+
<solid android:color="@color/ms_dark_window_bg" />
9+
</shape>
10+
</item>
11+
</selector>
12+
</item>
13+
</ripple>

library/src/main/res/drawable/default_click_bg.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<item android:state_pressed="true">
55
<shape android:shape="rectangle">
6-
<solid android:color="@color/hr_gray3" />
6+
<solid android:color="@color/ms_gray3" />
77
</shape>
88
</item>
99

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<item android:state_pressed="true">
5+
<shape android:shape="rectangle">
6+
<solid android:color="@color/ms_gray3" />
7+
</shape>
8+
</item>
9+
10+
<item>
11+
<shape android:shape="rectangle">
12+
<solid android:color="#00000000" />
13+
</shape>
14+
</item>
15+
16+
</selector>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:shape="rectangle">
3+
4+
<solid android:color="@color/default_divider_dark" />
5+
<size android:height="1dp" />
6+
7+
</shape>
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<com.kenumir.materialsettings.views.CheckableLinearLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
4-
style="@style/Settings_Item">
4+
style="?attr/msItem">
55

6-
<LinearLayout
6+
<RelativeLayout
77
android:layout_width="0dp"
88
android:layout_height="match_parent"
99
android:orientation="vertical"
@@ -12,21 +12,23 @@
1212

1313
<TextView
1414
android:id="@+id/material_dialog_item_title"
15-
style="@style/Settings_Item_Text"/>
15+
style="?attr/msTextStyle"/>
1616

1717
<TextView
1818
android:id="@+id/material_dialog_item_subtitle"
19-
style="@style/Settings_Item_SubText"/>
19+
style="?attr/msSubTextStyle"
20+
android:layout_below="@+id/material_dialog_item_title"/>
2021

21-
</LinearLayout>
22+
</RelativeLayout>
2223

2324
<LinearLayout
2425
android:layout_width="wrap_content"
2526
android:layout_height="match_parent"
2627
android:gravity="center">
2728

28-
<CheckBox style="@style/Settings_Item_CheckBox" />
29+
<android.support.v7.widget.SwitchCompat
30+
style="@style/Settings_Item_CheckBox"/>
2931

3032
</LinearLayout>
3133

32-
</com.kenumir.materialsettings.views.CheckableLinearLayout>
34+
</com.kenumir.materialsettings.views.CheckableLinearLayout>
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<View
3-
xmlns:android="http://schemas.android.com/apk/res/android"
4-
style="@style/Settings_Item_Divider"/>
2+
<View style="?attr/msDivider"/>

0 commit comments

Comments
 (0)