diff --git a/app/src/main/java/com/nextcloud/client/media/NextcloudExoPlayer.kt b/app/src/main/java/com/nextcloud/client/media/NextcloudExoPlayer.kt index 283f4e56ba04..443164a53efb 100644 --- a/app/src/main/java/com/nextcloud/client/media/NextcloudExoPlayer.kt +++ b/app/src/main/java/com/nextcloud/client/media/NextcloudExoPlayer.kt @@ -42,7 +42,9 @@ object NextcloudExoPlayer { .setMediaSourceFactory(mediaSourceFactory) .setAudioAttributes(AudioAttributes.DEFAULT, true) .setHandleAudioBecomingNoisy(true) - .setSeekForwardIncrementMs(FIVE_SECONDS_IN_MILLIS) + // NMC-3192 Fix + .setSeekBackIncrementMs(2 * FIVE_SECONDS_IN_MILLIS) + .setSeekForwardIncrementMs(2 * FIVE_SECONDS_IN_MILLIS) .build() } } diff --git a/app/src/main/java/com/nextcloud/utils/ShortcutUtil.kt b/app/src/main/java/com/nextcloud/utils/ShortcutUtil.kt index 439d2b6c75eb..b738af5faccf 100644 --- a/app/src/main/java/com/nextcloud/utils/ShortcutUtil.kt +++ b/app/src/main/java/com/nextcloud/utils/ShortcutUtil.kt @@ -16,6 +16,7 @@ import android.graphics.Bitmap import android.graphics.Canvas import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.Drawable +import androidx.core.content.ContextCompat import androidx.core.content.pm.ShortcutInfoCompat import androidx.core.content.pm.ShortcutManagerCompat import androidx.core.graphics.drawable.IconCompat @@ -59,10 +60,13 @@ class ShortcutUtil @Inject constructor(private val mContext: Context) { icon = IconCompat.createWithAdaptiveBitmap(thumbnail) } else if (file.isFolder) { val isAutoUploadFolder = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, user) - val isDarkModeActive = syncedFolderProvider.preferences.isDarkModeEnabled val overlayIconId = file.getFileOverlayIconId(isAutoUploadFolder) - val drawable = MimeTypeUtil.getFileIcon(isDarkModeActive, overlayIconId, mContext, viewThemeUtils) + // NMC Customization: No overlay icon will be used. Directly using folder icons + val drawable = ContextCompat.getDrawable(mContext, overlayIconId) ?: MimeTypeUtil.getDefaultFolderIcon( + mContext, + viewThemeUtils + ) val bitmapIcon = drawable.toBitmap() icon = IconCompat.createWithBitmap(bitmapIcon) } else { diff --git a/app/src/main/java/com/nmc/android/utils/KeyboardUtils.java b/app/src/main/java/com/nmc/android/utils/KeyboardUtils.java new file mode 100644 index 000000000000..ec43ac2dd3a8 --- /dev/null +++ b/app/src/main/java/com/nmc/android/utils/KeyboardUtils.java @@ -0,0 +1,21 @@ +package com.nmc.android.utils; + +import android.app.Activity; +import android.content.Context; +import android.view.View; +import android.view.inputmethod.InputMethodManager; + +public class KeyboardUtils { + + public static void showSoftKeyboard(Context context, View view) { + view.requestFocus(); + InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); + } + + public static void hideKeyboardFrom(Context context, View view) { + view.clearFocus(); + InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/owncloud/android/media/MediaControlView.kt b/app/src/main/java/com/owncloud/android/media/MediaControlView.kt index 25747c3f1bd0..984ab1bf7593 100644 --- a/app/src/main/java/com/owncloud/android/media/MediaControlView.kt +++ b/app/src/main/java/com/owncloud/android/media/MediaControlView.kt @@ -353,5 +353,7 @@ class MediaControlView(context: Context, attrs: AttributeSet?) : companion object { private val TAG = MediaControlView::class.java.getSimpleName() private const val SHOW_PROGRESS = 1 + // NMC-3192 Fix + private const val FIVE_SECONDS_IN_MILLIS = 5000 } } diff --git a/app/src/main/java/com/owncloud/android/ui/activity/EditorWebView.java b/app/src/main/java/com/owncloud/android/ui/activity/EditorWebView.java index d1f75389a8cd..8e57ff921917 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/EditorWebView.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/EditorWebView.java @@ -40,6 +40,8 @@ import javax.inject.Inject; +import androidx.core.content.ContextCompat; + public abstract class EditorWebView extends ExternalSiteWebView { public static final int REQUEST_LOCAL_FILE = 101; public ValueCallback uploadMessage; @@ -235,8 +237,8 @@ protected void setThumbnailView(final User user) { boolean isAutoUploadFolder = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, user); Integer overlayIconId = file.getFileOverlayIconId(isAutoUploadFolder); - LayerDrawable drawable = MimeTypeUtil.getFileIcon(preferences.isDarkModeEnabled(), overlayIconId, this, viewThemeUtils); - binding.thumbnail.setImageDrawable(drawable); + // NMC Customization: No overlay icon will be used. Directly using folder icons + binding.thumbnail.setImageDrawable(ContextCompat.getDrawable(this, overlayIconId)); } else { if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file)) && file.getRemoteId() != null) { // Thumbnail in cache? diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index 868513da42f2..c58f81b943fd 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -130,6 +130,7 @@ import com.owncloud.android.utils.MimeTypeUtil; import com.owncloud.android.utils.PermissionUtil; import com.owncloud.android.utils.PushUtils; +import com.nmc.android.utils.KeyboardUtils; import com.owncloud.android.utils.StringUtils; import com.owncloud.android.utils.theme.CapabilityUtils; @@ -1064,6 +1065,8 @@ private void resetSearchAction() { private void popBack() { binding.fabMain.setImageResource(R.drawable.ic_plus); resetScrolling(true); + // hide the keyboard on back press if showing + KeyboardUtils.hideKeyboardFrom(this, binding.getRoot()); showSortListGroup(false); super.onBackPressed(); } diff --git a/app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java index 27f5237dc710..1e0efc315424 100755 --- a/app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java @@ -98,6 +98,7 @@ import java.util.Calendar; import java.util.List; import java.util.Stack; +import java.util.stream.Collectors; import javax.inject.Inject; @@ -758,6 +759,10 @@ private void populateDirectoryList() { if (mFile != null) { List files = getStorageManager().getFolderContent(mFile, false); + // NMC-2893 Task + // Filtering and showing only files which are folder + files = files.stream().filter(OCFile::isFolder).collect(Collectors.toList()); + if (files.isEmpty()) { setMessageForEmptyList(R.string.file_list_empty_headline, R.string.empty, R.drawable.uploads); diff --git a/app/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java index e51fd0869b4e..2419696f677a 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java @@ -39,6 +39,7 @@ import javax.inject.Inject; +import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; @@ -73,8 +74,8 @@ protected void onCreate(Bundle savedInstanceState) { boolean isAutoUploadFolder = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, optionalUser.get()); Integer overlayIconId = file.getFileOverlayIconId(isAutoUploadFolder); - LayerDrawable drawable = MimeTypeUtil.getFileIcon(preferences.isDarkModeEnabled(), overlayIconId, this, viewThemeUtils); - binding.shareFileIcon.setImageDrawable(drawable); + // NMC Customization: No overlay icon will be used. Directly using folder icons + binding.shareFileIcon.setImageDrawable(ContextCompat.getDrawable(this, overlayIconId)); } else { binding.shareFileIcon.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(), file.getFileName(), diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/ReceiveExternalFilesAdapter.kt b/app/src/main/java/com/owncloud/android/ui/adapter/ReceiveExternalFilesAdapter.kt index 11bbd4bf86ff..4ba839809bcd 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/ReceiveExternalFilesAdapter.kt +++ b/app/src/main/java/com/owncloud/android/ui/adapter/ReceiveExternalFilesAdapter.kt @@ -13,6 +13,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageView +import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView import com.nextcloud.client.account.User import com.owncloud.android.databinding.UploaderListItemLayoutBinding @@ -113,10 +114,9 @@ class ReceiveExternalFilesAdapter( private fun setupThumbnailForFolder(thumbnailImageView: ImageView, file: OCFile) { val isAutoUploadFolder = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, user) - val isDarkModeActive = syncedFolderProvider.preferences.isDarkModeEnabled val overlayIconId = file.getFileOverlayIconId(isAutoUploadFolder) - val icon = MimeTypeUtil.getFileIcon(isDarkModeActive, overlayIconId, context, viewThemeUtils) - thumbnailImageView.setImageDrawable(icon) + // NMC Customization: No overlay icon will be used. Directly using folder icons + thumbnailImageView.setImageDrawable(ContextCompat.getDrawable(context, overlayIconId)) } @Suppress("NestedBlockDepth") diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt b/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt index a158c8052948..b9ed0199af30 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt @@ -29,6 +29,7 @@ import com.nextcloud.client.account.UserAccountManager import com.nextcloud.client.core.AsyncRunner import com.nextcloud.client.di.Injectable import com.nextcloud.client.di.ViewModelFactory +import com.nmc.android.utils.KeyboardUtils import com.nextcloud.client.network.ClientFactory import com.owncloud.android.R import com.owncloud.android.databinding.ListFragmentBinding @@ -238,6 +239,8 @@ class UnifiedSearchFragment : private fun showFile(file: OCFile, showFileActions: Boolean) { activity.let { if (activity is FileDisplayActivity) { + // NMC: hide keyboard when user taps on any file to view + KeyboardUtils.hideKeyboardFrom(requireContext(), binding.root) val fda = activity as FileDisplayActivity fda.file = file @@ -298,6 +301,7 @@ class UnifiedSearchFragment : } override fun onQueryTextSubmit(query: String): Boolean { + KeyboardUtils.hideKeyboardFrom(requireContext(), binding.root) vm.setQuery(query) vm.initialQuery() return true diff --git a/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java b/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java index 106916fb6e93..9961f744db69 100644 --- a/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java +++ b/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java @@ -32,7 +32,6 @@ import android.graphics.Point; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; -import android.graphics.drawable.LayerDrawable; import android.net.Uri; import android.os.AsyncTask; import android.text.Spannable; @@ -105,6 +104,7 @@ import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.appcompat.widget.AppCompatDrawableManager; +import androidx.core.content.ContextCompat; import androidx.core.content.res.ResourcesCompat; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; @@ -865,11 +865,9 @@ public static void setThumbnail(OCFile file, stopShimmer(shimmerThumbnail, thumbnailView); boolean isAutoUploadFolder = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, user); - boolean isDarkModeActive = preferences.isDarkModeEnabled(); - Integer overlayIconId = file.getFileOverlayIconId(isAutoUploadFolder); - LayerDrawable fileIcon = MimeTypeUtil.getFileIcon(isDarkModeActive, overlayIconId, context, viewThemeUtils); - thumbnailView.setImageDrawable(fileIcon); + // NMC Customization: No overlay icon will be used. Directly using folder icons + thumbnailView.setImageDrawable(ContextCompat.getDrawable(context, overlayIconId)); } else { if (file.getRemoteId() != null && file.isPreviewAvailable()) { // Thumbnail in cache? diff --git a/app/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java b/app/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java index 5e11ec467c05..66dfc9579cd5 100644 --- a/app/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java +++ b/app/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java @@ -16,7 +16,6 @@ import android.net.Uri; import android.webkit.MimeTypeMap; -import com.nextcloud.android.common.ui.theme.utils.ColorRole; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.resources.files.model.ServerFileInterface; @@ -94,13 +93,8 @@ public static Drawable getFileTypeIcon(String mimetype, ViewThemeUtils viewThemeUtils) { if (context != null) { int iconId = MimeTypeUtil.getFileTypeIconId(mimetype, filename); - Drawable icon = ContextCompat.getDrawable(context, iconId); - - if (R.drawable.file_zip == iconId) { - viewThemeUtils.platform.tintPrimaryDrawable(context, icon); - } - - return icon; + //NMC Customization + return ContextCompat.getDrawable(context, iconId); } else { return null; } @@ -128,11 +122,13 @@ public static Drawable getDefaultFolderIcon(Context context, ViewThemeUtils view Drawable drawable = ContextCompat.getDrawable(context, R.drawable.folder); assert(drawable != null); - viewThemeUtils.platform.tintDrawable(context, drawable, ColorRole.PRIMARY); return drawable; } - public static LayerDrawable getFileIcon(Boolean isDarkModeActive, Integer overlayIconId, Context context, ViewThemeUtils viewThemeUtils) { + // NMC Note: This funtion won't be used in NMC as we are using different folder icons with inbuilt overlay. So this function is of no use for us. + // changed access to PRIVATE, in case if NC will use this function in more areas then we will get compile error which can be fixed by us + // so that UI won't be impacted. + private static LayerDrawable getFileIcon(Boolean isDarkModeActive, Integer overlayIconId, Context context, ViewThemeUtils viewThemeUtils) { Drawable folderDrawable = getDefaultFolderIcon(context, viewThemeUtils); assert(folderDrawable != null);