Merge "Make CDM UI support dark theme"

This commit is contained in:
Eugene Susla
2020-11-02 22:16:56 +00:00
committed by Android (Google) Code Review
5 changed files with 24 additions and 7 deletions

View File

@@ -30,13 +30,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@android:string/cancel"
style="@android:style/Widget.Material.Light.Button.Borderless.Colored"
style="@android:style/Widget.Material.Button.Borderless.Colored"
/>
<Button
android:id="@+id/button_pair"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@android:string/ok"
style="@android:style/Widget.Material.Light.Button.Borderless.Colored"
style="@android:style/Widget.Material.Button.Borderless.Colored"
/>
</LinearLayout>

View File

@@ -29,7 +29,7 @@
android:layout_height="match_parent"
android:layout_below="@+id/title"
android:layout_above="@+id/buttons"
style="@android:style/Widget.Material.Light.ListView"
style="@android:style/Widget.Material.ListView"
/>
<include layout="@layout/buttons" />

View File

@@ -20,6 +20,5 @@
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
style="@*android:style/TextAppearance.Widget.Toolbar.Title"
/>

View File

@@ -21,6 +21,7 @@
<item name="*android:windowFixedHeightMajor">100%</item>
<item name="*android:windowFixedHeightMinor">100%</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:forceDarkAllowed">true</item>
</style>
</resources>

View File

@@ -49,6 +49,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.net.wifi.WifiManager;
@@ -58,6 +59,8 @@ import android.os.Parcelable;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
@@ -317,6 +320,8 @@ public class DeviceDiscoveryService extends Service {
private Drawable BLUETOOTH_ICON = icon(android.R.drawable.stat_sys_data_bluetooth);
private Drawable WIFI_ICON = icon(com.android.internal.R.drawable.ic_wifi_signal_3);
private SparseArray<Integer> mColors = new SparseArray();
private Drawable icon(int drawableRes) {
Drawable icon = getResources().getDrawable(drawableRes, null);
icon.setTint(Color.DKGRAY);
@@ -343,24 +348,36 @@ public class DeviceDiscoveryService extends Service {
textView.setText(device.getDisplayName());
textView.setBackgroundColor(
device.equals(mSelectedDevice)
? Color.GRAY
? getColor(android.R.attr.colorControlHighlight)
: Color.TRANSPARENT);
textView.setCompoundDrawablesWithIntrinsicBounds(
device.device instanceof android.net.wifi.ScanResult
? WIFI_ICON
: BLUETOOTH_ICON,
null, null, null);
textView.getCompoundDrawables()[0].setTint(getColor(android.R.attr.colorForeground));
}
//TODO move to a layout file
private TextView newView() {
final TextView textView = new TextView(DeviceDiscoveryService.this);
textView.setTextColor(Color.BLACK);
textView.setTextColor(getColor(android.R.attr.colorForeground));
final int padding = DeviceChooserActivity.getPadding(getResources());
textView.setPadding(padding, padding, padding, padding);
textView.setCompoundDrawablePadding(padding);
return textView;
}
private int getColor(int colorAttr) {
if (mColors.contains(colorAttr)) {
return mColors.get(colorAttr);
}
TypedValue typedValue = new TypedValue();
TypedArray a = obtainStyledAttributes(typedValue.data, new int[] { colorAttr });
int result = a.getColor(0, 0);
a.recycle();
mColors.put(colorAttr, result);
return result;
}
}
/**