mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 07:05:49 +03:00
Merge pull request #1684 from esafirm/develop
Move account choice from startup to menu item. Add subtitle for account name
This commit is contained in:
commit
7234efc802
8 changed files with 107 additions and 68 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 {
|
||||
|
@ -722,11 +698,21 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|||
}
|
||||
}
|
||||
|
||||
private void setupActionBarSubtitle() {
|
||||
if (isHaveMultipleAccount()) {
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setSubtitle(getAccount().name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void populateDirectoryList() {
|
||||
setContentView(R.layout.uploader_layout);
|
||||
setupEmptyList();
|
||||
setupToolbar();
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
setupActionBarSubtitle();
|
||||
|
||||
ListView mListView = (ListView) findViewById(android.R.id.list);
|
||||
|
||||
|
@ -1030,13 +1016,20 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isHaveMultipleAccount() {
|
||||
return mAccountManager.getAccountsByType(MainApp.getAccountType()).length > 1;
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
if (!isHaveMultipleAccount()) {
|
||||
MenuItem switchAccountMenu = menu.findItem(R.id.action_switch_account);
|
||||
switchAccountMenu.setVisible(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1055,6 +1048,9 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|||
onBackPressed();
|
||||
}
|
||||
break;
|
||||
case R.id.action_switch_account:
|
||||
showAccountChooserDialog();
|
||||
break;
|
||||
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
|
@ -29,6 +29,8 @@ import android.content.pm.ActivityInfo;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -77,6 +79,7 @@ public class ShareLinkToDialog extends DialogFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
mIntent = getArguments().getParcelable(ARG_INTENT);
|
||||
String[] packagesToExclude = getArguments().getStringArray(ARG_PACKAGES_TO_EXCLUDE);
|
||||
|
@ -84,8 +87,7 @@ public class ShareLinkToDialog extends DialogFragment {
|
|||
packagesToExclude : new String[0]);
|
||||
|
||||
PackageManager pm= getActivity().getPackageManager();
|
||||
List<ResolveInfo> activities = pm.queryIntentActivities(mIntent,
|
||||
PackageManager.MATCH_DEFAULT_ONLY);
|
||||
List<ResolveInfo> activities = pm.queryIntentActivities(mIntent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
Iterator<ResolveInfo> it = activities.iterator();
|
||||
ResolveInfo resolveInfo;
|
||||
while (it.hasNext()) {
|
||||
|
@ -110,7 +112,6 @@ public class ShareLinkToDialog extends DialogFragment {
|
|||
mAdapter = new ActivityAdapter(getActivity(), pm, activities);
|
||||
|
||||
return createSelector(sendAction);
|
||||
|
||||
}
|
||||
|
||||
private AlertDialog createSelector(final boolean sendAction) {
|
||||
|
@ -152,7 +153,7 @@ public class ShareLinkToDialog extends DialogFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
public @NonNull View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
convertView = newView(parent);
|
||||
}
|
||||
|
|
|
@ -21,39 +21,29 @@
|
|||
android:id="@+id/list_item"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:paddingStart="@dimen/standard_padding_independent"
|
||||
android:paddingEnd="@dimen/standard_padding_independent"
|
||||
android:paddingRight="@dimen/standard_padding_independent"
|
||||
android:paddingLeft="@dimen/standard_padding_independent"
|
||||
android:paddingStart="@dimen/standard_padding"
|
||||
android:paddingEnd="@dimen/standard_padding"
|
||||
android:paddingRight="@dimen/standard_padding"
|
||||
android:paddingLeft="@dimen/standard_padding"
|
||||
android:minWidth="@dimen/activity_row_layout_min_width_independent"
|
||||
android:background="?android:attr/activatedBackgroundIndicator"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:duplicateParentState="true" >
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="@dimen/user_icon_size_independent"
|
||||
android:layout_height="@dimen/user_icon_size_independent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/standard_half_padding_independent"
|
||||
android:layout_marginRight="@dimen/standard_half_padding_independent"
|
||||
android:duplicateParentState="true" />
|
||||
android:layout_marginEnd="@dimen/standard_padding"
|
||||
android:layout_marginRight="@dimen/standard_padding"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textAppearance="?android:attr/textAppearanceLargePopupMenu"
|
||||
android:duplicateParentState="true"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal" />
|
||||
|
||||
</LinearLayout>
|
||||
android:ellipsize="marquee"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -78,7 +78,7 @@
|
|||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="@dimen/zero"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="top"
|
||||
|
|
|
@ -28,6 +28,6 @@
|
|||
android:contentDescription="@string/select_all"
|
||||
android:title="@string/select_all"
|
||||
android:icon="@drawable/ic_select_all"
|
||||
app:showAsAction="always"/>
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
</menu>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
android:title="@string/actionbar_search"
|
||||
android:contentDescription="@string/actionbar_search"
|
||||
app:actionViewClass="android.support.v7.widget.SearchView"
|
||||
app:showAsAction="always"/>
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/action_create_dir"
|
||||
android:icon="@drawable/ic_action_create_dir"
|
||||
|
|
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"?>
|
||||
<!--
|
||||
Nextcloud Android client application
|
||||
|
||||
Copyright (C) 2017 Esa Firman
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or any later version.
|
||||
|
||||
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 AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero 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="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/action_switch_account"
|
||||
android:contentDescription="@string/common_switch_account"
|
||||
android:orderInCategory="1"
|
||||
android:title="@string/common_switch_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>
|
|
@ -184,6 +184,7 @@
|
|||
<string name="downloader_not_downloaded_yet">Not downloaded yet</string>
|
||||
<string name="downloader_download_failed_credentials_error">Download failed, you need to log in again</string>
|
||||
<string name="common_choose_account">Choose account</string>
|
||||
<string name="common_switch_account">Switch Account</string>
|
||||
<string name="sync_fail_ticker">Sync failed</string>
|
||||
<string name="sync_fail_ticker_unauthorized">Sync failed, you need to log in again</string>
|
||||
<string name="sync_fail_content">Could not complete sync of %1$s</string>
|
||||
|
|
Loading…
Reference in a new issue