Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,7 @@ protected void onPause() {
@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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ private void hideRefreshLayoutLoader() {
}

public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.notifications_actions_menu, menu);
getMenuInflater().inflate(R.menu.activity_notifications, menu);

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ private boolean isHaveMultipleAccount() {
@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ protected void onCreate(Bundle savedInstanceState) {
@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public static void startUploadActivityForResult(Activity activity, Account accou
@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ protected void onPause() {
@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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void onCreate(Bundle savedInstanceState) {
@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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private void onOverflowIconClicked(View view, AppCompatCheckBox allowEditsCheckB
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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public void showLinkOverflowMenu() {
}

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ public void showActivityDetailView(OCFile file) {
@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),
Expand Down Expand Up @@ -587,7 +587,7 @@ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public static ContactListFragment newInstance(OCFile file, Account account) {
@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public void onStop() {
@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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ private void stopAudio() {
@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ protected void onPostExecute(final StringWriter stringWriter) {
@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public void onDestroy() {
@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);
Expand Down Expand Up @@ -243,7 +243,7 @@ public void onRestoreIconClicked(TrashbinFile file, View view) {

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.trashbin_options_menu, menu);
getMenuInflater().inflate(R.menu.activity_trashbin, menu);

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/res/layout/drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
46 changes: 46 additions & 0 deletions src/main/res/menu/activity_folder_picker.xml
Original file line number Diff line number Diff line change
@@ -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>
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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
Expand Down