19f0bcd12aab977eec99d692de9206484e859a252Todd Volkert/* 29f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * Copyright (C) 2015 The Android Open Source Project 39f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * 49f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * Licensed under the Apache License, Version 2.0 (the "License"); 59f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * you may not use this file except in compliance with the License. 69f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * You may obtain a copy of the License at 79f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * 89f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * http://www.apache.org/licenses/LICENSE-2.0 99f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * 109f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * Unless required by applicable law or agreed to in writing, software 119f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * distributed under the License is distributed on an "AS IS" BASIS, 129f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * See the License for the specific language governing permissions and 149f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * limitations under the License. 159f0bcd12aab977eec99d692de9206484e859a252Todd Volkert */ 169f0bcd12aab977eec99d692de9206484e859a252Todd Volkert 179f0bcd12aab977eec99d692de9206484e859a252Todd Volkertpackage com.android.packageinstaller.permission.ui; 189f0bcd12aab977eec99d692de9206484e859a252Todd Volkert 199f0bcd12aab977eec99d692de9206484e859a252Todd Volkertimport android.graphics.drawable.Icon; 209f0bcd12aab977eec99d692de9206484e859a252Todd Volkertimport android.os.Bundle; 219f0bcd12aab977eec99d692de9206484e859a252Todd Volkertimport android.view.View; 2217c6b0c6492c259e02f1f1edbbf4863a71b6e7abTodd Volkertimport android.view.WindowManager; 239f0bcd12aab977eec99d692de9206484e859a252Todd Volkert 249f0bcd12aab977eec99d692de9206484e859a252Todd Volkert/** 259f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * Class for managing the presentation and user interaction of the "grant 269f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * permissions" user interface. 279f0bcd12aab977eec99d692de9206484e859a252Todd Volkert */ 28ef861375eebd9ac6cce7c0bb163380ab1c951063Svetoslavpublic interface GrantPermissionsViewHandler { 299f0bcd12aab977eec99d692de9206484e859a252Todd Volkert 309f0bcd12aab977eec99d692de9206484e859a252Todd Volkert /** 319f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * Listener interface for getting notified when the user responds to a 329f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * permissions grant request. 339f0bcd12aab977eec99d692de9206484e859a252Todd Volkert */ 349f0bcd12aab977eec99d692de9206484e859a252Todd Volkert interface ResultListener { 359f0bcd12aab977eec99d692de9206484e859a252Todd Volkert void onPermissionGrantResult(String groupName, boolean granted, boolean doNotAskAgain); 369f0bcd12aab977eec99d692de9206484e859a252Todd Volkert } 379f0bcd12aab977eec99d692de9206484e859a252Todd Volkert 389f0bcd12aab977eec99d692de9206484e859a252Todd Volkert /** 399f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * Creates and returns the view hierarchy that is managed by this view 409f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * handler. This must be called before {@link #updateUi}. 419f0bcd12aab977eec99d692de9206484e859a252Todd Volkert */ 429f0bcd12aab977eec99d692de9206484e859a252Todd Volkert View createView(); 439f0bcd12aab977eec99d692de9206484e859a252Todd Volkert 449f0bcd12aab977eec99d692de9206484e859a252Todd Volkert /** 4517c6b0c6492c259e02f1f1edbbf4863a71b6e7abTodd Volkert * Updates the layout attributes of the current window. This is an optional 4617c6b0c6492c259e02f1f1edbbf4863a71b6e7abTodd Volkert * operation; implementations only need to do work in this method if they 4717c6b0c6492c259e02f1f1edbbf4863a71b6e7abTodd Volkert * need to alter the default styles provided by the activity's theme. 4817c6b0c6492c259e02f1f1edbbf4863a71b6e7abTodd Volkert */ 4917c6b0c6492c259e02f1f1edbbf4863a71b6e7abTodd Volkert void updateWindowAttributes(WindowManager.LayoutParams outLayoutParams); 5017c6b0c6492c259e02f1f1edbbf4863a71b6e7abTodd Volkert 5117c6b0c6492c259e02f1f1edbbf4863a71b6e7abTodd Volkert /** 529f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * Updates the view hierarchy to reflect the specified state. 539f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * <p> 549f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * Note that this must be called at least once before showing the UI to 559f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * the user to properly initialize the UI. 569f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * 579f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * @param groupName the name of the permission group 589f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * @param groupCount the total number of groups that are being requested 599f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * @param groupIndex the index of the current group being requested 609f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * @param icon the icon representation of the current group 619f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * @param message the message to display the user 629f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * @param showDoNotAsk whether to show the "do not ask again" option 639f0bcd12aab977eec99d692de9206484e859a252Todd Volkert */ 649f0bcd12aab977eec99d692de9206484e859a252Todd Volkert void updateUi(String groupName, int groupCount, int groupIndex, Icon icon, 659f0bcd12aab977eec99d692de9206484e859a252Todd Volkert CharSequence message, boolean showDoNotAsk); 669f0bcd12aab977eec99d692de9206484e859a252Todd Volkert 679f0bcd12aab977eec99d692de9206484e859a252Todd Volkert /** 689f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * Sets the result listener that will be notified when the user responds 699f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * to a permissions grant request. 709f0bcd12aab977eec99d692de9206484e859a252Todd Volkert */ 719f0bcd12aab977eec99d692de9206484e859a252Todd Volkert GrantPermissionsViewHandler setResultListener(ResultListener listener); 729f0bcd12aab977eec99d692de9206484e859a252Todd Volkert 739f0bcd12aab977eec99d692de9206484e859a252Todd Volkert /** 749f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * Called by {@link GrantPermissionsActivity} to save the state of this 759f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * view handler to the specified bundle. 769f0bcd12aab977eec99d692de9206484e859a252Todd Volkert */ 779f0bcd12aab977eec99d692de9206484e859a252Todd Volkert void saveInstanceState(Bundle outState); 789f0bcd12aab977eec99d692de9206484e859a252Todd Volkert 799f0bcd12aab977eec99d692de9206484e859a252Todd Volkert /** 809f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * Called by {@link GrantPermissionsActivity} to load the state of this 819f0bcd12aab977eec99d692de9206484e859a252Todd Volkert * view handler from the specified bundle. 829f0bcd12aab977eec99d692de9206484e859a252Todd Volkert */ 839f0bcd12aab977eec99d692de9206484e859a252Todd Volkert void loadInstanceState(Bundle savedInstanceState); 84ac65014749a771543f78147ef63fdbfc06e69da7Svetoslav 85ac65014749a771543f78147ef63fdbfc06e69da7Svetoslav /** 86ac65014749a771543f78147ef63fdbfc06e69da7Svetoslav * Gives a chance for handling the back key. 87ac65014749a771543f78147ef63fdbfc06e69da7Svetoslav */ 88ac65014749a771543f78147ef63fdbfc06e69da7Svetoslav void onBackPressed(); 899f0bcd12aab977eec99d692de9206484e859a252Todd Volkert} 90