mirror of
https://github.com/nextcloud/android.git
synced 2024-11-25 22:55:46 +03:00
Move account chooser in ReceiveExternalFilesActivity
Showing it in overflow menu instead of when the page is open https://github.com/nextcloud/android/issues/344
This commit is contained in:
parent
6379366b0d
commit
02e01755db
2 changed files with 61 additions and 34 deletions
|
@ -134,15 +134,11 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|||
|
||||
private SyncBroadcastReceiver mSyncBroadcastReceiver;
|
||||
private boolean mSyncInProgress = false;
|
||||
private boolean mAccountSelected;
|
||||
private boolean mAccountSelectionShowing;
|
||||
|
||||
private final static int REQUEST_CODE__SETUP_ACCOUNT = REQUEST_CODE__LAST_SHARED + 1;
|
||||
|
||||
private final static String KEY_PARENTS = "PARENTS";
|
||||
private final static String KEY_FILE = "FILE";
|
||||
private final static String KEY_ACCOUNT_SELECTED = "ACCOUNT_SELECTED";
|
||||
private final static String KEY_ACCOUNT_SELECTION_SHOWING = "ACCOUNT_SELECTION_SHOWING";
|
||||
|
||||
private boolean mUploadFromTmpFile = false;
|
||||
private String mSubjectText;
|
||||
|
@ -162,22 +158,13 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|||
|
||||
if (savedInstanceState == null) {
|
||||
mParents = new Stack<>();
|
||||
mAccountSelected = false;
|
||||
mAccountSelectionShowing = false;
|
||||
|
||||
} else {
|
||||
mParents = (Stack<String>) savedInstanceState.getSerializable(KEY_PARENTS);
|
||||
mFile = savedInstanceState.getParcelable(KEY_FILE);
|
||||
mAccountSelected = savedInstanceState.getBoolean(KEY_ACCOUNT_SELECTED);
|
||||
mAccountSelectionShowing = savedInstanceState.getBoolean(KEY_ACCOUNT_SELECTION_SHOWING);
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (mAccountSelected) {
|
||||
setAccount(savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT));
|
||||
}
|
||||
|
||||
// Listen for sync messages
|
||||
IntentFilter syncIntentFilter = new IntentFilter(RefreshFolderOperation.
|
||||
EVENT_SINGLE_FOLDER_CONTENTS_SYNCED);
|
||||
|
@ -205,11 +192,6 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|||
Log_OC.i(TAG, "No ownCloud account is available");
|
||||
DialogNoAccount dialog = new DialogNoAccount();
|
||||
dialog.show(getSupportFragmentManager(), null);
|
||||
} else if (accounts.length > 1 && !mAccountSelected && !mAccountSelectionShowing) {
|
||||
Log_OC.i(TAG, "More than one ownCloud is available");
|
||||
DialogMultipleAccount dialog = new DialogMultipleAccount();
|
||||
dialog.show(getSupportFragmentManager(), null);
|
||||
mAccountSelectionShowing = true;
|
||||
} else {
|
||||
if (!savedAccount) {
|
||||
setAccount(accounts[0]);
|
||||
|
@ -225,6 +207,11 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|||
super.setAccount(account, savedAccount);
|
||||
}
|
||||
|
||||
private void showAccountChooserDialog() {
|
||||
DialogMultipleAccount dialog = new DialogMultipleAccount();
|
||||
dialog.show(getSupportFragmentManager(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAccountSet(boolean stateWasRecovered) {
|
||||
super.onAccountSet(mAccountWasRestored);
|
||||
|
@ -238,8 +225,6 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|||
super.onSaveInstanceState(outState);
|
||||
outState.putSerializable(KEY_PARENTS, mParents);
|
||||
outState.putParcelable(KEY_FILE, mFile);
|
||||
outState.putBoolean(KEY_ACCOUNT_SELECTED, mAccountSelected);
|
||||
outState.putBoolean(KEY_ACCOUNT_SELECTION_SHOWING, mAccountSelectionShowing);
|
||||
outState.putParcelable(FileActivity.EXTRA_ACCOUNT, getAccount());
|
||||
|
||||
Log_OC.d(TAG, "onSaveInstanceState() end");
|
||||
|
@ -308,11 +293,9 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final ReceiveExternalFilesActivity parent = (ReceiveExternalFilesActivity) getActivity();
|
||||
parent.setAccount(parent.mAccountManager.getAccountsByType(MainApp.getAccountType())[which]);
|
||||
parent.setAccount(parent.mAccountManager.getAccountsByType(MainApp.getAccountType())[which], false);
|
||||
parent.onAccountSet(parent.mAccountWasRestored);
|
||||
dialog.dismiss();
|
||||
parent.mAccountSelected = true;
|
||||
parent.mAccountSelectionShowing = false;
|
||||
}
|
||||
});
|
||||
builder.setCancelable(true);
|
||||
|
@ -333,13 +316,6 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|||
|
||||
return adapterAccountList;
|
||||
}
|
||||
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
super.onCancel(dialog);
|
||||
final ReceiveExternalFilesActivity parent = (ReceiveExternalFilesActivity) getActivity();
|
||||
parent.mAccountSelectionShowing = false;
|
||||
parent.finish();
|
||||
}
|
||||
}
|
||||
|
||||
public static class DialogInputUploadFilename extends DialogFragment {
|
||||
|
@ -1033,10 +1009,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.main_menu, menu);
|
||||
menu.findItem(R.id.action_sort).setVisible(false);
|
||||
menu.findItem(R.id.action_switch_view).setVisible(false);
|
||||
menu.findItem(R.id.action_sync_account).setVisible(false);
|
||||
inflater.inflate(R.menu.receive_file_menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1055,6 +1028,9 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|||
onBackPressed();
|
||||
}
|
||||
break;
|
||||
case R.id.action_choose_account:
|
||||
showAccountChooserDialog();
|
||||
break;
|
||||
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
|
|
51
src/main/res/menu/receive_file_menu.xml
Normal file
51
src/main/res/menu/receive_file_menu.xml
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
ownCloud Android client application
|
||||
|
||||
Copyright (C) 2012 Bartek Przybylski
|
||||
Copyright (C) 2015 ownCloud Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2,
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_search"
|
||||
android:contentDescription="@string/actionbar_search"
|
||||
android:icon="@drawable/ic_search"
|
||||
android:title="@string/actionbar_search"
|
||||
app:actionViewClass="android.support.v7.widget.SearchView"
|
||||
app:showAsAction="always"/>
|
||||
<item
|
||||
android:id="@+id/action_choose_account"
|
||||
android:contentDescription="@string/common_choose_account"
|
||||
android:orderInCategory="1"
|
||||
android:title="@string/common_choose_account"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/action_create_dir"
|
||||
android:contentDescription="@string/actionbar_mkdir"
|
||||
android:icon="@drawable/ic_action_create_dir"
|
||||
android:orderInCategory="1"
|
||||
android:title="@string/actionbar_mkdir"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/action_select_all"
|
||||
android:contentDescription="@string/select_all"
|
||||
android:icon="@drawable/ic_select_all"
|
||||
android:orderInCategory="1"
|
||||
android:title="@string/select_all"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
</menu>
|
Loading…
Reference in a new issue