Skip to content

Commit a512ae7

Browse files
committed
Customized theme of toolbar and action mode.
NMC-2138: Sort filter toolbar button customized. NMC-2035: Customized navigation view theme with drawer options. NMC-4150: fix no internet info box in image preview
1 parent 022f9c2 commit a512ae7

38 files changed

+681
-373
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,10 @@
353353
<activity
354354
android:name=".ui.activity.SettingsActivity"
355355
android:exported="false"
356-
android:theme="@style/PreferenceTheme" />
356+
android:theme="@style/Theme.ownCloud" />
357357
<activity
358358
android:name=".ui.preview.PreviewImageActivity"
359-
android:exported="false"
360-
android:theme="@style/Theme.ownCloud.Overlay" />
359+
android:exported="false" />
361360
<activity
362361
android:name=".ui.preview.PreviewMediaActivity"
363362
android:configChanges="orientation|screenLayout|screenSize|keyboardHidden"

app/src/main/java/com/nextcloud/client/logger/ui/LogsActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class LogsActivity : ToolbarActivity() {
6363

6464
setupToolbar()
6565
supportActionBar?.setDisplayHomeAsUpEnabled(true)
66+
// NMC Customization: show divider
67+
showHideDefaultToolbarDivider(true)
6668

6769
supportActionBar?.let {
6870
viewThemeUtils.files.themeActionBar(this, it, R.string.logs_title)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.nmc.android.utils
2+
3+
import android.graphics.drawable.Drawable
4+
import androidx.annotation.ColorInt
5+
import androidx.core.graphics.BlendModeColorFilterCompat
6+
import androidx.core.graphics.BlendModeCompat
7+
import androidx.core.graphics.drawable.DrawableCompat
8+
9+
object DrawableThemeUtils {
10+
@JvmStatic
11+
fun tintDrawable(drawable: Drawable, @ColorInt color: Int): Drawable {
12+
val wrap: Drawable = DrawableCompat.wrap(drawable)
13+
wrap.colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(
14+
color, BlendModeCompat.SRC_ATOP
15+
)
16+
return wrap
17+
}
18+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.nmc.android.utils
2+
3+
import android.content.Context
4+
import android.content.res.ColorStateList
5+
import android.graphics.Color
6+
import com.google.android.material.navigation.NavigationView
7+
import com.nextcloud.android.common.ui.util.buildColorStateList
8+
import com.owncloud.android.R
9+
10+
object NavigationViewThemeUtils {
11+
@JvmStatic
12+
@JvmOverloads
13+
fun colorNavigationView(
14+
context: Context,
15+
navigationView: NavigationView,
16+
colorIcons: Boolean = true
17+
) {
18+
if (navigationView.itemBackground != null) {
19+
navigationView.itemBackground?.setTintList(
20+
buildColorStateList(
21+
android.R.attr.state_checked to context.resources.getColor(R.color.nav_selected_bg_color, null),
22+
-android.R.attr.state_checked to Color.TRANSPARENT
23+
)
24+
)
25+
}
26+
navigationView.background.setTintList(
27+
ColorStateList.valueOf(
28+
context.resources.getColor(
29+
R.color.nav_bg_color,
30+
null
31+
)
32+
)
33+
)
34+
35+
val colorStateList =
36+
buildColorStateList(
37+
android.R.attr.state_checked to context.resources.getColor(R.color.nav_txt_selected_color, null),
38+
-android.R.attr.state_checked to context.resources.getColor(R.color.nav_txt_unselected_color, null),
39+
)
40+
41+
navigationView.itemTextColor = colorStateList
42+
if (colorIcons) {
43+
navigationView.itemIconTintList = colorStateList
44+
}
45+
}
46+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.nmc.android.utils
2+
3+
import android.content.Context
4+
import android.graphics.Typeface
5+
import android.text.Spannable
6+
import android.text.style.StyleSpan
7+
import androidx.appcompat.app.ActionBar
8+
import com.owncloud.android.R
9+
import com.owncloud.android.utils.StringUtils
10+
11+
object ToolbarThemeUtils {
12+
@JvmStatic
13+
fun setColoredTitle(context: Context, actionBar: ActionBar?, title: String) {
14+
if (actionBar != null) {
15+
val text: Spannable = StringUtils.getColorSpan(title, context.resources.getColor(R.color.fontAppbar, null))
16+
17+
//bold the magenta from MagentaCLOUD title
18+
if (title.contains(context.resources.getString(R.string.app_name))) {
19+
val textToBold = context.resources.getString(R.string.splashScreenBold)
20+
val indexStart = title.indexOf(textToBold)
21+
val indexEnd = indexStart + textToBold.length
22+
text.setSpan(StyleSpan(Typeface.BOLD), indexStart, indexEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
23+
}
24+
actionBar.title = text
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)