mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 16:26:47 +00:00
Merge "Use a selector instead of loading resource for drop target." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b1e51e2a3f
21
res/drawable/drop_target_background.xml
Normal file
21
res/drawable/drop_target_background.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2021 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="true"
|
||||
android:drawable="@drawable/drop_target_frame_hover" />
|
||||
<item android:state_selected="false"
|
||||
android:drawable="@drawable/drop_target_frame" />
|
||||
</selector>
|
||||
@@ -271,7 +271,7 @@
|
||||
<item name="android:textSize">@dimen/drop_target_text_size</item>
|
||||
<item name="android:singleLine">true</item>
|
||||
<item name="android:ellipsize">end</item>
|
||||
<item name="android:background">@drawable/drop_target_frame</item>
|
||||
<item name="android:background">@drawable/drop_target_background</item>
|
||||
</style>
|
||||
|
||||
<style name="DropTargetButton" parent="DropTargetButtonBase" />
|
||||
|
||||
@@ -142,11 +142,6 @@ public abstract class ButtonDropTarget extends TextView
|
||||
}
|
||||
}
|
||||
|
||||
private void setBackgroundDrawable(int resId) {
|
||||
Drawable bd = AppCompatResources.getDrawable(getContext(), resId);
|
||||
setBackground(bd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onDragEnter(DragObject d) {
|
||||
if (!mAccessibleDrag && !mTextVisible) {
|
||||
@@ -172,7 +167,7 @@ public abstract class ButtonDropTarget extends TextView
|
||||
}
|
||||
|
||||
d.dragView.setAlpha(DRAG_VIEW_HOVER_OVER_OPACITY);
|
||||
setBackgroundDrawable(R.drawable.drop_target_frame_hover);
|
||||
setSelected(true);
|
||||
if (d.stateAnnouncer != null) {
|
||||
d.stateAnnouncer.cancel();
|
||||
}
|
||||
@@ -190,7 +185,7 @@ public abstract class ButtonDropTarget extends TextView
|
||||
|
||||
if (!d.dragComplete) {
|
||||
d.dragView.setAlpha(1f);
|
||||
setBackgroundDrawable(R.drawable.drop_target_frame);
|
||||
setSelected(false);
|
||||
} else {
|
||||
d.dragView.setAlpha(DRAG_VIEW_HOVER_OVER_OPACITY);
|
||||
}
|
||||
@@ -230,6 +225,7 @@ public abstract class ButtonDropTarget extends TextView
|
||||
public void onDragEnd() {
|
||||
mActive = false;
|
||||
setOnClickListener(null);
|
||||
setSelected(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user