Skip to content
Open
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
18 changes: 18 additions & 0 deletions app/src/main/java/com/nmc/android/utils/DisplayUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.nmc.android.utils

import android.content.Context
import android.content.res.Configuration
import com.owncloud.android.R

object DisplayUtils {

@JvmStatic
fun isShowDividerForList(context: Context): Boolean = isTablet(context) || isLandscapeOrientation(context)

@JvmStatic
fun isTablet(context: Context): Boolean = context.resources.getBoolean(R.bool.isTablet)

@JvmStatic
fun isLandscapeOrientation(context: Context): Boolean =
context.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import android.content.IntentFilter
import android.content.res.Resources
import android.os.Bundle
import android.os.Parcelable
import android.util.TypedValue
import android.view.ActionMode
import android.view.Menu
import android.view.MenuItem
Expand Down Expand Up @@ -54,6 +55,7 @@ import com.owncloud.android.utils.PathUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.io.File
import java.util.Locale
import javax.inject.Inject

@Suppress("Detekt.TooManyFunctions")
Expand Down Expand Up @@ -477,6 +479,32 @@ open class FolderPickerActivity :
OperationsService.ACTION_MOVE_FILE
)
}
adjustButtonTexts()
}
}

// NMC-4239 fix
// adjust button german texts in portrait mode
private fun adjustButtonTexts(){
if (!com.nmc.android.utils.DisplayUtils.isTablet(this)
&& !com.nmc.android.utils.DisplayUtils.isLandscapeOrientation(this)
) {
if (Locale.getDefault().language.equals(Locale.GERMAN.language)
|| Locale.getDefault().language.equals(Locale.GERMANY.language)
) {
folderPickerBinding.folderPickerBtnCopy.setTextSize(
TypedValue.COMPLEX_UNIT_PX,
getResources().getDimension(R.dimen.txt_size_11sp)
)
folderPickerBinding.folderPickerBtnMove.setTextSize(
TypedValue.COMPLEX_UNIT_PX,
getResources().getDimension(R.dimen.txt_size_11sp)
)
folderPickerBinding.folderPickerBtnCancel.setTextSize(
TypedValue.COMPLEX_UNIT_PX,
getResources().getDimension(R.dimen.txt_size_11sp)
);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.os.Environment
import android.util.TypedValue
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
Expand Down Expand Up @@ -53,6 +54,7 @@ import com.owncloud.android.ui.fragment.localfilelist.LocalFileListListener
import com.owncloud.android.utils.FileSortOrder
import com.owncloud.android.utils.PermissionUtil.checkStoragePermission
import java.io.File
import java.util.Locale
import javax.inject.Inject

class UploadFilesActivity :
Expand Down Expand Up @@ -180,6 +182,7 @@ class UploadFilesActivity :
fileListFragment = supportFragmentManager.findFragmentByTag(LOCAL_FILES_LIST_TAG) as LocalFileListFragment

setupButtons()
updateButtonTextSize()
uploadBehaviour = UploadBehaviourSelector(this, binding, preferences).apply {
setup(themeUtils.getDefaultDisplayNameForRootFolder(this@UploadFilesActivity))
}
Expand All @@ -193,6 +196,28 @@ class UploadFilesActivity :
Log_OC.d(TAG, "onCreate() end")
}

private fun updateButtonTextSize(){
// reduce the button text size so that the text doesn't go to next line
// this should only happen for GERMAN language
// and device should not be tablet and should be in portrait mode
if (!com.nmc.android.utils.DisplayUtils.isTablet(this)
&& !com.nmc.android.utils.DisplayUtils.isLandscapeOrientation(this)
) {
if (Locale.getDefault().language.equals(Locale.GERMAN.language)
|| Locale.getDefault().language.equals(Locale.GERMANY.language)
) {
binding.uploadFilesBtnUpload.setTextSize(
TypedValue.COMPLEX_UNIT_PX,
resources.getDimension(R.dimen.txt_size_13sp)
)
binding.uploadFilesBtnCancel.setTextSize(
TypedValue.COMPLEX_UNIT_PX,
resources.getDimension(R.dimen.txt_size_13sp)
)
}
}
}

private fun restoreState(savedInstanceState: Bundle?) {
intent.extras?.let { extras ->
isFolderPickerMode = extras.getBoolean(KEY_LOCAL_FOLDER_PICKER_MODE, false)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2018 Andy Scherzinger <info@andy-scherzinger.de>
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
*/
package com.owncloud.android.ui.decoration;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.view.View;

import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.RecyclerView;

/**
* DividerItemDecoration based on {@link DividerItemDecoration} adding a 72dp left padding.
*/
public class SimpleListItemDividerDecoration extends DividerItemDecoration {
private static final int[] ATTRS = new int[]{android.R.attr.listDivider};

private final Rect bounds = new Rect();
private Drawable divider;
private int leftPadding = 0;
private boolean hasFooter;

/**
* Default divider will be used
*/
public SimpleListItemDividerDecoration(Context context) {
super(context, DividerItemDecoration.VERTICAL);
final TypedArray styledAttributes = context.obtainStyledAttributes(ATTRS);
divider = styledAttributes.getDrawable(0);
leftPadding = Math.round(72 * (context.getResources().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT));
styledAttributes.recycle();
}

/**
* Custom divider will be used
*
* @param hasFooter if recyclerview has footer and no divider should be shown for footer then pass true else false
*/
public SimpleListItemDividerDecoration(Context context, int resId, boolean hasFooter) {
super(context, DividerItemDecoration.VERTICAL);
this.hasFooter = hasFooter;
divider = ContextCompat.getDrawable(context, resId);
}

@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
canvas.save();
final int right;
//noinspection AndroidLintNewApi - NewApi lint fails to handle overrides.
if (parent.getClipToPadding()) {
right = parent.getWidth() - parent.getPaddingRight();
canvas.clipRect(leftPadding, parent.getPaddingTop(), right,
parent.getHeight() - parent.getPaddingBottom());
} else {
right = parent.getWidth();
}

int childCount = parent.getChildCount();

if (hasFooter) {
childCount = childCount - 1;
}

for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
parent.getDecoratedBoundsWithMargins(child, bounds);
final int bottom = bounds.bottom + Math.round(child.getTranslationY());
final int top = bottom - 1;

if (divider != null) {
divider.setBounds(leftPadding, top, right, bottom);
divider.draw(canvas);
}
}
canvas.restore();
}
}
Loading
Loading