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

Commit 2badb3e1 authored by tmfang's avatar tmfang
Browse files

Create a bar char preference widget

- Per Q design, we will show a bar chart in Settings > Privacy page.
  Permission team also needs this bar chart in their page.
- Create a new library named SettingsLibBarChartPreference

Test: visual, robotest
Change-Id: Iff5a1233357a6aa6a667c0059f542a1b444b59a2
Fixes: 117623686
parent 25e0861b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ android_library {
        "SettingsLibLayoutPreference",
        "SettingsLibActionButtonsPreference",
        "SettingsLibEntityHeaderWidgets",
        "SettingsLibBarChartPreference"
    ],

    // ANDROIDMK TRANSLATION ERROR: unsupported assignment to LOCAL_SHARED_JAVA_LIBRARIES
+13 −0
Original line number Diff line number Diff line
android_library {
    name: "SettingsLibBarChartPreference",

    srcs: ["src/**/*.java"],
    resource_dirs: ["res"],

    static_libs: [
          "androidx.preference_preference",
    ],

    sdk_version: "system_current",
    min_sdk_version: "21",
}
+23 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2018 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.
  -->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.android.settingslib.widget">

    <uses-sdk android:minSdkVersion="21" />

</manifest>
+65 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2018 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"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="16dp"
    android:layout_marginEnd="16dp"
    android:gravity="center"
    android:orientation="vertical">

    <TextView
        android:id="@+id/bar_chart_title"
        android:layout_width="wrap_content"
        android:layout_height="48dp"
        android:gravity="center"
        android:textAppearance="@style/BarChart.Text.HeaderTitle"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center|bottom">

        <com.android.settingslib.widget.BarView
            android:id="@+id/bar_view1"
            style="@style/BarViewStyle"
            settings:barColor="#FA7B17"/>
        <com.android.settingslib.widget.BarView
            android:id="@+id/bar_view2"
            style="@style/BarViewStyle"
            settings:barColor="#F439A0"/>
        <com.android.settingslib.widget.BarView
            android:id="@+id/bar_view3"
            style="@style/BarViewStyle"
            settings:barColor="#A142F4"/>
        <com.android.settingslib.widget.BarView
            android:id="@+id/bar_view4"
            style="@style/BarViewStyle"
            settings:barColor="#24C1E0"/>
    </LinearLayout>

    <Button
        android:id="@+id/bar_chart_details"
        style="@android:style/Widget.DeviceDefault.Button.Borderless.Colored"
        android:layout_width="wrap_content"
        android:layout_height="48dp"
        android:gravity="center"/>

</LinearLayout>
+58 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2018 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="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical">

    <View
        android:id="@+id/bar_view"
        android:layout_width="8dp"
        android:layout_height="wrap_content"
        android:background="?android:attr/colorAccent"/>

    <ImageView
        android:id="@+id/icon_view"
        android:layout_width="@dimen/settings_bar_view_icon_size"
        android:layout_height="@dimen/settings_bar_view_icon_size"
        android:scaleType="fitCenter"
        android:layout_marginTop="12dp"
        android:layout_marginBottom="12dp"/>

    <TextView
        android:id="@+id/bar_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="2dp"
        android:singleLine="true"
        android:ellipsize="marquee"
        android:textAppearance="@style/BarChart.Text.Title"/>

    <TextView
        android:id="@+id/bar_summary"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="12dp"
        android:singleLine="true"
        android:ellipsize="marquee"
        android:textAppearance="@style/BarChart.Text.Summary"/>

</LinearLayout>
 No newline at end of file
Loading