Merge "RequestManageCredentials landscape mode" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
17101d6ebe
139
res/layout-land/request_manage_credentials.xml
Normal file
139
res/layout-land/request_manage_credentials.xml
Normal file
@@ -0,0 +1,139 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright (C) 2021 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"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="2">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
style="@style/RequestManageCredentialsHeaderLandscape">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/credential_management_app_icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@null" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/credential_management_app_title"
|
||||
style="@style/RequestManageCredentialsTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/credential_management_app_description"
|
||||
style="@style/RequestManageCredentialsDescription"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/request_manage_credentials_description" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="true">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/apps_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_panel"
|
||||
style="@style/RequestManageCredentialsButtonPanel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:id="@+id/dont_allow_button"
|
||||
style="@style/RequestManageCredentialsDontAllowButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/request_manage_credentials_dont_allow" />
|
||||
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/allow_button"
|
||||
style="@style/RequestManageCredentialsAllowButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/request_manage_credentials_allow" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
android:id="@+id/extended_fab"
|
||||
style="@style/RequestManageCredentialsFab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/request_manage_credentials_more"
|
||||
android:theme="@style/Theme.CollapsingToolbar.Settings"
|
||||
app:backgroundTint="?android:attr/colorPrimary"
|
||||
app:elevation="3dp"
|
||||
app:icon="@drawable/ic_arrow_downward"
|
||||
app:iconTint="?android:attr/colorAccent"
|
||||
app:layout_anchor="@id/apps_list"
|
||||
app:layout_anchorGravity="bottom|center" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@@ -829,6 +829,13 @@
|
||||
<item name="android:orientation">vertical</item>
|
||||
</style>
|
||||
|
||||
<style name="RequestManageCredentialsHeaderLandscape">
|
||||
<item name="android:paddingStart">24dp</item>
|
||||
<item name="android:paddingEnd">24dp</item>
|
||||
<item name="android:paddingTop">24dp</item>
|
||||
<item name="android:paddingBottom">24dp</item>
|
||||
</style>
|
||||
|
||||
<style name="RequestManageCredentialsTitle">
|
||||
<item name="android:layout_marginTop">24dp</item>
|
||||
<item name="android:textSize">36sp</item>
|
||||
|
@@ -21,7 +21,10 @@ import android.app.Activity;
|
||||
import android.app.admin.DevicePolicyEventLogger;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -37,7 +40,9 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@@ -83,6 +88,7 @@ public class RequestManageCredentials extends Activity {
|
||||
private KeyChain.KeyChainConnection mKeyChainConnection;
|
||||
|
||||
private boolean mDisplayingButtonPanel = false;
|
||||
private boolean mIsLandscapeMode = false;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -114,6 +120,8 @@ public class RequestManageCredentials extends Activity {
|
||||
.setStrings(mCredentialManagerPackage)
|
||||
.write();
|
||||
setContentView(R.layout.request_manage_credentials);
|
||||
mIsLandscapeMode = getResources().getConfiguration().orientation
|
||||
== Configuration.ORIENTATION_LANDSCAPE;
|
||||
|
||||
mKeyChainTread = new HandlerThread("KeyChainConnection");
|
||||
mKeyChainTread.start();
|
||||
@@ -134,6 +142,9 @@ public class RequestManageCredentials extends Activity {
|
||||
getNumberOfAuthenticationPolicyUris(mAuthenticationPolicy))
|
||||
.write();
|
||||
|
||||
if (mIsLandscapeMode) {
|
||||
loadHeader();
|
||||
}
|
||||
loadRecyclerView();
|
||||
loadButtons();
|
||||
loadExtendedFloatingActionButton();
|
||||
@@ -193,7 +204,7 @@ public class RequestManageCredentials extends Activity {
|
||||
|
||||
CredentialManagementAppAdapter recyclerViewAdapter = new CredentialManagementAppAdapter(
|
||||
this, mCredentialManagerPackage, mAuthenticationPolicy.getAppAndUriMappings(),
|
||||
/* include header= */ true, /* include expander= */ false);
|
||||
/* include header= */ !mIsLandscapeMode, /* include expander= */ false);
|
||||
mRecyclerView.setAdapter(recyclerViewAdapter);
|
||||
}
|
||||
|
||||
@@ -214,12 +225,33 @@ public class RequestManageCredentials extends Activity {
|
||||
private void loadExtendedFloatingActionButton() {
|
||||
mExtendedFab = findViewById(R.id.extended_fab);
|
||||
mExtendedFab.setOnClickListener(v -> {
|
||||
mRecyclerView.scrollToPosition(mAuthenticationPolicy.getAppAndUriMappings().size());
|
||||
final int position = mIsLandscapeMode
|
||||
? mAuthenticationPolicy.getAppAndUriMappings().size() - 1
|
||||
: mAuthenticationPolicy.getAppAndUriMappings().size();
|
||||
mRecyclerView.scrollToPosition(position);
|
||||
mExtendedFab.hide();
|
||||
showButtonPanel();
|
||||
});
|
||||
}
|
||||
|
||||
private void loadHeader() {
|
||||
final ImageView mAppIconView = findViewById(R.id.credential_management_app_icon);
|
||||
final TextView mTitleView = findViewById(R.id.credential_management_app_title);
|
||||
try {
|
||||
ApplicationInfo applicationInfo =
|
||||
getPackageManager().getApplicationInfo(mCredentialManagerPackage, 0);
|
||||
mAppIconView.setImageDrawable(getPackageManager().getApplicationIcon(applicationInfo));
|
||||
mTitleView.setText(TextUtils.expandTemplate(
|
||||
getText(R.string.request_manage_credentials_title),
|
||||
applicationInfo.loadLabel(getPackageManager())));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
mAppIconView.setImageDrawable(null);
|
||||
mTitleView.setText(TextUtils.expandTemplate(
|
||||
getText(R.string.request_manage_credentials_title),
|
||||
mCredentialManagerPackage));
|
||||
}
|
||||
}
|
||||
|
||||
private void setOrUpdateCredentialManagementAppAndFinish() {
|
||||
try {
|
||||
mKeyChainConnection.getService().setCredentialManagementApp(
|
||||
|
Reference in New Issue
Block a user