mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
Added 3 dot menu to filter Media data.
This commit is contained in:
parent
b3b3376c5b
commit
95fafabe8a
18 changed files with 701 additions and 13 deletions
|
@ -3,7 +3,7 @@ import org.gradle.internal.jvm.Jvm
|
|||
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.1.3'
|
||||
classpath 'com.android.tools.build:gradle:7.0.4'
|
||||
classpath 'com.hiya:jacoco-android:0.2'
|
||||
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.6'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
|
|
@ -377,4 +377,16 @@ public interface AppPreferences {
|
|||
boolean isStoragePermissionRequested();
|
||||
|
||||
void setStoragePermissionRequested(boolean value);
|
||||
|
||||
/**
|
||||
* Saves the show/hide Image State
|
||||
*/
|
||||
void setHideImageClicked(boolean isHideImageClicked);
|
||||
boolean getHideImageClicked();
|
||||
|
||||
/**
|
||||
* Saves the show/hide Video State
|
||||
*/
|
||||
void setHideVideoClicked(boolean isHideVideoClicked);
|
||||
boolean getHideVideoClicked();
|
||||
}
|
||||
|
|
|
@ -99,6 +99,9 @@ public final class AppPreferencesImpl implements AppPreferences {
|
|||
|
||||
private static final String PREF__STORAGE_PERMISSION_REQUESTED = "storage_permission_requested";
|
||||
|
||||
private static final String PREF__IS_HIDE_IMAGE_CLICKED = "is_hideImage_clicked";
|
||||
private static final String PREF__IS_HIDE_VIDEO_CLICKED = "is_hideVideo_clicked";
|
||||
|
||||
private final Context context;
|
||||
private final SharedPreferences preferences;
|
||||
private final CurrentAccountProvider currentAccountProvider;
|
||||
|
@ -712,4 +715,24 @@ public final class AppPreferencesImpl implements AppPreferences {
|
|||
public int computeBruteForceDelay(int count) {
|
||||
return (int) Math.min(count / 3d, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHideImageClicked(boolean isHideImageClicked) {
|
||||
preferences.edit().putBoolean(PREF__IS_HIDE_IMAGE_CLICKED, isHideImageClicked).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHideImageClicked() {
|
||||
return preferences.getBoolean(PREF__IS_HIDE_IMAGE_CLICKED,false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHideVideoClicked(boolean isHideVideoClicked) {
|
||||
preferences.edit().putBoolean(PREF__IS_HIDE_VIDEO_CLICKED, isHideVideoClicked).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHideVideoClicked() {
|
||||
return preferences.getBoolean(PREF__IS_HIDE_VIDEO_CLICKED,false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ import java.util.ArrayList;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
@ -84,6 +85,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
|||
".EXTRA_CURRENT_FOLDER";
|
||||
public static final String MOVE = "MOVE";
|
||||
public static final String COPY = "COPY";
|
||||
public static final String CHOOSE_LOCATION = "CHOOSE_LOCATION";
|
||||
|
||||
private SyncBroadcastReceiver mSyncBroadcastReceiver;
|
||||
|
||||
|
@ -132,6 +134,14 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
|||
mSearchOnlyFolders = true;
|
||||
mDoNotEnterEncryptedFolder = true;
|
||||
break;
|
||||
case CHOOSE_LOCATION:
|
||||
caption = getResources().getText(R.string.choose_location).toString();
|
||||
mSearchOnlyFolders = true;
|
||||
mDoNotEnterEncryptedFolder = true;
|
||||
mChooseBtn.setText(getResources().getString(R.string.common_select));
|
||||
mChooseBtn.setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_tick,
|
||||
null));
|
||||
break;
|
||||
default:
|
||||
caption = ThemeUtils.getDefaultDisplayNameForRootFolder(this);
|
||||
break;
|
||||
|
|
|
@ -39,10 +39,13 @@ import com.owncloud.android.datamodel.FileDataStorageManager
|
|||
import com.owncloud.android.datamodel.GalleryItems
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.ui.activity.ComponentsGetter
|
||||
import com.owncloud.android.ui.fragment.GalleryFragment
|
||||
import com.owncloud.android.ui.fragment.SearchType
|
||||
import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.FileSortOrder
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView.SectionedAdapter
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
|
@ -145,10 +148,69 @@ class GalleryAdapter(
|
|||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun showAllGalleryItems(storageManager: FileDataStorageManager) {
|
||||
fun showAllGalleryItems(storageManager: FileDataStorageManager,
|
||||
remotePath: String,
|
||||
mediaObject: MutableList<OCFile>,
|
||||
isVideoHideClicked: Boolean, isImageHideClicked: Boolean,
|
||||
imageList: MutableList<OCFile>, videoList: MutableList<OCFile>, photoFragment: GalleryFragment) {
|
||||
|
||||
val items = storageManager.allGalleryItems
|
||||
mediaObject.clear()
|
||||
|
||||
files = items
|
||||
for (c in items) {
|
||||
if (c is OCFile) {
|
||||
if (c.remotePath.contains(remotePath)) {
|
||||
mediaObject.add(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setAdapterWithHideShowImage(
|
||||
mediaObject, isVideoHideClicked, isImageHideClicked, imageList, videoList,
|
||||
photoFragment
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Set Image/Video List According to Selection of Hide/Show Image/Video
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun setAdapterWithHideShowImage(
|
||||
mediaObject: List<OCFile>,
|
||||
isVideoHideClicked: Boolean, isImageHideClicked: Boolean,
|
||||
imageList: MutableList<OCFile>, videoList: MutableList<OCFile>,
|
||||
photoFragment: GalleryFragment
|
||||
) {
|
||||
|
||||
val finalSortedList: List<OCFile>
|
||||
|
||||
if (isVideoHideClicked) {
|
||||
imageList.clear()
|
||||
for (ocFile in mediaObject) {
|
||||
if (MimeTypeUtil.isImage(ocFile.mimeType) && !imageList.contains(ocFile)) {
|
||||
imageList.add(ocFile)
|
||||
}
|
||||
}
|
||||
finalSortedList = imageList
|
||||
if (imageList.isEmpty()) {
|
||||
photoFragment.setEmptyListMessage(SearchType.GALLERY_SEARCH)
|
||||
}
|
||||
} else if (isImageHideClicked) {
|
||||
videoList.clear()
|
||||
for (ocFile in mediaObject) {
|
||||
if (MimeTypeUtil.isVideo(ocFile.mimeType) && !videoList.contains(ocFile)) {
|
||||
videoList.add(ocFile)
|
||||
}
|
||||
}
|
||||
finalSortedList = videoList
|
||||
if (videoList.isEmpty()) {
|
||||
photoFragment.setEmptyListMessage(SearchType.GALLERY_SEARCH)
|
||||
}
|
||||
} else {
|
||||
finalSortedList = mediaObject
|
||||
}
|
||||
|
||||
files = finalSortedList
|
||||
.groupBy { firstOfMonth(it.modificationTimestamp) }
|
||||
.map { GalleryItems(it.key, FileStorageUtils.sortOcFolderDescDateModifiedWithoutFavoritesFirst(it.value)) }
|
||||
.sortedBy { it.date }.reversed()
|
||||
|
@ -156,6 +218,12 @@ class GalleryAdapter(
|
|||
Handler(Looper.getMainLooper()).post { notifyDataSetChanged() }
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun resetAdapter(){
|
||||
files = emptyList()
|
||||
Handler(Looper.getMainLooper()).post { notifyDataSetChanged() }
|
||||
}
|
||||
|
||||
private fun firstOfMonth(timestamp: Long): Long {
|
||||
val cal = Calendar.getInstance()
|
||||
cal.time = Date(timestamp)
|
||||
|
|
|
@ -21,22 +21,37 @@
|
|||
|
||||
package com.owncloud.android.ui.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.activity.FileActivity;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.ui.activity.FolderPickerActivity;
|
||||
import com.owncloud.android.ui.adapter.CommonOCFileListAdapterInterface;
|
||||
import com.owncloud.android.ui.adapter.GalleryAdapter;
|
||||
import com.owncloud.android.ui.asynctasks.GallerySearchTask;
|
||||
import com.owncloud.android.ui.events.ChangeMenuEvent;
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeMenuUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
@ -44,7 +59,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
/**
|
||||
* A Fragment that lists all files and folders in a given path
|
||||
*/
|
||||
public class GalleryFragment extends OCFileListFragment {
|
||||
public class GalleryFragment extends OCFileListFragment implements GalleryFragmentBottomSheetActions {
|
||||
private static final int MAX_ITEMS_PER_ROW = 10;
|
||||
private boolean photoSearchQueryRunning = false;
|
||||
private AsyncTask<Void, Void, GallerySearchTask.Result> photoSearchTask;
|
||||
|
@ -54,10 +69,32 @@ public class GalleryFragment extends OCFileListFragment {
|
|||
private int limit = 300;
|
||||
private GalleryAdapter mAdapter;
|
||||
|
||||
private static final int SELECT_LOCATION_REQUEST_CODE = 212;
|
||||
private OCFile remoteFilePath;
|
||||
private String remotePath = "/";
|
||||
private List<OCFile> mediaObject;
|
||||
private GalleryFragmentBottomSheetDialog galleryFragmentBottomSheetDialog;
|
||||
private List<OCFile> imageList;
|
||||
private List<OCFile> videoList;
|
||||
|
||||
@Inject AppPreferences appPreferences;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
searchFragment = true;
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
if (galleryFragmentBottomSheetDialog == null) {
|
||||
FileActivity activity = (FileActivity) getActivity();
|
||||
|
||||
galleryFragmentBottomSheetDialog = new GalleryFragmentBottomSheetDialog(activity,
|
||||
this,
|
||||
appPreferences);
|
||||
}
|
||||
imageList = new ArrayList<>();
|
||||
videoList = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -91,6 +128,12 @@ public class GalleryFragment extends OCFileListFragment {
|
|||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
if (mediaObject == null) {
|
||||
mediaObject = new ArrayList<>();
|
||||
} else {
|
||||
mediaObject.clear();
|
||||
}
|
||||
|
||||
currentSearchType = SearchType.GALLERY_SEARCH;
|
||||
|
||||
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_GRID_AND_SORT;
|
||||
|
@ -133,6 +176,7 @@ public class GalleryFragment extends OCFileListFragment {
|
|||
public void onRefresh() {
|
||||
super.onRefresh();
|
||||
|
||||
mediaObject.clear();
|
||||
handleSearchEvent();
|
||||
}
|
||||
|
||||
|
@ -163,7 +207,7 @@ public class GalleryFragment extends OCFileListFragment {
|
|||
setEmptyListLoadingMessage();
|
||||
|
||||
// always show first stored items
|
||||
mAdapter.showAllGalleryItems(mContainerActivity.getStorageManager());
|
||||
showAllGalleryItems();
|
||||
|
||||
setFabVisible(false);
|
||||
|
||||
|
@ -219,6 +263,76 @@ public class GalleryFragment extends OCFileListFragment {
|
|||
|
||||
startDate = endDate - (daySpan * 24 * 60 * 60);
|
||||
|
||||
runGallerySearchTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
remotePath = setDefaultRemotePath();
|
||||
}
|
||||
|
||||
private String setDefaultRemotePath() {
|
||||
if (remoteFilePath == null) {
|
||||
setRemoteFilePath(remotePath);
|
||||
}
|
||||
return remotePath;
|
||||
}
|
||||
|
||||
private void setRemoteFilePath(String remotePath) {
|
||||
remoteFilePath = new OCFile(remotePath);
|
||||
remoteFilePath.setFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, @NonNull MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
inflater.inflate(R.menu.fragment_gallery_three_dots, menu);
|
||||
|
||||
MenuItem menuItem = menu.findItem(R.id.action_three_dot_icon);
|
||||
|
||||
if (menuItem != null) {
|
||||
ThemeMenuUtils.tintMenuIcon(requireContext(), menuItem,
|
||||
ThemeColorUtils.appBarPrimaryFontColor(requireContext()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
// Handle item selection
|
||||
if (item.getItemId() == R.id.action_three_dot_icon) {
|
||||
if (!photoSearchQueryRunning) {
|
||||
galleryFragmentBottomSheetDialog.show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
if (requestCode == SELECT_LOCATION_REQUEST_CODE) {
|
||||
if (data != null) {
|
||||
OCFile chosenFolder = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER);
|
||||
if (chosenFolder != null) {
|
||||
remoteFilePath = chosenFolder;
|
||||
searchAndDisplayAfterChangingFolder();
|
||||
}
|
||||
}
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
private void searchAndDisplayAfterChangingFolder() {
|
||||
mAdapter.resetAdapter();
|
||||
mediaObject.clear();
|
||||
runGallerySearchTask();
|
||||
}
|
||||
|
||||
private void runGallerySearchTask() {
|
||||
photoSearchTask = new GallerySearchTask(this,
|
||||
accountManager.getUser(),
|
||||
mContainerActivity.getStorageManager(),
|
||||
|
@ -257,19 +371,51 @@ public class GalleryFragment extends OCFileListFragment {
|
|||
startDate = endDate - (daySpan * 24 * 60 * 60);
|
||||
|
||||
photoSearchQueryRunning = true;
|
||||
photoSearchTask = new GallerySearchTask(this,
|
||||
accountManager.getUser(),
|
||||
mContainerActivity.getStorageManager(),
|
||||
startDate,
|
||||
endDate,
|
||||
limit)
|
||||
.execute();
|
||||
runGallerySearchTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Actions implementation of Bottom Sheet Dialog
|
||||
@Override
|
||||
public void hideVideos(boolean isHideVideosClicked) {
|
||||
|
||||
if (!mediaObject.isEmpty()) {
|
||||
mAdapter.setAdapterWithHideShowImage(mediaObject,
|
||||
preferences.getHideVideoClicked(),
|
||||
preferences.getHideImageClicked(), imageList, videoList,
|
||||
this);
|
||||
|
||||
} else {
|
||||
setEmptyListMessage(SearchType.GALLERY_SEARCH);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideImages(boolean isHideImagesClicked) {
|
||||
if (!mediaObject.isEmpty()) {
|
||||
mAdapter.setAdapterWithHideShowImage(mediaObject,
|
||||
preferences.getHideVideoClicked(),
|
||||
preferences.getHideImageClicked(), imageList, videoList,
|
||||
this);
|
||||
|
||||
} else {
|
||||
setEmptyListMessage(SearchType.GALLERY_SEARCH);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectMediaFolder() {
|
||||
Intent action = new Intent(requireActivity(), FolderPickerActivity.class);
|
||||
action.putExtra(FolderPickerActivity.EXTRA_ACTION, FolderPickerActivity.CHOOSE_LOCATION);
|
||||
startActivityForResult(action, SELECT_LOCATION_REQUEST_CODE);
|
||||
}
|
||||
|
||||
public void showAllGalleryItems() {
|
||||
mAdapter.showAllGalleryItems(mContainerActivity.getStorageManager());
|
||||
mAdapter.showAllGalleryItems(mContainerActivity.getStorageManager(), remoteFilePath.getRemotePath(),
|
||||
mediaObject, preferences.getHideVideoClicked(), preferences.getHideImageClicked(),
|
||||
imageList, videoList, this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.owncloud.android.ui.fragment;
|
||||
|
||||
public interface GalleryFragmentBottomSheetActions {
|
||||
|
||||
/**
|
||||
* hide all the images in particular Folder.
|
||||
*/
|
||||
void hideImages(boolean isHideImagesClicked);
|
||||
|
||||
/**
|
||||
* hide all the videos in particular folder.
|
||||
*/
|
||||
void hideVideos(boolean isHideVideosClicked);
|
||||
|
||||
/**
|
||||
* load all media of a particular folder.
|
||||
*/
|
||||
void selectMediaFolder();
|
||||
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
package com.owncloud.android.ui.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.databinding.FragmentGalleryBottomSheetBinding;
|
||||
import com.owncloud.android.ui.activity.FileActivity;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
public class GalleryFragmentBottomSheetDialog extends BottomSheetDialog {
|
||||
|
||||
private FragmentGalleryBottomSheetBinding binding;
|
||||
private final GalleryFragmentBottomSheetActions actions;
|
||||
private final AppPreferences preferences;
|
||||
private boolean isHideImageClicked;
|
||||
private boolean isHideVideoClicked;
|
||||
private BottomSheetBehavior mBottomBehavior;
|
||||
|
||||
public GalleryFragmentBottomSheetDialog(FileActivity fileActivity,
|
||||
GalleryFragmentBottomSheetActions actions,
|
||||
AppPreferences preferences) {
|
||||
super(fileActivity);
|
||||
this.actions = actions;
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = FragmentGalleryBottomSheetBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
if (getWindow() != null) {
|
||||
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
setupLayout();
|
||||
setupClickListener();
|
||||
mBottomBehavior = BottomSheetBehavior.from((View) binding.getRoot().getParent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
mBottomBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
}
|
||||
|
||||
private void setupLayout() {
|
||||
|
||||
if (!preferences.getHideImageClicked()) {
|
||||
binding.hideImagesImageview.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_camera));
|
||||
binding.hideImagesTextview.setText(getContext().getResources().getString(R.string.hide_images));
|
||||
binding.tickMarkHideImages.setVisibility(View.GONE);
|
||||
} else if (preferences.getHideImageClicked()) {
|
||||
binding.hideImagesImageview.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_no_camera));
|
||||
binding.hideImagesTextview.setText(getContext().getResources().getString(R.string.show_images));
|
||||
binding.tickMarkHideImages.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (!preferences.getHideVideoClicked()) {
|
||||
binding.hideVideoImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_video_camera));
|
||||
binding.hideVideoTextview.setText(getContext().getResources().getString(R.string.hide_video));
|
||||
binding.tickMarkHideVideo.setVisibility(View.GONE);
|
||||
} else if (preferences.getHideVideoClicked()) {
|
||||
binding.hideVideoImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_no_video_camera));
|
||||
binding.hideVideoTextview.setText(getContext().getResources().getString(R.string.show_video));
|
||||
binding.tickMarkHideVideo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupClickListener() {
|
||||
|
||||
binding.hideImages.setOnClickListener(v -> {
|
||||
|
||||
if (!preferences.getHideImageClicked() && preferences.getHideVideoClicked()) {
|
||||
isHideImageClicked = true;
|
||||
isHideVideoClicked = false;
|
||||
binding.hideImagesImageview.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_no_camera));
|
||||
binding.hideImagesTextview.setText(getContext().getResources().getString(R.string.show_images));
|
||||
binding.hideVideoImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_video_camera));
|
||||
binding.hideVideoTextview.setText(getContext().getResources().getString(R.string.hide_video));
|
||||
binding.tickMarkHideImages.setVisibility(View.VISIBLE);
|
||||
binding.tickMarkHideVideo.setVisibility(View.GONE);
|
||||
|
||||
} else if (!preferences.getHideImageClicked() && !preferences.getHideVideoClicked()) {
|
||||
isHideImageClicked = true;
|
||||
binding.hideImagesImageview.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_no_camera));
|
||||
binding.hideImagesTextview.setText(getContext().getResources().getString(R.string.show_images));
|
||||
binding.tickMarkHideImages.setVisibility(View.VISIBLE);
|
||||
} else if (preferences.getHideImageClicked() && !preferences.getHideVideoClicked()) {
|
||||
isHideImageClicked = false;
|
||||
binding.hideImagesImageview.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_camera));
|
||||
binding.hideImagesTextview.setText(getContext().getResources().getString(R.string.hide_images));
|
||||
binding.tickMarkHideImages.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
|
||||
preferences.setHideImageClicked(isHideImageClicked);
|
||||
preferences.setHideVideoClicked(isHideVideoClicked);
|
||||
actions.hideImages(preferences.getHideImageClicked());
|
||||
dismiss();
|
||||
});
|
||||
|
||||
binding.hideVideo.setOnClickListener(v -> {
|
||||
|
||||
if (!preferences.getHideVideoClicked() && !preferences.getHideImageClicked()) {
|
||||
isHideVideoClicked = true;
|
||||
binding.hideVideoImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_no_video_camera));
|
||||
binding.hideVideoTextview.setText(getContext().getResources().getString(R.string.show_video));
|
||||
binding.tickMarkHideVideo.setVisibility(View.VISIBLE);
|
||||
} else if (!preferences.getHideVideoClicked() && preferences.getHideImageClicked()) {
|
||||
isHideVideoClicked = true;
|
||||
isHideImageClicked = false;
|
||||
|
||||
binding.hideVideoImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_no_video_camera));
|
||||
binding.hideVideoTextview.setText(getContext().getResources().getString(R.string.show_video));
|
||||
binding.hideImagesImageview.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_camera));
|
||||
binding.hideImagesTextview.setText(getContext().getResources().getString(R.string.hide_images));
|
||||
binding.tickMarkHideImages.setVisibility(View.GONE);
|
||||
binding.tickMarkHideVideo.setVisibility(View.VISIBLE);
|
||||
|
||||
} else if (preferences.getHideVideoClicked() && !preferences.getHideImageClicked()) {
|
||||
isHideVideoClicked = false;
|
||||
binding.hideVideoImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_video_camera));
|
||||
binding.hideVideoTextview.setText(getContext().getResources().getString(R.string.hide_video));
|
||||
binding.tickMarkHideVideo.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
preferences.setHideVideoClicked(isHideVideoClicked);
|
||||
preferences.setHideImageClicked(isHideImageClicked);
|
||||
actions.hideVideos(preferences.getHideVideoClicked());
|
||||
dismiss();
|
||||
});
|
||||
|
||||
binding.selectMediaFolder.setOnClickListener(v -> {
|
||||
|
||||
actions.selectMediaFolder();
|
||||
dismiss();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
|
@ -22,11 +22,16 @@
|
|||
*/
|
||||
package com.owncloud.android.utils.theme;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
|
||||
/**
|
||||
* Utility class with methods for client side checkable theming.
|
||||
*/
|
||||
|
@ -43,4 +48,18 @@ public final class ThemeMenuUtils {
|
|||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
item.setTitle(newItemTitle);
|
||||
}
|
||||
|
||||
/**
|
||||
* tinting menu item color
|
||||
*
|
||||
* @param context
|
||||
* @param item the menu item object
|
||||
* @param color the color wanted as a color resource
|
||||
*/
|
||||
public static void tintMenuIcon(@NonNull Context context, @NonNull MenuItem item, int color) {
|
||||
Drawable normalDrawable = item.getIcon();
|
||||
Drawable wrapDrawable = DrawableCompat.wrap(normalDrawable);
|
||||
DrawableCompat.setTint(wrapDrawable, color);
|
||||
item.setIcon(wrapDrawable);
|
||||
}
|
||||
}
|
||||
|
|
50
app/src/main/res/drawable/ic_no_camera.xml
Normal file
50
app/src/main/res/drawable/ic_no_camera.xml
Normal file
|
@ -0,0 +1,50 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M12,17.237C12.677,17.237 13.321,17.099 13.91,16.855L12.717,15.663C12.485,15.711 12.246,15.737 12,15.737C10.067,15.737 8.5,14.171 8.5,12.237C8.5,12.212 8.5,12.186 8.5,12.161C8.502,11.94 8.53,11.726 8.572,11.517L7.382,10.327C7.138,10.916 7,11.56 7,12.237C7.003,14.997 9.24,17.234 12,17.237"
|
||||
android:strokeWidth="1"
|
||||
android:fillColor="#262626"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#00000000"/>
|
||||
<path
|
||||
android:pathData="M15.792,18.737L4,18.737C3.977,18.738 3.954,18.738 3.931,18.737C3.122,18.718 2.481,18.047 2.5,17.237L2.5,8.737C2.5,8.715 2.5,8.693 2.5,8.671C2.519,7.86 3.19,7.218 4,7.237L4.292,7.237L2.981,5.926C1.829,6.345 1,7.44 1,8.737L1,17.237C1,18.894 2.343,20.237 4,20.237L17.292,20.237L15.792,18.737Z"
|
||||
android:strokeWidth="1"
|
||||
android:fillColor="#262626"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#00000000"/>
|
||||
<path
|
||||
android:pathData="M20,9.737C20,9.185 19.553,8.737 19,8.737C18.447,8.737 18,9.185 18,9.737C18,10.29 18.447,10.737 19,10.737C19.553,10.737 20,10.29 20,9.737"
|
||||
android:strokeWidth="1"
|
||||
android:fillColor="#262626"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#00000000"/>
|
||||
<group>
|
||||
<clip-path
|
||||
android:pathData="M7.1211,3.237l15.8789,0l0,15.692l-15.8789,0z"/>
|
||||
<path
|
||||
android:pathData="M8.2441,4.737L15.8001,4.737L17.3001,7.237L20.0001,7.237L20.0641,7.237C20.8751,7.255 21.5171,7.926 21.5001,8.737L21.5001,17.237C21.5011,17.259 21.5011,17.282 21.5001,17.303C21.4961,17.494 21.4521,17.675 21.3831,17.84L22.4751,18.929C22.8061,18.447 23.0001,17.865 23.0001,17.237L23.0001,8.737C23.0001,7.081 21.6571,5.737 20.0001,5.737L18.2001,5.737L16.7001,3.237L7.3501,3.237L7.1211,3.618L8.2441,4.737Z"
|
||||
android:strokeWidth="1"
|
||||
android:fillColor="#262626"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#00000000"/>
|
||||
</group>
|
||||
<group>
|
||||
<clip-path
|
||||
android:pathData="M2.2825,2.0003l19.5504,0l0,19.474l-19.5504,0z"/>
|
||||
<path
|
||||
android:pathData="M20.5068,21.2741L2.5068,3.2741C2.2168,2.9981 2.2068,2.5381 2.4838,2.2481C2.4908,2.2401 2.4988,2.2321 2.5068,2.2241C2.7838,1.9341 3.2438,1.9241 3.5338,2.2011L3.5568,2.2241L21.6078,20.2241C21.8978,20.5001 21.9088,20.9581 21.6338,21.2481C21.6248,21.2571 21.6158,21.2661 21.6078,21.2741C21.2888,21.5411 20.8248,21.5411 20.5068,21.2741"
|
||||
android:strokeWidth="1"
|
||||
android:fillColor="#262626"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#00000000"/>
|
||||
</group>
|
||||
<path
|
||||
android:pathData="M12.2842,8.7653C13.9832,8.9053 15.3272,10.2453 15.4712,11.9433L16.8742,13.3433C16.9562,12.9883 17.0002,12.6183 17.0002,12.2373C17.0002,9.4753 14.7622,7.2373 12.0002,7.2373C11.6142,7.2373 11.2402,7.2823 10.8812,7.3663L12.2842,8.7653Z"
|
||||
android:strokeWidth="1"
|
||||
android:fillColor="#262626"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#00000000"/>
|
||||
</vector>
|
12
app/src/main/res/drawable/ic_no_video_camera.xml
Normal file
12
app/src/main/res/drawable/ic_no_video_camera.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M4.1,2.45C4.4,2.15 4.85,2.15 5.15,2.45L5.15,2.45L23.2,20.45C23.5,20.75 23.5,21.2 23.2,21.5C23.05,21.65 22.85,21.7 22.65,21.7C22.45,21.7 22.25,21.65 22.1,21.5L22.1,21.5L4.1,3.5C3.8,3.2 3.8,2.75 4.1,2.45ZM3.4,5L4.9,6.5L3.5,6.5L3.5,17C3.5,17.85 4.15,18.5 5,18.5L5,18.5L16.9,18.5L18.2,19.75C17.8,19.9 17.4,20 17,20L17,20L5,20C3.35,20 2,18.65 2,17L2,17L2,10.5L0.5,10.5L0.5,6.5L2,6.5L2,5L3.4,5ZM20,5L20,8.8L21.8,7L23.5,7L23.5,17L21.8,17L18.5,13.7L18.5,6.5L11.3,6.5L9.8,5L20,5ZM22,8.9L20,10.9L20,13.1L22,15.1L22,8.9Z"
|
||||
android:strokeWidth="1"
|
||||
android:fillColor="#262626"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#00000000"/>
|
||||
</vector>
|
12
app/src/main/res/drawable/ic_tick.xml
Normal file
12
app/src/main/res/drawable/ic_tick.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M9,20.215L1.695,12.91C1.2205,12.4202 1.2262,11.6405 1.7077,11.1577C2.1892,10.6748 2.9689,10.6669 3.46,11.14L9,16.68L21,4.68C21.4944,4.238 22.248,4.2591 22.7169,4.7281C23.1859,5.197 23.207,5.9506 22.765,6.445L9,20.215Z"
|
||||
android:strokeWidth="1"
|
||||
android:fillColor="#262626"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#00000000"/>
|
||||
</vector>
|
12
app/src/main/res/drawable/ic_video_camera.xml
Normal file
12
app/src/main/res/drawable/ic_video_camera.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M20,5L20,8.8L21.8,7L23.5,7L23.5,17L21.8,17L20,15.2L20,17C20,18.65 18.65,20 17,20L17,20L5,20C3.35,20 2,18.65 2,17L2,17L2,10.5L0.5,10.5L0.5,6.5L2,6.5L2,5L20,5ZM18.5,6.5L3.5,6.5L3.5,17C3.5,17.85 4.15,18.5 5,18.5L5,18.5L17,18.5C17.85,18.5 18.5,17.85 18.5,17L18.5,17L18.5,6.5ZM9,9.25L14,12.5L9,15.75L9,9.25ZM22,8.9L20,10.9L20,13.1L22,15.1L22,8.9Z"
|
||||
android:strokeWidth="1"
|
||||
android:fillColor="#262626"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#00000000"/>
|
||||
</vector>
|
128
app/src/main/res/layout/fragment_gallery_bottom_sheet.xml
Normal file
128
app/src/main/res/layout/fragment_gallery_bottom_sheet.xml
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/bg_default"
|
||||
android:paddingBottom="@dimen/standard_half_padding">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/hideImages"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/standard_padding"
|
||||
android:paddingTop="@dimen/standard_padding"
|
||||
android:paddingRight="@dimen/standard_padding"
|
||||
android:paddingBottom="@dimen/standard_half_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/hideImagesImageview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/ic_camera"
|
||||
app:tint="@color/primary" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/hideImagesTextview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="@dimen/standard_margin"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:layout_toRightOf="@id/hideImagesImageview"
|
||||
android:text="@string/hide_images"
|
||||
android:textColor="@color/text_color"
|
||||
android:textSize="@dimen/bottom_sheet_text_size" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/tickMarkHideImages"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/ic_tick"
|
||||
android:visibility="gone"
|
||||
app:tint="@color/primary"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/hideVideo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/standard_padding"
|
||||
android:paddingTop="@dimen/standard_half_padding"
|
||||
android:paddingRight="@dimen/standard_padding"
|
||||
android:paddingBottom="@dimen/standard_half_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/hideVideoImageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/ic_video_camera"
|
||||
app:tint="@color/primary" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/hideVideoTextview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="@dimen/standard_margin"
|
||||
android:layout_toRightOf="@id/hideVideoImageView"
|
||||
android:text="@string/hide_video"
|
||||
android:textColor="@color/text_color"
|
||||
android:textSize="@dimen/bottom_sheet_text_size" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/tickMarkHideVideo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/ic_tick"
|
||||
android:visibility="gone"
|
||||
app:tint="@color/primary"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/selectMediaFolder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/standard_padding"
|
||||
android:paddingTop="@dimen/standard_half_padding"
|
||||
android:paddingRight="@dimen/standard_padding"
|
||||
android:paddingBottom="@dimen/standard_half_padding">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/nav_photos"
|
||||
app:tint="@color/primary" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="@dimen/standard_margin"
|
||||
android:text="@string/select_media_folder"
|
||||
android:textColor="@color/text_color"
|
||||
android:textSize="@dimen/bottom_sheet_text_size" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
13
app/src/main/res/menu/fragment_gallery_three_dots.xml
Normal file
13
app/src/main/res/menu/fragment_gallery_three_dots.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_three_dot_icon"
|
||||
android:contentDescription="@string/more"
|
||||
android:orderInCategory="1"
|
||||
android:title="@string/more"
|
||||
app:showAsAction="always"
|
||||
android:icon="@drawable/ic_dots_vertical"/>
|
||||
|
||||
</menu>
|
|
@ -904,4 +904,11 @@
|
|||
<item quantity="one">%d ausgewählt</item>
|
||||
<item quantity="other">%d ausgewählt</item>
|
||||
</plurals>
|
||||
<string name="hide_images">Bilder ausblenden</string>
|
||||
<string name="show_images">Bilder anzeigen</string>
|
||||
<string name="hide_video">Videos ausblenden</string>
|
||||
<string name="show_video">Videos anzeigen</string>
|
||||
<string name="select_media_folder">Den Ordner \"Medien\" auswählen</string>
|
||||
<string name="choose_location">Speicherort wählen</string>
|
||||
<string name="common_select">Auswählen</string>
|
||||
</resources>
|
||||
|
|
|
@ -1008,4 +1008,11 @@
|
|||
<string name="pdf_zoom_tip">Tap on a page to zoom in</string>
|
||||
<string name="storage_permission_full_access">Full access</string>
|
||||
<string name="storage_permission_media_read_only">Media read-only</string>
|
||||
<string name="hide_images">Hide images</string>
|
||||
<string name="show_images">Show images</string>
|
||||
<string name="hide_video">Hide video</string>
|
||||
<string name="show_video">Show video</string>
|
||||
<string name="select_media_folder">Select the \"Media\" folder</string>
|
||||
<string name="choose_location">Choose location</string>
|
||||
<string name="common_select">Select</string>
|
||||
</resources>
|
||||
|
|
|
@ -5,3 +5,5 @@ NC_TEST_SERVER_PASSWORD=test
|
|||
android.enableJetifier=true
|
||||
android.useAndroidX=true
|
||||
#android.debug.obsoleteApi=true
|
||||
#Fix for --> Out of memory: Java heap space.
|
||||
org.gradle.jvmargs=-Xmx2048m
|
||||
|
|
Loading…
Reference in a new issue