Visualize password requirements and their fulfillment
1. Aggregate policies and generate the requirements 2. When user modifies the password, check is each requirement fulfilled Update the view accordingly. Change-Id: I962ed3b81ce844006be1024a493e94ce52a3fdec Fix: 24900754
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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.settings.password;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import static com.android.settings.password.PasswordRequirementAdapter
|
||||
.PasswordRequirementViewHolder;
|
||||
|
||||
/**
|
||||
* Used in {@link com.android.settings.ConfirmLockPassword} to show password requirements.
|
||||
*/
|
||||
public class PasswordRequirementAdapter extends
|
||||
RecyclerView.Adapter<PasswordRequirementViewHolder> {
|
||||
private String[] mRequirements;
|
||||
|
||||
public PasswordRequirementAdapter() {
|
||||
setHasStableIds(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PasswordRequirementViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.password_requirement_item, parent, false);
|
||||
return new PasswordRequirementViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mRequirements.length;
|
||||
}
|
||||
|
||||
public void setRequirements(String[] requirements) {
|
||||
mRequirements = requirements;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return mRequirements[position].hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PasswordRequirementViewHolder holder, int position) {
|
||||
holder.mDescriptionText.setText(mRequirements[position]);
|
||||
}
|
||||
|
||||
public static class PasswordRequirementViewHolder extends RecyclerView.ViewHolder {
|
||||
private TextView mDescriptionText;
|
||||
|
||||
public PasswordRequirementViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mDescriptionText = (TextView) itemView;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user