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

Commit f86d4055 authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge "Removed bugreport tile code from Quick settings" into lmp-dev

parents 3eccbc27 3f11dede
Loading
Loading
Loading
Loading
+0 −25
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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="64dp"
        android:height="64dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">

    <path
        android:fillColor="#FFFFFFFF"
        android:pathData="M20.0,8.0l-2.8,0.0c-0.5,-0.8 -1.1,-1.5 -1.8,-2.0L17.0,4.4L15.6,3.0l-2.2,2.2C13.0,5.1 12.5,5.0 12.0,5.0s-1.0,0.1 -1.4,0.2L8.4,3.0L7.0,4.4L8.6,6.0C7.9,6.5 7.3,7.2 6.8,8.0L4.0,8.0l0.0,2.0l2.1,0.0C6.0,10.3 6.0,10.7 6.0,11.0l0.0,1.0L4.0,12.0l0.0,2.0l2.0,0.0l0.0,1.0c0.0,0.3 0.0,0.7 0.1,1.0L4.0,16.0l0.0,2.0l2.8,0.0c1.0,1.8 3.0,3.0 5.2,3.0s4.2,-1.2 5.2,-3.0L20.0,18.0l0.0,-2.0l-2.1,0.0c0.1,-0.3 0.1,-0.7 0.1,-1.0l0.0,-1.0l2.0,0.0l0.0,-2.0l-2.0,0.0l0.0,-1.0c0.0,-0.3 0.0,-0.7 -0.1,-1.0L20.0,10.0L20.0,8.0zM14.0,16.0l-4.0,0.0l0.0,-2.0l4.0,0.0L14.0,16.0zM14.0,12.0l-4.0,0.0l0.0,-2.0l4.0,0.0L14.0,12.0z"/>
</vector>
+0 −2
Original line number Diff line number Diff line
@@ -668,8 +668,6 @@
    <!-- Shows when people have clicked at the right edge of the screen to explain how to open the phone. In right-to-left languages, this is the opposite direction. [CHAR LIMIT=60] -->
    <string name="camera_hint">Swipe left for camera</string>

    <string name="bugreport_tile_extended" translatable="false">%s\n%s (%s)</string>

    <!-- Zen mode condition: no exit criteria. [CHAR LIMIT=NONE] -->
    <string name="zen_mode_forever">Indefinitely</string>

+0 −115
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 android.app.ActivityManagerNative;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Build;
import android.os.RemoteException;
import android.provider.Settings.Global;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;

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

/** Quick settings tile: Bug report **/
public class BugreportTile extends QSTile<QSTile.State> {

    private final GlobalSetting mSetting;

    public BugreportTile(Host host) {
        super(host);
        mSetting = new GlobalSetting(mContext, mHandler, Global.BUGREPORT_IN_POWER_MENU) {
            @Override
            protected void handleValueChanged(int value) {
                handleRefreshState(null);
            }
        };
    }

    @Override
    protected State newTileState() {
        return new State();
    }

    @Override
    public void setListening(boolean listening) {
        mSetting.setListening(listening);
    }

    @Override
    protected void handleClick() {
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                mHost.collapsePanels();
                mUiHandler.post(mShowDialog);
            }
        });
    }

    @Override
    protected void handleUpdateState(State state, Object pushArg) {
        state.visible = mSetting.getValue() != 0;
        state.iconId = R.drawable.ic_qs_bugreport;
        state.label = mContext.getString(
                R.string.bugreport_tile_extended,
                mContext.getString(com.android.internal.R.string.bugreport_title),
                Build.VERSION.RELEASE,
                Build.ID);
    }

    private final Runnable mShowDialog = new Runnable() {
        @Override
        public void run() {
            final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
            builder.setPositiveButton(com.android.internal.R.string.report, new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (which == DialogInterface.BUTTON_POSITIVE) {
                        // Add a little delay before executing, to give the
                        // dialog a chance to go away before it takes a
                        // screenshot.
                        mHandler.postDelayed(new Runnable() {
                            @Override public void run() {
                                try {
                                    ActivityManagerNative.getDefault().requestBugReport();
                                } catch (RemoteException e) {
                                }
                            }
                        }, 500);
                    }
                }
            });
            builder.setMessage(com.android.internal.R.string.bugreport_message);
            builder.setTitle(com.android.internal.R.string.bugreport_title);
            builder.setCancelable(true);
            final Dialog dialog = builder.create();
            dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
            try {
                WindowManagerGlobal.getWindowManagerService().dismissKeyguard();
            } catch (RemoteException e) {
            }
            dialog.show();
        }
    };
}