Reduce auto-save aggressiveness
This commit is contained in:
parent
2453207d20
commit
315c186db1
1 changed files with 12 additions and 10 deletions
|
@ -45,6 +45,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
@BindView(R.id.layout_tab)
|
@BindView(R.id.layout_tab)
|
||||||
TabLayout tabLayout;
|
TabLayout tabLayout;
|
||||||
|
|
||||||
|
private boolean shouldAutoSave = true;
|
||||||
private NewFileHandler newFileHandler;
|
private NewFileHandler newFileHandler;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -70,9 +71,9 @@ public class MainActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onUserLeaveHint() {
|
||||||
super.onPause();
|
super.onUserLeaveHint();
|
||||||
if (!presenter.getMarkdown().isEmpty() && Utils.isAutosaveEnabled(this)) {
|
if (shouldAutoSave && !presenter.getMarkdown().isEmpty() && Utils.isAutosaveEnabled(this)) {
|
||||||
presenter.saveMarkdown(null, null);
|
presenter.saveMarkdown(null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,6 +231,8 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
private void requestFileOp(int requestType) {
|
private void requestFileOp(int requestType) {
|
||||||
if (Utils.canAccessFiles(MainActivity.this)) {
|
if (Utils.canAccessFiles(MainActivity.this)) {
|
||||||
|
// If the user is going to save the file, we don't want to auto-save it for them
|
||||||
|
shouldAutoSave = false;
|
||||||
Intent intent = new Intent(MainActivity.this, ExplorerActivity.class);
|
Intent intent = new Intent(MainActivity.this, ExplorerActivity.class);
|
||||||
intent.putExtra(Constants.EXTRA_REQUEST_CODE, requestType);
|
intent.putExtra(Constants.EXTRA_REQUEST_CODE, requestType);
|
||||||
intent.putExtra(Constants.EXTRA_FILE, presenter.getFile());
|
intent.putExtra(Constants.EXTRA_FILE, presenter.getFile());
|
||||||
|
@ -237,13 +240,11 @@ public class MainActivity extends AppCompatActivity
|
||||||
intent,
|
intent,
|
||||||
requestType
|
requestType
|
||||||
);
|
);
|
||||||
} else {
|
} else if (Build.VERSION.SDK_INT >= 23) {
|
||||||
if (Build.VERSION.SDK_INT >= 23) {
|
requestPermissions(
|
||||||
requestPermissions(
|
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||||
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
requestType
|
||||||
requestType
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,6 +252,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
setTitle(presenter.getFileName());
|
setTitle(presenter.getFileName());
|
||||||
|
shouldAutoSave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NewFileHandler implements MarkdownPresenter.MarkdownSavedListener {
|
private class NewFileHandler implements MarkdownPresenter.MarkdownSavedListener {
|
||||||
|
|
Loading…
Reference in a new issue