Skip to content

Commit b26516b

Browse files
committed
Filtering only folders and showing them as per NMC-2893 Task
Update UnifiedSearchFragment.kt. Commit id: 4fb3fb3 from branch bug/NMC-1652. NMC-2140: Tinting removed for folder and file icons and not overlaying icon for folders.
1 parent 3f9cf2a commit b26516b

File tree

13 files changed

+65
-32
lines changed

13 files changed

+65
-32
lines changed

app/src/main/java/com/nextcloud/client/media/NextcloudExoPlayer.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ object NextcloudExoPlayer {
4242
.setMediaSourceFactory(mediaSourceFactory)
4343
.setAudioAttributes(AudioAttributes.DEFAULT, true)
4444
.setHandleAudioBecomingNoisy(true)
45-
.setSeekForwardIncrementMs(FIVE_SECONDS_IN_MILLIS)
45+
// NMC-3192 Fix
46+
.setSeekBackIncrementMs(2 * FIVE_SECONDS_IN_MILLIS)
47+
.setSeekForwardIncrementMs(2 * FIVE_SECONDS_IN_MILLIS)
4648
.build()
4749
}
4850
}

app/src/main/java/com/nextcloud/utils/ShortcutUtil.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import android.content.Intent
1515
import android.graphics.Bitmap
1616
import android.graphics.Canvas
1717
import android.graphics.drawable.Drawable
18+
import androidx.core.content.ContextCompat
1819
import androidx.core.content.pm.ShortcutInfoCompat
1920
import androidx.core.content.pm.ShortcutManagerCompat
2021
import androidx.core.graphics.createBitmap
@@ -92,9 +93,12 @@ class ShortcutUtil @Inject constructor(private val mContext: Context) {
9293

9394
file.isFolder -> {
9495
val isAutoUploadFolder = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, user)
95-
val isDarkModeActive = syncedFolderProvider.preferences.isDarkModeEnabled
9696
val overlayIconId = file.getFileOverlayIconId(isAutoUploadFolder)
97-
val drawable = MimeTypeUtil.getFolderIcon(isDarkModeActive, overlayIconId, mContext, viewThemeUtils)
97+
// NMC Customization: No overlay icon will be used. Directly using folder icons
98+
val drawable = ContextCompat.getDrawable(mContext, overlayIconId) ?: MimeTypeUtil.getDefaultFolderIcon(
99+
mContext,
100+
viewThemeUtils
101+
)
98102
IconCompat.createWithBitmap(drawable.toBitmap())
99103
}
100104

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.nmc.android.utils;
2+
3+
import android.app.Activity;
4+
import android.content.Context;
5+
import android.view.View;
6+
import android.view.inputmethod.InputMethodManager;
7+
8+
public class KeyboardUtils {
9+
10+
public static void showSoftKeyboard(Context context, View view) {
11+
view.requestFocus();
12+
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
13+
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
14+
}
15+
16+
public static void hideKeyboardFrom(Context context, View view) {
17+
view.clearFocus();
18+
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
19+
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
20+
}
21+
}

app/src/main/java/com/owncloud/android/media/MediaControlView.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,5 +351,7 @@ class MediaControlView(context: Context, attrs: AttributeSet?) :
351351
companion object {
352352
private val TAG = MediaControlView::class.java.getSimpleName()
353353
private const val SHOW_PROGRESS = 1
354+
// NMC-3192 Fix
355+
private const val FIVE_SECONDS_IN_MILLIS = 5000
354356
}
355357
}

app/src/main/java/com/owncloud/android/ui/activity/EditorWebView.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343

4444
import javax.inject.Inject;
4545

46+
import androidx.core.content.ContextCompat;
47+
4648
public abstract class EditorWebView extends ExternalSiteWebView {
4749
public static final int REQUEST_LOCAL_FILE = 101;
4850
public ValueCallback<Uri[]> uploadMessage;
@@ -254,8 +256,8 @@ protected void setThumbnailView(final User user) {
254256
boolean isAutoUploadFolder = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, user);
255257

256258
Integer overlayIconId = file.getFileOverlayIconId(isAutoUploadFolder);
257-
LayerDrawable drawable = MimeTypeUtil.getFolderIcon(preferences.isDarkModeEnabled(), overlayIconId, this, viewThemeUtils);
258-
binding.thumbnail.setImageDrawable(drawable);
259+
// NMC Customization: No overlay icon will be used. Directly using folder icons
260+
binding.thumbnail.setImageDrawable(ContextCompat.getDrawable(this, overlayIconId));
259261
} else {
260262
if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file)) && file.getRemoteId() != null) {
261263
// Thumbnail in cache?

app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ import com.nextcloud.utils.extensions.lastFragment
8484
import com.nextcloud.utils.extensions.logFileSize
8585
import com.nextcloud.utils.fileNameValidator.FileNameValidator.checkFolderPath
8686
import com.nextcloud.utils.view.FastScrollUtils
87+
import com.nmc.android.utils.KeyboardUtils
8788
import com.owncloud.android.MainApp
8889
import com.owncloud.android.R
8990
import com.owncloud.android.databinding.FilesBinding
@@ -1244,6 +1245,8 @@ class FileDisplayActivity :
12441245
private fun popBack() {
12451246
binding.fabMain.setImageResource(R.drawable.ic_plus)
12461247
resetScrolling(true)
1248+
// NMC: hide the keyboard on back press if showing
1249+
KeyboardUtils.hideKeyboardFrom(this, binding.root)
12471250
showSortListGroup(false)
12481251
super.onBackPressed()
12491252
}

app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
import java.util.Stack;
101101
import java.util.concurrent.ExecutorService;
102102
import java.util.concurrent.Executors;
103+
import java.util.stream.Collectors;
103104

104105
import javax.inject.Inject;
105106

@@ -770,6 +771,10 @@ private void populateDirectoryList(OCFile file) {
770771

771772
List<OCFile> files = getStorageManager().getFolderContent(mFile, false);
772773

774+
// NMC-2893 Task
775+
// Filtering and showing only files which are folder
776+
files = files.stream().filter(OCFile::isFolder).collect(Collectors.toList());
777+
773778
if (files.isEmpty()) {
774779
setMessageForEmptyList(R.string.file_list_empty_headline, R.string.empty,
775780
R.drawable.uploads);

app/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
import javax.inject.Inject;
4141

42+
import androidx.core.content.ContextCompat;
4243
import androidx.fragment.app.Fragment;
4344
import androidx.fragment.app.FragmentTransaction;
4445

@@ -73,8 +74,8 @@ protected void onCreate(Bundle savedInstanceState) {
7374
boolean isAutoUploadFolder = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, optionalUser.get());
7475

7576
Integer overlayIconId = file.getFileOverlayIconId(isAutoUploadFolder);
76-
LayerDrawable drawable = MimeTypeUtil.getFolderIcon(preferences.isDarkModeEnabled(), overlayIconId, this, viewThemeUtils);
77-
binding.shareFileIcon.setImageDrawable(drawable);
77+
// NMC Customization: No overlay icon will be used. Directly using folder icons
78+
binding.shareFileIcon.setImageDrawable(ContextCompat.getDrawable(this, overlayIconId));
7879
} else {
7980
binding.shareFileIcon.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
8081
file.getFileName(),

app/src/main/java/com/owncloud/android/ui/adapter/ReceiveExternalFilesAdapter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import android.view.LayoutInflater
1313
import android.view.View
1414
import android.view.ViewGroup
1515
import android.widget.ImageView
16+
import androidx.core.content.ContextCompat
1617
import androidx.recyclerview.widget.RecyclerView
1718
import com.nextcloud.client.account.User
1819
import com.owncloud.android.databinding.UploaderListItemLayoutBinding
@@ -113,10 +114,9 @@ class ReceiveExternalFilesAdapter(
113114

114115
private fun setupThumbnailForFolder(thumbnailImageView: ImageView, file: OCFile) {
115116
val isAutoUploadFolder = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, user)
116-
val isDarkModeActive = syncedFolderProvider.preferences.isDarkModeEnabled
117117
val overlayIconId = file.getFileOverlayIconId(isAutoUploadFolder)
118-
val icon = MimeTypeUtil.getFolderIcon(isDarkModeActive, overlayIconId, context, viewThemeUtils)
119-
thumbnailImageView.setImageDrawable(icon)
118+
// NMC Customization: No overlay icon will be used. Directly using folder icons
119+
thumbnailImageView.setImageDrawable(ContextCompat.getDrawable(context, overlayIconId))
120120
}
121121

122122
@Suppress("NestedBlockDepth")

app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,9 +1940,11 @@ protected void handleSearchEvent(SearchEvent event) {
19401940
} else if (!isGridViewPreferred(mFile) && isGridEnabled()) {
19411941
switchToListView();
19421942
}
1943-
};
19441943

1945-
updateSortButton();
1944+
// NMC-4749 fix
1945+
// move the ui operation inside runnable to execute it on Main Thread
1946+
updateSortButton();
1947+
};
19461948

19471949
new Handler(Looper.getMainLooper()).post(switchViewsRunnable);
19481950

0 commit comments

Comments
 (0)