mirror of
https://github.com/beemdevelopment/Aegis
synced 2024-09-06 16:03:30 +00:00
Remove unused SlotAdapter and SlotHolder
This commit is contained in:
parent
86b86fef10
commit
f7b4cceb81
|
@ -1,72 +0,0 @@
|
|||
package com.beemdevelopment.aegis.ui.views;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.beemdevelopment.aegis.R;
|
||||
import com.beemdevelopment.aegis.vault.slots.Slot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class SlotAdapter extends RecyclerView.Adapter<SlotHolder> {
|
||||
private Listener _listener;
|
||||
private ArrayList<Slot> _slots;
|
||||
|
||||
public SlotAdapter(Listener listener) {
|
||||
_listener = listener;
|
||||
_slots = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addSlot(Slot slot) {
|
||||
_slots.add(slot);
|
||||
|
||||
int position = getItemCount() - 1;
|
||||
if (position == 0) {
|
||||
notifyDataSetChanged();
|
||||
} else {
|
||||
notifyItemInserted(position);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSlot(Slot slot) {
|
||||
notifyItemChanged(_slots.indexOf(slot));
|
||||
}
|
||||
|
||||
public void removeSlot(Slot slot) {
|
||||
int position = _slots.indexOf(slot);
|
||||
_slots.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SlotHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_slot, parent, false);
|
||||
return new SlotHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(SlotHolder holder, int position) {
|
||||
holder.setData(_slots.get(position));
|
||||
holder.setOnEditClickListener(v -> {
|
||||
int position1 = holder.getAdapterPosition();
|
||||
_listener.onEditSlot(_slots.get(position1));
|
||||
});
|
||||
holder.setOnDeleteClickListener(v -> {
|
||||
int position12 = holder.getAdapterPosition();
|
||||
_listener.onRemoveSlot(_slots.get(position12));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return _slots.size();
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
void onEditSlot(Slot slot);
|
||||
void onRemoveSlot(Slot slot);
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package com.beemdevelopment.aegis.ui.views;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.beemdevelopment.aegis.R;
|
||||
import com.beemdevelopment.aegis.crypto.KeyStoreHandle;
|
||||
import com.beemdevelopment.aegis.crypto.KeyStoreHandleException;
|
||||
import com.beemdevelopment.aegis.vault.slots.BiometricSlot;
|
||||
import com.beemdevelopment.aegis.vault.slots.PasswordSlot;
|
||||
import com.beemdevelopment.aegis.vault.slots.RawSlot;
|
||||
import com.beemdevelopment.aegis.vault.slots.Slot;
|
||||
import com.beemdevelopment.aegis.helpers.BiometricsHelper;
|
||||
|
||||
public class SlotHolder extends RecyclerView.ViewHolder {
|
||||
private TextView _slotUsed;
|
||||
private TextView _slotName;
|
||||
private ImageView _slotImg;
|
||||
private LinearLayout _buttonEdit;
|
||||
private ImageView _buttonDelete;
|
||||
|
||||
public SlotHolder(final View view) {
|
||||
super(view);
|
||||
_slotUsed = view.findViewById(R.id.text_slot_used);
|
||||
_slotName = view.findViewById(R.id.text_slot_name);
|
||||
_slotImg = view.findViewById(R.id.img_slot);
|
||||
_buttonEdit = view.findViewById(R.id.button_edit);
|
||||
_buttonDelete = view.findViewById(R.id.button_delete);
|
||||
}
|
||||
|
||||
public void setData(Slot slot) {
|
||||
if (slot instanceof PasswordSlot) {
|
||||
_slotName.setText(R.string.password);
|
||||
_slotImg.setImageResource(R.drawable.ic_create_black_24dp);
|
||||
} else if (slot instanceof BiometricSlot) {
|
||||
_slotName.setText(R.string.authentication_method_biometrics);
|
||||
_slotImg.setImageResource(R.drawable.ic_fingerprint_black_24dp);
|
||||
if (BiometricsHelper.isAvailable(itemView.getContext())) {
|
||||
try {
|
||||
KeyStoreHandle keyStore = new KeyStoreHandle();
|
||||
if (keyStore.containsKey(slot.getUUID().toString())) {
|
||||
_slotUsed.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} catch (KeyStoreHandleException e) { }
|
||||
}
|
||||
} else if (slot instanceof RawSlot) {
|
||||
_slotName.setText(R.string.authentication_method_raw);
|
||||
_slotImg.setImageResource(R.drawable.ic_vpn_key_black_24dp);
|
||||
} else {
|
||||
throw new RuntimeException(String.format("Unsupported Slot type: %s", slot.getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnEditClickListener(View.OnClickListener listener) {
|
||||
_buttonEdit.setOnClickListener(listener);
|
||||
}
|
||||
|
||||
public void setOnDeleteClickListener(View.OnClickListener listener) {
|
||||
_buttonDelete.setOnClickListener(listener);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue