Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Add focus states for Bluetooth keyboard support on Edit Profile
Browse files Browse the repository at this point in the history
- LEARNER-6764
- Handled enabled/disabled state through xml instead of code
  • Loading branch information
miankhalid committed Dec 27, 2018
1 parent 2876127 commit 1e615fb
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -1,48 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_enabled="false" android:state_focused="true">
<shape android:shape="rectangle">
<solid android:color="@color/edx_brand_gray_back" />
<stroke android:width="@dimen/edx_line" android:color="@color/black" />
<corners android:bottomLeftRadius="@dimen/edx_box_radius" android:bottomRightRadius="0dp" android:radius="@dimen/edx_box_radius" android:topLeftRadius="@dimen/edx_box_radius" android:topRightRadius="0dp" />
</shape>
</item>
<item android:state_checked="true" android:state_enabled="false">
<shape
android:shape="rectangle">
<shape android:shape="rectangle">
<solid android:color="@color/edx_brand_gray_back" />
<stroke
android:width="@dimen/edx_hairline"
android:color="@color/edx_brand_gray_back" />
<corners
android:bottomLeftRadius="@dimen/edx_box_radius"
android:bottomRightRadius="0dp"
android:radius="@dimen/edx_box_radius"
android:topLeftRadius="@dimen/edx_box_radius"
android:topRightRadius="0dp" />
<stroke android:width="@dimen/edx_hairline" android:color="@color/edx_brand_gray_back" />
<corners android:bottomLeftRadius="@dimen/edx_box_radius" android:bottomRightRadius="0dp" android:radius="@dimen/edx_box_radius" android:topLeftRadius="@dimen/edx_box_radius" android:topRightRadius="0dp" />
</shape>
</item>
<item android:state_checked="true" android:state_focused="true">
<shape android:shape="rectangle">
<solid android:color="@color/edx_brand_primary_base" />
<stroke android:width="@dimen/edx_line" android:color="@color/black" />
<corners android:bottomLeftRadius="@dimen/edx_box_radius" android:bottomRightRadius="0dp" android:radius="@dimen/edx_box_radius" android:topLeftRadius="@dimen/edx_box_radius" android:topRightRadius="0dp" />
</shape>
</item>
<item android:state_checked="true">
<shape
android:shape="rectangle">
<shape android:shape="rectangle">
<solid android:color="@color/edx_brand_primary_base" />
<stroke
android:width="@dimen/edx_hairline"
android:color="@color/edx_brand_primary_base" />
<corners
android:bottomLeftRadius="@dimen/edx_box_radius"
android:bottomRightRadius="0dp"
android:radius="@dimen/edx_box_radius"
android:topLeftRadius="@dimen/edx_box_radius"
android:topRightRadius="0dp" />
<stroke android:width="@dimen/edx_hairline" android:color="@color/edx_brand_primary_base" />
<corners android:bottomLeftRadius="@dimen/edx_box_radius" android:bottomRightRadius="0dp" android:radius="@dimen/edx_box_radius" android:topLeftRadius="@dimen/edx_box_radius" android:topRightRadius="0dp" />
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="rectangle">
<solid android:color="@color/white" />
<stroke android:width="@dimen/edx_line" android:color="@color/black" />
<corners android:bottomLeftRadius="@dimen/edx_box_radius" android:bottomRightRadius="0dp" android:radius="@dimen/edx_box_radius" android:topLeftRadius="@dimen/edx_box_radius" android:topRightRadius="0dp" />
</shape>
</item>
<item>
<shape
android:shape="rectangle">
<shape android:shape="rectangle">
<solid android:color="@color/white" />
<stroke
android:width="@dimen/edx_hairline"
android:color="@color/edx_brand_gray_back" />
<corners
android:bottomLeftRadius="@dimen/edx_box_radius"
android:bottomRightRadius="0dp"
android:radius="@dimen/edx_box_radius"
android:topLeftRadius="@dimen/edx_box_radius"
android:topRightRadius="0dp" />
<stroke android:width="@dimen/edx_hairline" android:color="@color/edx_brand_gray_back" />
<corners android:bottomLeftRadius="@dimen/edx_box_radius" android:bottomRightRadius="0dp" android:radius="@dimen/edx_box_radius" android:topLeftRadius="@dimen/edx_box_radius" android:topRightRadius="0dp" />
</shape>
</item>
</selector>
Original file line number Diff line number Diff line change
@@ -1,48 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_enabled="false" android:state_focused="true">
<shape android:shape="rectangle">
<solid android:color="@color/edx_brand_gray_back" />
<stroke android:width="@dimen/edx_line" android:color="@color/black" />
<corners android:bottomLeftRadius="0dp" android:bottomRightRadius="@dimen/edx_box_radius" android:radius="@dimen/edx_box_radius" android:topLeftRadius="0dp" android:topRightRadius="@dimen/edx_box_radius" />
</shape>
</item>
<item android:state_checked="true" android:state_enabled="false">
<shape
android:shape="rectangle">
<shape android:shape="rectangle">
<solid android:color="@color/edx_brand_gray_back" />
<stroke
android:width="@dimen/edx_hairline"
android:color="@color/edx_brand_gray_back" />
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="@dimen/edx_box_radius"
android:radius="@dimen/edx_box_radius"
android:topLeftRadius="0dp"
android:topRightRadius="@dimen/edx_box_radius" />
<stroke android:width="@dimen/edx_hairline" android:color="@color/edx_brand_gray_back" />
<corners android:bottomLeftRadius="0dp" android:bottomRightRadius="@dimen/edx_box_radius" android:radius="@dimen/edx_box_radius" android:topLeftRadius="0dp" android:topRightRadius="@dimen/edx_box_radius" />
</shape>
</item>
<item android:state_checked="true" android:state_focused="true">
<shape android:shape="rectangle">
<solid android:color="@color/edx_brand_primary_base" />
<stroke android:width="@dimen/edx_line" android:color="@color/black" />
<corners android:bottomLeftRadius="0dp" android:bottomRightRadius="@dimen/edx_box_radius" android:radius="@dimen/edx_box_radius" android:topLeftRadius="0dp" android:topRightRadius="@dimen/edx_box_radius" />
</shape>
</item>
<item android:state_checked="true">
<shape
android:shape="rectangle">
<shape android:shape="rectangle">
<solid android:color="@color/edx_brand_primary_base" />
<stroke
android:width="@dimen/edx_hairline"
android:color="@color/edx_brand_primary_base" />
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="@dimen/edx_box_radius"
android:radius="@dimen/edx_box_radius"
android:topLeftRadius="0dp"
android:topRightRadius="@dimen/edx_box_radius" />
<stroke android:width="@dimen/edx_hairline" android:color="@color/edx_brand_primary_base" />
<corners android:bottomLeftRadius="0dp" android:bottomRightRadius="@dimen/edx_box_radius" android:radius="@dimen/edx_box_radius" android:topLeftRadius="0dp" android:topRightRadius="@dimen/edx_box_radius" />
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="rectangle">
<solid android:color="@color/white" />
<stroke android:width="@dimen/edx_line" android:color="@color/black" />
<corners android:bottomLeftRadius="0dp" android:bottomRightRadius="@dimen/edx_box_radius" android:radius="@dimen/edx_box_radius" android:topLeftRadius="0dp" android:topRightRadius="@dimen/edx_box_radius" />
</shape>
</item>
<item>
<shape
android:shape="rectangle">
<shape android:shape="rectangle">
<solid android:color="@color/white" />
<stroke
android:width="@dimen/edx_hairline"
android:color="@color/edx_brand_gray_back" />
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="@dimen/edx_box_radius"
android:radius="@dimen/edx_box_radius"
android:topLeftRadius="0dp"
android:topRightRadius="@dimen/edx_box_radius" />
<stroke android:width="@dimen/edx_hairline" android:color="@color/edx_brand_gray_back" />
<corners android:bottomLeftRadius="0dp" android:bottomRightRadius="@dimen/edx_box_radius" android:radius="@dimen/edx_box_radius" android:topLeftRadius="0dp" android:topRightRadius="@dimen/edx_box_radius" />
</shape>
</item>
</selector>
8 changes: 8 additions & 0 deletions OpenEdXMobile/res/drawable/focus_disabled_drawable.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/edx_brand_gray_x_back" />
<stroke
android:width="@dimen/edx_line"
android:color="@color/black" />
</shape>
8 changes: 8 additions & 0 deletions OpenEdXMobile/res/drawable/focus_drawable.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/transparent_black_13" />
<stroke
android:width="@dimen/edx_line"
android:color="@color/black" />
</shape>
3 changes: 3 additions & 0 deletions OpenEdXMobile/res/drawable/view_selector.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/edx_brand_gray_back" android:state_pressed="true"/>
<item android:drawable="@drawable/focus_disabled_drawable" android:state_enabled="false" android:state_focused="true"/>
<item android:drawable="@color/edx_brand_gray_x_back" android:state_enabled="false"/>
<item android:drawable="@drawable/focus_drawable" android:state_focused="true"/>
<item android:drawable="@android:color/transparent"/>
</selector>
3 changes: 2 additions & 1 deletion OpenEdXMobile/res/layout/edit_user_profile_field.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
android:background="?android:attr/selectableItemBackground"
android:textSize="@dimen/edx_base"
android:textColor="@color/edx_brand_gray_base"
tools:text="Birth year: 2008" />
tools:text="Birth year: 2008"
android:focusable="true" />
1 change: 1 addition & 0 deletions OpenEdXMobile/res/layout/fragment_edit_user_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
android:paddingLeft="@dimen/edx_margin"
android:paddingRight="@dimen/edx_margin"
android:text="@string/edit_user_profile_change_photo"
android:focusable="true"
android:textColor="@color/disableable_button_text"
android:textSize="@dimen/edx_x_small" />
</LinearLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ private static View createSwitch(@NonNull LayoutInflater inflater, @NonNull View
}
if (readOnly) {
group.setEnabled(false);
view.setBackgroundColor(view.getResources().getColor(R.color.edx_brand_gray_x_back));
} else {
group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
Expand Down Expand Up @@ -501,7 +500,6 @@ textView, null, null, new IconDrawable(context, FontAwesomeIcons.fa_angle_right)
.sizeDp(context, 24), null);
if (readOnly) {
textView.setEnabled(false);
textView.setBackgroundColor(textView.getResources().getColor(R.color.edx_brand_gray_x_back));
} else {
textView.setOnClickListener(onClickListener);
}
Expand Down

0 comments on commit 1e615fb

Please sign in to comment.