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

Commit 98b55c52 authored by Raff Tsai's avatar Raff Tsai
Browse files

Use TwoTargetPreference to replace customized layout

Bug: 139336138
Test: manual, robolectric
Change-Id: I0ffe90cd9ab5423b533507eeae47d5972704cf61
parent 235edcb1
Loading
Loading
Loading
Loading

res/drawable-hdpi/nav_divider.png

deleted100644 → 0
−320 B
Loading image diff...

res/drawable-mdpi/nav_divider.png

deleted100644 → 0
−311 B
Loading image diff...
−332 B
Loading image diff...
+0 −43
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 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.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical">

    <!-- Divider -->
    <ImageView
        android:id="@+id/divider"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:src="@drawable/nav_divider"
        android:contentDescription="@null"
         />

    <!-- Details button -->
    <ImageView
        android:id="@+id/deviceDetails"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:padding="8dip"
        android:background="?android:attr/selectableItemBackground"
        android:src="@drawable/ic_settings_accent"
        android:contentDescription="@string/wifi_display_details" />

</LinearLayout>
+14 −10
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settingslib.TwoTargetPreference;
import com.android.settingslib.search.SearchIndexable;

import java.util.ArrayList;
@@ -661,7 +662,7 @@ public final class WifiDisplaySettings extends SettingsPreferenceFragment implem
        }
    };

    private class RoutePreference extends Preference
    private class RoutePreference extends TwoTargetPreference
            implements Preference.OnPreferenceClickListener {
        private final MediaRouter.RouteInfo mRoute;

@@ -705,27 +706,30 @@ public final class WifiDisplaySettings extends SettingsPreferenceFragment implem
            implements View.OnClickListener {
        private final WifiDisplay mDisplay;

        @Override
        protected int getSecondTargetResId() {
            return R.layout.preference_widget_gear;
        }

        public WifiDisplayRoutePreference(Context context, MediaRouter.RouteInfo route,
                WifiDisplay display) {
            super(context, route);

            mDisplay = display;
            setWidgetLayoutResource(R.layout.wifi_display_preference);
        }

        @Override
        public void onBindViewHolder(PreferenceViewHolder view) {
            super.onBindViewHolder(view);
        public void onBindViewHolder(PreferenceViewHolder holder) {
            super.onBindViewHolder(holder);

            ImageView deviceDetails = (ImageView) view.findViewById(R.id.deviceDetails);
            if (deviceDetails != null) {
                deviceDetails.setOnClickListener(this);
            final ImageView gear = (ImageView) holder.findViewById(R.id.settings_button);
            if (gear != null) {
                gear.setOnClickListener(this);
                if (!isEnabled()) {
                    TypedValue value = new TypedValue();
                    getContext().getTheme().resolveAttribute(android.R.attr.disabledAlpha,
                            value, true);
                    deviceDetails.setImageAlpha((int) (value.getFloat() * 255));
                    deviceDetails.setEnabled(true); // always allow button to be pressed
                    gear.setImageAlpha((int) (value.getFloat() * 255));
                    gear.setEnabled(true); // always allow button to be pressed
                }
            }
        }