mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 855016 - Make the more-text links on about:home sections focusable and gamepad-actionable. r=sriram
This commit is contained in:
parent
af2eae9ced
commit
eb296268de
@ -4,6 +4,8 @@
|
||||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import org.mozilla.gecko.util.GamepadUtils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.text.TextUtils;
|
||||
@ -73,6 +75,7 @@ public class AboutHomeSection extends GeckoLinearLayout {
|
||||
|
||||
public void setOnMoreTextClickListener(View.OnClickListener listener) {
|
||||
mMoreText.setOnClickListener(listener);
|
||||
mMoreText.setOnKeyListener(GamepadUtils.getClickDispatcher());
|
||||
}
|
||||
|
||||
public void addItem(View item) {
|
||||
|
@ -5,14 +5,20 @@
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.BackgroundColorSpan;
|
||||
import android.text.style.UnderlineSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class LinkTextView extends TextView {
|
||||
private final BackgroundColorSpan mFocusBackgroundSpan;
|
||||
private boolean mFocusApplied;
|
||||
|
||||
public LinkTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mFocusBackgroundSpan = new BackgroundColorSpan(context.getResources().getColor(R.color.highlight_focused));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -22,4 +28,24 @@ public class LinkTextView extends TextView {
|
||||
|
||||
super.setText(content, BufferType.SPANNABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
|
||||
super.onFocusChanged(focused, direction, previouslyFocusedRect);
|
||||
|
||||
if (focused == mFocusApplied) {
|
||||
return;
|
||||
}
|
||||
mFocusApplied = focused;
|
||||
|
||||
CharSequence text = getText();
|
||||
if (text instanceof SpannableString) {
|
||||
SpannableString spannable = (SpannableString)text;
|
||||
if (focused) {
|
||||
spannable.setSpan(mFocusBackgroundSpan, 0, text.length(), 0);
|
||||
} else {
|
||||
spannable.removeSpan(mFocusBackgroundSpan);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,6 @@
|
||||
android:textColor="@color/abouthome_section_more_text"
|
||||
android:textSize="12sp"
|
||||
android:gravity="center"
|
||||
android:duplicateParentState="true"/>
|
||||
android:focusable="true"/>
|
||||
|
||||
</merge>
|
||||
|
Loading…
Reference in New Issue
Block a user