From 2033accbeecf48d391040707cde338a57dbcbade Mon Sep 17 00:00:00 2001 From: zt515 Date: Thu, 23 Nov 2017 23:56:52 +0800 Subject: [PATCH] UI: Create XTab --- .../frontend/preference/NeoTermPath.kt | 6 ++--- .../java/io/neoterm/frontend/xorg/XSession.kt | 6 ++++- .../io/neoterm/ui/term/NeoTermActivity.kt | 27 ++++++++++++++----- .../io/neoterm/ui/term/tab/XSessionTab.kt | 4 ++- app/src/main/res/menu/menu_main.xml | 6 +++++ app/src/main/res/values/strings.xml | 3 +-- 6 files changed, 38 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/neoterm/frontend/preference/NeoTermPath.kt b/app/src/main/java/io/neoterm/frontend/preference/NeoTermPath.kt index fccf2b9..b49bafd 100644 --- a/app/src/main/java/io/neoterm/frontend/preference/NeoTermPath.kt +++ b/app/src/main/java/io/neoterm/frontend/preference/NeoTermPath.kt @@ -1,7 +1,6 @@ package io.neoterm.frontend.preference import android.annotation.SuppressLint -import io.neoterm.BuildConfig /** * @author kiva @@ -24,15 +23,14 @@ object NeoTermPath { const val SOURCE_FILE = "$USR_PATH/etc/apt/sources.list" const val PACKAGE_LIST_DIR = "$USR_PATH/var/lib/apt/lists" - const val RELEASE_SOURCE = "https://mirrors.geekpie.org/neoterm" - const val DEBUG_SOURCE = "http://neoterm.studio" + const val SOURCE = "http://neoterm.studio" val DEFAULT_SOURCE: String val SERVER_BASE_URL: String val SERVER_BOOT_URL: String init { - DEFAULT_SOURCE = DEBUG_SOURCE + DEFAULT_SOURCE = SOURCE SERVER_BASE_URL = DEFAULT_SOURCE SERVER_BOOT_URL = "$SERVER_BASE_URL/boot" } diff --git a/app/src/main/java/io/neoterm/frontend/xorg/XSession.kt b/app/src/main/java/io/neoterm/frontend/xorg/XSession.kt index bcf0052..b88855d 100644 --- a/app/src/main/java/io/neoterm/frontend/xorg/XSession.kt +++ b/app/src/main/java/io/neoterm/frontend/xorg/XSession.kt @@ -1,7 +1,11 @@ package io.neoterm.frontend.xorg +import io.neoterm.backend.TerminalSession + /** * @author kiva */ -class XSession +class XSession { + +} diff --git a/app/src/main/java/io/neoterm/ui/term/NeoTermActivity.kt b/app/src/main/java/io/neoterm/ui/term/NeoTermActivity.kt index 35ed9e3..55a1eeb 100644 --- a/app/src/main/java/io/neoterm/ui/term/NeoTermActivity.kt +++ b/app/src/main/java/io/neoterm/ui/term/NeoTermActivity.kt @@ -1,6 +1,5 @@ package io.neoterm.ui.term -import android.annotation.SuppressLint import android.app.Activity import android.app.AlertDialog import android.content.* @@ -17,7 +16,6 @@ import android.support.v7.widget.Toolbar import android.view.* import android.view.inputmethod.InputMethodManager import android.widget.ImageButton -import android.widget.Toast import de.mrapp.android.tabswitcher.* import io.neoterm.App import io.neoterm.R @@ -30,12 +28,12 @@ import io.neoterm.frontend.preference.NeoPermission import io.neoterm.frontend.preference.NeoPreference import io.neoterm.frontend.shell.ShellParameter import io.neoterm.services.NeoTermService -import io.neoterm.ui.bonus.BonusActivity import io.neoterm.ui.pm.PackageManagerActivity import io.neoterm.ui.settings.SettingActivity import io.neoterm.ui.setup.SetupActivity import io.neoterm.ui.term.tab.TermTab import io.neoterm.ui.term.tab.TermTabDecorator +import io.neoterm.ui.term.tab.XSessionTab import io.neoterm.utils.FullScreenHelper import io.neoterm.utils.RangedInt import org.greenrobot.eventbus.EventBus @@ -154,6 +152,10 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference forceAddSystemSession() true } + R.id.menu_item_new_x_session -> { + addXSession(); + true + } else -> super.onOptionsItemSelected(item) } } @@ -434,7 +436,7 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference .systemShell(systemShell) val session = termService!!.createTermSession(parameter) - session.mSessionName = sessionName ?: "NeoTerm #${termService!!.sessions.size}" + session.mSessionName = sessionName ?: generateSessionName("NeoTerm") val tab = createTab(session.mSessionName) as TermTab tab.termData.initializeSessionWith(session, sessionCallback, viewClient) @@ -443,6 +445,14 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference switchToSession(tab) } + private fun addXSession() { + + } + + private fun generateSessionName(prefix: String): String { + return "$prefix #${termService!!.sessions.size}" + } + private fun switchToSession(session: TerminalSession?) { if (session == null) { return @@ -483,9 +493,14 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference } private fun createTab(tabTitle: String?): Tab { - val tab = TermTab(tabTitle ?: "NeoTerm") - tab.isCloseable = true + return postTabCreated(TermTab(tabTitle ?: "NeoTerm")) + } + private fun createXTab(tabTitle: String?): Tab { + return postTabCreated(XSessionTab(tabTitle ?: "NeoTerm")) + } + + private fun postTabCreated(tab: T) : T { // We must create a Bundle for each tab // tabs can use them to store status. tab.parameters = Bundle() diff --git a/app/src/main/java/io/neoterm/ui/term/tab/XSessionTab.kt b/app/src/main/java/io/neoterm/ui/term/tab/XSessionTab.kt index 7804255..dc29b7e 100644 --- a/app/src/main/java/io/neoterm/ui/term/tab/XSessionTab.kt +++ b/app/src/main/java/io/neoterm/ui/term/tab/XSessionTab.kt @@ -5,4 +5,6 @@ import de.mrapp.android.tabswitcher.Tab /** * @author kiva */ -class XSessionTab(title: CharSequence) : Tab(title) {} +class XSessionTab(title: CharSequence) : Tab(title) { + +} diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index eb782c2..de23c32 100755 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -17,6 +17,12 @@ android:id="@+id/menu_item_new_system_session" android:title="@string/new_system_session" app:showAsAction="never" /> + + + Select Enter new color Toggle extra keys + New X Session sh @@ -145,12 +146,10 @@ - mirrors.geekpie.org neoterm.studio - https://mirrors.geekpie.org/neoterm http://neoterm.studio