mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-20 12:02:16 +02:00
Merge pull request #3949 from timrae/small-changes
Small tweaks to the GUI
This commit is contained in:
commit
e9fda282f0
@ -1276,13 +1276,20 @@ public class DeckPicker extends NavigationDrawerActivity implements
|
||||
public void onPreExecute() {
|
||||
countUp = 0;
|
||||
countDown = 0;
|
||||
// Store the current time so that we don't bother the user with a sync prompt for another 10 minutes
|
||||
// Note: getLs() in Libanki doesn't take into account the case when no changes were found, or sync cancelled
|
||||
SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext());
|
||||
final long syncStartTime = System.currentTimeMillis();
|
||||
preferences.edit().putLong("lastSyncTime", syncStartTime).apply();
|
||||
|
||||
if (mProgressDialog == null || !mProgressDialog.isShowing()) {
|
||||
mProgressDialog = StyledProgressDialog
|
||||
.show(DeckPicker.this, getResources().getString(R.string.sync_title),
|
||||
getResources().getString(R.string.sync_title) + "\n"
|
||||
+ getResources().getString(R.string.sync_up_down_size, countUp, countDown),
|
||||
false);
|
||||
// Override the back key so that the user has to confirm before a sync is actually cancelled
|
||||
|
||||
// Override the back key so that the user can cancel a sync which is in progress
|
||||
mProgressDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||
@ -1290,9 +1297,15 @@ public class DeckPicker extends NavigationDrawerActivity implements
|
||||
if (event.getAction()!=KeyEvent.ACTION_DOWN) {
|
||||
return true;
|
||||
}
|
||||
// Show confirmation dialog
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && Connection.isCancellable() &&
|
||||
!Connection.getIsCancelled()) {
|
||||
// If less than 2s has elapsed since sync started then don't ask for confirmation
|
||||
if (System.currentTimeMillis() - syncStartTime < 2000) {
|
||||
Connection.cancel();
|
||||
return true;
|
||||
}
|
||||
// Show confirmation dialog to check if the user wants to cancel the sync
|
||||
MaterialDialog.Builder builder = new MaterialDialog.Builder(mProgressDialog.getContext());
|
||||
builder.content(R.string.cancel_sync_confirm)
|
||||
.cancelable(false)
|
||||
@ -1500,14 +1513,6 @@ public class DeckPicker extends NavigationDrawerActivity implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Write the time last sync was carried out. Useful for automatic sync interval.
|
||||
// Turns out getLs() query will get the same old value if the last sync didn't find any changes, thus is
|
||||
// unsuitable.
|
||||
SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext());
|
||||
Editor editor = preferences.edit();
|
||||
editor.putLong("lastSyncTime", System.currentTimeMillis());
|
||||
editor.commit();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -63,6 +63,8 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="48dp"
|
||||
android:minWidth="70dp"
|
||||
android:gravity="right"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true" >
|
||||
<TextView
|
||||
|
@ -195,7 +195,10 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:minLines="2"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center"/>
|
||||
android:gravity="center"
|
||||
android:paddingLeft="2dp"
|
||||
android:paddingRight="2dp"
|
||||
android:paddingBottom="8dp"/>
|
||||
<Button
|
||||
android:id="@+id/studyoptions_start"
|
||||
android:background="@color/fab_normal"
|
||||
|
Loading…
Reference in New Issue
Block a user