use of com.ichi2.anki.exception.ConfirmModSchemaException in project Anki-Android by ankidroid.
the class SchedTest method getColV1.
/**
***************
** autogenerated from https://github.com/ankitects/anki/blob/2c73dcb2e547c44d9e02c20a00f3c52419dc277b/pylib/tests/test_cards.py*
****************
*/
private Collection getColV1() throws ConfirmModSchemaException {
Collection col = getCol();
col.changeSchedulerVer(1);
return col;
}
use of com.ichi2.anki.exception.ConfirmModSchemaException in project Anki-Android by ankidroid.
the class DeckPicker method onFinishedStartup.
/**
* Perform the following tasks:
* Automatic backup
* loadStudyOptionsFragment() if tablet
* Automatic sync
*/
private void onFinishedStartup() {
// create backup in background if needed
BackupManager.performBackupInBackground(getCol().getPath(), getCol().getTime());
// Force a full sync if flag was set in upgrade path, asking the user to confirm if necessary
if (mRecommendFullSync) {
mRecommendFullSync = false;
try {
getCol().modSchema();
} catch (ConfirmModSchemaException e) {
Timber.w("Forcing full sync");
e.log();
// If libanki determines it's necessary to confirm the full sync then show a confirmation dialog
// We have to show the dialog via the DialogHandler since this method is called via an async task
Resources res = getResources();
Message handlerMessage = Message.obtain();
handlerMessage.what = DialogHandler.MSG_SHOW_FORCE_FULL_SYNC_DIALOG;
Bundle handlerMessageData = new Bundle();
handlerMessageData.putString("message", res.getString(R.string.full_sync_confirmation_upgrade) + "\n\n" + res.getString(R.string.full_sync_confirmation));
handlerMessage.setData(handlerMessageData);
getDialogHandler().sendMessage(handlerMessage);
}
}
automaticSync();
}
use of com.ichi2.anki.exception.ConfirmModSchemaException in project Anki-Android by ankidroid.
the class ModelFieldEditor method addFieldDialog.
/*
* Creates a dialog to create a field
*/
private void addFieldDialog() {
mFieldNameInput = new FixedEditText(this);
mFieldNameInput.setSingleLine(true);
new MaterialEditTextDialog.Builder(this, mFieldNameInput).title(R.string.model_field_editor_add).positiveText(R.string.dialog_ok).onPositive((dialog, which) -> {
// Name is valid, now field is added
changeHandler listener = changeFieldHandler();
String fieldName = _uniqueName(mFieldNameInput);
try {
addField(fieldName, listener, true);
} catch (ConfirmModSchemaException e) {
e.log();
// Create dialogue to for schema change
ConfirmationDialog c = new ConfirmationDialog();
c.setArgs(getResources().getString(R.string.full_sync_confirmation));
Runnable confirm = () -> {
try {
addField(fieldName, listener, false);
} catch (ConfirmModSchemaException e1) {
e1.log();
// This should never be thrown
}
dismissContextMenu();
};
c.setConfirm(confirm);
c.setCancel(mConfirmDialogCancel);
ModelFieldEditor.this.showDialogFragment(c);
}
mCol.getModels().update(mMod);
fullRefreshList();
}).negativeText(R.string.dialog_cancel).show();
}
use of com.ichi2.anki.exception.ConfirmModSchemaException in project Anki-Android by ankidroid.
the class ModelFieldEditor method renameFieldDialog.
/*
* Creates a dialog to rename the currently selected field
* Processing time is constant
*/
private void renameFieldDialog() {
mFieldNameInput = new FixedEditText(this);
mFieldNameInput.setSingleLine(true);
mFieldNameInput.setText(mFieldLabels.get(mCurrentPos));
mFieldNameInput.setSelection(mFieldNameInput.getText().length());
new MaterialEditTextDialog.Builder(this, mFieldNameInput).title(R.string.model_field_editor_rename).positiveText(R.string.rename).onPositive((dialog, which) -> {
String fieldName = _uniqueName(mFieldNameInput);
if (fieldName == null) {
return;
}
// Field is valid, now rename
try {
renameField();
} catch (ConfirmModSchemaException e) {
e.log();
// Handler mod schema confirmation
ConfirmationDialog c = new ConfirmationDialog();
c.setArgs(getResources().getString(R.string.full_sync_confirmation));
Runnable confirm = () -> {
mCol.modSchemaNoCheck();
try {
renameField();
} catch (ConfirmModSchemaException e1) {
e1.log();
// This should never be thrown
}
dismissContextMenu();
};
c.setConfirm(confirm);
c.setCancel(mConfirmDialogCancel);
ModelFieldEditor.this.showDialogFragment(c);
}
}).negativeText(R.string.dialog_cancel).show();
}
use of com.ichi2.anki.exception.ConfirmModSchemaException in project Anki-Android by ankidroid.
the class ModelFieldEditor method deleteFieldDialog.
/*
* Creates a dialog to delete the currently selected field
*/
private void deleteFieldDialog() {
Runnable confirm = () -> {
mCol.modSchemaNoCheck();
deleteField();
dismissContextMenu();
};
if (mFieldLabels.size() < 2) {
UIUtils.showThemedToast(this, getResources().getString(R.string.toast_last_field), true);
} else {
try {
mCol.modSchema();
ConfirmationDialog d = new ConfirmationDialog();
d.setArgs(getResources().getString(R.string.field_delete_warning));
d.setConfirm(confirm);
d.setCancel(mConfirmDialogCancel);
showDialogFragment(d);
} catch (ConfirmModSchemaException e) {
e.log();
ConfirmationDialog c = new ConfirmationDialog();
c.setConfirm(confirm);
c.setCancel(mConfirmDialogCancel);
c.setArgs(getResources().getString(R.string.full_sync_confirmation));
showDialogFragment(c);
}
}
}
Aggregations