mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
324: Add EmojiCompat (#368)
* Added blockSetDetails event * fixes * added documentation * added tests * injected new use-case for updating title * injected new use-case for updating title * fixes * first working implementation * fixes * Fix * fixes * fixes in testing * fixes * test fixes * fixed tests * fixed tests * #324: open modal view as full screen * #324: include compat emoji * #324: add emoji text view * #324: graphik font, add debug cert * #324: add padding * #324: befor PR fixes * #324: fix gradle lib Co-authored-by: ubu <ubuphobos@gmail.com>
This commit is contained in:
parent
0ff89bcf87
commit
a8f9df82b6
10 changed files with 69 additions and 7 deletions
|
@ -117,6 +117,7 @@ dependencies {
|
|||
implementation applicationDependencies.tableView
|
||||
implementation applicationDependencies.permissionDisp
|
||||
implementation applicationDependencies.pickT
|
||||
implementation applicationDependencies.emojiCompat
|
||||
|
||||
implementation applicationDependencies.viewModel
|
||||
implementation applicationDependencies.viewModelExtensions
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package com.agileburo.anytype.app
|
||||
|
||||
import android.app.Application
|
||||
import androidx.core.provider.FontRequest
|
||||
import androidx.emoji.text.EmojiCompat
|
||||
import androidx.emoji.text.FontRequestEmojiCompatConfig
|
||||
import com.agileburo.anytype.BuildConfig
|
||||
import com.agileburo.anytype.R
|
||||
import com.agileburo.anytype.core_utils.tools.CrashlyticsTree
|
||||
import com.agileburo.anytype.di.common.ComponentManager
|
||||
import com.agileburo.anytype.di.main.*
|
||||
|
@ -27,10 +31,23 @@ class AndroidApplication : Application() {
|
|||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
setupEmojiCompat()
|
||||
setupTimber()
|
||||
setupStetho()
|
||||
}
|
||||
|
||||
private fun setupEmojiCompat() {
|
||||
val fontRequest = FontRequest(
|
||||
"com.google.android.gms.fonts",
|
||||
"com.google.android.gms",
|
||||
"Graphik Regular",
|
||||
R.array.certs
|
||||
)
|
||||
val config = FontRequestEmojiCompatConfig(this, fontRequest)
|
||||
EmojiCompat.init(config)
|
||||
}
|
||||
|
||||
private fun setupTimber() {
|
||||
if (BuildConfig.DEBUG)
|
||||
Timber.plant(Timber.DebugTree())
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package com.agileburo.anytype.ui.page.modals
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.lifecycle.Observer
|
||||
|
@ -19,6 +21,8 @@ import com.agileburo.anytype.presentation.page.picker.PageIconPickerViewModel
|
|||
import com.agileburo.anytype.presentation.page.picker.PageIconPickerViewModel.Contract
|
||||
import com.agileburo.anytype.presentation.page.picker.PageIconPickerViewModel.ViewState
|
||||
import com.agileburo.anytype.presentation.page.picker.PageIconPickerViewModelFactory
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import kotlinx.android.synthetic.main.fragment_page_icon_picker.*
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -80,6 +84,12 @@ class PageIconPickerFragment : BaseBottomSheetFragment() {
|
|||
savedInstanceState: Bundle?
|
||||
): View? = inflater.inflate(R.layout.fragment_page_icon_picker, container, false)
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
|
||||
setModalToFullScreenState(dialog)
|
||||
return dialog
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
|
@ -120,6 +130,11 @@ class PageIconPickerFragment : BaseBottomSheetFragment() {
|
|||
vm.state.observe(viewLifecycleOwner, Observer { render(it) })
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
dialog?.setOnShowListener { null }
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
fun render(state: ViewState) {
|
||||
when (state) {
|
||||
is ViewState.Success -> pageIconPickerAdapter.update(state.views)
|
||||
|
@ -136,6 +151,21 @@ class PageIconPickerFragment : BaseBottomSheetFragment() {
|
|||
componentManager().pageIconPickerSubComponent.release()
|
||||
}
|
||||
|
||||
private fun setModalToFullScreenState(dialog: BottomSheetDialog) =
|
||||
dialog.setOnShowListener { dialogInterface ->
|
||||
(dialogInterface as? BottomSheetDialog)?.let { bottomSheetDialog ->
|
||||
bottomSheetDialog.findViewById<FrameLayout>(com.google.android.material.R.id.design_bottom_sheet)
|
||||
?.let { bottomSheetView ->
|
||||
BottomSheetBehavior.from(bottomSheetView).apply {
|
||||
val lp = bottomSheetView.layoutParams
|
||||
lp.height = activity?.window?.decorView?.measuredHeight ?: 0
|
||||
bottomSheetView.layoutParams = lp
|
||||
state = BottomSheetBehavior.STATE_EXPANDED
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun newInstance(
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
<androidx.emoji.widget.EmojiTextView
|
||||
android:id="@+id/emoji"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="165dp"
|
||||
android:minHeight="300dp" />
|
||||
|
||||
</LinearLayout>
|
|
@ -1,5 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<font-family xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:fontProviderAuthority="com.google.android.gms.fonts"
|
||||
android:fontProviderCerts="@array/certs"
|
||||
android:fontProviderPackage="com.google.android.gms"
|
||||
android:fontProviderQuery="Graphik Regular">
|
||||
|
||||
<font
|
||||
android:font="@font/graphik_regular"
|
||||
|
|
|
@ -170,4 +170,9 @@
|
|||
<string name="menu_item_color">Color</string>
|
||||
<string name="menu_item_background">Background</string>
|
||||
|
||||
<!-- Non-valid certificate, need update -->
|
||||
<string-array name="certs">
|
||||
<item>MIIEqDCCA5CgAwIBAgIJA071MA0GCSqGSIb3DQEBBAUAMIGUMQsww...</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -19,6 +19,7 @@ ext {
|
|||
material_version = '1.1.0-beta02'
|
||||
fragment_version = "1.2.3"
|
||||
ktx_core_version = "1.2.0"
|
||||
emoji_compat_version = '1.1.0-beta01'
|
||||
|
||||
// Architecture Components
|
||||
lifecycle_version = '2.1.0'
|
||||
|
@ -96,6 +97,7 @@ ext {
|
|||
androidAnnotations: "androidx.annotation:annotation:$appcompat_version",
|
||||
betterLinkMovement: "me.saket:better-link-movement-method:$better_link_method_version",
|
||||
ktxCore: "androidx.core:core-ktx:$ktx_core_version",
|
||||
emojiCompat: "androidx.emoji:emoji-appcompat:$emoji_compat_version",
|
||||
|
||||
glide: "com.github.bumptech.glide:glide:$glide_version",
|
||||
glideCompiler: "com.github.bumptech.glide:compiler:$glide_version",
|
||||
|
|
|
@ -55,6 +55,7 @@ dependencies {
|
|||
implementation applicationDependencies.kotlin
|
||||
implementation applicationDependencies.coroutines
|
||||
implementation applicationDependencies.androidxCore
|
||||
implementation applicationDependencies.emojiCompat
|
||||
|
||||
implementation applicationDependencies.design
|
||||
implementation applicationDependencies.recyclerView
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
<androidx.emoji.widget.EmojiTextView
|
||||
android:id="@+id/emoji"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/emoji_color"
|
||||
android:textSize="22sp"
|
||||
android:gravity="center"
|
||||
tools:text="🎢" />
|
||||
|
||||
</FrameLayout>
|
Loading…
Add table
Add a link
Reference in a new issue