mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-30 00:01:19 +00:00
#200 - Cannot change folder type or pull order in wrapper UI #202 - User selections are lost if screen rotation changes during folder edit #203 - Edit folder dialog - AlertDialogs leak on screen rotation
This commit is contained in:
parent
a1fef79c2e
commit
c96786bcb9
4 changed files with 28 additions and 33 deletions
|
@ -596,17 +596,13 @@ public class DeviceActivity extends SyncthingActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showCompressionDialog(){
|
private void showCompressionDialog(){
|
||||||
mCompressionDialog = createCompressionDialog();
|
mCompressionDialog = new AlertDialog.Builder(this)
|
||||||
mCompressionDialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Dialog createCompressionDialog(){
|
|
||||||
return new AlertDialog.Builder(this)
|
|
||||||
.setTitle(R.string.compression)
|
.setTitle(R.string.compression)
|
||||||
.setSingleChoiceItems(R.array.compress_entries,
|
.setSingleChoiceItems(R.array.compress_entries,
|
||||||
Compression.fromValue(this, mDevice.compression).getIndex(),
|
Compression.fromValue(this, mDevice.compression).getIndex(),
|
||||||
mCompressionEntrySelectedListener)
|
mCompressionEntrySelectedListener)
|
||||||
.create();
|
.create();
|
||||||
|
mCompressionDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -223,10 +223,8 @@ public class FolderActivity extends SyncthingActivity
|
||||||
|
|
||||||
if (mIsCreateMode) {
|
if (mIsCreateMode) {
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mFolder = new Gson().fromJson(savedInstanceState.getString("folder"), Folder.class);
|
mFolder = new Gson().fromJson(savedInstanceState.getString("mFolder"), Folder.class);
|
||||||
if (savedInstanceState.getBoolean(IS_SHOW_DISCARD_DIALOG)){
|
mFolderUri = savedInstanceState.getParcelable("mFolderUri");
|
||||||
showDiscardDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (mFolder == null) {
|
if (mFolder == null) {
|
||||||
initFolder();
|
initFolder();
|
||||||
|
@ -244,15 +242,11 @@ public class FolderActivity extends SyncthingActivity
|
||||||
mPathView.setEnabled(false);
|
mPathView.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (savedInstanceState != null){
|
if (savedInstanceState != null) {
|
||||||
if (savedInstanceState.getBoolean(IS_SHOWING_DELETE_DIALOG)){
|
if (savedInstanceState.getBoolean(IS_SHOWING_DELETE_DIALOG)) {
|
||||||
showDeleteDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (savedInstanceState != null){
|
|
||||||
if (savedInstanceState.getBoolean(IS_SHOWING_DELETE_DIALOG)){
|
|
||||||
showDeleteDialog();
|
showDeleteDialog();
|
||||||
|
} else if (savedInstanceState.getBoolean(IS_SHOW_DISCARD_DIALOG)) {
|
||||||
|
showDiscardDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,12 +381,16 @@ public class FolderActivity extends SyncthingActivity
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
|
|
||||||
outState.putBoolean(IS_SHOWING_DELETE_DIALOG, mDeleteDialog != null && mDeleteDialog.isShowing());
|
outState.putBoolean(IS_SHOWING_DELETE_DIALOG, mDeleteDialog != null && mDeleteDialog.isShowing());
|
||||||
Util.dismissDialogSafe(mDeleteDialog, this);
|
Util.dismissDialogSafe(mDeleteDialog, this);
|
||||||
|
|
||||||
if (mIsCreateMode){
|
outState.putBoolean(IS_SHOW_DISCARD_DIALOG, mDiscardDialog != null && mDiscardDialog.isShowing());
|
||||||
outState.putBoolean(IS_SHOW_DISCARD_DIALOG, mDiscardDialog != null && mDiscardDialog.isShowing());
|
Util.dismissDialogSafe(mDiscardDialog, this);
|
||||||
Util.dismissDialogSafe(mDiscardDialog, this);
|
|
||||||
|
if (mIsCreateMode) {
|
||||||
|
outState.putString("mFolder", new Gson().toJson(mFolder));
|
||||||
|
outState.putParcelable("mFolderUri", mFolderUri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +408,13 @@ public class FolderActivity extends SyncthingActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceStateChange(SyncthingService.State currentState) {
|
public void onServiceStateChange(SyncthingService.State currentState) {
|
||||||
|
if (mFolderNeedsToUpdate) {
|
||||||
|
Log.d(TAG, "onServiceStateChange: Suppressing reload of folder config as changes were made to that folder in the meantime.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!mIsCreateMode) {
|
if (!mIsCreateMode) {
|
||||||
|
Log.d(TAG, "onServiceStateChange: (Re)loading folder config ...");
|
||||||
RestApi restApi = getApi();
|
RestApi restApi = getApi();
|
||||||
List<Folder> folders = mConfig.getFolders(restApi);
|
List<Folder> folders = mConfig.getFolders(restApi);
|
||||||
String passedId = getIntent().getStringExtra(EXTRA_FOLDER_ID);
|
String passedId = getIntent().getStringExtra(EXTRA_FOLDER_ID);
|
||||||
|
@ -427,7 +431,6 @@ public class FolderActivity extends SyncthingActivity
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mConfig.getFolderIgnoreList(restApi, mFolder, this::onReceiveFolderIgnoreList);
|
mConfig.getFolderIgnoreList(restApi, mFolder, this::onReceiveFolderIgnoreList);
|
||||||
checkWriteAndUpdateUI();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the extra is set, we should automatically share the current folder with the given device.
|
// If the extra is set, we should automatically share the current folder with the given device.
|
||||||
|
@ -438,8 +441,8 @@ public class FolderActivity extends SyncthingActivity
|
||||||
mFolderNeedsToUpdate = true;
|
mFolderNeedsToUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkWriteAndUpdateUI();
|
||||||
attemptToApplyVersioningConfig();
|
attemptToApplyVersioningConfig();
|
||||||
|
|
||||||
updateViewsAndSetListeners();
|
updateViewsAndSetListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -578,12 +581,7 @@ public class FolderActivity extends SyncthingActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showDeleteDialog(){
|
private void showDeleteDialog(){
|
||||||
mDeleteDialog = createDeleteDialog();
|
mDeleteDialog = new AlertDialog.Builder(this)
|
||||||
mDeleteDialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Dialog createDeleteDialog(){
|
|
||||||
return new AlertDialog.Builder(this)
|
|
||||||
.setMessage(R.string.remove_folder_confirm)
|
.setMessage(R.string.remove_folder_confirm)
|
||||||
.setPositiveButton(android.R.string.yes, (dialogInterface, i) -> {
|
.setPositiveButton(android.R.string.yes, (dialogInterface, i) -> {
|
||||||
mConfig.removeFolder(getApi(), mFolder.id);
|
mConfig.removeFolder(getApi(), mFolder.id);
|
||||||
|
@ -592,6 +590,7 @@ public class FolderActivity extends SyncthingActivity
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.no, null)
|
.setNegativeButton(android.R.string.no, null)
|
||||||
.create();
|
.create();
|
||||||
|
mDeleteDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,8 +16,8 @@ import java.util.List;
|
||||||
|
|
||||||
public class FolderTypeDialogActivity extends AppCompatActivity {
|
public class FolderTypeDialogActivity extends AppCompatActivity {
|
||||||
|
|
||||||
public static final String EXTRA_FOLDER_TYPE = "com.nutomic.syncthinandroid.activities.FolderTypeDialogActivity.FOLDER_TYPE";
|
public static final String EXTRA_FOLDER_TYPE = "com.github.catfriend1.syncthingandroid.activities.FolderTypeDialogActivity.FOLDER_TYPE";
|
||||||
public static final String EXTRA_RESULT_FOLDER_TYPE = "com.nutomic.syncthinandroid.activities.FolderTypeDialogActivity.EXTRA_RESULT_FOLDER_TYPE";
|
public static final String EXTRA_RESULT_FOLDER_TYPE = "com.github.catfriend1.syncthingandroid.activities.FolderTypeDialogActivity.EXTRA_RESULT_FOLDER_TYPE";
|
||||||
|
|
||||||
private String selectedType;
|
private String selectedType;
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ import java.util.List;
|
||||||
|
|
||||||
public class PullOrderDialogActivity extends AppCompatActivity {
|
public class PullOrderDialogActivity extends AppCompatActivity {
|
||||||
|
|
||||||
public static final String EXTRA_PULL_ORDER = "com.nutomic.syncthinandroid.activities.PullOrderDialogActivity.PULL_ORDER";
|
public static final String EXTRA_PULL_ORDER = "com.github.catfriend1.syncthingandroid.activities.PullOrderDialogActivity.PULL_ORDER";
|
||||||
public static final String EXTRA_RESULT_PULL_ORDER = "com.nutomic.syncthinandroid.activities.PullOrderDialogActivity.EXTRA_RESULT_PULL_ORDER";
|
public static final String EXTRA_RESULT_PULL_ORDER = "com.github.catfriend1.syncthingandroid.activities.PullOrderDialogActivity.EXTRA_RESULT_PULL_ORDER";
|
||||||
|
|
||||||
private String selectedType;
|
private String selectedType;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue