mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
Improve sort button and hide if necessary
Signed-off-by: Joris Bodin <joris.bodin@infomaniak.com>
This commit is contained in:
parent
29f60460bb
commit
3bc3a86354
6 changed files with 33 additions and 28 deletions
|
@ -131,10 +131,12 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
|||
|
||||
import static com.owncloud.android.datamodel.OCFile.ROOT_PATH;
|
||||
import static com.owncloud.android.utils.DisplayUtils.openSortingOrderDialogFragment;
|
||||
import static com.owncloud.android.utils.FileSortOrder.sort_a_to_z_id;
|
||||
import static com.owncloud.android.utils.FileSortOrder.sort_big_to_small_id;
|
||||
import static com.owncloud.android.utils.FileSortOrder.sort_new_to_old_id;
|
||||
import static com.owncloud.android.utils.FileSortOrder.sort_old_to_new_id;
|
||||
import static com.owncloud.android.utils.FileSortOrder.sort_small_to_big_id;
|
||||
import static com.owncloud.android.utils.FileSortOrder.sort_z_to_a_id;
|
||||
|
||||
/**
|
||||
* A Fragment that lists all files and folders in a given path.
|
||||
|
@ -779,6 +781,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
menu.add(menuItemOrig.getGroupId(), menuItemOrig.getItemId(), menuItemOrig.getOrder(),
|
||||
menuItemOrig.getTitle());
|
||||
}
|
||||
mSortButton.setVisibility(View.VISIBLE);
|
||||
|
||||
} else if (menuItemAddRemoveValue == MenuItemAddRemove.ADD_GRID_AND_SORT) {
|
||||
if (menu.findItem(R.id.action_switch_view) == null) {
|
||||
|
@ -786,12 +789,14 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
menu.add(menuItemOrig.getGroupId(), menuItemOrig.getItemId(), menuItemOrig.getOrder(),
|
||||
menuItemOrig.getTitle());
|
||||
}
|
||||
mSwitchGridViewButton.setVisibility(View.VISIBLE);
|
||||
|
||||
if (menu.findItem(R.id.action_sort) == null) {
|
||||
menuItemOrig = mOriginalMenuItems.get(1);
|
||||
menu.add(menuItemOrig.getGroupId(), menuItemOrig.getItemId(), menuItemOrig.getOrder(),
|
||||
menuItemOrig.getTitle());
|
||||
}
|
||||
mSortButton.setVisibility(View.VISIBLE);
|
||||
} else if (menuItemAddRemoveValue == MenuItemAddRemove.REMOVE_SEARCH) {
|
||||
menu.removeItem(R.id.action_search);
|
||||
} else if (menuItemAddRemoveValue == MenuItemAddRemove.ADD_GRID_AND_SORT_WITH_SEARCH) {
|
||||
|
@ -800,12 +805,14 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
menu.add(menuItemOrig.getGroupId(), menuItemOrig.getItemId(), menuItemOrig.getOrder(),
|
||||
menuItemOrig.getTitle());
|
||||
}
|
||||
mSwitchGridViewButton.setVisibility(View.VISIBLE);
|
||||
|
||||
if (menu.findItem(R.id.action_sort) == null) {
|
||||
menuItemOrig = mOriginalMenuItems.get(1);
|
||||
menu.add(menuItemOrig.getGroupId(), menuItemOrig.getItemId(), menuItemOrig.getOrder(),
|
||||
menuItemOrig.getTitle());
|
||||
}
|
||||
mSortButton.setVisibility(View.VISIBLE);
|
||||
|
||||
if (menu.findItem(R.id.action_search) == null) {
|
||||
menuItemOrig = mOriginalMenuItems.get(2);
|
||||
|
@ -815,10 +822,13 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
} else if (menuItemAddRemoveValue == MenuItemAddRemove.REMOVE_SORT) {
|
||||
menu.removeItem(R.id.action_sort);
|
||||
menu.removeItem(R.id.action_search);
|
||||
mSortButton.setVisibility(View.GONE);
|
||||
} else if (menuItemAddRemoveValue == MenuItemAddRemove.REMOVE_GRID_AND_SORT) {
|
||||
menu.removeItem(R.id.action_sort);
|
||||
menu.removeItem(R.id.action_switch_view);
|
||||
menu.removeItem(R.id.action_search);
|
||||
mSortButton.setVisibility(View.GONE);
|
||||
mSwitchGridViewButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1317,26 +1327,27 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
private void setSortButton(FileSortOrder sortOrder) {
|
||||
int nameId;
|
||||
switch (sortOrder.name) {
|
||||
case sort_z_to_a_id:
|
||||
nameId = R.string.menu_item_sort_by_name_z_a;
|
||||
break;
|
||||
case sort_new_to_old_id:
|
||||
nameId = R.string.menu_item_sort_by_date_newest_first;
|
||||
break;
|
||||
case sort_old_to_new_id:
|
||||
nameId = R.string.sort_by_date;
|
||||
nameId = R.string.menu_item_sort_by_date_oldest_first;
|
||||
break;
|
||||
case sort_big_to_small_id:
|
||||
case sort_small_to_big_id:
|
||||
nameId = R.string.sort_by_size;
|
||||
nameId = R.string.menu_item_sort_by_size_biggest_first;
|
||||
break;
|
||||
case sort_small_to_big_id:
|
||||
nameId = R.string.menu_item_sort_by_size_smallest_first;
|
||||
break;
|
||||
case sort_a_to_z_id:
|
||||
default:
|
||||
nameId = R.string.sort_by_name;
|
||||
nameId = R.string.menu_item_sort_by_name_a_z;
|
||||
break;
|
||||
}
|
||||
mSortButton.setText(getString(nameId));
|
||||
Drawable icon;
|
||||
if (sortOrder.isAscending) {
|
||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_arrow_down);
|
||||
} else {
|
||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_arrow_up);
|
||||
}
|
||||
mSortButton.setIcon(icon);
|
||||
}
|
||||
|
||||
private void setGridSwitchButton() {
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M20,12l-1.41,-1.41L13,16.17V4h-2v12.17l-5.58,-5.59L4,12l8,8 8,-8z" />
|
||||
</vector>
|
9
src/main/res/drawable/ic_keyboard_arrow_down.xml
Normal file
9
src/main/res/drawable/ic_keyboard_arrow_down.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M7.41,7.84L12,12.42l4.59,-4.58L18,9.25l-6,6 -6,-6z"/>
|
||||
</vector>
|
|
@ -45,12 +45,12 @@
|
|||
android:layout_marginStart="8dp"
|
||||
android:contentDescription="@string/actionbar_sort"
|
||||
android:minWidth="0dp"
|
||||
android:text="@string/sort_by_name"
|
||||
android:text="@string/menu_item_sort_by_date_newest_first"
|
||||
android:textAlignment="textStart"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@color/fontAppbar"
|
||||
android:textSize="14sp"
|
||||
app:icon="@drawable/ic_arrow_up"
|
||||
app:icon="@drawable/ic_keyboard_arrow_down"
|
||||
app:iconGravity="textEnd"
|
||||
app:iconSize="16dp"
|
||||
app:iconTint="@color/fontAppbar"
|
||||
|
|
|
@ -633,9 +633,6 @@ Attention la suppression est irréversible.</string>
|
|||
<string name="signup_with_provider">Se connecter avec un fournisseur</string>
|
||||
<string name="single_sign_on_request_token" formatted="true">Autoriser %1$s à accéder à votre compte Nextcloud %2$s ?</string>
|
||||
<string name="sort_by">Trier par</string>
|
||||
<string name="sort_by_date">Date</string>
|
||||
<string name="sort_by_name">Nom</string>
|
||||
<string name="sort_by_size">Taille</string>
|
||||
<string name="sort_by_modification_date_ascending">Le plus récent en premier</string>
|
||||
<string name="sort_by_modification_date_descending">Le plus ancien en premier</string>
|
||||
<string name="sort_by_name_ascending">A - Z</string>
|
||||
|
|
|
@ -11,9 +11,6 @@
|
|||
<string name="actionbar_send_file">Send</string>
|
||||
<string name="actionbar_sort">Sort</string>
|
||||
<string name="sort_by">Sort by</string>
|
||||
<string name="sort_by_date">Date</string>
|
||||
<string name="sort_by_name">Name</string>
|
||||
<string name="sort_by_size">Size</string>
|
||||
<string name="menu_item_sort_by_name_a_z">A - Z</string>
|
||||
<string name="menu_item_sort_by_name_z_a">Z - A</string>
|
||||
<string name="menu_item_sort_by_date_newest_first">Newest first</string>
|
||||
|
|
Loading…
Reference in a new issue