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

Commit 75bee9bf authored by Fan Zhang's avatar Fan Zhang
Browse files

App header cleanup

- Refactor the entity header layout to use LinearLayout and add id to
  content area
- Remove now unused AppHeader class
- Make entire icon+text area clickable and link to app info page
  Refactor the binding logic from bindButton to its own method.
- Remove unused MultiLinePreference

Fix: 62705377
Test: make RunSettingsRoboTests

Change-Id: I6db554695410e71b669f6fdba29d98fedc3364b9
parent 08da5d84
Loading
Loading
Loading
Loading
+60 −54
Original line number Diff line number Diff line
@@ -16,16 +16,24 @@
  -->

<!-- Entity header -->
<RelativeLayout
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/entity_header"
    style="@style/EntityHeader"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingStart="@dimen/preference_no_icon_padding_start"
    android:paddingTop="24dp"
    android:paddingBottom="24dp">

    <LinearLayout
        android:id="@+id/entity_header_content"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="?android:attr/selectableItemBackground"
        android:orientation="horizontal"
        android:paddingStart="56dp">

        <ImageView
            android:id="@+id/entity_header_icon"
            android:layout_width="48dp"
@@ -34,40 +42,9 @@
            android:layout_gravity="center_horizontal"
            android:antialias="true" />

    <LinearLayout
        android:id="@+id/entity_header_links"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignParentEnd="true"
        android:orientation="vertical">

        <ImageButton
            android:id="@android:id/button1"
            style="?android:attr/actionOverflowButtonStyle"
            android:layout_width="wrap_content"
            android:layout_weight="1"
            android:layout_height="0dp"
            android:minWidth="@dimen/min_tap_target_size"
            android:src="@drawable/ic_settings_24dp"
            android:tint="?android:attr/colorAccent" />

        <ImageButton
            android:id="@android:id/button2"
            style="?android:attr/actionOverflowButtonStyle"
            android:layout_width="wrap_content"
            android:layout_weight="1"
            android:layout_height="0dp"
            android:minWidth="@dimen/min_tap_target_size"
            android:src="@null"
            android:tint="?android:attr/colorAccent" />

    </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
        android:layout_toEndOf="@id/entity_header_icon"
        android:layout_toStartOf="@id/entity_header_links"
            android:paddingStart="16dp"
            android:paddingEnd="16dp"
            android:orientation="vertical">
@@ -105,5 +82,34 @@
                android:textColor="?android:attr/textColorSecondary" />

        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/entity_header_links"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="vertical">

</RelativeLayout>
 No newline at end of file
        <ImageButton
            android:id="@android:id/button1"
            style="?android:attr/actionOverflowButtonStyle"
            android:layout_width="wrap_content"
            android:layout_weight="1"
            android:layout_height="0dp"
            android:minWidth="@dimen/min_tap_target_size"
            android:src="@drawable/ic_settings_24dp"
            android:tint="?android:attr/colorAccent" />

        <ImageButton
            android:id="@android:id/button2"
            style="?android:attr/actionOverflowButtonStyle"
            android:layout_width="wrap_content"
            android:layout_weight="1"
            android:layout_height="0dp"
            android:minWidth="@dimen/min_tap_target_size"
            android:src="@null"
            android:tint="?android:attr/colorAccent" />

    </LinearLayout>

</LinearLayout>
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -28,9 +28,11 @@
    android:orientation="horizontal">

    <LinearLayout
        android:id="@+id/entity_header_content"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="?android:attr/selectableItemBackground"
        android:orientation="vertical">

        <ImageView
+0 −41
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 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.
 */

package com.android.settings;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;

public class AppHeader {

    public static final String EXTRA_HIDE_INFO_BUTTON = "hideInfoButton";
    // constant value that can be used to check return code from sub activity.
    private static final int INSTALLED_APP_DETAILS = 1;

    public static boolean includeAppInfo(final Fragment fragment) {
        Bundle args = fragment.getArguments();
        boolean showInfo = true;
        if (args != null && args.getBoolean(EXTRA_HIDE_INFO_BUTTON, false)) {
            showInfo = false;
        }
        Intent intent = fragment.getActivity().getIntent();
        if (intent != null && intent.getBooleanExtra(EXTRA_HIDE_INFO_BUTTON, false)) {
            showInfo = false;
        }
        return showInfo;
    }
}
+0 −49
Original line number Diff line number Diff line
/*
 * 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.
 */

package com.android.settings;

import android.content.Context;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

public class MultiLinePreference extends Preference {

    public MultiLinePreference(Context ctx, AttributeSet attrs, int defStyle) {
        super(ctx, attrs, defStyle);
    }

    public MultiLinePreference(Context ctx, AttributeSet attrs) {
        super(ctx, attrs);
    }

    public MultiLinePreference(Context ctx) {
        super(ctx);
    }

    @Override
    public void onBindViewHolder(PreferenceViewHolder view) {
        super.onBindViewHolder(view);

        TextView textView = (TextView) view.findViewById(android.R.id.title);
        if (textView != null) {
            textView.setSingleLine(false);
        }
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -51,7 +51,8 @@ public abstract class AppInfoWithHeader extends AppInfoBase {
                .setIsInstantApp(AppUtils.isInstant(mPackageInfo.applicationInfo))
                .setPackageName(mPackageName)
                .setUid(mPackageInfo.applicationInfo.uid)
                .setButtonActions(ActionType.ACTION_APP_INFO, ActionType.ACTION_NONE)
                .setHasAppInfoLink(true)
                .setButtonActions(ActionType.ACTION_NONE, ActionType.ACTION_NONE)
                .done(activity, getPrefContext());
        getPreferenceScreen().addPreference(pref);
    }
Loading