pause animation code on background, change no account added string
This commit is contained in:
parent
ce59e605ba
commit
332f539e87
4 changed files with 33 additions and 27 deletions
|
@ -87,7 +87,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
|
||||||
|
|
||||||
public void test000EmptyStart() throws InterruptedException {
|
public void test000EmptyStart() throws InterruptedException {
|
||||||
|
|
||||||
onView(withText("No Account has been added yet")).check(matches(isDisplayed()));
|
onView(withText("No account has been added yet")).check(matches(isDisplayed()));
|
||||||
onView(withText("Add")).check(matches(isDisplayed()));
|
onView(withText("Add")).check(matches(isDisplayed()));
|
||||||
|
|
||||||
Intents.init();
|
Intents.init();
|
||||||
|
@ -139,7 +139,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
|
||||||
|
|
||||||
|
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
onView(withText("No Account has been added yet")).check(matches(isDisplayed()));
|
onView(withText("No account has been added yet")).check(matches(isDisplayed()));
|
||||||
|
|
||||||
Intents.release();
|
Intents.release();
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
|
||||||
// We can also validate that an intent resolving to the "camera" activity has been sent out by our app
|
// We can also validate that an intent resolving to the "camera" activity has been sent out by our app
|
||||||
intended(hasAction("com.google.zxing.client.android.SCAN"));
|
intended(hasAction("com.google.zxing.client.android.SCAN"));
|
||||||
|
|
||||||
onView(withText("No Account has been added yet")).check(matches(isDisplayed()));
|
onView(withText("No account has been added yet")).check(matches(isDisplayed()));
|
||||||
|
|
||||||
Intents.release();
|
Intents.release();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.ActionMode;
|
import android.view.ActionMode;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
@ -36,6 +37,9 @@ public class MainActivity extends AppCompatActivity implements ActionMode.Callb
|
||||||
private EntriesAdapter adapter;
|
private EntriesAdapter adapter;
|
||||||
private FloatingActionButton fab;
|
private FloatingActionButton fab;
|
||||||
|
|
||||||
|
private Handler handler;
|
||||||
|
private Runnable handlerTask;
|
||||||
|
|
||||||
private Entry nextSelection = null;
|
private Entry nextSelection = null;
|
||||||
private void showNoAccount(){
|
private void showNoAccount(){
|
||||||
Snackbar noAccountSnackbar = Snackbar.make(fab, R.string.no_accounts, Snackbar.LENGTH_INDEFINITE)
|
Snackbar noAccountSnackbar = Snackbar.make(fab, R.string.no_accounts, Snackbar.LENGTH_INDEFINITE)
|
||||||
|
@ -96,30 +100,18 @@ public class MainActivity extends AppCompatActivity implements ActionMode.Callb
|
||||||
showNoAccount();
|
showNoAccount();
|
||||||
}
|
}
|
||||||
|
|
||||||
int progress = ((int) (System.currentTimeMillis() / 1000) % 30);
|
handler = new Handler();
|
||||||
progressBar.setProgress((int) (1000.0 * progress / 30.0));
|
handlerTask = new Runnable()
|
||||||
|
|
||||||
ObjectAnimator animation = ObjectAnimator.ofInt(progressBar, "progress", 1000);
|
|
||||||
animation.setDuration((30 - progress) * 1000);
|
|
||||||
animation.setInterpolator(new LinearInterpolator());
|
|
||||||
animation.start();
|
|
||||||
|
|
||||||
|
|
||||||
final Handler handler = new Handler();
|
|
||||||
final Runnable handlerTask = new Runnable()
|
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
int progress = (int) (System.currentTimeMillis() / 1000) % 30 ;
|
int progress = (int) (System.currentTimeMillis() / 1000) % 30 ;
|
||||||
|
progressBar.setProgress(progress*100);
|
||||||
|
|
||||||
if(progress == 0){
|
ObjectAnimator animation = ObjectAnimator.ofInt(progressBar, "progress", (progress+1)*100);
|
||||||
progressBar.setProgress(progress);
|
animation.setDuration(1000);
|
||||||
|
|
||||||
ObjectAnimator animation = ObjectAnimator.ofInt(progressBar, "progress", 1000);
|
|
||||||
animation.setDuration(30 * 1000);
|
|
||||||
animation.setInterpolator(new LinearInterpolator());
|
animation.setInterpolator(new LinearInterpolator());
|
||||||
animation.start();
|
animation.start();
|
||||||
}
|
|
||||||
|
|
||||||
for(int i =0;i< adapter.getCount();i++){
|
for(int i =0;i< adapter.getCount();i++){
|
||||||
if(progress == 0 || adapter.getItem(i).getCurrentOTP() == null){
|
if(progress == 0 || adapter.getItem(i).getCurrentOTP() == null){
|
||||||
|
@ -131,7 +123,20 @@ public class MainActivity extends AppCompatActivity implements ActionMode.Callb
|
||||||
handler.postDelayed(this, 1000);
|
handler.postDelayed(this, 1000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
handlerTask.run();
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
handler.post(handlerTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
|
||||||
|
handler.removeCallbacks(handlerTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -175,6 +180,7 @@ public class MainActivity extends AppCompatActivity implements ActionMode.Callb
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
android:max="1000"
|
android:max="3000"
|
||||||
android:progress="500"
|
android:progress="1500"
|
||||||
android:layout_alignBottom="@id/toolbar"
|
android:layout_alignBottom="@id/toolbar"
|
||||||
|
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">OTP Authenticator</string>
|
<string name="app_name">OTP Authenticator</string>
|
||||||
<string name="app_launcher">Authenticator</string>
|
<string name="app_launcher">Authenticator</string>
|
||||||
<string name="no_accounts">No Account has been added yet</string>
|
<string name="no_accounts">No account has been added yet</string>
|
||||||
<string name="menu_delete">Delete</string>
|
<string name="menu_delete">Delete</string>
|
||||||
<string name="menu_edit">Edit</string>
|
<string name="menu_edit">Edit</string>
|
||||||
<string name="menu_scan">Scan QR Code</string>
|
<string name="menu_scan">Scan QR Code</string>
|
||||||
|
|
Loading…
Reference in a new issue