Merge "Use TwoTargetPreference to replace customized layout"
This commit is contained in:
committed by
Android (Google) Code Review
commit
1171eb2eca
Binary file not shown.
Before Width: | Height: | Size: 320 B |
Binary file not shown.
Before Width: | Height: | Size: 311 B |
Binary file not shown.
Before Width: | Height: | Size: 332 B |
@@ -1,43 +0,0 @@
|
|||||||
<?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>
|
|
@@ -67,6 +67,7 @@ import com.android.settings.SettingsPreferenceFragment;
|
|||||||
import com.android.settings.dashboard.SummaryLoader;
|
import com.android.settings.dashboard.SummaryLoader;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.search.Indexable;
|
import com.android.settings.search.Indexable;
|
||||||
|
import com.android.settingslib.TwoTargetPreference;
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
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 {
|
implements Preference.OnPreferenceClickListener {
|
||||||
private final MediaRouter.RouteInfo mRoute;
|
private final MediaRouter.RouteInfo mRoute;
|
||||||
|
|
||||||
@@ -705,27 +706,30 @@ public final class WifiDisplaySettings extends SettingsPreferenceFragment implem
|
|||||||
implements View.OnClickListener {
|
implements View.OnClickListener {
|
||||||
private final WifiDisplay mDisplay;
|
private final WifiDisplay mDisplay;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getSecondTargetResId() {
|
||||||
|
return R.layout.preference_widget_gear;
|
||||||
|
}
|
||||||
|
|
||||||
public WifiDisplayRoutePreference(Context context, MediaRouter.RouteInfo route,
|
public WifiDisplayRoutePreference(Context context, MediaRouter.RouteInfo route,
|
||||||
WifiDisplay display) {
|
WifiDisplay display) {
|
||||||
super(context, route);
|
super(context, route);
|
||||||
|
|
||||||
mDisplay = display;
|
mDisplay = display;
|
||||||
setWidgetLayoutResource(R.layout.wifi_display_preference);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||||
super.onBindViewHolder(view);
|
super.onBindViewHolder(holder);
|
||||||
|
|
||||||
ImageView deviceDetails = (ImageView) view.findViewById(R.id.deviceDetails);
|
final ImageView gear = (ImageView) holder.findViewById(R.id.settings_button);
|
||||||
if (deviceDetails != null) {
|
if (gear != null) {
|
||||||
deviceDetails.setOnClickListener(this);
|
gear.setOnClickListener(this);
|
||||||
if (!isEnabled()) {
|
if (!isEnabled()) {
|
||||||
TypedValue value = new TypedValue();
|
TypedValue value = new TypedValue();
|
||||||
getContext().getTheme().resolveAttribute(android.R.attr.disabledAlpha,
|
getContext().getTheme().resolveAttribute(android.R.attr.disabledAlpha,
|
||||||
value, true);
|
value, true);
|
||||||
deviceDetails.setImageAlpha((int) (value.getFloat() * 255));
|
gear.setImageAlpha((int) (value.getFloat() * 255));
|
||||||
deviceDetails.setEnabled(true); // always allow button to be pressed
|
gear.setEnabled(true); // always allow button to be pressed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user