Merge "Remove QS Gutter"
diff --git a/packages/SystemUI/res/layout/battery_detail.xml b/packages/SystemUI/res/layout/battery_detail.xml
deleted file mode 100644
index 6162d65..0000000
--- a/packages/SystemUI/res/layout/battery_detail.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-<?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:systemui="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
-
- <TextView
- android:id="@+id/charge_and_estimation"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingStart="16dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="?android:attr/colorAccent" />
-
- <com.android.systemui.ResizingSpace
- android:layout_width="match_parent"
- android:layout_height="@dimen/battery_detail_graph_space_top" />
-
- <com.android.settingslib.graph.UsageView
- android:id="@+id/battery_usage"
- android:layout_width="match_parent"
- android:layout_height="141dp"
- android:layout_marginStart="16dp"
- android:layout_marginEnd="24dp"
- systemui:sideLabels="@array/battery_labels"
- android:colorAccent="?android:attr/colorAccent"
- systemui:textColor="?android:attr/textColorSecondary" />
-
- <com.android.systemui.ResizingSpace
- android:layout_width="match_parent"
- android:layout_height="@dimen/battery_detail_graph_space_bottom" />
-
- <View
- android:layout_width="match_parent"
- android:layout_height="1dp"
- android:background="?android:attr/listDivider"
- android:layout_marginBottom="8dp" />
-
- <RelativeLayout
- android:id="@+id/switch_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingTop="16dp"
- android:paddingBottom="16dp"
- android:background="?android:attr/selectableItemBackground"
- android:clickable="true">
-
- <ImageView
- android:id="@android:id/icon"
- android:layout_width="24dp"
- android:layout_height="24dp"
- android:scaleType="fitCenter"
- android:adjustViewBounds="true"
- android:layout_alignParentTop="true"
- android:layout_alignParentStart="true"
- android:layout_marginStart="16dp"
- android:layout_marginEnd="32dp" />
-
- <TextView
- android:id="@android:id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_toStartOf="@android:id/toggle"
- android:layout_toEndOf="@android:id/icon"
- android:textAppearance="@style/TextAppearance.QS.DetailItemPrimary"
- android:text="@string/battery_detail_switch_title" />
-
- <TextView
- android:id="@android:id/summary"
- android:visibility="gone"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@android:id/title"
- android:layout_toStartOf="@android:id/toggle"
- android:layout_toEndOf="@android:id/icon"
- android:textAppearance="@style/TextAppearance.QS.DetailItemSecondary"
- android:text="@string/battery_detail_switch_summary" />
-
- <Switch
- android:id="@android:id/toggle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentEnd="true"
- android:layout_alignParentTop="true"
- android:layout_marginEnd="16dp"
- android:clickable="false"
- android:textAppearance="@style/TextAppearance.QS.DetailHeader" />
-
- </RelativeLayout>
-</LinearLayout>
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java
index 336c581..918c00c 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java
@@ -15,27 +15,12 @@
*/
package com.android.systemui.qs.tiles;
-import android.content.BroadcastReceiver;
-import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
import android.service.quicksettings.Tile;
-import android.util.TypedValue;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnAttachStateChangeListener;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.widget.Checkable;
-import android.widget.ImageView;
import android.widget.Switch;
-import android.widget.TextView;
-
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settingslib.graph.BatteryMeterDrawableBase;
import com.android.systemui.Dependency;
import com.android.systemui.R;
-import com.android.systemui.plugins.qs.DetailAdapter;
import com.android.systemui.plugins.qs.QSTile.BooleanState;
import com.android.systemui.qs.QSHost;
import com.android.systemui.qs.tileimpl.QSTileImpl;
@@ -45,12 +30,10 @@
BatteryController.BatteryStateChangeCallback {
private final BatteryController mBatteryController;
- private final BatteryDetail mBatteryDetail = new BatteryDetail();
private int mLevel;
private boolean mPowerSave;
private boolean mCharging;
- private boolean mDetailShown;
private boolean mPluggedIn;
public BatterySaverTile(QSHost host) {
@@ -78,14 +61,6 @@
}
@Override
- public void setDetailListening(boolean listening) {
- super.setDetailListening(listening);
- if (!listening) {
- mBatteryDetail.mCurrentView = null;
- }
- }
-
- @Override
public Intent getLongClickIntent() {
return new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
}
@@ -117,135 +92,11 @@
mPluggedIn = pluggedIn;
mCharging = charging;
refreshState(level);
- if (mDetailShown) {
- mBatteryDetail.postBindView();
- }
}
@Override
public void onPowerSaveChanged(boolean isPowerSave) {
mPowerSave = isPowerSave;
refreshState(null);
- if (mDetailShown) {
- mBatteryDetail.postBindView();
- }
- }
-
- private final class BatteryDetail implements DetailAdapter, OnClickListener,
- OnAttachStateChangeListener {
- private final BatteryMeterDrawableBase mDrawable
- = new BatteryMeterDrawableBase(
- mHost.getContext(),
- mHost.getContext().getColor(R.color.meter_background_color));
- private View mCurrentView;
-
- @Override
- public CharSequence getTitle() {
- return mContext.getString(R.string.battery_panel_title, mLevel);
- }
-
- @Override
- public Boolean getToggleState() {
- return null;
- }
-
- @Override
- public View createDetailView(Context context, View convertView, ViewGroup parent) {
- if (convertView == null) {
- convertView = LayoutInflater.from(mContext).inflate(R.layout.battery_detail, parent,
- false);
- }
- mCurrentView = convertView;
- mCurrentView.addOnAttachStateChangeListener(this);
- bindView();
- return convertView;
- }
-
- private void postBindView() {
- if (mCurrentView == null) return;
- mCurrentView.post(new Runnable() {
- @Override
- public void run() {
- bindView();
- }
- });
- }
-
- private void bindView() {
- if (mCurrentView == null) {
- return;
- }
- mDrawable.setBatteryLevel(100);
- mDrawable.setCharging(false);
- mDrawable.setPowerSave(true);
- mDrawable.setShowPercent(false);
- ((ImageView) mCurrentView.findViewById(android.R.id.icon)).setImageDrawable(mDrawable);
- Checkable checkbox = (Checkable) mCurrentView.findViewById(android.R.id.toggle);
- checkbox.setChecked(mPowerSave);
- final TextView batterySaverTitle =
- (TextView) mCurrentView.findViewById(android.R.id.title);
- final TextView batterySaverSummary =
- (TextView) mCurrentView.findViewById(android.R.id.summary);
- if (mCharging) {
- mCurrentView.findViewById(R.id.switch_container).setAlpha(.7f);
- batterySaverTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
- batterySaverTitle.setText(R.string.battery_detail_charging_summary);
- mCurrentView.findViewById(android.R.id.toggle).setVisibility(View.GONE);
- mCurrentView.findViewById(R.id.switch_container).setClickable(false);
- } else {
- mCurrentView.findViewById(R.id.switch_container).setAlpha(1);
- batterySaverTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
- batterySaverTitle.setText(R.string.battery_detail_switch_title);
- batterySaverSummary.setText(R.string.battery_detail_switch_summary);
- mCurrentView.findViewById(android.R.id.toggle).setVisibility(View.VISIBLE);
- mCurrentView.findViewById(R.id.switch_container).setClickable(true);
- mCurrentView.findViewById(R.id.switch_container).setOnClickListener(this);
- }
- }
-
- @Override
- public void onClick(View v) {
- mBatteryController.setPowerSaveMode(!mPowerSave);
- }
-
- @Override
- public Intent getSettingsIntent() {
- return new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
- }
-
- @Override
- public void setToggleState(boolean state) {
- // No toggle state.
- }
-
- @Override
- public int getMetricsCategory() {
- return MetricsEvent.QS_BATTERY_DETAIL;
- }
-
- @Override
- public void onViewAttachedToWindow(View v) {
- if (!mDetailShown) {
- mDetailShown = true;
- v.getContext().registerReceiver(mReceiver,
- new IntentFilter(Intent.ACTION_TIME_TICK), null,
- Dependency.get(Dependency.TIME_TICK_HANDLER));
- }
- }
-
- @Override
- public void onViewDetachedFromWindow(View v) {
- if (mDetailShown) {
- mDetailShown = false;
- v.getContext().unregisterReceiver(mReceiver);
- }
- }
-
- private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- postBindView();
- }
- };
}
}
\ No newline at end of file