Loading res/layout/battery_chart_graph.xml +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ <com.android.settings.fuelgauge.BatteryChartView android:id="@+id/battery_chart" android:layout_width="match_parent" android:layout_height="151dp" android:layout_height="141dp" android:layout_marginBottom="16dp" android:textAppearance="?android:attr/textAppearanceSmall" settings:textColor="?android:attr/textColorSecondary" /> Loading res/layout/battery_usage_graph.xmldeleted 100644 → 0 +0 −53 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2016 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:paddingTop="16dp" android:paddingStart="@dimen/preference_no_icon_padding_start" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:orientation="vertical"> <TextView android:id="@+id/charge" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:fontFamily="@*android:string/config_headlineFontFamily" android:textAppearance="?android:attr/textAppearanceLarge" android:textSize="36sp" android:textColor="?android:attr/colorAccent" /> <com.android.settings.widget.UsageView android:id="@+id/battery_usage" android:layout_width="match_parent" android:layout_height="141dp" android:layout_marginBottom="16dp" settings:sideLabels="@array/battery_labels" android:colorAccent="?android:attr/colorAccent" android:gravity="end" settings:textColor="?android:attr/textColorSecondary" /> <TextView android:id="@+id/bottom_summary" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:textAppearance="?android:attr/textAppearanceSmall" /> </LinearLayout> src/com/android/settings/fuelgauge/BatteryChartView.java +1 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,7 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick public void setLevels(int[] levels) { // We should provide trapezoid count + 1 data to draw all trapezoids. mLevels = levels.length == mTrapezoidCount + 1 ? levels : null; setClickable(mLevels != null); invalidate(); } Loading src/com/android/settings/fuelgauge/BatteryHistoryPreference.java +10 −38 Original line number Diff line number Diff line Loading @@ -19,8 +19,8 @@ package com.android.settings.fuelgauge; import android.content.Context; import android.os.BatteryUsageStats; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; Loading @@ -28,26 +28,26 @@ import androidx.preference.Preference; import androidx.preference.PreferenceViewHolder; import com.android.settings.R; import com.android.settings.widget.UsageView; import com.android.settings.overlay.FeatureFactory; /** * Custom preference for displaying power consumption as a bar and an icon on the left for the * subsystem/app type. * Custom preference for displaying the battery level as chart graph. */ public class BatteryHistoryPreference extends Preference { private static final String TAG = "BatteryHistoryPreference"; private CharSequence mSummary; private TextView mSummaryView; @VisibleForTesting boolean hideSummary; @VisibleForTesting BatteryInfo mBatteryInfo; public BatteryHistoryPreference(Context context, AttributeSet attrs) { super(context, attrs); setLayoutResource(R.layout.battery_usage_graph); final boolean isChartGraphEnabled = FeatureFactory.getFactory(context).getPowerUsageFeatureProvider(context) .isChartGraphEnabled(context); Log.i(TAG, "isChartGraphEnabled: " + isChartGraphEnabled); if (isChartGraphEnabled) { setLayoutResource(R.layout.battery_chart_graph); } setSelectable(false); } Loading @@ -58,22 +58,6 @@ public class BatteryHistoryPreference extends Preference { }, batteryUsageStats, false); } public void setBottomSummary(CharSequence text) { mSummary = text; if (mSummaryView != null) { mSummaryView.setVisibility(View.VISIBLE); mSummaryView.setText(mSummary); } hideSummary = false; } public void hideBottomSummary() { if (mSummaryView != null) { mSummaryView.setVisibility(View.GONE); } hideSummary = true; } @Override public void onBindViewHolder(PreferenceViewHolder view) { super.onBindViewHolder(view); Loading @@ -81,18 +65,6 @@ public class BatteryHistoryPreference extends Preference { if (mBatteryInfo == null) { return; } ((TextView) view.findViewById(R.id.charge)).setText(mBatteryInfo.batteryPercentString); mSummaryView = (TextView) view.findViewById(R.id.bottom_summary); if (mSummary != null) { mSummaryView.setText(mSummary); } if (hideSummary) { mSummaryView.setVisibility(View.GONE); } UsageView usageView = (UsageView) view.findViewById(R.id.battery_usage); usageView.findViewById(R.id.label_group).setAlpha(.7f); mBatteryInfo.bindHistory(usageView); BatteryUtils.logRuntime(TAG, "onBindViewHolder", startTime); } } src/com/android/settings/fuelgauge/PowerUsageAdvanced.java +0 −18 Original line number Diff line number Diff line Loading @@ -63,9 +63,6 @@ public class PowerUsageAdvanced extends PowerUsageBase { mHistPref = (BatteryHistoryPreference) findPreference(KEY_BATTERY_GRAPH); mPowerUsageFeatureProvider = FeatureFactory.getFactory(context) .getPowerUsageFeatureProvider(context); // init the summary so other preferences won't have unnecessary move updateHistPrefSummary(context); restoreSavedInstance(icicle); } Loading Loading @@ -151,24 +148,9 @@ public class PowerUsageAdvanced extends PowerUsageBase { return; } updatePreference(mHistPref); updateHistPrefSummary(context); mBatteryAppListPreferenceController.refreshAppListGroup(mBatteryUsageStats, mShowAllApps); } private void updateHistPrefSummary(Context context) { Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); final boolean plugged = batteryIntent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) != 0; if (mPowerUsageFeatureProvider.isEnhancedBatteryPredictionEnabled(context) && !plugged) { mHistPref.setBottomSummary( mPowerUsageFeatureProvider.getAdvancedUsageScreenInfoString()); } else { mHistPref.hideBottomSummary(); } } public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider() { @Override Loading Loading
res/layout/battery_chart_graph.xml +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ <com.android.settings.fuelgauge.BatteryChartView android:id="@+id/battery_chart" android:layout_width="match_parent" android:layout_height="151dp" android:layout_height="141dp" android:layout_marginBottom="16dp" android:textAppearance="?android:attr/textAppearanceSmall" settings:textColor="?android:attr/textColorSecondary" /> Loading
res/layout/battery_usage_graph.xmldeleted 100644 → 0 +0 −53 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2016 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:paddingTop="16dp" android:paddingStart="@dimen/preference_no_icon_padding_start" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:orientation="vertical"> <TextView android:id="@+id/charge" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:fontFamily="@*android:string/config_headlineFontFamily" android:textAppearance="?android:attr/textAppearanceLarge" android:textSize="36sp" android:textColor="?android:attr/colorAccent" /> <com.android.settings.widget.UsageView android:id="@+id/battery_usage" android:layout_width="match_parent" android:layout_height="141dp" android:layout_marginBottom="16dp" settings:sideLabels="@array/battery_labels" android:colorAccent="?android:attr/colorAccent" android:gravity="end" settings:textColor="?android:attr/textColorSecondary" /> <TextView android:id="@+id/bottom_summary" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:textAppearance="?android:attr/textAppearanceSmall" /> </LinearLayout>
src/com/android/settings/fuelgauge/BatteryChartView.java +1 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,7 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick public void setLevels(int[] levels) { // We should provide trapezoid count + 1 data to draw all trapezoids. mLevels = levels.length == mTrapezoidCount + 1 ? levels : null; setClickable(mLevels != null); invalidate(); } Loading
src/com/android/settings/fuelgauge/BatteryHistoryPreference.java +10 −38 Original line number Diff line number Diff line Loading @@ -19,8 +19,8 @@ package com.android.settings.fuelgauge; import android.content.Context; import android.os.BatteryUsageStats; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; Loading @@ -28,26 +28,26 @@ import androidx.preference.Preference; import androidx.preference.PreferenceViewHolder; import com.android.settings.R; import com.android.settings.widget.UsageView; import com.android.settings.overlay.FeatureFactory; /** * Custom preference for displaying power consumption as a bar and an icon on the left for the * subsystem/app type. * Custom preference for displaying the battery level as chart graph. */ public class BatteryHistoryPreference extends Preference { private static final String TAG = "BatteryHistoryPreference"; private CharSequence mSummary; private TextView mSummaryView; @VisibleForTesting boolean hideSummary; @VisibleForTesting BatteryInfo mBatteryInfo; public BatteryHistoryPreference(Context context, AttributeSet attrs) { super(context, attrs); setLayoutResource(R.layout.battery_usage_graph); final boolean isChartGraphEnabled = FeatureFactory.getFactory(context).getPowerUsageFeatureProvider(context) .isChartGraphEnabled(context); Log.i(TAG, "isChartGraphEnabled: " + isChartGraphEnabled); if (isChartGraphEnabled) { setLayoutResource(R.layout.battery_chart_graph); } setSelectable(false); } Loading @@ -58,22 +58,6 @@ public class BatteryHistoryPreference extends Preference { }, batteryUsageStats, false); } public void setBottomSummary(CharSequence text) { mSummary = text; if (mSummaryView != null) { mSummaryView.setVisibility(View.VISIBLE); mSummaryView.setText(mSummary); } hideSummary = false; } public void hideBottomSummary() { if (mSummaryView != null) { mSummaryView.setVisibility(View.GONE); } hideSummary = true; } @Override public void onBindViewHolder(PreferenceViewHolder view) { super.onBindViewHolder(view); Loading @@ -81,18 +65,6 @@ public class BatteryHistoryPreference extends Preference { if (mBatteryInfo == null) { return; } ((TextView) view.findViewById(R.id.charge)).setText(mBatteryInfo.batteryPercentString); mSummaryView = (TextView) view.findViewById(R.id.bottom_summary); if (mSummary != null) { mSummaryView.setText(mSummary); } if (hideSummary) { mSummaryView.setVisibility(View.GONE); } UsageView usageView = (UsageView) view.findViewById(R.id.battery_usage); usageView.findViewById(R.id.label_group).setAlpha(.7f); mBatteryInfo.bindHistory(usageView); BatteryUtils.logRuntime(TAG, "onBindViewHolder", startTime); } }
src/com/android/settings/fuelgauge/PowerUsageAdvanced.java +0 −18 Original line number Diff line number Diff line Loading @@ -63,9 +63,6 @@ public class PowerUsageAdvanced extends PowerUsageBase { mHistPref = (BatteryHistoryPreference) findPreference(KEY_BATTERY_GRAPH); mPowerUsageFeatureProvider = FeatureFactory.getFactory(context) .getPowerUsageFeatureProvider(context); // init the summary so other preferences won't have unnecessary move updateHistPrefSummary(context); restoreSavedInstance(icicle); } Loading Loading @@ -151,24 +148,9 @@ public class PowerUsageAdvanced extends PowerUsageBase { return; } updatePreference(mHistPref); updateHistPrefSummary(context); mBatteryAppListPreferenceController.refreshAppListGroup(mBatteryUsageStats, mShowAllApps); } private void updateHistPrefSummary(Context context) { Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); final boolean plugged = batteryIntent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) != 0; if (mPowerUsageFeatureProvider.isEnhancedBatteryPredictionEnabled(context) && !plugged) { mHistPref.setBottomSummary( mPowerUsageFeatureProvider.getAdvancedUsageScreenInfoString()); } else { mHistPref.hideBottomSummary(); } } public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider() { @Override Loading