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
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.
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.
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. 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
@ -26,23 +30,35 @@ Examples of unacceptable behavior by participants include:
## 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
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
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
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
[version]: http://contributor-covenant.org/version/1/4/

View File

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

View File

@ -12,7 +12,7 @@ class NeoLangGroupNode(val attributes: Array<NeoLangAttributeNode>) : NeoLangBas
}
companion object {
fun emptyNode() : NeoLangGroupNode {
fun emptyNode(): NeoLangGroupNode {
return NeoLangGroupNode(arrayOf())
}
}

View File

@ -13,7 +13,7 @@ class NeoLangProgramNode(val groups: List<NeoLangGroupNode>) : NeoLangBaseNode()
}
companion object {
fun emptyNode() : NeoLangProgramNode {
fun emptyNode(): NeoLangProgramNode {
return NeoLangProgramNode(listOf())
}
}

View File

@ -11,7 +11,7 @@ class AstVisitor(private val ast: NeoLangAst, private val visitorCallback: IVisi
}
@Suppress("UNCHECKED_CAST")
fun <T : IVisitorCallback> getCallback() : T {
fun <T : IVisitorCallback> getCallback(): T {
return visitorCallback as T
}
}

View File

@ -14,5 +14,5 @@ interface IVisitorCallback {
fun onExitContext()
fun getCurrentContext() : NeoLangContext
fun getCurrentContext(): NeoLangContext
}

View File

@ -4,7 +4,6 @@ import io.neolang.ast.NeoLangEOFToken
import io.neolang.ast.NeoLangToken
import io.neolang.ast.NeoLangTokenType
import io.neolang.ast.NeoLangTokenValue
import java.util.*
/**
* grammar: [
@ -69,7 +68,8 @@ class NeoLangLexer {
while (currentChar == ' '
|| currentChar == '\t'
|| currentChar == '\n'
|| currentChar == '\r') {
|| currentChar == '\r'
) {
if (currentChar == '\n') {
++lineNumber
}
@ -202,8 +202,8 @@ class NeoLangLexer {
var loop = moveToNextChar() // skip 'x' or 'X'
while (loop && (currentChar.isHexNumber())) {
value *= 16
+ (currentChar.toInt().and(15))
+ if (currentChar >= 'A') 9 else 0
+(currentChar.toInt().and(15))
+if (currentChar >= 'A') 9 else 0
loop = moveToNextChar()
}
return value

View File

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

View File

@ -5,7 +5,10 @@ import io.neolang.runtime.context.NeoLangContext
/**
* @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 {
internal class PrimaryElement(val primaryValue: NeoLangValue) : NeoLangArrayElement() {
override fun eval(): NeoLangValue {

View File

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

View File

@ -2,7 +2,7 @@ package io.neoterm.bridge;
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).

View File

@ -7,14 +7,18 @@ NeoTerm
A modern-designed android terminal emulator for the 21st century.
### 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
View on [GitBook](https://neoterm.gitbooks.io/neoterm-wiki/content)
View on [GitHub](https://github.com/NeoTerm/NeoTerm-Wiki)
### Download
[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)

View File

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

View File

@ -27,30 +27,26 @@ import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Arrays;
@SuppressWarnings("JniMissingFunction")
class AccelerometerReader implements SensorEventListener
{
class AccelerometerReader implements SensorEventListener {
private SensorManager _manager = null;
public boolean openedBySDL = false;
public static final GyroscopeListener gyro = new GyroscopeListener();
public static final OrientationListener orientation = new OrientationListener();
public AccelerometerReader(Context context)
{
public AccelerometerReader(Context context) {
_manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
}
public synchronized void stop()
{
if( _manager != null )
{
public synchronized void stop() {
if (_manager != null) {
Log.i("SDL", "libSDL: stopping accelerometer/gyroscope/orientation");
_manager.unregisterListener(this);
_manager.unregisterListener(gyro);
@ -58,23 +54,19 @@ class AccelerometerReader implements SensorEventListener
}
}
public synchronized void start()
{
if( (Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer) &&
_manager != null && _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null )
{
public synchronized void start() {
if ((Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer) &&
_manager != null && _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null) {
Log.i("SDL", "libSDL: starting accelerometer");
_manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
}
if( (Globals.AppUsesGyroscope || Globals.MoveMouseWithGyroscope) &&
_manager != null && _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null )
{
if ((Globals.AppUsesGyroscope || Globals.MoveMouseWithGyroscope) &&
_manager != null && _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null) {
Log.i("SDL", "libSDL: starting gyroscope");
_manager.registerListener(gyro, _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
}
if( (Globals.AppUsesOrientationSensor) && _manager != null &&
_manager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR) != null )
{
if ((Globals.AppUsesOrientationSensor) && _manager != null &&
_manager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR) != null) {
Log.i("SDL", "libSDL: starting orientation sensor");
_manager.registerListener(orientation, _manager.getDefaultSensor(
Sensor.TYPE_GAME_ROTATION_VECTOR),
@ -82,37 +74,32 @@ class AccelerometerReader implements SensorEventListener
}
}
public void onSensorChanged(SensorEvent event)
{
if( Globals.HorizontalOrientation )
{
if( gyro.invertedOrientation )
public void onSensorChanged(SensorEvent event) {
if (Globals.HorizontalOrientation) {
if (gyro.invertedOrientation)
nativeAccelerometer(-event.values[1], event.values[0], event.values[2]);
else
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!
}
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;
// Noise filter with sane initial values, so user will be able
// to move gyroscope during the first 10 seconds, while the noise is measured.
// After that the values are replaced by noiseMin/noiseMax.
final float filterMin[] = new float[] { -0.05f, -0.05f, -0.05f };
final float filterMax[] = new float[] { 0.05f, 0.05f, 0.05f };
final float filterMin[] = new float[]{-0.05f, -0.05f, -0.05f};
final float filterMax[] = new float[]{0.05f, 0.05f, 0.05f};
// The noise levels we're measuring.
// Large initial values, they will decrease, but never increase.
float noiseMin[] = new float[] { -1.0f, -1.0f, -1.0f };
float noiseMax[] = new float[] { 1.0f, 1.0f, 1.0f };
float noiseMin[] = new float[]{-1.0f, -1.0f, -1.0f};
float noiseMax[] = new float[]{1.0f, 1.0f, 1.0f};
// The gyro data buffer, from which we care calculating min/max noise values.
// The bigger it is, the more precise the calclations, and the longer it takes to converge.
@ -130,24 +117,19 @@ class AccelerometerReader implements SensorEventListener
// How long the algorithm is running, to stop it if it does not converge.
int measurementIteration = 0;
public GyroscopeListener()
{
public GyroscopeListener() {
}
void collectNoiseData(final float[] data)
{
for( int i = 0; i < noiseMin.length; i++ )
{
if( data[i] < noiseMin[i] || data[i] > noiseMax[i] )
{
void collectNoiseData(final float[] data) {
for (int i = 0; i < noiseMin.length; 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
if( movementBackoff < 0 )
{
if (movementBackoff < 0) {
int discard = 10;
if( -movementBackoff < discard )
if (-movementBackoff < discard)
discard = -movementBackoff;
noiseDataIdx -= discard;
if( noiseDataIdx < 0 )
if (noiseDataIdx < 0)
noiseDataIdx = 0;
}
movementBackoff = 10;
@ -156,24 +138,22 @@ class AccelerometerReader implements SensorEventListener
noiseData[noiseDataIdx][i] = data[i];
}
movementBackoff--;
if( movementBackoff >= 0 )
if (movementBackoff >= 0)
return; // Also discard several values after the movement stopped
noiseDataIdx++;
if( noiseDataIdx < noiseData.length )
if (noiseDataIdx < noiseData.length)
return;
measurementIteration++;
Log.d( "SDL", "GYRO_NOISE: Measuring in progress... " + measurementIteration );
if( measurementIteration > 5 )
{
Log.d("SDL", "GYRO_NOISE: Measuring in progress... " + measurementIteration);
if (measurementIteration > 5) {
// 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(noiseMax, 0, filterMax, 0, filterMax.length);
}
if( measurementIteration > 15 )
{
Log.d( "SDL", "GYRO_NOISE: Measuring done! Maximum number of iterations reached: " + measurementIteration );
if (measurementIteration > 15) {
Log.d("SDL", "GYRO_NOISE: Measuring done! Maximum number of iterations reached: " + measurementIteration);
noiseData = null;
measuredNoiseRange = null;
return;
@ -181,15 +161,13 @@ class AccelerometerReader implements SensorEventListener
noiseDataIdx = 0;
boolean changed = false;
for( int i = 0; i < noiseMin.length; i++ )
{
for (int i = 0; i < noiseMin.length; i++) {
float min = 1.0f;
float max = -1.0f;
for( int ii = 0; ii < noiseData.length; ii++ )
{
if( min > noiseData[ii][i] )
for (int ii = 0; ii < noiseData.length; ii++) {
if (min > noiseData[ii][i])
min = noiseData[ii][i];
if( max < noiseData[ii][i] )
if (max < noiseData[ii][i])
max = noiseData[ii][i];
}
// Increase the range a bit, for safe conservative filtering
@ -198,8 +176,7 @@ class AccelerometerReader implements SensorEventListener
max += (max - middle) * 0.2f;
// 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
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
noiseMin[i] = (noiseMin[i] + min * 4.0f) / 5.0f;
noiseMax[i] = (noiseMax[i] + max * 4.0f) / 5.0f;
@ -207,29 +184,26 @@ class AccelerometerReader implements SensorEventListener
}
}
Log.d( "SDL", "GYRO_NOISE: MIN MAX: " + Arrays.toString(noiseMin) + " " + Arrays.toString(noiseMax) );
Log.d("SDL", "GYRO_NOISE: MIN MAX: " + Arrays.toString(noiseMin) + " " + Arrays.toString(noiseMax));
if( !changed )
if (!changed)
return;
// Determine when to stop measuring - check that the previous min/max range is close enough to the current one
float range[] = new float[noiseMin.length];
for( int i = 0; i < noiseMin.length; i++ )
for (int i = 0; i < noiseMin.length; i++)
range[i] = noiseMax[i] - noiseMin[i];
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;
return; // First iteration, skip further checks
}
for( int i = 0; i < range.length; i++ )
{
if( measuredNoiseRange[i] / range[i] > 1.2f )
{
for (int i = 0; i < range.length; i++) {
if (measuredNoiseRange[i] / range[i] > 1.2f) {
measuredNoiseRange = range;
return;
}
@ -240,91 +214,82 @@ class AccelerometerReader implements SensorEventListener
System.arraycopy(noiseMax, 0, filterMax, 0, filterMax.length);
noiseData = null;
measuredNoiseRange = null;
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;
final float[] data = event.values;
if( noiseData != null )
if (noiseData != null)
collectNoiseData(data);
for( int i = 0; i < 3; i++ )
{
if( data[i] < filterMin[i] )
{
for (int i = 0; i < 3; i++) {
if (data[i] < filterMin[i]) {
filtered = false;
data[i] -= filterMin[i];
}
else if( data[i] > filterMax[i] )
{
} else if (data[i] > filterMax[i]) {
filtered = false;
data[i] -= filterMax[i];
}
}
if( filtered )
if (filtered)
return;
if( Globals.HorizontalOrientation )
{
if( invertedOrientation )
if (Globals.HorizontalOrientation) {
if (invertedOrientation)
nativeGyroscope(-data[0], -data[1], data[2]);
else
nativeGyroscope(data[0], data[1], data[2]);
}
else
{
if( invertedOrientation )
} else {
if (invertedOrientation)
nativeGyroscope(-data[1], data[0], data[2]);
else
nativeGyroscope(data[1], -data[0], data[2]);
}
}
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);
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);
if ( manager == null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) == null )
if (manager == null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) == null)
return;
manager.registerListener(gyro, manager.getDefaultSensor(
Globals.AppUsesOrientationSensor ? Sensor.TYPE_GAME_ROTATION_VECTOR : Sensor.TYPE_GYROSCOPE),
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);
if ( manager == null )
if (manager == null)
return;
manager.unregisterListener(l);
}
}
static class OrientationListener implements SensorEventListener
{
public OrientationListener()
{
static class OrientationListener implements SensorEventListener {
public OrientationListener() {
}
public void onSensorChanged(SensorEvent event)
{
public void onSensorChanged(SensorEvent event) {
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 nativeGyroscope(float X, float Y, float Z);
private static native void nativeOrientation(float X, float Y, float Z);
}

View File

@ -23,77 +23,60 @@ freely, subject to the following restrictions:
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.AudioManager;
import android.media.AudioRecord;
import android.media.AudioTrack;
import android.media.MediaRecorder.AudioSource;
import java.io.*;
import android.util.Log;
import java.util.concurrent.Semaphore;
import android.Manifest;
import android.content.pm.PackageManager;
import io.neoterm.xorg.NeoXorgViewClient;
import java.util.concurrent.Semaphore;
@SuppressWarnings("JniMissingFunction")
class AudioThread
{
class AudioThread {
private NeoXorgViewClient mClient;
private AudioTrack mAudio;
private byte[] mAudioBuffer;
private int mVirtualBufSize;
public AudioThread(NeoXorgViewClient client)
{
public AudioThread(NeoXorgViewClient client) {
this.mClient = client;
mAudio = null;
mAudioBuffer = null;
nativeAudioInitJavaCallbacks();
}
public int fillBuffer()
{
if( mClient.isPaused() )
{
try{
public int fillBuffer() {
if (mClient.isPaused()) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {}
} catch (InterruptedException e) {
}
else
{
} else {
//if( Globals.AudioBufferConfig == 0 ) // Gives too much spam to logcat, makes things worse
// mAudio.flush();
mAudio.write( mAudioBuffer, 0, mVirtualBufSize );
mAudio.write(mAudioBuffer, 0, mVirtualBufSize);
}
return 1;
}
public int initAudio(int rate, int channels, int encoding, int bufSize)
{
if( mAudio == null )
{
channels = ( channels == 1 ) ? AudioFormat.CHANNEL_CONFIGURATION_MONO :
public int initAudio(int rate, int channels, int encoding, int bufSize) {
if (mAudio == null) {
channels = (channels == 1) ? AudioFormat.CHANNEL_CONFIGURATION_MONO :
AudioFormat.CHANNEL_CONFIGURATION_STEREO;
encoding = ( encoding == 1 ) ? AudioFormat.ENCODING_PCM_16BIT :
encoding = (encoding == 1) ? AudioFormat.ENCODING_PCM_16BIT :
AudioFormat.ENCODING_PCM_8BIT;
mVirtualBufSize = bufSize;
if( AudioTrack.getMinBufferSize( rate, channels, encoding ) > bufSize )
bufSize = AudioTrack.getMinBufferSize( rate, channels, encoding );
if (AudioTrack.getMinBufferSize(rate, channels, encoding) > bufSize)
bufSize = AudioTrack.getMinBufferSize(rate, channels, encoding);
if(Globals.AudioBufferConfig != 0) { // application's choice - use minimal buffer
bufSize = (int)((float)bufSize * (((float)(Globals.AudioBufferConfig - 1) * 2.5f) + 1.0f));
if (Globals.AudioBufferConfig != 0) { // application's choice - use minimal buffer
bufSize = (int) ((float) bufSize * (((float) (Globals.AudioBufferConfig - 1) * 2.5f) + 1.0f));
mVirtualBufSize = bufSize;
}
mAudioBuffer = new byte[bufSize];
@ -103,21 +86,18 @@ class AudioThread
channels,
encoding,
bufSize,
AudioTrack.MODE_STREAM );
AudioTrack.MODE_STREAM);
mAudio.play();
}
return mVirtualBufSize;
}
public byte[] getBuffer()
{
public byte[] getBuffer() {
return mAudioBuffer;
}
public int deinitAudio()
{
if( mAudio != null )
{
public int deinitAudio() {
if (mAudio != null) {
mAudio.stop();
mAudio.release();
mAudio = null;
@ -126,34 +106,27 @@ class AudioThread
return 1;
}
public int initAudioThread()
{
public int initAudioThread() {
// Make audio thread priority higher so audio thread won't get underrun
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
return 1;
}
public int pauseAudioPlayback()
{
if( mAudio != null )
{
public int pauseAudioPlayback() {
if (mAudio != null) {
mAudio.pause();
}
if( mRecordThread != null )
{
if (mRecordThread != null) {
mRecordThread.pauseRecording();
}
return 1;
}
public int resumeAudioPlayback()
{
if( mAudio != null )
{
public int resumeAudioPlayback() {
if (mAudio != null) {
mAudio.play();
}
if( mRecordThread != null )
{
if (mRecordThread != null) {
mRecordThread.resumeRecording();
}
return 1;
@ -167,35 +140,31 @@ class AudioThread
private AudioRecord mRecorder = null;
private int mRecorderBufferSize = 0;
private byte[] startRecording(int rate, int channels, int encoding, int bufsize)
{
if( mRecordThread == null )
{
private byte[] startRecording(int rate, int channels, int encoding, int bufsize) {
if (mRecordThread == null) {
mRecordThread = new RecordingThread();
mRecordThread.start();
}
if( !mRecordThread.isStopped() )
{
if (!mRecordThread.isStopped()) {
Log.i("SDL", "SDL: error: application already opened audio recording device");
return null;
}
mRecordThread.init(bufsize);
int channelConfig = ( channels == 1 ) ? AudioFormat.CHANNEL_IN_MONO :
int channelConfig = (channels == 1) ? AudioFormat.CHANNEL_IN_MONO :
AudioFormat.CHANNEL_IN_STEREO;
int encodingConfig = ( encoding == 1 ) ? AudioFormat.ENCODING_PCM_16BIT :
int encodingConfig = (encoding == 1) ? AudioFormat.ENCODING_PCM_16BIT :
AudioFormat.ENCODING_PCM_8BIT;
int minBufDevice = AudioRecord.getMinBufferSize(rate, channelConfig, encodingConfig);
int minBufferSize = Math.max(bufsize * 8, minBufDevice + (bufsize - (minBufDevice % bufsize)));
Log.i("SDL", "SDL: app opened recording device, rate " + rate + " channels " + channels + " sample size " + (encoding+1) + " bufsize " + bufsize + " internal bufsize " + minBufferSize);
if( mRecorder == null || mRecorder.getSampleRate() != rate ||
Log.i("SDL", "SDL: app opened recording device, rate " + rate + " channels " + channels + " sample size " + (encoding + 1) + " bufsize " + bufsize + " internal bufsize " + minBufferSize);
if (mRecorder == null || mRecorder.getSampleRate() != rate ||
mRecorder.getChannelCount() != channels ||
mRecorder.getAudioFormat() != encodingConfig ||
mRecorderBufferSize != minBufferSize )
{
if( mRecorder != null )
mRecorderBufferSize != minBufferSize) {
if (mRecorder != null)
mRecorder.release();
mRecorder = null;
try {
@ -217,19 +186,15 @@ class AudioThread
}
}
}
}
else
{
} else {
Log.i("SDL", "SDL: reusing old recording device");
}
mRecordThread.startRecording();
return mRecordThread.mRecordBuffer;
}
private void stopRecording()
{
if( mRecordThread == null || mRecordThread.isStopped() )
{
private void stopRecording() {
if (mRecordThread == null || mRecordThread.isStopped()) {
Log.i("SDL", "SDL: error: application already closed audio recording device");
return;
}
@ -237,45 +202,37 @@ class AudioThread
Log.i("SDL", "SDL: app closed recording device");
}
private class RecordingThread extends Thread
{
private class RecordingThread extends Thread {
private boolean stopped = true;
byte[] mRecordBuffer;
private Semaphore waitStarted = new Semaphore(0);
private boolean sleep = false;
RecordingThread()
{
RecordingThread() {
super();
}
void init(int bufsize)
{
if( mRecordBuffer == null || mRecordBuffer.length != bufsize )
void init(int bufsize) {
if (mRecordBuffer == null || mRecordBuffer.length != bufsize)
mRecordBuffer = new byte[bufsize];
}
public void run()
{
while( true )
{
public void run() {
while (true) {
waitStarted.acquireUninterruptibly();
waitStarted.drainPermits();
stopped = false;
sleep = false;
while( !sleep )
{
while (!sleep) {
int got = mRecorder.read(mRecordBuffer, 0, mRecordBuffer.length);
if( got != mRecordBuffer.length )
{
if (got != mRecordBuffer.length) {
// Audio is stopped here, sleep a bit.
try{
try {
Thread.sleep(1000);
} catch (InterruptedException e) {}
} catch (InterruptedException e) {
}
else
{
} else {
//Log.i("SDL", "SDL: nativeAudioRecordCallback with len " + mRecordBuffer.length);
nativeAudioRecordCallback();
//Log.i("SDL", "SDL: nativeAudioRecordCallback returned");
@ -287,33 +244,32 @@ class AudioThread
}
}
public void startRecording()
{
public void startRecording() {
mRecorder.startRecording();
waitStarted.release();
}
public void stopRecording()
{
public void stopRecording() {
sleep = true;
while( !stopped )
{
try{
while (!stopped) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {}
} catch (InterruptedException e) {
}
}
public void pauseRecording()
{
if( !stopped )
}
public void pauseRecording() {
if (!stopped)
mRecorder.stop();
}
public void resumeRecording()
{
if( !stopped )
public void resumeRecording() {
if (!stopped)
mRecorder.startRecording();
}
public boolean isStopped()
{
public boolean isStopped() {
return stopped;
}
}

View File

@ -22,116 +22,91 @@ freely, subject to the following restrictions:
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.OnPrimaryClipChangedListener;
import android.app.PendingIntent;
import android.app.AlarmManager;
import android.content.Intent;
import android.view.View;
import android.view.Display;
import android.content.Context;
import android.os.Build;
import android.util.Log;
public abstract class Clipboard
{
public static Clipboard get()
{
public abstract class Clipboard {
public static Clipboard get() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
return NewerClipboard.Holder.Instance;
return OlderClipboard.Holder.Instance;
}
public abstract void set(final Context context, final String text);
public abstract String get(final Context context);
public abstract void setListener(final Context context, final Runnable listener);
private static class NewerClipboard extends Clipboard
{
private static class Holder
{
private static class NewerClipboard extends Clipboard {
private static class Holder {
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 {
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
if( clipboard != null )
if (clipboard != null)
clipboard.setText(text);
} catch (Exception e) {
Log.i("SDL", "setClipboardText() exception: " + e.toString());
}
}
public String get(final Context context)
{
public String get(final Context context) {
String ret = "";
try {
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
if( clipboard != null && clipboard.getText() != null )
if (clipboard != null && clipboard.getText() != null)
ret = clipboard.getText().toString();
} catch (Exception e) {
Log.i("SDL", "getClipboardText() exception: " + e.toString());
}
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);
clipboard.addPrimaryClipChangedListener(new OnPrimaryClipChangedListener()
{
public void onPrimaryClipChanged()
{
clipboard.addPrimaryClipChangedListener(new OnPrimaryClipChangedListener() {
public void onPrimaryClipChanged() {
listener.run();
}
});
}
}
private static class OlderClipboard extends Clipboard
{
private static class Holder
{
private static class OlderClipboard extends Clipboard {
private static class Holder {
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 {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
if( clipboard != null )
if (clipboard != null)
clipboard.setText(text);
} catch (Exception e) {
Log.i("SDL", "setClipboardText() exception: " + e.toString());
}
}
public String get(final Context context)
{
public String get(final Context context) {
String ret = "";
try {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
if( clipboard != null && clipboard.getText() != null )
if (clipboard != null && clipboard.getText() != null)
ret = clipboard.getText().toString();
} catch (Exception e) {
Log.i("SDL", "getClipboardText() exception: " + e.toString());
}
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");
}
}

View File

@ -20,27 +20,19 @@
package io.neoterm;
import java.io.Writer;
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.app.KeyguardManager;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.SurfaceHolder;
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
@ -149,7 +141,6 @@ import android.app.KeyguardManager;
* }
* }
* </pre>
*
*/
@SuppressWarnings("ALL")
public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Callback {
@ -213,7 +204,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
SurfaceHolder holder = getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
mKeyguardManager = ((KeyguardManager)getContext().getSystemService(Context.KEYGUARD_SERVICE));
mKeyguardManager = ((KeyguardManager) getContext().getSystemService(Context.KEYGUARD_SERVICE));
}
/**
@ -227,6 +218,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* Wrapping is typically used for debugging purposes.
* <p>
* The default value is null.
*
* @param glWrapper the new 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
* of the DEBUG_CHECK_* constants. The debug flags take effect
* whenever a surface is created. The default value is zero.
*
* @param debugFlags the new debug flags
* @see #DEBUG_CHECK_GL_ERROR
* @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.
*
* @return the current value of the debug flags.
*/
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
* view will choose a config as close to 16-bit RGB as possible, with
* a depth buffer as close to 16 bits as possible.
*
* @param 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
* view will choose a config as close to 16-bit RGB as possible, with
* a depth buffer as close to 16 bits as possible.
*
*/
public void setEGLConfigChooser(int redSize, int greenSize, int blueSize,
int alphaSize, int depthSize, int stencilSize, boolean gles2, boolean gles3) {
setEGLConfigChooser(new ComponentSizeChooser(redSize, greenSize,
blueSize, alphaSize, depthSize, stencilSize, gles2, gles3));
}
/**
* Set the rendering mode. When renderMode is
* 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
* from any thread. Must not be called before a renderer has been set.
*
* @return the current rendering mode.
* @see #RENDERMODE_CONTINUOUSLY
* @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
* to communicate with the Renderer on the rendering thread.
* Must not be called before a renderer has been set.
*
* @param r the runnable to be run on the GL rendering thread.
*/
public void queueEvent(Runnable r) {
@ -477,11 +474,13 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* }
* }
* </pre>
*
* @see #setGLWrapper(GLWrapper)
*/
public interface GLWrapper {
/**
* Wraps a gl interface in another gl interface.
*
* @param gl a GL interface that is to be wrapped.
* @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
* is a convenient place to do this.
*
*
* @see #setRenderer(Renderer)
*/
public static interface SwapBuffersCallback {
public boolean SwapBuffers();
public void ResetVideoSurface();
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
* manually delete these lost resources.
* <p>
*
* @param gl the GL interface. Use <code>instanceof</code> to
* test if the interface supports GL11 or higher interfaces.
* @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);
* }
* </pre>
*
* @param gl the GL interface. Use <code>instanceof</code> to
* test if the interface supports GL11 or higher interfaces.
* @param width
@ -577,10 +579,11 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
*/
public abstract void onSurfaceChanged(GL10 gl, int width, int height);
/** Called when screen size changes */
public void onWindowResize(int width, int height)
{
if( mSwapBuffersCallback != null )
/**
* Called when screen size changes
*/
public void onWindowResize(int width, int height) {
if (mSwapBuffersCallback != null)
mSwapBuffersCallback.onWindowResize(width, height);
}
@ -596,23 +599,24 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* //... other gl calls to render the scene ...
* }
* </pre>
*
* @param gl the GL interface. Use <code>instanceof</code> to
* test if the interface supports GL11 or higher interfaces.
*/
public abstract void onDrawFrame(GL10 gl);
public boolean SwapBuffers() {
if( mSwapBuffersCallback != null )
if (mSwapBuffersCallback != null)
return mSwapBuffersCallback.SwapBuffers();
return false;
}
public void ResetVideoSurface() {
if( mSwapBuffersCallback != null )
if (mSwapBuffersCallback != null)
mSwapBuffersCallback.ResetVideoSurface();
}
public void setSwapBuffersCallback( SwapBuffersCallback c ) {
public void setSwapBuffersCallback(SwapBuffersCallback c) {
mSwapBuffersCallback = c;
}
@ -632,12 +636,15 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* implement this method by calling
* {@link EGL10#eglChooseConfig} and iterating through the results. Please consult the
* EGL specification available from The Khronos Group to learn how to call eglChooseConfig.
*
* @param egl the EGL10 for the current display.
* @param display the current display.
* @return the chosen configuration.
*/
EGLConfig chooseConfig(EGL10 egl, EGLDisplay display);
public boolean isGles2Required();
public boolean isGles3Required();
}
@ -646,6 +653,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
public BaseConfigChooser(int[] configSpec) {
mConfigSpec = configSpec;
}
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
int[] num_config = new int[1];
egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config);
@ -676,7 +684,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
private static class ComponentSizeChooser extends BaseConfigChooser {
public ComponentSizeChooser(int redSize, int greenSize, int blueSize,
int alphaSize, int depthSize, int stencilSize, boolean isGles2, boolean isGles3) {
super(new int[] {EGL10.EGL_NONE}); // Get all possible configs
super(new int[]{EGL10.EGL_NONE}); // Get all possible configs
mValue = new int[1];
mRedSize = redSize;
mGreenSize = greenSize;
@ -698,8 +706,8 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
int selectidx = -1;
Log.v("SDL", "Desired GL config: " + "R" + mRedSize + "G" + mGreenSize + "B" + mBlueSize + "A" + mAlphaSize + " depth " + mDepthSize + " stencil " + mStencilSize + " type " + (mIsGles3 ? "GLES3" : mIsGles2 ? "GLES2" : "GLES"));
for(EGLConfig config : configs) {
if ( config == null )
for (EGLConfig config : configs) {
if (config == null)
continue;
int r = findConfigAttrib(egl, display, config,
EGL10.EGL_RED_SIZE, 0);
@ -722,36 +730,36 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
EGL10.EGL_CONFIG_CAVEAT, EGL10.EGL_NONE);
int distance = Math.abs(r - mRedSize) + Math.abs(g - mGreenSize) + Math.abs(b - mBlueSize);
int dist1 = distance;
if( mAlphaSize - a > 0 )
if (mAlphaSize - a > 0)
distance += mAlphaSize - a;
else if( mAlphaSize - a < 0 )
else if (mAlphaSize - a < 0)
distance += 1; // Small penalty if we don't need alpha channel but it is present
int dist2 = distance;
if( (d > 0) != (mDepthSize > 0) )
if ((d > 0) != (mDepthSize > 0))
distance += (mDepthSize > 0) ? 5 : 1; // Small penalty if we don't need zbuffer but it is present
int dist3 = distance;
if( (s > 0) != (mStencilSize > 0) )
if ((s > 0) != (mStencilSize > 0))
distance += (mStencilSize > 0) ? 5 : 1; // Small penalty if we don't need stencil buffer but it is present
int dist4 = distance;
if( (rendertype & desiredtype) == 0 )
if ((rendertype & desiredtype) == 0)
distance += 5;
int dist5 = distance;
if( caveat == EGL10.EGL_SLOW_CONFIG )
if (caveat == EGL10.EGL_SLOW_CONFIG)
distance += 4;
if( caveat == EGL10.EGL_NON_CONFORMANT_CONFIG ) // dunno what that means, probably R and B channels swapped
if (caveat == EGL10.EGL_NON_CONFORMANT_CONFIG) // dunno what that means, probably R and B channels swapped
distance += 1;
String cfgcur = "R" + r + "G" + g + "B" + b + "A" + a + " depth " + d + " stencil " + s +
" type " + rendertype + " (";
if((rendertype & EGL_OPENGL_ES_BIT) != 0)
if ((rendertype & EGL_OPENGL_ES_BIT) != 0)
cfgcur += "GLES";
if((rendertype & EGL_OPENGL_ES2_BIT) != 0)
if ((rendertype & EGL_OPENGL_ES2_BIT) != 0)
cfgcur += " GLES2";
if((rendertype & EGL_OPENGL_ES3_BIT) != 0)
if ((rendertype & EGL_OPENGL_ES3_BIT) != 0)
cfgcur += " GLES3";
if((rendertype & EGL_OPENGL_BIT) != 0)
if ((rendertype & EGL_OPENGL_BIT) != 0)
cfgcur += " OPENGL";
if((rendertype & EGL_OPENVG_BIT) != 0)
if ((rendertype & EGL_OPENVG_BIT) != 0)
cfgcur += " OPENVG";
cfgcur += ")";
cfgcur += " caveat " + (caveat == EGL10.EGL_NONE ? "none" :
@ -769,7 +777,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
}
idx += 1;
}
Log.v("SDL", "GLSurfaceView_SDL::EGLConfigChooser::chooseConfig(): selected " + selectidx + ": " + cfglog );
Log.v("SDL", "GLSurfaceView_SDL::EGLConfigChooser::chooseConfig(): selected " + selectidx + ": " + cfglog);
return closestConfig;
}
@ -783,13 +791,11 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
return defaultValue;
}
public boolean isGles2Required()
{
public boolean isGles2Required() {
return mIsGles2;
}
public boolean isGles3Required()
{
public boolean isGles3Required() {
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
* RGB565 as possible, with or without a depth buffer.
*
*/
private static class SimpleEGLConfigChooser16 extends ComponentSizeChooser {
public SimpleEGLConfigChooser16(boolean withDepthBuffer, boolean stencil, boolean gles2, boolean gles3) {
@ -845,15 +850,18 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
mAlphaSize = 8;
}
}
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);
if(videoDepthBpp == 24)
if (videoDepthBpp == 24)
return new SimpleEGLConfigChooser24(withDepthBuffer, stencil, gles2, gles3);
if(videoDepthBpp == 32)
if (videoDepthBpp == 32)
return new SimpleEGLConfigChooser32(withDepthBuffer, stencil, gles2, gles3);
return null;
};
}
;
/**
* An EGL helper class.
@ -866,9 +874,10 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
/**
* Initialize EGL for a given configuration spec.
*
* @param configSpec
*/
public void start(){
public void start() {
Log.v("SDL", "GLSurfaceView_SDL::EglHelper::start(): creating GL context");
/*
@ -887,7 +896,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
int[] version = new int[2];
mEgl.eglInitialize(mEglDisplay, version);
mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);
if( mEglConfig == null )
if (mEglConfig == null)
Log.e("SDL", "GLSurfaceView_SDL::EglHelper::start(): mEglConfig is NULL");
/*
@ -895,15 +904,15 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* OpenGL context is a somewhat heavy object.
*/
final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
final int[] gles2_attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
final int[] gles3_attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL10.EGL_NONE };
final int[] gles2_attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE};
final int[] gles3_attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL10.EGL_NONE};
mEglContext = mEgl.eglCreateContext(mEglDisplay, mEglConfig,
EGL10.EGL_NO_CONTEXT,
mEGLConfigChooser.isGles3Required() ? gles3_attrib_list :
mEGLConfigChooser.isGles2Required() ? gles2_attrib_list : null );
mEGLConfigChooser.isGles2Required() ? gles2_attrib_list : null);
if( mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT )
if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT)
Log.e("SDL", "GLSurfaceView_SDL::EglHelper::start(): mEglContext is EGL_NO_CONTEXT, error: " + mEgl.eglGetError());
mEglSurface = null;
@ -961,6 +970,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
/**
* Display the current render surface.
*
* @return false if the context has been lost.
*/
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
* to a Renderer instance to do the actual drawing. Can be configured to
* render continuously or on request.
*
*/
class GLThread extends Thread implements SwapBuffersCallback {
GLThread(Renderer renderer) {
@ -1066,7 +1075,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
boolean tellRendererSurfaceCreated = false;
boolean tellRendererSurfaceChanged = false;
while(true) { // Loop until we're re-created GL context and successfully called swap()
while (true) { // Loop until we're re-created GL context and successfully called swap()
int w, h;
boolean changed = false;
@ -1075,19 +1084,16 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
mRenderer.onSurfaceDestroyed();
mEglHelper.finish();
mNeedStart = true;
if( Globals.NonBlockingSwapBuffers )
if (Globals.NonBlockingSwapBuffers)
return false;
}
}
while (needToWait()) {
//Log.v("SDL", "GLSurfaceView_SDL::run(): paused");
synchronized(this) {
try
{
synchronized (this) {
try {
wait(500);
}
catch(InterruptedException e)
{
} catch (InterruptedException e) {
Log.v("SDL", "GLSurfaceView_SDL::GLThread::SwapBuffers(): Who dared to interrupt my slumber?");
Thread.interrupted(); // Clear the flag
}
@ -1124,14 +1130,14 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* Once we're done with GL, we need to call swapBuffers()
* to instruct the system to display the rendered frame
*/
if( !mResetVideoSurface && mEglHelper.swap() )
if (!mResetVideoSurface && mEglHelper.swap())
return true;
// We've lost GL context - recreate it
mResetVideoSurface = false;
mRenderer.onSurfaceDestroyed();
mEglHelper.finish();
mNeedStart = true;
if( Globals.NonBlockingSwapBuffers )
if (Globals.NonBlockingSwapBuffers)
return false;
}
}
@ -1146,10 +1152,10 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
return false;
}
if ( Globals.HorizontalOrientation != (mWidth > mHeight) )
if (Globals.HorizontalOrientation != (mWidth > mHeight))
return true; // Wait until screen orientation changes
if (mPaused || (! mHasSurface)) {
if (mPaused || (!mHasSurface)) {
return true;
}
@ -1162,10 +1168,10 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
}
public void setRenderMode(int renderMode) {
if ( !((RENDERMODE_WHEN_DIRTY <= renderMode) && (renderMode <= RENDERMODE_CONTINUOUSLY)) ) {
if (!((RENDERMODE_WHEN_DIRTY <= renderMode) && (renderMode <= RENDERMODE_CONTINUOUSLY))) {
throw new IllegalArgumentException("renderMode");
}
synchronized(this) {
synchronized (this) {
mRenderMode = renderMode;
if (renderMode == RENDERMODE_CONTINUOUSLY) {
notify();
@ -1174,27 +1180,27 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
}
public int getRenderMode() {
synchronized(this) {
synchronized (this) {
return mRenderMode;
}
}
public void requestRender() {
synchronized(this) {
synchronized (this) {
mRequestRender = true;
notify();
}
}
public void surfaceCreated() {
synchronized(this) {
synchronized (this) {
mHasSurface = true;
notify();
}
}
public void surfaceDestroyed() {
synchronized(this) {
synchronized (this) {
mHasSurface = false;
notify();
}
@ -1230,7 +1236,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
// don't call this from GLThread thread or it is a guaranteed
// deadlock!
Log.v("SDL", "GLSurfaceView_SDL::requestExitAndWait()");
synchronized(this) {
synchronized (this) {
mDone = true;
notify();
}
@ -1243,16 +1249,17 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
/**
* Queue an "event" 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) {
synchronized(this) {
synchronized (this) {
mEventQueue.add(r);
}
}
private Runnable getEvent() {
synchronized(this) {
synchronized (this) {
if (mEventQueue.size() > 0) {
return mEventQueue.remove(0);
}
@ -1287,12 +1294,11 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
}
@Override public void write(char[] buf, int offset, int count) {
for(int i = 0; i < count; i++) {
for (int i = 0; i < count; i++) {
char c = buf[offset + i];
if ( c == '\n') {
if (c == '\n') {
flushBuilder();
}
else {
} else {
mBuilder.append(c);
}
}

View File

@ -22,16 +22,14 @@ freely, subject to the following restrictions:
package io.neoterm;
import java.lang.String;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.lang.reflect.Field;
// 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
class SDL_1_2_Keycodes
{
class SDL_1_2_Keycodes {
public static final int SDLK_UNKNOWN = 0;
public static final int SDLK_BACKSPACE = 8;
public static final int SDLK_TAB = 9;
@ -279,8 +277,7 @@ class SDL_1_2_Keycodes
// 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
class SDL_1_3_Keycodes
{
class SDL_1_3_Keycodes {
public static final int SDLK_UNKNOWN = 0;
public static final int SDLK_A = 4;
public static final int SDLK_B = 5;
@ -533,56 +530,48 @@ class SDL_1_3_Keycodes
public static final int SDLK_NO_REMAP = 512;
}
class SDL_Keys
{
public static String [] names = null;
public static Integer [] values = null;
class SDL_Keys {
public static String[] names = null;
public static Integer[] values = null;
public static String [] namesSorted = null;
public static Integer [] namesSortedIdx = null;
public static Integer [] namesSortedBackIdx = null;
public static String[] namesSorted = null;
public static Integer[] namesSortedIdx = null;
public static Integer[] namesSortedBackIdx = null;
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)
{
for( int f = 0; f < values.length; f++ )
{
if( values[f] == v )
static String getName(int v) {
for (int f = 0; f < values.length; f++) {
if (values[f] == v)
return names[f];
}
return names[0];
}
static
{
ArrayList<String> Names = new ArrayList<String> ();
ArrayList<Integer> Values = new ArrayList<Integer> ();
Field [] fields = SDL_1_2_Keycodes.class.getDeclaredFields();
if( Globals.Using_SDL_1_3 )
{
static {
ArrayList<String> Names = new ArrayList<String>();
ArrayList<Integer> Values = new ArrayList<Integer>();
Field[] fields = SDL_1_2_Keycodes.class.getDeclaredFields();
if (Globals.Using_SDL_1_3) {
fields = SDL_1_3_Keycodes.class.getDeclaredFields();
}
try {
for(Field f: fields)
{
if( !f.getName().startsWith("SDLK_") )
{
for (Field f : fields) {
if (!f.getName().startsWith("SDLK_")) {
continue;
}
Values.add(f.getInt(null));
Names.add(f.getName().substring(5).toUpperCase());
}
} catch(IllegalAccessException e) {};
} catch (IllegalAccessException e) {
}
;
// Sort by value
for( int i = 0; i < Values.size(); i++ )
{
for( int j = i; j < Values.size(); j++ )
{
if( Values.get(i) > Values.get(j) )
{
for (int i = 0; i < Values.size(); i++) {
for (int j = i; j < Values.size(); j++) {
if (Values.get(i) > Values.get(j)) {
int x = Values.get(i);
Values.set(i, Values.get(j));
Values.set(j, x);
@ -599,12 +588,9 @@ class SDL_Keys
namesSortedIdx = new Integer[values.length];
namesSortedBackIdx = new Integer[values.length];
Arrays.sort(namesSorted);
for( int i = 0; i < namesSorted.length; i++ )
{
for( int j = 0; j < namesSorted.length; j++ )
{
if( namesSorted[i].equals( names[j] ) )
{
for (int i = 0; i < namesSorted.length; i++) {
for (int j = 0; j < namesSorted.length; j++) {
if (namesSorted[i].equals(names[j])) {
namesSortedIdx[i] = j;
namesSortedBackIdx[j] = i;
break;

View File

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

View File

@ -28,22 +28,14 @@ import android.os.Environment;
import android.os.StatFs;
import android.util.DisplayMetrics;
import android.util.Log;
import io.neoterm.xorg.NeoXorgViewClient;
import io.neoterm.xorg.R;
import java.io.File;
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.io.*;
import java.util.ArrayList;
import java.util.Locale;
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?
@SuppressWarnings("JniMissingFunction")

View File

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

View File

@ -27,7 +27,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.RectF;
import androidx.appcompat.app.AlertDialog;
import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.MotionEvent;
@ -35,26 +34,23 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import androidx.appcompat.app.AlertDialog;
import io.neoterm.xorg.R;
import java.util.Arrays;
import io.neoterm.xorg.R;
class SettingsMenuKeyboard extends SettingsMenu
{
static class KeyboardConfigMainMenu extends Menu
{
String title(final MainActivity p)
{
class SettingsMenuKeyboard extends SettingsMenu {
static class KeyboardConfigMainMenu extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.controls_screenkb);
}
boolean enabled()
{
boolean enabled() {
return Globals.UseTouchscreenKeyboard;
}
void run (final MainActivity p)
{
void run(final MainActivity p) {
Menu options[] =
{
new ScreenKeyboardThemeConfig(),
@ -70,38 +66,32 @@ class SettingsMenuKeyboard extends SettingsMenu
}
}
static class ScreenKeyboardSizeConfig extends Menu
{
String title(final MainActivity p)
{
static class ScreenKeyboardSizeConfig extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.controls_screenkb_size);
}
void run (final MainActivity p)
{
final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_large),
void run(final MainActivity p) {
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_small),
p.getResources().getString(R.string.controls_screenkb_tiny),
p.getResources().getString(R.string.controls_screenkb_custom) };
p.getResources().getString(R.string.controls_screenkb_custom)};
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_size));
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardSize, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardSize, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.TouchscreenKeyboardSize = item;
dialog.dismiss();
if( Globals.TouchscreenKeyboardSize == Globals.TOUCHSCREEN_KEYBOARD_CUSTOM )
if (Globals.TouchscreenKeyboardSize == Globals.TOUCHSCREEN_KEYBOARD_CUSTOM)
new CustomizeScreenKbLayout().run(p);
else
goBack(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -111,35 +101,29 @@ class SettingsMenuKeyboard extends SettingsMenu
}
}
static class ScreenKeyboardDrawSizeConfig extends Menu
{
String title(final MainActivity p)
{
static class ScreenKeyboardDrawSizeConfig extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.controls_screenkb_drawsize);
}
void run (final MainActivity p)
{
final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_large),
void run(final MainActivity p) {
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_small),
p.getResources().getString(R.string.controls_screenkb_tiny) };
p.getResources().getString(R.string.controls_screenkb_tiny)};
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_drawsize));
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardDrawSize, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardDrawSize, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.TouchscreenKeyboardDrawSize = item;
dialog.dismiss();
goBack(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -149,14 +133,12 @@ class SettingsMenuKeyboard extends SettingsMenu
}
}
static class ScreenKeyboardThemeConfig extends Menu
{
String title(final MainActivity p)
{
static class ScreenKeyboardThemeConfig extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.controls_screenkb_theme);
}
void run (final MainActivity p)
{
void run(final MainActivity p) {
final CharSequence[] items = {
p.getResources().getString(R.string.controls_screenkb_by, "Ultimate Droid", "Sean Stieber"),
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);
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_theme));
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTheme, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTheme, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.TouchscreenKeyboardTheme = item;
dialog.dismiss();
goBack(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -195,36 +173,30 @@ class SettingsMenuKeyboard extends SettingsMenu
}
}
static class ScreenKeyboardTransparencyConfig extends Menu
{
String title(final MainActivity p)
{
static class ScreenKeyboardTransparencyConfig extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.controls_screenkb_transparency);
}
void run (final MainActivity p)
{
final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_trans_0),
void run(final MainActivity p) {
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_2),
p.getResources().getString(R.string.controls_screenkb_trans_3),
p.getResources().getString(R.string.controls_screenkb_trans_4) };
p.getResources().getString(R.string.controls_screenkb_trans_4)};
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_transparency));
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTransparency, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTransparency, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.TouchscreenKeyboardTransparency = item;
dialog.dismiss();
goBack(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -234,34 +206,30 @@ class SettingsMenuKeyboard extends SettingsMenu
}
}
static class RemapHwKeysConfig extends Menu
{
String title(final MainActivity p)
{
static class RemapHwKeysConfig extends Menu {
String title(final MainActivity p) {
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.getVideoLayout().setOnKeyListener(new KeyRemapTool(p));
}
public static class KeyRemapTool implements View.OnKeyListener
{
public static class KeyRemapTool implements View.OnKeyListener {
MainActivity p;
public KeyRemapTool(MainActivity _p)
{
public KeyRemapTool(MainActivity _p) {
p = _p;
}
@Override
public boolean onKey(View v, int keyCode, KeyEvent event)
{
public boolean onKey(View v, int keyCode, KeyEvent event) {
p.getVideoLayout().setOnKeyListener(null);
int keyIndex = keyCode;
if( keyIndex < 0 )
if (keyIndex < 0)
keyIndex = 0;
if( keyIndex > SDL_Keys.JAVA_KEYCODE_LAST )
if (keyIndex > SDL_Keys.JAVA_KEYCODE_LAST)
keyIndex = 0;
final int KeyIndexFinal = keyIndex;
@ -275,29 +243,24 @@ class SettingsMenuKeyboard extends SettingsMenu
p.getResources().getString(R.string.remap_hwkeys_select_more_keys),
};
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] = Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.remap_hwkeys_select_simple);
builder.setItems(items, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
dialog.dismiss();
if( item >= 6 )
if (item >= 6)
ShowAllKeys(KeyIndexFinal);
else
{
else {
Globals.RemapHwKeycode[KeyIndexFinal] = Globals.RemapScreenKbKeycode[item];
goBack(p);
}
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -306,24 +269,20 @@ class SettingsMenuKeyboard extends SettingsMenu
alert.show();
return true;
}
public void ShowAllKeys(final int KeyIndex)
{
public void ShowAllKeys(final int KeyIndex) {
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.remap_hwkeys_select);
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapHwKeycode[KeyIndex]], new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapHwKeycode[KeyIndex]], new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.RemapHwKeycode[KeyIndex] = SDL_Keys.namesSortedIdx[item];
dialog.dismiss();
goBack(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -334,15 +293,13 @@ class SettingsMenuKeyboard extends SettingsMenu
}
}
static class RemapScreenKbConfig extends Menu
{
String title(final MainActivity p)
{
static class RemapScreenKbConfig extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.remap_screenkb);
}
//boolean enabled() { return true; };
void run (final MainActivity p)
{
void run(final MainActivity p) {
CharSequence[] items = {
p.getResources().getString(R.string.remap_screenkb_joystick),
p.getResources().getString(R.string.remap_screenkb_button_text),
@ -355,45 +312,37 @@ class SettingsMenuKeyboard extends SettingsMenu
};
boolean defaults[] = Arrays.copyOf(Globals.ScreenKbControlsShown, Globals.ScreenKbControlsShown.length);
if( Globals.AppUsesSecondJoystick )
{
if (Globals.AppUsesSecondJoystick) {
items = Arrays.copyOf(items, items.length + 1);
items[items.length - 1] = p.getResources().getString(R.string.remap_screenkb_joystick) + " 2";
defaults = Arrays.copyOf(defaults, defaults.length + 1);
defaults[defaults.length - 1] = true;
}
if( Globals.AppUsesThirdJoystick )
{
if (Globals.AppUsesThirdJoystick) {
items = Arrays.copyOf(items, items.length + 1);
items[items.length - 1] = p.getResources().getString(R.string.remap_screenkb_joystick) + " 3";
defaults = Arrays.copyOf(defaults, defaults.length + 1);
defaults[defaults.length - 1] = true;
}
for( int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
items[i+2] = items[i+2] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
for (int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++)
items[i + 2] = items[i + 2] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.remap_screenkb));
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
{
public void onClick(DialogInterface dialog, int item, boolean isChecked)
{
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialog, int item, boolean isChecked) {
Globals.ScreenKbControlsShown[item] = isChecked;
}
});
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
dialog.dismiss();
showRemapScreenKbConfig2(p, 0);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -402,8 +351,7 @@ class SettingsMenuKeyboard extends SettingsMenu
alert.show();
}
static void showRemapScreenKbConfig2(final MainActivity p, final int currentButton)
{
static void showRemapScreenKbConfig2(final MainActivity p, final int currentButton) {
CharSequence[] items = {
p.getResources().getString(R.string.remap_screenkb_button) + " 1",
p.getResources().getString(R.string.remap_screenkb_button) + " 2",
@ -413,36 +361,30 @@ class SettingsMenuKeyboard extends SettingsMenu
p.getResources().getString(R.string.remap_screenkb_button) + " 6",
};
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("_", " ");
if( currentButton >= Globals.RemapScreenKbKeycode.length )
{
if (currentButton >= Globals.RemapScreenKbKeycode.length) {
goBack(p);
return;
}
if( ! Globals.ScreenKbControlsShown[currentButton + 2] )
{
if (!Globals.ScreenKbControlsShown[currentButton + 2]) {
showRemapScreenKbConfig2(p, currentButton + 1);
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(items[currentButton]);
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapScreenKbKeycode[currentButton]], new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapScreenKbKeycode[currentButton]], new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.RemapScreenKbKeycode[currentButton] = SDL_Keys.namesSortedIdx[item];
dialog.dismiss();
showRemapScreenKbConfig2(p, currentButton + 1);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -452,15 +394,13 @@ class SettingsMenuKeyboard extends SettingsMenu
}
}
static class ScreenGesturesConfig extends Menu
{
String title(final MainActivity p)
{
static class ScreenGesturesConfig extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.remap_screenkb_button_gestures);
}
//boolean enabled() { return true; };
void run (final MainActivity p)
{
void run(final MainActivity p) {
CharSequence[] items = {
p.getResources().getString(R.string.remap_screenkb_button_zoomin),
p.getResources().getString(R.string.remap_screenkb_button_zoomout),
@ -477,25 +417,19 @@ class SettingsMenuKeyboard extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.remap_screenkb_button_gestures));
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
{
public void onClick(DialogInterface dialog, int item, boolean isChecked)
{
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialog, int item, boolean isChecked) {
Globals.MultitouchGesturesUsed[item] = isChecked;
}
});
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
dialog.dismiss();
showScreenGesturesConfig2(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -504,8 +438,7 @@ class SettingsMenuKeyboard extends SettingsMenu
alert.show();
}
static void showScreenGesturesConfig2(final MainActivity p)
{
static void showScreenGesturesConfig2(final MainActivity p) {
final CharSequence[] items = {
p.getResources().getString(R.string.accel_slow),
p.getResources().getString(R.string.accel_medium),
@ -515,20 +448,16 @@ class SettingsMenuKeyboard extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.remap_screenkb_button_gestures_sensitivity);
builder.setSingleChoiceItems(items, Globals.MultitouchGestureSensitivity, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(items, Globals.MultitouchGestureSensitivity, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.MultitouchGestureSensitivity = item;
dialog.dismiss();
showScreenGesturesConfig3(p, 0);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -537,8 +466,7 @@ class SettingsMenuKeyboard extends SettingsMenu
alert.show();
}
static void showScreenGesturesConfig3(final MainActivity p, final int currentButton)
{
static void showScreenGesturesConfig3(final MainActivity p, final int currentButton) {
CharSequence[] items = {
p.getResources().getString(R.string.remap_screenkb_button_zoomin),
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),
};
if( currentButton >= Globals.RemapMultitouchGestureKeycode.length )
{
if (currentButton >= Globals.RemapMultitouchGestureKeycode.length) {
goBack(p);
return;
}
if( ! Globals.MultitouchGesturesUsed[currentButton] )
{
if (!Globals.MultitouchGesturesUsed[currentButton]) {
showScreenGesturesConfig3(p, currentButton + 1);
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(items[currentButton]);
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapMultitouchGestureKeycode[currentButton]], new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapMultitouchGestureKeycode[currentButton]], new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.RemapMultitouchGestureKeycode[currentButton] = SDL_Keys.namesSortedIdx[item];
dialog.dismiss();
showScreenGesturesConfig3(p, currentButton + 1);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -582,22 +504,19 @@ class SettingsMenuKeyboard extends SettingsMenu
}
}
static class CustomizeScreenKbLayout extends Menu
{
String title(final MainActivity p)
{
static class CustomizeScreenKbLayout extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.screenkb_custom_layout);
}
//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));
CustomizeScreenKbLayoutTool tool = new CustomizeScreenKbLayoutTool(p);
Globals.TouchscreenKeyboardSize = Globals.TOUCHSCREEN_KEYBOARD_CUSTOM;
}
static class CustomizeScreenKbLayoutTool implements View.OnTouchListener, View.OnKeyListener
{
static class CustomizeScreenKbLayoutTool implements View.OnTouchListener, View.OnKeyListener {
MainActivity p;
FrameLayout layout = null;
ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length];
@ -620,8 +539,7 @@ class SettingsMenuKeyboard extends SettingsMenu
int oldX = 0, oldY = 0;
boolean resizing = false;
public CustomizeScreenKbLayoutTool(MainActivity _p)
{
public CustomizeScreenKbLayoutTool(MainActivity _p) {
p = _p;
layout = new FrameLayout(p);
p.getVideoLayout().addView(layout);
@ -633,13 +551,12 @@ class SettingsMenuKeyboard extends SettingsMenu
boundary = new ImageView(p);
boundary.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
boundary.setScaleType(ImageView.ScaleType.MATRIX);
boundaryBmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.rectangle );
boundaryBmp = BitmapFactory.decodeResource(p.getResources(), R.drawable.rectangle);
boundary.setImageBitmap(boundaryBmp);
layout.addView(boundary);
currentButton = -1;
if( Globals.TouchscreenKeyboardTheme == 2 )
{
buttons = new int[] {
if (Globals.TouchscreenKeyboardTheme == 2) {
buttons = new int[]{
R.drawable.sun_dpad,
R.drawable.sun_keyboard,
R.drawable.sun_b1,
@ -660,41 +577,37 @@ class SettingsMenuKeyboard extends SettingsMenu
p.getWindowManager().getDefaultDisplay().getMetrics(dm);
displayX = dm.widthPixels;
displayY = dm.heightPixels;
} catch (Exception eeeee) {}
} catch (Exception eeeee) {
}
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
{
if( ! Globals.ScreenKbControlsShown[i] )
for (int i = 0; i < Globals.ScreenKbControlsLayout.length; i++) {
if (!Globals.ScreenKbControlsShown[i])
continue;
if( currentButton == -1 )
if (currentButton == -1)
currentButton = i;
//Log.i("SDL", "Screen kb button " + i + " coords " + Globals.ScreenKbControlsLayout[i][0] + ":" + Globals.ScreenKbControlsLayout[i][1] + ":" + Globals.ScreenKbControlsLayout[i][2] + ":" + Globals.ScreenKbControlsLayout[i][3] );
// Check if the button is off screen edge or shrunk to zero
if( Globals.ScreenKbControlsLayout[i][0] > Globals.ScreenKbControlsLayout[i][2] - displayY/12 )
Globals.ScreenKbControlsLayout[i][0] = Globals.ScreenKbControlsLayout[i][2] - displayY/12;
if( Globals.ScreenKbControlsLayout[i][1] > Globals.ScreenKbControlsLayout[i][3] - displayY/12 )
Globals.ScreenKbControlsLayout[i][1] = Globals.ScreenKbControlsLayout[i][3] - displayY/12;
if( 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 )
Globals.ScreenKbControlsLayout[i][1] = Globals.ScreenKbControlsLayout[i][3] - displayY*2/3;
if( Globals.ScreenKbControlsLayout[i][0] < 0 )
{
if (Globals.ScreenKbControlsLayout[i][0] > Globals.ScreenKbControlsLayout[i][2] - displayY / 12)
Globals.ScreenKbControlsLayout[i][0] = Globals.ScreenKbControlsLayout[i][2] - displayY / 12;
if (Globals.ScreenKbControlsLayout[i][1] > Globals.ScreenKbControlsLayout[i][3] - displayY / 12)
Globals.ScreenKbControlsLayout[i][1] = Globals.ScreenKbControlsLayout[i][3] - displayY / 12;
if (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)
Globals.ScreenKbControlsLayout[i][1] = Globals.ScreenKbControlsLayout[i][3] - displayY * 2 / 3;
if (Globals.ScreenKbControlsLayout[i][0] < 0) {
Globals.ScreenKbControlsLayout[i][2] += -Globals.ScreenKbControlsLayout[i][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][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][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][3] = displayY;
}
@ -703,7 +616,7 @@ class SettingsMenuKeyboard extends SettingsMenu
imgs[i] = new ImageView(p);
imgs[i].setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
imgs[i].setScaleType(ImageView.ScaleType.MATRIX);
bmps[i] = BitmapFactory.decodeResource( p.getResources(), buttons[i] );
bmps[i] = BitmapFactory.decodeResource(p.getResources(), buttons[i]);
imgs[i].setImageBitmap(bmps[i]);
imgs[i].setAlpha(128);
layout.addView(imgs[i]);
@ -715,14 +628,13 @@ class SettingsMenuKeyboard extends SettingsMenu
imgs[i].setImageMatrix(m);
}
boundary.bringToFront();
if( currentButton == -1 )
onKey( null, KeyEvent.KEYCODE_BACK, null ); // All buttons disabled - do not show anything
if (currentButton == -1)
onKey(null, KeyEvent.KEYCODE_BACK, null); // All buttons disabled - do not show anything
else
setupButton(currentButton);
}
void setupButton(int i)
{
void setupButton(int i) {
Matrix m = new Matrix();
RectF src = new RectF(0, 0, bmps[i].getWidth(), bmps[i].getHeight());
RectF dst = new RectF(Globals.ScreenKbControlsLayout[i][0], Globals.ScreenKbControlsLayout[i][1],
@ -734,38 +646,34 @@ class SettingsMenuKeyboard extends SettingsMenu
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
boundary.setImageMatrix(m);
String buttonText = "";
if( i >= 2 && i <= 7 )
if (i >= 2 && i <= 7)
buttonText = p.getResources().getString(R.string.remap_screenkb_button) + (i - 2);
if( i >= 2 && i - 2 < Globals.AppTouchscreenKeyboardKeysNames.length )
if (i >= 2 && i - 2 < Globals.AppTouchscreenKeyboardKeysNames.length)
buttonText = Globals.AppTouchscreenKeyboardKeysNames[i - 2].replace("_", " ");
if( i == 0 )
if (i == 0)
buttonText = "Joystick";
if( i == 1 )
if (i == 1)
buttonText = "Text input";
if( i == 8 )
if (i == 8)
buttonText = "Joystick 2";
if( i == 9 )
if (i == 9)
buttonText = "Joystick 3";
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help) + "\n" + buttonText);
}
@Override
public boolean onTouch(View v, MotionEvent ev)
{
if( ev.getAction() == MotionEvent.ACTION_DOWN )
{
oldX = (int)ev.getX();
oldY = (int)ev.getY();
public boolean onTouch(View v, MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
oldX = (int) ev.getX();
oldY = (int) ev.getY();
resizing = true;
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
{
if( ! Globals.ScreenKbControlsShown[i] )
for (int i = 0; i < Globals.ScreenKbControlsLayout.length; i++) {
if (!Globals.ScreenKbControlsShown[i])
continue;
if( Globals.ScreenKbControlsLayout[i][0] <= oldX &&
if (Globals.ScreenKbControlsLayout[i][0] <= oldX &&
Globals.ScreenKbControlsLayout[i][2] >= oldX &&
Globals.ScreenKbControlsLayout[i][1] <= oldY &&
Globals.ScreenKbControlsLayout[i][3] >= oldY )
{
Globals.ScreenKbControlsLayout[i][3] >= oldY) {
currentButton = i;
setupButton(currentButton);
resizing = false;
@ -773,30 +681,24 @@ class SettingsMenuKeyboard extends SettingsMenu
}
}
}
if( ev.getAction() == MotionEvent.ACTION_MOVE )
{
int dx = (int)ev.getX() - oldX;
int dy = (int)ev.getY() - oldY;
if( resizing )
{
if (ev.getAction() == MotionEvent.ACTION_MOVE) {
int dx = (int) ev.getX() - oldX;
int dy = (int) ev.getY() - oldY;
if (resizing) {
// Resize slowly, with 1/3 of movement speed
dx /= 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][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][3] -= dy;
}
dx *= 6;
dy *= 6;
}
else
{
} else {
Globals.ScreenKbControlsLayout[currentButton][0] += dx;
Globals.ScreenKbControlsLayout[currentButton][2] += dx;
Globals.ScreenKbControlsLayout[currentButton][1] += dy;
@ -819,10 +721,8 @@ class SettingsMenuKeyboard extends SettingsMenu
}
@Override
public boolean onKey(View v, int keyCode, KeyEvent event)
{
if( keyCode == KeyEvent.KEYCODE_BACK )
{
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
p.getVideoLayout().removeView(layout);
layout = null;
goBack(p);
@ -832,15 +732,13 @@ class SettingsMenuKeyboard extends SettingsMenu
}
}
static class ScreenKeyboardAdvanced extends Menu
{
String title(final MainActivity p)
{
static class ScreenKeyboardAdvanced extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.advanced);
}
//boolean enabled() { return true; };
void run (final MainActivity p)
{
void run(final MainActivity p) {
CharSequence[] items = {
p.getResources().getString(R.string.screenkb_floating_joystick),
};
@ -851,26 +749,20 @@ class SettingsMenuKeyboard extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.advanced));
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
{
public void onClick(DialogInterface dialog, int item, boolean isChecked)
{
if( item == 0 )
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialog, int item, boolean isChecked) {
if (item == 0)
Globals.FloatingScreenJoystick = isChecked;
}
});
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
dialog.dismiss();
goBack(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});

View File

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

View File

@ -27,33 +27,29 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.RectF;
import androidx.appcompat.app.AlertDialog;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.appcompat.app.AlertDialog;
import io.neoterm.xorg.R;
import java.util.ArrayList;
import io.neoterm.xorg.R;
class SettingsMenuMouse extends SettingsMenu
{
static class MouseConfigMainMenu extends Menu
{
String title(final MainActivity p)
{
class SettingsMenuMouse extends SettingsMenu {
static class MouseConfigMainMenu extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.mouse_emulation);
}
boolean enabled()
{
boolean enabled() {
return Globals.AppUsesMouse;
}
void run (final MainActivity p)
{
void run(final MainActivity p) {
Menu options[] =
{
new DisplaySizeConfig(false),
@ -69,23 +65,22 @@ class SettingsMenuMouse extends SettingsMenu
}
}
static class DisplaySizeConfig extends Menu
{
static class DisplaySizeConfig extends Menu {
boolean firstStart = false;
DisplaySizeConfig()
{
DisplaySizeConfig() {
this.firstStart = true;
}
DisplaySizeConfig(boolean firstStart)
{
DisplaySizeConfig(boolean firstStart) {
this.firstStart = firstStart;
}
String title(final MainActivity p)
{
String title(final MainActivity p) {
return p.getResources().getString(R.string.display_size_mouse);
}
void run (final MainActivity p)
{
void run(final MainActivity p) {
CharSequence[] items = {
p.getResources().getString(R.string.display_size_small),
p.getResources().getString(R.string.display_size_small_touchpad),
@ -98,8 +93,7 @@ class SettingsMenuMouse extends SettingsMenu
int _size_desktop = 3;
int _more_options = 4;
if( ! Globals.SwVideoMode )
{
if (!Globals.SwVideoMode) {
CharSequence[] items2 = {
p.getResources().getString(R.string.display_size_small_touchpad),
p.getResources().getString(R.string.display_size_large),
@ -111,8 +105,7 @@ class SettingsMenuMouse extends SettingsMenu
_size_desktop = 2;
_size_small = 1000;
}
if( firstStart )
{
if (firstStart) {
CharSequence[] items2 = {
p.getResources().getString(R.string.display_size_small),
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),
};
items = items2;
if( ! Globals.SwVideoMode )
{
if (!Globals.SwVideoMode) {
CharSequence[] items3 = {
p.getResources().getString(R.string.display_size_small_touchpad),
p.getResources().getString(R.string.display_size_large),
@ -142,41 +134,34 @@ class SettingsMenuMouse extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.display_size);
class ClickListener implements DialogInterface.OnClickListener
{
public void onClick(DialogInterface dialog, int item)
{
class ClickListener implements DialogInterface.OnClickListener {
public void onClick(DialogInterface dialog, int item) {
dialog.dismiss();
if( item == size_desktop )
{
if (item == size_desktop) {
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NORMAL;
Globals.RelativeMouseMovement = false;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
Globals.ForceHardwareMouse = true;
}
if( item == size_large )
{
if (item == size_large) {
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NORMAL;
Globals.RelativeMouseMovement = false;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
Globals.ForceHardwareMouse = false;
}
if( item == size_small )
{
if (item == size_small) {
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR;
Globals.RelativeMouseMovement = false;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_MAGNIFIER;
Globals.ForceHardwareMouse = false;
}
if( item == size_small_touchpad )
{
if (item == size_small_touchpad) {
Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT;
Globals.RelativeMouseMovement = true;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
Globals.ForceHardwareMouse = false;
}
if( item == more_options )
{
if (item == more_options) {
menuStack.clear();
new MainMenu().run(p);
return;
@ -194,10 +179,8 @@ class SettingsMenuMouse extends SettingsMenu
Globals.ShowScreenUnderFinger + 1,
new ClickListener());
*/
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -207,43 +190,37 @@ class SettingsMenuMouse extends SettingsMenu
}
}
static class LeftClickConfig extends Menu
{
String title(final MainActivity p)
{
static class LeftClickConfig extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.leftclick_question);
}
void run (final MainActivity p)
{
final CharSequence[] items = { p.getResources().getString(R.string.leftclick_normal),
void run(final MainActivity p) {
final CharSequence[] items = {p.getResources().getString(R.string.leftclick_normal),
p.getResources().getString(R.string.leftclick_near_cursor),
p.getResources().getString(R.string.leftclick_multitouch),
p.getResources().getString(R.string.leftclick_pressure),
p.getResources().getString(R.string.rightclick_key),
p.getResources().getString(R.string.leftclick_timeout),
p.getResources().getString(R.string.leftclick_tap),
p.getResources().getString(R.string.leftclick_tap_or_timeout) };
p.getResources().getString(R.string.leftclick_tap_or_timeout)};
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.leftclick_question);
builder.setSingleChoiceItems(items, Globals.LeftClickMethod, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(items, Globals.LeftClickMethod, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
dialog.dismiss();
Globals.LeftClickMethod = item;
if( item == Mouse.LEFT_CLICK_WITH_KEY )
if (item == Mouse.LEFT_CLICK_WITH_KEY)
p.getVideoLayout().setOnKeyListener(new KeyRemapToolMouseClick(p, true));
else if( item == Mouse.LEFT_CLICK_WITH_TIMEOUT || item == Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT )
else if (item == Mouse.LEFT_CLICK_WITH_TIMEOUT || item == Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT)
showLeftClickTimeoutConfig(p);
else
goBack(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -251,28 +228,25 @@ class SettingsMenuMouse extends SettingsMenu
alert.setOwnerActivity(p);
alert.show();
}
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_2),
p.getResources().getString(R.string.leftclick_timeout_time_3),
p.getResources().getString(R.string.leftclick_timeout_time_4) };
p.getResources().getString(R.string.leftclick_timeout_time_4)};
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.leftclick_timeout_time);
builder.setSingleChoiceItems(items, Globals.LeftClickTimeout, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(items, Globals.LeftClickTimeout, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.LeftClickTimeout = item;
dialog.dismiss();
goBack(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -282,44 +256,38 @@ class SettingsMenuMouse extends SettingsMenu
}
}
static class RightClickConfig extends Menu
{
String title(final MainActivity p)
{
static class RightClickConfig extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.rightclick_question);
}
boolean enabled()
{
boolean enabled() {
return Globals.AppNeedsTwoButtonMouse;
}
void run (final MainActivity p)
{
final CharSequence[] items = { p.getResources().getString(R.string.rightclick_none),
void run(final MainActivity p) {
final CharSequence[] items = {p.getResources().getString(R.string.rightclick_none),
p.getResources().getString(R.string.rightclick_multitouch),
p.getResources().getString(R.string.rightclick_pressure),
p.getResources().getString(R.string.rightclick_key),
p.getResources().getString(R.string.leftclick_timeout) };
p.getResources().getString(R.string.leftclick_timeout)};
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.rightclick_question);
builder.setSingleChoiceItems(items, Globals.RightClickMethod, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(items, Globals.RightClickMethod, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.RightClickMethod = item;
dialog.dismiss();
if( item == Mouse.RIGHT_CLICK_WITH_KEY )
if (item == Mouse.RIGHT_CLICK_WITH_KEY)
p.getVideoLayout().setOnKeyListener(new KeyRemapToolMouseClick(p, false));
else if( item == Mouse.RIGHT_CLICK_WITH_TIMEOUT )
else if (item == Mouse.RIGHT_CLICK_WITH_TIMEOUT)
showRightClickTimeoutConfig(p);
else
goBack(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -329,27 +297,23 @@ class SettingsMenuMouse extends SettingsMenu
}
static void showRightClickTimeoutConfig(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_2),
p.getResources().getString(R.string.leftclick_timeout_time_3),
p.getResources().getString(R.string.leftclick_timeout_time_4) };
p.getResources().getString(R.string.leftclick_timeout_time_4)};
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.leftclick_timeout_time);
builder.setSingleChoiceItems(items, Globals.RightClickTimeout, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(items, Globals.RightClickTimeout, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.RightClickTimeout = item;
dialog.dismiss();
goBack(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -359,28 +323,26 @@ class SettingsMenuMouse extends SettingsMenu
}
}
public static class KeyRemapToolMouseClick implements View.OnKeyListener
{
public static class KeyRemapToolMouseClick implements View.OnKeyListener {
MainActivity p;
boolean leftClick;
public KeyRemapToolMouseClick(MainActivity _p, boolean leftClick)
{
public KeyRemapToolMouseClick(MainActivity _p, boolean leftClick) {
p = _p;
p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
this.leftClick = leftClick;
}
@Override
public boolean onKey(View v, int keyCode, KeyEvent event)
{
public boolean onKey(View v, int keyCode, KeyEvent event) {
p.getVideoLayout().setOnKeyListener(null);
int keyIndex = keyCode;
if( keyIndex < 0 )
if (keyIndex < 0)
keyIndex = 0;
if( keyIndex > SDL_Keys.JAVA_KEYCODE_LAST )
if (keyIndex > SDL_Keys.JAVA_KEYCODE_LAST)
keyIndex = 0;
if( leftClick )
if (leftClick)
Globals.LeftClickKey = keyIndex;
else
Globals.RightClickKey = keyIndex;
@ -390,14 +352,12 @@ class SettingsMenuMouse extends SettingsMenu
}
}
static class AdditionalMouseConfig extends Menu
{
String title(final MainActivity p)
{
static class AdditionalMouseConfig extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.advanced);
}
void run (final MainActivity p)
{
void run(final MainActivity p) {
CharSequence[] items = {
p.getResources().getString(R.string.mouse_hover_jitter_filter),
p.getResources().getString(R.string.mouse_joystickmouse),
@ -420,38 +380,32 @@ class SettingsMenuMouse extends SettingsMenu
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.advanced));
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
{
public void onClick(DialogInterface dialog, int item, boolean isChecked)
{
if( item == 0 )
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialog, int item, boolean isChecked) {
if (item == 0)
Globals.HoverJitterFilter = isChecked;
if( item == 1 )
if (item == 1)
Globals.MoveMouseWithJoystick = isChecked;
if( item == 2 )
if (item == 2)
Globals.ClickMouseWithDpad = isChecked;
if( item == 3 )
if (item == 3)
Globals.RelativeMouseMovement = isChecked;
if( item == 4 )
if (item == 4)
Globals.MoveMouseWithGyroscope = isChecked;
if( item == 5 )
if (item == 5)
Globals.FingerHover = isChecked;
if( item == 6 )
if (item == 6)
Globals.GenerateSubframeTouchEvents = isChecked;
}
});
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
dialog.dismiss();
showGyroscopeMouseMovementConfig(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -460,36 +414,30 @@ class SettingsMenuMouse extends SettingsMenu
alert.show();
}
static void showGyroscopeMouseMovementConfig(final MainActivity p)
{
if( !Globals.MoveMouseWithGyroscope )
{
static void showGyroscopeMouseMovementConfig(final MainActivity p) {
if (!Globals.MoveMouseWithGyroscope) {
showRelativeMouseMovementConfig(p);
return;
}
final CharSequence[] items = { p.getResources().getString(R.string.accel_veryslow),
final CharSequence[] items = {p.getResources().getString(R.string.accel_veryslow),
p.getResources().getString(R.string.accel_slow),
p.getResources().getString(R.string.accel_medium),
p.getResources().getString(R.string.accel_fast),
p.getResources().getString(R.string.accel_veryfast) };
p.getResources().getString(R.string.accel_veryfast)};
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.mouse_gyroscope_mouse_sensitivity);
builder.setSingleChoiceItems(items, Globals.MoveMouseWithGyroscopeSpeed, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(items, Globals.MoveMouseWithGyroscopeSpeed, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.MoveMouseWithGyroscopeSpeed = item;
dialog.dismiss();
showRelativeMouseMovementConfig(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -498,36 +446,30 @@ class SettingsMenuMouse extends SettingsMenu
alert.show();
}
static void showRelativeMouseMovementConfig(final MainActivity p)
{
if( !Globals.RelativeMouseMovement )
{
static void showRelativeMouseMovementConfig(final MainActivity p) {
if (!Globals.RelativeMouseMovement) {
goBack(p);
return;
}
final CharSequence[] items = { p.getResources().getString(R.string.accel_veryslow),
final CharSequence[] items = {p.getResources().getString(R.string.accel_veryslow),
p.getResources().getString(R.string.accel_slow),
p.getResources().getString(R.string.accel_medium),
p.getResources().getString(R.string.accel_fast),
p.getResources().getString(R.string.accel_veryfast) };
p.getResources().getString(R.string.accel_veryfast)};
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.mouse_relative_speed);
builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementSpeed, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementSpeed, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.RelativeMouseMovementSpeed = item;
dialog.dismiss();
showRelativeMouseMovementConfig1(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -536,29 +478,24 @@ class SettingsMenuMouse extends SettingsMenu
alert.show();
}
static void showRelativeMouseMovementConfig1(final MainActivity p)
{
final CharSequence[] items = { p.getResources().getString(R.string.none),
static void showRelativeMouseMovementConfig1(final MainActivity p) {
final CharSequence[] items = {p.getResources().getString(R.string.none),
p.getResources().getString(R.string.accel_slow),
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);
builder.setTitle(R.string.mouse_relative_accel);
builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementAccel, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementAccel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.RelativeMouseMovementAccel = item;
dialog.dismiss();
goBack(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -568,38 +505,34 @@ class SettingsMenuMouse extends SettingsMenu
}
}
static class JoystickMouseConfig extends Menu
{
String title(final MainActivity p)
{
static class JoystickMouseConfig extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.mouse_joystickmousespeed);
}
boolean enabled()
{
boolean enabled() {
return Globals.MoveMouseWithJoystick;
};
void run (final MainActivity p)
{
final CharSequence[] items = { p.getResources().getString(R.string.accel_slow),
}
;
void run(final MainActivity p) {
final CharSequence[] items = {p.getResources().getString(R.string.accel_slow),
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);
builder.setTitle(R.string.mouse_joystickmousespeed);
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickSpeed, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickSpeed, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.MoveMouseWithJoystickSpeed = item;
dialog.dismiss();
showJoystickMouseAccelConfig(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -608,29 +541,24 @@ class SettingsMenuMouse extends SettingsMenu
alert.show();
}
static void showJoystickMouseAccelConfig(final MainActivity p)
{
final CharSequence[] items = { p.getResources().getString(R.string.none),
static void showJoystickMouseAccelConfig(final MainActivity p) {
final CharSequence[] items = {p.getResources().getString(R.string.none),
p.getResources().getString(R.string.accel_slow),
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);
builder.setTitle(R.string.mouse_joystickmouseaccel);
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickAccel, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickAccel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Globals.MoveMouseWithJoystickAccel = item;
dialog.dismiss();
goBack(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
goBack(p);
}
});
@ -640,47 +568,44 @@ class SettingsMenuMouse extends SettingsMenu
}
}
static class TouchPressureMeasurementTool extends Menu
{
String title(final MainActivity p)
{
static class TouchPressureMeasurementTool extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.measurepressure);
}
boolean enabled()
{
boolean enabled() {
return Globals.RightClickMethod == Mouse.RIGHT_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.getVideoLayout().setOnTouchListener(new TouchMeasurementTool(p));
}
public static class TouchMeasurementTool implements View.OnTouchListener
{
public static class TouchMeasurementTool implements View.OnTouchListener {
MainActivity p;
ArrayList<Integer> force = new ArrayList<Integer>();
ArrayList<Integer> radius = new ArrayList<Integer>();
static final int maxEventAmount = 100;
public TouchMeasurementTool(MainActivity _p)
{
public TouchMeasurementTool(MainActivity _p) {
p = _p;
}
@Override
public boolean onTouch(View v, MotionEvent ev)
{
force.add(new Integer((int)(ev.getPressure() * 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)));
public boolean onTouch(View v, MotionEvent ev) {
force.add(new Integer((int) (ev.getPressure() * 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)));
try {
Thread.sleep(10L);
} catch (InterruptedException e) { }
} catch (InterruptedException e) {
}
if( force.size() >= maxEventAmount )
{
if (force.size() >= maxEventAmount) {
p.getVideoLayout().setOnTouchListener(null);
Globals.ClickScreenPressure = getAverageForce();
Globals.ClickScreenTouchspotSize = getAverageRadius();
@ -690,20 +615,17 @@ class SettingsMenuMouse extends SettingsMenu
return true;
}
int getAverageForce()
{
int getAverageForce() {
int avg = 0;
for(Integer f: force)
{
for (Integer f : force) {
avg += f;
}
return avg / force.size();
}
int getAverageRadius()
{
int getAverageRadius() {
int avg = 0;
for(Integer r: radius)
{
for (Integer r : radius) {
avg += r;
}
return avg / radius.size();
@ -711,15 +633,13 @@ class SettingsMenuMouse extends SettingsMenu
}
}
static class CalibrateTouchscreenMenu extends Menu
{
String title(final MainActivity p)
{
static class CalibrateTouchscreenMenu extends Menu {
String title(final MainActivity p) {
return p.getResources().getString(R.string.calibrate_touchscreen);
}
//boolean enabled() { return true; };
void run (final MainActivity p)
{
void run(final MainActivity p) {
p.setText(p.getResources().getString(R.string.calibrate_touchscreen_touch));
Globals.TouchscreenCalibration[0] = 0;
Globals.TouchscreenCalibration[1] = 0;
@ -730,19 +650,17 @@ class SettingsMenuMouse extends SettingsMenu
p.getVideoLayout().setOnKeyListener(tool);
}
static class ScreenEdgesCalibrationTool implements View.OnTouchListener, View.OnKeyListener
{
static class ScreenEdgesCalibrationTool implements View.OnTouchListener, View.OnKeyListener {
MainActivity p;
ImageView img;
Bitmap bmp;
public ScreenEdgesCalibrationTool(MainActivity _p)
{
public ScreenEdgesCalibrationTool(MainActivity _p) {
p = _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));
img.setScaleType(ImageView.ScaleType.MATRIX);
bmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.calibrate );
bmp = BitmapFactory.decodeResource(p.getResources(), R.drawable.calibrate);
img.setImageBitmap(bmp);
Matrix m = new Matrix();
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
@ -754,25 +672,23 @@ class SettingsMenuMouse extends SettingsMenu
}
@Override
public boolean onTouch(View v, MotionEvent ev)
{
if( Globals.TouchscreenCalibration[0] == Globals.TouchscreenCalibration[1] &&
public boolean onTouch(View v, MotionEvent ev) {
if (Globals.TouchscreenCalibration[0] == Globals.TouchscreenCalibration[1] &&
Globals.TouchscreenCalibration[1] == Globals.TouchscreenCalibration[2] &&
Globals.TouchscreenCalibration[2] == Globals.TouchscreenCalibration[3] )
{
Globals.TouchscreenCalibration[0] = (int)ev.getX();
Globals.TouchscreenCalibration[1] = (int)ev.getY();
Globals.TouchscreenCalibration[2] = (int)ev.getX();
Globals.TouchscreenCalibration[3] = (int)ev.getY();
Globals.TouchscreenCalibration[2] == Globals.TouchscreenCalibration[3]) {
Globals.TouchscreenCalibration[0] = (int) ev.getX();
Globals.TouchscreenCalibration[1] = (int) ev.getY();
Globals.TouchscreenCalibration[2] = (int) ev.getX();
Globals.TouchscreenCalibration[3] = (int) ev.getY();
}
if( ev.getX() < Globals.TouchscreenCalibration[0] )
Globals.TouchscreenCalibration[0] = (int)ev.getX();
if( ev.getY() < Globals.TouchscreenCalibration[1] )
Globals.TouchscreenCalibration[1] = (int)ev.getY();
if( ev.getX() > Globals.TouchscreenCalibration[2] )
Globals.TouchscreenCalibration[2] = (int)ev.getX();
if( ev.getY() > Globals.TouchscreenCalibration[3] )
Globals.TouchscreenCalibration[3] = (int)ev.getY();
if (ev.getX() < Globals.TouchscreenCalibration[0])
Globals.TouchscreenCalibration[0] = (int) ev.getX();
if (ev.getY() < Globals.TouchscreenCalibration[1])
Globals.TouchscreenCalibration[1] = (int) ev.getY();
if (ev.getX() > Globals.TouchscreenCalibration[2])
Globals.TouchscreenCalibration[2] = (int) ev.getX();
if (ev.getY() > Globals.TouchscreenCalibration[3])
Globals.TouchscreenCalibration[3] = (int) ev.getY();
Matrix m = new Matrix();
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
RectF dst = new RectF(Globals.TouchscreenCalibration[0], Globals.TouchscreenCalibration[1],
@ -783,8 +699,7 @@ class SettingsMenuMouse extends SettingsMenu
}
@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().setOnKeyListener(null);
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;
import java.io.InputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.EOFException;
import android.util.Log;
import java.io.InputStream;
/**
* 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
* 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 InputStream in = null;
private final byte[] inBuf = new byte[8192];
@ -46,36 +42,29 @@ public class XZInputStream extends InputStream
private final byte[] tempBuf = new byte[1];
public XZInputStream(InputStream in) throws IOException
{
public XZInputStream(InputStream in) throws IOException {
this.in = in;
if (in == null)
{
if (in == null) {
throw new NullPointerException("InputStream == null");
}
nativeData = nativeInit();
if (nativeData == 0)
{
if (nativeData == 0) {
throw new OutOfMemoryError("Cannot initialize JNI liblzma object");
}
}
@Override
public int available() throws IOException
{
public int available() throws IOException {
return 0; // Don't care
}
@Override
public void close() throws IOException
{
synchronized (this)
{
public void close() throws IOException {
synchronized (this) {
if (nativeData != 0)
nativeClose(nativeData);
nativeData = 0;
if (in != null)
{
if (in != null) {
try {
in.close();
} finally {
@ -86,8 +75,7 @@ public class XZInputStream extends InputStream
}
@Override
protected void finalize() throws IOException
{
protected void finalize() throws IOException {
try {
close();
} finally {
@ -100,14 +88,12 @@ public class XZInputStream extends InputStream
}
@Override
public int read() throws IOException
{
public int read() throws IOException {
return read(tempBuf, 0, 1) == -1 ? -1 : (tempBuf[0] & 0xFF);
}
@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 +
// " inOffset " + inOffset + " inAvailable " + inAvailable);
if (outBufEof)
@ -117,8 +103,7 @@ public class XZInputStream extends InputStream
int oldOutOffset = outOffset;
if (inOffset >= inAvailable && inAvailable != -1)
{
if (inOffset >= inAvailable && inAvailable != -1) {
inAvailable = in.read(inBuf, 0, inBuf.length);
inOffset = 0;
//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 +
// " inOffset " + inOffset + " inAvailable " + inAvailable + " ret " + ret);
if (ret != 0)
{
if (ret == 1)
{
if (ret != 0) {
if (ret == 1) {
if (inOffset < inAvailable)
throw new IOException("Garbage at the end of LZMA stream");
if (inAvailable != -1)
@ -143,9 +126,7 @@ public class XZInputStream extends InputStream
if (inAvailable != -1)
throw new IOException("Garbage at the end of LZMA stream");
outBufEof = true;
}
else
{
} else {
throw new IOException("LZMA error " + ret);
}
}
@ -155,7 +136,9 @@ public class XZInputStream extends InputStream
}
private native long nativeInit();
private native void nativeClose(long nativeData);
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.view.Window;
import android.view.WindowManager;
import io.neoterm.NeoGLView;
/**

View File

@ -9,7 +9,7 @@
<string name="download_unneeded">没有需要下载的内容</string>
<string name="connecting_to">正在连接到 %s</string>
<string name="failed_connecting_to">连接到 %s 失败</string>
<string name="error_connecting_to"> %s 连接出错</string>
<string name="error_connecting_to">%s 连接出错</string>
<string name="dl_from">正在从 %s 下载数据</string>
<string name="error_dl_from">从 %s 下载数据时出错</string>
<string name="error_write">写入到 %s 时出错</string>
@ -189,7 +189,9 @@
<!-- Play Game Services strings -->
<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_unknown_error">未知错误。</string>
<string name="accessing_network">正在访问网络,请稍候</string>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="left" type="id" />
<item name="right" type="id" />
<item name="top" type="id" />
<item name="bottom" type="id" />
<item name="left" type="id"/>
<item name="right" type="id"/>
<item name="top" type="id"/>
<item name="bottom" type="id"/>
</resources>

View File

@ -151,7 +151,8 @@
<string name="video">Video settings</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_autodetect">Auto-detect screen orientation</string>
<string name="video_bpp_24">24 bpp screen color depth</string>
@ -190,8 +191,13 @@
<string name="no">No</string>
<!-- 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_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_sign_in_failed">Failed to sign in. Please check your network connection and try again.
</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_unknown_error">Unknown error.</string>
<string name="accessing_network">Accessing network, please wait</string>

View File

@ -1,49 +1,50 @@
<?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">
<Row>
<Key android:codes="45" android:keyEdgeFlags="left" android:keyLabel="q" />
<Key android:codes="51" android:keyLabel="w" />
<Key android:codes="33" android:keyLabel="e" />
<Key android:codes="46" android:keyLabel="r" />
<Key android:codes="48" android:keyLabel="t" />
<Key android:codes="53" android:keyLabel="y" />
<Key android:codes="49" android:keyLabel="u" />
<Key android:codes="37" android:keyLabel="i" />
<Key android:codes="43" android:keyLabel="o" />
<Key android:codes="44" android:keyEdgeFlags="right" android:keyLabel="p" />
<Key android:codes="45" android:keyEdgeFlags="left" android:keyLabel="q"/>
<Key android:codes="51" android:keyLabel="w"/>
<Key android:codes="33" android:keyLabel="e"/>
<Key android:codes="46" android:keyLabel="r"/>
<Key android:codes="48" android:keyLabel="t"/>
<Key android:codes="53" android:keyLabel="y"/>
<Key android:codes="49" android:keyLabel="u"/>
<Key android:codes="37" android:keyLabel="i"/>
<Key android:codes="43" android:keyLabel="o"/>
<Key android:codes="44" android:keyEdgeFlags="right" android:keyLabel="p"/>
</Row>
<Row>
<Key android:codes="29" android:keyEdgeFlags="left" android:keyLabel="a" />
<Key android:codes="47" android:keyLabel="s" />
<Key android:codes="32" android:keyLabel="d" />
<Key android:codes="34" android:keyLabel="f" />
<Key android:codes="35" android:keyLabel="g" />
<Key android:codes="36" android:keyLabel="h" />
<Key android:codes="38" android:keyLabel="j" />
<Key android:codes="39" android:keyLabel="k" />
<Key android:codes="40" android:keyLabel="l" />
<Key android:codes="74" android:keyEdgeFlags="right" android:keyLabel=";" />
<Key android:codes="29" android:keyEdgeFlags="left" android:keyLabel="a"/>
<Key android:codes="47" android:keyLabel="s"/>
<Key android:codes="32" android:keyLabel="d"/>
<Key android:codes="34" android:keyLabel="f"/>
<Key android:codes="35" android:keyLabel="g"/>
<Key android:codes="36" android:keyLabel="h"/>
<Key android:codes="38" android:keyLabel="j"/>
<Key android:codes="39" android:keyLabel="k"/>
<Key android:codes="40" android:keyLabel="l"/>
<Key android:codes="74" android:keyEdgeFlags="right" android:keyLabel=";"/>
</Row>
<Row>
<Key android:codes="-1" android:keyEdgeFlags="left" android:keyLabel="⇪" />
<Key android:codes="54" android:keyLabel="z" />
<Key android:codes="52" android:keyLabel="x" />
<Key android:codes="31" android:keyLabel="c" />
<Key android:codes="50" android:keyLabel="v" />
<Key android:codes="30" android:keyLabel="b" />
<Key android:codes="42" android:keyLabel="n" />
<Key android:codes="41" android:keyLabel="m" />
<Key android:keyWidth="20.000004%p" android:codes="67" android:keyEdgeFlags="right" android:keyLabel="≪ ×" />
<Key android:codes="-1" android:keyEdgeFlags="left" android:keyLabel="⇪"/>
<Key android:codes="54" android:keyLabel="z"/>
<Key android:codes="52" android:keyLabel="x"/>
<Key android:codes="31" android:keyLabel="c"/>
<Key android:codes="50" android:keyLabel="v"/>
<Key android:codes="30" android:keyLabel="b"/>
<Key android:codes="42" android:keyLabel="n"/>
<Key android:codes="41" android:keyLabel="m"/>
<Key android:keyWidth="20.000004%p" android:codes="67" android:keyEdgeFlags="right" android:keyLabel="≪ ×"/>
</Row>
<Row android:rowEdgeFlags="bottom">
<Key android:codes="-6" android:keyEdgeFlags="left" android:keyLabel="123…" />
<Key android:codes="71" android:keyLabel="[" />
<Key android:codes="72" android:keyLabel="]" />
<Key android:codes="76" android:keyLabel="/" />
<Key android:keyWidth="20.000004%p" android:codes="62" android:keyLabel="Space" />
<Key android:codes="55" android:keyLabel="," />
<Key android:codes="56" android:keyLabel="." />
<Key android:keyWidth="20.000004%p" android:codes="66" android:keyEdgeFlags="right" android:keyLabel="Enter" />
<Key android:codes="-6" android:keyEdgeFlags="left" android:keyLabel="123…"/>
<Key android:codes="71" android:keyLabel="["/>
<Key android:codes="72" android:keyLabel="]"/>
<Key android:codes="76" android:keyLabel="/"/>
<Key android:keyWidth="20.000004%p" android:codes="62" android:keyLabel="Space"/>
<Key android:codes="55" android:keyLabel=","/>
<Key android:codes="56" android:keyLabel="."/>
<Key android:keyWidth="20.000004%p" android:codes="66" android:keyEdgeFlags="right" android:keyLabel="Enter"/>
</Row>
</Keyboard>

View File

@ -28,7 +28,7 @@
<Key android:codes="92" android:keyLabel="PgUp"/>
<Key android:codes="122" android:keyLabel="Home"/>
<Key android:codes="19" android:keyLabel="↑"/>
<Key android:codes="123" android:keyLabel="End" android:keyEdgeFlags="right" />
<Key android:codes="123" android:keyLabel="End" android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:codes="-1" android:keyLabel="!@#…" android:keyEdgeFlags="left"/>

View File

@ -28,7 +28,7 @@
<Key android:codes="131" android:keyLabel="F1"/>
<Key android:codes="132" android:keyLabel="F2"/>
<Key android:codes="133" android:keyLabel="F3"/>
<Key android:codes="134" android:keyLabel="F4" android:keyEdgeFlags="right" />
<Key android:codes="134" android:keyLabel="F4" android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:codes="-1" android:keyLabel="123…" android:keyEdgeFlags="left"/>
@ -49,7 +49,7 @@
<Key android:codes="156" android:keyLabel="Kp -"/>
<Key android:codes="157" android:keyLabel="Kp +"/>
<Key android:codes="160" android:keyLabel="Kp ↵"/>
<Key android:codes="139" android:keyLabel="F9" />
<Key android:codes="139" android:keyLabel="F9"/>
<Key android:codes="140" android:keyLabel="F10"/>
<Key android:codes="141" android:keyLabel="F11"/>
<Key android:codes="142" android:keyLabel="F12" android:keyEdgeFlags="right"/>

View File

@ -7,16 +7,16 @@
android:keyHeight="10%p">
<Row>
<Key android:codes="111" android:keyLabel="ESC" android:keyEdgeFlags="left"/>
<Key android:codes="131" android:keyLabel="F1" />
<Key android:codes="132" android:keyLabel="F2" />
<Key android:codes="133" android:keyLabel="F3" />
<Key android:codes="134" android:keyLabel="F4" />
<Key android:codes="135" android:keyLabel="F5" />
<Key android:codes="136" android:keyLabel="F6" />
<Key android:codes="137" android:keyLabel="F7" />
<Key android:codes="138" android:keyLabel="F8" />
<Key android:codes="139" android:keyLabel="F9" />
<Key android:codes="140" android:keyLabel="F10" />
<Key android:codes="131" android:keyLabel="F1"/>
<Key android:codes="132" android:keyLabel="F2"/>
<Key android:codes="133" android:keyLabel="F3"/>
<Key android:codes="134" android:keyLabel="F4"/>
<Key android:codes="135" android:keyLabel="F5"/>
<Key android:codes="136" android:keyLabel="F6"/>
<Key android:codes="137" android:keyLabel="F7"/>
<Key android:codes="138" android:keyLabel="F8"/>
<Key android:codes="139" android:keyLabel="F9"/>
<Key android:codes="140" android:keyLabel="F10"/>
<Key android:codes="124" android:keyLabel="HELP" android:keyEdgeFlags="right"/>
</Row>
@ -78,10 +78,10 @@
</Row>
<Row android:rowEdgeFlags="bottom">
<Key android:codes="57" android:keyLabel="ALT" android:keyEdgeFlags="left"/>
<Key android:codes="68" android:keyLabel="'" />
<Key android:codes="68" android:keyLabel="'"/>
<Key android:codes="73" android:keyLabel="\\"/>
<Key android:codes="69" android:keyLabel="-"/>
<Key android:codes="62" android:keyLabel="SPACE" android:keyWidth="30%p" />
<Key android:codes="62" android:keyLabel="SPACE" android:keyWidth="30%p"/>
<Key android:codes="70" android:keyLabel="="/>
<Key android:codes="71" android:keyLabel="["/>
<Key android:codes="72" android:keyLabel="]"/>

View File

@ -38,7 +38,8 @@
<Key android:codes="30" android:keyLabel="B" 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="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 android:rowEdgeFlags="bottom">
<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="55" android:keyLabel="&lt;" 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>
</Keyboard>

View File

@ -7,12 +7,12 @@
android:keyHeight="10%p">
<Row>
<Key android:codes="111" android:keyLabel="Esc" android:keyEdgeFlags="left"/>
<Key android:codes="122" android:keyLabel="Clear" />
<Key android:codes="124" android:keyLabel="Insert" />
<Key android:codes="123" android:keyLabel="Help" />
<Key android:codes="129" android:keyLabel="Start" />
<Key android:codes="128" android:keyLabel="Select" />
<Key android:codes="127" android:keyLabel="Option" />
<Key android:codes="122" android:keyLabel="Clear"/>
<Key android:codes="124" android:keyLabel="Insert"/>
<Key android:codes="123" android:keyLabel="Help"/>
<Key android:codes="129" android:keyLabel="Start"/>
<Key android:codes="128" android:keyLabel="Select"/>
<Key android:codes="127" android:keyLabel="Option"/>
<Key android:codes="130" android:keyLabel="Reset" android:keyEdgeFlags="right"/>
</Row>
<Row>
@ -76,7 +76,7 @@
<Key android:codes="69" android:keyLabel="-"/>
<Key android:codes="81" android:keyLabel="+"/>
<Key android:codes="70" android:keyLabel="="/>
<Key android:codes="62" android:keyLabel="SPACE" android:keyWidth="30%p" />
<Key android:codes="62" android:keyLabel="SPACE" android:keyWidth="30%p"/>
<Key android:codes="71" android:keyLabel="["/>
<Key android:codes="72" android:keyLabel="]"/>
<Key android:codes="18" android:keyLabel="#"/>

View File

@ -7,14 +7,14 @@
android:keyHeight="10%p">
<Row>
<Key android:codes="113" android:keyLabel="C=" android:keyEdgeFlags="left"/>
<Key android:codes="111" android:keyLabel="RS" />
<Key android:codes="5" android:keyLabel="CTRL" />
<Key android:codes="126" android:keyLabel="F1" />
<Key android:codes="103" android:keyLabel="F3" />
<Key android:codes="104" android:keyLabel="F5" />
<Key android:codes="105" android:keyLabel="F7" />
<Key android:codes="3" android:keyLabel="Home" />
<Key android:codes="71" android:keyLabel="\@" />
<Key android:codes="111" android:keyLabel="RS"/>
<Key android:codes="5" android:keyLabel="CTRL"/>
<Key android:codes="126" android:keyLabel="F1"/>
<Key android:codes="103" android:keyLabel="F3"/>
<Key android:codes="104" android:keyLabel="F5"/>
<Key android:codes="105" android:keyLabel="F7"/>
<Key android:codes="3" android:keyLabel="Home"/>
<Key android:codes="71" android:keyLabel="\@"/>
<Key android:codes="67" android:keyLabel="DEL" android:keyEdgeFlags="right"/>
</Row>
@ -28,8 +28,8 @@
<Key android:codes="14" android:keyLabel="7"/>
<Key android:codes="15" android:keyLabel="8"/>
<Key android:codes="16" android:keyLabel="9"/>
<Key android:codes="7" android:keyLabel="0" />
<Key android:codes="69" android:keyLabel="+" />
<Key android:codes="7" android:keyLabel="0"/>
<Key android:codes="69" android:keyLabel="+"/>
<Key android:codes="70" android:keyLabel="-" android:keyEdgeFlags="right"/>
</Row>
<Row>

View File

@ -38,7 +38,8 @@
<Key android:codes="30" android:keyLabel="b" 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="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 android:rowEdgeFlags="bottom">
<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="55" 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>
</Keyboard>

View File

@ -28,7 +28,7 @@
<Key android:codes="92" android:keyLabel="PgUp" android:isRepeatable="true"/>
<Key android:codes="122" android:keyLabel="Home" android:isRepeatable="true"/>
<Key android:codes="19" android:keyLabel="↑" android:isRepeatable="true"/>
<Key android:codes="123" android:keyLabel="End" android:isRepeatable="true" android:keyEdgeFlags="right" />
<Key android:codes="123" android:keyLabel="End" android:isRepeatable="true" android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:codes="-1" android:keyLabel="!@#…" android:keyEdgeFlags="left"/>

View File

@ -28,7 +28,7 @@
<Key android:codes="131" android:keyLabel="F1" android:isRepeatable="true"/>
<Key android:codes="132" android:keyLabel="F2" android:isRepeatable="true"/>
<Key android:codes="133" android:keyLabel="F3" android:isRepeatable="true"/>
<Key android:codes="134" android:keyLabel="F4" android:isRepeatable="true" android:keyEdgeFlags="right" />
<Key android:codes="134" android:keyLabel="F4" android:isRepeatable="true" android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:codes="-1" android:keyLabel="123…" android:keyEdgeFlags="left"/>

View File

@ -38,7 +38,8 @@
<Key android:codes="30" android:keyLabel="B" 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="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 android:rowEdgeFlags="bottom">
<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="55" android:keyLabel="&lt;" 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>
</Keyboard>

View File

@ -2,7 +2,7 @@ package io.neoterm;
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).

View File

@ -4,18 +4,18 @@
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
android:required="false"/>
<uses-feature
android:name="android.software.leanback"
android:required="false" />
android:required="false"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application
android:name=".App"
@ -37,28 +37,28 @@
android:theme="@style/AppTheme.NoActionBar.Dark"
android:windowSoftInputMode="adjustResize|stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/app_shortcuts" />
android:resource="@xml/app_shortcuts"/>
</activity>
<activity-alias
android:name=".NeoLotMainActivity"
android:targetActivity="io.neoterm.ui.term.NeoTermActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.IOT_LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.IOT_LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity-alias>
@ -69,7 +69,7 @@
android:theme="@style/AppTheme.Dark"
android:windowSoftInputMode="adjustResize|stateHidden">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
@ -79,11 +79,11 @@
android:label="@string/term_here"
android:targetActivity=".ui.term.NeoTermRemoteInterface">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEND"/>
<action android:name="android.intent.action.MAIN"/>
<data android:mimeType="*/*" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity-alias>
@ -93,34 +93,34 @@
android:label="@string/user_script"
android:targetActivity=".ui.term.NeoTermRemoteInterface">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEND"/>
<action android:name="android.intent.action.SEND_MULTIPLE"/>
<action android:name="android.intent.action.MAIN"/>
<data android:mimeType="*/*" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<data android:scheme="file" />
<data android:scheme="file"/>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW"/>
<action android:name="android.intent.action.MAIN"/>
<data android:mimeType="*/*" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="http" />
<data android:scheme="https" />
<data android:scheme="ftp" />
<data android:mimeType="application/*" />
<data android:mimeType="audio/*" />
<data android:mimeType="video/*" />
<data android:scheme="http"/>
<data android:scheme="https"/>
<data android:scheme="ftp"/>
<data android:mimeType="application/*"/>
<data android:mimeType="audio/*"/>
<data android:mimeType="video/*"/>
</intent-filter>
</activity-alias>
@ -128,67 +128,67 @@
android:name=".ui.support.AboutActivity"
android:exported="false"
android:label="@string/about"
android:theme="@style/AppTheme.NoActionBar.Dark" />
android:theme="@style/AppTheme.NoActionBar.Dark"/>
<activity
android:name=".ui.crash.CrashActivity"
android:exported="false"
android:label="@string/error"
android:theme="@style/AppTheme.NoActionBar.Dark" />
android:theme="@style/AppTheme.NoActionBar.Dark"/>
<activity
android:name=".ui.setup.SetupActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true"
android:theme="@style/AppTheme.NoActionBar" />
android:theme="@style/AppTheme.NoActionBar"/>
<activity
android:name=".ui.bonus.BonusActivity"
android:configChanges="orientation|keyboardHidden"
android:exported="false"
android:theme="@style/AppTheme.NoActionBar.Dark" />
android:theme="@style/AppTheme.NoActionBar.Dark"/>
<activity
android:name=".ui.pm.PackageManagerActivity"
android:exported="false"
android:label="@string/package_settings"
android:theme="@style/AppTheme.NoActionBar.Dark" />
android:theme="@style/AppTheme.NoActionBar.Dark"/>
<activity
android:name=".ui.customize.CustomizeActivity"
android:exported="false"
android:label="@string/customization_settings"
android:theme="@style/AppTheme.NoActionBar.Dark" />
android:theme="@style/AppTheme.NoActionBar.Dark"/>
<activity
android:name=".ui.customize.ColorSchemeActivity"
android:exported="false"
android:label="@string/pref_customization_color_scheme"
android:theme="@style/AppTheme.NoActionBar.Dark" />
android:theme="@style/AppTheme.NoActionBar.Dark"/>
<activity
android:name=".ui.support.HelpActivity"
android:exported="false"
android:label="@string/faq"
android:theme="@style/AppTheme.NoActionBar.Dark" />
android:theme="@style/AppTheme.NoActionBar.Dark"/>
<activity
android:name=".ui.settings.SettingActivity"
android:exported="false"
android:theme="@style/AppTheme.Dark" />
android:theme="@style/AppTheme.Dark"/>
<activity
android:name=".ui.settings.GeneralSettingsActivity"
android:exported="false"
android:theme="@style/AppTheme.Dark" />
android:theme="@style/AppTheme.Dark"/>
<activity
android:name=".ui.settings.UISettingsActivity"
android:exported="false"
android:theme="@style/AppTheme.Dark" />
android:theme="@style/AppTheme.Dark"/>
<service
android:name=".services.NeoTermService"
android:enabled="true" />
android:enabled="true"/>
<meta-data
android:name="com.sec.android.support.multiwindow"
android:value="true" />
android:value="true"/>
<meta-data
android:name="com.lge.support.SPLIT_WINDOW"
android:value="true" />
android:value="true"/>
</application>
</manifest>

View File

@ -1,6 +1,8 @@
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 {
private final byte[] mBuffer;

View File

@ -4,7 +4,9 @@ import android.util.Log;
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";
}

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);
/** 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);
/**
@ -35,7 +37,9 @@ final class JNI {
*/
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);
}

View File

@ -3,56 +3,7 @@ package io.neoterm.backend;
import java.util.HashMap;
import java.util.Map;
import static android.view.KeyEvent.KEYCODE_BACK;
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;
import static android.view.KeyEvent.*;
public final class KeyHandler {

View File

@ -9,13 +9,21 @@ package io.neoterm.backend;
public final class TerminalBuffer {
TerminalRow[] mLines;
/** The length of {@link #mLines}. */
/**
* The length of {@link #mLines}.
*/
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;
/** The number of rows kept in history. */
/**
* The number of rows kept in history.
*/
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;
/**
@ -397,7 +405,9 @@ public final class TerminalBuffer {
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,
int bottom, int right) {
for (int y = top; y < bottom; y++) {

View File

@ -11,7 +11,9 @@ import java.util.Properties;
*/
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 = {
// 16 original colors. First 8 are dim.
0xff000000, // black

View File

@ -1,9 +1,13 @@
package io.neoterm.backend;
/** Current terminal colors (if different from default). */
/**
* Current terminal colors (if different from default).
*/
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();
/**
@ -12,17 +16,23 @@ public final class TerminalColors {
*/
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() {
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) {
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() {
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) {
int c = parse(textParameter);
if (c != 0) mCurrentColors[intoIndex] = c;

View File

@ -2,25 +2,37 @@ package io.neoterm.backend;
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 {
/** 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) {
byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
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);
/** 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);
/** 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);
/** 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 onColorsChanged();

View File

@ -11,20 +11,34 @@ public final class TerminalRow {
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;
/** The text filling this terminal row. */
/**
* The text filling this terminal row.
*/
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;
/** 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;
/** 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;
/** 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;
/** 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) {
mColumns = columns;
mText = new char[(int) (SPARE_CAPACITY_FACTOR * columns)];
@ -32,7 +46,9 @@ public final class TerminalRow {
clear(style);
}
/** NOTE: The sourceX2 is exclusive. */
/**
* NOTE: The sourceX2 is exclusive.
*/
public void copyInterval(TerminalRow line, int sourceX1, int sourceX2, int destinationX) {
mHasNonOneWidthOrSurrogateChars |= line.mHasNonOneWidthOrSurrogateChars;
final int x1 = line.findStartOfColumn(sourceX1);
@ -62,7 +78,9 @@ public final class TerminalRow {
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) {
if (column == mColumns) return getSpaceUsed();

View File

@ -8,11 +8,7 @@ import android.system.Os;
import android.system.OsConstants;
import android.util.Log;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
@ -30,7 +26,9 @@ import java.util.UUID;
*/
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 {
void onTextChanged(TerminalSession changedSession);
@ -83,20 +81,28 @@ public class TerminalSession extends TerminalOutput {
* writing to the {@link #mTerminalFileDescriptor}.
*/
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];
public SessionChangedCallback getSessionChangedCallback() {
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;
/** 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;
/** 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;
/**
@ -105,7 +111,9 @@ public class TerminalSession extends TerminalOutput {
*/
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;
@SuppressLint("HandlerLeak")
@ -147,7 +155,9 @@ public class TerminalSession extends TerminalOutput {
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) {
if (mEmulator == null) {
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() {
return (mEmulator == null) ? null : mEmulator.getTitle();
}
@ -219,13 +231,17 @@ public class TerminalSession extends TerminalOutput {
}.start();
}
/** Write data to the executablePath process. */
/**
* Write data to the executablePath process.
*/
@Override
public void write(byte[] data, int offset, int 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) {
if (codePoint > 1114111 || (codePoint >= 0xD800 && codePoint <= 0xDFFF)) {
// 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;
}
/** Notify the {@link #mChangeCallback} that the screen has changed. */
/**
* Notify the {@link #mChangeCallback} that the screen has changed.
*/
private void notifyScreenUpdate() {
mChangeCallback.onTextChanged(this);
}
/** Reset state for terminal emulator state. */
/**
* Reset state for terminal emulator state.
*/
public void reset() {
mEmulator.reset();
notifyScreenUpdate();
}
/** Finish this terminal session by sending SIGKILL to the executablePath. */
/**
* Finish this terminal session by sending SIGKILL to the executablePath.
*/
public void finishIfRunning() {
if (isRunning()) {
try {
@ -302,7 +324,9 @@ public class TerminalSession extends TerminalOutput {
return exitDescription;
}
/** Cleanup resources when the process exits. */
/**
* Cleanup resources when the process exits.
*/
private void cleanupResources(int exitStatus) {
synchronized (this) {
mShellPid = -1;
@ -324,7 +348,9 @@ public class TerminalSession extends TerminalOutput {
return mShellPid != -1;
}
/** Only valid if not {@link #isRunning()}. */
/**
* Only valid if not {@link #isRunning()}.
*/
public synchronized int getExitStatus() {
return mShellExitStatus;
}

View File

@ -29,21 +29,31 @@ public final class TextStyle {
* </p>
*/
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;
/** 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;
/** If true (24-bit) color is used for the cell for foregroundColor. */
private final static int CHARACTER_ATTRIBUTE_TRUECOLOR_BACKGROUND= 1 << 10;
/**
* If true (24-bit) color is used for the cell for foregroundColor.
*/
private final static int CHARACTER_ATTRIBUTE_TRUECOLOR_BACKGROUND = 1 << 10;
public final static int COLOR_INDEX_FOREGROUND = 256;
public final static int COLOR_INDEX_BACKGROUND = 257;
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;
/** 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);
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.
*
* <p>
* Implementation from https://github.com/jquast/wcwidth but we return 0 for unprintable characters.
*/
public final class WcWidth {
@ -427,7 +427,9 @@ public final class WcWidth {
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) {
if (ucs == 0 ||
ucs == 0x034F ||
@ -449,7 +451,9 @@ public final class WcWidth {
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) {
char c = chars[index];
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>()
builder.append(" ${NeoColorScheme.COLOR_META_NAME}: \"${colorScheme.colorName}\"\n")
builder.append(" ${NeoColorScheme.COLOR_META_VERSION}: ${colorScheme.colorVersion
?: component.getLoaderVersion()}\n")
builder.append(
" ${NeoColorScheme.COLOR_META_VERSION}: ${
colorScheme.colorVersion
?: component.getLoaderVersion()
}\n"
)
builder.append("\n")
}

View File

@ -76,7 +76,8 @@ class ColorSchemeComponent : ConfigFileBasedComponent<NeoColorScheme>(NeoTermPat
}
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)) {
currentColorName = DefaultColorScheme.colorName
NeoPreference.store(R.string.key_customization_color_scheme, DefaultColorScheme.colorName)

View File

@ -6,5 +6,5 @@ import io.neoterm.frontend.config.NeoConfigureFile
* @author kiva
*/
interface IConfigureLoader {
fun loadConfigure() : NeoConfigureFile?
fun loadConfigure(): NeoConfigureFile?
}

View File

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

View File

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

View File

@ -5,28 +5,17 @@ import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
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.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
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;
import java.util.*;
/**
* @author Lody, Kiva

View File

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

View File

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

View File

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

View File

@ -1,16 +1,16 @@
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.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;
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
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@ import java.nio.file.Files
*/
open class NeoConfigureFile(val configureFile: File) {
private val configParser = NeoLangParser()
open protected var configVisitor : ConfigVisitor? = null
open protected var configVisitor: ConfigVisitor? = null
fun getVisitor() = configVisitor ?: throw IllegalStateException("Configure file not loaded or parse failed.")

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@ class ShellProfile : NeoProfile() {
private const val COLOR_SCHEME = "color-scheme"
private const val WORD_BASED_IME = "word-based-ime"
fun create() : ShellProfile {
fun create(): ShellProfile {
return ShellProfile()
}
}

View File

@ -11,12 +11,13 @@ import java.io.File
/**
* @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>,
changeCallback: SessionChangedCallback,
private val initialCommand: String?,
val shellProfile: ShellProfile)
: TerminalSession(shellPath, cwd, args, env, changeCallback) {
val shellProfile: ShellProfile
) : TerminalSession(shellPath, cwd, args, env, changeCallback) {
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 {
val cwd = this.cwd ?: NeoTermPath.HOME_PATH
val shell = this.executablePath ?:
if (systemShell)
val shell = this.executablePath ?: if (systemShell)
"/system/bin/sh"
else
shellProfile.loginShell
@ -157,8 +157,10 @@ open class ShellTermSession private constructor(shellPath: String, cwd: String,
val args = this.args ?: mutableListOf(shell)
val env = transformEnvironment(this.env) ?: buildEnvironment(cwd, systemShell)
val callback = changeCallback ?: TermSessionCallback()
return ShellTermSession(shell, cwd, args.toTypedArray(), env, callback,
initialCommand ?: "", shellProfile)
return ShellTermSession(
shell, cwd, args.toTypedArray(), env, callback,
initialCommand ?: "", shellProfile
)
}
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) {
val pathEnv = "PATH=" + System.getenv("PATH")
arrayOf(termEnv, homeEnv, androidRootEnv, androidDataEnv,
arrayOf(
termEnv, homeEnv, androidRootEnv, androidDataEnv,
externalStorageEnv, pathEnv, neotermIdEnv, prefixEnv,
originLdEnv, originPathEnv, colorterm)
originLdEnv, originPathEnv, colorterm
)
} else {
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,
tmpdirEnv, neotermIdEnv, originPathEnv, originLdEnv,
ldPreloadEnv, prefixEnv, colorterm)
ldPreloadEnv, prefixEnv, colorterm
)
}
.filter { it.isNotEmpty() }
.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.CompletionResult
import io.neoterm.frontend.completion.view.CandidatePopupWindow
import io.neoterm.frontend.logging.NLog
import io.neoterm.frontend.terminal.TerminalView
import java.util.*
@ -80,8 +79,10 @@ class TermCompleteListener(var terminalView: TerminalView?) : OnAutoCompleteList
}
if (BuildConfig.DEBUG) {
Log.e("NeoTerm-AC", "currentEditing: $textNeedCompletion, " +
"deleteLength: $deleteLength, completeString: $newText")
Log.e(
"NeoTerm-AC", "currentEditing: $textNeedCompletion, " +
"deleteLength: $deleteLength, completeString: $newText"
)
}
pushString(newText)

View File

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

View File

@ -167,14 +167,25 @@ class TermViewClient(val context: Context) : TerminalViewClient {
'v' -> {
resultingCodePoint = -1
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 (session != null) {
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) {
session?.writeCodePoint(altDown, resultingCodePoint)
@ -220,7 +231,8 @@ class TermViewClient(val context: Context) : TerminalViewClient {
}
if ((lastTitle != title || force)
&& updateExtraKeysVisibility()) {
&& updateExtraKeysVisibility()
) {
removeExtraKeys()
ComponentManager.getComponent<ExtraKeyComponent>().showShortcutKeys(title, extraKeysView)
extraKeysView.updateButtons()

View File

@ -1,6 +1,5 @@
package io.neoterm.frontend.session.xorg
import androidx.appcompat.app.AppCompatActivity
import android.app.UiModeManager
import android.content.Context
import android.content.pm.ActivityInfo
@ -14,6 +13,7 @@ import android.view.*
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatActivity
import io.neoterm.*
import io.neoterm.frontend.session.xorg.client.XSessionData
import io.neoterm.xorg.NeoXorgViewClient
@ -24,13 +24,16 @@ import java.util.*
* @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 = "";
init {
if (Globals.InhibitSuspend) {
window.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
window.setFlags(
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
)
}
mSessionData.client = this
@ -104,7 +107,10 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
}
if (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))
}
@ -119,16 +125,25 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
if (key == Keyboard.KEYCODE_SHIFT) {
builtinKeyboard.shift = !builtinKeyboard.shift
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
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)
return
}
if (key == Keyboard.KEYCODE_ALT) {
builtinKeyboard.alt = !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
builtinKeyboard.shift = false
builtinKeyboard.changeKeyboard(keyboard)
@ -158,7 +173,10 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
mActivity.onKeyUp(key, KeyEvent(KeyEvent.ACTION_UP, key))
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)
for (k in builtinKeyboard.keyboard.keys) {
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) {}
})
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)
}
})
@ -220,10 +242,12 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
if (mSessionData.screenKeyboard != null)
return
val screenKeyboard = EditText(mActivity, null,
val screenKeyboard = EditText(
mActivity, null,
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP)
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
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.postDelayed({
screenKeyboard.requestFocus()
screenKeyboard.dispatchTouchEvent(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.dispatchTouchEvent(
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.requestFocus()
screenKeyboard.setSelection(screenKeyboard.text.length)
@ -279,7 +321,8 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
override fun updateScreenOrientation() {
var rotation: Int = windowManager.defaultDisplay.rotation
NeoAccelerometerReader.setGyroInvertedOrientation(
rotation == Surface.ROTATION_180 || rotation == Surface.ROTATION_270)
rotation == Surface.ROTATION_180 || rotation == Surface.ROTATION_270
)
}
override fun initScreenOrientation() {
@ -306,9 +349,11 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
override fun setSystemMousePointerVisible(visible: Int) {
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
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_2 ||
keyCode == KeyEvent.KEYCODE_BUTTON_3 ||
keyCode == KeyEvent.KEYCODE_BUTTON_4)) {
keyCode == KeyEvent.KEYCODE_BUTTON_4)
) {
client.hideScreenKeyboard()
return true
}
@ -343,7 +389,8 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
return false
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
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 false

View File

@ -4,12 +4,7 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
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;
import io.neoterm.backend.*;
/**
* Renderer of a {@link TerminalEmulator} into a {@link Canvas}.
@ -22,16 +17,26 @@ final class TerminalRenderer {
final Typeface mTypeface;
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;
/** 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;
/** 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;
/** The {@link #mFontLineSpacing} + {@link #mFontAscent}. */
/**
* The {@link #mFontLineSpacing} + {@link #mFontAscent}.
*/
final int mFontLineSpacingAndAscent;
/** AutoCompletion PopupWindow need them to show popup window */
/**
* AutoCompletion PopupWindow need them to show popup window
*/
protected float savedLastDrawnLineX;
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,
int selectionY1, int selectionY2, int selectionX1, int selectionX2) {
final boolean reverseVideo = mEmulator.isReverseVideo();

View File

@ -15,27 +15,14 @@ import android.text.InputType;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ActionMode;
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.*;
import android.view.accessibility.AccessibilityManager;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.widget.Scroller;
import io.neoterm.R;
import io.neoterm.backend.EmulatorDebug;
import io.neoterm.backend.KeyHandler;
import io.neoterm.backend.TerminalBuffer;
import io.neoterm.backend.TerminalEmulator;
import io.neoterm.backend.TerminalSession;
import io.neoterm.backend.*;
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.MotionEvent;
import android.view.ScaleGestureDetector;
import io.neoterm.backend.TerminalSession;
/**

View File

@ -166,8 +166,10 @@ class ExtraKeysView(context: Context, attrs: AttributeSet) : LinearLayout(contex
if (NeoPreference.isExplicitExtraKeysWeightEnabled())
LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f)
else
LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT)
LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
layoutParams.setMargins(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.os.Handler
import android.os.Looper
import androidx.appcompat.widget.AppCompatButton
import android.util.AttributeSet
import android.view.MotionEvent
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)
}
private class RepeatableButtonWidget(context: Context?, attrs: AttributeSet?, defStyleAttr: Int)
: AppCompatButton(context!!, attrs, defStyleAttr) {
private class RepeatableButtonWidget(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) :
AppCompatButton(context!!, attrs, defStyleAttr) {
/**
* Milliseconds how long we trigger an action

View File

@ -10,7 +10,8 @@ import android.widget.ToggleButton
* @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
override fun onClick(view: View) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,13 +9,16 @@ import io.neoterm.R
import io.neoterm.component.colorscheme.NeoColorScheme
import io.neoterm.ui.customize.adapter.holder.ColorItemViewHolder
import io.neoterm.ui.customize.model.ColorItem
import java.util.*
/**
* @author kiva
*/
class ColorItemAdapter(context: Context, initColorScheme: NeoColorScheme, comparator: Comparator<ColorItem>, private val listener: ColorItemAdapter.Listener)
: SortedListAdapter<ColorItem>(context, ColorItem::class.java, comparator), FastScrollRecyclerView.SectionedAdapter {
class ColorItemAdapter(
context: Context,
initColorScheme: NeoColorScheme,
comparator: Comparator<ColorItem>,
private val listener: ColorItemAdapter.Listener
) : SortedListAdapter<ColorItem>(context, ColorItem::class.java, comparator), FastScrollRecyclerView.SectionedAdapter {
val colorList = mutableListOf<ColorItem>()
@ -35,7 +38,11 @@ class ColorItemAdapter(context: Context, initColorScheme: NeoColorScheme, compar
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)
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.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 colorItemDesc: TextView = rootView.findViewById<TextView>(R.id.color_item_description)
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.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.Menu
import android.view.MenuItem
import android.widget.EditText
import android.widget.TextView
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 io.neoterm.R
import io.neoterm.backend.TerminalSession
@ -77,8 +76,10 @@ class PackageManagerActivity : AppCompatActivity(), SearchView.OnQueryTextListen
private fun installPackage(packageName: String?) {
if (packageName != null) {
TerminalDialog(this@PackageManagerActivity)
.execute(NeoTermPath.APT_BIN_PATH,
arrayOf("apt", "install", "-y", packageName))
.execute(
NeoTermPath.APT_BIN_PATH,
arrayOf("apt", "install", "-y", packageName)
)
.onFinish(object : TerminalDialog.SessionFinishedCallback {
override fun onSessionFinished(dialog: TerminalDialog, finishedSession: TerminalSession?) {
dialog.setTitle(getString(R.string.done))
@ -197,7 +198,7 @@ class PackageManagerActivity : AppCompatActivity(), SearchView.OnQueryTextListen
}
dialog.dismiss()
PackageUtils.apt(this, "upgrade", arrayOf("-y"), out@ { exitStatus, dialog ->
PackageUtils.apt(this, "upgrade", arrayOf("-y"), out@{ exitStatus, dialog ->
if (exitStatus != 0) {
dialog.setTitle(getString(R.string.error))
return@out
@ -230,8 +231,10 @@ class PackageManagerActivity : AppCompatActivity(), SearchView.OnQueryTextListen
}.start()
}
private fun sortDistance(models: List<PackageModel>, query: String,
mapper: (NeoPackageInfo) -> String): List<Pair<PackageModel, Int>> {
private fun sortDistance(
models: List<PackageModel>, query: String,
mapper: (NeoPackageInfo) -> String
): List<Pair<PackageModel, Int>> {
return models
.map({
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.ui.pm.adapter.holder.PackageViewHolder
import io.neoterm.ui.pm.model.PackageModel
import java.util.*
class PackageAdapter(context: Context, comparator: Comparator<PackageModel>, private val listener: PackageAdapter.Listener) : SortedListAdapter<PackageModel>(context, PackageModel::class.java, comparator), FastScrollRecyclerView.SectionedAdapter {
class PackageAdapter(
context: Context,
comparator: Comparator<PackageModel>,
private val listener: PackageAdapter.Listener
) : SortedListAdapter<PackageModel>(context, PackageModel::class.java, comparator),
FastScrollRecyclerView.SectionedAdapter {
override fun getSectionName(position: Int): String {
return getItem(position).packageInfo.packageName?.substring(0, 1) ?: "#"
@ -20,7 +24,11 @@ class PackageAdapter(context: Context, comparator: Comparator<PackageModel>, pri
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)
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.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 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 {
return context.getString(R.string.package_details,
return context.getString(
R.string.package_details,
packageInfo.packageName, packageInfo.version,
packageInfo.dependenciesString,
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.graphics.Canvas;
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.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
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;
public class RecyclerTabLayout extends RecyclerView {
@ -264,7 +263,7 @@ public class RecyclerTabLayout extends RecyclerView {
if (position == 0) {
float indicatorGap = (nextView.getMeasuredWidth() - selectedView.getMeasuredWidth()) / 2;
mIndicatorGap = (int) (indicatorGap * positionOffset);
mIndicatorScroll = (int)((selectedView.getMeasuredWidth() + indicatorGap) * positionOffset);
mIndicatorScroll = (int) ((selectedView.getMeasuredWidth() + indicatorGap) * positionOffset);
} else {
float indicatorGap = (nextView.getMeasuredWidth() - selectedView.getMeasuredWidth()) / 2;

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