Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ff963b0 authored by Yogisha Dixit's avatar Yogisha Dixit
Browse files

Use a selector instead of loading resource for drop target.

Test: manual
Bug: 187355401,187035471
Change-Id: I65fef2c810c791c3282bd4a087359f6cff774cc4
parent 04eff269
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
<?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>
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -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" />
+3 −7
Original line number Diff line number Diff line
@@ -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);
    }

    /**