Use progress circle
This commit is contained in:
parent
94a8994d40
commit
1049b4e48a
@ -142,7 +142,8 @@ public class GroupFragment extends NamedFragment {
|
||||
|
||||
if(vh.getOTPData().getType() == OTPType.TOTP) {
|
||||
long timeDiff = vh.getOTPData().getNextDueTime() - System.currentTimeMillis() / 1000;
|
||||
vh.getBinding().progress.setProgress((int) ((1 - ((double) timeDiff / vh.getOTPData().getPeriod())) * 100));
|
||||
double progress = 1 - ((double) timeDiff / vh.getOTPData().getPeriod());
|
||||
vh.getBinding().progress.setImageLevel((int) (progress * 10_000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class OTPListAdapter extends RecyclerView.Adapter<OTPListItem> {
|
||||
|
||||
holder.setOTPData(data);
|
||||
holder.getBinding().label.setText(String.format("%s%s", data.getIssuer() == null || data.getIssuer().isEmpty() ? "" : data.getIssuer() + ": ", data.getName()));
|
||||
holder.getBinding().progress.setVisibility(data.getType() == OTPType.TOTP ? View.VISIBLE : View.GONE);
|
||||
holder.getBinding().progress.setVisibility(data.getType() == OTPType.TOTP ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
holder.getBinding().getRoot().setOnClickListener(view -> {
|
||||
if(data.getType() != OTPType.HOTP) return;
|
||||
|
@ -127,6 +127,7 @@ public class DialogUtil {
|
||||
binding.inputDigits.setEnabled(!view);
|
||||
|
||||
binding.inputName.setEnabled(!view);
|
||||
binding.inputIssuer.setEnabled(!view);
|
||||
binding.inputSecret.setEnabled(!view);
|
||||
binding.inputCounter.setEnabled(!view);
|
||||
binding.inputChecksum.setEnabled(!view);
|
||||
@ -180,6 +181,7 @@ public class DialogUtil {
|
||||
}
|
||||
|
||||
public static void showViewCodeDialog(LayoutInflater inflater, @NonNull OTPData initialData, Runnable back) {
|
||||
// TODO: use better dialogs
|
||||
switch(initialData.getType()) {
|
||||
case HOTP: showHOTPDialog(inflater, initialData, d -> {}, back, true); break;
|
||||
case TOTP: showTOTPDialog(inflater, initialData, d -> {}, back, true); break;
|
||||
|
18
app/src/main/res/drawable/progress_circle.xml
Normal file
18
app/src/main/res/drawable/progress_circle.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:fromDegrees="270"
|
||||
android:toDegrees="270">
|
||||
<shape
|
||||
android:shape="ring"
|
||||
android:innerRadius="0dp"
|
||||
android:thickness="10dp"
|
||||
android:useLevel="true">
|
||||
|
||||
<gradient
|
||||
android:angle="0"
|
||||
android:endColor="?attr/colorTheme1"
|
||||
android:startColor="?attr/colorTheme1"
|
||||
android:type="sweep"
|
||||
android:useLevel="false" />
|
||||
</shape>
|
||||
</rotate>
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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="wrap_content"
|
||||
android:orientation="vertical"
|
||||
@ -14,19 +15,32 @@
|
||||
android:textAlignment="center"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/otpCode"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="000000"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp" />
|
||||
android:gravity="center"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginStart="10dp">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:max="100" />
|
||||
<Space
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/otpCode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="000000"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/progress"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
app:srcCompat="@drawable/progress_circle" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user