Fix: Details improvement
This commit is contained in:
parent
a15bb719df
commit
352684d831
@ -12,9 +12,10 @@
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".ui.NeoTermActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="adjustResize|stateAlwaysVisible">
|
||||
android:windowSoftInputMode="adjustResize|stateHidden">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
@ -111,7 +111,7 @@ static int create_subprocess(JNIEnv *env,
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL Java_io_neoterm_terminal_JNI_createSubprocess(
|
||||
extern "C" JNIEXPORT jint JNICALL Java_io_neoterm_backend_JNI_createSubprocess(
|
||||
JNIEnv *env,
|
||||
jclass TERMUX_UNUSED(clazz),
|
||||
jstring cmd,
|
||||
@ -181,7 +181,7 @@ extern "C" JNIEXPORT jint JNICALL Java_io_neoterm_terminal_JNI_createSubprocess(
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_io_neoterm_terminal_JNI_setPtyWindowSize(JNIEnv *TERMUX_UNUSED(env),
|
||||
Java_io_neoterm_backend_JNI_setPtyWindowSize(JNIEnv *TERMUX_UNUSED(env),
|
||||
jclass TERMUX_UNUSED(clazz),
|
||||
jint fd, jint rows,
|
||||
jint cols) {
|
||||
@ -190,7 +190,7 @@ Java_io_neoterm_terminal_JNI_setPtyWindowSize(JNIEnv *TERMUX_UNUSED(env),
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_io_neoterm_terminal_JNI_setPtyUTF8Mode(JNIEnv *TERMUX_UNUSED(env), jclass TERMUX_UNUSED(clazz),
|
||||
Java_io_neoterm_backend_JNI_setPtyUTF8Mode(JNIEnv *TERMUX_UNUSED(env), jclass TERMUX_UNUSED(clazz),
|
||||
jint fd) {
|
||||
struct termios tios;
|
||||
tcgetattr(fd, &tios);
|
||||
@ -201,7 +201,7 @@ Java_io_neoterm_terminal_JNI_setPtyUTF8Mode(JNIEnv *TERMUX_UNUSED(env), jclass T
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT int JNICALL
|
||||
Java_io_neoterm_terminal_JNI_waitFor(JNIEnv *TERMUX_UNUSED(env), jclass TERMUX_UNUSED(clazz),
|
||||
Java_io_neoterm_backend_JNI_waitFor(JNIEnv *TERMUX_UNUSED(env), jclass TERMUX_UNUSED(clazz),
|
||||
jint pid) {
|
||||
int status;
|
||||
waitpid(pid, &status, 0);
|
||||
@ -216,7 +216,7 @@ Java_io_neoterm_terminal_JNI_waitFor(JNIEnv *TERMUX_UNUSED(env), jclass TERMUX_U
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_io_neoterm_terminal_JNI_close(JNIEnv *TERMUX_UNUSED(env), jclass TERMUX_UNUSED(clazz),
|
||||
Java_io_neoterm_backend_JNI_close(JNIEnv *TERMUX_UNUSED(env), jclass TERMUX_UNUSED(clazz),
|
||||
jint fileDescriptor) {
|
||||
close(fileDescriptor);
|
||||
}
|
||||
|
@ -1,24 +1,17 @@
|
||||
package io.neoterm.customize
|
||||
package io.neoterm.customize.color
|
||||
|
||||
import io.neoterm.backend.TerminalColors
|
||||
import io.neoterm.backend.TerminalSession
|
||||
|
||||
/**
|
||||
* @author kiva
|
||||
*/
|
||||
class NeoTermColorScheme {
|
||||
open class NeoTermColorScheme {
|
||||
var foreground: String? = null
|
||||
var background: String? = null
|
||||
var cursor: String? = null
|
||||
var color: MutableMap<Int, String> = mutableMapOf()
|
||||
|
||||
fun apply(session: TerminalSession?) {
|
||||
if (session == null) {
|
||||
return
|
||||
}
|
||||
|
||||
val termSession = session
|
||||
fun apply() {
|
||||
TerminalColors.COLOR_SCHEME.updateWith(foreground, background, cursor, color)
|
||||
termSession.emulator.mColors.reset()
|
||||
}
|
||||
}
|
@ -1,7 +1,30 @@
|
||||
package io.neoterm.customize.color.builtin
|
||||
|
||||
import io.neoterm.customize.color.NeoTermColorScheme
|
||||
|
||||
/**
|
||||
* @author kiva
|
||||
*/
|
||||
class MaterialColorScheme {
|
||||
class MaterialColorScheme : NeoTermColorScheme() {
|
||||
init {
|
||||
foreground = "#263238"
|
||||
background = "#263238"
|
||||
cursor = "#a9aaa5"
|
||||
color[0] = "#263238"
|
||||
color[8] = "#37474f"
|
||||
color[1] = "#ff9800"
|
||||
color[9] = "#ffa74d"
|
||||
color[2] = "#8bc34a"
|
||||
color[10] = "#9ccc65"
|
||||
color[3] = "#ffc107"
|
||||
color[11] = "#ffa000"
|
||||
color[4] = "#03a9f4"
|
||||
color[12] = "#81d4fa"
|
||||
color[5] = "#e91e63"
|
||||
color[13] = "#ad1457"
|
||||
color[6] = "#009688"
|
||||
color[14] = "#26a69a"
|
||||
color[7] = "#cfd8dc"
|
||||
color[15] = "#eceff1"
|
||||
}
|
||||
}
|
@ -127,7 +127,7 @@ public class NeoTermService extends Service {
|
||||
Notification.Builder builder = new Notification.Builder(this);
|
||||
builder.setContentTitle(getText(R.string.app_name));
|
||||
builder.setContentText(contentText);
|
||||
builder.setSmallIcon(R.drawable.ic_service_notification);
|
||||
builder.setSmallIcon(R.drawable.ic_terminal_running);
|
||||
builder.setContentIntent(pendingIntent);
|
||||
builder.setOngoing(true);
|
||||
builder.setShowWhen(false);
|
||||
|
@ -15,13 +15,10 @@ import android.widget.ImageButton
|
||||
import de.mrapp.android.tabswitcher.*
|
||||
import de.mrapp.android.tabswitcher.view.TabSwitcherButton
|
||||
import io.neoterm.R
|
||||
import io.neoterm.backend.TerminalSession
|
||||
import io.neoterm.preference.NeoTermPreference
|
||||
import io.neoterm.services.NeoTermService
|
||||
import io.neoterm.view.tab.TermSessionChangedCallback
|
||||
import io.neoterm.view.tab.TermTab
|
||||
import io.neoterm.view.tab.TermTabDecorator
|
||||
import io.neoterm.view.tab.TermViewClient
|
||||
import io.neoterm.backend.TerminalSession
|
||||
import io.neoterm.view.tab.*
|
||||
|
||||
|
||||
class NeoTermActivity : AppCompatActivity(), ServiceConnection {
|
||||
@ -97,6 +94,7 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection {
|
||||
|
||||
override fun onTabRemoved(tabSwitcher: TabSwitcher, index: Int, tab: Tab, animation: Animation) {
|
||||
if (tab is TermTab) {
|
||||
tab.termSession?.finishIfRunning()
|
||||
removeFinishedSession(tab.termSession)
|
||||
tab.cleanup()
|
||||
}
|
||||
@ -220,6 +218,14 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection {
|
||||
|
||||
private fun createTab(tabTitle: String?): Tab {
|
||||
val tab = TermTab(tabTitle ?: "NeoTerm")
|
||||
tab.closeTabProvider = object : CloseTabProvider {
|
||||
override fun closeTab(tab: Tab) {
|
||||
tabSwitcher.removeTab(tab)
|
||||
if (tabSwitcher.count > 0) {
|
||||
switchToSession(tabSwitcher.getTab(tabSwitcher.count - 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
tab.isCloseable = true
|
||||
tab.parameters = Bundle()
|
||||
tab.setBackgroundColor(ContextCompat.getColor(this, R.color.tab_background_color))
|
||||
|
@ -1,5 +1,8 @@
|
||||
package io.neoterm.view.tab
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import io.neoterm.backend.TerminalSession
|
||||
import io.neoterm.view.TerminalView
|
||||
|
||||
@ -21,10 +24,14 @@ class TermSessionChangedCallback : TerminalSession.SessionChangedCallback {
|
||||
}
|
||||
|
||||
override fun onSessionFinished(finishedSession: TerminalSession?) {
|
||||
|
||||
termTab?.onSessionFinished()
|
||||
}
|
||||
|
||||
override fun onClipboardText(session: TerminalSession?, text: String?) {
|
||||
if (termView != null) {
|
||||
val clipboard = termView!!.context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
clipboard.primaryClip = ClipData.newPlainText("", text)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBell(session: TerminalSession?) {
|
||||
|
@ -1,54 +1,53 @@
|
||||
package io.neoterm.view.tab
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import android.graphics.Color
|
||||
import android.support.v7.widget.Toolbar
|
||||
import de.mrapp.android.tabswitcher.Tab
|
||||
import io.neoterm.backend.TerminalSession
|
||||
import io.neoterm.customize.NeoTermColorScheme
|
||||
import io.neoterm.customize.color.NeoTermColorScheme
|
||||
|
||||
/**
|
||||
* @author kiva
|
||||
*/
|
||||
|
||||
class TermTab : Tab {
|
||||
class TermTab(title: CharSequence) : Tab(title) {
|
||||
var termSession: TerminalSession? = null
|
||||
var sessionCallback: TermSessionChangedCallback? = null
|
||||
var viewClient: TermViewClient? = null
|
||||
var toolbar: Toolbar? = null
|
||||
|
||||
constructor(title: CharSequence) : super(title)
|
||||
|
||||
private constructor(source: Parcel) : super(source)
|
||||
var closeTabProvider: CloseTabProvider? = null
|
||||
|
||||
fun changeColorScheme(colorScheme: NeoTermColorScheme?) {
|
||||
colorScheme?.apply(termSession)
|
||||
colorScheme?.apply()
|
||||
viewClient?.extraKeysView?.setBackgroundColor(Color.parseColor(colorScheme?.background))
|
||||
}
|
||||
|
||||
fun cleanup() {
|
||||
termSession?.finishIfRunning()
|
||||
viewClient?.termTab = null
|
||||
viewClient?.termView = null
|
||||
viewClient?.extraKeysView = null
|
||||
sessionCallback?.termView = null
|
||||
sessionCallback?.termTab = null
|
||||
closeTabProvider = null
|
||||
toolbar = null
|
||||
termSession = null
|
||||
}
|
||||
|
||||
companion object {
|
||||
val CREATOR: Parcelable.Creator<TermTab> = object : Parcelable.Creator<TermTab> {
|
||||
override fun createFromParcel(source: Parcel): TermTab {
|
||||
return TermTab(source)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<TermTab?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun updateTitle(title: String) {
|
||||
this.title = title
|
||||
toolbar?.title = title
|
||||
}
|
||||
|
||||
fun onSessionFinished() {
|
||||
viewClient?.sessionFinished = true
|
||||
}
|
||||
|
||||
fun requiredCloseTab() {
|
||||
closeTabProvider?.closeTab(this)
|
||||
}
|
||||
}
|
||||
|
||||
interface CloseTabProvider {
|
||||
fun closeTab(tab: Tab)
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import de.mrapp.android.tabswitcher.TabSwitcher
|
||||
import de.mrapp.android.tabswitcher.TabSwitcherDecorator
|
||||
import io.neoterm.ui.NeoTermActivity
|
||||
import io.neoterm.R
|
||||
import io.neoterm.customize.color.builtin.MaterialColorScheme
|
||||
import io.neoterm.view.ExtraKeysView
|
||||
import io.neoterm.view.TerminalView
|
||||
|
||||
@ -66,9 +67,10 @@ class TermTabDecorator(val context: NeoTermActivity) : TabSwitcherDecorator() {
|
||||
|
||||
// 复用前一次的 TermSession
|
||||
termTab.sessionCallback?.termView = view
|
||||
termTab.sessionCallback?.termTab = tab
|
||||
termTab.sessionCallback?.termTab = termTab
|
||||
|
||||
// 复用上一次的 TermViewClient
|
||||
termTab.viewClient?.termTab = termTab
|
||||
termTab.viewClient?.termView = view
|
||||
termTab.viewClient?.extraKeysView = extraKeysView
|
||||
|
||||
|
@ -16,6 +16,10 @@ import io.neoterm.view.TerminalViewClient
|
||||
class TermViewClient(val context: Context) : TerminalViewClient {
|
||||
private var mVirtualControlKeyDown: Boolean = false
|
||||
private var mVirtualFnKeyDown: Boolean = false
|
||||
|
||||
var sessionFinished: Boolean = false
|
||||
|
||||
var termTab: TermTab? = null
|
||||
var termView: TerminalView? = null
|
||||
var extraKeysView: ExtraKeysView? = null
|
||||
|
||||
@ -43,8 +47,16 @@ class TermViewClient(val context: Context) : TerminalViewClient {
|
||||
}
|
||||
|
||||
override fun onKeyDown(keyCode: Int, e: KeyEvent?, session: TerminalSession?): Boolean {
|
||||
// TODO
|
||||
return false
|
||||
when (keyCode) {
|
||||
KeyEvent.KEYCODE_ENTER -> {
|
||||
if (e?.action == KeyEvent.ACTION_DOWN && sessionFinished) {
|
||||
termTab?.requiredCloseTab()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
else -> return false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onKeyUp(keyCode: Int, e: KeyEvent?): Boolean {
|
||||
|
BIN
app/src/main/res/drawable/ic_tab_icon.png
Normal file
BIN
app/src/main/res/drawable/ic_tab_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 187 B |
@ -8,6 +8,7 @@
|
||||
android:background="#ff14181c"
|
||||
custom:layoutPolicy="auto"
|
||||
custom:tabBackgroundColor="@color/tab_background_color"
|
||||
custom:tabIcon="@drawable/ic_tab_icon"
|
||||
custom:tabTitleTextColor="@color/tab_title_text_color"
|
||||
custom:tabCloseButtonIcon="@drawable/ic_close_tab_18dp"
|
||||
custom:toolbarMenu="@menu/tab_switcher"
|
||||
|
Loading…
Reference in New Issue
Block a user