Fix the animator duration the easy and consistent way
This commit is contained in:
parent
d09cc06ee6
commit
159c28dd0d
2 changed files with 1 additions and 50 deletions
|
@ -29,13 +29,11 @@ import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
|
@ -63,7 +61,6 @@ import com.google.zxing.integration.android.IntentIntegrator;
|
||||||
|
|
||||||
import org.shadowice.flocke.andotp.ItemTouchHelper.SimpleItemTouchHelperCallback;
|
import org.shadowice.flocke.andotp.ItemTouchHelper.SimpleItemTouchHelperCallback;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
@ -238,40 +235,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to fix the animation scale
|
|
||||||
private float fixAnimationScale() {
|
|
||||||
float durationScale = Settings.Global.getFloat(this.getContentResolver(), Settings.Global.ANIMATOR_DURATION_SCALE, 0);
|
|
||||||
|
|
||||||
if (durationScale != 1) {
|
|
||||||
try {
|
|
||||||
Class c = Class.forName("android.animation.ValueAnimator");
|
|
||||||
Method m = c.getMethod("setDurationScale", new Class[]{float.class});
|
|
||||||
m.invoke(null, new Object[]{ 1f });
|
|
||||||
durationScale = 1f;
|
|
||||||
} catch (Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
if (!prefs.getBoolean(getString(R.string.pref_animator_warning_displayed), false)) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
||||||
builder.setTitle(R.string.title_animator_duration)
|
|
||||||
.setMessage(R.string.msg_animator_duration_scale)
|
|
||||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {}
|
|
||||||
})
|
|
||||||
.create()
|
|
||||||
.show();
|
|
||||||
|
|
||||||
prefs.edit().putBoolean(getString(R.string.pref_animator_warning_displayed), true).apply();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return durationScale;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize the main application
|
// Initialize the main application
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -307,7 +270,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
ItemTouchHelper touchHelper = new ItemTouchHelper(touchHelperCallback);
|
ItemTouchHelper touchHelper = new ItemTouchHelper(touchHelperCallback);
|
||||||
touchHelper.attachToRecyclerView(recList);
|
touchHelper.attachToRecyclerView(recList);
|
||||||
|
|
||||||
final float durationScale = fixAnimationScale();
|
float durationScale = Settings.Global.getFloat(this.getContentResolver(), Settings.Global.ANIMATOR_DURATION_SCALE, 0);
|
||||||
final long animatorDuration = (long) (1000 / durationScale);
|
final long animatorDuration = (long) (1000 / durationScale);
|
||||||
|
|
||||||
adapter.setMoveEventCallback(new EntriesCardAdapter.ViewHolderEventCallback() {
|
adapter.setMoveEventCallback(new EntriesCardAdapter.ViewHolderEventCallback() {
|
||||||
|
|
|
@ -17,15 +17,6 @@
|
||||||
<string name="menu_import">Import (JSON)</string>
|
<string name="menu_import">Import (JSON)</string>
|
||||||
<string name="menu_submenu_backup">Import / Export</string>
|
<string name="menu_submenu_backup">Import / Export</string>
|
||||||
|
|
||||||
<string name="msg_animator_duration_scale">Your devices <b>Animator duration scale</b> seems to
|
|
||||||
be set to something other than the default (<i>1.0x</i>), which will result in a not very
|
|
||||||
smooth animation of the countdown bar.
|
|
||||||
\n\nandOTP tried to apply an automatic fix to itself, but something went wrong with that.
|
|
||||||
Now it will try to compensate manually during the animation. In the case that does not work
|
|
||||||
you can either live with the jumpy countdown bar or change your devices <b>Animator duration
|
|
||||||
scale</b> in the <b>Developer options</b>.
|
|
||||||
\n\n<b>This message will not be shown again!</b>
|
|
||||||
</string>
|
|
||||||
<string name="msg_camera_permission">Camera permission not granted</string>
|
<string name="msg_camera_permission">Camera permission not granted</string>
|
||||||
<string name="msg_confirm_delete">Are you sure you want do remove this account?</string>
|
<string name="msg_confirm_delete">Are you sure you want do remove this account?</string>
|
||||||
<string name="msg_copied_to_clipboard">Copied to clipboard</string>
|
<string name="msg_copied_to_clipboard">Copied to clipboard</string>
|
||||||
|
@ -41,11 +32,8 @@
|
||||||
<string name="msg_storage_not_accessible">External storage currently not accessible</string>
|
<string name="msg_storage_not_accessible">External storage currently not accessible</string>
|
||||||
<string name="msg_storage_permissions">Storage permissions not granted</string>
|
<string name="msg_storage_permissions">Storage permissions not granted</string>
|
||||||
|
|
||||||
<string name="title_animator_duration">Animator duration scale</string>
|
|
||||||
<string name="title_search">Search</string>
|
<string name="title_search">Search</string>
|
||||||
|
|
||||||
<string name="pref_animator_warning_displayed">animator_warning_displayed</string>
|
|
||||||
|
|
||||||
<!-- About dialog -->
|
<!-- About dialog -->
|
||||||
<string name="about_description">
|
<string name="about_description">
|
||||||
An open-source two-factor authentication App for Android 4.4+.
|
An open-source two-factor authentication App for Android 4.4+.
|
||||||
|
|
Loading…
Reference in a new issue