Feature: ColorScheme editor first step.
This commit is contained in:
@ -3,6 +3,8 @@ package io.neoterm.component.color
|
||||
import android.content.Context
|
||||
import io.neoterm.App
|
||||
import io.neoterm.R
|
||||
import io.neoterm.component.config.ConfigureComponent
|
||||
import io.neoterm.frontend.component.ComponentManager
|
||||
import io.neoterm.frontend.preference.NeoPreference
|
||||
import io.neoterm.frontend.preference.NeoTermPath
|
||||
import io.neoterm.frontend.component.NeoComponent
|
||||
@ -10,6 +12,7 @@ import io.neoterm.frontend.logging.NLog
|
||||
import io.neoterm.utils.AssetsUtils
|
||||
import io.neoterm.frontend.terminal.TerminalView
|
||||
import io.neoterm.frontend.terminal.eks.ExtraKeysView
|
||||
import io.neoterm.utils.FileUtils
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
@ -75,6 +78,10 @@ class ColorSchemeComponent : NeoComponent {
|
||||
NeoPreference.store(R.string.key_customization_color_scheme, colorName)
|
||||
}
|
||||
|
||||
fun setCurrentColorScheme(color: NeoColorScheme) {
|
||||
setCurrentColorScheme(color.colorName)
|
||||
}
|
||||
|
||||
override fun onServiceObtained() {
|
||||
checkForFiles()
|
||||
}
|
||||
@ -114,4 +121,17 @@ class ColorSchemeComponent : NeoComponent {
|
||||
colors[DEFAULT_COLOR.colorName] = DEFAULT_COLOR
|
||||
}
|
||||
}
|
||||
|
||||
fun saveColorScheme(colorScheme: NeoColorScheme) {
|
||||
val colorFile = colorFile(colorScheme.colorName)
|
||||
if (colorFile.exists()) {
|
||||
throw RuntimeException("ColorScheme ${colorScheme.colorName} exists!")
|
||||
}
|
||||
|
||||
val component = ComponentManager.getComponent<ConfigureComponent>()
|
||||
val content = component.export(colorScheme)
|
||||
if (!FileUtils.writeFile(colorFile, content.toByteArray())) {
|
||||
throw RuntimeException("Failed to save file ${colorFile.absolutePath}")
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
package io.neoterm.component.color
|
||||
|
||||
import io.neolang.visitor.ConfigVisitor
|
||||
import io.neoterm.backend.TerminalColorScheme
|
||||
import io.neoterm.backend.TerminalColors
|
||||
import io.neoterm.component.config.ConfigureComponent
|
||||
import io.neolang.visitor.ConfigVisitor
|
||||
import io.neoterm.frontend.component.ComponentManager
|
||||
import io.neoterm.frontend.config.NeoConfigureFile
|
||||
import io.neoterm.frontend.logging.NLog
|
||||
import io.neoterm.frontend.component.ComponentManager
|
||||
import io.neoterm.frontend.terminal.TerminalView
|
||||
import io.neoterm.frontend.terminal.eks.ExtraKeysView
|
||||
import java.io.File
|
||||
@ -26,23 +26,30 @@ open class NeoColorScheme {
|
||||
val COLOR_META_PATH = arrayOf(COLOR_META_CONTEXT_NAME)
|
||||
val COLOR_PATH = arrayOf(COLOR_META_CONTEXT_NAME, COLOR_CONTEXT_NAME)
|
||||
|
||||
// const val COLOR_DIM_BLACK = 0
|
||||
// const val COLOR_DIM_RED = 1
|
||||
// const val COLOR_DIM_GREEN = 2
|
||||
// const val COLOR_DIM_YELLOW = 3
|
||||
// const val COLOR_DIM_BLUE = 4
|
||||
// const val COLOR_DIM_MAGENTA = 5
|
||||
// const val COLOR_DIM_CYAN = 6
|
||||
// const val COLOR_DIM_WHITE = 7
|
||||
//
|
||||
// const val COLOR_BRIGHT_BLACK = 8
|
||||
// const val COLOR_BRIGHT_RED = 9
|
||||
// const val COLOR_BRIGHT_GREEN = 10
|
||||
// const val COLOR_BRIGHT_YELLOW = 11
|
||||
// const val COLOR_BRIGHT_BLUE = 12
|
||||
// const val COLOR_BRIGHT_MAGENTA = 13
|
||||
// const val COLOR_BRIGHT_CYAN = 14
|
||||
// const val COLOR_BRIGHT_WHITE = 15
|
||||
const val COLOR_TYPE_BEGIN = -3
|
||||
const val COLOR_TYPE_END = 15
|
||||
|
||||
const val COLOR_BACKGROUND = -3
|
||||
const val COLOR_FOREGROUND = -2
|
||||
const val COLOR_CURSOR = -1
|
||||
|
||||
const val COLOR_DIM_BLACK = 0
|
||||
const val COLOR_DIM_RED = 1
|
||||
const val COLOR_DIM_GREEN = 2
|
||||
const val COLOR_DIM_YELLOW = 3
|
||||
const val COLOR_DIM_BLUE = 4
|
||||
const val COLOR_DIM_MAGENTA = 5
|
||||
const val COLOR_DIM_CYAN = 6
|
||||
const val COLOR_DIM_WHITE = 7
|
||||
|
||||
const val COLOR_BRIGHT_BLACK = 8
|
||||
const val COLOR_BRIGHT_RED = 9
|
||||
const val COLOR_BRIGHT_GREEN = 10
|
||||
const val COLOR_BRIGHT_YELLOW = 11
|
||||
const val COLOR_BRIGHT_BLUE = 12
|
||||
const val COLOR_BRIGHT_MAGENTA = 13
|
||||
const val COLOR_BRIGHT_CYAN = 14
|
||||
const val COLOR_BRIGHT_WHITE = 15
|
||||
}
|
||||
|
||||
lateinit var colorName: String
|
||||
@ -53,9 +60,43 @@ open class NeoColorScheme {
|
||||
var color: MutableMap<Int, String> = mutableMapOf()
|
||||
|
||||
fun setColor(type: Int, color: String) {
|
||||
if (type < 0) {
|
||||
when (type) {
|
||||
COLOR_BACKGROUND -> backgroundColor = color
|
||||
COLOR_FOREGROUND -> foregroundColor = color
|
||||
COLOR_CURSOR -> cursorColor = color
|
||||
}
|
||||
return
|
||||
}
|
||||
this.color[type] = color
|
||||
}
|
||||
|
||||
fun getColor(type: Int): String? {
|
||||
validateColors()
|
||||
return when (type) {
|
||||
COLOR_BACKGROUND -> backgroundColor
|
||||
COLOR_FOREGROUND -> foregroundColor
|
||||
COLOR_CURSOR -> cursorColor
|
||||
else -> {
|
||||
if (type in (0..color.size - 1)) {
|
||||
color[type]
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun copy(): NeoColorScheme {
|
||||
val copy = NeoColorScheme()
|
||||
copy.colorName = colorName
|
||||
copy.backgroundColor = backgroundColor
|
||||
copy.foregroundColor = foregroundColor
|
||||
copy.cursorColor = cursorColor
|
||||
this.color.forEach { copy.color.put(it.key, it.value) }
|
||||
return copy
|
||||
}
|
||||
|
||||
fun loadConfigure(file: File): Boolean {
|
||||
// TODO: Refactor with NeoExtraKey#loadConfigure
|
||||
val loaderService = ComponentManager.getComponent<ConfigureComponent>()
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.neoterm.component.config
|
||||
|
||||
import io.neoterm.component.color.NeoColorScheme
|
||||
import io.neoterm.component.config.loader.NeoLangConfigureLoader
|
||||
import io.neoterm.component.config.loader.OldConfigureLoader
|
||||
import io.neoterm.frontend.component.NeoComponent
|
||||
@ -24,4 +25,8 @@ class ConfigureComponent : NeoComponent {
|
||||
else -> OldConfigureLoader(configFile)
|
||||
}
|
||||
}
|
||||
|
||||
fun export(colorScheme: NeoColorScheme): String {
|
||||
return ""
|
||||
}
|
||||
}
|
@ -43,6 +43,18 @@ class CrashActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun collectModelInfo(): String {
|
||||
return "${Build.MODEL} (Android ${Build.VERSION.RELEASE})"
|
||||
return "${Build.MODEL} (Android ${Build.VERSION.RELEASE} ${determineArchName()})"
|
||||
}
|
||||
|
||||
private fun determineArchName(): String {
|
||||
for (androidArch in Build.SUPPORTED_ABIS) {
|
||||
when (androidArch) {
|
||||
"arm64-v8a" -> return "aarch64"
|
||||
"armeabi-v7a" -> return "arm"
|
||||
"x86_64" -> return "x86_64"
|
||||
"x86" -> return "i686"
|
||||
}
|
||||
}
|
||||
return "Unknown Arch"
|
||||
}
|
||||
}
|
@ -1,22 +1,169 @@
|
||||
package io.neoterm.ui.customize
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.os.Bundle
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.KeyEvent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import com.github.wrdlbrnft.sortedlistadapter.SortedListAdapter
|
||||
import io.neoterm.R
|
||||
import io.neoterm.backend.TerminalColors
|
||||
import io.neoterm.component.color.ColorSchemeComponent
|
||||
import io.neoterm.component.color.NeoColorScheme
|
||||
import io.neoterm.frontend.component.ComponentManager
|
||||
import io.neoterm.frontend.terminal.TerminalView
|
||||
import io.neoterm.ui.customize.adapter.ColorItemAdapter
|
||||
import io.neoterm.ui.customize.model.ColorItem
|
||||
import io.neoterm.utils.TerminalUtils
|
||||
|
||||
/**
|
||||
* @author kiva
|
||||
*/
|
||||
class ColorSchemeActivity : BaseCustomizeActivity() {
|
||||
private val COMPARATOR = SortedListAdapter.ComparatorBuilder<ColorItem>()
|
||||
.setOrderForModel<ColorItem>(ColorItem::class.java) { a, b ->
|
||||
a.colorType.compareTo(b.colorType)
|
||||
}
|
||||
.build()
|
||||
|
||||
var changed = false
|
||||
lateinit var editingColorScheme: NeoColorScheme
|
||||
lateinit var adapter: ColorItemAdapter
|
||||
|
||||
val colorSchemeComponent = ComponentManager.getComponent<ColorSchemeComponent>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
initCustomizationComponent(R.layout.ui_color_scheme)
|
||||
|
||||
editingColorScheme = colorSchemeComponent.getCurrentColorScheme().copy()
|
||||
editingColorScheme.colorName = ""
|
||||
|
||||
val terminalView = findViewById<TerminalView>(R.id.terminal_view)
|
||||
TerminalUtils.setupTerminalView(terminalView, null)
|
||||
|
||||
adapter = ColorItemAdapter(this, editingColorScheme, COMPARATOR, object : ColorItemAdapter.Listener {
|
||||
override fun onModelClicked(model: ColorItem) {
|
||||
showItemEditor(model)
|
||||
}
|
||||
})
|
||||
val recyclerView = findViewById<RecyclerView>(R.id.custom_color_color_list)
|
||||
recyclerView.setHasFixedSize(true)
|
||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||
recyclerView.adapter = adapter
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_color_edit, menu)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
|
||||
when (item?.itemId) {
|
||||
android.R.id.home -> finish()
|
||||
R.id.action_done -> applyColorScheme(editingColorScheme)
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event!!.action == KeyEvent.ACTION_DOWN && changed) {
|
||||
AlertDialog.Builder(this)
|
||||
.setMessage(getString(R.string.discard_changes))
|
||||
.setPositiveButton(R.string.save, { _, _ ->
|
||||
applyColorScheme(editingColorScheme, true)
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.setNeutralButton(R.string.exit, { _, _ ->
|
||||
finish()
|
||||
})
|
||||
.show()
|
||||
return true
|
||||
}
|
||||
return super.onKeyDown(keyCode, event)
|
||||
}
|
||||
|
||||
private fun showItemEditor(model: ColorItem) {
|
||||
val view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null, false)
|
||||
view.findViewById<TextView>(R.id.dialog_edit_text_info).text = getString(R.string.input_new_value)
|
||||
|
||||
val edit = view.findViewById<EditText>(R.id.dialog_edit_text_editor)
|
||||
edit.setText(model.colorValue)
|
||||
if (model.colorValue.isNotEmpty()) {
|
||||
edit.setTextColor(TerminalColors.parse(model.colorValue))
|
||||
}
|
||||
edit.addTextChangedListener(object : TextWatcher {
|
||||
override fun afterTextChanged(editable: Editable?) {
|
||||
if (editable != null && editable.isNotEmpty()) {
|
||||
val color = TerminalColors.parse(editable.toString())
|
||||
if (color != 0) {
|
||||
edit.setTextColor(color)
|
||||
} else {
|
||||
edit.setTextColor(resources.getColor(R.color.textColor))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
|
||||
}
|
||||
|
||||
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
|
||||
}
|
||||
})
|
||||
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle(model.colorName)
|
||||
.setView(view)
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.setPositiveButton(android.R.string.yes, { _, _ ->
|
||||
model.colorValue = edit.text.toString()
|
||||
adapter.notifyItemChanged(adapter.colorList.indexOf(model))
|
||||
|
||||
editingColorScheme.setColor(model.colorType, model.colorValue)
|
||||
colorSchemeComponent.applyColorScheme(terminalView, null, editingColorScheme)
|
||||
changed = true
|
||||
})
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun applyColorScheme(colorScheme: NeoColorScheme, finishAfter: Boolean = false) {
|
||||
if (colorScheme.colorName.isEmpty()) {
|
||||
val view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null, false)
|
||||
view.findViewById<TextView>(R.id.dialog_edit_text_info).text = getString(R.string.save_color_info)
|
||||
|
||||
val edit = view.findViewById<EditText>(R.id.dialog_edit_text_editor)
|
||||
edit.setText(getString(R.string.save_color_scheme_name_template))
|
||||
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle(R.string.save_color)
|
||||
.setView(view)
|
||||
.setPositiveButton(android.R.string.yes, { _, _ ->
|
||||
colorScheme.colorName = edit.text.toString()
|
||||
applyColorScheme(colorScheme, finishAfter)
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show()
|
||||
} else {
|
||||
try {
|
||||
colorSchemeComponent.saveColorScheme(colorScheme)
|
||||
colorSchemeComponent.setCurrentColorScheme(colorScheme)
|
||||
changed = false
|
||||
|
||||
Toast.makeText(this, R.string.done, Toast.LENGTH_SHORT).show()
|
||||
if (finishAfter) {
|
||||
finish()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(this, getString(R.string.error) + ": ${e.localizedMessage}", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,8 +13,8 @@ import android.widget.Toast
|
||||
import io.neoterm.R
|
||||
import io.neoterm.component.color.ColorSchemeComponent
|
||||
import io.neoterm.component.font.FontComponent
|
||||
import io.neoterm.frontend.preference.NeoTermPath
|
||||
import io.neoterm.frontend.component.ComponentManager
|
||||
import io.neoterm.frontend.preference.NeoTermPath
|
||||
import io.neoterm.utils.FileUtils
|
||||
import io.neoterm.utils.MediaUtils
|
||||
import java.io.File
|
||||
@ -40,16 +40,17 @@ class CustomizeActivity : BaseCustomizeActivity() {
|
||||
|
||||
findViewById<View>(R.id.custom_install_color_button).setOnClickListener {
|
||||
AlertDialog.Builder(this)
|
||||
.setMessage(R.string.pref_customization_font)
|
||||
.setMessage(R.string.pref_customization_color_scheme)
|
||||
.setNeutralButton(android.R.string.no, null)
|
||||
.setPositiveButton(R.string.install_font, { _, _ ->
|
||||
.setPositiveButton(R.string.install_color, { _, _ ->
|
||||
val intent = Intent()
|
||||
intent.action = Intent.ACTION_GET_CONTENT
|
||||
intent.type = "*/*"
|
||||
startActivityForResult(Intent.createChooser(intent, getString(R.string.install_color)), REQUEST_SELECT_COLOR)
|
||||
})
|
||||
.setNegativeButton(R.string.new_color_scheme, { _, _ ->
|
||||
startActivity(Intent(this, ColorSchemeActivity::class.java))
|
||||
val intent = Intent(this, ColorSchemeActivity::class.java)
|
||||
startActivity(intent)
|
||||
})
|
||||
.show()
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
package io.neoterm.ui.customize.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.github.wrdlbrnft.sortedlistadapter.SortedListAdapter
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import io.neoterm.R
|
||||
import io.neoterm.component.color.NeoColorScheme
|
||||
import io.neoterm.ui.customize.adapter.holder.ColorItemViewHolder
|
||||
import io.neoterm.ui.customize.model.ColorItem
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* @author kiva
|
||||
*/
|
||||
class ColorItemAdapter(context: Context, initColorScheme: NeoColorScheme, comparator: Comparator<ColorItem>, private val listener: ColorItemAdapter.Listener)
|
||||
: SortedListAdapter<ColorItem>(context, ColorItem::class.java, comparator), FastScrollRecyclerView.SectionedAdapter {
|
||||
|
||||
val colorList = mutableListOf<ColorItem>()
|
||||
|
||||
init {
|
||||
(NeoColorScheme.COLOR_TYPE_BEGIN..NeoColorScheme.COLOR_TYPE_END)
|
||||
.forEach {
|
||||
colorList.add(ColorItem(it, initColorScheme.getColor(it) ?: ""))
|
||||
}
|
||||
edit().add(colorList).commit()
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
fun onModelClicked(model: ColorItem)
|
||||
}
|
||||
|
||||
override fun getSectionName(position: Int): String {
|
||||
return colorList[position].colorName[0].toString()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup, viewType: Int): SortedListAdapter.ViewHolder<out ColorItem> {
|
||||
val rootView = inflater.inflate(R.layout.item_color, parent, false)
|
||||
return ColorItemViewHolder(rootView, listener)
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package io.neoterm.ui.customize.adapter.holder
|
||||
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import com.github.wrdlbrnft.sortedlistadapter.SortedListAdapter
|
||||
import io.neoterm.R
|
||||
import io.neoterm.backend.TerminalColors
|
||||
import io.neoterm.ui.customize.adapter.ColorItemAdapter
|
||||
import io.neoterm.ui.customize.model.ColorItem
|
||||
|
||||
class ColorItemViewHolder(private val rootView: View, private val listener: ColorItemAdapter.Listener) : SortedListAdapter.ViewHolder<ColorItem>(rootView) {
|
||||
private val colorItemName: TextView = rootView.findViewById<TextView>(R.id.color_item_name)
|
||||
private val colorItemDesc: TextView = rootView.findViewById<TextView>(R.id.color_item_description)
|
||||
|
||||
override fun performBind(item: ColorItem) {
|
||||
rootView.setOnClickListener { listener.onModelClicked(item) }
|
||||
colorItemName.text = item.colorName
|
||||
colorItemDesc.text = item.colorValue
|
||||
if (item.colorValue.isNotEmpty()) {
|
||||
colorItemDesc.setTextColor(TerminalColors.parse(item.colorValue))
|
||||
}
|
||||
}
|
||||
}
|
27
app/src/main/java/io/neoterm/ui/customize/model/ColorItem.kt
Normal file
27
app/src/main/java/io/neoterm/ui/customize/model/ColorItem.kt
Normal file
@ -0,0 +1,27 @@
|
||||
package io.neoterm.ui.customize.model
|
||||
|
||||
import com.github.wrdlbrnft.sortedlistadapter.SortedListAdapter
|
||||
import io.neoterm.App
|
||||
import io.neoterm.R
|
||||
import io.neoterm.component.color.NeoColorScheme
|
||||
|
||||
/**
|
||||
* @author kiva
|
||||
*/
|
||||
class ColorItem(var colorType: Int, var colorValue: String) : SortedListAdapter.ViewModel {
|
||||
override fun <T> isSameModelAs(t: T): Boolean {
|
||||
if (t is ColorItem) {
|
||||
return t.colorName == colorName
|
||||
&& t.colorValue == colorValue
|
||||
&& t.colorType == colorType
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun <T> isContentTheSameAs(t: T): Boolean {
|
||||
return isSameModelAs(t)
|
||||
}
|
||||
|
||||
var colorName = App.get().resources
|
||||
.getStringArray(R.array.color_item_names)[colorType - NeoColorScheme.COLOR_TYPE_BEGIN]
|
||||
}
|
@ -40,7 +40,7 @@ import io.neoterm.utils.PackageUtils
|
||||
class PackageManagerActivity : AppCompatActivity(), SearchView.OnQueryTextListener, SortedListAdapter.Callback {
|
||||
private val COMPARATOR = SortedListAdapter.ComparatorBuilder<PackageModel>()
|
||||
.setOrderForModel<PackageModel>(PackageModel::class.java) { a, b ->
|
||||
a!!.packageInfo.packageName!!.compareTo(b!!.packageInfo.packageName!!)
|
||||
a.packageInfo.packageName!!.compareTo(b.packageInfo.packageName!!)
|
||||
}
|
||||
.build()
|
||||
|
||||
@ -73,8 +73,6 @@ class PackageManagerActivity : AppCompatActivity(), SearchView.OnQueryTextListen
|
||||
.show()
|
||||
}
|
||||
|
||||
}, FastScrollRecyclerView.SectionedAdapter {
|
||||
models[it].packageInfo.packageName?.substring(0, 1) ?: "#"
|
||||
})
|
||||
adapter.addCallback(this)
|
||||
|
||||
|
@ -6,14 +6,14 @@ import android.view.ViewGroup
|
||||
import com.github.wrdlbrnft.sortedlistadapter.SortedListAdapter
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import io.neoterm.R
|
||||
import io.neoterm.ui.pm.adapter.viewholder.PackageViewHolder
|
||||
import io.neoterm.ui.pm.adapter.holder.PackageViewHolder
|
||||
import io.neoterm.ui.pm.model.PackageModel
|
||||
import java.util.*
|
||||
|
||||
class PackageAdapter(context: Context, comparator: Comparator<PackageModel>, private val listener: PackageAdapter.Listener, private val sectionedAdapter: FastScrollRecyclerView.SectionedAdapter?) : SortedListAdapter<PackageModel>(context, PackageModel::class.java, comparator), FastScrollRecyclerView.SectionedAdapter {
|
||||
class PackageAdapter(context: Context, comparator: Comparator<PackageModel>, private val listener: PackageAdapter.Listener) : SortedListAdapter<PackageModel>(context, PackageModel::class.java, comparator), FastScrollRecyclerView.SectionedAdapter {
|
||||
|
||||
override fun getSectionName(position: Int): String {
|
||||
return sectionedAdapter?.getSectionName(position) ?: "#"
|
||||
return getItem(position).packageInfo.packageName?.substring(0, 1) ?: "#"
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package io.neoterm.ui.pm.adapter.viewholder
|
||||
package io.neoterm.ui.pm.adapter.holder
|
||||
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
21
app/src/main/res/layout/dialog_edit_text.xml
Normal file
21
app/src/main/res/layout/dialog_edit_text.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/text_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialog_edit_text_info"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/dialog_edit_text_editor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:inputType="text"
|
||||
android:maxLines="1" />
|
||||
|
||||
</LinearLayout>
|
30
app/src/main/res/layout/item_color.xml
Normal file
30
app/src/main/res/layout/item_color.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/package_item_padding"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/color_item_name"
|
||||
style="@style/TextAppearance.AppCompat.Medium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/textColor"
|
||||
tools:text="Color Item Name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/color_item_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/text_margin"
|
||||
android:maxLines="3"
|
||||
android:textColor="@color/textColorSecondary"
|
||||
tools:text="Color Item Description" />
|
||||
|
||||
</LinearLayout>
|
@ -3,8 +3,11 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/text_margin"
|
||||
android:orientation="vertical">
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/package_item_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/package_item_name"
|
||||
|
@ -15,31 +15,57 @@
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="@dimen/preview_layout_margin"
|
||||
android:background="@color/terminal_background">
|
||||
android:orientation="vertical">
|
||||
|
||||
<io.neoterm.frontend.terminal.eks.ExtraKeysView
|
||||
android:id="@+id/custom_extra_keys"
|
||||
style="?android:buttonBarStyle"
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/eks_height_two_line"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone" />
|
||||
android:layout_height="0dp"
|
||||
android:layout_margin="@dimen/preview_layout_margin"
|
||||
android:layout_weight="1.0"
|
||||
android:background="@color/terminal_background">
|
||||
|
||||
<io.neoterm.frontend.terminal.TerminalView
|
||||
android:id="@+id/terminal_view"
|
||||
<io.neoterm.frontend.terminal.eks.ExtraKeysView
|
||||
android:id="@+id/custom_extra_keys"
|
||||
style="?android:buttonBarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/eks_height_two_line"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone" />
|
||||
|
||||
<io.neoterm.frontend.terminal.TerminalView
|
||||
android:id="@+id/terminal_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@id/custom_extra_keys"
|
||||
android:fadeScrollbars="true"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
android:scrollbars="vertical" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@id/custom_extra_keys"
|
||||
android:fadeScrollbars="true"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
android:scrollbars="vertical" />
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0"
|
||||
android:orientation="vertical">
|
||||
|
||||
</RelativeLayout>
|
||||
<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
android:id="@+id/custom_color_color_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:fastScrollAutoHide="true"
|
||||
app:fastScrollAutoHideDelay="1000"
|
||||
app:fastScrollPopupBgColor="@color/colorAccent"
|
||||
app:fastScrollPopupTextColor="@android:color/primary_text_dark"
|
||||
app:fastScrollThumbColor="@color/colorAccent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
9
app/src/main/res/menu/menu_color_edit.xml
Normal file
9
app/src/main/res/menu/menu_color_edit.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_done"
|
||||
android:icon="@drawable/ic_done"
|
||||
android:title="@string/done"
|
||||
app:showAsAction="always" />
|
||||
</menu>
|
@ -125,4 +125,32 @@
|
||||
<string name="process_exit_signal">信号 %d</string>
|
||||
<string name="process_exit_prompt">按回车关闭</string>
|
||||
<string name="process_exit_prompt_press_back">按返回关闭</string>
|
||||
<string name="save_color_info">输入新的配色方案名</string>
|
||||
<string name="save_color_scheme_name_template">新配色方案</string>
|
||||
<string name="save_color">保存配色方案</string>
|
||||
<string name="discard_changes">丢弃所有改动?</string>
|
||||
<string name="save">保存</string>
|
||||
<string name="input_new_value">输入新颜色</string>
|
||||
|
||||
<string-array name="color_item_names">
|
||||
<item>背景色</item>
|
||||
<item>前景色</item>
|
||||
<item>光标颜色</item>
|
||||
<item>黑色</item>
|
||||
<item>红色</item>
|
||||
<item>绿色</item>
|
||||
<item>黄色</item>
|
||||
<item>蓝色</item>
|
||||
<item>洋红色</item>
|
||||
<item>青色</item>
|
||||
<item>白色</item>
|
||||
<item>亮黑色</item>
|
||||
<item>亮红色</item>
|
||||
<item>亮绿色</item>
|
||||
<item>亮黄色</item>
|
||||
<item>亮蓝色</item>
|
||||
<item>亮洋红色</item>
|
||||
<item>亮青色</item>
|
||||
<item>亮白色</item>
|
||||
</string-array>
|
||||
</resources>
|
@ -13,4 +13,7 @@
|
||||
<dimen name="min_popup_height">24dp</dimen>
|
||||
<dimen name="popup_padding">4dp</dimen>
|
||||
<dimen name="md_list_item_height">48dp</dimen>
|
||||
|
||||
<dimen name="package_item_padding">16dp</dimen>
|
||||
<dimen name="color_item_padding">4dp</dimen>
|
||||
</resources>
|
||||
|
@ -125,6 +125,12 @@
|
||||
<string name="process_exit_signal">signal %d</string>
|
||||
<string name="process_exit_prompt">press Enter</string>
|
||||
<string name="process_exit_prompt_press_back">Press Back</string>
|
||||
<string name="save_color_info">Enter new color scheme name</string>
|
||||
<string name="save_color_scheme_name_template">NewColorScheme</string>
|
||||
<string name="save_color">Save color scheme</string>
|
||||
<string name="discard_changes">Discard all changes?</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="input_new_value">Enter new color</string>
|
||||
|
||||
<string-array name="pref_general_shell_entries" translatable="false">
|
||||
<item>sh</item>
|
||||
@ -157,4 +163,26 @@
|
||||
<item>http://neoterm.studio</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="color_item_names">
|
||||
<item>Background color</item>
|
||||
<item>Foreground color</item>
|
||||
<item>Cursor color</item>
|
||||
<item>Dim black</item>
|
||||
<item>Dim red</item>
|
||||
<item>Dim green</item>
|
||||
<item>Dim yellow</item>
|
||||
<item>Dim blue</item>
|
||||
<item>Dim magenta</item>
|
||||
<item>Dim cyan</item>
|
||||
<item>Dim white</item>
|
||||
<item>Bright black</item>
|
||||
<item>Bright red</item>
|
||||
<item>Bright green</item>
|
||||
<item>Bright yellow</item>
|
||||
<item>Bright blue</item>
|
||||
<item>Bright magenta</item>
|
||||
<item>Bright cyan</item>
|
||||
<item>Bright white</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
@ -48,13 +48,13 @@
|
||||
</Preference>
|
||||
-->
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_info_white_36dp"
|
||||
android:title="@string/faq" >
|
||||
<intent
|
||||
android:targetClass="io.neoterm.ui.support.HelpActivity"
|
||||
android:targetPackage="io.neoterm" />
|
||||
</Preference>
|
||||
<!--<Preference-->
|
||||
<!--android:icon="@drawable/ic_info_white_36dp"-->
|
||||
<!--android:title="@string/faq" >-->
|
||||
<!--<intent-->
|
||||
<!--android:targetClass="io.neoterm.ui.support.HelpActivity"-->
|
||||
<!--android:targetPackage="io.neoterm" />-->
|
||||
<!--</Preference>-->
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_info_white_36dp"
|
||||
|
Reference in New Issue
Block a user