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

Commit c6bc5fd4 authored by Eugene Susla's avatar Eugene Susla Committed by Android (Google) Code Review
Browse files

Merge "Make CDM UI support dark theme"

parents 68cf2528 32d69204
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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>
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -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" />
+0 −1
Original line number Diff line number Diff line
@@ -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"
/>
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -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>
+20 −3
Original line number Diff line number Diff line
@@ -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;
        }
    }

    /**