Installer: Add debug source

This commit is contained in:
zt515 2017-07-01 23:53:12 +08:00
parent 9ae6981bb9
commit 8df8b714bf
8 changed files with 68 additions and 67 deletions

View File

@ -20,4 +20,8 @@ object NeoTermPath {
const val DEFAULT_SOURCE = "https://mirrors.geekpie.org/neoterm"
const val SERVER_BASE_URL = DEFAULT_SOURCE
const val SERVER_BOOT_URL = "$SERVER_BASE_URL/boot"
const val DEBUG_SOURCE = "http://192.243.117.135"
const val DEBUG_SERVER = DEBUG_SOURCE
const val DEBUG_SERVER_BOOT_URL = "$DEBUG_SERVER/boot"
}

View File

@ -1,4 +1,4 @@
package io.neoterm.customize.installer;
package io.neoterm.customize.setup;
import android.app.Activity;
import android.app.ProgressDialog;
@ -22,6 +22,7 @@ import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import io.neoterm.BuildConfig;
import io.neoterm.R;
import io.neoterm.backend.EmulatorDebug;
import io.neoterm.customize.NeoTermPath;
@ -190,7 +191,8 @@ public final class BaseFileInstaller {
private static URL determineZipUrl() throws MalformedURLException {
String archName = determineArchName();
return new URL(NeoTermPath.SERVER_BOOT_URL + "/" + archName + ".zip");
String baseUrl = BuildConfig.DEBUG ? NeoTermPath.DEBUG_SERVER_BOOT_URL : NeoTermPath.SERVER_BOOT_URL;
return new URL(baseUrl + "/" + archName + ".zip");
}
private static String determineArchName() {

View File

@ -22,10 +22,11 @@ import io.neoterm.backend.TerminalSession
import io.neoterm.customize.font.FontManager
import io.neoterm.customize.eks.EksConfigLoader
import io.neoterm.customize.eks.builtin.BuiltinEksKeys
import io.neoterm.customize.installer.BaseFileInstaller
import io.neoterm.customize.setup.BaseFileInstaller
import io.neoterm.preference.NeoPermission
import io.neoterm.preference.NeoPreference
import io.neoterm.services.NeoTermService
import io.neoterm.ui.pm.PackageManagerActivity
import io.neoterm.ui.settings.SettingActivity
import io.neoterm.utils.FullScreenHelper
import io.neoterm.view.eks.StatedControlButton
@ -387,6 +388,10 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0)
true
}
R.id.menu_item_package_settings -> {
startActivity(Intent(this, PackageManagerActivity::class.java))
true
}
R.id.menu_item_new_session -> {
if (!tabSwitcher.isSwitcherShown) {
tabSwitcher.showSwitcher()

View File

@ -27,7 +27,7 @@ import io.neoterm.preference.NeoPreference
import io.neoterm.ui.pm.adapter.PackageAdapter
import io.neoterm.ui.pm.model.PackageModel
import io.neoterm.utils.FileUtils
import io.neoterm.utils.TerminalDialog
import io.neoterm.view.TerminalDialog
import java.io.File
import java.net.URL
@ -59,18 +59,20 @@ class PackageManagerActivity : AppCompatActivity(), SearchView.OnQueryTextListen
progressBar = findViewById(R.id.package_loading_progress_bar) as ProgressBar
recyclerView = findViewById(R.id.package_list) as RecyclerView
recyclerView.setHasFixedSize(true)
adapter = PackageAdapter(this, COMPARATOR, PackageAdapter.Listener {
AlertDialog.Builder(this@PackageManagerActivity)
.setTitle(it.packageInfo.packageName)
.setMessage(it.getPackageDetails(this@PackageManagerActivity))
.setPositiveButton(R.string.install, { _, _ ->
val dialog = TerminalDialog(this@PackageManagerActivity, null)
dialog.execute("${NeoTermPath.USR_PATH}/bin/apt",
arrayOf("apt", "install", "-y", it.packageInfo.packageName!!))
dialog.show("Installing ${it.packageInfo.packageName}")
})
.setNegativeButton(android.R.string.no, null)
.show()
adapter = PackageAdapter(this, COMPARATOR, object : PackageAdapter.Listener {
override fun onModelClicked(model: PackageModel) {
AlertDialog.Builder(this@PackageManagerActivity)
.setTitle(model.packageInfo.packageName)
.setMessage(model.getPackageDetails(this@PackageManagerActivity))
.setPositiveButton(R.string.install, { _, _ ->
val dialog = TerminalDialog(this@PackageManagerActivity, null)
dialog.execute("${NeoTermPath.USR_PATH}/bin/apt",
arrayOf("apt", "install", "-y", model.packageInfo.packageName!!))
dialog.show("Installing ${model.packageInfo.packageName}")
})
.setNegativeButton(android.R.string.no, null)
.show()
}
}, FastScrollRecyclerView.SectionedAdapter {
models[it].packageInfo.packageName?.substring(0, 1) ?: "#"

View File

@ -1,45 +0,0 @@
package io.neoterm.ui.pm.adapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.github.wrdlbrnft.sortedlistadapter.SortedListAdapter;
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView;
import java.util.Comparator;
import io.neoterm.R;
import io.neoterm.ui.pm.adapter.viewholder.PackageViewHolder;
import io.neoterm.ui.pm.model.PackageModel;
public class PackageAdapter extends SortedListAdapter<PackageModel> implements FastScrollRecyclerView.SectionedAdapter {
@NonNull
@Override
public String getSectionName(int position) {
return sectionedAdapter != null ? sectionedAdapter.getSectionName(position) : "#";
}
public interface Listener {
void onModelClicked(PackageModel model);
}
private final Listener listener;
private final FastScrollRecyclerView.SectionedAdapter sectionedAdapter;
public PackageAdapter(Context context, Comparator<PackageModel> comparator, Listener listener, FastScrollRecyclerView.SectionedAdapter sectionedAdapter) {
super(context, PackageModel.class, comparator);
this.listener = listener;
this.sectionedAdapter = sectionedAdapter;
}
@NonNull
@Override
protected ViewHolder<? extends PackageModel> onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent, int viewType) {
final View rootView = inflater.inflate(R.layout.package_item, parent, false);
return new PackageViewHolder(rootView, listener);
}
}

View File

@ -0,0 +1,27 @@
package io.neoterm.ui.pm.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.ui.pm.adapter.viewholder.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 {
override fun getSectionName(position: Int): String {
return sectionedAdapter?.getSectionName(position) ?: "#"
}
interface Listener {
fun onModelClicked(model: PackageModel)
}
override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup, viewType: Int): SortedListAdapter.ViewHolder<out PackageModel> {
val rootView = inflater.inflate(R.layout.package_item, parent, false)
return PackageViewHolder(rootView, listener)
}
}

View File

@ -1,4 +1,4 @@
package io.neoterm.utils
package io.neoterm.view
import android.app.AlertDialog
import android.content.Context
@ -11,6 +11,7 @@ import android.view.View
import io.neoterm.R
import io.neoterm.backend.TerminalSession
import io.neoterm.preference.NeoPreference
import io.neoterm.utils.TerminalUtils
import io.neoterm.view.TerminalView
import io.neoterm.view.TerminalViewClient

View File

@ -14,27 +14,32 @@ implied. See the License for the specific language governing permissions and lim
License.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/toggle_tab_switcher_menu_item"
android:title="@string/toggle_tab_switcher_menu_item"
app:actionLayout="@layout/tab_switcher_menu_item"
app:showAsAction="ifRoom"/>
app:showAsAction="ifRoom" />
<item
android:id="@+id/menu_item_new_session"
android:title="@string/new_session"
app:showAsAction="never"/>
app:showAsAction="never" />
<item
android:id="@+id/menu_item_toggle_ime"
android:title="@string/toggle_ime"
app:showAsAction="never"/>
app:showAsAction="never" />
<item
android:id="@+id/menu_item_package_settings"
android:title="@string/package_settings"
app:showAsAction="never" />
<item
android:id="@+id/menu_item_settings"
android:title="@string/settings"
app:showAsAction="never"/>
app:showAsAction="never" />
</menu>