-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from stefan-niedermann/rewrite-mentions-and-s…
…earch-highlight feat(markdown): Rewrite MentionsPlugin and SearchHighlightPlugin
- Loading branch information
Showing
50 changed files
with
1,403 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
markdown/src/main/java/it/niedermann/android/markdown/ThemeUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package it.niedermann.android.markdown | ||
|
||
import android.content.Context | ||
import android.content.res.ColorStateList | ||
import android.graphics.drawable.Drawable | ||
import com.nextcloud.android.common.ui.theme.MaterialSchemes | ||
import com.nextcloud.android.common.ui.theme.MaterialSchemes.Companion.fromColor | ||
import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase | ||
|
||
class ThemeUtils(schemes: MaterialSchemes) : ViewThemeUtilsBase(schemes) { | ||
|
||
fun getPrimary(context: Context): Int { | ||
return withScheme(context) { scheme -> scheme.primary } | ||
} | ||
|
||
fun getOnPrimary(context: Context): Int { | ||
return withScheme(context) { scheme -> scheme.onPrimary } | ||
} | ||
|
||
fun getSecondary(context: Context): Int { | ||
return withScheme(context) { scheme -> scheme.secondary } | ||
} | ||
|
||
fun getOnSecondary(context: Context): Int { | ||
return withScheme(context) { scheme -> scheme.onSecondary } | ||
} | ||
|
||
fun tintDrawable( | ||
context: Context, | ||
drawable: Drawable | ||
): Drawable { | ||
return withScheme(context) { scheme -> | ||
drawable.setTintList(ColorStateList.valueOf(scheme.onSurfaceVariant)) | ||
drawable | ||
} | ||
} | ||
|
||
companion object { | ||
private val cache = mutableMapOf<Int, ThemeUtils>() | ||
fun of(color: Int): ThemeUtils { | ||
return cache.computeIfAbsent(color) { | ||
ThemeUtils(fromColor(color)) | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.