Add Font Awesome

Using https://github.com/finnmglas/fontawesome-android
This commit is contained in:
Finn M Glas 2020-05-20 22:05:08 +02:00
parent 92e8cbd450
commit 7cd450f897
5 changed files with 102 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,93 @@
package com.finnmglas.launcher // replace with your package
// On GitHub: https://github.com/finnmglas/fontawesome-android
import android.content.Context
import android.graphics.Typeface
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView
class FontAwesomeSolid : AppCompatTextView {
constructor(
context: Context?,
attrs: AttributeSet?,
defStyle: Int
) : super(context, attrs, defStyle) {
init()
}
constructor(context: Context?, attrs: AttributeSet?) : super(
context,
attrs
) {
init()
}
constructor(context: Context?) : super(context) {
init()
}
private fun init() {
typeface = Typeface.createFromAsset(
context.assets,
"fontawesome/fa-solid-900.ttf"
)
}
}
class FontAwesomeRegular : AppCompatTextView {
constructor(
context: Context?,
attrs: AttributeSet?,
defStyle: Int
) : super(context, attrs, defStyle) {
init()
}
constructor(context: Context?, attrs: AttributeSet?) : super(
context,
attrs
) {
init()
}
constructor(context: Context?) : super(context) {
init()
}
private fun init() {
typeface = Typeface.createFromAsset(
context.assets,
"fontawesome/fa-regular-400.ttf"
)
}
}
class FontAwesomeBrand : AppCompatTextView {
constructor(
context: Context?,
attrs: AttributeSet?,
defStyle: Int
) : super(context, attrs, defStyle) {
init()
}
constructor(context: Context?, attrs: AttributeSet?) : super(
context,
attrs
) {
init()
}
constructor(context: Context?) : super(context) {
init()
}
private fun init() {
typeface = Typeface.createFromAsset(
context.assets,
"fontawesome/fa-brands-400.ttf"
)
}
}

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="fas_bars" translatable="false">&#xf0c9;</string>
<string name="fas_home" translatable="false">&#xf015;</string>
<string name="fas_globe" translatable="false">&#xf0ac;</string>
<string name="fas_star" translatable="false">&#xf005;</string>
<string name="far_star" translatable="false">&#xf005;</string>
</resources>