Show Floating action button to request manage credentials
Background * This is part of the work to support a credential management app on unmanaged devices. Changes * Show FAB for detailed/long manage credentials authentication policy. * Hide FAB for short manage credentials authentication policy. * Unexpand FAB once the user start starts scrolling. * Hide FAB once the user has scrolled to the bottom. Manual Testing * Verify FAB is shown for a detailed/long policy: https://screenshot.googleplex.com/BUb4LGz3GD6AozS * Verify FAB is hidden for a short policy * Verify FAB is hidden when user has scrolled to the bottom: https://screenshot.googleplex.com/6FQRqto3r3jzfXH * Verify FAB is unexpanded (text hidden) when the users start scrolling: https://screenshot.googleplex.com/4FfAt5MsCfrAwQK Bug: 165641221 Test: Manual Testing make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.security.RequestManageCredentialsTest Change-Id: Ied2ef726ad4dcc3f92c20249f80294f0a3071a8a
This commit is contained in:
@@ -35,6 +35,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
||||
|
||||
/**
|
||||
* Displays a full screen to the user asking whether the calling app can manage the user's
|
||||
* KeyChain credentials. This screen includes the authentication policy highlighting what apps and
|
||||
@@ -62,6 +64,7 @@ public class RequestManageCredentials extends Activity {
|
||||
private RecyclerView mRecyclerView;
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
private LinearLayout mButtonPanel;
|
||||
private ExtendedFloatingActionButton mExtendedFab;
|
||||
|
||||
private boolean mDisplayingButtonPanel = false;
|
||||
|
||||
@@ -79,6 +82,7 @@ public class RequestManageCredentials extends Activity {
|
||||
|
||||
loadRecyclerView();
|
||||
loadButtons();
|
||||
loadExtendedFloatingActionButton();
|
||||
addOnScrollListener();
|
||||
} else {
|
||||
Log.e(TAG, "Unable to start activity because intent action is not "
|
||||
@@ -106,6 +110,15 @@ public class RequestManageCredentials extends Activity {
|
||||
allowButton.setOnClickListener(setCredentialManagementApp());
|
||||
}
|
||||
|
||||
private void loadExtendedFloatingActionButton() {
|
||||
mExtendedFab = findViewById(R.id.extended_fab);
|
||||
mExtendedFab.setOnClickListener(v -> {
|
||||
mRecyclerView.scrollToPosition(mAuthenticationPolicy.getAppAndUriMappings().size());
|
||||
mExtendedFab.hide();
|
||||
showButtonPanel();
|
||||
});
|
||||
}
|
||||
|
||||
private View.OnClickListener finishRequestManageCredentials() {
|
||||
return v -> {
|
||||
Toast.makeText(this, R.string.request_manage_credentials_dont_allow,
|
||||
@@ -130,9 +143,16 @@ public class RequestManageCredentials extends Activity {
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
if (!mDisplayingButtonPanel) {
|
||||
// On down scroll, hide text in floating action button by setting
|
||||
// extended to false.
|
||||
if (dy > 0 && mExtendedFab.getVisibility() == View.VISIBLE) {
|
||||
mExtendedFab.setExtended(false);
|
||||
}
|
||||
if (isRecyclerScrollable()) {
|
||||
mExtendedFab.show();
|
||||
hideButtonPanel();
|
||||
} else {
|
||||
mExtendedFab.hide();
|
||||
showButtonPanel();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user