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

Commit fe23da57 authored by Fan Zhang's avatar Fan Zhang
Browse files

Misc layout fixes

- Apply entity header effect to battery summary screen.
- BidiWrap wifi ap name is it's correctly displayed in RLT languages
- Remove footer preference layout - settingslib already has one

Fix: 62039146
Fix: 62138362
Fix: 37920219
Test: make RunSettingsRoboTests

Change-Id: Idf1385ee40772c63075e5f81eb039c6da56256ab
parent 2be17c0d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/app_snippet"
    android:id="@+id/battery_entity_header"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"

res/layout/preference_footer.xml

deleted100644 → 0
+0 −54
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"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
    android:background="?android:attr/selectableItemBackground"
    android:clipToPadding="false">

    <LinearLayout
        android:id="@+id/icon_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:minWidth="56dp"
        android:gravity="start|top"
        android:orientation="horizontal"
        android:paddingEnd="12dp"
        android:paddingTop="20dp"
        android:paddingBottom="4dp">
        <ImageView
            android:id="@android:id/icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <com.android.settingslib.widget.LinkTextView
        android:id="@android:id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingBottom="16dp"
        android:paddingTop="16dp"
        android:maxLines="10"
        android:textColor="?android:attr/textColorSecondary"
        android:ellipsize="marquee" />

</LinearLayout>
 No newline at end of file
+29 −3
Original line number Diff line number Diff line
@@ -17,24 +17,32 @@

package com.android.settings.fuelgauge;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.PreferenceFragment;
import android.support.v7.preference.PreferenceScreen;
import android.widget.TextView;

import com.android.settings.R;
import com.android.settings.applications.LayoutPreference;
import com.android.settings.core.PreferenceController;
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.Utils;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;

/**
 * Controller that update the battery header view
 */
public class BatteryHeaderPreferenceController extends PreferenceController {
public class BatteryHeaderPreferenceController extends PreferenceController
        implements LifecycleObserver, OnStart {
    @VisibleForTesting
    static final String KEY_BATTERY_HEADER = "battery_header";

    @VisibleForTesting
    BatteryMeterView mBatteryMeterView;
    @VisibleForTesting
@@ -42,16 +50,26 @@ public class BatteryHeaderPreferenceController extends PreferenceController {
    @VisibleForTesting
    TextView mSummary;

    private final Activity mActivity;
    private final PreferenceFragment mHost;
    private final Lifecycle mLifecycle;

    private LayoutPreference mBatteryLayoutPref;

    public BatteryHeaderPreferenceController(Context context) {
    public BatteryHeaderPreferenceController(Context context, Activity activity,
            PreferenceFragment host, Lifecycle lifecycle) {
        super(context);
        mActivity = activity;
        mHost = host;
        mLifecycle = lifecycle;
        if (mLifecycle != null) {
            mLifecycle.addObserver(this);
        }
    }

    @Override
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);

        mBatteryLayoutPref = (LayoutPreference) screen.findPreference(KEY_BATTERY_HEADER);
        mBatteryMeterView = (BatteryMeterView) mBatteryLayoutPref
                .findViewById(R.id.battery_header_icon);
@@ -76,6 +94,14 @@ public class BatteryHeaderPreferenceController extends PreferenceController {
        return KEY_BATTERY_HEADER;
    }

    @Override
    public void onStart() {
        EntityHeaderController.newInstance(mActivity, mHost,
                mBatteryLayoutPref.findViewById(R.id.battery_entity_header))
                .setRecyclerView(mHost.getListView(), mLifecycle)
                .styleActionBar(mActivity);
    }

    public void updateHeaderPreference(BatteryInfo info) {
        mTimeText.setText(Utils.formatPercentage(info.batteryLevel));
        if (info.remainingLabel == null) {
+2 −5
Original line number Diff line number Diff line
@@ -63,7 +63,6 @@ import com.android.settings.fuelgauge.anomaly.AnomalyLoader;
import com.android.settings.fuelgauge.anomaly.AnomalySummaryPreferenceController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.widget.FooterPreferenceMixin;

import java.util.ArrayList;
import java.util.Arrays;
@@ -106,9 +105,6 @@ public class PowerUsageSummary extends PowerUsageBase implements
    static final int MENU_TOGGLE_APPS = Menu.FIRST + 5;
    private static final int MENU_HELP = Menu.FIRST + 6;

    private final FooterPreferenceMixin mFooterPreferenceMixin =
            new FooterPreferenceMixin(this, getLifecycle());

    @VisibleForTesting
    boolean mShowAllApps = false;
    @VisibleForTesting
@@ -246,7 +242,8 @@ public class PowerUsageSummary extends PowerUsageBase implements
    @Override
    protected List<PreferenceController> getPreferenceControllers(Context context) {
        final List<PreferenceController> controllers = new ArrayList<>();
        mBatteryHeaderPreferenceController = new BatteryHeaderPreferenceController(context);
        mBatteryHeaderPreferenceController = new BatteryHeaderPreferenceController(
                context, getActivity(), this /* host */, getLifecycle());
        controllers.add(mBatteryHeaderPreferenceController);
        controllers.add(new AutoBrightnessPreferenceController(context, KEY_AUTO_BRIGHTNESS));
        controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT));
+6 −4
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.text.BidiFormatter;

import com.android.settings.R;
import com.android.settings.datausage.DataSaverBackend;
@@ -109,12 +110,13 @@ public class WifiApEnabler {
        }
    }

    public void updateConfigSummary(WifiConfiguration wifiConfig) {
    private void updateConfigSummary(WifiConfiguration wifiConfig) {
        String s = mContext.getString(
                com.android.internal.R.string.wifi_tether_configure_ssid_default);
        mSwitch.setSummary(String.format(
                    mContext.getString(R.string.wifi_tether_enabled_subtext),
                    (wifiConfig == null) ? s : wifiConfig.SSID));

        mSwitch.setSummary(mContext.getString(R.string.wifi_tether_enabled_subtext,
                BidiFormatter.getInstance().unicodeWrap(
                        (wifiConfig == null) ? s : wifiConfig.SSID)));
    }

    private void updateTetherState(Object[] available, Object[] tethered, Object[] errored) {
Loading