Added progressbars to keys

pull/41/head
Michael Schättgen 9 years ago
parent 9112c16235
commit 1b12dfc3e0

@ -1,11 +1,14 @@
package me.impy.aegis;
import android.animation.ObjectAnimator;
import android.os.CountDownTimer;
import android.os.Handler;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.amulyakhare.textdrawable.TextDrawable;
@ -53,12 +56,17 @@ public class KeyProfileAdapter extends RecyclerView.Adapter<KeyProfileAdapter.Ke
TextView profileCode;
ImageView profileDrawable;
KeyProfile keyProfile;
ProgressBar progressBar;
CountDownTimer mCountDownTimer;
int i = 0;
KeyProfileHolder(final View itemView) {
super(itemView);
profileName = (TextView) itemView.findViewById(R.id.profile_name);
profileCode = (TextView) itemView.findViewById(R.id.profile_code);
profileDrawable = (ImageView) itemView.findViewById(R.id.ivTextDrawable);
progressBar = (ProgressBar) itemView.findViewById(R.id.progressBar);
}
public void setData(KeyProfile profile) {
@ -81,6 +89,30 @@ public class KeyProfileAdapter extends RecyclerView.Adapter<KeyProfileAdapter.Ke
this.keyProfile.Code = otp;
profileCode.setText(otp.substring(0, 3) + " " + otp.substring(3));
i = Math.round((float)keyProfile.Info.getMillisTillNextRotation() / (float)((keyProfile.Info.getPeriod() * 1000)) * 100);
if(i == 100)
{
i = 0;
}
progressBar.setProgress(i);
mCountDownTimer = new CountDownTimer(keyProfile.Info.getMillisTillNextRotation(), (keyProfile.Info.getPeriod() * 1000 / 100)) {
@Override
public void onTick(long millisUntilFinished) {
i++;
progressBar.setProgress(i);
}
@Override
public void onFinish() {
//Do what you want
i = 0;
progressBar.setProgress(i);
}
};
mCountDownTimer.start();
}
private TextDrawable generateTextDrawable(KeyProfile profile)

@ -1,16 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:background="@color/background"
android:layout_height="match_parent">
<RelativeLayout
@ -68,4 +69,19 @@
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:padding="0dp"
android:layout_margin="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="4dp"
android:id="@+id/progressBar"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>

@ -6,7 +6,7 @@
<color name="colorPrimaryLight">#B3E5FC</color>
<color name="colorAccent">#FF5252</color>
<color name="primary_text">#212121</color>
<color name="secondary_text">#434343</color>
<color name="secondary_text">#FF5252</color>
<color name="primary_text_inverted">#ffffff</color>
<color name="secondary_text_inverted">#efefef</color>
<color name="icons">#FFFFFF</color>

@ -27,9 +27,9 @@
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
<style name="EditTextTintTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<!--<item name="colorAccent">@color/</item>-->

Loading…
Cancel
Save