use of org.shadowice.flocke.andotp.View.TagsAdapter in project andOTP by andOTP.
the class MainActivity method onCreate.
// Initialize the main application
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.app_name);
if (!settings.getScreenshotsEnabled())
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
settings.registerPreferenceChangeListener(this);
encryptionType = settings.getEncryption();
if (settings.getAuthMethod() != AuthMethod.NONE && savedInstanceState == null)
requireAuthentication = true;
setBroadcastCallback(new BroadcastReceivedCallback() {
@Override
public void onReceivedScreenOff() {
if (settings.getRelockOnScreenOff() && settings.getAuthMethod() != AuthMethod.NONE)
requireAuthentication = true;
}
});
if (!settings.getFirstTimeWarningShown()) {
showFirstTimeWarning();
}
fabsMenu = findViewById(R.id.fabs_menu);
TitleFAB qrFAB = findViewById(R.id.fab_qr_scan);
qrFAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
fabsMenu.collapse();
scanQRCode();
}
});
TitleFAB manualFAB = findViewById(R.id.fab_manual_entry);
manualFAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
fabsMenu.collapse();
ManualEntryDialog.show(MainActivity.this, settings, adapter);
}
});
final ProgressBar progressBar = findViewById(R.id.progressBar);
RecyclerView recList = findViewById(R.id.cardList);
recList.setHasFixedSize(true);
LinearLayoutManager llm = new LinearLayoutManager(this);
llm.setOrientation(LinearLayoutManager.VERTICAL);
recList.setLayoutManager(llm);
tagsDrawerAdapter = new TagsAdapter(this, new HashMap<String, Boolean>());
adapter = new EntriesCardAdapter(this, tagsDrawerAdapter);
recList.setAdapter(adapter);
touchHelperCallback = new SimpleItemTouchHelperCallback(adapter);
ItemTouchHelper touchHelper = new ItemTouchHelper(touchHelperCallback);
touchHelper.attachToRecyclerView(recList);
NotificationHelper.initializeNotificationChannels(this);
restoreSortMode();
float durationScale = android.provider.Settings.Global.getFloat(this.getContentResolver(), android.provider.Settings.Global.ANIMATOR_DURATION_SCALE, 0);
if (durationScale == 0)
durationScale = 1;
final long animatorDuration = (long) (1000 / durationScale);
adapter.setCallback(new EntriesCardAdapter.Callback() {
@Override
public void onMoveEventStart() {
stopUpdater();
}
@Override
public void onMoveEventStop() {
startUpdater();
}
});
handler = new Handler();
handlerTask = new Runnable() {
@Override
public void run() {
int progress = (int) (TokenCalculator.TOTP_DEFAULT_PERIOD - (System.currentTimeMillis() / 1000) % TokenCalculator.TOTP_DEFAULT_PERIOD);
progressBar.setProgress(progress * 100);
ObjectAnimator animation = ObjectAnimator.ofInt(progressBar, "progress", (progress - 1) * 100);
animation.setDuration(animatorDuration);
animation.setInterpolator(new LinearInterpolator());
animation.start();
adapter.updateTokens();
handler.postDelayed(this, 1000);
}
};
setupDrawer();
}
Aggregations