MISC: change all indent to 2 spaces (so compat!)

This commit is contained in:
imkiva 2021-05-08 00:11:00 +08:00 committed by Kiva Oyama
parent 880082458a
commit e8e9162fcf
326 changed files with 37875 additions and 38821 deletions

View File

@ -2,8 +2,12 @@
## Our Pledge ## Our Pledge
Originally, NeoTerm was designed as the front end of [Termux](https://github.com/termux/termux-app) to provide some functions that Termux didn't have, but we found it very convenient. In continuous development, we discovered our goal: to be the best terminal for Android. Originally, NeoTerm was designed as the front end of [Termux](https://github.com/termux/termux-app) to provide some
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. functions that Termux didn't have, but we found it very convenient. In continuous development, we discovered our goal:
to be the best terminal for Android. In the interest of fostering an open and welcoming environment, we as contributors
and maintainers pledge to making participation in our project and our community a harassment-free experience for
everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards ## Our Standards
@ -26,23 +30,35 @@ Examples of unacceptable behavior by participants include:
## Our Responsibilities ## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take
appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any
contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope ## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the
project or its community. Examples of representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed representative at an online or offline
event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement ## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at kiva515@foxmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at
kiva515@foxmail.com. The project team will review and investigate all complaints, and will respond in a way that it
deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the
reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent
repercussions as determined by other members of the project's leadership.
## Attribution ## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available
at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org [homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/ [version]: http://contributor-covenant.org/version/1/4/

View File

@ -1,5 +1,6 @@
# Contributing # Contributing
# How to # How to
NeoTerm is a free software, so any contributions and any contribution types are welcomed! NeoTerm is a free software, so any contributions and any contribution types are welcomed!

View File

@ -4,7 +4,6 @@ import io.neolang.ast.NeoLangEOFToken
import io.neolang.ast.NeoLangToken import io.neolang.ast.NeoLangToken
import io.neolang.ast.NeoLangTokenType import io.neolang.ast.NeoLangTokenType
import io.neolang.ast.NeoLangTokenValue import io.neolang.ast.NeoLangTokenValue
import java.util.*
/** /**
* grammar: [ * grammar: [
@ -69,7 +68,8 @@ class NeoLangLexer {
while (currentChar == ' ' while (currentChar == ' '
|| currentChar == '\t' || currentChar == '\t'
|| currentChar == '\n' || currentChar == '\n'
|| currentChar == '\r') { || currentChar == '\r'
) {
if (currentChar == '\n') { if (currentChar == '\n') {
++lineNumber ++lineNumber
} }

View File

@ -49,9 +49,11 @@ class NeoLangParser {
return true return true
} else if (errorThrow) { } else if (errorThrow) {
throw InvalidTokenException("Unexpected token `${currentToken.tokenValue}' typed " + throw InvalidTokenException(
"Unexpected token `${currentToken.tokenValue}' typed " +
"`${currentToken.tokenType}' near line ${currentToken.lineNumber}, " + "`${currentToken.tokenType}' near line ${currentToken.lineNumber}, " +
"expected $tokenType") "expected $tokenType"
)
} }
return false return false
@ -88,7 +90,8 @@ class NeoLangParser {
while (token.tokenType !== NeoLangTokenType.EOF while (token.tokenType !== NeoLangTokenType.EOF
&& token.tokenType !== NeoLangTokenType.BRACKET_END && token.tokenType !== NeoLangTokenType.BRACKET_END
&& token.tokenType !== NeoLangTokenType.ARRAY_END) { && token.tokenType !== NeoLangTokenType.ARRAY_END
) {
attr = attribute() attr = attribute()
if (attr == null) { if (attr == null) {
break break
@ -127,7 +130,8 @@ class NeoLangParser {
if (match(NeoLangTokenType.COMMA)) { if (match(NeoLangTokenType.COMMA)) {
// More than one elements // More than one elements
while (token.tokenType !== NeoLangTokenType.EOF while (token.tokenType !== NeoLangTokenType.EOF
&& token.tokenType !== NeoLangTokenType.ARRAY_END) { && token.tokenType !== NeoLangTokenType.ARRAY_END
) {
block = blockNonArrayElement(arrayName) block = blockNonArrayElement(arrayName)
if (block == null) { if (block == null) {
break break

View File

@ -5,7 +5,10 @@ import io.neolang.runtime.context.NeoLangContext
/** /**
* @author kiva * @author kiva
*/ */
class NeoLangArray private constructor(val elements: List<NeoLangArrayElement>, override val size: Int = elements.size) : Collection<NeoLangArrayElement> { class NeoLangArray private constructor(
val elements: List<NeoLangArrayElement>,
override val size: Int = elements.size
) : Collection<NeoLangArrayElement> {
companion object { companion object {
internal class PrimaryElement(val primaryValue: NeoLangValue) : NeoLangArrayElement() { internal class PrimaryElement(val primaryValue: NeoLangValue) : NeoLangArrayElement() {
override fun eval(): NeoLangValue { override fun eval(): NeoLangValue {

View File

@ -1,2 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest
package="io.neoterm.bridge"/> package="io.neoterm.bridge"/>

View File

@ -2,7 +2,7 @@ package io.neoterm.bridge;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
/** /**
* Example local unit test, which will execute on the development machine (host). * Example local unit test, which will execute on the development machine (host).

View File

@ -7,14 +7,18 @@ NeoTerm
A modern-designed android terminal emulator for the 21st century. A modern-designed android terminal emulator for the 21st century.
### Our Pledge ### Our Pledge
Originally, NeoTerm was designed as the front end of Termux to provide some functions that Termux didn't have, but we found it very convenient. In continuous development, we discovered our goal: to be the best terminal for Android.
Originally, NeoTerm was designed as the front end of Termux to provide some functions that Termux didn't have, but we
found it very convenient. In continuous development, we discovered our goal: to be the best terminal for Android.
### Help & Documentation ### Help & Documentation
View on [GitBook](https://neoterm.gitbooks.io/neoterm-wiki/content) View on [GitBook](https://neoterm.gitbooks.io/neoterm-wiki/content)
View on [GitHub](https://github.com/NeoTerm/NeoTerm-Wiki) View on [GitHub](https://github.com/NeoTerm/NeoTerm-Wiki)
### Download ### Download
[GitHub Release Page](https://github.com/NeoTerm/NeoTerm/releases) [GitHub Release Page](https://github.com/NeoTerm/NeoTerm/releases)
[lzzySoft's F-Droid repo](https://apt.izzysoft.de/fdroid/index/apk/io.neoterm) (thanks to @lzzySoft) [lzzySoft's F-Droid repo](https://apt.izzysoft.de/fdroid/index/apk/io.neoterm) (thanks to @lzzySoft)

View File

@ -1,2 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest
package="io.neoterm.xorg"/> package="io.neoterm.xorg"/>

View File

@ -27,30 +27,26 @@ import android.hardware.Sensor;
import android.hardware.SensorEvent; import android.hardware.SensorEvent;
import android.hardware.SensorEventListener; import android.hardware.SensorEventListener;
import android.hardware.SensorManager; import android.hardware.SensorManager;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log; import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Arrays; import java.util.Arrays;
@SuppressWarnings("JniMissingFunction") @SuppressWarnings("JniMissingFunction")
class AccelerometerReader implements SensorEventListener class AccelerometerReader implements SensorEventListener {
{
private SensorManager _manager = null; private SensorManager _manager = null;
public boolean openedBySDL = false; public boolean openedBySDL = false;
public static final GyroscopeListener gyro = new GyroscopeListener(); public static final GyroscopeListener gyro = new GyroscopeListener();
public static final OrientationListener orientation = new OrientationListener(); public static final OrientationListener orientation = new OrientationListener();
public AccelerometerReader(Context context) public AccelerometerReader(Context context) {
{
_manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); _manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
} }
public synchronized void stop() public synchronized void stop() {
{ if (_manager != null) {
if( _manager != null )
{
Log.i("SDL", "libSDL: stopping accelerometer/gyroscope/orientation"); Log.i("SDL", "libSDL: stopping accelerometer/gyroscope/orientation");
_manager.unregisterListener(this); _manager.unregisterListener(this);
_manager.unregisterListener(gyro); _manager.unregisterListener(gyro);
@ -58,23 +54,19 @@ class AccelerometerReader implements SensorEventListener
} }
} }
public synchronized void start() public synchronized void start() {
{
if ((Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer) && if ((Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer) &&
_manager != null && _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null ) _manager != null && _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null) {
{
Log.i("SDL", "libSDL: starting accelerometer"); Log.i("SDL", "libSDL: starting accelerometer");
_manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME); _manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
} }
if ((Globals.AppUsesGyroscope || Globals.MoveMouseWithGyroscope) && if ((Globals.AppUsesGyroscope || Globals.MoveMouseWithGyroscope) &&
_manager != null && _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null ) _manager != null && _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null) {
{
Log.i("SDL", "libSDL: starting gyroscope"); Log.i("SDL", "libSDL: starting gyroscope");
_manager.registerListener(gyro, _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME); _manager.registerListener(gyro, _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
} }
if ((Globals.AppUsesOrientationSensor) && _manager != null && if ((Globals.AppUsesOrientationSensor) && _manager != null &&
_manager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR) != null ) _manager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR) != null) {
{
Log.i("SDL", "libSDL: starting orientation sensor"); Log.i("SDL", "libSDL: starting orientation sensor");
_manager.registerListener(orientation, _manager.getDefaultSensor( _manager.registerListener(orientation, _manager.getDefaultSensor(
Sensor.TYPE_GAME_ROTATION_VECTOR), Sensor.TYPE_GAME_ROTATION_VECTOR),
@ -82,25 +74,20 @@ class AccelerometerReader implements SensorEventListener
} }
} }
public void onSensorChanged(SensorEvent event) public void onSensorChanged(SensorEvent event) {
{ if (Globals.HorizontalOrientation) {
if( Globals.HorizontalOrientation )
{
if (gyro.invertedOrientation) if (gyro.invertedOrientation)
nativeAccelerometer(-event.values[1], event.values[0], event.values[2]); nativeAccelerometer(-event.values[1], event.values[0], event.values[2]);
else else
nativeAccelerometer(event.values[1], -event.values[0], event.values[2]); nativeAccelerometer(event.values[1], -event.values[0], event.values[2]);
} } else
else
nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested! nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested!
} }
public void onAccuracyChanged(Sensor s, int a) public void onAccuracyChanged(Sensor s, int a) {
{
} }
static class GyroscopeListener implements SensorEventListener static class GyroscopeListener implements SensorEventListener {
{
public boolean invertedOrientation = false; public boolean invertedOrientation = false;
// Noise filter with sane initial values, so user will be able // Noise filter with sane initial values, so user will be able
@ -130,19 +117,14 @@ class AccelerometerReader implements SensorEventListener
// How long the algorithm is running, to stop it if it does not converge. // How long the algorithm is running, to stop it if it does not converge.
int measurementIteration = 0; int measurementIteration = 0;
public GyroscopeListener() public GyroscopeListener() {
{
} }
void collectNoiseData(final float[] data) void collectNoiseData(final float[] data) {
{ for (int i = 0; i < noiseMin.length; i++) {
for( int i = 0; i < noiseMin.length; i++ ) if (data[i] < noiseMin[i] || data[i] > noiseMax[i]) {
{
if( data[i] < noiseMin[i] || data[i] > noiseMax[i] )
{
// Movement detected, this can converge our min/max too early, so we're discarding last few values // Movement detected, this can converge our min/max too early, so we're discarding last few values
if( movementBackoff < 0 ) if (movementBackoff < 0) {
{
int discard = 10; int discard = 10;
if (-movementBackoff < discard) if (-movementBackoff < discard)
discard = -movementBackoff; discard = -movementBackoff;
@ -165,14 +147,12 @@ class AccelerometerReader implements SensorEventListener
measurementIteration++; measurementIteration++;
Log.d("SDL", "GYRO_NOISE: Measuring in progress... " + measurementIteration); Log.d("SDL", "GYRO_NOISE: Measuring in progress... " + measurementIteration);
if( measurementIteration > 5 ) if (measurementIteration > 5) {
{
// We've collected enough data to use our noise min/max values as a new filter // We've collected enough data to use our noise min/max values as a new filter
System.arraycopy(noiseMin, 0, filterMin, 0, filterMin.length); System.arraycopy(noiseMin, 0, filterMin, 0, filterMin.length);
System.arraycopy(noiseMax, 0, filterMax, 0, filterMax.length); System.arraycopy(noiseMax, 0, filterMax, 0, filterMax.length);
} }
if( measurementIteration > 15 ) if (measurementIteration > 15) {
{
Log.d("SDL", "GYRO_NOISE: Measuring done! Maximum number of iterations reached: " + measurementIteration); Log.d("SDL", "GYRO_NOISE: Measuring done! Maximum number of iterations reached: " + measurementIteration);
noiseData = null; noiseData = null;
measuredNoiseRange = null; measuredNoiseRange = null;
@ -181,12 +161,10 @@ class AccelerometerReader implements SensorEventListener
noiseDataIdx = 0; noiseDataIdx = 0;
boolean changed = false; boolean changed = false;
for( int i = 0; i < noiseMin.length; i++ ) for (int i = 0; i < noiseMin.length; i++) {
{
float min = 1.0f; float min = 1.0f;
float max = -1.0f; float max = -1.0f;
for( int ii = 0; ii < noiseData.length; ii++ ) for (int ii = 0; ii < noiseData.length; ii++) {
{
if (min > noiseData[ii][i]) if (min > noiseData[ii][i])
min = noiseData[ii][i]; min = noiseData[ii][i];
if (max < noiseData[ii][i]) if (max < noiseData[ii][i])
@ -198,8 +176,7 @@ class AccelerometerReader implements SensorEventListener
max += (max - middle) * 0.2f; max += (max - middle) * 0.2f;
// Check if range between min/max is less then the current range, as a safety measure, // Check if range between min/max is less then the current range, as a safety measure,
// and min/max range is not jumping outside of previously measured range // and min/max range is not jumping outside of previously measured range
if( max - min < noiseMax[i] - noiseMin[i] && min >= noiseMin[i] && max <= noiseMax[i] ) if (max - min < noiseMax[i] - noiseMin[i] && min >= noiseMin[i] && max <= noiseMax[i]) {
{
// Move old min/max closer to the measured min/max, but do not replace the values altogether // Move old min/max closer to the measured min/max, but do not replace the values altogether
noiseMin[i] = (noiseMin[i] + min * 4.0f) / 5.0f; noiseMin[i] = (noiseMin[i] + min * 4.0f) / 5.0f;
noiseMax[i] = (noiseMax[i] + max * 4.0f) / 5.0f; noiseMax[i] = (noiseMax[i] + max * 4.0f) / 5.0f;
@ -220,16 +197,13 @@ class AccelerometerReader implements SensorEventListener
Log.d("SDL", "GYRO_NOISE: RANGE: " + Arrays.toString(range) + " " + Arrays.toString(measuredNoiseRange)); Log.d("SDL", "GYRO_NOISE: RANGE: " + Arrays.toString(range) + " " + Arrays.toString(measuredNoiseRange));
if( measuredNoiseRange == null ) if (measuredNoiseRange == null) {
{
measuredNoiseRange = range; measuredNoiseRange = range;
return; // First iteration, skip further checks return; // First iteration, skip further checks
} }
for( int i = 0; i < range.length; i++ ) for (int i = 0; i < range.length; i++) {
{ if (measuredNoiseRange[i] / range[i] > 1.2f) {
if( measuredNoiseRange[i] / range[i] > 1.2f )
{
measuredNoiseRange = range; measuredNoiseRange = range;
return; return;
} }
@ -243,23 +217,18 @@ class AccelerometerReader implements SensorEventListener
Log.d("SDL", "GYRO_NOISE: Measuring done! Range converged on iteration " + measurementIteration); Log.d("SDL", "GYRO_NOISE: Measuring done! Range converged on iteration " + measurementIteration);
} }
public void onSensorChanged(final SensorEvent event) public void onSensorChanged(final SensorEvent event) {
{
boolean filtered = true; boolean filtered = true;
final float[] data = event.values; final float[] data = event.values;
if (noiseData != null) if (noiseData != null)
collectNoiseData(data); collectNoiseData(data);
for( int i = 0; i < 3; i++ ) for (int i = 0; i < 3; i++) {
{ if (data[i] < filterMin[i]) {
if( data[i] < filterMin[i] )
{
filtered = false; filtered = false;
data[i] -= filterMin[i]; data[i] -= filterMin[i];
} } else if (data[i] > filterMax[i]) {
else if( data[i] > filterMax[i] )
{
filtered = false; filtered = false;
data[i] -= filterMax[i]; data[i] -= filterMax[i];
} }
@ -268,15 +237,12 @@ class AccelerometerReader implements SensorEventListener
if (filtered) if (filtered)
return; return;
if( Globals.HorizontalOrientation ) if (Globals.HorizontalOrientation) {
{
if (invertedOrientation) if (invertedOrientation)
nativeGyroscope(-data[0], -data[1], data[2]); nativeGyroscope(-data[0], -data[1], data[2]);
else else
nativeGyroscope(data[0], data[1], data[2]); nativeGyroscope(data[0], data[1], data[2]);
} } else {
else
{
if (invertedOrientation) if (invertedOrientation)
nativeGyroscope(-data[1], data[0], data[2]); nativeGyroscope(-data[1], data[0], data[2]);
else else
@ -284,16 +250,15 @@ class AccelerometerReader implements SensorEventListener
} }
} }
public void onAccuracyChanged(Sensor s, int a) public void onAccuracyChanged(Sensor s, int a) {
{
} }
public boolean available(AppCompatActivity context)
{ public boolean available(AppCompatActivity context) {
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
return (manager != null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null); return (manager != null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null);
} }
public void registerListener(AppCompatActivity context, SensorEventListener l)
{ public void registerListener(AppCompatActivity context, SensorEventListener l) {
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
if (manager == null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) == null) if (manager == null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) == null)
return; return;
@ -301,8 +266,8 @@ class AccelerometerReader implements SensorEventListener
Globals.AppUsesOrientationSensor ? Sensor.TYPE_GAME_ROTATION_VECTOR : Sensor.TYPE_GYROSCOPE), Globals.AppUsesOrientationSensor ? Sensor.TYPE_GAME_ROTATION_VECTOR : Sensor.TYPE_GYROSCOPE),
SensorManager.SENSOR_DELAY_GAME); SensorManager.SENSOR_DELAY_GAME);
} }
public void unregisterListener(AppCompatActivity context, SensorEventListener l)
{ public void unregisterListener(AppCompatActivity context, SensorEventListener l) {
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
if (manager == null) if (manager == null)
return; return;
@ -310,21 +275,21 @@ class AccelerometerReader implements SensorEventListener
} }
} }
static class OrientationListener implements SensorEventListener static class OrientationListener implements SensorEventListener {
{ public OrientationListener() {
public OrientationListener()
{
} }
public void onSensorChanged(SensorEvent event)
{ public void onSensorChanged(SensorEvent event) {
nativeOrientation(event.values[0], event.values[1], event.values[2]); nativeOrientation(event.values[0], event.values[1], event.values[2]);
} }
public void onAccuracyChanged(Sensor s, int a)
{ public void onAccuracyChanged(Sensor s, int a) {
} }
} }
private static native void nativeAccelerometer(float accX, float accY, float accZ); private static native void nativeAccelerometer(float accX, float accY, float accZ);
private static native void nativeGyroscope(float X, float Y, float Z); private static native void nativeGyroscope(float X, float Y, float Z);
private static native void nativeOrientation(float X, float Y, float Z); private static native void nativeOrientation(float X, float Y, float Z);
} }

View File

@ -23,52 +23,37 @@ freely, subject to the following restrictions:
package io.neoterm; package io.neoterm;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.media.AudioTrack;
import android.media.AudioManager;
import android.media.AudioFormat; import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord; import android.media.AudioRecord;
import android.media.AudioTrack;
import android.media.MediaRecorder.AudioSource; import android.media.MediaRecorder.AudioSource;
import java.io.*;
import android.util.Log; import android.util.Log;
import java.util.concurrent.Semaphore;
import android.Manifest;
import android.content.pm.PackageManager;
import io.neoterm.xorg.NeoXorgViewClient; import io.neoterm.xorg.NeoXorgViewClient;
import java.util.concurrent.Semaphore;
@SuppressWarnings("JniMissingFunction") @SuppressWarnings("JniMissingFunction")
class AudioThread class AudioThread {
{
private NeoXorgViewClient mClient; private NeoXorgViewClient mClient;
private AudioTrack mAudio; private AudioTrack mAudio;
private byte[] mAudioBuffer; private byte[] mAudioBuffer;
private int mVirtualBufSize; private int mVirtualBufSize;
public AudioThread(NeoXorgViewClient client) public AudioThread(NeoXorgViewClient client) {
{
this.mClient = client; this.mClient = client;
mAudio = null; mAudio = null;
mAudioBuffer = null; mAudioBuffer = null;
nativeAudioInitJavaCallbacks(); nativeAudioInitJavaCallbacks();
} }
public int fillBuffer() public int fillBuffer() {
{ if (mClient.isPaused()) {
if( mClient.isPaused() )
{
try { try {
Thread.sleep(500); Thread.sleep(500);
} catch (InterruptedException e) {} } catch (InterruptedException e) {
} }
else } else {
{
//if( Globals.AudioBufferConfig == 0 ) // Gives too much spam to logcat, makes things worse //if( Globals.AudioBufferConfig == 0 ) // Gives too much spam to logcat, makes things worse
// mAudio.flush(); // mAudio.flush();
@ -78,10 +63,8 @@ class AudioThread
return 1; return 1;
} }
public int initAudio(int rate, int channels, int encoding, int bufSize) public int initAudio(int rate, int channels, int encoding, int bufSize) {
{ if (mAudio == null) {
if( mAudio == null )
{
channels = (channels == 1) ? AudioFormat.CHANNEL_CONFIGURATION_MONO : channels = (channels == 1) ? AudioFormat.CHANNEL_CONFIGURATION_MONO :
AudioFormat.CHANNEL_CONFIGURATION_STEREO; AudioFormat.CHANNEL_CONFIGURATION_STEREO;
encoding = (encoding == 1) ? AudioFormat.ENCODING_PCM_16BIT : encoding = (encoding == 1) ? AudioFormat.ENCODING_PCM_16BIT :
@ -109,15 +92,12 @@ class AudioThread
return mVirtualBufSize; return mVirtualBufSize;
} }
public byte[] getBuffer() public byte[] getBuffer() {
{
return mAudioBuffer; return mAudioBuffer;
} }
public int deinitAudio() public int deinitAudio() {
{ if (mAudio != null) {
if( mAudio != null )
{
mAudio.stop(); mAudio.stop();
mAudio.release(); mAudio.release();
mAudio = null; mAudio = null;
@ -126,34 +106,27 @@ class AudioThread
return 1; return 1;
} }
public int initAudioThread() public int initAudioThread() {
{
// Make audio thread priority higher so audio thread won't get underrun // Make audio thread priority higher so audio thread won't get underrun
Thread.currentThread().setPriority(Thread.MAX_PRIORITY); Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
return 1; return 1;
} }
public int pauseAudioPlayback() public int pauseAudioPlayback() {
{ if (mAudio != null) {
if( mAudio != null )
{
mAudio.pause(); mAudio.pause();
} }
if( mRecordThread != null ) if (mRecordThread != null) {
{
mRecordThread.pauseRecording(); mRecordThread.pauseRecording();
} }
return 1; return 1;
} }
public int resumeAudioPlayback() public int resumeAudioPlayback() {
{ if (mAudio != null) {
if( mAudio != null )
{
mAudio.play(); mAudio.play();
} }
if( mRecordThread != null ) if (mRecordThread != null) {
{
mRecordThread.resumeRecording(); mRecordThread.resumeRecording();
} }
return 1; return 1;
@ -167,15 +140,12 @@ class AudioThread
private AudioRecord mRecorder = null; private AudioRecord mRecorder = null;
private int mRecorderBufferSize = 0; private int mRecorderBufferSize = 0;
private byte[] startRecording(int rate, int channels, int encoding, int bufsize) private byte[] startRecording(int rate, int channels, int encoding, int bufsize) {
{ if (mRecordThread == null) {
if( mRecordThread == null )
{
mRecordThread = new RecordingThread(); mRecordThread = new RecordingThread();
mRecordThread.start(); mRecordThread.start();
} }
if( !mRecordThread.isStopped() ) if (!mRecordThread.isStopped()) {
{
Log.i("SDL", "SDL: error: application already opened audio recording device"); Log.i("SDL", "SDL: error: application already opened audio recording device");
return null; return null;
} }
@ -193,8 +163,7 @@ class AudioThread
if (mRecorder == null || mRecorder.getSampleRate() != rate || if (mRecorder == null || mRecorder.getSampleRate() != rate ||
mRecorder.getChannelCount() != channels || mRecorder.getChannelCount() != channels ||
mRecorder.getAudioFormat() != encodingConfig || mRecorder.getAudioFormat() != encodingConfig ||
mRecorderBufferSize != minBufferSize ) mRecorderBufferSize != minBufferSize) {
{
if (mRecorder != null) if (mRecorder != null)
mRecorder.release(); mRecorder.release();
mRecorder = null; mRecorder = null;
@ -217,19 +186,15 @@ class AudioThread
} }
} }
} }
} } else {
else
{
Log.i("SDL", "SDL: reusing old recording device"); Log.i("SDL", "SDL: reusing old recording device");
} }
mRecordThread.startRecording(); mRecordThread.startRecording();
return mRecordThread.mRecordBuffer; return mRecordThread.mRecordBuffer;
} }
private void stopRecording() private void stopRecording() {
{ if (mRecordThread == null || mRecordThread.isStopped()) {
if( mRecordThread == null || mRecordThread.isStopped() )
{
Log.i("SDL", "SDL: error: application already closed audio recording device"); Log.i("SDL", "SDL: error: application already closed audio recording device");
return; return;
} }
@ -237,45 +202,37 @@ class AudioThread
Log.i("SDL", "SDL: app closed recording device"); Log.i("SDL", "SDL: app closed recording device");
} }
private class RecordingThread extends Thread private class RecordingThread extends Thread {
{
private boolean stopped = true; private boolean stopped = true;
byte[] mRecordBuffer; byte[] mRecordBuffer;
private Semaphore waitStarted = new Semaphore(0); private Semaphore waitStarted = new Semaphore(0);
private boolean sleep = false; private boolean sleep = false;
RecordingThread() RecordingThread() {
{
super(); super();
} }
void init(int bufsize) void init(int bufsize) {
{
if (mRecordBuffer == null || mRecordBuffer.length != bufsize) if (mRecordBuffer == null || mRecordBuffer.length != bufsize)
mRecordBuffer = new byte[bufsize]; mRecordBuffer = new byte[bufsize];
} }
public void run() public void run() {
{ while (true) {
while( true )
{
waitStarted.acquireUninterruptibly(); waitStarted.acquireUninterruptibly();
waitStarted.drainPermits(); waitStarted.drainPermits();
stopped = false; stopped = false;
sleep = false; sleep = false;
while( !sleep ) while (!sleep) {
{
int got = mRecorder.read(mRecordBuffer, 0, mRecordBuffer.length); int got = mRecorder.read(mRecordBuffer, 0, mRecordBuffer.length);
if( got != mRecordBuffer.length ) if (got != mRecordBuffer.length) {
{
// Audio is stopped here, sleep a bit. // Audio is stopped here, sleep a bit.
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) {} } catch (InterruptedException e) {
} }
else } else {
{
//Log.i("SDL", "SDL: nativeAudioRecordCallback with len " + mRecordBuffer.length); //Log.i("SDL", "SDL: nativeAudioRecordCallback with len " + mRecordBuffer.length);
nativeAudioRecordCallback(); nativeAudioRecordCallback();
//Log.i("SDL", "SDL: nativeAudioRecordCallback returned"); //Log.i("SDL", "SDL: nativeAudioRecordCallback returned");
@ -287,33 +244,32 @@ class AudioThread
} }
} }
public void startRecording() public void startRecording() {
{
mRecorder.startRecording(); mRecorder.startRecording();
waitStarted.release(); waitStarted.release();
} }
public void stopRecording()
{ public void stopRecording() {
sleep = true; sleep = true;
while( !stopped ) while (!stopped) {
{
try { try {
Thread.sleep(100); Thread.sleep(100);
} catch (InterruptedException e) {} } catch (InterruptedException e) {
} }
} }
public void pauseRecording() }
{
public void pauseRecording() {
if (!stopped) if (!stopped)
mRecorder.stop(); mRecorder.stop();
} }
public void resumeRecording()
{ public void resumeRecording() {
if (!stopped) if (!stopped)
mRecorder.startRecording(); mRecorder.startRecording();
} }
public boolean isStopped()
{ public boolean isStopped() {
return stopped; return stopped;
} }
} }

View File

@ -22,53 +22,32 @@ freely, subject to the following restrictions:
package io.neoterm; package io.neoterm;
import android.os.Bundle;
import android.os.Build;
import android.os.Environment;
import android.util.DisplayMetrics;
import android.util.Log;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.AssetManager;
import android.app.Activity;
import android.view.MotionEvent;
import android.view.KeyEvent;
import android.view.InputDevice;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.ClipboardManager.OnPrimaryClipChangedListener; import android.content.ClipboardManager.OnPrimaryClipChangedListener;
import android.app.PendingIntent; import android.content.Context;
import android.app.AlarmManager; import android.os.Build;
import android.content.Intent; import android.util.Log;
import android.view.View;
import android.view.Display;
public abstract class Clipboard public abstract class Clipboard {
{ public static Clipboard get() {
public static Clipboard get()
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
return NewerClipboard.Holder.Instance; return NewerClipboard.Holder.Instance;
return OlderClipboard.Holder.Instance; return OlderClipboard.Holder.Instance;
} }
public abstract void set(final Context context, final String text); public abstract void set(final Context context, final String text);
public abstract String get(final Context context); public abstract String get(final Context context);
public abstract void setListener(final Context context, final Runnable listener); public abstract void setListener(final Context context, final Runnable listener);
private static class NewerClipboard extends Clipboard private static class NewerClipboard extends Clipboard {
{ private static class Holder {
private static class Holder
{
private static final NewerClipboard Instance = new NewerClipboard(); private static final NewerClipboard Instance = new NewerClipboard();
} }
public void set(final Context context, final String text)
{ public void set(final Context context, final String text) {
try { try {
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
if (clipboard != null) if (clipboard != null)
@ -77,8 +56,8 @@ public abstract class Clipboard
Log.i("SDL", "setClipboardText() exception: " + e.toString()); Log.i("SDL", "setClipboardText() exception: " + e.toString());
} }
} }
public String get(final Context context)
{ public String get(final Context context) {
String ret = ""; String ret = "";
try { try {
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
@ -89,27 +68,23 @@ public abstract class Clipboard
} }
return ret; return ret;
} }
public void setListener(final Context context, final Runnable listener)
{ public void setListener(final Context context, final Runnable listener) {
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
clipboard.addPrimaryClipChangedListener(new OnPrimaryClipChangedListener() clipboard.addPrimaryClipChangedListener(new OnPrimaryClipChangedListener() {
{ public void onPrimaryClipChanged() {
public void onPrimaryClipChanged()
{
listener.run(); listener.run();
} }
}); });
} }
} }
private static class OlderClipboard extends Clipboard private static class OlderClipboard extends Clipboard {
{ private static class Holder {
private static class Holder
{
private static final OlderClipboard Instance = new OlderClipboard(); private static final OlderClipboard Instance = new OlderClipboard();
} }
public void set(final Context context, final String text)
{ public void set(final Context context, final String text) {
try { try {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE); android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
if (clipboard != null) if (clipboard != null)
@ -118,8 +93,8 @@ public abstract class Clipboard
Log.i("SDL", "setClipboardText() exception: " + e.toString()); Log.i("SDL", "setClipboardText() exception: " + e.toString());
} }
} }
public String get(final Context context)
{ public String get(final Context context) {
String ret = ""; String ret = "";
try { try {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE); android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
@ -130,8 +105,8 @@ public abstract class Clipboard
} }
return ret; return ret;
} }
public void setListener(final Context context, final Runnable listener)
{ public void setListener(final Context context, final Runnable listener) {
Log.i("SDL", "Cannot set clipboard listener on Android 2.3 or older"); Log.i("SDL", "Cannot set clipboard listener on Android 2.3 or older");
} }
} }

View File

@ -20,27 +20,19 @@
package io.neoterm; package io.neoterm;
import java.io.Writer; import android.app.KeyguardManager;
import java.util.ArrayList;
import java.util.concurrent.Semaphore;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGL11;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
import javax.microedition.khronos.opengles.GL;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.EGL14; // Android 4.2 or newer
import android.content.Context; import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
import android.view.SurfaceView; import android.view.SurfaceView;
import android.app.KeyguardManager;
import javax.microedition.khronos.egl.*;
import javax.microedition.khronos.opengles.GL;
import javax.microedition.khronos.opengles.GL10;
import java.io.Writer;
import java.util.ArrayList;
import java.util.concurrent.Semaphore;
/** /**
* An implementation of SurfaceView that uses the dedicated surface for * An implementation of SurfaceView that uses the dedicated surface for
@ -149,7 +141,6 @@ import android.app.KeyguardManager;
* } * }
* } * }
* </pre> * </pre>
*
*/ */
@SuppressWarnings("ALL") @SuppressWarnings("ALL")
public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Callback { public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Callback {
@ -227,6 +218,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* Wrapping is typically used for debugging purposes. * Wrapping is typically used for debugging purposes.
* <p> * <p>
* The default value is null. * The default value is null.
*
* @param glWrapper the new GLWrapper * @param glWrapper the new GLWrapper
*/ */
public void setGLWrapper(GLWrapper glWrapper) { public void setGLWrapper(GLWrapper glWrapper) {
@ -238,6 +230,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* constructed by OR-together zero or more * constructed by OR-together zero or more
* of the DEBUG_CHECK_* constants. The debug flags take effect * of the DEBUG_CHECK_* constants. The debug flags take effect
* whenever a surface is created. The default value is zero. * whenever a surface is created. The default value is zero.
*
* @param debugFlags the new debug flags * @param debugFlags the new debug flags
* @see #DEBUG_CHECK_GL_ERROR * @see #DEBUG_CHECK_GL_ERROR
* @see #DEBUG_LOG_GL_CALLS * @see #DEBUG_LOG_GL_CALLS
@ -248,6 +241,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
/** /**
* Get the current value of the debug flags. * Get the current value of the debug flags.
*
* @return the current value of the debug flags. * @return the current value of the debug flags.
*/ */
public int getDebugFlags() { public int getDebugFlags() {
@ -301,6 +295,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* If no setEGLConfigChooser method is called, then by default the * If no setEGLConfigChooser method is called, then by default the
* view will choose a config as close to 16-bit RGB as possible, with * view will choose a config as close to 16-bit RGB as possible, with
* a depth buffer as close to 16 bits as possible. * a depth buffer as close to 16 bits as possible.
*
* @param configChooser * @param configChooser
*/ */
public void setEGLConfigChooser(EGLConfigChooser configChooser) { public void setEGLConfigChooser(EGLConfigChooser configChooser) {
@ -340,13 +335,13 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* If no setEGLConfigChooser method is called, then by default the * If no setEGLConfigChooser method is called, then by default the
* view will choose a config as close to 16-bit RGB as possible, with * view will choose a config as close to 16-bit RGB as possible, with
* a depth buffer as close to 16 bits as possible. * a depth buffer as close to 16 bits as possible.
*
*/ */
public void setEGLConfigChooser(int redSize, int greenSize, int blueSize, public void setEGLConfigChooser(int redSize, int greenSize, int blueSize,
int alphaSize, int depthSize, int stencilSize, boolean gles2, boolean gles3) { int alphaSize, int depthSize, int stencilSize, boolean gles2, boolean gles3) {
setEGLConfigChooser(new ComponentSizeChooser(redSize, greenSize, setEGLConfigChooser(new ComponentSizeChooser(redSize, greenSize,
blueSize, alphaSize, depthSize, stencilSize, gles2, gles3)); blueSize, alphaSize, depthSize, stencilSize, gles2, gles3));
} }
/** /**
* Set the rendering mode. When renderMode is * Set the rendering mode. When renderMode is
* RENDERMODE_CONTINUOUSLY, the renderer is called * RENDERMODE_CONTINUOUSLY, the renderer is called
@ -370,6 +365,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
/** /**
* Get the current rendering mode. May be called * Get the current rendering mode. May be called
* from any thread. Must not be called before a renderer has been set. * from any thread. Must not be called before a renderer has been set.
*
* @return the current rendering mode. * @return the current rendering mode.
* @see #RENDERMODE_CONTINUOUSLY * @see #RENDERMODE_CONTINUOUSLY
* @see #RENDERMODE_WHEN_DIRTY * @see #RENDERMODE_WHEN_DIRTY
@ -439,6 +435,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* Queue a runnable to be run on the GL rendering thread. This can be used * Queue a runnable to be run on the GL rendering thread. This can be used
* to communicate with the Renderer on the rendering thread. * to communicate with the Renderer on the rendering thread.
* Must not be called before a renderer has been set. * Must not be called before a renderer has been set.
*
* @param r the runnable to be run on the GL rendering thread. * @param r the runnable to be run on the GL rendering thread.
*/ */
public void queueEvent(Runnable r) { public void queueEvent(Runnable r) {
@ -477,11 +474,13 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* } * }
* } * }
* </pre> * </pre>
*
* @see #setGLWrapper(GLWrapper) * @see #setGLWrapper(GLWrapper)
*/ */
public interface GLWrapper { public interface GLWrapper {
/** /**
* Wraps a gl interface in another gl interface. * Wraps a gl interface in another gl interface.
*
* @param gl a GL interface that is to be wrapped. * @param gl a GL interface that is to be wrapped.
* @return either the input argument or another GL object that wraps the input argument. * @return either the input argument or another GL object that wraps the input argument.
*/ */
@ -514,12 +513,13 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* that it still needs. The {@link #onSurfaceCreated(GL10, EGLConfig)} method * that it still needs. The {@link #onSurfaceCreated(GL10, EGLConfig)} method
* is a convenient place to do this. * is a convenient place to do this.
* *
*
* @see #setRenderer(Renderer) * @see #setRenderer(Renderer)
*/ */
public static interface SwapBuffersCallback { public static interface SwapBuffersCallback {
public boolean SwapBuffers(); public boolean SwapBuffers();
public void ResetVideoSurface(); public void ResetVideoSurface();
public void onWindowResize(int width, int height); public void onWindowResize(int width, int height);
} }
@ -543,6 +543,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* the corresponding "glDelete" methods such as glDeleteTextures to * the corresponding "glDelete" methods such as glDeleteTextures to
* manually delete these lost resources. * manually delete these lost resources.
* <p> * <p>
*
* @param gl the GL interface. Use <code>instanceof</code> to * @param gl the GL interface. Use <code>instanceof</code> to
* test if the interface supports GL11 or higher interfaces. * test if the interface supports GL11 or higher interfaces.
* @param config the EGLConfig of the created surface. Can be used * @param config the EGLConfig of the created surface. Can be used
@ -570,6 +571,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10); * gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);
* } * }
* </pre> * </pre>
*
* @param gl the GL interface. Use <code>instanceof</code> to * @param gl the GL interface. Use <code>instanceof</code> to
* test if the interface supports GL11 or higher interfaces. * test if the interface supports GL11 or higher interfaces.
* @param width * @param width
@ -577,9 +579,10 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
*/ */
public abstract void onSurfaceChanged(GL10 gl, int width, int height); public abstract void onSurfaceChanged(GL10 gl, int width, int height);
/** Called when screen size changes */ /**
public void onWindowResize(int width, int height) * Called when screen size changes
{ */
public void onWindowResize(int width, int height) {
if (mSwapBuffersCallback != null) if (mSwapBuffersCallback != null)
mSwapBuffersCallback.onWindowResize(width, height); mSwapBuffersCallback.onWindowResize(width, height);
} }
@ -596,6 +599,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* //... other gl calls to render the scene ... * //... other gl calls to render the scene ...
* } * }
* </pre> * </pre>
*
* @param gl the GL interface. Use <code>instanceof</code> to * @param gl the GL interface. Use <code>instanceof</code> to
* test if the interface supports GL11 or higher interfaces. * test if the interface supports GL11 or higher interfaces.
*/ */
@ -632,12 +636,15 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* implement this method by calling * implement this method by calling
* {@link EGL10#eglChooseConfig} and iterating through the results. Please consult the * {@link EGL10#eglChooseConfig} and iterating through the results. Please consult the
* EGL specification available from The Khronos Group to learn how to call eglChooseConfig. * EGL specification available from The Khronos Group to learn how to call eglChooseConfig.
*
* @param egl the EGL10 for the current display. * @param egl the EGL10 for the current display.
* @param display the current display. * @param display the current display.
* @return the chosen configuration. * @return the chosen configuration.
*/ */
EGLConfig chooseConfig(EGL10 egl, EGLDisplay display); EGLConfig chooseConfig(EGL10 egl, EGLDisplay display);
public boolean isGles2Required(); public boolean isGles2Required();
public boolean isGles3Required(); public boolean isGles3Required();
} }
@ -646,6 +653,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
public BaseConfigChooser(int[] configSpec) { public BaseConfigChooser(int[] configSpec) {
mConfigSpec = configSpec; mConfigSpec = configSpec;
} }
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
int[] num_config = new int[1]; int[] num_config = new int[1];
egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config); egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config);
@ -783,13 +791,11 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
return defaultValue; return defaultValue;
} }
public boolean isGles2Required() public boolean isGles2Required() {
{
return mIsGles2; return mIsGles2;
} }
public boolean isGles3Required() public boolean isGles3Required() {
{
return mIsGles3; return mIsGles3;
} }
@ -814,7 +820,6 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
/** /**
* This class will choose a supported surface as close to * This class will choose a supported surface as close to
* RGB565 as possible, with or without a depth buffer. * RGB565 as possible, with or without a depth buffer.
*
*/ */
private static class SimpleEGLConfigChooser16 extends ComponentSizeChooser { private static class SimpleEGLConfigChooser16 extends ComponentSizeChooser {
public SimpleEGLConfigChooser16(boolean withDepthBuffer, boolean stencil, boolean gles2, boolean gles3) { public SimpleEGLConfigChooser16(boolean withDepthBuffer, boolean stencil, boolean gles2, boolean gles3) {
@ -845,6 +850,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
mAlphaSize = 8; mAlphaSize = 8;
} }
} }
private static ComponentSizeChooser getEglConfigChooser(int videoDepthBpp, boolean withDepthBuffer, boolean stencil, boolean gles2, boolean gles3) { private static ComponentSizeChooser getEglConfigChooser(int videoDepthBpp, boolean withDepthBuffer, boolean stencil, boolean gles2, boolean gles3) {
if (videoDepthBpp == 16) if (videoDepthBpp == 16)
return new SimpleEGLConfigChooser16(withDepthBuffer, stencil, gles2, gles3); return new SimpleEGLConfigChooser16(withDepthBuffer, stencil, gles2, gles3);
@ -853,7 +859,9 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
if (videoDepthBpp == 32) if (videoDepthBpp == 32)
return new SimpleEGLConfigChooser32(withDepthBuffer, stencil, gles2, gles3); return new SimpleEGLConfigChooser32(withDepthBuffer, stencil, gles2, gles3);
return null; return null;
}; }
;
/** /**
* An EGL helper class. * An EGL helper class.
@ -866,6 +874,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
/** /**
* Initialize EGL for a given configuration spec. * Initialize EGL for a given configuration spec.
*
* @param configSpec * @param configSpec
*/ */
public void start() { public void start() {
@ -961,6 +970,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
/** /**
* Display the current render surface. * Display the current render surface.
*
* @return false if the context has been lost. * @return false if the context has been lost.
*/ */
public boolean swap() { public boolean swap() {
@ -1005,7 +1015,6 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* A generic GL Thread. Takes care of initializing EGL and GL. Delegates * A generic GL Thread. Takes care of initializing EGL and GL. Delegates
* to a Renderer instance to do the actual drawing. Can be configured to * to a Renderer instance to do the actual drawing. Can be configured to
* render continuously or on request. * render continuously or on request.
*
*/ */
class GLThread extends Thread implements SwapBuffersCallback { class GLThread extends Thread implements SwapBuffersCallback {
GLThread(Renderer renderer) { GLThread(Renderer renderer) {
@ -1082,12 +1091,9 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
while (needToWait()) { while (needToWait()) {
//Log.v("SDL", "GLSurfaceView_SDL::run(): paused"); //Log.v("SDL", "GLSurfaceView_SDL::run(): paused");
synchronized (this) { synchronized (this) {
try try {
{
wait(500); wait(500);
} } catch (InterruptedException e) {
catch(InterruptedException e)
{
Log.v("SDL", "GLSurfaceView_SDL::GLThread::SwapBuffers(): Who dared to interrupt my slumber?"); Log.v("SDL", "GLSurfaceView_SDL::GLThread::SwapBuffers(): Who dared to interrupt my slumber?");
Thread.interrupted(); // Clear the flag Thread.interrupted(); // Clear the flag
} }
@ -1243,6 +1249,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
/** /**
* Queue an "event" to be run on the GL rendering thread. * Queue an "event" to be run on the GL rendering thread.
*
* @param r the runnable to be run on the GL rendering thread. * @param r the runnable to be run on the GL rendering thread.
*/ */
public void queueEvent(Runnable r) { public void queueEvent(Runnable r) {
@ -1291,8 +1298,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
char c = buf[offset + i]; char c = buf[offset + i];
if (c == '\n') { if (c == '\n') {
flushBuilder(); flushBuilder();
} } else {
else {
mBuilder.append(c); mBuilder.append(c);
} }
} }

View File

@ -22,16 +22,14 @@ freely, subject to the following restrictions:
package io.neoterm; package io.neoterm;
import java.lang.String; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.lang.reflect.Field;
// Autogenerated by hand with a command: // Autogenerated by hand with a command:
// grep 'SDLK_' SDL_keysym.h | sed 's/SDLK_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java // grep 'SDLK_' SDL_keysym.h | sed 's/SDLK_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java
class SDL_1_2_Keycodes class SDL_1_2_Keycodes {
{
public static final int SDLK_UNKNOWN = 0; public static final int SDLK_UNKNOWN = 0;
public static final int SDLK_BACKSPACE = 8; public static final int SDLK_BACKSPACE = 8;
public static final int SDLK_TAB = 9; public static final int SDLK_TAB = 9;
@ -279,8 +277,7 @@ class SDL_1_2_Keycodes
// Autogenerated by hand with a command: // Autogenerated by hand with a command:
// grep 'SDL_SCANCODE_' SDL_scancode.h | sed 's/SDL_SCANCODE_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java // grep 'SDL_SCANCODE_' SDL_scancode.h | sed 's/SDL_SCANCODE_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java
class SDL_1_3_Keycodes class SDL_1_3_Keycodes {
{
public static final int SDLK_UNKNOWN = 0; public static final int SDLK_UNKNOWN = 0;
public static final int SDLK_A = 4; public static final int SDLK_A = 4;
public static final int SDLK_B = 5; public static final int SDLK_B = 5;
@ -533,8 +530,7 @@ class SDL_1_3_Keycodes
public static final int SDLK_NO_REMAP = 512; public static final int SDLK_NO_REMAP = 512;
} }
class SDL_Keys class SDL_Keys {
{
public static String[] names = null; public static String[] names = null;
public static Integer[] values = null; public static Integer[] values = null;
@ -544,45 +540,38 @@ class SDL_Keys
static final int JAVA_KEYCODE_LAST = 255; // Android 2.3 added several new gaming keys, Android 3.1 added even more - keep in sync with javakeycodes.h static final int JAVA_KEYCODE_LAST = 255; // Android 2.3 added several new gaming keys, Android 3.1 added even more - keep in sync with javakeycodes.h
static String getName(int v) static String getName(int v) {
{ for (int f = 0; f < values.length; f++) {
for( int f = 0; f < values.length; f++ )
{
if (values[f] == v) if (values[f] == v)
return names[f]; return names[f];
} }
return names[0]; return names[0];
} }
static static {
{
ArrayList<String> Names = new ArrayList<String>(); ArrayList<String> Names = new ArrayList<String>();
ArrayList<Integer> Values = new ArrayList<Integer>(); ArrayList<Integer> Values = new ArrayList<Integer>();
Field[] fields = SDL_1_2_Keycodes.class.getDeclaredFields(); Field[] fields = SDL_1_2_Keycodes.class.getDeclaredFields();
if( Globals.Using_SDL_1_3 ) if (Globals.Using_SDL_1_3) {
{
fields = SDL_1_3_Keycodes.class.getDeclaredFields(); fields = SDL_1_3_Keycodes.class.getDeclaredFields();
} }
try { try {
for(Field f: fields) for (Field f : fields) {
{ if (!f.getName().startsWith("SDLK_")) {
if( !f.getName().startsWith("SDLK_") )
{
continue; continue;
} }
Values.add(f.getInt(null)); Values.add(f.getInt(null));
Names.add(f.getName().substring(5).toUpperCase()); Names.add(f.getName().substring(5).toUpperCase());
} }
} catch(IllegalAccessException e) {}; } catch (IllegalAccessException e) {
}
;
// Sort by value // Sort by value
for( int i = 0; i < Values.size(); i++ ) for (int i = 0; i < Values.size(); i++) {
{ for (int j = i; j < Values.size(); j++) {
for( int j = i; j < Values.size(); j++ ) if (Values.get(i) > Values.get(j)) {
{
if( Values.get(i) > Values.get(j) )
{
int x = Values.get(i); int x = Values.get(i);
Values.set(i, Values.get(j)); Values.set(i, Values.get(j));
Values.set(j, x); Values.set(j, x);
@ -599,12 +588,9 @@ class SDL_Keys
namesSortedIdx = new Integer[values.length]; namesSortedIdx = new Integer[values.length];
namesSortedBackIdx = new Integer[values.length]; namesSortedBackIdx = new Integer[values.length];
Arrays.sort(namesSorted); Arrays.sort(namesSorted);
for( int i = 0; i < namesSorted.length; i++ ) for (int i = 0; i < namesSorted.length; i++) {
{ for (int j = 0; j < namesSorted.length; j++) {
for( int j = 0; j < namesSorted.length; j++ ) if (namesSorted[i].equals(names[j])) {
{
if( namesSorted[i].equals( names[j] ) )
{
namesSortedIdx[i] = j; namesSortedIdx[i] = j;
namesSortedBackIdx[j] = i; namesSortedBackIdx[j] = i;
break; break;

View File

@ -39,38 +39,22 @@ import android.inputmethodservice.Keyboard;
import android.inputmethodservice.KeyboardView; import android.inputmethodservice.KeyboardView;
import android.os.Bundle; import android.os.Bundle;
import android.os.SystemClock; import android.os.SystemClock;
import androidx.appcompat.app.AppCompatActivity;
import android.text.InputType; import android.text.InputType;
import android.text.SpannedString; import android.text.SpannedString;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.view.Display; import android.view.*;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.View.OnKeyListener; import android.view.View.OnKeyListener;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.Button; import android.widget.*;
import android.widget.EditText; import androidx.appcompat.app.AppCompatActivity;
import android.widget.FrameLayout; import io.neoterm.xorg.NeoXorgViewClient;
import android.widget.ImageView; import io.neoterm.xorg.R;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
import io.neoterm.xorg.NeoXorgViewClient;
import io.neoterm.xorg.R;
public class MainActivity extends AppCompatActivity implements NeoXorgViewClient { public class MainActivity extends AppCompatActivity implements NeoXorgViewClient {
@Override @Override

View File

@ -28,22 +28,14 @@ import android.os.Environment;
import android.os.StatFs; import android.os.StatFs;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import io.neoterm.xorg.NeoXorgViewClient;
import io.neoterm.xorg.R;
import java.io.File; import java.io.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import io.neoterm.xorg.NeoXorgViewClient;
import io.neoterm.xorg.R;
// TODO: too much code here, split into multiple files, possibly auto-generated menus? // TODO: too much code here, split into multiple files, possibly auto-generated menus?
@SuppressWarnings("JniMissingFunction") @SuppressWarnings("JniMissingFunction")

View File

@ -24,57 +24,48 @@ package io.neoterm;
import android.content.DialogInterface; import android.content.DialogInterface;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import io.neoterm.xorg.R;
import java.util.ArrayList; import java.util.ArrayList;
import io.neoterm.xorg.R;
class SettingsMenu {
class SettingsMenu public static abstract class Menu {
{
public static abstract class Menu
{
// Should be overridden by children // Should be overridden by children
abstract void run(final MainActivity p); abstract void run(final MainActivity p);
abstract String title(final MainActivity p); abstract String title(final MainActivity p);
boolean enabled()
{ boolean enabled() {
return true; return true;
} }
// Should not be overridden // Should not be overridden
boolean enabledOrHidden() boolean enabledOrHidden() {
{ for (Menu m : Globals.HiddenMenuOptions) {
for( Menu m: Globals.HiddenMenuOptions )
{
if (m.getClass().getName().equals(this.getClass().getName())) if (m.getClass().getName().equals(this.getClass().getName()))
return false; return false;
} }
return enabled(); return enabled();
} }
void showMenuOptionsList(final MainActivity p, final Menu[] list)
{ void showMenuOptionsList(final MainActivity p, final Menu[] list) {
menuStack.add(this); menuStack.add(this);
ArrayList<CharSequence> items = new ArrayList<CharSequence>(); ArrayList<CharSequence> items = new ArrayList<CharSequence>();
for( Menu m: list ) for (Menu m : list) {
{
if (m.enabledOrHidden()) if (m.enabledOrHidden())
items.add(m.title(p)); items.add(m.title(p));
} }
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(title(p)); builder.setTitle(title(p));
builder.setItems(items.toArray(new CharSequence[0]), new DialogInterface.OnClickListener() builder.setItems(items.toArray(new CharSequence[0]), new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss(); dialog.dismiss();
int selected = 0; int selected = 0;
for( Menu m: list ) for (Menu m : list) {
{ if (m.enabledOrHidden()) {
if(m.enabledOrHidden()) if (selected == item) {
{
if( selected == item )
{
m.run(p); m.run(p);
return; return;
} }
@ -83,10 +74,8 @@ class SettingsMenu
} }
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBackOuterMenu(p); goBackOuterMenu(p);
} }
}); });
@ -98,18 +87,14 @@ class SettingsMenu
static ArrayList<Menu> menuStack = new ArrayList<Menu>(); static ArrayList<Menu> menuStack = new ArrayList<Menu>();
public static void showConfig(final MainActivity p, final boolean firstStart) public static void showConfig(final MainActivity p, final boolean firstStart) {
{
Settings.settingsChanged = true; Settings.settingsChanged = true;
if( Globals.OptionalDataDownload == null ) if (Globals.OptionalDataDownload == null) {
{
String downloads[] = Globals.DataDownloadUrl; String downloads[] = Globals.DataDownloadUrl;
Globals.OptionalDataDownload = new boolean[downloads.length]; Globals.OptionalDataDownload = new boolean[downloads.length];
boolean oldFormat = true; boolean oldFormat = true;
for( int i = 0; i < downloads.length; i++ ) for (int i = 0; i < downloads.length; i++) {
{ if (downloads[i].indexOf("!") == 0) {
if( downloads[i].indexOf("!") == 0 )
{
Globals.OptionalDataDownload[i] = true; Globals.OptionalDataDownload[i] = true;
oldFormat = false; oldFormat = false;
} }
@ -120,15 +105,12 @@ class SettingsMenu
if (!firstStart) if (!firstStart)
new MainMenu().run(p); new MainMenu().run(p);
else else {
{
if (Globals.StartupMenuButtonTimeout > 0) // If we did not disable startup menu altogether if (Globals.StartupMenuButtonTimeout > 0) // If we did not disable startup menu altogether
{ {
for( Menu m: Globals.FirstStartMenuOptions ) for (Menu m : Globals.FirstStartMenuOptions) {
{
boolean hidden = false; boolean hidden = false;
for( Menu m1: Globals.HiddenMenuOptions ) for (Menu m1 : Globals.HiddenMenuOptions) {
{
if (m1.getClass().getName().equals(m.getClass().getName())) if (m1.getClass().getName().equals(m.getClass().getName()))
hidden = true; hidden = true;
} }
@ -140,58 +122,47 @@ class SettingsMenu
} }
} }
static void goBack(final MainActivity p) static void goBack(final MainActivity p) {
{ if (menuStack.isEmpty()) {
if(menuStack.isEmpty())
{
Settings.Save(p); Settings.Save(p);
} } else {
else
{
Menu c = menuStack.remove(menuStack.size() - 1); Menu c = menuStack.remove(menuStack.size() - 1);
c.run(p); c.run(p);
} }
} }
static void goBackOuterMenu(final MainActivity p) static void goBackOuterMenu(final MainActivity p) {
{
if (!menuStack.isEmpty()) if (!menuStack.isEmpty())
menuStack.remove(menuStack.size() - 1); menuStack.remove(menuStack.size() - 1);
goBack(p); goBack(p);
} }
static class OkButton extends Menu static class OkButton extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.ok); return p.getResources().getString(R.string.ok);
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
goBackOuterMenu(p); goBackOuterMenu(p);
} }
} }
static class DummyMenu extends Menu static class DummyMenu extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.ok); return p.getResources().getString(R.string.ok);
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
goBack(p); goBack(p);
} }
} }
static class MainMenu extends Menu static class MainMenu extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.device_config); return p.getResources().getString(R.string.device_config);
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
Menu options[] = Menu options[] =
{ {
new SettingsMenuMisc.DownloadConfig(), new SettingsMenuMisc.DownloadConfig(),

View File

@ -27,7 +27,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.graphics.RectF; import android.graphics.RectF;
import androidx.appcompat.app.AlertDialog;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -35,26 +34,23 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import androidx.appcompat.app.AlertDialog;
import io.neoterm.xorg.R;
import java.util.Arrays; import java.util.Arrays;
import io.neoterm.xorg.R;
class SettingsMenuKeyboard extends SettingsMenu {
class SettingsMenuKeyboard extends SettingsMenu static class KeyboardConfigMainMenu extends Menu {
{ String title(final MainActivity p) {
static class KeyboardConfigMainMenu extends Menu
{
String title(final MainActivity p)
{
return p.getResources().getString(R.string.controls_screenkb); return p.getResources().getString(R.string.controls_screenkb);
} }
boolean enabled()
{ boolean enabled() {
return Globals.UseTouchscreenKeyboard; return Globals.UseTouchscreenKeyboard;
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
Menu options[] = Menu options[] =
{ {
new ScreenKeyboardThemeConfig(), new ScreenKeyboardThemeConfig(),
@ -70,14 +66,12 @@ class SettingsMenuKeyboard extends SettingsMenu
} }
} }
static class ScreenKeyboardSizeConfig extends Menu static class ScreenKeyboardSizeConfig extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.controls_screenkb_size); return p.getResources().getString(R.string.controls_screenkb_size);
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
final CharSequence[] items = {p.getResources().getString(R.string.controls_screenkb_large), final CharSequence[] items = {p.getResources().getString(R.string.controls_screenkb_large),
p.getResources().getString(R.string.controls_screenkb_medium), p.getResources().getString(R.string.controls_screenkb_medium),
p.getResources().getString(R.string.controls_screenkb_small), p.getResources().getString(R.string.controls_screenkb_small),
@ -86,10 +80,8 @@ class SettingsMenuKeyboard extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_size)); builder.setTitle(p.getResources().getString(R.string.controls_screenkb_size));
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardSize, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardSize, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.TouchscreenKeyboardSize = item; Globals.TouchscreenKeyboardSize = item;
dialog.dismiss(); dialog.dismiss();
if (Globals.TouchscreenKeyboardSize == Globals.TOUCHSCREEN_KEYBOARD_CUSTOM) if (Globals.TouchscreenKeyboardSize == Globals.TOUCHSCREEN_KEYBOARD_CUSTOM)
@ -98,10 +90,8 @@ class SettingsMenuKeyboard extends SettingsMenu
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -111,14 +101,12 @@ class SettingsMenuKeyboard extends SettingsMenu
} }
} }
static class ScreenKeyboardDrawSizeConfig extends Menu static class ScreenKeyboardDrawSizeConfig extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.controls_screenkb_drawsize); return p.getResources().getString(R.string.controls_screenkb_drawsize);
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
final CharSequence[] items = {p.getResources().getString(R.string.controls_screenkb_large), final CharSequence[] items = {p.getResources().getString(R.string.controls_screenkb_large),
p.getResources().getString(R.string.controls_screenkb_medium), p.getResources().getString(R.string.controls_screenkb_medium),
p.getResources().getString(R.string.controls_screenkb_small), p.getResources().getString(R.string.controls_screenkb_small),
@ -126,20 +114,16 @@ class SettingsMenuKeyboard extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_drawsize)); builder.setTitle(p.getResources().getString(R.string.controls_screenkb_drawsize));
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardDrawSize, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardDrawSize, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.TouchscreenKeyboardDrawSize = item; Globals.TouchscreenKeyboardDrawSize = item;
dialog.dismiss(); dialog.dismiss();
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -149,14 +133,12 @@ class SettingsMenuKeyboard extends SettingsMenu
} }
} }
static class ScreenKeyboardThemeConfig extends Menu static class ScreenKeyboardThemeConfig extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.controls_screenkb_theme); return p.getResources().getString(R.string.controls_screenkb_theme);
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
final CharSequence[] items = { final CharSequence[] items = {
p.getResources().getString(R.string.controls_screenkb_by, "Ultimate Droid", "Sean Stieber"), p.getResources().getString(R.string.controls_screenkb_by, "Ultimate Droid", "Sean Stieber"),
p.getResources().getString(R.string.controls_screenkb_by, "Simple Theme", "Beholder"), p.getResources().getString(R.string.controls_screenkb_by, "Simple Theme", "Beholder"),
@ -172,20 +154,16 @@ class SettingsMenuKeyboard extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_theme)); builder.setTitle(p.getResources().getString(R.string.controls_screenkb_theme));
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTheme, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTheme, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.TouchscreenKeyboardTheme = item; Globals.TouchscreenKeyboardTheme = item;
dialog.dismiss(); dialog.dismiss();
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -195,14 +173,12 @@ class SettingsMenuKeyboard extends SettingsMenu
} }
} }
static class ScreenKeyboardTransparencyConfig extends Menu static class ScreenKeyboardTransparencyConfig extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.controls_screenkb_transparency); return p.getResources().getString(R.string.controls_screenkb_transparency);
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
final CharSequence[] items = {p.getResources().getString(R.string.controls_screenkb_trans_0), final CharSequence[] items = {p.getResources().getString(R.string.controls_screenkb_trans_0),
p.getResources().getString(R.string.controls_screenkb_trans_1), p.getResources().getString(R.string.controls_screenkb_trans_1),
p.getResources().getString(R.string.controls_screenkb_trans_2), p.getResources().getString(R.string.controls_screenkb_trans_2),
@ -211,20 +187,16 @@ class SettingsMenuKeyboard extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_transparency)); builder.setTitle(p.getResources().getString(R.string.controls_screenkb_transparency));
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTransparency, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTransparency, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.TouchscreenKeyboardTransparency = item; Globals.TouchscreenKeyboardTransparency = item;
dialog.dismiss(); dialog.dismiss();
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -234,29 +206,25 @@ class SettingsMenuKeyboard extends SettingsMenu
} }
} }
static class RemapHwKeysConfig extends Menu static class RemapHwKeysConfig extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.remap_hwkeys); return p.getResources().getString(R.string.remap_hwkeys);
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
p.setText(p.getResources().getString(R.string.remap_hwkeys_press)); p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
p.getVideoLayout().setOnKeyListener(new KeyRemapTool(p)); p.getVideoLayout().setOnKeyListener(new KeyRemapTool(p));
} }
public static class KeyRemapTool implements View.OnKeyListener public static class KeyRemapTool implements View.OnKeyListener {
{
MainActivity p; MainActivity p;
public KeyRemapTool(MainActivity _p)
{ public KeyRemapTool(MainActivity _p) {
p = _p; p = _p;
} }
@Override @Override
public boolean onKey(View v, int keyCode, KeyEvent event) public boolean onKey(View v, int keyCode, KeyEvent event) {
{
p.getVideoLayout().setOnKeyListener(null); p.getVideoLayout().setOnKeyListener(null);
int keyIndex = keyCode; int keyIndex = keyCode;
if (keyIndex < 0) if (keyIndex < 0)
@ -280,24 +248,19 @@ class SettingsMenuKeyboard extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.remap_hwkeys_select_simple); builder.setTitle(R.string.remap_hwkeys_select_simple);
builder.setItems(items, new DialogInterface.OnClickListener() builder.setItems(items, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss(); dialog.dismiss();
if (item >= 6) if (item >= 6)
ShowAllKeys(KeyIndexFinal); ShowAllKeys(KeyIndexFinal);
else else {
{
Globals.RemapHwKeycode[KeyIndexFinal] = Globals.RemapScreenKbKeycode[item]; Globals.RemapHwKeycode[KeyIndexFinal] = Globals.RemapScreenKbKeycode[item];
goBack(p); goBack(p);
} }
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -306,24 +269,20 @@ class SettingsMenuKeyboard extends SettingsMenu
alert.show(); alert.show();
return true; return true;
} }
public void ShowAllKeys(final int KeyIndex)
{ public void ShowAllKeys(final int KeyIndex) {
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.remap_hwkeys_select); builder.setTitle(R.string.remap_hwkeys_select);
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapHwKeycode[KeyIndex]], new DialogInterface.OnClickListener() builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapHwKeycode[KeyIndex]], new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.RemapHwKeycode[KeyIndex] = SDL_Keys.namesSortedIdx[item]; Globals.RemapHwKeycode[KeyIndex] = SDL_Keys.namesSortedIdx[item];
dialog.dismiss(); dialog.dismiss();
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -334,15 +293,13 @@ class SettingsMenuKeyboard extends SettingsMenu
} }
} }
static class RemapScreenKbConfig extends Menu static class RemapScreenKbConfig extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.remap_screenkb); return p.getResources().getString(R.string.remap_screenkb);
} }
//boolean enabled() { return true; }; //boolean enabled() { return true; };
void run (final MainActivity p) void run(final MainActivity p) {
{
CharSequence[] items = { CharSequence[] items = {
p.getResources().getString(R.string.remap_screenkb_joystick), p.getResources().getString(R.string.remap_screenkb_joystick),
p.getResources().getString(R.string.remap_screenkb_button_text), p.getResources().getString(R.string.remap_screenkb_button_text),
@ -355,15 +312,13 @@ class SettingsMenuKeyboard extends SettingsMenu
}; };
boolean defaults[] = Arrays.copyOf(Globals.ScreenKbControlsShown, Globals.ScreenKbControlsShown.length); boolean defaults[] = Arrays.copyOf(Globals.ScreenKbControlsShown, Globals.ScreenKbControlsShown.length);
if( Globals.AppUsesSecondJoystick ) if (Globals.AppUsesSecondJoystick) {
{
items = Arrays.copyOf(items, items.length + 1); items = Arrays.copyOf(items, items.length + 1);
items[items.length - 1] = p.getResources().getString(R.string.remap_screenkb_joystick) + " 2"; items[items.length - 1] = p.getResources().getString(R.string.remap_screenkb_joystick) + " 2";
defaults = Arrays.copyOf(defaults, defaults.length + 1); defaults = Arrays.copyOf(defaults, defaults.length + 1);
defaults[defaults.length - 1] = true; defaults[defaults.length - 1] = true;
} }
if( Globals.AppUsesThirdJoystick ) if (Globals.AppUsesThirdJoystick) {
{
items = Arrays.copyOf(items, items.length + 1); items = Arrays.copyOf(items, items.length + 1);
items[items.length - 1] = p.getResources().getString(R.string.remap_screenkb_joystick) + " 3"; items[items.length - 1] = p.getResources().getString(R.string.remap_screenkb_joystick) + " 3";
defaults = Arrays.copyOf(defaults, defaults.length + 1); defaults = Arrays.copyOf(defaults, defaults.length + 1);
@ -375,25 +330,19 @@ class SettingsMenuKeyboard extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.remap_screenkb)); builder.setTitle(p.getResources().getString(R.string.remap_screenkb));
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() {
{ public void onClick(DialogInterface dialog, int item, boolean isChecked) {
public void onClick(DialogInterface dialog, int item, boolean isChecked)
{
Globals.ScreenKbControlsShown[item] = isChecked; Globals.ScreenKbControlsShown[item] = isChecked;
} }
}); });
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss(); dialog.dismiss();
showRemapScreenKbConfig2(p, 0); showRemapScreenKbConfig2(p, 0);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -402,8 +351,7 @@ class SettingsMenuKeyboard extends SettingsMenu
alert.show(); alert.show();
} }
static void showRemapScreenKbConfig2(final MainActivity p, final int currentButton) static void showRemapScreenKbConfig2(final MainActivity p, final int currentButton) {
{
CharSequence[] items = { CharSequence[] items = {
p.getResources().getString(R.string.remap_screenkb_button) + " 1", p.getResources().getString(R.string.remap_screenkb_button) + " 1",
p.getResources().getString(R.string.remap_screenkb_button) + " 2", p.getResources().getString(R.string.remap_screenkb_button) + " 2",
@ -416,33 +364,27 @@ class SettingsMenuKeyboard extends SettingsMenu
for (int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++) for (int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++)
items[i] = items[i] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " "); items[i] = items[i] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
if( currentButton >= Globals.RemapScreenKbKeycode.length ) if (currentButton >= Globals.RemapScreenKbKeycode.length) {
{
goBack(p); goBack(p);
return; return;
} }
if( ! Globals.ScreenKbControlsShown[currentButton + 2] ) if (!Globals.ScreenKbControlsShown[currentButton + 2]) {
{
showRemapScreenKbConfig2(p, currentButton + 1); showRemapScreenKbConfig2(p, currentButton + 1);
return; return;
} }
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(items[currentButton]); builder.setTitle(items[currentButton]);
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapScreenKbKeycode[currentButton]], new DialogInterface.OnClickListener() builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapScreenKbKeycode[currentButton]], new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.RemapScreenKbKeycode[currentButton] = SDL_Keys.namesSortedIdx[item]; Globals.RemapScreenKbKeycode[currentButton] = SDL_Keys.namesSortedIdx[item];
dialog.dismiss(); dialog.dismiss();
showRemapScreenKbConfig2(p, currentButton + 1); showRemapScreenKbConfig2(p, currentButton + 1);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -452,15 +394,13 @@ class SettingsMenuKeyboard extends SettingsMenu
} }
} }
static class ScreenGesturesConfig extends Menu static class ScreenGesturesConfig extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.remap_screenkb_button_gestures); return p.getResources().getString(R.string.remap_screenkb_button_gestures);
} }
//boolean enabled() { return true; }; //boolean enabled() { return true; };
void run (final MainActivity p) void run(final MainActivity p) {
{
CharSequence[] items = { CharSequence[] items = {
p.getResources().getString(R.string.remap_screenkb_button_zoomin), p.getResources().getString(R.string.remap_screenkb_button_zoomin),
p.getResources().getString(R.string.remap_screenkb_button_zoomout), p.getResources().getString(R.string.remap_screenkb_button_zoomout),
@ -477,25 +417,19 @@ class SettingsMenuKeyboard extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.remap_screenkb_button_gestures)); builder.setTitle(p.getResources().getString(R.string.remap_screenkb_button_gestures));
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() {
{ public void onClick(DialogInterface dialog, int item, boolean isChecked) {
public void onClick(DialogInterface dialog, int item, boolean isChecked)
{
Globals.MultitouchGesturesUsed[item] = isChecked; Globals.MultitouchGesturesUsed[item] = isChecked;
} }
}); });
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss(); dialog.dismiss();
showScreenGesturesConfig2(p); showScreenGesturesConfig2(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -504,8 +438,7 @@ class SettingsMenuKeyboard extends SettingsMenu
alert.show(); alert.show();
} }
static void showScreenGesturesConfig2(final MainActivity p) static void showScreenGesturesConfig2(final MainActivity p) {
{
final CharSequence[] items = { final CharSequence[] items = {
p.getResources().getString(R.string.accel_slow), p.getResources().getString(R.string.accel_slow),
p.getResources().getString(R.string.accel_medium), p.getResources().getString(R.string.accel_medium),
@ -515,20 +448,16 @@ class SettingsMenuKeyboard extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.remap_screenkb_button_gestures_sensitivity); builder.setTitle(R.string.remap_screenkb_button_gestures_sensitivity);
builder.setSingleChoiceItems(items, Globals.MultitouchGestureSensitivity, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.MultitouchGestureSensitivity, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.MultitouchGestureSensitivity = item; Globals.MultitouchGestureSensitivity = item;
dialog.dismiss(); dialog.dismiss();
showScreenGesturesConfig3(p, 0); showScreenGesturesConfig3(p, 0);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -537,8 +466,7 @@ class SettingsMenuKeyboard extends SettingsMenu
alert.show(); alert.show();
} }
static void showScreenGesturesConfig3(final MainActivity p, final int currentButton) static void showScreenGesturesConfig3(final MainActivity p, final int currentButton) {
{
CharSequence[] items = { CharSequence[] items = {
p.getResources().getString(R.string.remap_screenkb_button_zoomin), p.getResources().getString(R.string.remap_screenkb_button_zoomin),
p.getResources().getString(R.string.remap_screenkb_button_zoomout), p.getResources().getString(R.string.remap_screenkb_button_zoomout),
@ -546,33 +474,27 @@ class SettingsMenuKeyboard extends SettingsMenu
p.getResources().getString(R.string.remap_screenkb_button_rotateright), p.getResources().getString(R.string.remap_screenkb_button_rotateright),
}; };
if( currentButton >= Globals.RemapMultitouchGestureKeycode.length ) if (currentButton >= Globals.RemapMultitouchGestureKeycode.length) {
{
goBack(p); goBack(p);
return; return;
} }
if( ! Globals.MultitouchGesturesUsed[currentButton] ) if (!Globals.MultitouchGesturesUsed[currentButton]) {
{
showScreenGesturesConfig3(p, currentButton + 1); showScreenGesturesConfig3(p, currentButton + 1);
return; return;
} }
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(items[currentButton]); builder.setTitle(items[currentButton]);
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapMultitouchGestureKeycode[currentButton]], new DialogInterface.OnClickListener() builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapMultitouchGestureKeycode[currentButton]], new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.RemapMultitouchGestureKeycode[currentButton] = SDL_Keys.namesSortedIdx[item]; Globals.RemapMultitouchGestureKeycode[currentButton] = SDL_Keys.namesSortedIdx[item];
dialog.dismiss(); dialog.dismiss();
showScreenGesturesConfig3(p, currentButton + 1); showScreenGesturesConfig3(p, currentButton + 1);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -582,22 +504,19 @@ class SettingsMenuKeyboard extends SettingsMenu
} }
} }
static class CustomizeScreenKbLayout extends Menu static class CustomizeScreenKbLayout extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.screenkb_custom_layout); return p.getResources().getString(R.string.screenkb_custom_layout);
} }
//boolean enabled() { return true; }; //boolean enabled() { return true; };
void run (final MainActivity p) void run(final MainActivity p) {
{
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help)); p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help));
CustomizeScreenKbLayoutTool tool = new CustomizeScreenKbLayoutTool(p); CustomizeScreenKbLayoutTool tool = new CustomizeScreenKbLayoutTool(p);
Globals.TouchscreenKeyboardSize = Globals.TOUCHSCREEN_KEYBOARD_CUSTOM; Globals.TouchscreenKeyboardSize = Globals.TOUCHSCREEN_KEYBOARD_CUSTOM;
} }
static class CustomizeScreenKbLayoutTool implements View.OnTouchListener, View.OnKeyListener static class CustomizeScreenKbLayoutTool implements View.OnTouchListener, View.OnKeyListener {
{
MainActivity p; MainActivity p;
FrameLayout layout = null; FrameLayout layout = null;
ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length]; ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length];
@ -620,8 +539,7 @@ class SettingsMenuKeyboard extends SettingsMenu
int oldX = 0, oldY = 0; int oldX = 0, oldY = 0;
boolean resizing = false; boolean resizing = false;
public CustomizeScreenKbLayoutTool(MainActivity _p) public CustomizeScreenKbLayoutTool(MainActivity _p) {
{
p = _p; p = _p;
layout = new FrameLayout(p); layout = new FrameLayout(p);
p.getVideoLayout().addView(layout); p.getVideoLayout().addView(layout);
@ -637,8 +555,7 @@ class SettingsMenuKeyboard extends SettingsMenu
boundary.setImageBitmap(boundaryBmp); boundary.setImageBitmap(boundaryBmp);
layout.addView(boundary); layout.addView(boundary);
currentButton = -1; currentButton = -1;
if( Globals.TouchscreenKeyboardTheme == 2 ) if (Globals.TouchscreenKeyboardTheme == 2) {
{
buttons = new int[]{ buttons = new int[]{
R.drawable.sun_dpad, R.drawable.sun_dpad,
R.drawable.sun_keyboard, R.drawable.sun_keyboard,
@ -660,10 +577,10 @@ class SettingsMenuKeyboard extends SettingsMenu
p.getWindowManager().getDefaultDisplay().getMetrics(dm); p.getWindowManager().getDefaultDisplay().getMetrics(dm);
displayX = dm.widthPixels; displayX = dm.widthPixels;
displayY = dm.heightPixels; displayY = dm.heightPixels;
} catch (Exception eeeee) {} } catch (Exception eeeee) {
}
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ ) for (int i = 0; i < Globals.ScreenKbControlsLayout.length; i++) {
{
if (!Globals.ScreenKbControlsShown[i]) if (!Globals.ScreenKbControlsShown[i])
continue; continue;
if (currentButton == -1) if (currentButton == -1)
@ -678,23 +595,19 @@ class SettingsMenuKeyboard extends SettingsMenu
Globals.ScreenKbControlsLayout[i][0] = Globals.ScreenKbControlsLayout[i][2] - displayY * 2 / 3; Globals.ScreenKbControlsLayout[i][0] = Globals.ScreenKbControlsLayout[i][2] - displayY * 2 / 3;
if (Globals.ScreenKbControlsLayout[i][1] < Globals.ScreenKbControlsLayout[i][3] - displayY * 2 / 3) if (Globals.ScreenKbControlsLayout[i][1] < Globals.ScreenKbControlsLayout[i][3] - displayY * 2 / 3)
Globals.ScreenKbControlsLayout[i][1] = Globals.ScreenKbControlsLayout[i][3] - displayY * 2 / 3; Globals.ScreenKbControlsLayout[i][1] = Globals.ScreenKbControlsLayout[i][3] - displayY * 2 / 3;
if( Globals.ScreenKbControlsLayout[i][0] < 0 ) if (Globals.ScreenKbControlsLayout[i][0] < 0) {
{
Globals.ScreenKbControlsLayout[i][2] += -Globals.ScreenKbControlsLayout[i][0]; Globals.ScreenKbControlsLayout[i][2] += -Globals.ScreenKbControlsLayout[i][0];
Globals.ScreenKbControlsLayout[i][0] = 0; Globals.ScreenKbControlsLayout[i][0] = 0;
} }
if( Globals.ScreenKbControlsLayout[i][2] > displayX ) if (Globals.ScreenKbControlsLayout[i][2] > displayX) {
{
Globals.ScreenKbControlsLayout[i][0] -= Globals.ScreenKbControlsLayout[i][2] - displayX; Globals.ScreenKbControlsLayout[i][0] -= Globals.ScreenKbControlsLayout[i][2] - displayX;
Globals.ScreenKbControlsLayout[i][2] = displayX; Globals.ScreenKbControlsLayout[i][2] = displayX;
} }
if( Globals.ScreenKbControlsLayout[i][1] < 0 ) if (Globals.ScreenKbControlsLayout[i][1] < 0) {
{
Globals.ScreenKbControlsLayout[i][3] += -Globals.ScreenKbControlsLayout[i][1]; Globals.ScreenKbControlsLayout[i][3] += -Globals.ScreenKbControlsLayout[i][1];
Globals.ScreenKbControlsLayout[i][1] = 0; Globals.ScreenKbControlsLayout[i][1] = 0;
} }
if( Globals.ScreenKbControlsLayout[i][3] > displayY ) if (Globals.ScreenKbControlsLayout[i][3] > displayY) {
{
Globals.ScreenKbControlsLayout[i][1] -= Globals.ScreenKbControlsLayout[i][3] - displayY; Globals.ScreenKbControlsLayout[i][1] -= Globals.ScreenKbControlsLayout[i][3] - displayY;
Globals.ScreenKbControlsLayout[i][3] = displayY; Globals.ScreenKbControlsLayout[i][3] = displayY;
} }
@ -721,8 +634,7 @@ class SettingsMenuKeyboard extends SettingsMenu
setupButton(currentButton); setupButton(currentButton);
} }
void setupButton(int i) void setupButton(int i) {
{
Matrix m = new Matrix(); Matrix m = new Matrix();
RectF src = new RectF(0, 0, bmps[i].getWidth(), bmps[i].getHeight()); RectF src = new RectF(0, 0, bmps[i].getWidth(), bmps[i].getHeight());
RectF dst = new RectF(Globals.ScreenKbControlsLayout[i][0], Globals.ScreenKbControlsLayout[i][1], RectF dst = new RectF(Globals.ScreenKbControlsLayout[i][0], Globals.ScreenKbControlsLayout[i][1],
@ -750,22 +662,18 @@ class SettingsMenuKeyboard extends SettingsMenu
} }
@Override @Override
public boolean onTouch(View v, MotionEvent ev) public boolean onTouch(View v, MotionEvent ev) {
{ if (ev.getAction() == MotionEvent.ACTION_DOWN) {
if( ev.getAction() == MotionEvent.ACTION_DOWN )
{
oldX = (int) ev.getX(); oldX = (int) ev.getX();
oldY = (int) ev.getY(); oldY = (int) ev.getY();
resizing = true; resizing = true;
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ ) for (int i = 0; i < Globals.ScreenKbControlsLayout.length; i++) {
{
if (!Globals.ScreenKbControlsShown[i]) if (!Globals.ScreenKbControlsShown[i])
continue; continue;
if (Globals.ScreenKbControlsLayout[i][0] <= oldX && if (Globals.ScreenKbControlsLayout[i][0] <= oldX &&
Globals.ScreenKbControlsLayout[i][2] >= oldX && Globals.ScreenKbControlsLayout[i][2] >= oldX &&
Globals.ScreenKbControlsLayout[i][1] <= oldY && Globals.ScreenKbControlsLayout[i][1] <= oldY &&
Globals.ScreenKbControlsLayout[i][3] >= oldY ) Globals.ScreenKbControlsLayout[i][3] >= oldY) {
{
currentButton = i; currentButton = i;
setupButton(currentButton); setupButton(currentButton);
resizing = false; resizing = false;
@ -773,30 +681,24 @@ class SettingsMenuKeyboard extends SettingsMenu
} }
} }
} }
if( ev.getAction() == MotionEvent.ACTION_MOVE ) if (ev.getAction() == MotionEvent.ACTION_MOVE) {
{
int dx = (int) ev.getX() - oldX; int dx = (int) ev.getX() - oldX;
int dy = (int) ev.getY() - oldY; int dy = (int) ev.getY() - oldY;
if( resizing ) if (resizing) {
{
// Resize slowly, with 1/3 of movement speed // Resize slowly, with 1/3 of movement speed
dx /= 6; dx /= 6;
dy /= 6; dy /= 6;
if( Globals.ScreenKbControlsLayout[currentButton][0] <= Globals.ScreenKbControlsLayout[currentButton][2] + dx*2 ) if (Globals.ScreenKbControlsLayout[currentButton][0] <= Globals.ScreenKbControlsLayout[currentButton][2] + dx * 2) {
{
Globals.ScreenKbControlsLayout[currentButton][0] -= dx; Globals.ScreenKbControlsLayout[currentButton][0] -= dx;
Globals.ScreenKbControlsLayout[currentButton][2] += dx; Globals.ScreenKbControlsLayout[currentButton][2] += dx;
} }
if( Globals.ScreenKbControlsLayout[currentButton][1] <= Globals.ScreenKbControlsLayout[currentButton][3] + dy*2 ) if (Globals.ScreenKbControlsLayout[currentButton][1] <= Globals.ScreenKbControlsLayout[currentButton][3] + dy * 2) {
{
Globals.ScreenKbControlsLayout[currentButton][1] += dy; Globals.ScreenKbControlsLayout[currentButton][1] += dy;
Globals.ScreenKbControlsLayout[currentButton][3] -= dy; Globals.ScreenKbControlsLayout[currentButton][3] -= dy;
} }
dx *= 6; dx *= 6;
dy *= 6; dy *= 6;
} } else {
else
{
Globals.ScreenKbControlsLayout[currentButton][0] += dx; Globals.ScreenKbControlsLayout[currentButton][0] += dx;
Globals.ScreenKbControlsLayout[currentButton][2] += dx; Globals.ScreenKbControlsLayout[currentButton][2] += dx;
Globals.ScreenKbControlsLayout[currentButton][1] += dy; Globals.ScreenKbControlsLayout[currentButton][1] += dy;
@ -819,10 +721,8 @@ class SettingsMenuKeyboard extends SettingsMenu
} }
@Override @Override
public boolean onKey(View v, int keyCode, KeyEvent event) public boolean onKey(View v, int keyCode, KeyEvent event) {
{ if (keyCode == KeyEvent.KEYCODE_BACK) {
if( keyCode == KeyEvent.KEYCODE_BACK )
{
p.getVideoLayout().removeView(layout); p.getVideoLayout().removeView(layout);
layout = null; layout = null;
goBack(p); goBack(p);
@ -832,15 +732,13 @@ class SettingsMenuKeyboard extends SettingsMenu
} }
} }
static class ScreenKeyboardAdvanced extends Menu static class ScreenKeyboardAdvanced extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.advanced); return p.getResources().getString(R.string.advanced);
} }
//boolean enabled() { return true; }; //boolean enabled() { return true; };
void run (final MainActivity p) void run(final MainActivity p) {
{
CharSequence[] items = { CharSequence[] items = {
p.getResources().getString(R.string.screenkb_floating_joystick), p.getResources().getString(R.string.screenkb_floating_joystick),
}; };
@ -851,26 +749,20 @@ class SettingsMenuKeyboard extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.advanced)); builder.setTitle(p.getResources().getString(R.string.advanced));
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() {
{ public void onClick(DialogInterface dialog, int item, boolean isChecked) {
public void onClick(DialogInterface dialog, int item, boolean isChecked)
{
if (item == 0) if (item == 0)
Globals.FloatingScreenJoystick = isChecked; Globals.FloatingScreenJoystick = isChecked;
} }
}); });
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss(); dialog.dismiss();
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });

View File

@ -26,60 +26,47 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.StatFs; import android.os.StatFs;
import androidx.appcompat.app.AlertDialog;
import android.text.InputType; import android.text.InputType;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.*;
import android.widget.EditText; import androidx.appcompat.app.AlertDialog;
import android.widget.FrameLayout; import io.neoterm.xorg.R;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
import io.neoterm.xorg.R;
class SettingsMenuMisc extends SettingsMenu {
class SettingsMenuMisc extends SettingsMenu static class DownloadConfig extends Menu {
{ String title(final MainActivity p) {
static class DownloadConfig extends Menu
{
String title(final MainActivity p)
{
return p.getResources().getString(R.string.storage_question); return p.getResources().getString(R.string.storage_question);
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
long freeSdcard = 0; long freeSdcard = 0;
long freePhone = 0; long freePhone = 0;
try try {
{
StatFs phone = new StatFs(p.getFilesDir().getAbsolutePath()); StatFs phone = new StatFs(p.getFilesDir().getAbsolutePath());
freePhone = (long) phone.getAvailableBlocks() * phone.getBlockSize() / 1024 / 1024; freePhone = (long) phone.getAvailableBlocks() * phone.getBlockSize() / 1024 / 1024;
StatFs sdcard = new StatFs(Settings.SdcardAppPath.get().bestPath(p)); StatFs sdcard = new StatFs(Settings.SdcardAppPath.get().bestPath(p));
freeSdcard = (long) sdcard.getAvailableBlocks() * sdcard.getBlockSize() / 1024 / 1024; freeSdcard = (long) sdcard.getAvailableBlocks() * sdcard.getBlockSize() / 1024 / 1024;
} catch (Exception e) {
} }
catch(Exception e) {}
final CharSequence[] items = {p.getResources().getString(R.string.storage_phone, freePhone), final CharSequence[] items = {p.getResources().getString(R.string.storage_phone, freePhone),
p.getResources().getString(R.string.storage_sd, freeSdcard), p.getResources().getString(R.string.storage_sd, freeSdcard),
p.getResources().getString(R.string.storage_custom)}; p.getResources().getString(R.string.storage_custom)};
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.storage_question)); builder.setTitle(p.getResources().getString(R.string.storage_question));
builder.setSingleChoiceItems(items, Globals.DownloadToSdcard ? 1 : 0, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.DownloadToSdcard ? 1 : 0, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss(); dialog.dismiss();
if (item == 2) if (item == 2)
showCustomDownloadDirConfig(p); showCustomDownloadDirConfig(p);
else else {
{
Globals.DownloadToSdcard = (item != 0); Globals.DownloadToSdcard = (item != 0);
Globals.DataDir = Globals.DownloadToSdcard ? Globals.DataDir = Globals.DownloadToSdcard ?
Settings.SdcardAppPath.get().bestPath(p) : Settings.SdcardAppPath.get().bestPath(p) :
@ -88,10 +75,8 @@ class SettingsMenuMisc extends SettingsMenu
} }
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -99,8 +84,8 @@ class SettingsMenuMisc extends SettingsMenu
alert.setOwnerActivity(p); alert.setOwnerActivity(p);
alert.show(); alert.show();
} }
static void showCustomDownloadDirConfig(final MainActivity p)
{ static void showCustomDownloadDirConfig(final MainActivity p) {
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.storage_custom)); builder.setTitle(p.getResources().getString(R.string.storage_custom));
@ -110,19 +95,15 @@ class SettingsMenuMisc extends SettingsMenu
edit.setText(Globals.DataDir); edit.setText(Globals.DataDir);
builder.setView(edit); builder.setView(edit);
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.DataDir = edit.getText().toString(); Globals.DataDir = edit.getText().toString();
dialog.dismiss(); dialog.dismiss();
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -132,23 +113,22 @@ class SettingsMenuMisc extends SettingsMenu
} }
} }
static class OptionalDownloadConfig extends Menu static class OptionalDownloadConfig extends Menu {
{
boolean firstStart = false; boolean firstStart = false;
OptionalDownloadConfig()
{ OptionalDownloadConfig() {
firstStart = true; firstStart = true;
} }
OptionalDownloadConfig(boolean firstStart)
{ OptionalDownloadConfig(boolean firstStart) {
this.firstStart = firstStart; this.firstStart = firstStart;
} }
String title(final MainActivity p)
{ String title(final MainActivity p) {
return p.getResources().getString(R.string.downloads); return p.getResources().getString(R.string.downloads);
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
String[] downloadFiles = Globals.DataDownloadUrl; String[] downloadFiles = Globals.DataDownloadUrl;
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
@ -157,12 +137,10 @@ class SettingsMenuMisc extends SettingsMenu
final int itemsIdx[] = new int[downloadFiles.length]; final int itemsIdx[] = new int[downloadFiles.length];
ArrayList<CharSequence> items = new ArrayList<CharSequence>(); ArrayList<CharSequence> items = new ArrayList<CharSequence>();
ArrayList<Boolean> enabledItems = new ArrayList<Boolean>(); ArrayList<Boolean> enabledItems = new ArrayList<Boolean>();
for(int i = 0; i < downloadFiles.length; i++ ) for (int i = 0; i < downloadFiles.length; i++) {
{
String item = new String(downloadFiles[i].split("[|]")[0]); String item = new String(downloadFiles[i].split("[|]")[0]);
boolean enabled = false; boolean enabled = false;
if( item.toString().indexOf("!") == 0 ) if (item.toString().indexOf("!") == 0) {
{
item = item.toString().substring(1); item = item.toString().substring(1);
enabled = true; enabled = true;
} }
@ -173,14 +151,11 @@ class SettingsMenuMisc extends SettingsMenu
enabledItems.add(enabled); enabledItems.add(enabled);
} }
if( Globals.OptionalDataDownload == null || Globals.OptionalDataDownload.length != downloadFiles.length ) if (Globals.OptionalDataDownload == null || Globals.OptionalDataDownload.length != downloadFiles.length) {
{
Globals.OptionalDataDownload = new boolean[downloadFiles.length]; Globals.OptionalDataDownload = new boolean[downloadFiles.length];
boolean oldFormat = true; boolean oldFormat = true;
for( int i = 0; i < downloadFiles.length; i++ ) for (int i = 0; i < downloadFiles.length; i++) {
{ if (downloadFiles[i].indexOf("!") == 0) {
if( downloadFiles[i].indexOf("!") == 0 )
{
Globals.OptionalDataDownload[i] = true; Globals.OptionalDataDownload[i] = true;
oldFormat = false; oldFormat = false;
} }
@ -188,8 +163,7 @@ class SettingsMenuMisc extends SettingsMenu
if (oldFormat) if (oldFormat)
Globals.OptionalDataDownload[0] = true; Globals.OptionalDataDownload[0] = true;
} }
if( enabledItems.size() <= 0 ) if (enabledItems.size() <= 0) {
{
goBack(p); goBack(p);
return; return;
} }
@ -199,37 +173,28 @@ class SettingsMenuMisc extends SettingsMenu
for (int i = 0; i < enabledItems.size(); i++) for (int i = 0; i < enabledItems.size(); i++)
enabledItems2[i] = enabledItems.get(i); enabledItems2[i] = enabledItems.get(i);
builder.setMultiChoiceItems(items.toArray(new CharSequence[0]), enabledItems2, new DialogInterface.OnMultiChoiceClickListener() builder.setMultiChoiceItems(items.toArray(new CharSequence[0]), enabledItems2, new DialogInterface.OnMultiChoiceClickListener() {
{ public void onClick(DialogInterface dialog, int item, boolean isChecked) {
public void onClick(DialogInterface dialog, int item, boolean isChecked)
{
Globals.OptionalDataDownload[itemsIdx[item]] = isChecked; Globals.OptionalDataDownload[itemsIdx[item]] = isChecked;
} }
}); });
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss(); dialog.dismiss();
goBack(p); goBack(p);
} }
}); });
if( firstStart ) if (firstStart) {
{ builder.setNegativeButton(p.getResources().getString(R.string.show_more_options), new DialogInterface.OnClickListener() {
builder.setNegativeButton(p.getResources().getString(R.string.show_more_options), new DialogInterface.OnClickListener() public void onClick(DialogInterface dialog, int item) {
{
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss(); dialog.dismiss();
menuStack.clear(); menuStack.clear();
new MainMenu().run(p); new MainMenu().run(p);
} }
}); });
} }
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -239,14 +204,12 @@ class SettingsMenuMisc extends SettingsMenu
} }
} }
static class AudioConfig extends Menu static class AudioConfig extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.audiobuf_question); return p.getResources().getString(R.string.audiobuf_question);
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
final CharSequence[] items = {p.getResources().getString(R.string.audiobuf_verysmall), final CharSequence[] items = {p.getResources().getString(R.string.audiobuf_verysmall),
p.getResources().getString(R.string.audiobuf_small), p.getResources().getString(R.string.audiobuf_small),
p.getResources().getString(R.string.audiobuf_medium), p.getResources().getString(R.string.audiobuf_medium),
@ -254,19 +217,15 @@ class SettingsMenuMisc extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.audiobuf_question); builder.setTitle(R.string.audiobuf_question);
builder.setSingleChoiceItems(items, Globals.AudioBufferConfig, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.AudioBufferConfig, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.AudioBufferConfig = item; Globals.AudioBufferConfig = item;
dialog.dismiss(); dialog.dismiss();
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -276,16 +235,15 @@ class SettingsMenuMisc extends SettingsMenu
} }
} }
static class VideoSettingsConfig extends Menu static class VideoSettingsConfig extends Menu {
{
static int debugMenuShowCount = 0; static int debugMenuShowCount = 0;
String title(final MainActivity p)
{ String title(final MainActivity p) {
return p.getResources().getString(R.string.video); return p.getResources().getString(R.string.video);
} }
//boolean enabled() { return true; }; //boolean enabled() { return true; };
void run (final MainActivity p) void run(final MainActivity p) {
{
debugMenuShowCount++; debugMenuShowCount++;
CharSequence[] items = { CharSequence[] items = {
p.getResources().getString(R.string.mouse_keepaspectratio), p.getResources().getString(R.string.mouse_keepaspectratio),
@ -306,8 +264,7 @@ class SettingsMenuMisc extends SettingsMenu
Globals.TvBorders, Globals.TvBorders,
}; };
if(Globals.SwVideoMode && !Globals.CompatibilityHacksVideo) if (Globals.SwVideoMode && !Globals.CompatibilityHacksVideo) {
{
CharSequence[] items2 = { CharSequence[] items2 = {
p.getResources().getString(R.string.mouse_keepaspectratio), p.getResources().getString(R.string.mouse_keepaspectratio),
p.getResources().getString(R.string.video_smooth), p.getResources().getString(R.string.video_smooth),
@ -332,8 +289,7 @@ class SettingsMenuMisc extends SettingsMenu
defaults = defaults2; defaults = defaults2;
} }
if(Globals.Using_SDL_1_3) if (Globals.Using_SDL_1_3) {
{
CharSequence[] items2 = { CharSequence[] items2 = {
p.getResources().getString(R.string.mouse_keepaspectratio), p.getResources().getString(R.string.mouse_keepaspectratio),
}; };
@ -346,10 +302,8 @@ class SettingsMenuMisc extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.video)); builder.setTitle(p.getResources().getString(R.string.video));
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() {
{ public void onClick(DialogInterface dialog, int item, boolean isChecked) {
public void onClick(DialogInterface dialog, int item, boolean isChecked)
{
if (item == 0) if (item == 0)
Globals.KeepAspectRatio = isChecked; Globals.KeepAspectRatio = isChecked;
if (item == 1) if (item == 1)
@ -368,18 +322,14 @@ class SettingsMenuMisc extends SettingsMenu
Globals.MultiThreadedVideo = isChecked; Globals.MultiThreadedVideo = isChecked;
} }
}); });
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss(); dialog.dismiss();
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -389,41 +339,35 @@ class SettingsMenuMisc extends SettingsMenu
} }
} }
static class ShowReadme extends Menu static class ShowReadme extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return "Readme"; return "Readme";
} }
boolean enabled()
{ boolean enabled() {
return true; return true;
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
String readmes[] = Globals.ReadmeText.split("\\^"); String readmes[] = Globals.ReadmeText.split("\\^");
String lang = new String(Locale.getDefault().getLanguage()) + ":"; String lang = new String(Locale.getDefault().getLanguage()) + ":";
if (p.isRunningOnOUYA()) if (p.isRunningOnOUYA())
lang = "tv:"; lang = "tv:";
String readme = readmes[0]; String readme = readmes[0];
String buttonName = "", buttonUrl = ""; String buttonName = "", buttonUrl = "";
for( String r: readmes ) for (String r : readmes) {
{
if (r.startsWith(lang)) if (r.startsWith(lang))
readme = r.substring(lang.length()); readme = r.substring(lang.length());
if( r.startsWith("button:") ) if (r.startsWith("button:")) {
{
buttonName = r.substring("button:".length()); buttonName = r.substring("button:".length());
if( buttonName.indexOf(":") != -1 ) if (buttonName.indexOf(":") != -1) {
{
buttonUrl = buttonName.substring(buttonName.indexOf(":") + 1); buttonUrl = buttonName.substring(buttonName.indexOf(":") + 1);
buttonName = buttonName.substring(0, buttonName.indexOf(":")); buttonName = buttonName.substring(0, buttonName.indexOf(":"));
} }
} }
} }
readme = readme.trim(); readme = readme.trim();
if( readme.length() <= 2 ) if (readme.length() <= 2) {
{
goBack(p); goBack(p);
return; return;
} }
@ -445,10 +389,8 @@ class SettingsMenuMisc extends SettingsMenu
scroll.addView(text, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); scroll.addView(text, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
final Button ok = new Button(p); final Button ok = new Button(p);
final AlertDialog alertDismiss[] = new AlertDialog[1]; final AlertDialog alertDismiss[] = new AlertDialog[1];
ok.setOnClickListener(new View.OnClickListener() ok.setOnClickListener(new View.OnClickListener() {
{ public void onClick(View v) {
public void onClick(View v)
{
alertDismiss[0].cancel(); alertDismiss[0].cancel();
} }
}); });
@ -457,17 +399,13 @@ class SettingsMenuMisc extends SettingsMenu
layout.setOrientation(LinearLayout.VERTICAL); layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(scroll); layout.addView(scroll);
layout.addView(ok); layout.addView(ok);
if( buttonName.length() > 0 ) if (buttonName.length() > 0) {
{
Button cancel = new Button(p); Button cancel = new Button(p);
cancel.setText(buttonName); cancel.setText(buttonName);
final String url = buttonUrl; final String url = buttonUrl;
cancel.setOnClickListener(new View.OnClickListener() cancel.setOnClickListener(new View.OnClickListener() {
{ public void onClick(View v) {
public void onClick(View v) if (url.length() > 0) {
{
if( url.length() > 0 )
{
Intent i = new Intent(Intent.ACTION_VIEW); Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url)); i.setData(Uri.parse(url));
p.startActivity(i); p.startActivity(i);
@ -479,10 +417,8 @@ class SettingsMenuMisc extends SettingsMenu
layout.addView(cancel); layout.addView(cancel);
} }
builder.setView(layout); builder.setView(layout);
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -493,30 +429,26 @@ class SettingsMenuMisc extends SettingsMenu
} }
} }
static class GyroscopeCalibration extends Menu static class GyroscopeCalibration extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return ""; return "";
} }
boolean enabled()
{ boolean enabled() {
return false; return false;
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
goBack(p); goBack(p);
} }
} }
static class CommandlineConfig extends Menu static class CommandlineConfig extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.storage_commandline); return p.getResources().getString(R.string.storage_commandline);
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.storage_commandline)); builder.setTitle(p.getResources().getString(R.string.storage_commandline));
@ -533,15 +465,12 @@ class SettingsMenuMisc extends SettingsMenu
//edit.setMaxLines(100); //edit.setMaxLines(100);
builder.setView(edit); builder.setView(edit);
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.CommandLine = "SDL_app"; Globals.CommandLine = "SDL_app";
String args[] = edit.getText().toString().split("\n"); String args[] = edit.getText().toString().split("\n");
boolean firstArg = true; boolean firstArg = true;
for( String arg: args ) for (String arg : args) {
{
Globals.CommandLine += " "; Globals.CommandLine += " ";
if (firstArg) if (firstArg)
Globals.CommandLine += arg; Globals.CommandLine += arg;
@ -553,10 +482,8 @@ class SettingsMenuMisc extends SettingsMenu
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -566,43 +493,35 @@ class SettingsMenuMisc extends SettingsMenu
} }
} }
static class ResetToDefaultsConfig extends Menu static class ResetToDefaultsConfig extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.reset_config); return p.getResources().getString(R.string.reset_config);
} }
boolean enabled()
{ boolean enabled() {
return true; return true;
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.reset_config_ask)); builder.setTitle(p.getResources().getString(R.string.reset_config_ask));
builder.setMessage(p.getResources().getString(R.string.reset_config_ask)); builder.setMessage(p.getResources().getString(R.string.reset_config_ask));
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Settings.DeleteSdlConfigOnUpgradeAndRestart(p); // Never returns Settings.DeleteSdlConfigOnUpgradeAndRestart(p); // Never returns
dialog.dismiss(); dialog.dismiss();
goBack(p); goBack(p);
} }
}); });
builder.setNegativeButton(p.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() builder.setNegativeButton(p.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss(); dialog.dismiss();
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });

View File

@ -27,33 +27,29 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.graphics.RectF; import android.graphics.RectF;
import androidx.appcompat.app.AlertDialog;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import androidx.appcompat.app.AlertDialog;
import io.neoterm.xorg.R;
import java.util.ArrayList; import java.util.ArrayList;
import io.neoterm.xorg.R;
class SettingsMenuMouse extends SettingsMenu {
class SettingsMenuMouse extends SettingsMenu static class MouseConfigMainMenu extends Menu {
{ String title(final MainActivity p) {
static class MouseConfigMainMenu extends Menu
{
String title(final MainActivity p)
{
return p.getResources().getString(R.string.mouse_emulation); return p.getResources().getString(R.string.mouse_emulation);
} }
boolean enabled()
{ boolean enabled() {
return Globals.AppUsesMouse; return Globals.AppUsesMouse;
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
Menu options[] = Menu options[] =
{ {
new DisplaySizeConfig(false), new DisplaySizeConfig(false),
@ -69,23 +65,22 @@ class SettingsMenuMouse extends SettingsMenu
} }
} }
static class DisplaySizeConfig extends Menu static class DisplaySizeConfig extends Menu {
{
boolean firstStart = false; boolean firstStart = false;
DisplaySizeConfig()
{ DisplaySizeConfig() {
this.firstStart = true; this.firstStart = true;
} }
DisplaySizeConfig(boolean firstStart)
{ DisplaySizeConfig(boolean firstStart) {
this.firstStart = firstStart; this.firstStart = firstStart;
} }
String title(final MainActivity p)
{ String title(final MainActivity p) {
return p.getResources().getString(R.string.display_size_mouse); return p.getResources().getString(R.string.display_size_mouse);
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
CharSequence[] items = { CharSequence[] items = {
p.getResources().getString(R.string.display_size_small), p.getResources().getString(R.string.display_size_small),
p.getResources().getString(R.string.display_size_small_touchpad), p.getResources().getString(R.string.display_size_small_touchpad),
@ -98,8 +93,7 @@ class SettingsMenuMouse extends SettingsMenu
int _size_desktop = 3; int _size_desktop = 3;
int _more_options = 4; int _more_options = 4;
if( ! Globals.SwVideoMode ) if (!Globals.SwVideoMode) {
{
CharSequence[] items2 = { CharSequence[] items2 = {
p.getResources().getString(R.string.display_size_small_touchpad), p.getResources().getString(R.string.display_size_small_touchpad),
p.getResources().getString(R.string.display_size_large), p.getResources().getString(R.string.display_size_large),
@ -111,8 +105,7 @@ class SettingsMenuMouse extends SettingsMenu
_size_desktop = 2; _size_desktop = 2;
_size_small = 1000; _size_small = 1000;
} }
if( firstStart ) if (firstStart) {
{
CharSequence[] items2 = { CharSequence[] items2 = {
p.getResources().getString(R.string.display_size_small), p.getResources().getString(R.string.display_size_small),
p.getResources().getString(R.string.display_size_small_touchpad), p.getResources().getString(R.string.display_size_small_touchpad),
@ -121,8 +114,7 @@ class SettingsMenuMouse extends SettingsMenu
p.getResources().getString(R.string.show_more_options), p.getResources().getString(R.string.show_more_options),
}; };
items = items2; items = items2;
if( ! Globals.SwVideoMode ) if (!Globals.SwVideoMode) {
{
CharSequence[] items3 = { CharSequence[] items3 = {
p.getResources().getString(R.string.display_size_small_touchpad), p.getResources().getString(R.string.display_size_small_touchpad),
p.getResources().getString(R.string.display_size_large), p.getResources().getString(R.string.display_size_large),
@ -142,41 +134,34 @@ class SettingsMenuMouse extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.display_size); builder.setTitle(R.string.display_size);
class ClickListener implements DialogInterface.OnClickListener class ClickListener implements DialogInterface.OnClickListener {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss(); dialog.dismiss();
if( item == size_desktop ) if (item == size_desktop) {
{
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NORMAL; Globals.LeftClickMethod = Mouse.LEFT_CLICK_NORMAL;
Globals.RelativeMouseMovement = false; Globals.RelativeMouseMovement = false;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE; Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
Globals.ForceHardwareMouse = true; Globals.ForceHardwareMouse = true;
} }
if( item == size_large ) if (item == size_large) {
{
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NORMAL; Globals.LeftClickMethod = Mouse.LEFT_CLICK_NORMAL;
Globals.RelativeMouseMovement = false; Globals.RelativeMouseMovement = false;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE; Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
Globals.ForceHardwareMouse = false; Globals.ForceHardwareMouse = false;
} }
if( item == size_small ) if (item == size_small) {
{
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR; Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR;
Globals.RelativeMouseMovement = false; Globals.RelativeMouseMovement = false;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_MAGNIFIER; Globals.ShowScreenUnderFinger = Mouse.ZOOM_MAGNIFIER;
Globals.ForceHardwareMouse = false; Globals.ForceHardwareMouse = false;
} }
if( item == size_small_touchpad ) if (item == size_small_touchpad) {
{
Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT; Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT;
Globals.RelativeMouseMovement = true; Globals.RelativeMouseMovement = true;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE; Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
Globals.ForceHardwareMouse = false; Globals.ForceHardwareMouse = false;
} }
if( item == more_options ) if (item == more_options) {
{
menuStack.clear(); menuStack.clear();
new MainMenu().run(p); new MainMenu().run(p);
return; return;
@ -194,10 +179,8 @@ class SettingsMenuMouse extends SettingsMenu
Globals.ShowScreenUnderFinger + 1, Globals.ShowScreenUnderFinger + 1,
new ClickListener()); new ClickListener());
*/ */
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -207,14 +190,12 @@ class SettingsMenuMouse extends SettingsMenu
} }
} }
static class LeftClickConfig extends Menu static class LeftClickConfig extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.leftclick_question); return p.getResources().getString(R.string.leftclick_question);
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
final CharSequence[] items = {p.getResources().getString(R.string.leftclick_normal), final CharSequence[] items = {p.getResources().getString(R.string.leftclick_normal),
p.getResources().getString(R.string.leftclick_near_cursor), p.getResources().getString(R.string.leftclick_near_cursor),
p.getResources().getString(R.string.leftclick_multitouch), p.getResources().getString(R.string.leftclick_multitouch),
@ -226,10 +207,8 @@ class SettingsMenuMouse extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.leftclick_question); builder.setTitle(R.string.leftclick_question);
builder.setSingleChoiceItems(items, Globals.LeftClickMethod, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.LeftClickMethod, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss(); dialog.dismiss();
Globals.LeftClickMethod = item; Globals.LeftClickMethod = item;
if (item == Mouse.LEFT_CLICK_WITH_KEY) if (item == Mouse.LEFT_CLICK_WITH_KEY)
@ -240,10 +219,8 @@ class SettingsMenuMouse extends SettingsMenu
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -251,6 +228,7 @@ class SettingsMenuMouse extends SettingsMenu
alert.setOwnerActivity(p); alert.setOwnerActivity(p);
alert.show(); alert.show();
} }
static void showLeftClickTimeoutConfig(final MainActivity p) { static void showLeftClickTimeoutConfig(final MainActivity p) {
final CharSequence[] items = {p.getResources().getString(R.string.leftclick_timeout_time_0), final CharSequence[] items = {p.getResources().getString(R.string.leftclick_timeout_time_0),
p.getResources().getString(R.string.leftclick_timeout_time_1), p.getResources().getString(R.string.leftclick_timeout_time_1),
@ -260,19 +238,15 @@ class SettingsMenuMouse extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.leftclick_timeout_time); builder.setTitle(R.string.leftclick_timeout_time);
builder.setSingleChoiceItems(items, Globals.LeftClickTimeout, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.LeftClickTimeout, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.LeftClickTimeout = item; Globals.LeftClickTimeout = item;
dialog.dismiss(); dialog.dismiss();
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -282,18 +256,16 @@ class SettingsMenuMouse extends SettingsMenu
} }
} }
static class RightClickConfig extends Menu static class RightClickConfig extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.rightclick_question); return p.getResources().getString(R.string.rightclick_question);
} }
boolean enabled()
{ boolean enabled() {
return Globals.AppNeedsTwoButtonMouse; return Globals.AppNeedsTwoButtonMouse;
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
final CharSequence[] items = {p.getResources().getString(R.string.rightclick_none), final CharSequence[] items = {p.getResources().getString(R.string.rightclick_none),
p.getResources().getString(R.string.rightclick_multitouch), p.getResources().getString(R.string.rightclick_multitouch),
p.getResources().getString(R.string.rightclick_pressure), p.getResources().getString(R.string.rightclick_pressure),
@ -302,10 +274,8 @@ class SettingsMenuMouse extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.rightclick_question); builder.setTitle(R.string.rightclick_question);
builder.setSingleChoiceItems(items, Globals.RightClickMethod, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.RightClickMethod, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.RightClickMethod = item; Globals.RightClickMethod = item;
dialog.dismiss(); dialog.dismiss();
if (item == Mouse.RIGHT_CLICK_WITH_KEY) if (item == Mouse.RIGHT_CLICK_WITH_KEY)
@ -316,10 +286,8 @@ class SettingsMenuMouse extends SettingsMenu
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -337,19 +305,15 @@ class SettingsMenuMouse extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.leftclick_timeout_time); builder.setTitle(R.string.leftclick_timeout_time);
builder.setSingleChoiceItems(items, Globals.RightClickTimeout, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.RightClickTimeout, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.RightClickTimeout = item; Globals.RightClickTimeout = item;
dialog.dismiss(); dialog.dismiss();
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -359,20 +323,18 @@ class SettingsMenuMouse extends SettingsMenu
} }
} }
public static class KeyRemapToolMouseClick implements View.OnKeyListener public static class KeyRemapToolMouseClick implements View.OnKeyListener {
{
MainActivity p; MainActivity p;
boolean leftClick; boolean leftClick;
public KeyRemapToolMouseClick(MainActivity _p, boolean leftClick)
{ public KeyRemapToolMouseClick(MainActivity _p, boolean leftClick) {
p = _p; p = _p;
p.setText(p.getResources().getString(R.string.remap_hwkeys_press)); p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
this.leftClick = leftClick; this.leftClick = leftClick;
} }
@Override @Override
public boolean onKey(View v, int keyCode, KeyEvent event) public boolean onKey(View v, int keyCode, KeyEvent event) {
{
p.getVideoLayout().setOnKeyListener(null); p.getVideoLayout().setOnKeyListener(null);
int keyIndex = keyCode; int keyIndex = keyCode;
if (keyIndex < 0) if (keyIndex < 0)
@ -390,14 +352,12 @@ class SettingsMenuMouse extends SettingsMenu
} }
} }
static class AdditionalMouseConfig extends Menu static class AdditionalMouseConfig extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.advanced); return p.getResources().getString(R.string.advanced);
} }
void run (final MainActivity p)
{ void run(final MainActivity p) {
CharSequence[] items = { CharSequence[] items = {
p.getResources().getString(R.string.mouse_hover_jitter_filter), p.getResources().getString(R.string.mouse_hover_jitter_filter),
p.getResources().getString(R.string.mouse_joystickmouse), p.getResources().getString(R.string.mouse_joystickmouse),
@ -420,10 +380,8 @@ class SettingsMenuMouse extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.advanced)); builder.setTitle(p.getResources().getString(R.string.advanced));
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() {
{ public void onClick(DialogInterface dialog, int item, boolean isChecked) {
public void onClick(DialogInterface dialog, int item, boolean isChecked)
{
if (item == 0) if (item == 0)
Globals.HoverJitterFilter = isChecked; Globals.HoverJitterFilter = isChecked;
if (item == 1) if (item == 1)
@ -440,18 +398,14 @@ class SettingsMenuMouse extends SettingsMenu
Globals.GenerateSubframeTouchEvents = isChecked; Globals.GenerateSubframeTouchEvents = isChecked;
} }
}); });
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss(); dialog.dismiss();
showGyroscopeMouseMovementConfig(p); showGyroscopeMouseMovementConfig(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -460,10 +414,8 @@ class SettingsMenuMouse extends SettingsMenu
alert.show(); alert.show();
} }
static void showGyroscopeMouseMovementConfig(final MainActivity p) static void showGyroscopeMouseMovementConfig(final MainActivity p) {
{ if (!Globals.MoveMouseWithGyroscope) {
if( !Globals.MoveMouseWithGyroscope )
{
showRelativeMouseMovementConfig(p); showRelativeMouseMovementConfig(p);
return; return;
} }
@ -476,20 +428,16 @@ class SettingsMenuMouse extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.mouse_gyroscope_mouse_sensitivity); builder.setTitle(R.string.mouse_gyroscope_mouse_sensitivity);
builder.setSingleChoiceItems(items, Globals.MoveMouseWithGyroscopeSpeed, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.MoveMouseWithGyroscopeSpeed, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.MoveMouseWithGyroscopeSpeed = item; Globals.MoveMouseWithGyroscopeSpeed = item;
dialog.dismiss(); dialog.dismiss();
showRelativeMouseMovementConfig(p); showRelativeMouseMovementConfig(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -498,10 +446,8 @@ class SettingsMenuMouse extends SettingsMenu
alert.show(); alert.show();
} }
static void showRelativeMouseMovementConfig(final MainActivity p) static void showRelativeMouseMovementConfig(final MainActivity p) {
{ if (!Globals.RelativeMouseMovement) {
if( !Globals.RelativeMouseMovement )
{
goBack(p); goBack(p);
return; return;
} }
@ -514,20 +460,16 @@ class SettingsMenuMouse extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.mouse_relative_speed); builder.setTitle(R.string.mouse_relative_speed);
builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementSpeed, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementSpeed, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.RelativeMouseMovementSpeed = item; Globals.RelativeMouseMovementSpeed = item;
dialog.dismiss(); dialog.dismiss();
showRelativeMouseMovementConfig1(p); showRelativeMouseMovementConfig1(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -536,8 +478,7 @@ class SettingsMenuMouse extends SettingsMenu
alert.show(); alert.show();
} }
static void showRelativeMouseMovementConfig1(final MainActivity p) static void showRelativeMouseMovementConfig1(final MainActivity p) {
{
final CharSequence[] items = {p.getResources().getString(R.string.none), final CharSequence[] items = {p.getResources().getString(R.string.none),
p.getResources().getString(R.string.accel_slow), p.getResources().getString(R.string.accel_slow),
p.getResources().getString(R.string.accel_medium), p.getResources().getString(R.string.accel_medium),
@ -545,20 +486,16 @@ class SettingsMenuMouse extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.mouse_relative_accel); builder.setTitle(R.string.mouse_relative_accel);
builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementAccel, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementAccel, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.RelativeMouseMovementAccel = item; Globals.RelativeMouseMovementAccel = item;
dialog.dismiss(); dialog.dismiss();
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -568,38 +505,34 @@ class SettingsMenuMouse extends SettingsMenu
} }
} }
static class JoystickMouseConfig extends Menu static class JoystickMouseConfig extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.mouse_joystickmousespeed); return p.getResources().getString(R.string.mouse_joystickmousespeed);
} }
boolean enabled()
{ boolean enabled() {
return Globals.MoveMouseWithJoystick; return Globals.MoveMouseWithJoystick;
}; }
void run (final MainActivity p)
{ ;
void run(final MainActivity p) {
final CharSequence[] items = {p.getResources().getString(R.string.accel_slow), final CharSequence[] items = {p.getResources().getString(R.string.accel_slow),
p.getResources().getString(R.string.accel_medium), p.getResources().getString(R.string.accel_medium),
p.getResources().getString(R.string.accel_fast)}; p.getResources().getString(R.string.accel_fast)};
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.mouse_joystickmousespeed); builder.setTitle(R.string.mouse_joystickmousespeed);
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickSpeed, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickSpeed, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.MoveMouseWithJoystickSpeed = item; Globals.MoveMouseWithJoystickSpeed = item;
dialog.dismiss(); dialog.dismiss();
showJoystickMouseAccelConfig(p); showJoystickMouseAccelConfig(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -608,8 +541,7 @@ class SettingsMenuMouse extends SettingsMenu
alert.show(); alert.show();
} }
static void showJoystickMouseAccelConfig(final MainActivity p) static void showJoystickMouseAccelConfig(final MainActivity p) {
{
final CharSequence[] items = {p.getResources().getString(R.string.none), final CharSequence[] items = {p.getResources().getString(R.string.none),
p.getResources().getString(R.string.accel_slow), p.getResources().getString(R.string.accel_slow),
p.getResources().getString(R.string.accel_medium), p.getResources().getString(R.string.accel_medium),
@ -617,20 +549,16 @@ class SettingsMenuMouse extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.mouse_joystickmouseaccel); builder.setTitle(R.string.mouse_joystickmouseaccel);
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickAccel, new DialogInterface.OnClickListener() builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickAccel, new DialogInterface.OnClickListener() {
{ public void onClick(DialogInterface dialog, int item) {
public void onClick(DialogInterface dialog, int item)
{
Globals.MoveMouseWithJoystickAccel = item; Globals.MoveMouseWithJoystickAccel = item;
dialog.dismiss(); dialog.dismiss();
goBack(p); goBack(p);
} }
}); });
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
{ public void onCancel(DialogInterface dialog) {
public void onCancel(DialogInterface dialog)
{
goBack(p); goBack(p);
} }
}); });
@ -640,47 +568,44 @@ class SettingsMenuMouse extends SettingsMenu
} }
} }
static class TouchPressureMeasurementTool extends Menu static class TouchPressureMeasurementTool extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.measurepressure); return p.getResources().getString(R.string.measurepressure);
} }
boolean enabled()
{ boolean enabled() {
return Globals.RightClickMethod == Mouse.RIGHT_CLICK_WITH_PRESSURE || return Globals.RightClickMethod == Mouse.RIGHT_CLICK_WITH_PRESSURE ||
Globals.LeftClickMethod == Mouse.LEFT_CLICK_WITH_PRESSURE; Globals.LeftClickMethod == Mouse.LEFT_CLICK_WITH_PRESSURE;
}; }
void run (final MainActivity p)
{ ;
void run(final MainActivity p) {
p.setText(p.getResources().getString(R.string.measurepressure_touchplease)); p.setText(p.getResources().getString(R.string.measurepressure_touchplease));
p.getVideoLayout().setOnTouchListener(new TouchMeasurementTool(p)); p.getVideoLayout().setOnTouchListener(new TouchMeasurementTool(p));
} }
public static class TouchMeasurementTool implements View.OnTouchListener public static class TouchMeasurementTool implements View.OnTouchListener {
{
MainActivity p; MainActivity p;
ArrayList<Integer> force = new ArrayList<Integer>(); ArrayList<Integer> force = new ArrayList<Integer>();
ArrayList<Integer> radius = new ArrayList<Integer>(); ArrayList<Integer> radius = new ArrayList<Integer>();
static final int maxEventAmount = 100; static final int maxEventAmount = 100;
public TouchMeasurementTool(MainActivity _p) public TouchMeasurementTool(MainActivity _p) {
{
p = _p; p = _p;
} }
@Override @Override
public boolean onTouch(View v, MotionEvent ev) public boolean onTouch(View v, MotionEvent ev) {
{
force.add(new Integer((int) (ev.getPressure() * 1000.0))); force.add(new Integer((int) (ev.getPressure() * 1000.0)));
radius.add(new Integer((int) (ev.getSize() * 1000.0))); radius.add(new Integer((int) (ev.getSize() * 1000.0)));
p.setText(p.getResources().getString(R.string.measurepressure_response, force.get(force.size() - 1), radius.get(radius.size() - 1))); p.setText(p.getResources().getString(R.string.measurepressure_response, force.get(force.size() - 1), radius.get(radius.size() - 1)));
try { try {
Thread.sleep(10L); Thread.sleep(10L);
} catch (InterruptedException e) { } } catch (InterruptedException e) {
}
if( force.size() >= maxEventAmount ) if (force.size() >= maxEventAmount) {
{
p.getVideoLayout().setOnTouchListener(null); p.getVideoLayout().setOnTouchListener(null);
Globals.ClickScreenPressure = getAverageForce(); Globals.ClickScreenPressure = getAverageForce();
Globals.ClickScreenTouchspotSize = getAverageRadius(); Globals.ClickScreenTouchspotSize = getAverageRadius();
@ -690,20 +615,17 @@ class SettingsMenuMouse extends SettingsMenu
return true; return true;
} }
int getAverageForce() int getAverageForce() {
{
int avg = 0; int avg = 0;
for(Integer f: force) for (Integer f : force) {
{
avg += f; avg += f;
} }
return avg / force.size(); return avg / force.size();
} }
int getAverageRadius()
{ int getAverageRadius() {
int avg = 0; int avg = 0;
for(Integer r: radius) for (Integer r : radius) {
{
avg += r; avg += r;
} }
return avg / radius.size(); return avg / radius.size();
@ -711,15 +633,13 @@ class SettingsMenuMouse extends SettingsMenu
} }
} }
static class CalibrateTouchscreenMenu extends Menu static class CalibrateTouchscreenMenu extends Menu {
{ String title(final MainActivity p) {
String title(final MainActivity p)
{
return p.getResources().getString(R.string.calibrate_touchscreen); return p.getResources().getString(R.string.calibrate_touchscreen);
} }
//boolean enabled() { return true; }; //boolean enabled() { return true; };
void run (final MainActivity p) void run(final MainActivity p) {
{
p.setText(p.getResources().getString(R.string.calibrate_touchscreen_touch)); p.setText(p.getResources().getString(R.string.calibrate_touchscreen_touch));
Globals.TouchscreenCalibration[0] = 0; Globals.TouchscreenCalibration[0] = 0;
Globals.TouchscreenCalibration[1] = 0; Globals.TouchscreenCalibration[1] = 0;
@ -730,14 +650,12 @@ class SettingsMenuMouse extends SettingsMenu
p.getVideoLayout().setOnKeyListener(tool); p.getVideoLayout().setOnKeyListener(tool);
} }
static class ScreenEdgesCalibrationTool implements View.OnTouchListener, View.OnKeyListener static class ScreenEdgesCalibrationTool implements View.OnTouchListener, View.OnKeyListener {
{
MainActivity p; MainActivity p;
ImageView img; ImageView img;
Bitmap bmp; Bitmap bmp;
public ScreenEdgesCalibrationTool(MainActivity _p) public ScreenEdgesCalibrationTool(MainActivity _p) {
{
p = _p; p = _p;
img = new ImageView(p); img = new ImageView(p);
img.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); img.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
@ -754,12 +672,10 @@ class SettingsMenuMouse extends SettingsMenu
} }
@Override @Override
public boolean onTouch(View v, MotionEvent ev) public boolean onTouch(View v, MotionEvent ev) {
{
if (Globals.TouchscreenCalibration[0] == Globals.TouchscreenCalibration[1] && if (Globals.TouchscreenCalibration[0] == Globals.TouchscreenCalibration[1] &&
Globals.TouchscreenCalibration[1] == Globals.TouchscreenCalibration[2] && Globals.TouchscreenCalibration[1] == Globals.TouchscreenCalibration[2] &&
Globals.TouchscreenCalibration[2] == Globals.TouchscreenCalibration[3] ) Globals.TouchscreenCalibration[2] == Globals.TouchscreenCalibration[3]) {
{
Globals.TouchscreenCalibration[0] = (int) ev.getX(); Globals.TouchscreenCalibration[0] = (int) ev.getX();
Globals.TouchscreenCalibration[1] = (int) ev.getY(); Globals.TouchscreenCalibration[1] = (int) ev.getY();
Globals.TouchscreenCalibration[2] = (int) ev.getX(); Globals.TouchscreenCalibration[2] = (int) ev.getX();
@ -783,8 +699,7 @@ class SettingsMenuMouse extends SettingsMenu
} }
@Override @Override
public boolean onKey(View v, int keyCode, KeyEvent event) public boolean onKey(View v, int keyCode, KeyEvent event) {
{
p.getVideoLayout().setOnTouchListener(null); p.getVideoLayout().setOnTouchListener(null);
p.getVideoLayout().setOnKeyListener(null); p.getVideoLayout().setOnKeyListener(null);
p.getVideoLayout().removeView(img); p.getVideoLayout().removeView(img);

File diff suppressed because it is too large Load Diff

View File

@ -22,11 +22,8 @@ freely, subject to the following restrictions:
package io.neoterm; package io.neoterm;
import java.io.InputStream;
import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.EOFException; import java.io.InputStream;
import android.util.Log;
/** /**
* Decompresses a .xz file in streamed mode (no seeking). * Decompresses a .xz file in streamed mode (no seeking).
@ -34,8 +31,7 @@ import android.util.Log;
* but using liblzma and JNI instead of Java, because Java heap * but using liblzma and JNI instead of Java, because Java heap
* is very limited, and we're hitting memory limit on emulator. * is very limited, and we're hitting memory limit on emulator.
*/ */
public class XZInputStream extends InputStream public class XZInputStream extends InputStream {
{
private long nativeData = 0; private long nativeData = 0;
private InputStream in = null; private InputStream in = null;
private final byte[] inBuf = new byte[8192]; private final byte[] inBuf = new byte[8192];
@ -46,36 +42,29 @@ public class XZInputStream extends InputStream
private final byte[] tempBuf = new byte[1]; private final byte[] tempBuf = new byte[1];
public XZInputStream(InputStream in) throws IOException public XZInputStream(InputStream in) throws IOException {
{
this.in = in; this.in = in;
if (in == null) if (in == null) {
{
throw new NullPointerException("InputStream == null"); throw new NullPointerException("InputStream == null");
} }
nativeData = nativeInit(); nativeData = nativeInit();
if (nativeData == 0) if (nativeData == 0) {
{
throw new OutOfMemoryError("Cannot initialize JNI liblzma object"); throw new OutOfMemoryError("Cannot initialize JNI liblzma object");
} }
} }
@Override @Override
public int available() throws IOException public int available() throws IOException {
{
return 0; // Don't care return 0; // Don't care
} }
@Override @Override
public void close() throws IOException public void close() throws IOException {
{ synchronized (this) {
synchronized (this)
{
if (nativeData != 0) if (nativeData != 0)
nativeClose(nativeData); nativeClose(nativeData);
nativeData = 0; nativeData = 0;
if (in != null) if (in != null) {
{
try { try {
in.close(); in.close();
} finally { } finally {
@ -86,8 +75,7 @@ public class XZInputStream extends InputStream
} }
@Override @Override
protected void finalize() throws IOException protected void finalize() throws IOException {
{
try { try {
close(); close();
} finally { } finally {
@ -100,14 +88,12 @@ public class XZInputStream extends InputStream
} }
@Override @Override
public int read() throws IOException public int read() throws IOException {
{
return read(tempBuf, 0, 1) == -1 ? -1 : (tempBuf[0] & 0xFF); return read(tempBuf, 0, 1) == -1 ? -1 : (tempBuf[0] & 0xFF);
} }
@Override @Override
public int read(byte[] outBuf, int outOffset, int outCount) throws IOException public int read(byte[] outBuf, int outOffset, int outCount) throws IOException {
{
//Log.i("SDL", "XZInputStream.read: outOffset " + outOffset + " outCount " + outCount + " outBufEof " + outBufEof + //Log.i("SDL", "XZInputStream.read: outOffset " + outOffset + " outCount " + outCount + " outBufEof " + outBufEof +
// " inOffset " + inOffset + " inAvailable " + inAvailable); // " inOffset " + inOffset + " inAvailable " + inAvailable);
if (outBufEof) if (outBufEof)
@ -117,8 +103,7 @@ public class XZInputStream extends InputStream
int oldOutOffset = outOffset; int oldOutOffset = outOffset;
if (inOffset >= inAvailable && inAvailable != -1) if (inOffset >= inAvailable && inAvailable != -1) {
{
inAvailable = in.read(inBuf, 0, inBuf.length); inAvailable = in.read(inBuf, 0, inBuf.length);
inOffset = 0; inOffset = 0;
//Log.i("SDL", "XZInputStream.read: in.read: inOffset " + inOffset + " inAvailable " + inAvailable); //Log.i("SDL", "XZInputStream.read: in.read: inOffset " + inOffset + " inAvailable " + inAvailable);
@ -132,10 +117,8 @@ public class XZInputStream extends InputStream
//Log.i("SDL", "XZInputStream.read: nativeRead: outOffset " + outOffset + " outCount " + outCount + " outBufEof " + outBufEof + //Log.i("SDL", "XZInputStream.read: nativeRead: outOffset " + outOffset + " outCount " + outCount + " outBufEof " + outBufEof +
// " inOffset " + inOffset + " inAvailable " + inAvailable + " ret " + ret); // " inOffset " + inOffset + " inAvailable " + inAvailable + " ret " + ret);
if (ret != 0) if (ret != 0) {
{ if (ret == 1) {
if (ret == 1)
{
if (inOffset < inAvailable) if (inOffset < inAvailable)
throw new IOException("Garbage at the end of LZMA stream"); throw new IOException("Garbage at the end of LZMA stream");
if (inAvailable != -1) if (inAvailable != -1)
@ -143,9 +126,7 @@ public class XZInputStream extends InputStream
if (inAvailable != -1) if (inAvailable != -1)
throw new IOException("Garbage at the end of LZMA stream"); throw new IOException("Garbage at the end of LZMA stream");
outBufEof = true; outBufEof = true;
} } else {
else
{
throw new IOException("LZMA error " + ret); throw new IOException("LZMA error " + ret);
} }
} }
@ -155,7 +136,9 @@ public class XZInputStream extends InputStream
} }
private native long nativeInit(); private native long nativeInit();
private native void nativeClose(long nativeData); private native void nativeClose(long nativeData);
private native int nativeRead(long nativeData, byte[] inBuf, int inAvailable, byte[] outBuf, int outCount, int[] offsets); private native int nativeRead(long nativeData, byte[] inBuf, int inAvailable, byte[] outBuf, int outCount, int[] offsets);
} }

View File

@ -3,7 +3,6 @@ package io.neoterm.xorg;
import android.content.Context; import android.content.Context;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import io.neoterm.NeoGLView; import io.neoterm.NeoGLView;
/** /**

View File

@ -189,7 +189,9 @@
<!-- Play Game Services strings --> <!-- Play Game Services strings -->
<string name="gamehelper_sign_in_failed">无法登录,请检查您的网络连接,然后重试。</string> <string name="gamehelper_sign_in_failed">无法登录,请检查您的网络连接,然后重试。</string>
<string name="gamehelper_app_misconfigured">应用程序配置不正确。请检查包名和签名证书是否与开发者控制台中创建的客户端ID一致。此外如果应用程序尚未发布请检查您的帐户是否为测试人员帐户。详细信息请参阅日志。</string> <string name="gamehelper_app_misconfigured">
应用程序配置不正确。请检查包名和签名证书是否与开发者控制台中创建的客户端ID一致。此外如果应用程序尚未发布请检查您的帐户是否为测试人员帐户。详细信息请参阅日志。
</string>
<string name="gamehelper_license_failed">许可证检查失败。</string> <string name="gamehelper_license_failed">许可证检查失败。</string>
<string name="gamehelper_unknown_error">未知错误。</string> <string name="gamehelper_unknown_error">未知错误。</string>
<string name="accessing_network">正在访问网络,请稍候</string> <string name="accessing_network">正在访问网络,请稍候</string>

View File

@ -151,7 +151,8 @@
<string name="video">Video settings</string> <string name="video">Video settings</string>
<string name="video_smooth">Linear video filtering</string> <string name="video_smooth">Linear video filtering</string>
<string name="video_separatethread">Separate thread for video, it can increase FPS, it also can crash the app</string> <string name="video_separatethread">Separate thread for video, it can increase FPS, it also can crash the app
</string>
<string name="video_orientation_vertical">Portrait/vertical screen orientation</string> <string name="video_orientation_vertical">Portrait/vertical screen orientation</string>
<string name="video_orientation_autodetect">Auto-detect screen orientation</string> <string name="video_orientation_autodetect">Auto-detect screen orientation</string>
<string name="video_bpp_24">24 bpp screen color depth</string> <string name="video_bpp_24">24 bpp screen color depth</string>
@ -190,8 +191,13 @@
<string name="no">No</string> <string name="no">No</string>
<!-- Play Game Services strings --> <!-- Play Game Services strings -->
<string name="gamehelper_sign_in_failed">Failed to sign in. Please check your network connection and try again.</string> <string name="gamehelper_sign_in_failed">Failed to sign in. Please check your network connection and try again.
<string name="gamehelper_app_misconfigured">The application is incorrectly configured. Check that the package name and signing certificate match the client ID created in Developer Console. Also, if the application is not yet published, check that the account you are trying to sign in with is listed as a tester account. See logs for more information.</string> </string>
<string name="gamehelper_app_misconfigured">The application is incorrectly configured. Check that the package name
and signing certificate match the client ID created in Developer Console. Also, if the application is not yet
published, check that the account you are trying to sign in with is listed as a tester account. See logs for
more information.
</string>
<string name="gamehelper_license_failed">License check failed.</string> <string name="gamehelper_license_failed">License check failed.</string>
<string name="gamehelper_unknown_error">Unknown error.</string> <string name="gamehelper_unknown_error">Unknown error.</string>
<string name="accessing_network">Accessing network, please wait</string> <string name="accessing_network">Accessing network, please wait</string>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Keyboard android:keyWidth="10.000002%p" android:keyHeight="10.000002%p" android:horizontalGap="0.0px" android:verticalGap="0.0px" <Keyboard android:keyWidth="10.000002%p" android:keyHeight="10.000002%p" android:horizontalGap="0.0px"
android:verticalGap="0.0px"
xmlns:android="http://schemas.android.com/apk/res/android"> xmlns:android="http://schemas.android.com/apk/res/android">
<Row> <Row>
<Key android:codes="45" android:keyEdgeFlags="left" android:keyLabel="q"/> <Key android:codes="45" android:keyEdgeFlags="left" android:keyLabel="q"/>

View File

@ -38,7 +38,8 @@
<Key android:codes="30" android:keyLabel="B" android:isRepeatable="true"/> <Key android:codes="30" android:keyLabel="B" android:isRepeatable="true"/>
<Key android:codes="42" android:keyLabel="N" android:isRepeatable="true"/> <Key android:codes="42" android:keyLabel="N" android:isRepeatable="true"/>
<Key android:codes="41" android:keyLabel="M" android:isRepeatable="true"/> <Key android:codes="41" android:keyLabel="M" android:isRepeatable="true"/>
<Key android:codes="67" android:keyLabel="≪ ×" android:keyWidth="20%p" android:keyEdgeFlags="right" android:isRepeatable="true"/> <Key android:codes="67" android:keyLabel="≪ ×" android:keyWidth="20%p" android:keyEdgeFlags="right"
android:isRepeatable="true"/>
</Row> </Row>
<Row android:rowEdgeFlags="bottom"> <Row android:rowEdgeFlags="bottom">
<Key android:codes="-6" android:keyLabel="!@#…" android:keyEdgeFlags="left" android:isRepeatable="true"/> <Key android:codes="-6" android:keyLabel="!@#…" android:keyEdgeFlags="left" android:isRepeatable="true"/>
@ -48,6 +49,7 @@
<Key android:codes="62" android:keyLabel="Space" android:keyWidth="20%p" android:isRepeatable="true"/> <Key android:codes="62" android:keyLabel="Space" android:keyWidth="20%p" android:isRepeatable="true"/>
<Key android:codes="55" android:keyLabel="&lt;" android:isRepeatable="true"/> <Key android:codes="55" android:keyLabel="&lt;" android:isRepeatable="true"/>
<Key android:codes="56" android:keyLabel="&gt;" android:isRepeatable="true"/> <Key android:codes="56" android:keyLabel="&gt;" android:isRepeatable="true"/>
<Key android:codes="66" android:keyLabel="Enter" android:keyWidth="20%p" android:keyEdgeFlags="right" android:isRepeatable="true"/> <Key android:codes="66" android:keyLabel="Enter" android:keyWidth="20%p" android:keyEdgeFlags="right"
android:isRepeatable="true"/>
</Row> </Row>
</Keyboard> </Keyboard>

View File

@ -38,7 +38,8 @@
<Key android:codes="30" android:keyLabel="b" android:isRepeatable="true"/> <Key android:codes="30" android:keyLabel="b" android:isRepeatable="true"/>
<Key android:codes="42" android:keyLabel="n" android:isRepeatable="true"/> <Key android:codes="42" android:keyLabel="n" android:isRepeatable="true"/>
<Key android:codes="41" android:keyLabel="m" android:isRepeatable="true"/> <Key android:codes="41" android:keyLabel="m" android:isRepeatable="true"/>
<Key android:codes="67" android:keyLabel="≪ ×" android:keyWidth="20%p" android:keyEdgeFlags="right" android:isRepeatable="true"/> <Key android:codes="67" android:keyLabel="≪ ×" android:keyWidth="20%p" android:keyEdgeFlags="right"
android:isRepeatable="true"/>
</Row> </Row>
<Row android:rowEdgeFlags="bottom"> <Row android:rowEdgeFlags="bottom">
<Key android:codes="-6" android:keyLabel="123…" android:keyEdgeFlags="left"/> <Key android:codes="-6" android:keyLabel="123…" android:keyEdgeFlags="left"/>
@ -48,6 +49,7 @@
<Key android:codes="62" android:keyLabel="Space" android:keyWidth="20%p" android:isRepeatable="true"/> <Key android:codes="62" android:keyLabel="Space" android:keyWidth="20%p" android:isRepeatable="true"/>
<Key android:codes="55" android:keyLabel="," android:isRepeatable="true"/> <Key android:codes="55" android:keyLabel="," android:isRepeatable="true"/>
<Key android:codes="56" android:keyLabel="." android:isRepeatable="true"/> <Key android:codes="56" android:keyLabel="." android:isRepeatable="true"/>
<Key android:codes="66" android:keyLabel="Enter" android:keyWidth="20%p" android:keyEdgeFlags="right" android:isRepeatable="true"/> <Key android:codes="66" android:keyLabel="Enter" android:keyWidth="20%p" android:keyEdgeFlags="right"
android:isRepeatable="true"/>
</Row> </Row>
</Keyboard> </Keyboard>

View File

@ -38,7 +38,8 @@
<Key android:codes="30" android:keyLabel="B" android:isRepeatable="true"/> <Key android:codes="30" android:keyLabel="B" android:isRepeatable="true"/>
<Key android:codes="42" android:keyLabel="N" android:isRepeatable="true"/> <Key android:codes="42" android:keyLabel="N" android:isRepeatable="true"/>
<Key android:codes="41" android:keyLabel="M" android:isRepeatable="true"/> <Key android:codes="41" android:keyLabel="M" android:isRepeatable="true"/>
<Key android:codes="67" android:keyLabel="≪ ×" android:keyWidth="20%p" android:keyEdgeFlags="right" android:isRepeatable="true"/> <Key android:codes="67" android:keyLabel="≪ ×" android:keyWidth="20%p" android:keyEdgeFlags="right"
android:isRepeatable="true"/>
</Row> </Row>
<Row android:rowEdgeFlags="bottom"> <Row android:rowEdgeFlags="bottom">
<Key android:codes="-6" android:keyLabel="!@#…" android:keyEdgeFlags="left"/> <Key android:codes="-6" android:keyLabel="!@#…" android:keyEdgeFlags="left"/>
@ -48,6 +49,7 @@
<Key android:codes="62" android:keyLabel="Space" android:keyWidth="20%p" android:isRepeatable="true"/> <Key android:codes="62" android:keyLabel="Space" android:keyWidth="20%p" android:isRepeatable="true"/>
<Key android:codes="55" android:keyLabel="&lt;" android:isRepeatable="true"/> <Key android:codes="55" android:keyLabel="&lt;" android:isRepeatable="true"/>
<Key android:codes="56" android:keyLabel="&gt;" android:isRepeatable="true"/> <Key android:codes="56" android:keyLabel="&gt;" android:isRepeatable="true"/>
<Key android:codes="66" android:keyLabel="Enter" android:keyWidth="20%p" android:keyEdgeFlags="right" android:isRepeatable="true"/> <Key android:codes="66" android:keyLabel="Enter" android:keyWidth="20%p" android:keyEdgeFlags="right"
android:isRepeatable="true"/>
</Row> </Row>
</Keyboard> </Keyboard>

View File

@ -2,7 +2,7 @@ package io.neoterm;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
/** /**
* Example local unit test, which will execute on the development machine (host). * Example local unit test, which will execute on the development machine (host).

View File

@ -1,6 +1,8 @@
package io.neoterm.backend; package io.neoterm.backend;
/** A circular byte buffer allowing one producer and one consumer thread. */ /**
* A circular byte buffer allowing one producer and one consumer thread.
*/
final class ByteQueue { final class ByteQueue {
private final byte[] mBuffer; private final byte[] mBuffer;

View File

@ -4,7 +4,9 @@ import android.util.Log;
public final class EmulatorDebug { public final class EmulatorDebug {
/** The tag to use with {@link Log}. */ /**
* The tag to use with {@link Log}.
*/
public static final String LOG_TAG = "NeoTerm-Emulator"; public static final String LOG_TAG = "NeoTerm-Emulator";
} }

View File

@ -25,7 +25,9 @@ final class JNI {
*/ */
public static native int createSubprocess(String cmd, String cwd, String[] args, String[] envVars, int[] processId, int rows, int columns); public static native int createSubprocess(String cmd, String cwd, String[] args, String[] envVars, int[] processId, int rows, int columns);
/** Set the window size for a given pty, which allows connected programs to learn how large their screen is. */ /**
* Set the window size for a given pty, which allows connected programs to learn how large their screen is.
*/
public static native void setPtyWindowSize(int fd, int rows, int cols); public static native void setPtyWindowSize(int fd, int rows, int cols);
/** /**
@ -35,7 +37,9 @@ final class JNI {
*/ */
public static native int waitFor(int processId); public static native int waitFor(int processId);
/** Close a file descriptor through the close(2) system call. */ /**
* Close a file descriptor through the close(2) system call.
*/
public static native void close(int fileDescriptor); public static native void close(int fileDescriptor);
} }

View File

@ -3,56 +3,7 @@ package io.neoterm.backend;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static android.view.KeyEvent.KEYCODE_BACK; import static android.view.KeyEvent.*;
import static android.view.KeyEvent.KEYCODE_BREAK;
import static android.view.KeyEvent.KEYCODE_DEL;
import static android.view.KeyEvent.KEYCODE_DPAD_CENTER;
import static android.view.KeyEvent.KEYCODE_DPAD_DOWN;
import static android.view.KeyEvent.KEYCODE_DPAD_LEFT;
import static android.view.KeyEvent.KEYCODE_DPAD_RIGHT;
import static android.view.KeyEvent.KEYCODE_DPAD_UP;
import static android.view.KeyEvent.KEYCODE_ENTER;
import static android.view.KeyEvent.KEYCODE_ESCAPE;
import static android.view.KeyEvent.KEYCODE_F1;
import static android.view.KeyEvent.KEYCODE_F10;
import static android.view.KeyEvent.KEYCODE_F11;
import static android.view.KeyEvent.KEYCODE_F12;
import static android.view.KeyEvent.KEYCODE_F2;
import static android.view.KeyEvent.KEYCODE_F3;
import static android.view.KeyEvent.KEYCODE_F4;
import static android.view.KeyEvent.KEYCODE_F5;
import static android.view.KeyEvent.KEYCODE_F6;
import static android.view.KeyEvent.KEYCODE_F7;
import static android.view.KeyEvent.KEYCODE_F8;
import static android.view.KeyEvent.KEYCODE_F9;
import static android.view.KeyEvent.KEYCODE_FORWARD_DEL;
import static android.view.KeyEvent.KEYCODE_INSERT;
import static android.view.KeyEvent.KEYCODE_MOVE_END;
import static android.view.KeyEvent.KEYCODE_MOVE_HOME;
import static android.view.KeyEvent.KEYCODE_NUMPAD_0;
import static android.view.KeyEvent.KEYCODE_NUMPAD_1;
import static android.view.KeyEvent.KEYCODE_NUMPAD_2;
import static android.view.KeyEvent.KEYCODE_NUMPAD_3;
import static android.view.KeyEvent.KEYCODE_NUMPAD_4;
import static android.view.KeyEvent.KEYCODE_NUMPAD_5;
import static android.view.KeyEvent.KEYCODE_NUMPAD_6;
import static android.view.KeyEvent.KEYCODE_NUMPAD_7;
import static android.view.KeyEvent.KEYCODE_NUMPAD_8;
import static android.view.KeyEvent.KEYCODE_NUMPAD_9;
import static android.view.KeyEvent.KEYCODE_NUMPAD_ADD;
import static android.view.KeyEvent.KEYCODE_NUMPAD_COMMA;
import static android.view.KeyEvent.KEYCODE_NUMPAD_DIVIDE;
import static android.view.KeyEvent.KEYCODE_NUMPAD_DOT;
import static android.view.KeyEvent.KEYCODE_NUMPAD_ENTER;
import static android.view.KeyEvent.KEYCODE_NUMPAD_EQUALS;
import static android.view.KeyEvent.KEYCODE_NUMPAD_MULTIPLY;
import static android.view.KeyEvent.KEYCODE_NUMPAD_SUBTRACT;
import static android.view.KeyEvent.KEYCODE_NUM_LOCK;
import static android.view.KeyEvent.KEYCODE_PAGE_DOWN;
import static android.view.KeyEvent.KEYCODE_PAGE_UP;
import static android.view.KeyEvent.KEYCODE_SPACE;
import static android.view.KeyEvent.KEYCODE_SYSRQ;
import static android.view.KeyEvent.KEYCODE_TAB;
public final class KeyHandler { public final class KeyHandler {

View File

@ -9,13 +9,21 @@ package io.neoterm.backend;
public final class TerminalBuffer { public final class TerminalBuffer {
TerminalRow[] mLines; TerminalRow[] mLines;
/** The length of {@link #mLines}. */ /**
* The length of {@link #mLines}.
*/
int mTotalRows; int mTotalRows;
/** The number of rows and columns visible on the screen. */ /**
* The number of rows and columns visible on the screen.
*/
int mScreenRows, mColumns; int mScreenRows, mColumns;
/** The number of rows kept in history. */ /**
* The number of rows kept in history.
*/
private int mActiveTranscriptRows = 0; private int mActiveTranscriptRows = 0;
/** The index in the circular buffer where the visible screen starts. */ /**
* The index in the circular buffer where the visible screen starts.
*/
private int mScreenFirstRow = 0; private int mScreenFirstRow = 0;
/** /**
@ -397,7 +405,9 @@ public final class TerminalBuffer {
return allocateFullLineIfNecessary(externalToInternalRow(externalRow)).getStyle(column); return allocateFullLineIfNecessary(externalToInternalRow(externalRow)).getStyle(column);
} }
/** Support for http://vt100.net/docs/vt510-rm/DECCARA and http://vt100.net/docs/vt510-rm/DECCARA */ /**
* Support for http://vt100.net/docs/vt510-rm/DECCARA and http://vt100.net/docs/vt510-rm/DECCARA
*/
public void setOrClearEffect(int bits, boolean setOrClear, boolean reverse, boolean rectangular, int leftMargin, int rightMargin, int top, int left, public void setOrClearEffect(int bits, boolean setOrClear, boolean reverse, boolean rectangular, int leftMargin, int rightMargin, int top, int left,
int bottom, int right) { int bottom, int right) {
for (int y = top; y < bottom; y++) { for (int y = top; y < bottom; y++) {

View File

@ -11,7 +11,9 @@ import java.util.Properties;
*/ */
public final class TerminalColorScheme { public final class TerminalColorScheme {
/** http://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg, but with blue color brighter. */ /**
* http://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg, but with blue color brighter.
*/
public static final int[] DEFAULT_COLORS = { public static final int[] DEFAULT_COLORS = {
// 16 original colors. First 8 are dim. // 16 original colors. First 8 are dim.
0xff000000, // black 0xff000000, // black

View File

@ -1,9 +1,13 @@
package io.neoterm.backend; package io.neoterm.backend;
/** Current terminal colors (if different from default). */ /**
* Current terminal colors (if different from default).
*/
public final class TerminalColors { public final class TerminalColors {
/** Static data - a bit ugly but ok for now. */ /**
* Static data - a bit ugly but ok for now.
*/
public static final TerminalColorScheme COLOR_SCHEME = new TerminalColorScheme(); public static final TerminalColorScheme COLOR_SCHEME = new TerminalColorScheme();
/** /**
@ -12,17 +16,23 @@ public final class TerminalColors {
*/ */
public final int[] mCurrentColors = new int[TextStyle.NUM_INDEXED_COLORS]; public final int[] mCurrentColors = new int[TextStyle.NUM_INDEXED_COLORS];
/** Create a new instance with default colors from the theme. */ /**
* Create a new instance with default colors from the theme.
*/
public TerminalColors() { public TerminalColors() {
reset(); reset();
} }
/** Reset a particular indexed color with the default color from the color theme. */ /**
* Reset a particular indexed color with the default color from the color theme.
*/
public void reset(int index) { public void reset(int index) {
mCurrentColors[index] = COLOR_SCHEME.mDefaultColors[index]; mCurrentColors[index] = COLOR_SCHEME.mDefaultColors[index];
} }
/** Reset all indexed colors with the default color from the color theme. */ /**
* Reset all indexed colors with the default color from the color theme.
*/
public void reset() { public void reset() {
reset(COLOR_SCHEME); reset(COLOR_SCHEME);
} }
@ -72,7 +82,9 @@ public final class TerminalColors {
} }
} }
/** Try parse a color from a text parameter and into a specified index. */ /**
* Try parse a color from a text parameter and into a specified index.
*/
public void tryParseColor(int intoIndex, String textParameter) { public void tryParseColor(int intoIndex, String textParameter) {
int c = parse(textParameter); int c = parse(textParameter);
if (c != 0) mCurrentColors[intoIndex] = c; if (c != 0) mCurrentColors[intoIndex] = c;

View File

@ -2,25 +2,37 @@ package io.neoterm.backend;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
/** A client which receives callbacks from events triggered by feeding input to a {@link TerminalEmulator}. */ /**
* A client which receives callbacks from events triggered by feeding input to a {@link TerminalEmulator}.
*/
public abstract class TerminalOutput { public abstract class TerminalOutput {
/** Write a string using the UTF-8 encoding to the terminal client. */ /**
* Write a string using the UTF-8 encoding to the terminal client.
*/
public final void write(String data) { public final void write(String data) {
byte[] bytes = data.getBytes(StandardCharsets.UTF_8); byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
write(bytes, 0, bytes.length); write(bytes, 0, bytes.length);
} }
/** Write bytes to the terminal client. */ /**
* Write bytes to the terminal client.
*/
public abstract void write(byte[] data, int offset, int count); public abstract void write(byte[] data, int offset, int count);
/** Notify the terminal client that the terminal title has changed. */ /**
* Notify the terminal client that the terminal title has changed.
*/
public abstract void titleChanged(String oldTitle, String newTitle); public abstract void titleChanged(String oldTitle, String newTitle);
/** Notify the terminal client that the terminal title has changed. */ /**
* Notify the terminal client that the terminal title has changed.
*/
public abstract void clipboardText(String text); public abstract void clipboardText(String text);
/** Notify the terminal client that a bell character (ASCII 7, bell, BEL, \a, ^G)) has been received. */ /**
* Notify the terminal client that a bell character (ASCII 7, bell, BEL, \a, ^G)) has been received.
*/
public abstract void onBell(); public abstract void onBell();
public abstract void onColorsChanged(); public abstract void onColorsChanged();

View File

@ -11,20 +11,34 @@ public final class TerminalRow {
private static final float SPARE_CAPACITY_FACTOR = 1.5f; private static final float SPARE_CAPACITY_FACTOR = 1.5f;
/** The number of columns in this terminal row. */ /**
* The number of columns in this terminal row.
*/
private final int mColumns; private final int mColumns;
/** The text filling this terminal row. */ /**
* The text filling this terminal row.
*/
public char[] mText; public char[] mText;
/** The number of java char:s used in {@link #mText}. */ /**
* The number of java char:s used in {@link #mText}.
*/
private short mSpaceUsed; private short mSpaceUsed;
/** If this row has been line wrapped due to text output at the end of line. */ /**
* If this row has been line wrapped due to text output at the end of line.
*/
boolean mLineWrap; boolean mLineWrap;
/** The style bits of each cell in the row. See {@link TextStyle}. */ /**
* The style bits of each cell in the row. See {@link TextStyle}.
*/
final long[] mStyle; final long[] mStyle;
/** If this row might contain chars with width != 1, used for deactivating fast path */ /**
* If this row might contain chars with width != 1, used for deactivating fast path
*/
boolean mHasNonOneWidthOrSurrogateChars; boolean mHasNonOneWidthOrSurrogateChars;
/** Construct a blank row (containing only whitespace, ' ') with a specified style. */ /**
* Construct a blank row (containing only whitespace, ' ') with a specified style.
*/
public TerminalRow(int columns, long style) { public TerminalRow(int columns, long style) {
mColumns = columns; mColumns = columns;
mText = new char[(int) (SPARE_CAPACITY_FACTOR * columns)]; mText = new char[(int) (SPARE_CAPACITY_FACTOR * columns)];
@ -32,7 +46,9 @@ public final class TerminalRow {
clear(style); clear(style);
} }
/** NOTE: The sourceX2 is exclusive. */ /**
* NOTE: The sourceX2 is exclusive.
*/
public void copyInterval(TerminalRow line, int sourceX1, int sourceX2, int destinationX) { public void copyInterval(TerminalRow line, int sourceX1, int sourceX2, int destinationX) {
mHasNonOneWidthOrSurrogateChars |= line.mHasNonOneWidthOrSurrogateChars; mHasNonOneWidthOrSurrogateChars |= line.mHasNonOneWidthOrSurrogateChars;
final int x1 = line.findStartOfColumn(sourceX1); final int x1 = line.findStartOfColumn(sourceX1);
@ -62,7 +78,9 @@ public final class TerminalRow {
return mSpaceUsed; return mSpaceUsed;
} }
/** Note that the column may end of second half of wide character. */ /**
* Note that the column may end of second half of wide character.
*/
public int findStartOfColumn(int column) { public int findStartOfColumn(int column) {
if (column == mColumns) return getSpaceUsed(); if (column == mColumns) return getSpaceUsed();

View File

@ -8,11 +8,7 @@ import android.system.Os;
import android.system.OsConstants; import android.system.OsConstants;
import android.util.Log; import android.util.Log;
import java.io.FileDescriptor; import java.io.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.UUID; import java.util.UUID;
@ -30,7 +26,9 @@ import java.util.UUID;
*/ */
public class TerminalSession extends TerminalOutput { public class TerminalSession extends TerminalOutput {
/** Callback to be invoked when a {@link TerminalSession} changes. */ /**
* Callback to be invoked when a {@link TerminalSession} changes.
*/
public interface SessionChangedCallback { public interface SessionChangedCallback {
void onTextChanged(TerminalSession changedSession); void onTextChanged(TerminalSession changedSession);
@ -83,20 +81,28 @@ public class TerminalSession extends TerminalOutput {
* writing to the {@link #mTerminalFileDescriptor}. * writing to the {@link #mTerminalFileDescriptor}.
*/ */
private final ByteQueue mTerminalToProcessIOQueue = new ByteQueue(4096); private final ByteQueue mTerminalToProcessIOQueue = new ByteQueue(4096);
/** Buffer to write translate code points into utf8 before writing to mTerminalToProcessIOQueue */ /**
* Buffer to write translate code points into utf8 before writing to mTerminalToProcessIOQueue
*/
private final byte[] mUtf8InputBuffer = new byte[5]; private final byte[] mUtf8InputBuffer = new byte[5];
public SessionChangedCallback getSessionChangedCallback() { public SessionChangedCallback getSessionChangedCallback() {
return mChangeCallback; return mChangeCallback;
} }
/** Callback which gets notified when a session finishes or changes title. */ /**
* Callback which gets notified when a session finishes or changes title.
*/
private final SessionChangedCallback mChangeCallback; private final SessionChangedCallback mChangeCallback;
/** The pid of the executablePath process. 0 if not started and -1 if finished running. */ /**
* The pid of the executablePath process. 0 if not started and -1 if finished running.
*/
private int mShellPid; private int mShellPid;
/** The exit status of the executablePath process. Only valid if ${@link #mShellPid} is -1. */ /**
* The exit status of the executablePath process. Only valid if ${@link #mShellPid} is -1.
*/
private int mShellExitStatus; private int mShellExitStatus;
/** /**
@ -105,7 +111,9 @@ public class TerminalSession extends TerminalOutput {
*/ */
private int mTerminalFileDescriptor; private int mTerminalFileDescriptor;
/** Set by the application for user identification of session, not by terminal. */ /**
* Set by the application for user identification of session, not by terminal.
*/
public String mSessionName; public String mSessionName;
@SuppressLint("HandlerLeak") @SuppressLint("HandlerLeak")
@ -147,7 +155,9 @@ public class TerminalSession extends TerminalOutput {
this.mEnv = env; this.mEnv = env;
} }
/** Inform the attached pty of the new size and reflow or initialize the emulator. */ /**
* Inform the attached pty of the new size and reflow or initialize the emulator.
*/
public void updateSize(int columns, int rows) { public void updateSize(int columns, int rows) {
if (mEmulator == null) { if (mEmulator == null) {
initializeEmulator(columns, rows); initializeEmulator(columns, rows);
@ -157,7 +167,9 @@ public class TerminalSession extends TerminalOutput {
} }
} }
/** The terminal title as set through escape sequences or null if none set. */ /**
* The terminal title as set through escape sequences or null if none set.
*/
public String getTitle() { public String getTitle() {
return (mEmulator == null) ? null : mEmulator.getTitle(); return (mEmulator == null) ? null : mEmulator.getTitle();
} }
@ -219,13 +231,17 @@ public class TerminalSession extends TerminalOutput {
}.start(); }.start();
} }
/** Write data to the executablePath process. */ /**
* Write data to the executablePath process.
*/
@Override @Override
public void write(byte[] data, int offset, int count) { public void write(byte[] data, int offset, int count) {
if (mShellPid > 0) mTerminalToProcessIOQueue.write(data, offset, count); if (mShellPid > 0) mTerminalToProcessIOQueue.write(data, offset, count);
} }
/** Write the Unicode code point to the terminal encoded in UTF-8. */ /**
* Write the Unicode code point to the terminal encoded in UTF-8.
*/
public void writeCodePoint(boolean prependEscape, int codePoint) { public void writeCodePoint(boolean prependEscape, int codePoint) {
if (codePoint > 1114111 || (codePoint >= 0xD800 && codePoint <= 0xDFFF)) { if (codePoint > 1114111 || (codePoint >= 0xD800 && codePoint <= 0xDFFF)) {
// 1114111 (= 2**16 + 1024**2 - 1) is the highest code point, [0xD800,0xDFFF] is the surrogate range. // 1114111 (= 2**16 + 1024**2 - 1) is the highest code point, [0xD800,0xDFFF] is the surrogate range.
@ -266,18 +282,24 @@ public class TerminalSession extends TerminalOutput {
return mEmulator; return mEmulator;
} }
/** Notify the {@link #mChangeCallback} that the screen has changed. */ /**
* Notify the {@link #mChangeCallback} that the screen has changed.
*/
private void notifyScreenUpdate() { private void notifyScreenUpdate() {
mChangeCallback.onTextChanged(this); mChangeCallback.onTextChanged(this);
} }
/** Reset state for terminal emulator state. */ /**
* Reset state for terminal emulator state.
*/
public void reset() { public void reset() {
mEmulator.reset(); mEmulator.reset();
notifyScreenUpdate(); notifyScreenUpdate();
} }
/** Finish this terminal session by sending SIGKILL to the executablePath. */ /**
* Finish this terminal session by sending SIGKILL to the executablePath.
*/
public void finishIfRunning() { public void finishIfRunning() {
if (isRunning()) { if (isRunning()) {
try { try {
@ -302,7 +324,9 @@ public class TerminalSession extends TerminalOutput {
return exitDescription; return exitDescription;
} }
/** Cleanup resources when the process exits. */ /**
* Cleanup resources when the process exits.
*/
private void cleanupResources(int exitStatus) { private void cleanupResources(int exitStatus) {
synchronized (this) { synchronized (this) {
mShellPid = -1; mShellPid = -1;
@ -324,7 +348,9 @@ public class TerminalSession extends TerminalOutput {
return mShellPid != -1; return mShellPid != -1;
} }
/** Only valid if not {@link #isRunning()}. */ /**
* Only valid if not {@link #isRunning()}.
*/
public synchronized int getExitStatus() { public synchronized int getExitStatus() {
return mShellExitStatus; return mShellExitStatus;
} }

View File

@ -29,21 +29,31 @@ public final class TextStyle {
* </p> * </p>
*/ */
public final static int CHARACTER_ATTRIBUTE_PROTECTED = 1 << 7; public final static int CHARACTER_ATTRIBUTE_PROTECTED = 1 << 7;
/** Dim colors. Also known as faint or half intensity. */ /**
* Dim colors. Also known as faint or half intensity.
*/
public final static int CHARACTER_ATTRIBUTE_DIM = 1 << 8; public final static int CHARACTER_ATTRIBUTE_DIM = 1 << 8;
/** If true (24-bit) color is used for the cell for foregroundColor. */ /**
* If true (24-bit) color is used for the cell for foregroundColor.
*/
private final static int CHARACTER_ATTRIBUTE_TRUECOLOR_FOREGROUND = 1 << 9; private final static int CHARACTER_ATTRIBUTE_TRUECOLOR_FOREGROUND = 1 << 9;
/** If true (24-bit) color is used for the cell for foregroundColor. */ /**
* If true (24-bit) color is used for the cell for foregroundColor.
*/
private final static int CHARACTER_ATTRIBUTE_TRUECOLOR_BACKGROUND = 1 << 10; private final static int CHARACTER_ATTRIBUTE_TRUECOLOR_BACKGROUND = 1 << 10;
public final static int COLOR_INDEX_FOREGROUND = 256; public final static int COLOR_INDEX_FOREGROUND = 256;
public final static int COLOR_INDEX_BACKGROUND = 257; public final static int COLOR_INDEX_BACKGROUND = 257;
public final static int COLOR_INDEX_CURSOR = 258; public final static int COLOR_INDEX_CURSOR = 258;
/** The 256 standard color entries and the three special (foregroundColor, backgroundColor and cursorColor) ones. */ /**
* The 256 standard color entries and the three special (foregroundColor, backgroundColor and cursorColor) ones.
*/
public final static int NUM_INDEXED_COLORS = 259; public final static int NUM_INDEXED_COLORS = 259;
/** Normal foregroundColor and backgroundColor colors and no effects. */ /**
* Normal foregroundColor and backgroundColor colors and no effects.
*/
final static long NORMAL = encode(COLOR_INDEX_FOREGROUND, COLOR_INDEX_BACKGROUND, 0); final static long NORMAL = encode(COLOR_INDEX_FOREGROUND, COLOR_INDEX_BACKGROUND, 0);
static long encode(int foreColor, int backColor, int effect) { static long encode(int foreColor, int backColor, int effect) {

View File

@ -2,7 +2,7 @@ package io.neoterm.backend;
/** /**
* Implementation of wcwidth(3) for Unicode 9. * Implementation of wcwidth(3) for Unicode 9.
* * <p>
* Implementation from https://github.com/jquast/wcwidth but we return 0 for unprintable characters. * Implementation from https://github.com/jquast/wcwidth but we return 0 for unprintable characters.
*/ */
public final class WcWidth { public final class WcWidth {
@ -427,7 +427,9 @@ public final class WcWidth {
return false; return false;
} }
/** Return the terminal display width of a code point: 0, 1 || 2. */ /**
* Return the terminal display width of a code point: 0, 1 || 2.
*/
public static int width(int ucs) { public static int width(int ucs) {
if (ucs == 0 || if (ucs == 0 ||
ucs == 0x034F || ucs == 0x034F ||
@ -449,7 +451,9 @@ public final class WcWidth {
return intable(WIDE_EASTASIAN, ucs) ? 2 : 1; return intable(WIDE_EASTASIAN, ucs) ? 2 : 1;
} }
/** The width at an index position in a java char array. */ /**
* The width at an index position in a java char array.
*/
public static int width(char[] chars, int index) { public static int width(char[] chars, int index) {
char c = chars[index]; char c = chars[index];
return Character.isHighSurrogate(c) ? width(Character.toCodePoint(c, chars[index + 1])) : width(c); return Character.isHighSurrogate(c) ? width(Character.toCodePoint(c, chars[index + 1])) : width(c);

View File

@ -40,8 +40,12 @@ class NeoColorGenerator(parameter: CodeGenParameter) : CodeGenerator(parameter)
val component = ComponentManager.getComponent<ConfigureComponent>() val component = ComponentManager.getComponent<ConfigureComponent>()
builder.append(" ${NeoColorScheme.COLOR_META_NAME}: \"${colorScheme.colorName}\"\n") builder.append(" ${NeoColorScheme.COLOR_META_NAME}: \"${colorScheme.colorName}\"\n")
builder.append(" ${NeoColorScheme.COLOR_META_VERSION}: ${colorScheme.colorVersion builder.append(
?: component.getLoaderVersion()}\n") " ${NeoColorScheme.COLOR_META_VERSION}: ${
colorScheme.colorVersion
?: component.getLoaderVersion()
}\n"
)
builder.append("\n") builder.append("\n")
} }

View File

@ -76,7 +76,8 @@ class ColorSchemeComponent : ConfigFileBasedComponent<NeoColorScheme>(NeoTermPat
} }
fun getCurrentColorSchemeName(): String { fun getCurrentColorSchemeName(): String {
var currentColorName = NeoPreference.loadString(R.string.key_customization_color_scheme, DefaultColorScheme.colorName) var currentColorName =
NeoPreference.loadString(R.string.key_customization_color_scheme, DefaultColorScheme.colorName)
if (!colors.containsKey(currentColorName)) { if (!colors.containsKey(currentColorName)) {
currentColorName = DefaultColorScheme.colorName currentColorName = DefaultColorScheme.colorName
NeoPreference.store(R.string.key_customization_color_scheme, DefaultColorScheme.colorName) NeoPreference.store(R.string.key_customization_color_scheme, DefaultColorScheme.colorName)

View File

@ -1,12 +1,12 @@
package io.neoterm.component.pm; package io.neoterm.component.pm;
import io.neoterm.frontend.component.NeoComponent;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import io.neoterm.frontend.component.NeoComponent;
/** /**
* @author kiva * @author kiva
*/ */

View File

@ -1,8 +1,8 @@
package io.neoterm.component.session package io.neoterm.component.session
import android.annotation.SuppressLint import android.annotation.SuppressLint
import androidx.appcompat.app.AppCompatActivity
import android.content.Context import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import io.neoterm.Globals import io.neoterm.Globals
import io.neoterm.frontend.component.NeoComponent import io.neoterm.frontend.component.NeoComponent
import io.neoterm.frontend.config.NeoTermPath import io.neoterm.frontend.config.NeoTermPath
@ -48,8 +48,10 @@ class SessionComponent : NeoComponent {
try { try {
System.load(soPath) System.load(soPath)
} catch (error: UnsatisfiedLinkError) { } catch (error: UnsatisfiedLinkError) {
NLog.e("SessionComponent", "Error loading lib " + soPath NLog.e(
+ ", reason: " + error.localizedMessage) "SessionComponent", "Error loading lib " + soPath
+ ", reason: " + error.localizedMessage
)
result = false result = false
} }
} }

View File

@ -5,28 +5,17 @@ import android.database.Cursor;
import android.database.SQLException; import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
import io.neoterm.App;
import io.neoterm.framework.database.*;
import io.neoterm.framework.database.bean.TableInfo;
import io.neoterm.framework.reflection.Reflect;
import io.neoterm.frontend.logging.NLog;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.neoterm.App;
import io.neoterm.framework.database.DatabaseDataType;
import io.neoterm.framework.database.OnDatabaseUpgradedListener;
import io.neoterm.framework.database.SQLStatementHelper;
import io.neoterm.framework.database.SQLTypeParser;
import io.neoterm.framework.database.NeoTermSQLiteConfig;
import io.neoterm.framework.database.TableHelper;
import io.neoterm.framework.database.ValueHelper;
import io.neoterm.framework.database.bean.TableInfo;
import io.neoterm.framework.reflection.Reflect;
import io.neoterm.frontend.logging.NLog;
/** /**
* @author Lody, Kiva * @author Lody, Kiva

View File

@ -107,6 +107,7 @@ public class NeoTermSQLiteConfig implements Serializable {
/** /**
* App 更新时是否默认删除所有存在的表 * App 更新时是否默认删除所有存在的表
*
* @return * @return
*/ */
public boolean isDefaultDropAllTables() { public boolean isDefaultDropAllTables() {
@ -115,6 +116,7 @@ public class NeoTermSQLiteConfig implements Serializable {
/** /**
* 设置 App 更新时是否默认删除所有存在的表 * 设置 App 更新时是否默认删除所有存在的表
*
* @param defaultDropAllTables * @param defaultDropAllTables
*/ */
public void setDefaultDropAllTables(boolean defaultDropAllTables) { public void setDefaultDropAllTables(boolean defaultDropAllTables) {

View File

@ -1,10 +1,10 @@
package io.neoterm.framework.database; package io.neoterm.framework.database;
import java.lang.reflect.Field;
import io.neoterm.framework.database.annotation.ID; import io.neoterm.framework.database.annotation.ID;
import io.neoterm.framework.database.bean.TableInfo; import io.neoterm.framework.database.bean.TableInfo;
import java.lang.reflect.Field;
/** /**
* @author kiva * @author kiva
*/ */

View File

@ -1,10 +1,10 @@
package io.neoterm.framework.database; package io.neoterm.framework.database;
import java.lang.reflect.Field;
import io.neoterm.framework.database.annotation.Ignore; import io.neoterm.framework.database.annotation.Ignore;
import io.neoterm.framework.database.annotation.NotNull; import io.neoterm.framework.database.annotation.NotNull;
import java.lang.reflect.Field;
/** /**
* @author kiva * @author kiva
*/ */

View File

@ -1,16 +1,16 @@
package io.neoterm.framework.database; package io.neoterm.framework.database;
import io.neoterm.framework.NeoTermDatabase;
import io.neoterm.framework.database.annotation.ID;
import io.neoterm.framework.database.annotation.Table;
import io.neoterm.framework.database.bean.TableInfo;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import io.neoterm.framework.NeoTermDatabase;
import io.neoterm.framework.database.annotation.ID;
import io.neoterm.framework.database.annotation.Table;
import io.neoterm.framework.database.bean.TableInfo;
/** /**
* @author kiva * @author kiva
*/ */

View File

@ -1,12 +1,12 @@
package io.neoterm.framework.database.bean; package io.neoterm.framework.database.bean;
import io.neoterm.framework.database.DatabaseDataType;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Map; import java.util.Map;
import io.neoterm.framework.database.DatabaseDataType;
/** /**
* @author kiva * @author kiva
*/ */

View File

@ -2,6 +2,7 @@ package io.neoterm.framework.reflection;
/** /**
* class representing null pointer. * class representing null pointer.
*
* @author kiva * @author kiva
*/ */
public class NullPointer { public class NullPointer {

View File

@ -45,9 +45,11 @@ class CandidatePopupWindow(val context: Context) {
rootView.setMaxHeight(maxHeight) rootView.setMaxHeight(maxHeight)
} }
popWindow.showAtLocation(terminalView, Gravity.BOTTOM.and(Gravity.START), popWindow.showAtLocation(
terminalView, Gravity.BOTTOM.and(Gravity.START),
terminalView.cursorAbsoluteX, terminalView.cursorAbsoluteX,
terminalView.cursorAbsoluteY) terminalView.cursorAbsoluteY
)
} }
} }

View File

@ -45,8 +45,10 @@ class MaxHeightView : LinearLayout {
else else
maxHeight maxHeight
} }
finalHeightMeasureSpec = View.MeasureSpec.makeMeasureSpec(heightSize, finalHeightMeasureSpec = View.MeasureSpec.makeMeasureSpec(
heightMode) heightSize,
heightMode
)
} }
super.onMeasure(widthMeasureSpec, finalHeightMeasureSpec) super.onMeasure(widthMeasureSpec, finalHeightMeasureSpec)

View File

@ -27,8 +27,8 @@ object ComponentManager {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
fun <T : NeoComponent> getComponent(componentInterface: Class<T>, errorThrow: Boolean = true): T { fun <T : NeoComponent> getComponent(componentInterface: Class<T>, errorThrow: Boolean = true): T {
val component: NeoComponent = COMPONENTS[componentInterface] ?: val component: NeoComponent =
throw ComponentNotFoundException(componentInterface.simpleName) COMPONENTS[componentInterface] ?: throw ComponentNotFoundException(componentInterface.simpleName)
component.onServiceObtained() component.onServiceObtained()
return component as T return component as T

View File

@ -1,12 +1,12 @@
package io.neoterm.frontend.config package io.neoterm.frontend.config
import android.Manifest import android.Manifest
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AlertDialog
import android.content.ActivityNotFoundException import android.content.ActivityNotFoundException
import android.content.DialogInterface import android.content.DialogInterface
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.os.Build import android.os.Build
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
@ -21,12 +21,18 @@ object NeoPermission {
return return
} }
if (ContextCompat.checkSelfPermission(context, if (ContextCompat.checkSelfPermission(
Manifest.permission.READ_EXTERNAL_STORAGE) context,
!= PackageManager.PERMISSION_GRANTED) { Manifest.permission.READ_EXTERNAL_STORAGE
)
!= PackageManager.PERMISSION_GRANTED
) {
if (ActivityCompat.shouldShowRequestPermissionRationale(context, if (ActivityCompat.shouldShowRequestPermissionRationale(
Manifest.permission.READ_EXTERNAL_STORAGE)) { context,
Manifest.permission.READ_EXTERNAL_STORAGE
)
) {
AlertDialog.Builder(context).setMessage("需要存储权限来访问存储设备上的文件") AlertDialog.Builder(context).setMessage("需要存储权限来访问存储设备上的文件")
.setPositiveButton(android.R.string.ok, { _: DialogInterface, _: Int -> .setPositiveButton(android.R.string.ok, { _: DialogInterface, _: Int ->
doRequestPermission(context, requestCode) doRequestPermission(context, requestCode)
@ -41,9 +47,11 @@ object NeoPermission {
private fun doRequestPermission(context: AppCompatActivity, requestCode: Int) { private fun doRequestPermission(context: AppCompatActivity, requestCode: Int) {
try { try {
ActivityCompat.requestPermissions(context, ActivityCompat.requestPermissions(
context,
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE),
requestCode) requestCode
)
} catch (ignore: ActivityNotFoundException) { } catch (ignore: ActivityNotFoundException) {
// for MIUI, we ignore it. // for MIUI, we ignore it.
} }

View File

@ -1,8 +1,8 @@
package io.neoterm.frontend.floating package io.neoterm.frontend.floating
import androidx.appcompat.app.AlertDialog
import android.content.Context import android.content.Context
import android.content.DialogInterface import android.content.DialogInterface
import androidx.appcompat.app.AlertDialog
import io.neoterm.R import io.neoterm.R
import io.neoterm.backend.TerminalSession import io.neoterm.backend.TerminalSession
import io.neoterm.frontend.session.shell.ShellParameter import io.neoterm.frontend.session.shell.ShellParameter

View File

@ -1,8 +1,8 @@
package io.neoterm.frontend.logging package io.neoterm.frontend.logging
import android.content.Context import android.content.Context
import androidx.annotation.IntDef
import android.util.Log import android.util.Log
import androidx.annotation.IntDef
import java.io.* import java.io.*
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
@ -21,7 +21,14 @@ object NLog {
const val E = Log.ERROR const val E = Log.ERROR
const val A = Log.ASSERT const val A = Log.ASSERT
@IntDef(V.toLong().toInt(), D.toLong().toInt(), I.toLong().toInt(), W.toLong().toInt(), E.toLong().toInt(), A.toLong().toInt()) @IntDef(
V.toLong().toInt(),
D.toLong().toInt(),
I.toLong().toInt(),
W.toLong().toInt(),
E.toLong().toInt(),
A.toLong().toInt()
)
@Retention(AnnotationRetention.SOURCE) @Retention(AnnotationRetention.SOURCE)
private annotation class TYPE private annotation class TYPE
@ -152,11 +159,13 @@ object NLog {
} }
if (sLogHeadSwitch) { if (sLogHeadSwitch) {
val head = Formatter() val head = Formatter()
.format("[Thread:%s], %s(%s:%d): ", .format(
"[Thread:%s], %s(%s:%d): ",
Thread.currentThread().name, Thread.currentThread().name,
targetElement.methodName, targetElement.methodName,
targetElement.fileName, targetElement.fileName,
targetElement.lineNumber) targetElement.lineNumber
)
.toString() .toString()
return arrayOf(returnTag, head, head) return arrayOf(returnTag, head, head)
} }

View File

@ -11,12 +11,13 @@ import java.io.File
/** /**
* @author kiva * @author kiva
*/ */
open class ShellTermSession private constructor(shellPath: String, cwd: String, open class ShellTermSession private constructor(
shellPath: String, cwd: String,
args: Array<String>, env: Array<String>, args: Array<String>, env: Array<String>,
changeCallback: SessionChangedCallback, changeCallback: SessionChangedCallback,
private val initialCommand: String?, private val initialCommand: String?,
val shellProfile: ShellProfile) val shellProfile: ShellProfile
: TerminalSession(shellPath, cwd, args, env, changeCallback) { ) : TerminalSession(shellPath, cwd, args, env, changeCallback) {
var exitPrompt = App.get().getString(R.string.process_exit_prompt) var exitPrompt = App.get().getString(R.string.process_exit_prompt)
@ -148,8 +149,7 @@ open class ShellTermSession private constructor(shellPath: String, cwd: String,
fun create(context: Context): ShellTermSession { fun create(context: Context): ShellTermSession {
val cwd = this.cwd ?: NeoTermPath.HOME_PATH val cwd = this.cwd ?: NeoTermPath.HOME_PATH
val shell = this.executablePath ?: val shell = this.executablePath ?: if (systemShell)
if (systemShell)
"/system/bin/sh" "/system/bin/sh"
else else
shellProfile.loginShell shellProfile.loginShell
@ -157,8 +157,10 @@ open class ShellTermSession private constructor(shellPath: String, cwd: String,
val args = this.args ?: mutableListOf(shell) val args = this.args ?: mutableListOf(shell)
val env = transformEnvironment(this.env) ?: buildEnvironment(cwd, systemShell) val env = transformEnvironment(this.env) ?: buildEnvironment(cwd, systemShell)
val callback = changeCallback ?: TermSessionCallback() val callback = changeCallback ?: TermSessionCallback()
return ShellTermSession(shell, cwd, args.toTypedArray(), env, callback, return ShellTermSession(
initialCommand ?: "", shellProfile) shell, cwd, args.toTypedArray(), env, callback,
initialCommand ?: "", shellProfile
)
} }
private fun transformEnvironment(env: MutableList<Pair<String, String>>?): Array<String>? { private fun transformEnvironment(env: MutableList<Pair<String, String>>?): Array<String>? {
@ -191,9 +193,11 @@ open class ShellTermSession private constructor(shellPath: String, cwd: String,
return if (systemShell) { return if (systemShell) {
val pathEnv = "PATH=" + System.getenv("PATH") val pathEnv = "PATH=" + System.getenv("PATH")
arrayOf(termEnv, homeEnv, androidRootEnv, androidDataEnv, arrayOf(
termEnv, homeEnv, androidRootEnv, androidDataEnv,
externalStorageEnv, pathEnv, neotermIdEnv, prefixEnv, externalStorageEnv, pathEnv, neotermIdEnv, prefixEnv,
originLdEnv, originPathEnv, colorterm) originLdEnv, originPathEnv, colorterm
)
} else { } else {
val ps1Env = "PS1=$ " val ps1Env = "PS1=$ "
@ -211,10 +215,12 @@ open class ShellTermSession private constructor(shellPath: String, cwd: String,
"" ""
} }
arrayOf(termEnv, homeEnv, ps1Env, ldEnv, langEnv, pathEnv, pwdEnv, arrayOf(
termEnv, homeEnv, ps1Env, ldEnv, langEnv, pathEnv, pwdEnv,
androidRootEnv, androidDataEnv, externalStorageEnv, androidRootEnv, androidDataEnv, externalStorageEnv,
tmpdirEnv, neotermIdEnv, originPathEnv, originLdEnv, tmpdirEnv, neotermIdEnv, originPathEnv, originLdEnv,
ldPreloadEnv, prefixEnv, colorterm) ldPreloadEnv, prefixEnv, colorterm
)
} }
.filter { it.isNotEmpty() } .filter { it.isNotEmpty() }
.toTypedArray() .toTypedArray()

View File

@ -9,7 +9,6 @@ import io.neoterm.frontend.completion.listener.OnCandidateSelectedListener
import io.neoterm.frontend.completion.model.CompletionCandidate import io.neoterm.frontend.completion.model.CompletionCandidate
import io.neoterm.frontend.completion.model.CompletionResult import io.neoterm.frontend.completion.model.CompletionResult
import io.neoterm.frontend.completion.view.CandidatePopupWindow import io.neoterm.frontend.completion.view.CandidatePopupWindow
import io.neoterm.frontend.logging.NLog
import io.neoterm.frontend.terminal.TerminalView import io.neoterm.frontend.terminal.TerminalView
import java.util.* import java.util.*
@ -80,8 +79,10 @@ class TermCompleteListener(var terminalView: TerminalView?) : OnAutoCompleteList
} }
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
Log.e("NeoTerm-AC", "currentEditing: $textNeedCompletion, " + Log.e(
"deleteLength: $deleteLength, completeString: $newText") "NeoTerm-AC", "currentEditing: $textNeedCompletion, " +
"deleteLength: $deleteLength, completeString: $newText"
)
} }
pushString(newText) pushString(newText)

View File

@ -37,7 +37,11 @@ class TermSessionData {
profile = null profile = null
} }
fun initializeSessionWith(session: TerminalSession, sessionCallback: TermSessionCallback?, viewClient: TermViewClient?) { fun initializeSessionWith(
session: TerminalSession,
sessionCallback: TermSessionCallback?,
viewClient: TermViewClient?
) {
this.termSession = session this.termSession = session
this.sessionCallback = sessionCallback this.sessionCallback = sessionCallback
this.viewClient = viewClient this.viewClient = viewClient

View File

@ -167,14 +167,25 @@ class TermViewClient(val context: Context) : TerminalViewClient {
'v' -> { 'v' -> {
resultingCodePoint = -1 resultingCodePoint = -1
val audio = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager val audio = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
audio.adjustSuggestedStreamVolume(AudioManager.ADJUST_SAME, AudioManager.USE_DEFAULT_STREAM_TYPE, AudioManager.FLAG_SHOW_UI) audio.adjustSuggestedStreamVolume(
AudioManager.ADJUST_SAME,
AudioManager.USE_DEFAULT_STREAM_TYPE,
AudioManager.FLAG_SHOW_UI
)
} }
} }
if (resultingKeyCode != -1) { if (resultingKeyCode != -1) {
if (session != null) { if (session != null) {
val term = session.emulator val term = session.emulator
session.write(KeyHandler.getCode(resultingKeyCode, 0, term.isCursorKeysApplicationMode, term.isKeypadApplicationMode)) session.write(
KeyHandler.getCode(
resultingKeyCode,
0,
term.isCursorKeysApplicationMode,
term.isKeypadApplicationMode
)
)
} }
} else if (resultingCodePoint != -1) { } else if (resultingCodePoint != -1) {
session?.writeCodePoint(altDown, resultingCodePoint) session?.writeCodePoint(altDown, resultingCodePoint)
@ -220,7 +231,8 @@ class TermViewClient(val context: Context) : TerminalViewClient {
} }
if ((lastTitle != title || force) if ((lastTitle != title || force)
&& updateExtraKeysVisibility()) { && updateExtraKeysVisibility()
) {
removeExtraKeys() removeExtraKeys()
ComponentManager.getComponent<ExtraKeyComponent>().showShortcutKeys(title, extraKeysView) ComponentManager.getComponent<ExtraKeyComponent>().showShortcutKeys(title, extraKeysView)
extraKeysView.updateButtons() extraKeysView.updateButtons()

View File

@ -1,6 +1,5 @@
package io.neoterm.frontend.session.xorg package io.neoterm.frontend.session.xorg
import androidx.appcompat.app.AppCompatActivity
import android.app.UiModeManager import android.app.UiModeManager
import android.content.Context import android.content.Context
import android.content.pm.ActivityInfo import android.content.pm.ActivityInfo
@ -14,6 +13,7 @@ import android.view.*
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import android.widget.EditText import android.widget.EditText
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatActivity
import io.neoterm.* import io.neoterm.*
import io.neoterm.frontend.session.xorg.client.XSessionData import io.neoterm.frontend.session.xorg.client.XSessionData
import io.neoterm.xorg.NeoXorgViewClient import io.neoterm.xorg.NeoXorgViewClient
@ -24,13 +24,16 @@ import java.util.*
* @author kiva * @author kiva
*/ */
class XSession constructor(private val mActivity: AppCompatActivity, val mSessionData: XSessionData) : NeoXorgViewClient { class XSession constructor(private val mActivity: AppCompatActivity, val mSessionData: XSessionData) :
NeoXorgViewClient {
var mSessionName = ""; var mSessionName = "";
init { init {
if (Globals.InhibitSuspend) { if (Globals.InhibitSuspend) {
window.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, window.setFlags(
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
)
} }
mSessionData.client = this mSessionData.client = this
@ -104,7 +107,10 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
} }
if (key > 100000) { if (key > 100000) {
key -= 100000 key -= 100000
mActivity.onKeyDown(KeyEvent.KEYCODE_SHIFT_LEFT, KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT)) mActivity.onKeyDown(
KeyEvent.KEYCODE_SHIFT_LEFT,
KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT)
)
} }
mActivity.onKeyDown(key, KeyEvent(KeyEvent.ACTION_DOWN, key)) mActivity.onKeyDown(key, KeyEvent(KeyEvent.ACTION_DOWN, key))
} }
@ -119,16 +125,25 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
if (key == Keyboard.KEYCODE_SHIFT) { if (key == Keyboard.KEYCODE_SHIFT) {
builtinKeyboard.shift = !builtinKeyboard.shift builtinKeyboard.shift = !builtinKeyboard.shift
if (builtinKeyboard.shift && !builtinKeyboard.alt) if (builtinKeyboard.shift && !builtinKeyboard.alt)
mActivity.onKeyDown(KeyEvent.KEYCODE_SHIFT_LEFT, KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT)) mActivity.onKeyDown(
KeyEvent.KEYCODE_SHIFT_LEFT,
KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT)
)
else else
mActivity.onKeyUp(KeyEvent.KEYCODE_SHIFT_LEFT, KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT)) mActivity.onKeyUp(
KeyEvent.KEYCODE_SHIFT_LEFT,
KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT)
)
builtinKeyboard.changeKeyboard(keyboard) builtinKeyboard.changeKeyboard(keyboard)
return return
} }
if (key == Keyboard.KEYCODE_ALT) { if (key == Keyboard.KEYCODE_ALT) {
builtinKeyboard.alt = !builtinKeyboard.alt builtinKeyboard.alt = !builtinKeyboard.alt
if (builtinKeyboard.alt) if (builtinKeyboard.alt)
mActivity.onKeyUp(KeyEvent.KEYCODE_SHIFT_LEFT, KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT)) mActivity.onKeyUp(
KeyEvent.KEYCODE_SHIFT_LEFT,
KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT)
)
else else
builtinKeyboard.shift = false builtinKeyboard.shift = false
builtinKeyboard.changeKeyboard(keyboard) builtinKeyboard.changeKeyboard(keyboard)
@ -158,7 +173,10 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
mActivity.onKeyUp(key, KeyEvent(KeyEvent.ACTION_UP, key)) mActivity.onKeyUp(key, KeyEvent(KeyEvent.ACTION_UP, key))
if (shifted) { if (shifted) {
mActivity.onKeyUp(KeyEvent.KEYCODE_SHIFT_LEFT, KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT)) mActivity.onKeyUp(
KeyEvent.KEYCODE_SHIFT_LEFT,
KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT)
)
builtinKeyboard.stickyKeys.remove(KeyEvent.KEYCODE_SHIFT_LEFT) builtinKeyboard.stickyKeys.remove(KeyEvent.KEYCODE_SHIFT_LEFT)
for (k in builtinKeyboard.keyboard.keys) { for (k in builtinKeyboard.keyboard.keys) {
if (k.sticky && k.codes[0] == KeyEvent.KEYCODE_SHIFT_LEFT && k.on) { if (k.sticky && k.codes[0] == KeyEvent.KEYCODE_SHIFT_LEFT && k.on) {
@ -182,7 +200,11 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
override fun onKey(p1: Int, p2: IntArray) {} override fun onKey(p1: Int, p2: IntArray) {}
}) })
mSessionData.screenKeyboard = builtinKeyboard mSessionData.screenKeyboard = builtinKeyboard
val layout = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM) val layout = FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT,
Gravity.BOTTOM
)
mSessionData.videoLayout!!.addView(mSessionData.screenKeyboard, layout) mSessionData.videoLayout!!.addView(mSessionData.screenKeyboard, layout)
} }
}) })
@ -220,10 +242,12 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
if (mSessionData.screenKeyboard != null) if (mSessionData.screenKeyboard != null)
return return
val screenKeyboard = EditText(mActivity, null, val screenKeyboard = EditText(
mActivity, null,
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP)
android.R.style.TextAppearance_Material_Widget_EditText android.R.style.TextAppearance_Material_Widget_EditText
else android.R.style.TextAppearance_Widget_EditText) else android.R.style.TextAppearance_Widget_EditText
)
val hint = mSessionData.screenKeyboardHintMessage val hint = mSessionData.screenKeyboardHintMessage
screenKeyboard.hint = hint ?: mActivity.getString(R.string.text_edit_click_here) screenKeyboard.hint = hint ?: mActivity.getString(R.string.text_edit_click_here)
@ -243,8 +267,26 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
screenKeyboard.isFocusable = true screenKeyboard.isFocusable = true
screenKeyboard.postDelayed({ screenKeyboard.postDelayed({
screenKeyboard.requestFocus() screenKeyboard.requestFocus()
screenKeyboard.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 0f, 0f, 0)) screenKeyboard.dispatchTouchEvent(
screenKeyboard.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, 0f, 0f, 0)) MotionEvent.obtain(
SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(),
MotionEvent.ACTION_DOWN,
0f,
0f,
0
)
)
screenKeyboard.dispatchTouchEvent(
MotionEvent.obtain(
SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(),
MotionEvent.ACTION_UP,
0f,
0f,
0
)
)
screenKeyboard.postDelayed({ screenKeyboard.postDelayed({
screenKeyboard.requestFocus() screenKeyboard.requestFocus()
screenKeyboard.setSelection(screenKeyboard.text.length) screenKeyboard.setSelection(screenKeyboard.text.length)
@ -279,7 +321,8 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
override fun updateScreenOrientation() { override fun updateScreenOrientation() {
var rotation: Int = windowManager.defaultDisplay.rotation var rotation: Int = windowManager.defaultDisplay.rotation
NeoAccelerometerReader.setGyroInvertedOrientation( NeoAccelerometerReader.setGyroInvertedOrientation(
rotation == Surface.ROTATION_180 || rotation == Surface.ROTATION_270) rotation == Surface.ROTATION_180 || rotation == Surface.ROTATION_270
)
} }
override fun initScreenOrientation() { override fun initScreenOrientation() {
@ -306,9 +349,11 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
override fun setSystemMousePointerVisible(visible: Int) { override fun setSystemMousePointerVisible(visible: Int) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
glView?.pointerIcon = android.view.PointerIcon.getSystemIcon(mActivity, glView?.pointerIcon = android.view.PointerIcon.getSystemIcon(
mActivity,
if (visible == 0) android.view.PointerIcon.TYPE_NULL if (visible == 0) android.view.PointerIcon.TYPE_NULL
else android.view.PointerIcon.TYPE_DEFAULT) else android.view.PointerIcon.TYPE_DEFAULT
)
} }
} }
@ -325,7 +370,8 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
keyCode == KeyEvent.KEYCODE_BUTTON_1 || keyCode == KeyEvent.KEYCODE_BUTTON_1 ||
keyCode == KeyEvent.KEYCODE_BUTTON_2 || keyCode == KeyEvent.KEYCODE_BUTTON_2 ||
keyCode == KeyEvent.KEYCODE_BUTTON_3 || keyCode == KeyEvent.KEYCODE_BUTTON_3 ||
keyCode == KeyEvent.KEYCODE_BUTTON_4)) { keyCode == KeyEvent.KEYCODE_BUTTON_4)
) {
client.hideScreenKeyboard() client.hideScreenKeyboard()
return true return true
} }
@ -343,7 +389,8 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
return false return false
if (ev.action == MotionEvent.ACTION_DOWN || ev.action == MotionEvent.ACTION_UP || ev.action == MotionEvent.ACTION_MOVE) { if (ev.action == MotionEvent.ACTION_DOWN || ev.action == MotionEvent.ACTION_UP || ev.action == MotionEvent.ACTION_MOVE) {
// Convert pointer coords, this will lose multitiouch data, however KeyboardView does not support multitouch anyway // Convert pointer coords, this will lose multitiouch data, however KeyboardView does not support multitouch anyway
val converted = MotionEvent.obtain(ev.downTime, ev.eventTime, ev.action, ev.x, ev.y - top.toFloat(), ev.metaState) val converted =
MotionEvent.obtain(ev.downTime, ev.eventTime, ev.action, ev.x, ev.y - top.toFloat(), ev.metaState)
return super.dispatchTouchEvent(converted) return super.dispatchTouchEvent(converted)
} }
return false return false

View File

@ -4,12 +4,7 @@ import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.Typeface; import android.graphics.Typeface;
import io.neoterm.backend.*;
import io.neoterm.backend.TerminalBuffer;
import io.neoterm.backend.TerminalEmulator;
import io.neoterm.backend.TerminalRow;
import io.neoterm.backend.TextStyle;
import io.neoterm.backend.WcWidth;
/** /**
* Renderer of a {@link TerminalEmulator} into a {@link Canvas}. * Renderer of a {@link TerminalEmulator} into a {@link Canvas}.
@ -22,16 +17,26 @@ final class TerminalRenderer {
final Typeface mTypeface; final Typeface mTypeface;
private final Paint mTextPaint = new Paint(); private final Paint mTextPaint = new Paint();
/** The width of a single mono spaced character obtained by {@link Paint#measureText(String)} on a single 'X'. */ /**
* The width of a single mono spaced character obtained by {@link Paint#measureText(String)} on a single 'X'.
*/
final float mFontWidth; final float mFontWidth;
/** The {@link Paint#getFontSpacing()}. See http://www.fampennings.nl/maarten/android/08numgrid/font.png */ /**
* The {@link Paint#getFontSpacing()}. See http://www.fampennings.nl/maarten/android/08numgrid/font.png
*/
final int mFontLineSpacing; final int mFontLineSpacing;
/** The {@link Paint#ascent()}. See http://www.fampennings.nl/maarten/android/08numgrid/font.png */ /**
* The {@link Paint#ascent()}. See http://www.fampennings.nl/maarten/android/08numgrid/font.png
*/
private final int mFontAscent; private final int mFontAscent;
/** The {@link #mFontLineSpacing} + {@link #mFontAscent}. */ /**
* The {@link #mFontLineSpacing} + {@link #mFontAscent}.
*/
final int mFontLineSpacingAndAscent; final int mFontLineSpacingAndAscent;
/** AutoCompletion PopupWindow need them to show popup window */ /**
* AutoCompletion PopupWindow need them to show popup window
*/
protected float savedLastDrawnLineX; protected float savedLastDrawnLineX;
protected float savedLastDrawnLineY; protected float savedLastDrawnLineY;
@ -57,7 +62,9 @@ final class TerminalRenderer {
} }
} }
/** Render the terminal to a canvas with at a specified row scroll, and an optional rectangular selection. */ /**
* Render the terminal to a canvas with at a specified row scroll, and an optional rectangular selection.
*/
public final void render(TerminalEmulator mEmulator, Canvas canvas, int topRow, public final void render(TerminalEmulator mEmulator, Canvas canvas, int topRow,
int selectionY1, int selectionY2, int selectionX1, int selectionX2) { int selectionY1, int selectionY2, int selectionX1, int selectionX2) {
final boolean reverseVideo = mEmulator.isReverseVideo(); final boolean reverseVideo = mEmulator.isReverseVideo();

View File

@ -15,27 +15,14 @@ import android.text.InputType;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
import android.view.ActionMode; import android.view.*;
import android.view.HapticFeedbackConstants;
import android.view.InputDevice;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import android.view.inputmethod.BaseInputConnection; import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputConnection;
import android.widget.Scroller; import android.widget.Scroller;
import io.neoterm.R; import io.neoterm.R;
import io.neoterm.backend.EmulatorDebug; import io.neoterm.backend.*;
import io.neoterm.backend.KeyHandler;
import io.neoterm.backend.TerminalBuffer;
import io.neoterm.backend.TerminalEmulator;
import io.neoterm.backend.TerminalSession;
import io.neoterm.frontend.completion.listener.OnAutoCompleteListener; import io.neoterm.frontend.completion.listener.OnAutoCompleteListener;
/** /**

View File

@ -3,7 +3,6 @@ package io.neoterm.frontend.terminal;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.ScaleGestureDetector; import android.view.ScaleGestureDetector;
import io.neoterm.backend.TerminalSession; import io.neoterm.backend.TerminalSession;
/** /**

View File

@ -166,8 +166,10 @@ class ExtraKeysView(context: Context, attrs: AttributeSet) : LinearLayout(contex
if (NeoPreference.isExplicitExtraKeysWeightEnabled()) if (NeoPreference.isExplicitExtraKeysWeightEnabled())
LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f) LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f)
else else
LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT) ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
layoutParams.setMargins(0, 0, 0, 0) layoutParams.setMargins(0, 0, 0, 0)
line.setPadding(0, 0, 0, 0) line.setPadding(0, 0, 0, 0)

View File

@ -3,10 +3,10 @@ package io.neoterm.frontend.terminal.extrakey.button
import android.content.Context import android.content.Context
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import androidx.appcompat.widget.AppCompatButton
import android.util.AttributeSet import android.util.AttributeSet
import android.view.MotionEvent import android.view.MotionEvent
import android.widget.Button import android.widget.Button
import androidx.appcompat.widget.AppCompatButton
/** /**
@ -18,8 +18,8 @@ open class RepeatableButton(buttonText: String) : ControlButton(buttonText) {
return RepeatableButtonWidget(context, attrs, defStyleAttr) return RepeatableButtonWidget(context, attrs, defStyleAttr)
} }
private class RepeatableButtonWidget(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) private class RepeatableButtonWidget(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) :
: AppCompatButton(context!!, attrs, defStyleAttr) { AppCompatButton(context!!, attrs, defStyleAttr) {
/** /**
* Milliseconds how long we trigger an action * Milliseconds how long we trigger an action

View File

@ -10,7 +10,8 @@ import android.widget.ToggleButton
* @author kiva * @author kiva
*/ */
open class StatedControlButton @JvmOverloads constructor(text: String, var initState: Boolean = false) : ControlButton(text) { open class StatedControlButton @JvmOverloads constructor(text: String, var initState: Boolean = false) :
ControlButton(text) {
var toggleButton: ToggleButton? = null var toggleButton: ToggleButton? = null
override fun onClick(view: View) { override fun onClick(view: View) {

View File

@ -9,8 +9,8 @@ import android.os.Binder
import android.os.Build import android.os.Build
import android.os.IBinder import android.os.IBinder
import android.os.PowerManager import android.os.PowerManager
import androidx.core.app.NotificationCompat
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.NotificationCompat
import io.neoterm.R import io.neoterm.R
import io.neoterm.backend.EmulatorDebug import io.neoterm.backend.EmulatorDebug
import io.neoterm.backend.TerminalSession import io.neoterm.backend.TerminalSession
@ -156,7 +156,11 @@ class NeoTermService : Service() {
builder.priority = if (lockAcquired) Notification.PRIORITY_HIGH else Notification.PRIORITY_LOW builder.priority = if (lockAcquired) Notification.PRIORITY_HIGH else Notification.PRIORITY_LOW
val exitIntent = Intent(this, NeoTermService::class.java).setAction(ACTION_SERVICE_STOP) val exitIntent = Intent(this, NeoTermService::class.java).setAction(ACTION_SERVICE_STOP)
builder.addAction(android.R.drawable.ic_delete, getString(R.string.exit), PendingIntent.getService(this, 0, exitIntent, 0)) builder.addAction(
android.R.drawable.ic_delete,
getString(R.string.exit),
PendingIntent.getService(this, 0, exitIntent, 0)
)
val newWakeAction = if (lockAcquired) ACTION_RELEASE_LOCK else ACTION_ACQUIRE_LOCK val newWakeAction = if (lockAcquired) ACTION_RELEASE_LOCK else ACTION_ACQUIRE_LOCK
val toggleWakeLockIntent = Intent(this, NeoTermService::class.java).setAction(newWakeAction) val toggleWakeLockIntent = Intent(this, NeoTermService::class.java).setAction(newWakeAction)
@ -164,7 +168,8 @@ class NeoTermService : Service() {
if (lockAcquired) if (lockAcquired)
R.string.service_release_lock R.string.service_release_lock
else else
R.string.service_acquire_lock) R.string.service_acquire_lock
)
val actionIcon = if (lockAcquired) android.R.drawable.ic_lock_idle_lock else android.R.drawable.ic_lock_lock val actionIcon = if (lockAcquired) android.R.drawable.ic_lock_idle_lock else android.R.drawable.ic_lock_lock
builder.addAction(actionIcon, actionTitle, PendingIntent.getService(this, 0, toggleWakeLockIntent, 0)) builder.addAction(actionIcon, actionTitle, PendingIntent.getService(this, 0, toggleWakeLockIntent, 0))
@ -184,8 +189,10 @@ class NeoTermService : Service() {
private fun acquireLock() { private fun acquireLock() {
if (mWakeLock == null) { if (mWakeLock == null) {
val pm = getSystemService(Context.POWER_SERVICE) as PowerManager val pm = getSystemService(Context.POWER_SERVICE) as PowerManager
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, mWakeLock = pm.newWakeLock(
EmulatorDebug.LOG_TAG + ":") PowerManager.PARTIAL_WAKE_LOCK,
EmulatorDebug.LOG_TAG + ":"
)
mWakeLock!!.acquire() mWakeLock!!.acquire()
val wm = applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager val wm = applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager

View File

@ -1,10 +1,10 @@
package io.neoterm.setup package io.neoterm.setup
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AlertDialog
import android.app.ProgressDialog import android.app.ProgressDialog
import android.content.Context import android.content.Context
import android.os.Build import android.os.Build
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import io.neoterm.App import io.neoterm.App
import io.neoterm.R import io.neoterm.R
import io.neoterm.frontend.config.NeoTermPath import io.neoterm.frontend.config.NeoTermPath
@ -20,8 +20,10 @@ object SetupHelper {
return !PREFIX_FILE.isDirectory return !PREFIX_FILE.isDirectory
} }
fun setup(activity: AppCompatActivity, connection: SourceConnection, fun setup(
resultListener: ResultListener) { activity: AppCompatActivity, connection: SourceConnection,
resultListener: ResultListener
) {
if (!needSetup()) { if (!needSetup()) {
resultListener.onResult(null) resultListener.onResult(null)
return return
@ -71,7 +73,9 @@ object SetupHelper {
"x86_64" -> return "x86_64" "x86_64" -> return "x86_64"
} }
} }
throw RuntimeException("Unable to determine arch from Build.SUPPORTED_ABIS = " throw RuntimeException(
+ Arrays.toString(Build.SUPPORTED_ABIS)) "Unable to determine arch from Build.SUPPORTED_ABIS = "
+ Arrays.toString(Build.SUPPORTED_ABIS)
)
} }
} }

View File

@ -1,24 +1,19 @@
package io.neoterm.setup; package io.neoterm.setup;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.system.Os; import android.system.Os;
import android.util.Pair; import android.util.Pair;
import androidx.appcompat.app.AppCompatActivity;
import io.neoterm.backend.EmulatorDebug;
import io.neoterm.frontend.config.NeoTermPath;
import io.neoterm.frontend.logging.NLog;
import java.io.BufferedReader; import java.io.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import io.neoterm.backend.EmulatorDebug;
import io.neoterm.frontend.config.NeoTermPath;
import io.neoterm.frontend.logging.NLog;
/** /**
* @author kiva * @author kiva
*/ */

View File

@ -12,11 +12,11 @@ import android.graphics.drawable.RippleDrawable
import android.graphics.drawable.ShapeDrawable import android.graphics.drawable.ShapeDrawable
import android.graphics.drawable.shapes.OvalShape import android.graphics.drawable.shapes.OvalShape
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import android.view.* import android.view.*
import android.view.animation.PathInterpolator import android.view.animation.PathInterpolator
import android.widget.FrameLayout import android.widget.FrameLayout
import android.widget.ImageView import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import io.neoterm.R import io.neoterm.R
/** /**
@ -36,14 +36,17 @@ class BonusActivity : AppCompatActivity() {
lollipopBackground.paint.color = FLAVORS[idx] lollipopBackground.paint.color = FLAVORS[idx]
return RippleDrawable( return RippleDrawable(
ColorStateList.valueOf(FLAVORS[idx + 1]), ColorStateList.valueOf(FLAVORS[idx + 1]),
lollipopBackground, null) lollipopBackground, null
)
} }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
mLayout = FrameLayout(this) mLayout = FrameLayout(this)
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, window.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN) WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
setContentView(mLayout) setContentView(mLayout)
} }
@ -85,8 +88,12 @@ class BonusActivity : AppCompatActivity() {
c.drawPath(mShadow, mPaint) c.drawPath(mShadow, mPaint)
} }
} }
mLayout.addView(stick, FrameLayout.LayoutParams((32 * dp).toInt(), mLayout.addView(
ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER_HORIZONTAL)) stick, FrameLayout.LayoutParams(
(32 * dp).toInt(),
ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER_HORIZONTAL
)
)
stick.alpha = 0f stick.alpha = 0f
val im = ImageView(this) val im = ImageView(this)
@ -100,8 +107,10 @@ class BonusActivity : AppCompatActivity() {
im.isClickable = true im.isClickable = true
val highlight = ShapeDrawable(OvalShape()) val highlight = ShapeDrawable(OvalShape())
highlight.paint.color = 0x10FFFFFF highlight.paint.color = 0x10FFFFFF
highlight.setBounds((size * .15f).toInt(), (size * .15f).toInt(), highlight.setBounds(
(size * .6f).toInt(), (size * .6f).toInt()) (size * .15f).toInt(), (size * .15f).toInt(),
(size * .6f).toInt(), (size * .6f).toInt()
)
im.overlay.add(highlight) im.overlay.add(highlight)
im.setOnClickListener { im.setOnClickListener {
if (mTapCount == 0) { if (mTapCount == 0) {
@ -161,11 +170,13 @@ class BonusActivity : AppCompatActivity() {
} }
companion object { companion object {
internal val FLAVORS = intArrayOf(0xFF9C27B0.toInt(), 0xFFBA68C8.toInt(), // grape internal val FLAVORS = intArrayOf(
0xFF9C27B0.toInt(), 0xFFBA68C8.toInt(), // grape
0xFFFF9800.toInt(), 0xFFFFB74D.toInt(), // orange 0xFFFF9800.toInt(), 0xFFFFB74D.toInt(), // orange
0xFFF06292.toInt(), 0xFFF8BBD0.toInt(), // bubblegum 0xFFF06292.toInt(), 0xFFF8BBD0.toInt(), // bubblegum
0xFFAFB42B.toInt(), 0xFFCDDC39.toInt(), // lime 0xFFAFB42B.toInt(), 0xFFCDDC39.toInt(), // lime
0xFF795548.toInt(), 0xFFA1887F.toInt())// mystery flavor 0xFF795548.toInt(), 0xFFA1887F.toInt()
)// mystery flavor
internal fun newColorIndex(): Int { internal fun newColorIndex(): Int {
return 2 * (Math.random() * FLAVORS.size / 2).toInt() return 2 * (Math.random() * FLAVORS.size / 2).toInt()

View File

@ -2,8 +2,8 @@ package io.neoterm.ui.crash
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import io.neoterm.R import io.neoterm.R
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.PrintStream import java.io.PrintStream

View File

@ -1,9 +1,9 @@
package io.neoterm.ui.customize package io.neoterm.ui.customize
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import android.view.MenuItem
import io.neoterm.R import io.neoterm.R
import io.neoterm.backend.TerminalSession import io.neoterm.backend.TerminalSession
import io.neoterm.frontend.config.NeoTermPath import io.neoterm.frontend.config.NeoTermPath

View File

@ -1,9 +1,6 @@
package io.neoterm.ui.customize package io.neoterm.ui.customize
import androidx.appcompat.app.AlertDialog
import android.os.Bundle import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import android.text.Editable import android.text.Editable
import android.text.TextWatcher import android.text.TextWatcher
import android.view.KeyEvent import android.view.KeyEvent
@ -13,6 +10,8 @@ import android.view.MenuItem
import android.widget.EditText import android.widget.EditText
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.recyclerview.widget.LinearLayoutManager
import com.github.wrdlbrnft.sortedlistadapter.SortedListAdapter import com.github.wrdlbrnft.sortedlistadapter.SortedListAdapter
import es.dmoral.coloromatic.ColorOMaticDialog import es.dmoral.coloromatic.ColorOMaticDialog
import es.dmoral.coloromatic.IndicatorMode import es.dmoral.coloromatic.IndicatorMode

View File

@ -9,13 +9,16 @@ import io.neoterm.R
import io.neoterm.component.colorscheme.NeoColorScheme import io.neoterm.component.colorscheme.NeoColorScheme
import io.neoterm.ui.customize.adapter.holder.ColorItemViewHolder import io.neoterm.ui.customize.adapter.holder.ColorItemViewHolder
import io.neoterm.ui.customize.model.ColorItem import io.neoterm.ui.customize.model.ColorItem
import java.util.*
/** /**
* @author kiva * @author kiva
*/ */
class ColorItemAdapter(context: Context, initColorScheme: NeoColorScheme, comparator: Comparator<ColorItem>, private val listener: ColorItemAdapter.Listener) class ColorItemAdapter(
: SortedListAdapter<ColorItem>(context, ColorItem::class.java, comparator), FastScrollRecyclerView.SectionedAdapter { 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>() val colorList = mutableListOf<ColorItem>()
@ -35,7 +38,11 @@ class ColorItemAdapter(context: Context, initColorScheme: NeoColorScheme, compar
return colorList[position].colorName[0].toString() return colorList[position].colorName[0].toString()
} }
override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup, viewType: Int): SortedListAdapter.ViewHolder<out ColorItem> { override fun onCreateViewHolder(
inflater: LayoutInflater,
parent: ViewGroup,
viewType: Int
): SortedListAdapter.ViewHolder<out ColorItem> {
val rootView = inflater.inflate(R.layout.item_color, parent, false) val rootView = inflater.inflate(R.layout.item_color, parent, false)
return ColorItemViewHolder(rootView, listener) return ColorItemViewHolder(rootView, listener)
} }

View File

@ -8,7 +8,8 @@ import io.neoterm.backend.TerminalColors
import io.neoterm.ui.customize.adapter.ColorItemAdapter import io.neoterm.ui.customize.adapter.ColorItemAdapter
import io.neoterm.ui.customize.model.ColorItem import io.neoterm.ui.customize.model.ColorItem
class ColorItemViewHolder(private val rootView: View, private val listener: ColorItemAdapter.Listener) : SortedListAdapter.ViewHolder<ColorItem>(rootView) { 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 colorItemName: TextView = rootView.findViewById<TextView>(R.id.color_item_name)
private val colorItemDesc: TextView = rootView.findViewById<TextView>(R.id.color_item_description) private val colorItemDesc: TextView = rootView.findViewById<TextView>(R.id.color_item_description)
private val colorView: View = rootView.findViewById<View>(R.id.color_item_view) private val colorView: View = rootView.findViewById<View>(R.id.color_item_view)

View File

@ -2,19 +2,18 @@ package io.neoterm.ui.pm
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
import androidx.core.view.MenuItemCompat
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.appcompat.widget.SearchView
import androidx.appcompat.widget.Toolbar
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.widget.EditText import android.widget.EditText
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.SearchView
import androidx.appcompat.widget.Toolbar
import androidx.core.view.MenuItemCompat
import androidx.recyclerview.widget.LinearLayoutManager
import com.github.wrdlbrnft.sortedlistadapter.SortedListAdapter import com.github.wrdlbrnft.sortedlistadapter.SortedListAdapter
import io.neoterm.R import io.neoterm.R
import io.neoterm.backend.TerminalSession import io.neoterm.backend.TerminalSession
@ -77,8 +76,10 @@ class PackageManagerActivity : AppCompatActivity(), SearchView.OnQueryTextListen
private fun installPackage(packageName: String?) { private fun installPackage(packageName: String?) {
if (packageName != null) { if (packageName != null) {
TerminalDialog(this@PackageManagerActivity) TerminalDialog(this@PackageManagerActivity)
.execute(NeoTermPath.APT_BIN_PATH, .execute(
arrayOf("apt", "install", "-y", packageName)) NeoTermPath.APT_BIN_PATH,
arrayOf("apt", "install", "-y", packageName)
)
.onFinish(object : TerminalDialog.SessionFinishedCallback { .onFinish(object : TerminalDialog.SessionFinishedCallback {
override fun onSessionFinished(dialog: TerminalDialog, finishedSession: TerminalSession?) { override fun onSessionFinished(dialog: TerminalDialog, finishedSession: TerminalSession?) {
dialog.setTitle(getString(R.string.done)) dialog.setTitle(getString(R.string.done))
@ -230,8 +231,10 @@ class PackageManagerActivity : AppCompatActivity(), SearchView.OnQueryTextListen
}.start() }.start()
} }
private fun sortDistance(models: List<PackageModel>, query: String, private fun sortDistance(
mapper: (NeoPackageInfo) -> String): List<Pair<PackageModel, Int>> { models: List<PackageModel>, query: String,
mapper: (NeoPackageInfo) -> String
): List<Pair<PackageModel, Int>> {
return models return models
.map({ .map({
Pair(it, StringDistance.distance(mapper(it.packageInfo).toLowerCase(), query.toLowerCase())) Pair(it, StringDistance.distance(mapper(it.packageInfo).toLowerCase(), query.toLowerCase()))

View File

@ -8,9 +8,13 @@ import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
import io.neoterm.R import io.neoterm.R
import io.neoterm.ui.pm.adapter.holder.PackageViewHolder import io.neoterm.ui.pm.adapter.holder.PackageViewHolder
import io.neoterm.ui.pm.model.PackageModel import io.neoterm.ui.pm.model.PackageModel
import java.util.*
class PackageAdapter(context: Context, comparator: Comparator<PackageModel>, private val listener: PackageAdapter.Listener) : 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 { override fun getSectionName(position: Int): String {
return getItem(position).packageInfo.packageName?.substring(0, 1) ?: "#" return getItem(position).packageInfo.packageName?.substring(0, 1) ?: "#"
@ -20,7 +24,11 @@ class PackageAdapter(context: Context, comparator: Comparator<PackageModel>, pri
fun onModelClicked(model: PackageModel) fun onModelClicked(model: PackageModel)
} }
override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup, viewType: Int): SortedListAdapter.ViewHolder<out PackageModel> { override fun onCreateViewHolder(
inflater: LayoutInflater,
parent: ViewGroup,
viewType: Int
): SortedListAdapter.ViewHolder<out PackageModel> {
val rootView = inflater.inflate(R.layout.item_package, parent, false) val rootView = inflater.inflate(R.layout.item_package, parent, false)
return PackageViewHolder(rootView, listener) return PackageViewHolder(rootView, listener)
} }

View File

@ -9,7 +9,8 @@ import io.neoterm.R
import io.neoterm.ui.pm.adapter.PackageAdapter import io.neoterm.ui.pm.adapter.PackageAdapter
import io.neoterm.ui.pm.model.PackageModel import io.neoterm.ui.pm.model.PackageModel
class PackageViewHolder(private val rootView: View, private val listener: PackageAdapter.Listener) : SortedListAdapter.ViewHolder<PackageModel>(rootView) { class PackageViewHolder(private val rootView: View, private val listener: PackageAdapter.Listener) :
SortedListAdapter.ViewHolder<PackageModel>(rootView) {
private val packageNameView: TextView = rootView.findViewById(R.id.package_item_name) private val packageNameView: TextView = rootView.findViewById(R.id.package_item_name)
private val packageDescView: TextView = rootView.findViewById(R.id.package_item_desc) private val packageDescView: TextView = rootView.findViewById(R.id.package_item_desc)

View File

@ -24,10 +24,12 @@ class PackageModel(val packageInfo: NeoPackageInfo) : SortedListAdapter.ViewMode
} }
fun getPackageDetails(context: Context): String { fun getPackageDetails(context: Context): String {
return context.getString(R.string.package_details, return context.getString(
R.string.package_details,
packageInfo.packageName, packageInfo.version, packageInfo.packageName, packageInfo.version,
packageInfo.dependenciesString, packageInfo.dependenciesString,
FileUtils.formatSizeInKB(packageInfo.installedSizeInBytes), FileUtils.formatSizeInKB(packageInfo.installedSizeInBytes),
packageInfo.description, packageInfo.homePage) packageInfo.description, packageInfo.homePage
)
} }
} }

View File

@ -22,19 +22,18 @@ import android.content.res.ColorStateList;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import androidx.core.view.ViewCompat;
import androidx.viewpager.widget.ViewPager;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import io.neoterm.R; import io.neoterm.R;
public class RecyclerTabLayout extends RecyclerView { public class RecyclerTabLayout extends RecyclerView {

View File

@ -18,12 +18,12 @@ package io.neoterm.ui.settings
import android.content.res.Configuration import android.content.res.Configuration
import android.os.Bundle import android.os.Bundle
import android.preference.PreferenceActivity import android.preference.PreferenceActivity
import androidx.annotation.LayoutRes
import androidx.appcompat.app.ActionBar
import androidx.appcompat.app.AppCompatDelegate
import android.view.MenuInflater import android.view.MenuInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.appcompat.app.ActionBar
import androidx.appcompat.app.AppCompatDelegate
/** /**
* A [android.preference.PreferenceActivity] which implements and proxies the necessary calls * A [android.preference.PreferenceActivity] which implements and proxies the necessary calls

View File

@ -1,8 +1,8 @@
package io.neoterm.ui.settings package io.neoterm.ui.settings
import androidx.appcompat.app.AlertDialog
import android.os.Bundle import android.os.Bundle
import android.view.MenuItem import android.view.MenuItem
import androidx.appcompat.app.AlertDialog
import io.neoterm.R import io.neoterm.R
import io.neoterm.frontend.config.NeoPreference import io.neoterm.frontend.config.NeoPreference
import io.neoterm.utils.PackageUtils import io.neoterm.utils.PackageUtils

View File

@ -4,11 +4,11 @@ import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import de.psdev.licensesdialog.LicensesDialog import de.psdev.licensesdialog.LicensesDialog
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20 import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20
import de.psdev.licensesdialog.licenses.GnuGeneralPublicLicense30 import de.psdev.licensesdialog.licenses.GnuGeneralPublicLicense30
@ -46,16 +46,86 @@ class AboutActivity : AppCompatActivity() {
findViewById<View>(R.id.about_licenses_view).setOnClickListener { findViewById<View>(R.id.about_licenses_view).setOnClickListener {
val notices = Notices() val notices = Notices()
notices.addNotice(Notice("ADBToolkitInstaller", "https://github.com/Crixec/ADBToolKitsInstaller", "Copyright (c) 2017 Crixec", GnuGeneralPublicLicense30())) notices.addNotice(
notices.addNotice(Notice("Android-Terminal-Emulator", "https://github.com/jackpal/Android-Terminal-Emulator", "Copyright (c) 2011-2016 Steven Luo", ApacheSoftwareLicense20())) Notice(
notices.addNotice(Notice("ChromeLikeTabSwitcher", "https://github.com/michael-rapp/ChromeLikeTabSwitcher", "Copyright (c) 2016-2017 Michael Rapp", ApacheSoftwareLicense20())) "ADBToolkitInstaller",
notices.addNotice(Notice("Color-O-Matic", "https://github.com/GrenderG/Color-O-Matic", "Copyright 2016-2017 GrenderG", GnuGeneralPublicLicense30())) "https://github.com/Crixec/ADBToolKitsInstaller",
notices.addNotice(Notice("EventBus", "http://greenrobot.org", "Copyright (C) 2012-2016 Markus Junginger, greenrobot (http://greenrobot.org)", ApacheSoftwareLicense20())) "Copyright (c) 2017 Crixec",
notices.addNotice(Notice("ModularAdapter", "https://wrdlbrnft.github.io/ModularAdapter", "Copyright (c) 2017 Wrdlbrnft", MITLicense())) GnuGeneralPublicLicense30()
notices.addNotice(Notice("RecyclerTabLayout", "https://github.com/nshmura/RecyclerTabLayout", "Copyright (C) 2017 nshmura", ApacheSoftwareLicense20())) )
notices.addNotice(Notice("RecyclerView-FastScroll", "Copyright (c) 2016, Tim Malseed", "Copyright (c) 2016, Tim Malseed", ApacheSoftwareLicense20())) )
notices.addNotice(Notice("SortedListAdapter", "https://wrdlbrnft.github.io/SortedListAdapter/", "Copyright (c) 2017 Wrdlbrnft", MITLicense())) notices.addNotice(
notices.addNotice(Notice("Termux", "https://termux.com", "Copyright 2016-2017 Fredrik Fornwall", GnuGeneralPublicLicense30())) Notice(
"Android-Terminal-Emulator",
"https://github.com/jackpal/Android-Terminal-Emulator",
"Copyright (c) 2011-2016 Steven Luo",
ApacheSoftwareLicense20()
)
)
notices.addNotice(
Notice(
"ChromeLikeTabSwitcher",
"https://github.com/michael-rapp/ChromeLikeTabSwitcher",
"Copyright (c) 2016-2017 Michael Rapp",
ApacheSoftwareLicense20()
)
)
notices.addNotice(
Notice(
"Color-O-Matic",
"https://github.com/GrenderG/Color-O-Matic",
"Copyright 2016-2017 GrenderG",
GnuGeneralPublicLicense30()
)
)
notices.addNotice(
Notice(
"EventBus",
"http://greenrobot.org",
"Copyright (C) 2012-2016 Markus Junginger, greenrobot (http://greenrobot.org)",
ApacheSoftwareLicense20()
)
)
notices.addNotice(
Notice(
"ModularAdapter",
"https://wrdlbrnft.github.io/ModularAdapter",
"Copyright (c) 2017 Wrdlbrnft",
MITLicense()
)
)
notices.addNotice(
Notice(
"RecyclerTabLayout",
"https://github.com/nshmura/RecyclerTabLayout",
"Copyright (C) 2017 nshmura",
ApacheSoftwareLicense20()
)
)
notices.addNotice(
Notice(
"RecyclerView-FastScroll",
"Copyright (c) 2016, Tim Malseed",
"Copyright (c) 2016, Tim Malseed",
ApacheSoftwareLicense20()
)
)
notices.addNotice(
Notice(
"SortedListAdapter",
"https://wrdlbrnft.github.io/SortedListAdapter/",
"Copyright (c) 2017 Wrdlbrnft",
MITLicense()
)
)
notices.addNotice(
Notice(
"Termux",
"https://termux.com",
"Copyright 2016-2017 Fredrik Fornwall",
GnuGeneralPublicLicense30()
)
)
LicensesDialog.Builder(this) LicensesDialog.Builder(this)
.setNotices(notices) .setNotices(notices)
.setIncludeOwnLicense(true) .setIncludeOwnLicense(true)

View File

@ -1,8 +1,8 @@
package io.neoterm.ui.support package io.neoterm.ui.support
import androidx.appcompat.app.AppCompatActivity
import android.content.ActivityNotFoundException import android.content.ActivityNotFoundException
import android.content.Intent import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import java.net.URISyntaxException import java.net.URISyntaxException
object Donation { object Donation {

View File

@ -1,8 +1,8 @@
package io.neoterm.ui.support package io.neoterm.ui.support
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import android.view.MenuItem import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import io.neoterm.R import io.neoterm.R
/** /**

View File

@ -1,8 +1,6 @@
package io.neoterm.ui.term package io.neoterm.ui.term
import android.Manifest import android.Manifest
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AlertDialog
import android.content.* import android.content.*
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.content.res.Configuration import android.content.res.Configuration
@ -10,14 +8,16 @@ import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.IBinder import android.os.IBinder
import android.preference.PreferenceManager import android.preference.PreferenceManager
import android.view.*
import android.view.inputmethod.InputMethodManager
import android.widget.ImageButton
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.view.OnApplyWindowInsetsListener import androidx.core.view.OnApplyWindowInsetsListener
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.appcompat.widget.Toolbar
import android.view.*
import android.view.inputmethod.InputMethodManager
import android.widget.ImageButton
import de.mrapp.android.tabswitcher.* import de.mrapp.android.tabswitcher.*
import io.neoterm.App import io.neoterm.App
import io.neoterm.BuildConfig import io.neoterm.BuildConfig
@ -25,10 +25,8 @@ import io.neoterm.R
import io.neoterm.backend.TerminalSession import io.neoterm.backend.TerminalSession
import io.neoterm.component.profile.ProfileComponent import io.neoterm.component.profile.ProfileComponent
import io.neoterm.frontend.component.ComponentManager import io.neoterm.frontend.component.ComponentManager
import io.neoterm.frontend.config.DefaultValues
import io.neoterm.frontend.config.NeoPermission import io.neoterm.frontend.config.NeoPermission
import io.neoterm.frontend.config.NeoPreference import io.neoterm.frontend.config.NeoPreference
import io.neoterm.frontend.config.NeoTermPath
import io.neoterm.frontend.session.shell.ShellParameter import io.neoterm.frontend.session.shell.ShellParameter
import io.neoterm.frontend.session.shell.ShellProfile import io.neoterm.frontend.session.shell.ShellProfile
import io.neoterm.frontend.session.shell.client.TermSessionCallback import io.neoterm.frontend.session.shell.client.TermSessionCallback
@ -72,8 +70,10 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
val fullscreen = NeoPreference.isFullScreenEnabled() val fullscreen = NeoPreference.isFullScreenEnabled()
if (fullscreen) { if (fullscreen) {
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, window.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN) WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
} }
val SDCARD_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1 val SDCARD_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1
@ -121,7 +121,8 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
} }
if (NeoPreference.isFullScreenEnabled() if (NeoPreference.isFullScreenEnabled()
|| NeoPreference.isHideToolbarEnabled()) { || NeoPreference.isHideToolbarEnabled()
) {
val toolbarHeight = toolbar.height.toFloat() val toolbarHeight = toolbar.height.toFloat()
val translationY = if (visible) 0.toFloat() else -toolbarHeight val translationY = if (visible) 0.toFloat() else -toolbarHeight
if (visible) { if (visible) {
@ -302,7 +303,8 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
when (requestCode) { when (requestCode) {
NeoPermission.REQUEST_APP_PERMISSION -> { NeoPermission.REQUEST_APP_PERMISSION -> {
if (grantResults.isEmpty() if (grantResults.isEmpty()
|| grantResults[0] != PackageManager.PERMISSION_GRANTED) { || grantResults[0] != PackageManager.PERMISSION_GRANTED
) {
AlertDialog.Builder(this).setMessage(R.string.permission_denied) AlertDialog.Builder(this).setMessage(R.string.permission_denied)
.setPositiveButton(android.R.string.ok, { _: DialogInterface, _: Int -> .setPositiveButton(android.R.string.ok, { _: DialogInterface, _: Int ->
finish() finish()
@ -406,8 +408,10 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
if (intent?.action == Intent.ACTION_RUN) { if (intent?.action == Intent.ACTION_RUN) {
// app shortcuts // app shortcuts
addNewSession(null, addNewSession(
false, createRevealAnimation()) null,
false, createRevealAnimation()
)
} else { } else {
switchToSession(lastSession) switchToSession(lastSession)
} }
@ -478,19 +482,23 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
private fun addNewSession() = addNewSessionWithProfile(ShellProfile.create()) private fun addNewSession() = addNewSessionWithProfile(ShellProfile.create())
private fun addNewSession(sessionName: String?, systemShell: Boolean, animation: Animation) private fun addNewSession(sessionName: String?, systemShell: Boolean, animation: Animation) =
= addNewSessionWithProfile(sessionName, systemShell, animation, ShellProfile.create()) addNewSessionWithProfile(sessionName, systemShell, animation, ShellProfile.create())
private fun addNewSessionWithProfile(profile: ShellProfile) { private fun addNewSessionWithProfile(profile: ShellProfile) {
if (!tabSwitcher.isSwitcherShown) { if (!tabSwitcher.isSwitcherShown) {
toggleSwitcher(showSwitcher = true, easterEgg = false) toggleSwitcher(showSwitcher = true, easterEgg = false)
} }
addNewSessionWithProfile(null, getSystemShellMode(), addNewSessionWithProfile(
createRevealAnimation(), profile) null, getSystemShellMode(),
createRevealAnimation(), profile
)
} }
private fun addNewSessionWithProfile(sessionName: String?, systemShell: Boolean, private fun addNewSessionWithProfile(
animation: Animation, profile: ShellProfile) { sessionName: String?, systemShell: Boolean,
animation: Animation, profile: ShellProfile
) {
val sessionCallback = TermSessionCallback() val sessionCallback = TermSessionCallback()
val viewClient = TermViewClient(this) val viewClient = TermViewClient(this)
@ -674,9 +682,11 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
private fun createWindowInsetsListener(): OnApplyWindowInsetsListener { private fun createWindowInsetsListener(): OnApplyWindowInsetsListener {
return OnApplyWindowInsetsListener { _, insets -> return OnApplyWindowInsetsListener { _, insets ->
tabSwitcher.setPadding(insets.systemWindowInsetLeft, tabSwitcher.setPadding(
insets.systemWindowInsetLeft,
insets.systemWindowInsetTop, insets.systemWindowInsetRight, insets.systemWindowInsetTop, insets.systemWindowInsetRight,
insets.systemWindowInsetBottom) insets.systemWindowInsetBottom
)
insets insets
} }
} }

View File

@ -1,15 +1,15 @@
package io.neoterm.ui.term package io.neoterm.ui.term
import androidx.appcompat.app.AppCompatActivity
import android.content.ComponentName import android.content.ComponentName
import android.content.Intent import android.content.Intent
import android.content.ServiceConnection import android.content.ServiceConnection
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import androidx.appcompat.app.AlertDialog
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import android.widget.ListView import android.widget.ListView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import io.neoterm.App import io.neoterm.App
import io.neoterm.R import io.neoterm.R
import io.neoterm.bridge.Bridge.* import io.neoterm.bridge.Bridge.*
@ -108,8 +108,10 @@ class NeoTermRemoteInterface : AppCompatActivity(), ServiceConnection {
} }
finish() finish()
} else { } else {
App.get().errorDialog(this, App.get().errorDialog(
getString(R.string.unsupported_term_here, intent?.toString())) { this,
getString(R.string.unsupported_term_here, intent?.toString())
) {
finish() finish()
} }
} }
@ -148,7 +150,8 @@ class NeoTermRemoteInterface : AppCompatActivity(), ServiceConnection {
if (filesToHandle.isNotEmpty()) { if (filesToHandle.isNotEmpty()) {
setupUserScriptView(filesToHandle, userScripts) setupUserScriptView(filesToHandle, userScripts)
} else { } else {
App.get().errorDialog(this, App.get().errorDialog(
this,
getString(R.string.no_files_selected, intent?.toString()) getString(R.string.no_files_selected, intent?.toString())
) { finish() } ) { finish() }
} }
@ -193,8 +196,10 @@ class NeoTermRemoteInterface : AppCompatActivity(), ServiceConnection {
return arguments.toTypedArray() return arguments.toTypedArray()
} }
private fun openTerm(parameter: ShellParameter, private fun openTerm(
foreground: Boolean = true) { parameter: ShellParameter,
foreground: Boolean = true
) {
val session = termService!!.createTermSession(parameter) val session = termService!!.createTermSession(parameter)
val data = Intent() val data = Intent()
@ -213,9 +218,11 @@ class NeoTermRemoteInterface : AppCompatActivity(), ServiceConnection {
} }
} }
private fun openTerm(initialCommand: String?, private fun openTerm(
initialCommand: String?,
sessionId: SessionId? = null, sessionId: SessionId? = null,
foreground: Boolean = true) { foreground: Boolean = true
) {
val parameter = ShellParameter() val parameter = ShellParameter()
.initialCommand(initialCommand) .initialCommand(initialCommand)
.callback(TermSessionCallback()) .callback(TermSessionCallback())

View File

@ -47,8 +47,10 @@ class NeoTabDecorator(val context: NeoTermActivity) : TabSwitcherDecorator() {
TerminalUtils.setupExtraKeysView(extraKeysView) TerminalUtils.setupExtraKeysView(extraKeysView)
val colorSchemeManager = ComponentManager.getComponent<ColorSchemeComponent>() val colorSchemeManager = ComponentManager.getComponent<ColorSchemeComponent>()
colorSchemeManager.applyColorScheme(terminalView, extraKeysView, colorSchemeManager.applyColorScheme(
colorSchemeManager.getCurrentColorScheme()) terminalView, extraKeysView,
colorSchemeManager.getCurrentColorScheme()
)
view view
} }
@ -62,8 +64,10 @@ class NeoTabDecorator(val context: NeoTermActivity) : TabSwitcherDecorator() {
} }
} }
override fun onShowTab(context: Context, tabSwitcher: TabSwitcher, override fun onShowTab(
view: View, tab: Tab, index: Int, viewType: Int, savedInstanceState: Bundle?) { context: Context, tabSwitcher: TabSwitcher,
view: View, tab: Tab, index: Int, viewType: Int, savedInstanceState: Bundle?
) {
// TODO: Improve // TODO: Improve
val toolbar = this@NeoTabDecorator.context.toolbar val toolbar = this@NeoTabDecorator.context.toolbar
@ -112,16 +116,22 @@ class NeoTabDecorator(val context: NeoTermActivity) : TabSwitcherDecorator() {
sessionData.glView?.requestFocus() sessionData.glView?.requestFocus()
setViewLayerType(sessionData.glView) setViewLayerType(sessionData.glView)
videoLayout.addView(sessionData.glView, videoLayout.addView(
sessionData.glView,
FrameLayout.LayoutParams( FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT)) FrameLayout.LayoutParams.MATCH_PARENT
)
)
if (Globals.HideSystemMousePointer if (Globals.HideSystemMousePointer
&& android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N
) {
sessionData.glView?.pointerIcon = sessionData.glView?.pointerIcon =
android.view.PointerIcon.getSystemIcon(context, android.view.PointerIcon.getSystemIcon(
android.view.PointerIcon.TYPE_NULL) context,
android.view.PointerIcon.TYPE_NULL
)
} }
val r = Rect() val r = Rect()
@ -132,12 +142,25 @@ class NeoTabDecorator(val context: NeoTermActivity) : TabSwitcherDecorator() {
videoLayout.getWindowVisibleDisplayFrame(r) videoLayout.getWindowVisibleDisplayFrame(r)
val heightDiff = videoLayout.rootView.height - videoLayout.height // Take system bar into consideration val heightDiff = videoLayout.rootView.height - videoLayout.height // Take system bar into consideration
val widthDiff = videoLayout.rootView.width - videoLayout.width // Nexus 5 has system bar at the right side val widthDiff = videoLayout.rootView.width - videoLayout.width // Nexus 5 has system bar at the right side
Log.v("SDL", "Main window visible region changed: " + r.left + ":" + r.top + ":" + r.width() + ":" + r.height()) Log.v(
"SDL",
"Main window visible region changed: " + r.left + ":" + r.top + ":" + r.width() + ":" + r.height()
)
videoLayout.postDelayed({ videoLayout.postDelayed({
sessionData.glView?.callNativeScreenVisibleRect(r.left + widthDiff, r.top + heightDiff, r.width(), r.height()) sessionData.glView?.callNativeScreenVisibleRect(
r.left + widthDiff,
r.top + heightDiff,
r.width(),
r.height()
)
}, 300) }, 300)
videoLayout.postDelayed({ videoLayout.postDelayed({
sessionData.glView?.callNativeScreenVisibleRect(r.left + widthDiff, r.top + heightDiff, r.width(), r.height()) sessionData.glView?.callNativeScreenVisibleRect(
r.left + widthDiff,
r.top + heightDiff,
r.width(),
r.height()
)
}, 600) }, 600)
}) })
} }
@ -145,8 +168,10 @@ class NeoTabDecorator(val context: NeoTermActivity) : TabSwitcherDecorator() {
} }
} }
private fun bindTerminalView(tab: TermTab, view: TerminalView?, private fun bindTerminalView(
extraKeysView: ExtraKeysView?) { tab: TermTab, view: TerminalView?,
extraKeysView: ExtraKeysView?
) {
val termView = view ?: return val termView = view ?: return
val termData = tab.termData val termData = tab.termData

View File

@ -1,8 +1,8 @@
package io.neoterm.ui.term.tab package io.neoterm.ui.term.tab
import android.content.Context import android.content.Context
import androidx.appcompat.widget.Toolbar
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import androidx.appcompat.widget.Toolbar
import io.neoterm.component.colorscheme.ColorSchemeComponent import io.neoterm.component.colorscheme.ColorSchemeComponent
import io.neoterm.frontend.component.ComponentManager import io.neoterm.frontend.component.ComponentManager
import io.neoterm.frontend.session.shell.client.TermSessionData import io.neoterm.frontend.session.shell.client.TermSessionData
@ -24,8 +24,10 @@ class TermTab(title: CharSequence) : NeoTab(title), TermUiPresenter {
fun updateColorScheme() { fun updateColorScheme() {
val colorSchemeManager = ComponentManager.getComponent<ColorSchemeComponent>() val colorSchemeManager = ComponentManager.getComponent<ColorSchemeComponent>()
colorSchemeManager.applyColorScheme(termData.termView, termData.extraKeysView, colorSchemeManager.applyColorScheme(
colorSchemeManager.getCurrentColorScheme()) termData.termView, termData.extraKeysView,
colorSchemeManager.getCurrentColorScheme()
)
} }
fun cleanup() { fun cleanup() {

View File

@ -1,15 +1,19 @@
package io.neoterm.utils package io.neoterm.utils
import androidx.appcompat.app.AppCompatActivity
import android.graphics.Rect import android.graphics.Rect
import android.view.View import android.view.View
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatActivity
/** /**
* Helper class to "adjustResize" Activity when we are in full screen mode and check IME status. * Helper class to "adjustResize" Activity when we are in full screen mode and check IME status.
* Android Bug 5497: https://code.google.com/p/android/issues/detail?id=5497 * Android Bug 5497: https://code.google.com/p/android/issues/detail?id=5497
*/ */
class FullScreenHelper private constructor(activity: AppCompatActivity, var fullScreen: Boolean, private var shouldSkipFirst: Boolean) { class FullScreenHelper private constructor(
activity: AppCompatActivity,
var fullScreen: Boolean,
private var shouldSkipFirst: Boolean
) {
interface KeyBoardListener { interface KeyBoardListener {
/** /**

View File

@ -134,7 +134,8 @@
<string name="support_donate_label">捐赠</string> <string name="support_donate_label">捐赠</string>
<string name="support_donate_description">如果你喜欢这个app你可以考虑请作者喝杯咖啡</string> <string name="support_donate_description">如果你喜欢这个app你可以考虑请作者喝杯咖啡</string>
<string name="about_developers">Kiva 维护\nCrixec 图标设计\n酷安用户 @NimaQu 赞助服务器\nQQ用户 @My 提供免费网络</string> <string name="about_developers">Kiva 维护\nCrixec 图标设计\n酷安用户 @NimaQu 赞助服务器\nQQ用户 @My 提供免费网络</string>
<string name="support_donate_dialog_text">这个app是我在课余时间制作的一个人不仅要维护app还要维护各种软件包和服务器如果能得到你的支持我将更有动力继续将app完善下去</string> <string name="support_donate_dialog_text">这个app是我在课余时间制作的一个人不仅要维护app还要维护各种软件包和服务器如果能得到你的支持我将更有动力继续将app完善下去
</string>
<string name="support_donate_alipay">支付宝</string> <string name="support_donate_alipay">支付宝</string>
<string name="new_color_scheme">新建配色方案</string> <string name="new_color_scheme">新建配色方案</string>
<string name="faq">常见问题</string> <string name="faq">常见问题</string>

View File

@ -60,7 +60,9 @@
<string name="source_changed">APT source changed, you may get it updated by executing: apt update</string> <string name="source_changed">APT source changed, you may get it updated by executing: apt update</string>
<string name="done">Done</string> <string name="done">Done</string>
<string name="install">Install</string> <string name="install">Install</string>
<string name="package_details">Package: %s\nVersion: %s\nDepends: %s\nInstalled Size: %s\nDescription: %s\nHome Page: %s</string> <string name="package_details">Package: %s\nVersion: %s\nDepends: %s\nInstalled Size: %s\nDescription: %s\nHome
Page: %s
</string>
<string name="package_list_empty">Package list is empty, please check out your source.</string> <string name="package_list_empty">Package list is empty, please check out your source.</string>
<string name="menu_refresh_list">Refresh</string> <string name="menu_refresh_list">Refresh</string>
<string name="menu_update">Update and Refresh</string> <string name="menu_update">Update and Refresh</string>
@ -72,7 +74,8 @@
<string name="crash_stack_trace">Stack Trace</string> <string name="crash_stack_trace">Stack Trace</string>
<string name="installer_message">Installing</string> <string name="installer_message">Installing</string>
<string name="installer_install_zsh_required">We will install oh-my-zsh and switch your login program to zsh</string> <string name="installer_install_zsh_required">We will install oh-my-zsh and switch your login program to zsh
</string>
<string name="pref_general_bell">Bell</string> <string name="pref_general_bell">Bell</string>
<string name="pref_general_bell_desc">Bell when receiving \'\\a\'</string> <string name="pref_general_bell_desc">Bell when receiving \'\\a\'</string>
@ -85,7 +88,9 @@
<string name="pref_general_initial_command">Initial Command</string> <string name="pref_general_initial_command">Initial Command</string>
<string name="pref_general_initial_command_desc">Execute commands when a session is being created</string> <string name="pref_general_initial_command_desc">Execute commands when a session is being created</string>
<string name="pref_general_auto_completion">Auto Completion(Experimental)</string> <string name="pref_general_auto_completion">Auto Completion(Experimental)</string>
<string name="pref_general_auto_completion_desc">Enable complete things when typing commands or path. This is still work in progress with lots of bugs to deal with</string> <string name="pref_general_auto_completion_desc">Enable complete things when typing commands or path. This is still
work in progress with lots of bugs to deal with
</string>
<string name="pref_general_volume_as_control">Use volume up and down as special keys</string> <string name="pref_general_volume_as_control">Use volume up and down as special keys</string>
<string name="pref_general_volume_as_control_desc">Volume Down as Ctrl\nVolume Up as FN</string> <string name="pref_general_volume_as_control_desc">Volume Down as Ctrl\nVolume Up as FN</string>
<string name="pref_general_use_execve_wrapper">Use execve() wrapper</string> <string name="pref_general_use_execve_wrapper">Use execve() wrapper</string>
@ -96,7 +101,9 @@
<string name="pref_ui_hide_toolbar">Hide Toolbar</string> <string name="pref_ui_hide_toolbar">Hide Toolbar</string>
<string name="pref_ui_hide_toolbar_desc">Hide toolbar when keyboard is showing</string> <string name="pref_ui_hide_toolbar_desc">Hide toolbar when keyboard is showing</string>
<string name="pref_ui_close_tab_anim_next_tab">Next tab animation</string> <string name="pref_ui_close_tab_anim_next_tab">Next tab animation</string>
<string name="pref_ui_close_tab_anim_next_tab_desc">Switch to the next tab instead of the previous tab when closing tab</string> <string name="pref_ui_close_tab_anim_next_tab_desc">Switch to the next tab instead of the previous tab when closing
tab
</string>
<string name="pref_ui_eks_weight_explicit">Use explicit weight for ExtraKeysView</string> <string name="pref_ui_eks_weight_explicit">Use explicit weight for ExtraKeysView</string>
<string name="pref_ui_eks_weight_explicit_desc">If ExtraKeysView shows incorrectly, please enable this</string> <string name="pref_ui_eks_weight_explicit_desc">If ExtraKeysView shows incorrectly, please enable this</string>
<string name="pref_ui_eks_enabled">Show extra keys</string> <string name="pref_ui_eks_enabled">Show extra keys</string>
@ -124,7 +131,9 @@
<string name="menu_upgrade">Upgrade</string> <string name="menu_upgrade">Upgrade</string>
<string name="apt_update_ok">Package list successfully updated</string> <string name="apt_update_ok">Package list successfully updated</string>
<string name="apt_upgrade_ok">Package successfully upgraded</string> <string name="apt_upgrade_ok">Package successfully upgraded</string>
<string name="installing_topic">Installation started. Please pay attention to the prompt that appears on the screen</string> <string name="installing_topic">Installation started. Please pay attention to the prompt that appears on the
screen
</string>
<string name="session_closed">Session was closed</string> <string name="session_closed">Session was closed</string>
<string name="restore_session">Cancel</string> <string name="restore_session">Cancel</string>
<string name="show_help">Show Help</string> <string name="show_help">Show Help</string>
@ -137,9 +146,14 @@
<string name="about_reset_label_desc">Clear all files except user home directory</string> <string name="about_reset_label_desc">Clear all files except user home directory</string>
<string name="support_donate_label">Donate</string> <string name="support_donate_label">Donate</string>
<string name="support_donate_description">If you like this app, you can offer developers a cup of coffee</string> <string name="support_donate_description">If you like this app, you can offer developers a cup of coffee</string>
<string name="support_donate_dialog_text">This app is made in my spare time. Not only me needs to develop app, but also maintains various software packages and servers. If you can support me, I will be more motivated to improve this app.</string> <string name="support_donate_dialog_text">This app is made in my spare time. Not only me needs to develop app, but
also maintains various software packages and servers. If you can support me, I will be more motivated to improve
this app.
</string>
<string name="support_donate_alipay">Alipay</string> <string name="support_donate_alipay">Alipay</string>
<string name="about_developers">Kiva for Maintaining\nCrixec for Icon Design\nCoolApk User @NimaQu for providing server\nQQ User @My for providing free network</string> <string name="about_developers">Kiva for Maintaining\nCrixec for Icon Design\nCoolApk User @NimaQu for providing
server\nQQ User @My for providing free network
</string>
<string name="new_color_scheme">New Color Scheme</string> <string name="new_color_scheme">New Color Scheme</string>
<string name="faq">FAQ</string> <string name="faq">FAQ</string>
<string name="new_source">New</string> <string name="new_source">New</string>
@ -164,11 +178,14 @@
<string name="input_new_source_repo">Enter new Repo</string> <string name="input_new_source_repo">Enter new Repo</string>
<string name="error_new_source_url">URL cannot be empty</string> <string name="error_new_source_url">URL cannot be empty</string>
<string name="error_new_source_repo">Repo cannot be empty</string> <string name="error_new_source_repo">Repo cannot be empty</string>
<string name="sorry_for_development">This feature is still under development so it is only available on DEBUG builds.\n</string> <string name="sorry_for_development">This feature is still under development so it is only available on DEBUG
builds.\n
</string>
<string name="dangerous_zone">Dangerous Zone</string> <string name="dangerous_zone">Dangerous Zone</string>
<string name="reset_app_warning">You will have to re-setup later, confirm?</string> <string name="reset_app_warning">You will have to re-setup later, confirm?</string>
<string name="default_source_url" translatable="false">https://raw.githubusercontent.com/NeoTerm/NeoTerm-repo/main</string> <string name="default_source_url" translatable="false">https://raw.githubusercontent.com/NeoTerm/NeoTerm-repo/main
</string>
<string-array name="pref_general_shell_entries" translatable="false"> <string-array name="pref_general_shell_entries" translatable="false">
<item>sh</item> <item>sh</item>

View File

@ -13,9 +13,9 @@
*/ */
package de.mrapp.android.tabswitcher; package de.mrapp.android.tabswitcher;
import android.view.animation.Interpolator;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import android.view.animation.Interpolator;
import static de.mrapp.android.util.Condition.ensureAtLeast; import static de.mrapp.android.util.Condition.ensureAtLeast;
@ -31,10 +31,8 @@ public abstract class Animation {
* An abstract base class for all builders, which allow to configure and create instances of the * An abstract base class for all builders, which allow to configure and create instances of the
* class {@link Animation}. * class {@link Animation}.
* *
* @param <AnimationType> * @param <AnimationType> The type of the animations, which are created by the builder
* The type of the animations, which are created by the builder * @param <BuilderType> The type of the builder
* @param <BuilderType>
* The type of the builder
*/ */
protected static abstract class Builder<AnimationType, BuilderType> { protected static abstract class Builder<AnimationType, BuilderType> {
@ -81,8 +79,7 @@ public abstract class Animation {
/** /**
* Sets the duration of the animations, which are created by the builder. * Sets the duration of the animations, which are created by the builder.
* *
* @param duration * @param duration The duration, which should be set, in milliseconds as a {@link Long} value or -1,
* The duration, which should be set, in milliseconds as a {@link Long} value or -1,
* if the default duration should be used * if the default duration should be used
* @return The builder, this method has be called upon, as an instance of the generic type * @return The builder, this method has be called upon, as an instance of the generic type
* BuilderType. The builder may not be null * BuilderType. The builder may not be null
@ -98,8 +95,7 @@ public abstract class Animation {
* Sets the interpolator, which should be used by the animations, which are created by the * Sets the interpolator, which should be used by the animations, which are created by the
* builder. * builder.
* *
* @param interpolator * @param interpolator The interpolator, which should be set, as an instance of the type {@link
* The interpolator, which should be set, as an instance of the type {@link
* Interpolator} or null, if the default interpolator should be used * Interpolator} or null, if the default interpolator should be used
* @return The builder, this method has be called upon, as an instance of the generic type * @return The builder, this method has be called upon, as an instance of the generic type
* BuilderType. The builder may not be null * BuilderType. The builder may not be null
@ -125,11 +121,9 @@ public abstract class Animation {
/** /**
* Creates a new animation. * Creates a new animation.
* *
* @param duration * @param duration The duration of the animation in milliseconds as a {@link Long} value or -1, if the
* The duration of the animation in milliseconds as a {@link Long} value or -1, if the
* default duration should be used * default duration should be used
* @param interpolator * @param interpolator The interpolator, which should be used by the animation, as an instance of the type
* The interpolator, which should be used by the animation, as an instance of the type
* {@link Interpolator} or null, if the default interpolator should be used * {@link Interpolator} or null, if the default interpolator should be used
*/ */
protected Animation(final long duration, @Nullable final Interpolator interpolator) { protected Animation(final long duration, @Nullable final Interpolator interpolator) {

View File

@ -45,8 +45,7 @@ public enum LayoutPolicy {
/** /**
* Creates a new layout policy. * Creates a new layout policy.
* *
* @param value * @param value The value of the layout policy as an {@link Integer} value
* The value of the layout policy as an {@link Integer} value
*/ */
LayoutPolicy(final int value) { LayoutPolicy(final int value) {
this.value = value; this.value = value;
@ -64,8 +63,7 @@ public enum LayoutPolicy {
/** /**
* Returns the layout policy, which corresponds to a specific value. * Returns the layout policy, which corresponds to a specific value.
* *
* @param value * @param value The value of the layout policy, which should be returned, as an {@link Integer}
* The value of the layout policy, which should be returned, as an {@link Integer}
* value * value
* @return The layout policy, which corresponds to the given value, as a value of the enum * @return The layout policy, which corresponds to the given value, as a value of the enum
* {@link LayoutPolicy} * {@link LayoutPolicy}

View File

@ -13,9 +13,9 @@
*/ */
package de.mrapp.android.tabswitcher; package de.mrapp.android.tabswitcher;
import android.view.animation.Interpolator;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import android.view.animation.Interpolator;
/** /**
* A peek animation, which animates the size of a tab starting at a specific position in order to * A peek animation, which animates the size of a tab starting at a specific position in order to
@ -58,8 +58,7 @@ public class PeekAnimation extends Animation {
* Sets the horizontal position, the animations, which are created by the builder, should * Sets the horizontal position, the animations, which are created by the builder, should
* start at. * start at.
* *
* @param x * @param x The horizontal position, which should be set, in pixels as a {@link Float} value
* The horizontal position, which should be set, in pixels as a {@link Float} value
* @return The builder, this method has be called upon, as an instance of the generic type * @return The builder, this method has be called upon, as an instance of the generic type
* BuilderType. The builder may not be null * BuilderType. The builder may not be null
*/ */
@ -73,8 +72,7 @@ public class PeekAnimation extends Animation {
* Sets the vertical position, the animations, which are created by the builder, should * Sets the vertical position, the animations, which are created by the builder, should
* start at. * start at.
* *
* @param y * @param y The vertical position, which should be set, in pixels as a {@link Float} value
* The vertical position, which should be set, in pixels as a {@link Float} value
* @return The builder, this method has be called upon, as an instance of the generic type * @return The builder, this method has be called upon, as an instance of the generic type
* BuilderType. The builder may not be null * BuilderType. The builder may not be null
*/ */
@ -105,11 +103,9 @@ public class PeekAnimation extends Animation {
/** /**
* Creates a new reveal animation. * Creates a new reveal animation.
* *
* @param x * @param x The horizontal position, the animation should start at, in pixels as a {@link Float}
* The horizontal position, the animation should start at, in pixels as a {@link Float}
* value * value
* @param y * @param y The vertical position, the animation should start at, in pixels as a {@link Float}
* The vertical position, the animation should start at, in pixels as a {@link Float}
* value * value
*/ */
private PeekAnimation(final long duration, @Nullable final Interpolator interpolator, private PeekAnimation(final long duration, @Nullable final Interpolator interpolator,

View File

@ -13,9 +13,9 @@
*/ */
package de.mrapp.android.tabswitcher; package de.mrapp.android.tabswitcher;
import android.view.animation.Interpolator;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import android.view.animation.Interpolator;
/** /**
* A reveal animation, which animates the size of a tab starting at a specific position. Reveal * A reveal animation, which animates the size of a tab starting at a specific position. Reveal
@ -56,8 +56,7 @@ public class RevealAnimation extends Animation {
* Sets the horizontal position, the animations, which are created by the builder, should * Sets the horizontal position, the animations, which are created by the builder, should
* start at. * start at.
* *
* @param x * @param x The horizontal position, which should be set, in pixels as a {@link Float} value
* The horizontal position, which should be set, in pixels as a {@link Float} value
* @return The builder, this method has be called upon, as an instance of the generic type * @return The builder, this method has be called upon, as an instance of the generic type
* BuilderType. The builder may not be null * BuilderType. The builder may not be null
*/ */
@ -71,8 +70,7 @@ public class RevealAnimation extends Animation {
* Sets the vertical position, the animations, which are created by the builder, should * Sets the vertical position, the animations, which are created by the builder, should
* start at. * start at.
* *
* @param y * @param y The vertical position, which should be set, in pixels as a {@link Float} value
* The vertical position, which should be set, in pixels as a {@link Float} value
* @return The builder, this method has be called upon, as an instance of the generic type * @return The builder, this method has be called upon, as an instance of the generic type
* BuilderType. The builder may not be null * BuilderType. The builder may not be null
*/ */
@ -103,11 +101,9 @@ public class RevealAnimation extends Animation {
/** /**
* Creates a new reveal animation. * Creates a new reveal animation.
* *
* @param x * @param x The horizontal position, the animation should start at, in pixels as a {@link Float}
* The horizontal position, the animation should start at, in pixels as a {@link Float}
* value * value
* @param y * @param y The vertical position, the animation should start at, in pixels as a {@link Float}
* The vertical position, the animation should start at, in pixels as a {@link Float}
* value * value
*/ */
private RevealAnimation(final long duration, @Nullable final Interpolator interpolator, private RevealAnimation(final long duration, @Nullable final Interpolator interpolator,

Some files were not shown because too many files have changed in this diff Show More