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

Commit bb8f3925 authored by Weng Su's avatar Weng Su
Browse files

Remove the background color of the data usage chart

- Includes Wi-Fi and Mobile data usage

Bug: 404458437
Bug: 407453358
Flag: EXEMPT refactor
Test: Manual testing
  atest ChartDataUsagePreferenceTest
  atest DataUsageListTest
Change-Id: I31ceb8b126893b462aecd176da65d4a1d8185de4
parent 3c8e4222
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@
        android:id="@+id/data_usage"
        android:layout_width="match_parent"
        android:layout_height="@dimen/data_usage_chart_height"
        android:layout_marginStart="@dimen/content_margin_left"
        android:layout_marginEnd="@dimen/content_margin_left"
        settings:sideLabels="@array/battery_labels"
        android:colorAccent="?android:attr/colorAccent"
        android:gravity="end"
+34 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2025 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:orientation="vertical">

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/content_margin_left"
        android:layout_marginEnd="@dimen/content_margin_left"
        android:gravity="center_vertical"
        android:minHeight="48dp"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="?android:attr/textColorSecondary"/>
</LinearLayout>
 No newline at end of file
+3 −2
Original line number Diff line number Diff line
@@ -26,8 +26,9 @@
            settings:controller="com.android.settings.datausage.ChartDataUsagePreferenceController"
            />

        <Preference
        <com.android.settingslib.widget.LayoutPreference
            android:key="warning"
            android:layout="@layout/data_usage_warning_preference"
            android:selectable="false"/>

    </PreferenceCategory>
+2 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import com.android.settings.datausage.lib.NetworkCycleChartData;
import com.android.settings.datausage.lib.NetworkUsageData;
import com.android.settings.widget.UsageView;
import com.android.settingslib.spaprivileged.framework.common.BytesFormatter;
import com.android.settingslib.widget.GroupSectionDividerMixin;

import java.util.ArrayList;
import java.util.Comparator;
@@ -45,7 +46,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class ChartDataUsagePreference extends Preference {
public class ChartDataUsagePreference extends Preference implements GroupSectionDividerMixin {

    // The resolution we show on the graph so that we can squash things down to ints.
    // Set to half a meg for now.
+7 −3
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.telephony.SubscriptionManager
import android.util.EventLog
import android.util.Log
import android.view.View
import android.widget.TextView
import androidx.annotation.OpenForTesting
import androidx.annotation.VisibleForTesting
import androidx.fragment.app.viewModels
@@ -37,6 +38,7 @@ import com.android.settings.datausage.lib.NetworkUsageData
import com.android.settings.network.telephony.SubscriptionRepository
import com.android.settingslib.spa.framework.util.collectLatestWithLifecycle
import com.android.settingslib.spaprivileged.framework.common.userManager
import com.android.settingslib.widget.LayoutPreference
import kotlin.jvm.optionals.getOrNull

/**
@@ -97,11 +99,13 @@ open class DataUsageList : DashboardFragment() {

    private fun updateWarning() {
        val template = template ?: return
        val warningPreference = findPreference<Preference>(KEY_WARNING)!!
        val preference = findPreference<LayoutPreference>(KEY_WARNING) ?: return
        val textView = preference.findViewById<TextView>(R.id.text) ?: return
        val context = requireContext()
        if (template.matchRule != NetworkTemplate.MATCH_WIFI) {
            warningPreference.setSummary(R.string.operator_warning)
            textView.text = context.getString(R.string.operator_warning)
        } else if (Utils.isMobileDataCapable(context)) {
            warningPreference.setSummary(R.string.non_carrier_data_usage_warning)
            textView.text = context.getString(R.string.non_carrier_data_usage_warning)
        }
    }

Loading