|
|
@ -7,8 +7,10 @@ import android.net.Uri |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
|
import android.util.DisplayMetrics |
|
|
|
import android.util.DisplayMetrics |
|
|
|
import android.view.LayoutInflater |
|
|
|
import android.view.LayoutInflater |
|
|
|
|
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.View |
|
|
|
import android.view.View |
|
|
|
import android.view.ViewGroup |
|
|
|
import android.view.ViewGroup |
|
|
|
|
|
|
|
import androidx.appcompat.widget.Toolbar |
|
|
|
import androidx.documentfile.provider.DocumentFile |
|
|
|
import androidx.documentfile.provider.DocumentFile |
|
|
|
import androidx.fragment.app.DialogFragment |
|
|
|
import androidx.fragment.app.DialogFragment |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
@ -33,6 +35,7 @@ import java.io.File |
|
|
|
import kotlin.coroutines.CoroutineContext |
|
|
|
import kotlin.coroutines.CoroutineContext |
|
|
|
|
|
|
|
|
|
|
|
class FontSelectDialog : DialogFragment(), |
|
|
|
class FontSelectDialog : DialogFragment(), |
|
|
|
|
|
|
|
Toolbar.OnMenuItemClickListener, |
|
|
|
CoroutineScope, |
|
|
|
CoroutineScope, |
|
|
|
FontAdapter.CallBack { |
|
|
|
FontAdapter.CallBack { |
|
|
|
lateinit var job: Job |
|
|
|
lateinit var job: Job |
|
|
@ -62,6 +65,8 @@ class FontSelectDialog : DialogFragment(), |
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
tool_bar.setTitle(R.string.select_font) |
|
|
|
tool_bar.setTitle(R.string.select_font) |
|
|
|
|
|
|
|
tool_bar.inflateMenu(R.menu.font_select) |
|
|
|
|
|
|
|
tool_bar.setOnMenuItemClickListener(this) |
|
|
|
adapter = FontAdapter(requireContext(), this) |
|
|
|
adapter = FontAdapter(requireContext(), this) |
|
|
|
recycler_view.layoutManager = LinearLayoutManager(context) |
|
|
|
recycler_view.layoutManager = LinearLayoutManager(context) |
|
|
|
recycler_view.adapter = adapter |
|
|
|
recycler_view.adapter = adapter |
|
|
@ -79,6 +84,27 @@ class FontSelectDialog : DialogFragment(), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onMenuItemClick(item: MenuItem?): Boolean { |
|
|
|
|
|
|
|
when (item?.itemId) { |
|
|
|
|
|
|
|
R.id.menu_default -> { |
|
|
|
|
|
|
|
val pf = parentFragment |
|
|
|
|
|
|
|
if (pf is CallBack) { |
|
|
|
|
|
|
|
if ("" != pf.curFontPath) { |
|
|
|
|
|
|
|
pf.selectFile("") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
val activity = activity |
|
|
|
|
|
|
|
if (activity is CallBack) { |
|
|
|
|
|
|
|
if ("" != activity.curFontPath) { |
|
|
|
|
|
|
|
activity.selectFile("") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
dismiss() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onDestroy() { |
|
|
|
override fun onDestroy() { |
|
|
|
super.onDestroy() |
|
|
|
super.onDestroy() |
|
|
|
job.cancel() |
|
|
|
job.cancel() |
|
|
|