Improve the progress bar

This commit is contained in:
Jakob Nixdorf 2017-06-29 17:10:18 +02:00
parent 3a42bbfba4
commit 0118279b4d
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC
4 changed files with 21 additions and 17 deletions

View file

@ -35,6 +35,14 @@ goes to Bruno.
--> -->
## Acknowledgments:
* [Apache Commons Code](https://commons.apache.org/proper/commons-codec/)
* [Code Parts from Google's Android Samples](https://android.googlesource.com/platform/development/+/master/samples/Vault/src/com/example/android/vault)
* [MaterialProgressBar](https://github.com/DreaminginCodeZH/MaterialProgressBar)
* [ZXing](https://github.com/zxing/zxing)
* [ZXing Android Embedded](https://github.com/journeyapps/zxing-android-embedded)
## License: ## License:
``` ```
Copyright (C) 2017 Jakob Nixdorf <flocke@shadowice.org> Copyright (C) 2017 Jakob Nixdorf <flocke@shadowice.org>

View file

@ -37,6 +37,7 @@ dependencies {
compile 'com.journeyapps:zxing-android-embedded:3.0.3@aar' compile 'com.journeyapps:zxing-android-embedded:3.0.3@aar'
compile 'com.google.zxing:core:3.2.1' compile 'com.google.zxing:core:3.2.1'
compile 'commons-codec:commons-codec:1.5' compile 'commons-codec:commons-codec:1.5'
compile 'me.zhanghai.android.materialprogressbar:library:1.4.1'
androidTestCompile 'com.android.support:support-annotations:25.3.1' androidTestCompile 'com.android.support:support-annotations:25.3.1'
androidTestCompile 'com.android.support.test:runner:0.5' androidTestCompile 'com.android.support.test:runner:0.5'

View file

@ -177,10 +177,10 @@ public class MainActivity extends AppCompatActivity {
{ {
@Override @Override
public void run() { public void run() {
int progress = (int) (System.currentTimeMillis() / 1000) % 30 ; int progress = (int) (TOTPHelper.TOTP_DEFAULT_PERIOD - (System.currentTimeMillis() / 1000) % TOTPHelper.TOTP_DEFAULT_PERIOD) ;
progressBar.setProgress(progress*100); progressBar.setProgress(progress*100);
ObjectAnimator animation = ObjectAnimator.ofInt(progressBar, "progress", (progress+1)*100); ObjectAnimator animation = ObjectAnimator.ofInt(progressBar, "progress", (progress-1)*100);
animation.setDuration(1000); animation.setDuration(1000);
animation.setInterpolator(new LinearInterpolator()); animation.setInterpolator(new LinearInterpolator());
animation.start(); animation.start();

View file

@ -26,25 +26,20 @@
android:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" /> app:popupTheme="@style/AppTheme.PopupOverlay" />
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/progressBar" android:id="@+id/progressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/toolbar"
android:max="3000" android:max="3000"
android:progress="1500" android:progress="1500"
android:layout_alignBottom="@id/toolbar" app:mpb_progressStyle="horizontal"
app:mpb_useIntrinsicPadding="false"
/> app:mpb_showProgressBackground="false"
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal.NoPadding" />
</RelativeLayout> </RelativeLayout>
</android.support.design.widget.AppBarLayout> </android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" /> <include layout="@layout/content_main" />
@ -55,6 +50,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_add_white"></android.support.design.widget.FloatingActionButton> android:src="@drawable/ic_add_white" />
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>