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
5 changes: 2 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,13 @@
android:name=".ui.activity.SettingsActivity"
android:enableOnBackInvokedCallback="false"
android:exported="false"
android:theme="@style/PreferenceTheme" />
android:theme="@style/Theme.ownCloud" />
<activity
android:name=".ui.preview.media.PreviewMediaActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:exported="false"
android:supportsPictureInPicture="true"
android:launchMode="singleTask"
android:theme="@style/Theme.ownCloud.Overlay" />
android:launchMode="singleTask" />
<activity
android:name="com.nextcloud.client.player.ui.audio.AudioPlayerActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class LogsActivity : ToolbarActivity() {

showActionBar(ActionBarStyle.Plain)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
// NMC Customization: show divider
showHideDefaultToolbarDivider(true)

supportActionBar?.let {
viewThemeUtils.files.themeActionBar(this, it, R.string.logs_title)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ fun highlightNavigationView(
bottomNavigationView: BottomNavigationView?,
menuItemId: Int
) {
drawerNavigationView?.setCheckedItem(menuItemId)
// NMC Customization: skip item check logic for logout
if (menuItemId != R.id.nav_logout) {
drawerNavigationView?.setCheckedItem(menuItemId)
}

bottomNavigationView?.let { bottomNav ->
val bottomNavItems = setOf(R.id.nav_assistant, R.id.nav_all_files, R.id.nav_favorites, R.id.nav_gallery)
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/com/nmc/android/utils/DrawableThemeUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.nmc.android.utils

import android.graphics.drawable.Drawable
import androidx.annotation.ColorInt
import androidx.core.graphics.BlendModeColorFilterCompat
import androidx.core.graphics.BlendModeCompat
import androidx.core.graphics.drawable.DrawableCompat

object DrawableThemeUtils {
@JvmStatic
fun tintDrawable(drawable: Drawable, @ColorInt color: Int): Drawable {
val wrap: Drawable = DrawableCompat.wrap(drawable)
wrap.colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(
color, BlendModeCompat.SRC_ATOP
)
return wrap
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.nmc.android.utils

import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
import com.google.android.material.navigation.NavigationView
import com.nextcloud.android.common.ui.util.buildColorStateList
import com.owncloud.android.R

object NavigationViewThemeUtils {
@JvmStatic
@JvmOverloads
fun colorNavigationView(
context: Context,
navigationView: NavigationView,
colorIcons: Boolean = true
) {
if (navigationView.itemBackground != null) {
navigationView.itemBackground?.setTintList(
buildColorStateList(
android.R.attr.state_checked to context.resources.getColor(R.color.nav_selected_bg_color, null),
-android.R.attr.state_checked to Color.TRANSPARENT
)
)
}
navigationView.background.setTintList(
ColorStateList.valueOf(
context.resources.getColor(
R.color.nav_bg_color,
null
)
)
)

val colorStateList =
buildColorStateList(
android.R.attr.state_checked to context.resources.getColor(R.color.nav_txt_selected_color, null),
-android.R.attr.state_checked to context.resources.getColor(R.color.nav_txt_unselected_color, null),
)

navigationView.itemTextColor = colorStateList
if (colorIcons) {
navigationView.itemIconTintList = colorStateList
}
}
}
27 changes: 27 additions & 0 deletions app/src/main/java/com/nmc/android/utils/ToolbarThemeUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.nmc.android.utils

import android.content.Context
import android.graphics.Typeface
import android.text.Spannable
import android.text.style.StyleSpan
import androidx.appcompat.app.ActionBar
import com.owncloud.android.R
import com.owncloud.android.utils.StringUtils

object ToolbarThemeUtils {
@JvmStatic
fun setColoredTitle(context: Context, actionBar: ActionBar?, title: String) {
if (actionBar != null) {
val text: Spannable = StringUtils.getColorSpan(title, context.resources.getColor(R.color.fontAppbar, null))

//bold the magenta from MagentaCLOUD title
if (title.contains(context.resources.getString(R.string.app_name))) {
val textToBold = context.resources.getString(R.string.splashScreenBold)
val indexStart = title.indexOf(textToBold)
val indexEnd = indexStart + textToBold.length
text.setSpan(StyleSpan(Typeface.BOLD), indexStart, indexEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
}
actionBar.title = text
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ public void networkAndServerConnectionListener(boolean isNetworkAndServerAvailab
refreshList();
}
} else {
if (this instanceof AudioPlayerActivity) {
if (this instanceof AudioPlayerActivity
// NMC-4150 fix
|| this instanceof PreviewMediaActivity) {
hideInfoBox();
} else {
showInfoBox(R.string.offline_mode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
Expand Down Expand Up @@ -1020,15 +1021,10 @@ private void setupActionBar() {
actionBar.setDisplayShowTitleEnabled(true);

if (getResources() == null) return;
Drawable menuIcon = ResourcesCompat.getDrawable(getResources(),
R.drawable.ic_arrow_back,
null);

if (menuIcon == null) return;
viewThemeUtils.androidx.themeActionBar(this,
actionBar,
getString(R.string.actionbar_settings),
menuIcon);
// custom color for back arrow for NMC
viewThemeUtils.files.themeActionBar(this, actionBar, getResources().getString(R.string.actionbar_settings));
// required for NMC
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.bg_default, null)));
}

private void launchDavDroidLogin() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class ShareActivity :
setupFileIcon(binding, file, user)
with(binding) {
shareFileName.text = getString(R.string.share_file, file.fileName)
viewThemeUtils.platform.colorViewBackground(shareHeaderDivider)
shareFileSize.text = HumanReadableFormatter.formatBytes(file.fileLength)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import com.google.android.material.card.MaterialCardView
import com.google.android.material.textview.MaterialTextView
import com.nextcloud.android.common.ui.theme.utils.ColorRole
import com.nextcloud.client.di.Injectable
import com.nextcloud.client.systembars.SystemBarBackgroundCallbacks
import com.nmc.android.utils.DrawableThemeUtils
import com.nmc.android.utils.ToolbarThemeUtils
import com.owncloud.android.R
import com.owncloud.android.datamodel.FileDataStorageManager
import com.owncloud.android.datamodel.OCFile
Expand All @@ -36,6 +37,7 @@ import com.owncloud.android.ui.activity.drawer.DrawerActivity
import com.owncloud.android.ui.fragment.OCFileListFragment
import com.owncloud.android.ui.fragment.SearchType
import com.owncloud.android.ui.navigation.model.ActionBarStyle
import com.owncloud.android.utils.StringUtils
import com.owncloud.android.utils.theme.ThemeUtils
import com.owncloud.android.utils.theme.ViewThemeUtils
import javax.inject.Inject
Expand All @@ -60,7 +62,7 @@ abstract class ToolbarActivity :
private lateinit var defaultToolbar: RelativeLayout
private lateinit var homeSearchToolbar: LinearLayout
private lateinit var homeSearchContainer: MaterialCardView

private lateinit var mDefaultToolbarDivider: View
private var appBar: AppBarLayout? = null
var previewImageView: ImageView? = null
private set
Expand Down Expand Up @@ -134,13 +136,16 @@ abstract class ToolbarActivity :
searchText = findViewById(R.id.search_text)
switchAccountButton = findViewById(R.id.switch_account_button)
notificationButton = findViewById(R.id.notification_button)
mDefaultToolbarDivider = findViewById(R.id.default_toolbar_divider)
toolbarSpinner = findViewById(R.id.toolbar_spinner)
}

private fun themeToolbarViews() {
viewThemeUtils.run {
material.themeToolbar(toolbar)
material.colorToolbarOverflowIcon(toolbar)
// custom color for overflow icon required for NMC
toolbar.overflowIcon?.let { icon ->
DrawableThemeUtils.tintDrawable(icon, resources.getColor(R.color.fontAppbar, null))
}
platform.themeStatusBar(this@ToolbarActivity)
material.colorMaterialTextButton(switchAccountButton)
material.themeSearchCardView(homeSearchContainer)
Expand Down Expand Up @@ -194,7 +199,10 @@ abstract class ToolbarActivity :

fun setActionBarTitle(title: String?) {
val actionBar = supportActionBar ?: return
title?.let { actionBar.title = it }
title?.let {
// custom styling for action bar title required for NMC
ToolbarThemeUtils.setColoredTitle(this, actionBar, it)
}
actionBar.setDisplayShowTitleEnabled(title != null)
}

Expand All @@ -203,8 +211,8 @@ abstract class ToolbarActivity :

fun updateToolbarSubtitle(subtitle: String) {
val actionBar = supportActionBar ?: return
actionBar.subtitle = subtitle
viewThemeUtils.androidx.themeActionBarSubtitle(this, actionBar)
// required for NMC
actionBar.subtitle = StringUtils.getColorSpan(subtitle, resources.getColor(R.color.fontAppbar, null))
}

fun clearToolbarSubtitle() {
Expand All @@ -229,27 +237,11 @@ abstract class ToolbarActivity :
private fun switchActionBar(style: ActionBarStyle) {
val appBar = appBar ?: return

viewThemeUtils.material.themeToolbar(toolbar)

when (style) {
ActionBarStyle.Search -> {
viewThemeUtils.platform.resetStatusBar(this)
setAppBarStateListAnimator(appBar, R.animator.appbar_elevation_off)
defaultToolbar.isVisible = false
homeSearchToolbar.isVisible = true
viewThemeUtils.material.themeSearchCardView(homeSearchContainer)
viewThemeUtils.material.themeSearchBarText(searchText)
}

ActionBarStyle.Plain -> {
setAppBarStateListAnimator(appBar, R.animator.appbar_elevation_on)
viewThemeUtils.platform.themeStatusBar(this)
defaultToolbar.isVisible = true
homeSearchToolbar.isVisible = false
}
}

SystemBarBackgroundCallbacks.apply(this, viewThemeUtils)
appBar.stateListAnimator = AnimatorInflater.loadStateListAnimator(appBar.context,
R.animator.appbar_elevation_on)
viewThemeUtils.platform.themeStatusBar(this)
defaultToolbar.visibility = View.VISIBLE
homeSearchToolbar.visibility = View.GONE
}

private fun setAppBarStateListAnimator(appBar: AppBarLayout, @AnimatorRes animatorId: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import com.nextcloud.utils.extensions.getSelectedMenuItemId
import com.nextcloud.utils.extensions.highlightNavigationView
import com.nextcloud.utils.extensions.setVisibleIf
import com.nextcloud.utils.mdm.MDMConfig
import com.nmc.android.utils.DrawableThemeUtils
import com.nmc.android.utils.NavigationViewThemeUtils
import com.owncloud.android.R
import com.owncloud.android.authentication.PassCodeManager
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl
Expand All @@ -57,7 +59,6 @@ import com.owncloud.android.ui.activity.drawer.externallinks.DrawerExternalLinks
import com.owncloud.android.ui.activity.drawer.externallinks.ExternalLinkOpener
import com.owncloud.android.ui.activity.drawer.externallinks.ExternalLinksSynchronizer
import com.owncloud.android.ui.activity.drawer.fragment.DrawerFragmentFinder
import com.owncloud.android.ui.activity.drawer.header.DrawerHeaderController
import com.owncloud.android.ui.activity.drawer.navigation.DrawerDeepLinkHandler
import com.owncloud.android.ui.activity.drawer.navigation.DrawerMenuFilter
import com.owncloud.android.ui.activity.drawer.navigation.DrawerMenuItemClickHandler
Expand Down Expand Up @@ -107,7 +108,6 @@ abstract class DrawerActivity :
private set

private var drawerLayout: DrawerLayout? = null
private var navigationViewHeader: View? = null
private var pendingRunnable: Runnable? = null
private lateinit var externalLinksSynchronizer: ExternalLinksSynchronizer

Expand All @@ -116,7 +116,6 @@ abstract class DrawerActivity :
private val externalLinkOpener = ExternalLinkOpener(this)
private val externalLinksMenu by lazy { DrawerExternalLinksMenu(this, externalLinkOpener) }
private val quotaController by lazy { DrawerQuotaController(this, externalLinkOpener) }
private val headerController by lazy { DrawerHeaderController(this, drawerNavigator) }
private val menuItemClickHandler by lazy { DrawerMenuItemClickHandler(this, drawerNavigator, externalLinksMenu) }
private val deepLinkHandler by lazy { DrawerDeepLinkHandler(this, drawerNavigator, menuItemClickHandler) }

Expand Down Expand Up @@ -238,9 +237,10 @@ abstract class DrawerActivity :
}

private fun setupDrawerNavigationView(navigationView: NavigationView, id: Int) {
viewThemeUtils.files.colorNavigationView(navigationView)
navigationViewHeader = navigationView.getHeaderView(0)
updateHeader()
// NMC Customization: theme navigation view
drawerNavigationView?.let {
NavigationViewThemeUtils.colorNavigationView(this, it)
}

navigationView.setNavigationItemSelectedListener { menuItem ->
drawerLayout?.closeDrawers()
Expand Down Expand Up @@ -281,7 +281,14 @@ abstract class DrawerActivity :
toggle.isDrawerIndicatorEnabled = true
toggle.isDrawerSlideAnimationEnabled = true
ResourcesCompat.getDrawable(resources, R.drawable.ic_arrow_back, null)?.let { backArrow ->
viewThemeUtils.platform.tintToolbarArrowDrawable(this, toggle, backArrow)
// custom color for back arrow required for NMC
toggle.setHomeAsUpIndicator(
DrawableThemeUtils.tintDrawable(
backArrow,
resources.getColor(R.color.fontAppbar, null)
)
)
toggle.drawerArrowDrawable.color = resources.getColor(R.color.fontAppbar, null)
}
}

Expand All @@ -290,11 +297,6 @@ abstract class DrawerActivity :
Handler(Looper.getMainLooper()).post(runnable)
pendingRunnable = null
}

fun updateHeader() {
val header = navigationViewHeader ?: return
headerController.update(header)
}
// endregion

// region Navigation
Expand All @@ -316,7 +318,8 @@ abstract class DrawerActivity :
fun <T : Fragment> getFragment(tag: String?, clazz: Class<T>): Optional<T> = fragmentFinder.getFragment(tag, clazz)

fun showBottomNavigationBar(show: Boolean) {
bottomNavigationView.setVisibleIf(show)
// NMC Customization: always hide bottom bar
bottomNavigationView.setVisibleIf(false)
}

protected fun handleDeepLink(uri: Uri) = deepLinkHandler.handle(uri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ object DrawerMenuFilter {

fun filter(menu: Menu, user: User, capability: OCCapability?, resources: Resources) {
capability?.let {
DrawerMenuUtil.filterTrashbinMenuItem(menu, it)
// NMC: trashbin icon is depending on capability due to this it doesn't appear in some of the devices
// so removing the check as we need this option always
// DrawerMenuUtil.filterTrashbinMenuItem(menu, it)
DrawerMenuUtil.filterActivityMenuItem(menu, it)
DrawerMenuUtil.filterGroupfoldersMenuItem(menu, it)
DrawerMenuUtil.filterAssistantMenuItem(menu, it, resources)
Expand Down
Loading
Loading