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

Commit 94565418 authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "Make user switcher appear inside the QS panel" into lmp-dev

parents a50cd8d4 1ef80fe5
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!--
  ~ Copyright (C) 2014 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
  -->

<com.android.systemui.qs.tiles.UserDetail
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <include layout="@layout/user_switcher_host" />
</com.android.systemui.qs.tiles.UserDetail>
 No newline at end of file
+3 −9
Original line number Diff line number Diff line
@@ -21,17 +21,11 @@
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#dd000000"
        android:elevation="12dp">
    <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/volume_panel_top"
            android:background="@*android:drawable/dialog_full_holo_dark">
        android:layout_height="match_parent">

        <ListView android:id="@android:id/list"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:listitem="@layout/user_switcher_item"/>
    </FrameLayout>

</com.android.systemui.settings.UserSwitcherHostView>
 No newline at end of file
+59 −24
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.systemui.R;
import com.android.systemui.qs.QSTile.DetailAdapter;
import com.android.systemui.settings.BrightnessController;
import com.android.systemui.settings.ToggleSlider;
import com.android.systemui.statusbar.phone.QSTileHost;

import java.util.ArrayList;

@@ -61,9 +62,10 @@ public class QSPanel extends ViewGroup {
    private boolean mExpanded;
    private boolean mListening;

    private TileRecord mDetailRecord;
    private Record mDetailRecord;
    private Callback mCallback;
    private BrightnessController mBrightnessController;
    private QSTileHost mHost;

    public QSPanel(Context context) {
        this(context, null);
@@ -89,12 +91,24 @@ public class QSPanel extends ViewGroup {
        mBrightnessController = new BrightnessController(getContext(),
                (ImageView) findViewById(R.id.brightness_icon),
                (ToggleSlider) findViewById(R.id.brightness_slider));

        mDetailDoneButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                showDetail(false, mDetailRecord);
            }
        });
    }

    public void setCallback(Callback callback) {
        mCallback = callback;
    }

    public void setHost(QSTileHost host) {
        mHost = host;
    }


    public void updateResources() {
        final Resources res = mContext.getResources();
        final int columns = Math.max(1, res.getInteger(R.integer.quick_settings_num_columns));
@@ -143,7 +157,13 @@ public class QSPanel extends ViewGroup {
        }
    }

    private void showDetail(boolean show, TileRecord r) {
    public void showDetailAdapter(boolean show, DetailAdapter adapter) {
        Record r = new Record();
        r.detailAdapter = adapter;
        showDetail(show, r);
    }

    private void showDetail(boolean show, Record r) {
        mHandler.obtainMessage(H.SHOW_DETAIL, show ? 1 : 0, 0, r).sendToTarget();
    }

@@ -203,40 +223,52 @@ public class QSPanel extends ViewGroup {
        addView(r.tileView);
    }

    private void handleShowDetail(TileRecord r, boolean show) {
        if (r == null) return;
        AnimatorListener listener = null;
    private void handleShowDetail(Record r, boolean show) {
        if (r instanceof TileRecord) {
            handleShowDetailTile((TileRecord) r, show);
        } else {
            handleShowDetailImpl(r, show, getWidth() /* x */, 0/* y */);
        }
    }

    private void handleShowDetailTile(TileRecord r, boolean show) {
        if ((mDetailRecord != null) == show) return;

        if (show) {
            if (mDetailRecord != null) return;  // already showing something in detail
            r.detailAdapter = r.tile.getDetailAdapter();
            if (r.detailAdapter == null) return;
            mDetailRecord = r;
            r.detailView = r.detailAdapter.createDetailView(mContext, r.detailView, mDetailContent);
            if (r.detailView == null) throw new IllegalStateException("Must return detail view");
            mDetailDoneButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    showDetail(false, mDetailRecord);
        }
            });
            final Intent settingsIntent = r.detailAdapter.getSettingsIntent();
        int x = r.tileView.getLeft() + r.tileView.getWidth() / 2;
        int y = r.tileView.getTop() + r.tileView.getHeight() / 2;
        handleShowDetailImpl(r, show, x, y);
    }

    private void handleShowDetailImpl(Record r, boolean show, int x, int y) {
        if ((mDetailRecord != null) == show) return;  // already in right state
        DetailAdapter detailAdapter = null;
        AnimatorListener listener = null;
        if (show) {
            detailAdapter = r.detailAdapter;
            r.detailView = detailAdapter.createDetailView(mContext, r.detailView, mDetailContent);
            if (r.detailView == null) throw new IllegalStateException("Must return detail view");

            final Intent settingsIntent = detailAdapter.getSettingsIntent();
            mDetailSettingsButton.setVisibility(settingsIntent != null ? VISIBLE : GONE);
            mDetailSettingsButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    mDetailRecord.tile.mHost.startSettingsActivity(settingsIntent);
                    mHost.startSettingsActivity(settingsIntent);
                }
            });

            mDetailContent.removeAllViews();
            mDetail.bringToFront();
            mDetailContent.addView(r.detailView);
            mDetailRecord = r;
        } else {
            if (mDetailRecord == null) return;
            listener = mTeardownDetailWhenDone;
        }
        fireShowingDetail(show ? r.detailAdapter : null);
        int x = r.tileView.getLeft() + r.tileView.getWidth() / 2;
        int y = r.tileView.getTop() + r.tileView.getHeight() / 2;
        fireShowingDetail(show ? detailAdapter : null);
        mClipper.animateCircularClip(x, y, show, listener);
    }

@@ -339,18 +371,21 @@ public class QSPanel extends ViewGroup {
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == SHOW_DETAIL) {
                handleShowDetail((TileRecord)msg.obj, msg.arg1 != 0);
                handleShowDetail((Record)msg.obj, msg.arg1 != 0);
            } else if (msg.what == SET_TILE_VISIBILITY) {
                handleSetTileVisibility((View)msg.obj, msg.arg1 != 0);
            }
        }
    }

    private static final class TileRecord {
        QSTile<?> tile;
        QSTileView tileView;
    private static class Record {
        View detailView;
        DetailAdapter detailAdapter;
    }

    private static final class TileRecord extends Record {
        QSTile<?> tile;
        QSTileView tileView;
        int row;
        int col;
    }
+78 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 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.systemui.qs.tiles;

import com.android.systemui.R;
import com.android.systemui.qs.QSTile;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

/**
 * Quick settings detail view for user switching.
 */
public class UserDetail extends FrameLayout {

    static final Intent USER_SETTINGS_INTENT = new Intent("android.settings.USER_SETTINGS");

    public UserDetail(Context context) {
        this(context, null);
    }

    public UserDetail(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public UserDetail(Context context, AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    public UserDetail(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    public static QSTile.DetailAdapter USER_DETAIL_ADAPTER = new QSTile.DetailAdapter() {
        @Override
        public int getTitle() {
            return R.string.quick_settings_user_title;
        }

        @Override
        public Boolean getToggleState() {
            return null;
        }

        @Override
        public View createDetailView(Context context, View convertView, ViewGroup parent) {
            return LayoutInflater.from(context).inflate(R.layout.qs_user_detail, parent, false);
        }

        @Override
        public Intent getSettingsIntent() {
            return USER_SETTINGS_INTENT;
        }

        @Override
        public void setToggleState(boolean state) {
        }
    };
}
+1 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ public class UserSwitcherHostView extends FrameLayout
        mListView = (ListView) findViewById(android.R.id.list);
        mListView.setAdapter(mAdapter);
        mListView.setOnItemClickListener(this);
        refreshUsers();
    }

    @Override
Loading