Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ public void setAutoUploadInit(boolean autoUploadInit) {

@Override
public int getUploaderBehaviour() {
return preferences.getInt(AUTO_PREF__UPLOADER_BEHAVIOR, 1);
// NMC Customization
return preferences.getInt(AUTO_PREF__UPLOADER_BEHAVIOR, 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import java.lang.ref.WeakReference;
import java.util.List;

import androidx.annotation.DimenRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
Expand Down Expand Up @@ -156,9 +157,19 @@ protected Void doInBackground(File... params) {
* @return int
*/
public static int getThumbnailDimension() {
return getThumbnailDimension(R.dimen.file_icon_size_grid);
}

/**
* Converts size of file icon from dp to pixel
* this function is required for custom thumbnail sizes
* @param thumbnailDimension dimension to be converted
* @return int
*/
public static int getThumbnailDimension(@DimenRes int thumbnailDimension) {
// Converts dp to pixel
Resources r = MainApp.getAppContext().getResources();
return Math.round(r.getDimension(R.dimen.file_icon_size_grid));
return Math.round(r.getDimension(thumbnailDimension));
}

/**
Expand Down Expand Up @@ -826,14 +837,25 @@ private enum Type {IMAGE, VIDEO}
private String mImageKey;
private final Context mContext;
private final ViewThemeUtils viewThemeUtils;
@DimenRes
private final int thumbnailDimension;

public MediaThumbnailGenerationTask(ImageView imageView,
Context context,
ViewThemeUtils viewThemeUtils) {
this(imageView, context, R.dimen.file_icon_size_grid, viewThemeUtils);
}

// constructor to generate thumbnails for the requested size
public MediaThumbnailGenerationTask(ImageView imageView,
Context context,
@DimenRes int thumbnailDimension,
ViewThemeUtils viewThemeUtils) {
// Use a WeakReference to ensure the ImageView can be garbage collected
mImageViewReference = new WeakReference<>(imageView);
mContext = context;
this.viewThemeUtils = viewThemeUtils;
this.thumbnailDimension = thumbnailDimension;
}

@Override
Expand All @@ -848,9 +870,9 @@ protected Bitmap doInBackground(Object... params) {
}

if (MimeTypeUtil.isImage(mFile)) {
thumbnail = doFileInBackground(mFile, Type.IMAGE);
thumbnail = doFileInBackground(mFile, Type.IMAGE, thumbnailDimension);
} else if (MimeTypeUtil.isVideo(mFile)) {
thumbnail = doFileInBackground(mFile, Type.VIDEO);
thumbnail = doFileInBackground(mFile, Type.VIDEO, thumbnailDimension);
}
}
} // the app should never break due to a problem with thumbnails
Expand Down Expand Up @@ -896,7 +918,7 @@ protected void onPostExecute(Bitmap bitmap) {
}
}

private Bitmap doFileInBackground(File file, Type type) {
private Bitmap doFileInBackground(File file, Type type, @DimenRes int thumbnailDimension) {
final String imageKey;

if (mImageKey != null) {
Expand All @@ -912,7 +934,7 @@ private Bitmap doFileInBackground(File file, Type type) {
if (thumbnail == null) {

if (Type.IMAGE == type) {
int px = getThumbnailDimension();
int px = getThumbnailDimension(thumbnailDimension);

Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(file.getAbsolutePath(), px, px);

Expand All @@ -938,7 +960,7 @@ private Bitmap doFileInBackground(File file, Type type) {

if (thumbnail != null) {
// Scale down bitmap if too large.
int px = getThumbnailDimension();
int px = getThumbnailDimension(thumbnailDimension);
int width = thumbnail.getWidth();
int height = thumbnail.getHeight();
int max = Math.max(width, height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ public void onCreate(Bundle savedInstanceState) {

// file upload spinner
List<String> behaviours = new ArrayList<>();
behaviours.add(getString(R.string.uploader_upload_files_behaviour_move_to_nextcloud_folder,
themeUtils.getDefaultDisplayNameForRootFolder(this)));
// Not required this option for NMC
// behaviours.add(getString(R.string.uploader_upload_files_behaviour_move_to_nextcloud_folder,
// themeUtils.getDefaultDisplayNameForRootFolder(this)));
behaviours.add(getString(R.string.uploader_upload_files_behaviour_only_upload));
behaviours.add(getString(R.string.uploader_upload_files_behaviour_upload_and_delete_from_source));

Expand All @@ -208,6 +209,19 @@ public void onCreate(Bundle savedInstanceState) {
behaviourAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
binding.uploadFilesSpinnerBehaviour.setAdapter(behaviourAdapter);
binding.uploadFilesSpinnerBehaviour.setSelection(localBehaviour);
// NMC Customization
binding.uploadFilesSpinnerBehaviour.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
// store behaviour
preferences.setUploaderBehaviour(binding.uploadFilesSpinnerBehaviour.getSelectedItemPosition());
}

@Override
public void onNothingSelected(AdapterView<?> adapterView) {

}
});

// setup the toolbar
setupToolbar();
Expand Down Expand Up @@ -272,7 +286,12 @@ public void showToolbarSpinner() {
private void fillDirectoryDropdown() {
File currentDir = mCurrentDir;
while (currentDir != null && currentDir.getParentFile() != null) {
mDirectories.add(currentDir.getName());
// NMC Customization
if (currentDir.getName().equals("0")) {
mDirectories.add(getResources().getString(R.string.storage_internal_storage));
} else {
mDirectories.add(currentDir.getName());
}
currentDir = currentDir.getParentFile();
}
mDirectories.add(File.separator);
Expand Down Expand Up @@ -503,15 +522,16 @@ public void onCheckAvailableSpaceFinish(boolean hasEnoughSpaceAvailable, String.

// set result code
switch (binding.uploadFilesSpinnerBehaviour.getSelectedItemPosition()) {
case 0: // move to nextcloud folder
// Not required for NMC
/*case 0: // move to nextcloud folder
setResult(RESULT_OK_AND_MOVE, data);
break;
break;*/

case 1: // only upload
case 0: // only upload
setResult(RESULT_OK_AND_DO_NOTHING, data);
break;

case 2: // upload and delete from source
case 1: // upload and delete from source
setResult(RESULT_OK_AND_DELETE, data);
break;

Expand Down Expand Up @@ -577,7 +597,8 @@ private void checkWritableFolder(File folder) {
int localBehaviour = preferences.getUploaderBehaviour();
binding.uploadFilesSpinnerBehaviour.setSelection(localBehaviour);
} else {
binding.uploadFilesSpinnerBehaviour.setSelection(1);
// NMC Customization: default select 0
binding.uploadFilesSpinnerBehaviour.setSelection(0);
textView.setText(new StringBuilder().append(getString(R.string.uploader_upload_files_behaviour))
.append(' ')
.append(getString(R.string.uploader_upload_files_behaviour_not_writable))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import android.view.ViewGroup
import android.widget.ImageButton
import android.widget.PopupMenu
import androidx.annotation.VisibleForTesting
import androidx.core.content.res.ResourcesCompat
import com.afollestad.sectionedrecyclerview.SectionedRecyclerViewAdapter
import com.afollestad.sectionedrecyclerview.SectionedViewHolder
import com.nextcloud.android.common.ui.theme.utils.ColorRole
import com.nextcloud.client.core.Clock
import com.owncloud.android.R
import com.owncloud.android.databinding.GridSyncItemBinding
Expand Down Expand Up @@ -335,6 +335,9 @@ class SyncedFolderAdapter(
MediaThumbnailGenerationTask(
holder.binding.thumbnail,
context,
// due to 512dp(NMC) thumb size there was scroll lagging in auto upload
// so for auto upload we have to use different thumb size (NMC-2589)
R.dimen.auto_upload_file_thumb_size,
viewThemeUtils
)

Expand Down Expand Up @@ -439,9 +442,16 @@ class SyncedFolderAdapter(

private fun setSyncButtonActiveIcon(syncStatusButton: ImageButton, enabled: Boolean) {
if (enabled) {
syncStatusButton.setImageDrawable(
viewThemeUtils.platform.tintDrawable(context, R.drawable.ic_cloud_sync_on, ColorRole.PRIMARY)
)
// NMC Customization theme color icon
val drawable = ResourcesCompat.getDrawable(context.resources, R.drawable.ic_cloud_sync_on, null)
drawable?.let {
syncStatusButton.setImageDrawable(
viewThemeUtils.platform.colorDrawable(
it,
ResourcesCompat.getColor(context.resources, R.color.primary, null)
)
)
}
} else {
syncStatusButton.setImageResource(R.drawable.ic_cloud_sync_off)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ class LocalStoragePathPickerDialogFragment :
Environment.getExternalStoragePublicDirectory(standardDirectory.name).absolutePath
)
}
val sdCard = getString(R.string.storage_internal_storage)
for (dir in FileStorageUtils.getStorageDirectories(requireActivity())) {
// NMC Customisation
if (internalStoragePaths.contains(dir)) {
addIfExists(storagePathItems, R.drawable.ic_sd_grey600, sdCard, dir)
val internalStorage = getString(R.string.storage_internal_storage)
addIfExists(storagePathItems, R.drawable.ic_sd_grey600, internalStorage, dir)
} else {
addIfExists(storagePathItems, R.drawable.ic_sd_grey600, File(dir).name, dir)
val sdCard = getString(R.string.storage_sd_card)
addIfExists(storagePathItems, R.drawable.ic_sd, sdCard, dir)
}
}
return storagePathItems
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ public Integer getUploadActionInteger() {
switch (uploadAction) {
case FileUploadWorker.LOCAL_BEHAVIOUR_FORGET:
return 0;
case FileUploadWorker.LOCAL_BEHAVIOUR_MOVE:
return 1;
// NMC customization: No required move
/*case FileUploadWorker.LOCAL_BEHAVIOUR_MOVE:
return 1;*/
case FileUploadWorker.LOCAL_BEHAVIOUR_DELETE:
return 2;
return 1;
}
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,7 @@
<string name="write_email">E-Mail senden</string>
<string name="wrong_storage_path">Speicherordner existiert nicht!</string>
<string name="wrong_storage_path_desc">Ursache könnte die Wiederherstellung einer Sicherungskopie auf einem anderen Gerät sein. Der Standard-Ordner wird jetzt wieder verwendet. Bitte überprüfen Sie die Einstellungen bezüglich des Speicherortes.</string>
<string name="storage_sd_card">SD-Karte</string>
<plurals name="hours">
<item quantity="one">%d Stunde</item>
<item quantity="other">%d Stunden</item>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-sw600dp/dims.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
<resources>
<integer name="media_grid_width">6</integer>
<dimen name="file_icon_size_grid">512dp</dimen>
<dimen name="auto_upload_file_thumb_size">512dp</dimen>
</resources>
6 changes: 4 additions & 2 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
<resources>
<string-array name="pref_behaviour_entries" translatable="false">
<item>@string/pref_behaviour_entries_keep_file</item>
<item>@string/pref_behaviour_entries_move</item>
<!-- not required for NMC -->
<!-- <item>@string/pref_behaviour_entries_move</item> -->
<item>@string/pref_behaviour_entries_delete_file</item>
</string-array>

<string-array name="pref_behaviour_entryValues" translatable="false">
<item>LOCAL_BEHAVIOUR_FORGET</item>
<item>LOCAL_BEHAVIOUR_MOVE</item>
<!-- not required for NMC -->
<!-- <item>LOCAL_BEHAVIOUR_MOVE</item> -->
<item>LOCAL_BEHAVIOUR_DELETE</item>
</string-array>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/dims.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
<dimen name="synced_folders_item_type_layout_right_end_margin">24dp</dimen>
<dimen name="synced_folders_recycler_view_layout_margin">-3dp</dimen>
<dimen name="synced_folders_control_width">80dp</dimen>
<dimen name="auto_upload_file_thumb_size">128dp</dimen>
<dimen name="bottom_sheet_text_size">16sp</dimen>
<dimen name="permission_dialog_text_size">18sp</dimen>
<dimen name="button_corner_radius">24dp</dimen>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,7 @@
<string name="delete_link">Delete Link</string>
<string name="share_settings">Settings</string>
<string name="common_confirm">Confirm</string>
<string name="storage_sd_card">SD Card</string>
<string name="strict_mode">Strict mode: no HTTP connection allowed!</string>
<string name="destination_filename">Destination filename</string>
<string name="suggest">Suggest</string>
Expand Down