Improve menu file name pattern

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2019-11-03 15:16:39 +01:00
parent ed8b9cbb72
commit 693f408276
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
41 changed files with 91 additions and 28 deletions

View File

@ -23,6 +23,8 @@
1. Backport pull request
1. Pull requests that also need changes on library
1. Adding new files
1. File naming
1. Menu files
1. Translations
1. Releases
1. Types
@ -236,6 +238,24 @@ Source code of app:
-->
```
## File naming
The file naming patterns are inspired and based on [Ribot's Android Project And Code Guidelines](https://github.com/ribot/android-guidelines/blob/c1d8c9c904eb31bf01fe24aadb963b74281fe79a/project_and_code_guidelines.md).
### Menu files
Similar to layout files, menu files should match the name of the component. For example, if we are defining a menu file that is going to be used in the `UserProfileActivity`, then the name of the file should be `activity_user_profile.xml`. Same pattern applies for menus used in adapter view items, dialogs, etc.
| Component | Class Name | Menu Name |
| ---------------- | ---------------------- | ----------------------------- |
| Activity | `UserProfileActivity` | `activity_user_profile.xml` |
| Fragment | `SignUpFragment` | `fragment_sign_up.xml` |
| Dialog | `ChangePasswordDialog` | `dialog_change_password.xml` |
| AdapterView item | --- | `item_person.xml` |
| Partial layout | --- | `partial_stats_bar.xml` |
A good practice is to not include the word `menu` as part of the name because these files are already located in the `menu` directory. In case a component uses several menus in different places (via popup menus) then the resource name would be extended. For example, if the user profile activity has two popup menus for configuring the users settings and one for the handling group assignments then the file names for the menus would be: `activity_user_profile_user_settings.xml` and `activity_user_profile_group_assignments.xml`.
## Translations
We manage translations via [Transifex](https://www.transifex.com/nextcloud/nextcloud/android/). So just request joining the translation team for Android on the site and start translating. All translations will then be automatically pushed to this repository, there is no need for any pull request for translations.

View File

@ -69,7 +69,7 @@ class ShowErrorActivity : AppCompatActivity() {
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.activity_error_show, menu)
menuInflater.inflate(R.menu.activity_show_error, menu)
return super.onCreateOptionsMenu(menu)
}

View File

@ -51,7 +51,7 @@ class EtmPreferencesFragment : EtmBaseFragment() {
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
inflater.inflate(R.menu.etm_preferences, menu)
inflater.inflate(R.menu.fragment_etm_preferences, menu)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {

View File

@ -84,7 +84,7 @@ class LogsActivity : ToolbarActivity() {
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.logs_menu, menu)
menuInflater.inflate(R.menu.activity_logs, menu)
(menu.findItem(R.id.action_search).actionView as SearchView).apply {
setOnQueryTextListener(searchBoxListener)

View File

@ -765,7 +765,7 @@ public class FileDisplayActivity extends FileActivity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
inflater.inflate(R.menu.activity_file_display, menu);
menu.findItem(R.id.action_create_dir).setVisible(false);
menu.findItem(R.id.action_select_all).setVisible(false);

View File

@ -293,11 +293,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
menu.findItem(R.id.action_switch_view).setVisible(false);
menu.findItem(R.id.action_sync_account).setVisible(false);
menu.findItem(R.id.action_select_all).setVisible(false);
// menu.findItem(R.id.action_sort).setVisible(false);
inflater.inflate(R.menu.activity_folder_picker, menu);
return true;
}

View File

@ -303,7 +303,7 @@ public class NotificationsActivity extends FileActivity implements Notifications
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.notifications_actions_menu, menu);
getMenuInflater().inflate(R.menu.activity_notifications, menu);
return true;
}

View File

@ -1016,7 +1016,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.receive_file_menu, menu);
inflater.inflate(R.menu.activity_receive_external_files, menu);
if (!isHaveMultipleAccount()) {
MenuItem switchAccountMenu = menu.findItem(R.id.action_switch_account);

View File

@ -175,7 +175,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.synced_folders_menu, menu);
inflater.inflate(R.menu.activity_synced_folders, menu);
if (powerManagementService.isPowerSavingExclusionAvailable()) {
MenuItem item = menu.findItem(R.id.action_disable_power_save_check);

View File

@ -254,7 +254,7 @@ public class UploadFilesActivity extends FileActivity implements
@Override
public boolean onCreateOptionsMenu(Menu menu) {
mOptionsMenu = menu;
getMenuInflater().inflate(R.menu.upload_files_picker, menu);
getMenuInflater().inflate(R.menu.activity_upload_files, menu);
if(!mLocalFolderPickerMode) {
MenuItem selectAll = menu.findItem(R.id.action_select_all);

View File

@ -269,7 +269,7 @@ public class UploadListActivity extends FileActivity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.upload_list_menu, menu);
inflater.inflate(R.menu.activity_upload_list, menu);
return true;
}

View File

@ -156,7 +156,7 @@ public class UserInfoActivity extends FileActivity implements Injectable {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.user_info_menu, menu);
inflater.inflate(R.menu.activity_user_info, menu);
return true;
}

View File

@ -183,7 +183,7 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.UserVi
context.getTheme().applyStyle(R.style.FallbackThemingTheme, true);
}
PopupMenu popup = new PopupMenu(context, view);
popup.inflate(R.menu.file_detail_sharing_menu);
popup.inflate(R.menu.item_user_sharing_settings);
prepareOptionsMenu(popup.getMenu(), share);

View File

@ -300,7 +300,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
private void onOverflowIconClicked(View view) {
PopupMenu popup = new PopupMenu(getActivity(), view);
popup.inflate(R.menu.file_details_actions_menu);
popup.inflate(R.menu.fragment_file_detail);
prepareOptionsMenu(popup.getMenu());
popup.setOnMenuItemClickListener(this::optionsItemSelected);

View File

@ -409,7 +409,7 @@ public class FileDetailSharingFragment extends Fragment implements UserListAdapt
}
PopupMenu popup = new PopupMenu(context, overflowMenuShareLink);
popup.inflate(R.menu.file_detail_sharing_link_menu);
popup.inflate(R.menu.fragment_file_detail_sharing_link);
prepareOptionsMenu(popup.getMenu());
popup.setOnMenuItemClickListener(this::optionsItemSelected);
popup.show();

View File

@ -467,7 +467,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
@Override
public void onOverflowIconClicked(OCFile file, View view) {
PopupMenu popup = new PopupMenu(getActivity(), view);
popup.inflate(R.menu.file_actions_menu);
popup.inflate(R.menu.item_file);
Account currentAccount = ((FileActivity) getActivity()).getAccount();
FileMenuFilter mf = new FileMenuFilter(mAdapter.getFiles().size(),
Collections.singleton(file),
@ -587,7 +587,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
mActiveActionMode = mode;
MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.file_actions_menu, menu);
inflater.inflate(R.menu.item_file, menu);
mode.invalidate();
//set gray color

View File

@ -166,7 +166,7 @@ public class ContactListFragment extends FileFragment implements Injectable {
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.contactlist_menu, menu);
inflater.inflate(R.menu.fragment_contact_list, menu);
}
@Override

View File

@ -315,7 +315,7 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.file_actions_menu, menu);
inflater.inflate(R.menu.item_file, menu);
}
/**

View File

@ -334,7 +334,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.file_actions_menu, menu);
inflater.inflate(R.menu.item_file, menu);
}
@Override

View File

@ -396,7 +396,7 @@ public class PreviewTextFragment extends FileFragment implements SearchView.OnQu
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.file_actions_menu, menu);
inflater.inflate(R.menu.item_file, menu);
MenuItem menuItem = menu.findItem(R.id.action_search);
menuItem.setVisible(true);

View File

@ -212,7 +212,7 @@ public class TrashbinActivity extends FileActivity implements
@Override
public void onOverflowIconClicked(TrashbinFile file, View view) {
PopupMenu popup = new PopupMenu(this, view);
popup.inflate(R.menu.trashbin_actions_menu);
popup.inflate(R.menu.item_trashbin);
popup.setOnMenuItemClickListener(item -> {
trashbinPresenter.removeTrashbinFile(file);
@ -243,7 +243,7 @@ public class TrashbinActivity extends FileActivity implements
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.trashbin_options_menu, menu);
getMenuInflater().inflate(R.menu.activity_trashbin, menu);
return true;
}

View File

@ -31,7 +31,7 @@
android:background="@color/bg_default"
android:theme="@style/NavigationView_ItemTextAppearance"
app:headerLayout="@layout/drawer_header"
app:menu="@menu/drawer_menu">
app:menu="@menu/partial_drawer_entries">
<LinearLayout
android:id="@+id/drawer_quota"

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Nextcloud Android client application
@author Andy Scherzinger
Copyright (C) 2019 Andy Scherzinger
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) 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 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 <https://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="androidx.appcompat.widget.SearchView"
app:showAsAction="ifRoom" />
<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_sort"
android:contentDescription="@string/actionbar_sort"
android:icon="@drawable/ic_sort_variant"
android:orderInCategory="1"
android:title="@string/actionbar_sort"
app:showAsAction="never" />
</menu>

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!--
<?xml version="1.0" encoding="utf-8"?>
<!--
Nextcloud Android client application
@author Tobias Kaminsky