MISC: change all indent to 2 spaces (so compat!)
This commit is contained in:
@ -2,8 +2,12 @@
|
|||||||
|
|
||||||
## Our Pledge
|
## Our Pledge
|
||||||
|
|
||||||
Originally, NeoTerm was designed as the front end of [Termux](https://github.com/termux/termux-app) to provide some functions that Termux didn't have, but we found it very convenient. In continuous development, we discovered our goal: to be the best terminal for Android.
|
Originally, NeoTerm was designed as the front end of [Termux](https://github.com/termux/termux-app) to provide some
|
||||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
functions that Termux didn't have, but we found it very convenient. In continuous development, we discovered our goal:
|
||||||
|
to be the best terminal for Android. In the interest of fostering an open and welcoming environment, we as contributors
|
||||||
|
and maintainers pledge to making participation in our project and our community a harassment-free experience for
|
||||||
|
everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience,
|
||||||
|
nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
## Our Standards
|
## Our Standards
|
||||||
|
|
||||||
@ -26,23 +30,35 @@ Examples of unacceptable behavior by participants include:
|
|||||||
|
|
||||||
## Our Responsibilities
|
## Our Responsibilities
|
||||||
|
|
||||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take
|
||||||
|
appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
|
||||||
|
issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any
|
||||||
|
contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||||
|
|
||||||
## Scope
|
## Scope
|
||||||
|
|
||||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the
|
||||||
|
project or its community. Examples of representing a project or community include using an official project e-mail
|
||||||
|
address, posting via an official social media account, or acting as an appointed representative at an online or offline
|
||||||
|
event. Representation of a project may be further defined and clarified by project maintainers.
|
||||||
|
|
||||||
## Enforcement
|
## Enforcement
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at kiva515@foxmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at
|
||||||
|
kiva515@foxmail.com. The project team will review and investigate all complaints, and will respond in a way that it
|
||||||
|
deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the
|
||||||
|
reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent
|
||||||
|
repercussions as determined by other members of the project's leadership.
|
||||||
|
|
||||||
## Attribution
|
## Attribution
|
||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available
|
||||||
|
at [http://contributor-covenant.org/version/1/4][version]
|
||||||
|
|
||||||
[homepage]: http://contributor-covenant.org
|
[homepage]: http://contributor-covenant.org
|
||||||
|
|
||||||
[version]: http://contributor-covenant.org/version/1/4/
|
[version]: http://contributor-covenant.org/version/1/4/
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# Contributing
|
# Contributing
|
||||||
|
|
||||||
# How to
|
# How to
|
||||||
|
|
||||||
NeoTerm is a free software, so any contributions and any contribution types are welcomed!
|
NeoTerm is a free software, so any contributions and any contribution types are welcomed!
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ class NeoLangGroupNode(val attributes: Array<NeoLangAttributeNode>) : NeoLangBas
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun emptyNode() : NeoLangGroupNode {
|
fun emptyNode(): NeoLangGroupNode {
|
||||||
return NeoLangGroupNode(arrayOf())
|
return NeoLangGroupNode(arrayOf())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ class NeoLangProgramNode(val groups: List<NeoLangGroupNode>) : NeoLangBaseNode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun emptyNode() : NeoLangProgramNode {
|
fun emptyNode(): NeoLangProgramNode {
|
||||||
return NeoLangProgramNode(listOf())
|
return NeoLangProgramNode(listOf())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ class AstVisitor(private val ast: NeoLangAst, private val visitorCallback: IVisi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
fun <T : IVisitorCallback> getCallback() : T {
|
fun <T : IVisitorCallback> getCallback(): T {
|
||||||
return visitorCallback as T
|
return visitorCallback as T
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,5 +14,5 @@ interface IVisitorCallback {
|
|||||||
|
|
||||||
fun onExitContext()
|
fun onExitContext()
|
||||||
|
|
||||||
fun getCurrentContext() : NeoLangContext
|
fun getCurrentContext(): NeoLangContext
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import io.neolang.ast.NeoLangEOFToken
|
|||||||
import io.neolang.ast.NeoLangToken
|
import io.neolang.ast.NeoLangToken
|
||||||
import io.neolang.ast.NeoLangTokenType
|
import io.neolang.ast.NeoLangTokenType
|
||||||
import io.neolang.ast.NeoLangTokenValue
|
import io.neolang.ast.NeoLangTokenValue
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* grammar: [
|
* grammar: [
|
||||||
@ -69,7 +68,8 @@ class NeoLangLexer {
|
|||||||
while (currentChar == ' '
|
while (currentChar == ' '
|
||||||
|| currentChar == '\t'
|
|| currentChar == '\t'
|
||||||
|| currentChar == '\n'
|
|| currentChar == '\n'
|
||||||
|| currentChar == '\r') {
|
|| currentChar == '\r'
|
||||||
|
) {
|
||||||
if (currentChar == '\n') {
|
if (currentChar == '\n') {
|
||||||
++lineNumber
|
++lineNumber
|
||||||
}
|
}
|
||||||
@ -202,8 +202,8 @@ class NeoLangLexer {
|
|||||||
var loop = moveToNextChar() // skip 'x' or 'X'
|
var loop = moveToNextChar() // skip 'x' or 'X'
|
||||||
while (loop && (currentChar.isHexNumber())) {
|
while (loop && (currentChar.isHexNumber())) {
|
||||||
value *= 16
|
value *= 16
|
||||||
+ (currentChar.toInt().and(15))
|
+(currentChar.toInt().and(15))
|
||||||
+ if (currentChar >= 'A') 9 else 0
|
+if (currentChar >= 'A') 9 else 0
|
||||||
loop = moveToNextChar()
|
loop = moveToNextChar()
|
||||||
}
|
}
|
||||||
return value
|
return value
|
||||||
|
@ -49,9 +49,11 @@ class NeoLangParser {
|
|||||||
return true
|
return true
|
||||||
|
|
||||||
} else if (errorThrow) {
|
} else if (errorThrow) {
|
||||||
throw InvalidTokenException("Unexpected token `${currentToken.tokenValue}' typed " +
|
throw InvalidTokenException(
|
||||||
|
"Unexpected token `${currentToken.tokenValue}' typed " +
|
||||||
"`${currentToken.tokenType}' near line ${currentToken.lineNumber}, " +
|
"`${currentToken.tokenType}' near line ${currentToken.lineNumber}, " +
|
||||||
"expected $tokenType")
|
"expected $tokenType"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@ -88,7 +90,8 @@ class NeoLangParser {
|
|||||||
|
|
||||||
while (token.tokenType !== NeoLangTokenType.EOF
|
while (token.tokenType !== NeoLangTokenType.EOF
|
||||||
&& token.tokenType !== NeoLangTokenType.BRACKET_END
|
&& token.tokenType !== NeoLangTokenType.BRACKET_END
|
||||||
&& token.tokenType !== NeoLangTokenType.ARRAY_END) {
|
&& token.tokenType !== NeoLangTokenType.ARRAY_END
|
||||||
|
) {
|
||||||
attr = attribute()
|
attr = attribute()
|
||||||
if (attr == null) {
|
if (attr == null) {
|
||||||
break
|
break
|
||||||
@ -127,7 +130,8 @@ class NeoLangParser {
|
|||||||
if (match(NeoLangTokenType.COMMA)) {
|
if (match(NeoLangTokenType.COMMA)) {
|
||||||
// More than one elements
|
// More than one elements
|
||||||
while (token.tokenType !== NeoLangTokenType.EOF
|
while (token.tokenType !== NeoLangTokenType.EOF
|
||||||
&& token.tokenType !== NeoLangTokenType.ARRAY_END) {
|
&& token.tokenType !== NeoLangTokenType.ARRAY_END
|
||||||
|
) {
|
||||||
block = blockNonArrayElement(arrayName)
|
block = blockNonArrayElement(arrayName)
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
break
|
break
|
||||||
|
@ -5,7 +5,10 @@ import io.neolang.runtime.context.NeoLangContext
|
|||||||
/**
|
/**
|
||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
class NeoLangArray private constructor(val elements: List<NeoLangArrayElement>, override val size: Int = elements.size) : Collection<NeoLangArrayElement> {
|
class NeoLangArray private constructor(
|
||||||
|
val elements: List<NeoLangArrayElement>,
|
||||||
|
override val size: Int = elements.size
|
||||||
|
) : Collection<NeoLangArrayElement> {
|
||||||
companion object {
|
companion object {
|
||||||
internal class PrimaryElement(val primaryValue: NeoLangValue) : NeoLangArrayElement() {
|
internal class PrimaryElement(val primaryValue: NeoLangValue) : NeoLangArrayElement() {
|
||||||
override fun eval(): NeoLangValue {
|
override fun eval(): NeoLangValue {
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest
|
||||||
package="io.neoterm.bridge" />
|
package="io.neoterm.bridge"/>
|
||||||
|
@ -2,7 +2,7 @@ package io.neoterm.bridge;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Example local unit test, which will execute on the development machine (host).
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
|
@ -7,14 +7,18 @@ NeoTerm
|
|||||||
A modern-designed android terminal emulator for the 21st century.
|
A modern-designed android terminal emulator for the 21st century.
|
||||||
|
|
||||||
### Our Pledge
|
### Our Pledge
|
||||||
Originally, NeoTerm was designed as the front end of Termux to provide some functions that Termux didn't have, but we found it very convenient. In continuous development, we discovered our goal: to be the best terminal for Android.
|
|
||||||
|
Originally, NeoTerm was designed as the front end of Termux to provide some functions that Termux didn't have, but we
|
||||||
|
found it very convenient. In continuous development, we discovered our goal: to be the best terminal for Android.
|
||||||
|
|
||||||
### Help & Documentation
|
### Help & Documentation
|
||||||
|
|
||||||
View on [GitBook](https://neoterm.gitbooks.io/neoterm-wiki/content)
|
View on [GitBook](https://neoterm.gitbooks.io/neoterm-wiki/content)
|
||||||
|
|
||||||
View on [GitHub](https://github.com/NeoTerm/NeoTerm-Wiki)
|
View on [GitHub](https://github.com/NeoTerm/NeoTerm-Wiki)
|
||||||
|
|
||||||
### Download
|
### Download
|
||||||
|
|
||||||
[GitHub Release Page](https://github.com/NeoTerm/NeoTerm/releases)
|
[GitHub Release Page](https://github.com/NeoTerm/NeoTerm/releases)
|
||||||
|
|
||||||
[lzzySoft's F-Droid repo](https://apt.izzysoft.de/fdroid/index/apk/io.neoterm) (thanks to @lzzySoft)
|
[lzzySoft's F-Droid repo](https://apt.izzysoft.de/fdroid/index/apk/io.neoterm) (thanks to @lzzySoft)
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest
|
||||||
package="io.neoterm.xorg" />
|
package="io.neoterm.xorg"/>
|
||||||
|
@ -27,30 +27,26 @@ import android.hardware.Sensor;
|
|||||||
import android.hardware.SensorEvent;
|
import android.hardware.SensorEvent;
|
||||||
import android.hardware.SensorEventListener;
|
import android.hardware.SensorEventListener;
|
||||||
import android.hardware.SensorManager;
|
import android.hardware.SensorManager;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("JniMissingFunction")
|
@SuppressWarnings("JniMissingFunction")
|
||||||
class AccelerometerReader implements SensorEventListener
|
class AccelerometerReader implements SensorEventListener {
|
||||||
{
|
|
||||||
|
|
||||||
private SensorManager _manager = null;
|
private SensorManager _manager = null;
|
||||||
public boolean openedBySDL = false;
|
public boolean openedBySDL = false;
|
||||||
public static final GyroscopeListener gyro = new GyroscopeListener();
|
public static final GyroscopeListener gyro = new GyroscopeListener();
|
||||||
public static final OrientationListener orientation = new OrientationListener();
|
public static final OrientationListener orientation = new OrientationListener();
|
||||||
|
|
||||||
public AccelerometerReader(Context context)
|
public AccelerometerReader(Context context) {
|
||||||
{
|
|
||||||
_manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
_manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void stop()
|
public synchronized void stop() {
|
||||||
{
|
if (_manager != null) {
|
||||||
if( _manager != null )
|
|
||||||
{
|
|
||||||
Log.i("SDL", "libSDL: stopping accelerometer/gyroscope/orientation");
|
Log.i("SDL", "libSDL: stopping accelerometer/gyroscope/orientation");
|
||||||
_manager.unregisterListener(this);
|
_manager.unregisterListener(this);
|
||||||
_manager.unregisterListener(gyro);
|
_manager.unregisterListener(gyro);
|
||||||
@ -58,23 +54,19 @@ class AccelerometerReader implements SensorEventListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void start()
|
public synchronized void start() {
|
||||||
{
|
if ((Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer) &&
|
||||||
if( (Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer) &&
|
_manager != null && _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null) {
|
||||||
_manager != null && _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null )
|
|
||||||
{
|
|
||||||
Log.i("SDL", "libSDL: starting accelerometer");
|
Log.i("SDL", "libSDL: starting accelerometer");
|
||||||
_manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
|
_manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
|
||||||
}
|
}
|
||||||
if( (Globals.AppUsesGyroscope || Globals.MoveMouseWithGyroscope) &&
|
if ((Globals.AppUsesGyroscope || Globals.MoveMouseWithGyroscope) &&
|
||||||
_manager != null && _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null )
|
_manager != null && _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null) {
|
||||||
{
|
|
||||||
Log.i("SDL", "libSDL: starting gyroscope");
|
Log.i("SDL", "libSDL: starting gyroscope");
|
||||||
_manager.registerListener(gyro, _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
|
_manager.registerListener(gyro, _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
|
||||||
}
|
}
|
||||||
if( (Globals.AppUsesOrientationSensor) && _manager != null &&
|
if ((Globals.AppUsesOrientationSensor) && _manager != null &&
|
||||||
_manager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR) != null )
|
_manager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR) != null) {
|
||||||
{
|
|
||||||
Log.i("SDL", "libSDL: starting orientation sensor");
|
Log.i("SDL", "libSDL: starting orientation sensor");
|
||||||
_manager.registerListener(orientation, _manager.getDefaultSensor(
|
_manager.registerListener(orientation, _manager.getDefaultSensor(
|
||||||
Sensor.TYPE_GAME_ROTATION_VECTOR),
|
Sensor.TYPE_GAME_ROTATION_VECTOR),
|
||||||
@ -82,37 +74,32 @@ class AccelerometerReader implements SensorEventListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSensorChanged(SensorEvent event)
|
public void onSensorChanged(SensorEvent event) {
|
||||||
{
|
if (Globals.HorizontalOrientation) {
|
||||||
if( Globals.HorizontalOrientation )
|
if (gyro.invertedOrientation)
|
||||||
{
|
|
||||||
if( gyro.invertedOrientation )
|
|
||||||
nativeAccelerometer(-event.values[1], event.values[0], event.values[2]);
|
nativeAccelerometer(-event.values[1], event.values[0], event.values[2]);
|
||||||
else
|
else
|
||||||
nativeAccelerometer(event.values[1], -event.values[0], event.values[2]);
|
nativeAccelerometer(event.values[1], -event.values[0], event.values[2]);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested!
|
nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onAccuracyChanged(Sensor s, int a)
|
public void onAccuracyChanged(Sensor s, int a) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class GyroscopeListener implements SensorEventListener
|
static class GyroscopeListener implements SensorEventListener {
|
||||||
{
|
|
||||||
public boolean invertedOrientation = false;
|
public boolean invertedOrientation = false;
|
||||||
|
|
||||||
// Noise filter with sane initial values, so user will be able
|
// Noise filter with sane initial values, so user will be able
|
||||||
// to move gyroscope during the first 10 seconds, while the noise is measured.
|
// to move gyroscope during the first 10 seconds, while the noise is measured.
|
||||||
// After that the values are replaced by noiseMin/noiseMax.
|
// After that the values are replaced by noiseMin/noiseMax.
|
||||||
final float filterMin[] = 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 };
|
final float filterMax[] = new float[]{0.05f, 0.05f, 0.05f};
|
||||||
|
|
||||||
// The noise levels we're measuring.
|
// The noise levels we're measuring.
|
||||||
// Large initial values, they will decrease, but never increase.
|
// Large initial values, they will decrease, but never increase.
|
||||||
float noiseMin[] = 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 };
|
float noiseMax[] = new float[]{1.0f, 1.0f, 1.0f};
|
||||||
|
|
||||||
// The gyro data buffer, from which we care calculating min/max noise values.
|
// 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.
|
// 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.
|
// How long the algorithm is running, to stop it if it does not converge.
|
||||||
int measurementIteration = 0;
|
int measurementIteration = 0;
|
||||||
|
|
||||||
public GyroscopeListener()
|
public GyroscopeListener() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void collectNoiseData(final float[] data)
|
void collectNoiseData(final float[] data) {
|
||||||
{
|
for (int i = 0; i < noiseMin.length; i++) {
|
||||||
for( int i = 0; i < noiseMin.length; i++ )
|
if (data[i] < noiseMin[i] || data[i] > noiseMax[i]) {
|
||||||
{
|
|
||||||
if( data[i] < noiseMin[i] || data[i] > noiseMax[i] )
|
|
||||||
{
|
|
||||||
// Movement detected, this can converge our min/max too early, so we're discarding last few values
|
// Movement detected, this can converge our min/max too early, so we're discarding last few values
|
||||||
if( movementBackoff < 0 )
|
if (movementBackoff < 0) {
|
||||||
{
|
|
||||||
int discard = 10;
|
int discard = 10;
|
||||||
if( -movementBackoff < discard )
|
if (-movementBackoff < discard)
|
||||||
discard = -movementBackoff;
|
discard = -movementBackoff;
|
||||||
noiseDataIdx -= discard;
|
noiseDataIdx -= discard;
|
||||||
if( noiseDataIdx < 0 )
|
if (noiseDataIdx < 0)
|
||||||
noiseDataIdx = 0;
|
noiseDataIdx = 0;
|
||||||
}
|
}
|
||||||
movementBackoff = 10;
|
movementBackoff = 10;
|
||||||
@ -156,24 +138,22 @@ class AccelerometerReader implements SensorEventListener
|
|||||||
noiseData[noiseDataIdx][i] = data[i];
|
noiseData[noiseDataIdx][i] = data[i];
|
||||||
}
|
}
|
||||||
movementBackoff--;
|
movementBackoff--;
|
||||||
if( movementBackoff >= 0 )
|
if (movementBackoff >= 0)
|
||||||
return; // Also discard several values after the movement stopped
|
return; // Also discard several values after the movement stopped
|
||||||
noiseDataIdx++;
|
noiseDataIdx++;
|
||||||
|
|
||||||
if( noiseDataIdx < noiseData.length )
|
if (noiseDataIdx < noiseData.length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
measurementIteration++;
|
measurementIteration++;
|
||||||
Log.d( "SDL", "GYRO_NOISE: Measuring in progress... " + measurementIteration );
|
Log.d("SDL", "GYRO_NOISE: Measuring in progress... " + measurementIteration);
|
||||||
if( measurementIteration > 5 )
|
if (measurementIteration > 5) {
|
||||||
{
|
|
||||||
// We've collected enough data to use our noise min/max values as a new filter
|
// We've collected enough data to use our noise min/max values as a new filter
|
||||||
System.arraycopy(noiseMin, 0, filterMin, 0, filterMin.length);
|
System.arraycopy(noiseMin, 0, filterMin, 0, filterMin.length);
|
||||||
System.arraycopy(noiseMax, 0, filterMax, 0, filterMax.length);
|
System.arraycopy(noiseMax, 0, filterMax, 0, filterMax.length);
|
||||||
}
|
}
|
||||||
if( measurementIteration > 15 )
|
if (measurementIteration > 15) {
|
||||||
{
|
Log.d("SDL", "GYRO_NOISE: Measuring done! Maximum number of iterations reached: " + measurementIteration);
|
||||||
Log.d( "SDL", "GYRO_NOISE: Measuring done! Maximum number of iterations reached: " + measurementIteration );
|
|
||||||
noiseData = null;
|
noiseData = null;
|
||||||
measuredNoiseRange = null;
|
measuredNoiseRange = null;
|
||||||
return;
|
return;
|
||||||
@ -181,15 +161,13 @@ class AccelerometerReader implements SensorEventListener
|
|||||||
|
|
||||||
noiseDataIdx = 0;
|
noiseDataIdx = 0;
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for( int i = 0; i < noiseMin.length; i++ )
|
for (int i = 0; i < noiseMin.length; i++) {
|
||||||
{
|
|
||||||
float min = 1.0f;
|
float min = 1.0f;
|
||||||
float max = -1.0f;
|
float max = -1.0f;
|
||||||
for( int ii = 0; ii < noiseData.length; ii++ )
|
for (int ii = 0; ii < noiseData.length; ii++) {
|
||||||
{
|
if (min > noiseData[ii][i])
|
||||||
if( min > noiseData[ii][i] )
|
|
||||||
min = noiseData[ii][i];
|
min = noiseData[ii][i];
|
||||||
if( max < noiseData[ii][i] )
|
if (max < noiseData[ii][i])
|
||||||
max = noiseData[ii][i];
|
max = noiseData[ii][i];
|
||||||
}
|
}
|
||||||
// Increase the range a bit, for safe conservative filtering
|
// Increase the range a bit, for safe conservative filtering
|
||||||
@ -198,8 +176,7 @@ class AccelerometerReader implements SensorEventListener
|
|||||||
max += (max - middle) * 0.2f;
|
max += (max - middle) * 0.2f;
|
||||||
// Check if range between min/max is less then the current range, as a safety measure,
|
// Check if range between min/max is less then the current range, as a safety measure,
|
||||||
// and min/max range is not jumping outside of previously measured range
|
// and min/max range is not jumping outside of previously measured range
|
||||||
if( max - min < noiseMax[i] - noiseMin[i] && min >= noiseMin[i] && max <= noiseMax[i] )
|
if (max - min < noiseMax[i] - noiseMin[i] && min >= noiseMin[i] && max <= noiseMax[i]) {
|
||||||
{
|
|
||||||
// Move old min/max closer to the measured min/max, but do not replace the values altogether
|
// Move old min/max closer to the measured min/max, but do not replace the values altogether
|
||||||
noiseMin[i] = (noiseMin[i] + min * 4.0f) / 5.0f;
|
noiseMin[i] = (noiseMin[i] + min * 4.0f) / 5.0f;
|
||||||
noiseMax[i] = (noiseMax[i] + max * 4.0f) / 5.0f;
|
noiseMax[i] = (noiseMax[i] + max * 4.0f) / 5.0f;
|
||||||
@ -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;
|
return;
|
||||||
|
|
||||||
// Determine when to stop measuring - check that the previous min/max range is close enough to the current one
|
// 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];
|
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];
|
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;
|
measuredNoiseRange = range;
|
||||||
return; // First iteration, skip further checks
|
return; // First iteration, skip further checks
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int i = 0; i < range.length; i++ )
|
for (int i = 0; i < range.length; i++) {
|
||||||
{
|
if (measuredNoiseRange[i] / range[i] > 1.2f) {
|
||||||
if( measuredNoiseRange[i] / range[i] > 1.2f )
|
|
||||||
{
|
|
||||||
measuredNoiseRange = range;
|
measuredNoiseRange = range;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -240,91 +214,82 @@ class AccelerometerReader implements SensorEventListener
|
|||||||
System.arraycopy(noiseMax, 0, filterMax, 0, filterMax.length);
|
System.arraycopy(noiseMax, 0, filterMax, 0, filterMax.length);
|
||||||
noiseData = null;
|
noiseData = null;
|
||||||
measuredNoiseRange = 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;
|
boolean filtered = true;
|
||||||
final float[] data = event.values;
|
final float[] data = event.values;
|
||||||
|
|
||||||
if( noiseData != null )
|
if (noiseData != null)
|
||||||
collectNoiseData(data);
|
collectNoiseData(data);
|
||||||
|
|
||||||
for( int i = 0; i < 3; i++ )
|
for (int i = 0; i < 3; i++) {
|
||||||
{
|
if (data[i] < filterMin[i]) {
|
||||||
if( data[i] < filterMin[i] )
|
|
||||||
{
|
|
||||||
filtered = false;
|
filtered = false;
|
||||||
data[i] -= filterMin[i];
|
data[i] -= filterMin[i];
|
||||||
}
|
} else if (data[i] > filterMax[i]) {
|
||||||
else if( data[i] > filterMax[i] )
|
|
||||||
{
|
|
||||||
filtered = false;
|
filtered = false;
|
||||||
data[i] -= filterMax[i];
|
data[i] -= filterMax[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( filtered )
|
if (filtered)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( Globals.HorizontalOrientation )
|
if (Globals.HorizontalOrientation) {
|
||||||
{
|
if (invertedOrientation)
|
||||||
if( invertedOrientation )
|
|
||||||
nativeGyroscope(-data[0], -data[1], data[2]);
|
nativeGyroscope(-data[0], -data[1], data[2]);
|
||||||
else
|
else
|
||||||
nativeGyroscope(data[0], data[1], data[2]);
|
nativeGyroscope(data[0], data[1], data[2]);
|
||||||
}
|
} else {
|
||||||
else
|
if (invertedOrientation)
|
||||||
{
|
|
||||||
if( invertedOrientation )
|
|
||||||
nativeGyroscope(-data[1], data[0], data[2]);
|
nativeGyroscope(-data[1], data[0], data[2]);
|
||||||
else
|
else
|
||||||
nativeGyroscope(data[1], -data[0], data[2]);
|
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);
|
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||||
return ( manager != null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null );
|
return (manager != null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null);
|
||||||
}
|
}
|
||||||
public void registerListener(AppCompatActivity context, SensorEventListener l)
|
|
||||||
{
|
public void registerListener(AppCompatActivity context, SensorEventListener l) {
|
||||||
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||||
if ( manager == null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) == null )
|
if (manager == null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) == null)
|
||||||
return;
|
return;
|
||||||
manager.registerListener(gyro, manager.getDefaultSensor(
|
manager.registerListener(gyro, manager.getDefaultSensor(
|
||||||
Globals.AppUsesOrientationSensor ? Sensor.TYPE_GAME_ROTATION_VECTOR : Sensor.TYPE_GYROSCOPE),
|
Globals.AppUsesOrientationSensor ? Sensor.TYPE_GAME_ROTATION_VECTOR : Sensor.TYPE_GYROSCOPE),
|
||||||
SensorManager.SENSOR_DELAY_GAME);
|
SensorManager.SENSOR_DELAY_GAME);
|
||||||
}
|
}
|
||||||
public void unregisterListener(AppCompatActivity context, SensorEventListener l)
|
|
||||||
{
|
public void unregisterListener(AppCompatActivity context, SensorEventListener l) {
|
||||||
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||||
if ( manager == null )
|
if (manager == null)
|
||||||
return;
|
return;
|
||||||
manager.unregisterListener(l);
|
manager.unregisterListener(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class OrientationListener implements SensorEventListener
|
static class OrientationListener implements SensorEventListener {
|
||||||
{
|
public OrientationListener() {
|
||||||
public OrientationListener()
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
public void onSensorChanged(SensorEvent event)
|
|
||||||
{
|
public void onSensorChanged(SensorEvent event) {
|
||||||
nativeOrientation(event.values[0], event.values[1], event.values[2]);
|
nativeOrientation(event.values[0], event.values[1], event.values[2]);
|
||||||
}
|
}
|
||||||
public void onAccuracyChanged(Sensor s, int a)
|
|
||||||
{
|
public void onAccuracyChanged(Sensor s, int a) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native void nativeAccelerometer(float accX, float accY, float accZ);
|
private static native void nativeAccelerometer(float accX, float accY, float accZ);
|
||||||
|
|
||||||
private static native void nativeGyroscope(float X, float Y, float Z);
|
private static native void nativeGyroscope(float X, float Y, float Z);
|
||||||
|
|
||||||
private static native void nativeOrientation(float X, float Y, float Z);
|
private static native void nativeOrientation(float X, float Y, float Z);
|
||||||
}
|
}
|
||||||
|
@ -23,77 +23,60 @@ freely, subject to the following restrictions:
|
|||||||
package io.neoterm;
|
package io.neoterm;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.media.AudioTrack;
|
|
||||||
import android.media.AudioManager;
|
|
||||||
import android.media.AudioFormat;
|
import android.media.AudioFormat;
|
||||||
|
import android.media.AudioManager;
|
||||||
import android.media.AudioRecord;
|
import android.media.AudioRecord;
|
||||||
|
import android.media.AudioTrack;
|
||||||
import android.media.MediaRecorder.AudioSource;
|
import android.media.MediaRecorder.AudioSource;
|
||||||
import java.io.*;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import java.util.concurrent.Semaphore;
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
|
|
||||||
import io.neoterm.xorg.NeoXorgViewClient;
|
import io.neoterm.xorg.NeoXorgViewClient;
|
||||||
|
|
||||||
|
import java.util.concurrent.Semaphore;
|
||||||
|
|
||||||
@SuppressWarnings("JniMissingFunction")
|
@SuppressWarnings("JniMissingFunction")
|
||||||
class AudioThread
|
class AudioThread {
|
||||||
{
|
|
||||||
private NeoXorgViewClient mClient;
|
private NeoXorgViewClient mClient;
|
||||||
private AudioTrack mAudio;
|
private AudioTrack mAudio;
|
||||||
private byte[] mAudioBuffer;
|
private byte[] mAudioBuffer;
|
||||||
private int mVirtualBufSize;
|
private int mVirtualBufSize;
|
||||||
|
|
||||||
public AudioThread(NeoXorgViewClient client)
|
public AudioThread(NeoXorgViewClient client) {
|
||||||
{
|
|
||||||
this.mClient = client;
|
this.mClient = client;
|
||||||
mAudio = null;
|
mAudio = null;
|
||||||
mAudioBuffer = null;
|
mAudioBuffer = null;
|
||||||
nativeAudioInitJavaCallbacks();
|
nativeAudioInitJavaCallbacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fillBuffer()
|
public int fillBuffer() {
|
||||||
{
|
if (mClient.isPaused()) {
|
||||||
if( mClient.isPaused() )
|
try {
|
||||||
{
|
|
||||||
try{
|
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
} catch (InterruptedException e) {}
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
//if( Globals.AudioBufferConfig == 0 ) // Gives too much spam to logcat, makes things worse
|
//if( Globals.AudioBufferConfig == 0 ) // Gives too much spam to logcat, makes things worse
|
||||||
// mAudio.flush();
|
// mAudio.flush();
|
||||||
|
|
||||||
mAudio.write( mAudioBuffer, 0, mVirtualBufSize );
|
mAudio.write(mAudioBuffer, 0, mVirtualBufSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int initAudio(int rate, int channels, int encoding, int bufSize)
|
public int initAudio(int rate, int channels, int encoding, int bufSize) {
|
||||||
{
|
if (mAudio == null) {
|
||||||
if( mAudio == null )
|
channels = (channels == 1) ? AudioFormat.CHANNEL_CONFIGURATION_MONO :
|
||||||
{
|
|
||||||
channels = ( channels == 1 ) ? AudioFormat.CHANNEL_CONFIGURATION_MONO :
|
|
||||||
AudioFormat.CHANNEL_CONFIGURATION_STEREO;
|
AudioFormat.CHANNEL_CONFIGURATION_STEREO;
|
||||||
encoding = ( encoding == 1 ) ? AudioFormat.ENCODING_PCM_16BIT :
|
encoding = (encoding == 1) ? AudioFormat.ENCODING_PCM_16BIT :
|
||||||
AudioFormat.ENCODING_PCM_8BIT;
|
AudioFormat.ENCODING_PCM_8BIT;
|
||||||
|
|
||||||
mVirtualBufSize = bufSize;
|
mVirtualBufSize = bufSize;
|
||||||
|
|
||||||
if( AudioTrack.getMinBufferSize( rate, channels, encoding ) > bufSize )
|
if (AudioTrack.getMinBufferSize(rate, channels, encoding) > bufSize)
|
||||||
bufSize = AudioTrack.getMinBufferSize( rate, channels, encoding );
|
bufSize = AudioTrack.getMinBufferSize(rate, channels, encoding);
|
||||||
|
|
||||||
if(Globals.AudioBufferConfig != 0) { // application's choice - use minimal buffer
|
if (Globals.AudioBufferConfig != 0) { // application's choice - use minimal buffer
|
||||||
bufSize = (int)((float)bufSize * (((float)(Globals.AudioBufferConfig - 1) * 2.5f) + 1.0f));
|
bufSize = (int) ((float) bufSize * (((float) (Globals.AudioBufferConfig - 1) * 2.5f) + 1.0f));
|
||||||
mVirtualBufSize = bufSize;
|
mVirtualBufSize = bufSize;
|
||||||
}
|
}
|
||||||
mAudioBuffer = new byte[bufSize];
|
mAudioBuffer = new byte[bufSize];
|
||||||
@ -103,21 +86,18 @@ class AudioThread
|
|||||||
channels,
|
channels,
|
||||||
encoding,
|
encoding,
|
||||||
bufSize,
|
bufSize,
|
||||||
AudioTrack.MODE_STREAM );
|
AudioTrack.MODE_STREAM);
|
||||||
mAudio.play();
|
mAudio.play();
|
||||||
}
|
}
|
||||||
return mVirtualBufSize;
|
return mVirtualBufSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getBuffer()
|
public byte[] getBuffer() {
|
||||||
{
|
|
||||||
return mAudioBuffer;
|
return mAudioBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int deinitAudio()
|
public int deinitAudio() {
|
||||||
{
|
if (mAudio != null) {
|
||||||
if( mAudio != null )
|
|
||||||
{
|
|
||||||
mAudio.stop();
|
mAudio.stop();
|
||||||
mAudio.release();
|
mAudio.release();
|
||||||
mAudio = null;
|
mAudio = null;
|
||||||
@ -126,34 +106,27 @@ class AudioThread
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int initAudioThread()
|
public int initAudioThread() {
|
||||||
{
|
|
||||||
// Make audio thread priority higher so audio thread won't get underrun
|
// Make audio thread priority higher so audio thread won't get underrun
|
||||||
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
|
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int pauseAudioPlayback()
|
public int pauseAudioPlayback() {
|
||||||
{
|
if (mAudio != null) {
|
||||||
if( mAudio != null )
|
|
||||||
{
|
|
||||||
mAudio.pause();
|
mAudio.pause();
|
||||||
}
|
}
|
||||||
if( mRecordThread != null )
|
if (mRecordThread != null) {
|
||||||
{
|
|
||||||
mRecordThread.pauseRecording();
|
mRecordThread.pauseRecording();
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int resumeAudioPlayback()
|
public int resumeAudioPlayback() {
|
||||||
{
|
if (mAudio != null) {
|
||||||
if( mAudio != null )
|
|
||||||
{
|
|
||||||
mAudio.play();
|
mAudio.play();
|
||||||
}
|
}
|
||||||
if( mRecordThread != null )
|
if (mRecordThread != null) {
|
||||||
{
|
|
||||||
mRecordThread.resumeRecording();
|
mRecordThread.resumeRecording();
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -167,35 +140,31 @@ class AudioThread
|
|||||||
private AudioRecord mRecorder = null;
|
private AudioRecord mRecorder = null;
|
||||||
private int mRecorderBufferSize = 0;
|
private int mRecorderBufferSize = 0;
|
||||||
|
|
||||||
private byte[] startRecording(int rate, int channels, int encoding, int bufsize)
|
private byte[] startRecording(int rate, int channels, int encoding, int bufsize) {
|
||||||
{
|
if (mRecordThread == null) {
|
||||||
if( mRecordThread == null )
|
|
||||||
{
|
|
||||||
mRecordThread = new RecordingThread();
|
mRecordThread = new RecordingThread();
|
||||||
mRecordThread.start();
|
mRecordThread.start();
|
||||||
}
|
}
|
||||||
if( !mRecordThread.isStopped() )
|
if (!mRecordThread.isStopped()) {
|
||||||
{
|
|
||||||
Log.i("SDL", "SDL: error: application already opened audio recording device");
|
Log.i("SDL", "SDL: error: application already opened audio recording device");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
mRecordThread.init(bufsize);
|
mRecordThread.init(bufsize);
|
||||||
|
|
||||||
int channelConfig = ( channels == 1 ) ? AudioFormat.CHANNEL_IN_MONO :
|
int channelConfig = (channels == 1) ? AudioFormat.CHANNEL_IN_MONO :
|
||||||
AudioFormat.CHANNEL_IN_STEREO;
|
AudioFormat.CHANNEL_IN_STEREO;
|
||||||
int encodingConfig = ( encoding == 1 ) ? AudioFormat.ENCODING_PCM_16BIT :
|
int encodingConfig = (encoding == 1) ? AudioFormat.ENCODING_PCM_16BIT :
|
||||||
AudioFormat.ENCODING_PCM_8BIT;
|
AudioFormat.ENCODING_PCM_8BIT;
|
||||||
|
|
||||||
int minBufDevice = AudioRecord.getMinBufferSize(rate, channelConfig, encodingConfig);
|
int minBufDevice = AudioRecord.getMinBufferSize(rate, channelConfig, encodingConfig);
|
||||||
int minBufferSize = Math.max(bufsize * 8, minBufDevice + (bufsize - (minBufDevice % bufsize)));
|
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);
|
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 ||
|
if (mRecorder == null || mRecorder.getSampleRate() != rate ||
|
||||||
mRecorder.getChannelCount() != channels ||
|
mRecorder.getChannelCount() != channels ||
|
||||||
mRecorder.getAudioFormat() != encodingConfig ||
|
mRecorder.getAudioFormat() != encodingConfig ||
|
||||||
mRecorderBufferSize != minBufferSize )
|
mRecorderBufferSize != minBufferSize) {
|
||||||
{
|
if (mRecorder != null)
|
||||||
if( mRecorder != null )
|
|
||||||
mRecorder.release();
|
mRecorder.release();
|
||||||
mRecorder = null;
|
mRecorder = null;
|
||||||
try {
|
try {
|
||||||
@ -217,19 +186,15 @@ class AudioThread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.i("SDL", "SDL: reusing old recording device");
|
Log.i("SDL", "SDL: reusing old recording device");
|
||||||
}
|
}
|
||||||
mRecordThread.startRecording();
|
mRecordThread.startRecording();
|
||||||
return mRecordThread.mRecordBuffer;
|
return mRecordThread.mRecordBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopRecording()
|
private void stopRecording() {
|
||||||
{
|
if (mRecordThread == null || mRecordThread.isStopped()) {
|
||||||
if( mRecordThread == null || mRecordThread.isStopped() )
|
|
||||||
{
|
|
||||||
Log.i("SDL", "SDL: error: application already closed audio recording device");
|
Log.i("SDL", "SDL: error: application already closed audio recording device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -237,45 +202,37 @@ class AudioThread
|
|||||||
Log.i("SDL", "SDL: app closed recording device");
|
Log.i("SDL", "SDL: app closed recording device");
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RecordingThread extends Thread
|
private class RecordingThread extends Thread {
|
||||||
{
|
|
||||||
private boolean stopped = true;
|
private boolean stopped = true;
|
||||||
byte[] mRecordBuffer;
|
byte[] mRecordBuffer;
|
||||||
private Semaphore waitStarted = new Semaphore(0);
|
private Semaphore waitStarted = new Semaphore(0);
|
||||||
private boolean sleep = false;
|
private boolean sleep = false;
|
||||||
|
|
||||||
RecordingThread()
|
RecordingThread() {
|
||||||
{
|
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(int bufsize)
|
void init(int bufsize) {
|
||||||
{
|
if (mRecordBuffer == null || mRecordBuffer.length != bufsize)
|
||||||
if( mRecordBuffer == null || mRecordBuffer.length != bufsize )
|
|
||||||
mRecordBuffer = new byte[bufsize];
|
mRecordBuffer = new byte[bufsize];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
while (true) {
|
||||||
while( true )
|
|
||||||
{
|
|
||||||
waitStarted.acquireUninterruptibly();
|
waitStarted.acquireUninterruptibly();
|
||||||
waitStarted.drainPermits();
|
waitStarted.drainPermits();
|
||||||
stopped = false;
|
stopped = false;
|
||||||
sleep = false;
|
sleep = false;
|
||||||
|
|
||||||
while( !sleep )
|
while (!sleep) {
|
||||||
{
|
|
||||||
int got = mRecorder.read(mRecordBuffer, 0, mRecordBuffer.length);
|
int got = mRecorder.read(mRecordBuffer, 0, mRecordBuffer.length);
|
||||||
if( got != mRecordBuffer.length )
|
if (got != mRecordBuffer.length) {
|
||||||
{
|
|
||||||
// Audio is stopped here, sleep a bit.
|
// Audio is stopped here, sleep a bit.
|
||||||
try{
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException e) {}
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
//Log.i("SDL", "SDL: nativeAudioRecordCallback with len " + mRecordBuffer.length);
|
//Log.i("SDL", "SDL: nativeAudioRecordCallback with len " + mRecordBuffer.length);
|
||||||
nativeAudioRecordCallback();
|
nativeAudioRecordCallback();
|
||||||
//Log.i("SDL", "SDL: nativeAudioRecordCallback returned");
|
//Log.i("SDL", "SDL: nativeAudioRecordCallback returned");
|
||||||
@ -287,33 +244,32 @@ class AudioThread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startRecording()
|
public void startRecording() {
|
||||||
{
|
|
||||||
mRecorder.startRecording();
|
mRecorder.startRecording();
|
||||||
waitStarted.release();
|
waitStarted.release();
|
||||||
}
|
}
|
||||||
public void stopRecording()
|
|
||||||
{
|
public void stopRecording() {
|
||||||
sleep = true;
|
sleep = true;
|
||||||
while( !stopped )
|
while (!stopped) {
|
||||||
{
|
try {
|
||||||
try{
|
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
} catch (InterruptedException e) {}
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void pauseRecording()
|
}
|
||||||
{
|
|
||||||
if( !stopped )
|
public void pauseRecording() {
|
||||||
|
if (!stopped)
|
||||||
mRecorder.stop();
|
mRecorder.stop();
|
||||||
}
|
}
|
||||||
public void resumeRecording()
|
|
||||||
{
|
public void resumeRecording() {
|
||||||
if( !stopped )
|
if (!stopped)
|
||||||
mRecorder.startRecording();
|
mRecorder.startRecording();
|
||||||
}
|
}
|
||||||
public boolean isStopped()
|
|
||||||
{
|
public boolean isStopped() {
|
||||||
return stopped;
|
return stopped;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,116 +22,91 @@ freely, subject to the following restrictions:
|
|||||||
|
|
||||||
package io.neoterm;
|
package io.neoterm;
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.content.res.AssetManager;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.InputDevice;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
|
||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.ClipboardManager.OnPrimaryClipChangedListener;
|
import android.content.ClipboardManager.OnPrimaryClipChangedListener;
|
||||||
import android.app.PendingIntent;
|
import android.content.Context;
|
||||||
import android.app.AlarmManager;
|
import android.os.Build;
|
||||||
import android.content.Intent;
|
import android.util.Log;
|
||||||
import android.view.View;
|
|
||||||
import android.view.Display;
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class Clipboard
|
public abstract class Clipboard {
|
||||||
{
|
public static Clipboard get() {
|
||||||
public static Clipboard get()
|
|
||||||
{
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||||
return NewerClipboard.Holder.Instance;
|
return NewerClipboard.Holder.Instance;
|
||||||
return OlderClipboard.Holder.Instance;
|
return OlderClipboard.Holder.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void set(final Context context, final String text);
|
public abstract void set(final Context context, final String text);
|
||||||
|
|
||||||
public abstract String get(final Context context);
|
public abstract String get(final Context context);
|
||||||
|
|
||||||
public abstract void setListener(final Context context, final Runnable listener);
|
public abstract void setListener(final Context context, final Runnable listener);
|
||||||
|
|
||||||
private static class NewerClipboard extends Clipboard
|
private static class NewerClipboard extends Clipboard {
|
||||||
{
|
private static class Holder {
|
||||||
private static class Holder
|
|
||||||
{
|
|
||||||
private static final NewerClipboard Instance = new NewerClipboard();
|
private static final NewerClipboard Instance = new NewerClipboard();
|
||||||
}
|
}
|
||||||
public void set(final Context context, final String text)
|
|
||||||
{
|
public void set(final Context context, final String text) {
|
||||||
try {
|
try {
|
||||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
||||||
if( clipboard != null )
|
if (clipboard != null)
|
||||||
clipboard.setText(text);
|
clipboard.setText(text);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.i("SDL", "setClipboardText() exception: " + e.toString());
|
Log.i("SDL", "setClipboardText() exception: " + e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public String get(final Context context)
|
|
||||||
{
|
public String get(final Context context) {
|
||||||
String ret = "";
|
String ret = "";
|
||||||
try {
|
try {
|
||||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
||||||
if( clipboard != null && clipboard.getText() != null )
|
if (clipboard != null && clipboard.getText() != null)
|
||||||
ret = clipboard.getText().toString();
|
ret = clipboard.getText().toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.i("SDL", "getClipboardText() exception: " + e.toString());
|
Log.i("SDL", "getClipboardText() exception: " + e.toString());
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
public void setListener(final Context context, final Runnable listener)
|
|
||||||
{
|
public void setListener(final Context context, final Runnable listener) {
|
||||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
||||||
clipboard.addPrimaryClipChangedListener(new OnPrimaryClipChangedListener()
|
clipboard.addPrimaryClipChangedListener(new OnPrimaryClipChangedListener() {
|
||||||
{
|
public void onPrimaryClipChanged() {
|
||||||
public void onPrimaryClipChanged()
|
|
||||||
{
|
|
||||||
listener.run();
|
listener.run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class OlderClipboard extends Clipboard
|
private static class OlderClipboard extends Clipboard {
|
||||||
{
|
private static class Holder {
|
||||||
private static class Holder
|
|
||||||
{
|
|
||||||
private static final OlderClipboard Instance = new OlderClipboard();
|
private static final OlderClipboard Instance = new OlderClipboard();
|
||||||
}
|
}
|
||||||
public void set(final Context context, final String text)
|
|
||||||
{
|
public void set(final Context context, final String text) {
|
||||||
try {
|
try {
|
||||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
||||||
if( clipboard != null )
|
if (clipboard != null)
|
||||||
clipboard.setText(text);
|
clipboard.setText(text);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.i("SDL", "setClipboardText() exception: " + e.toString());
|
Log.i("SDL", "setClipboardText() exception: " + e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public String get(final Context context)
|
|
||||||
{
|
public String get(final Context context) {
|
||||||
String ret = "";
|
String ret = "";
|
||||||
try {
|
try {
|
||||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
||||||
if( clipboard != null && clipboard.getText() != null )
|
if (clipboard != null && clipboard.getText() != null)
|
||||||
ret = clipboard.getText().toString();
|
ret = clipboard.getText().toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.i("SDL", "getClipboardText() exception: " + e.toString());
|
Log.i("SDL", "getClipboardText() exception: " + e.toString());
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
public void setListener(final Context context, final Runnable listener)
|
|
||||||
{
|
public void setListener(final Context context, final Runnable listener) {
|
||||||
Log.i("SDL", "Cannot set clipboard listener on Android 2.3 or older");
|
Log.i("SDL", "Cannot set clipboard listener on Android 2.3 or older");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,27 +20,19 @@
|
|||||||
|
|
||||||
package io.neoterm;
|
package io.neoterm;
|
||||||
|
|
||||||
import java.io.Writer;
|
import android.app.KeyguardManager;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.concurrent.Semaphore;
|
|
||||||
|
|
||||||
import javax.microedition.khronos.egl.EGL10;
|
|
||||||
import javax.microedition.khronos.egl.EGL11;
|
|
||||||
import javax.microedition.khronos.egl.EGLConfig;
|
|
||||||
import javax.microedition.khronos.egl.EGLContext;
|
|
||||||
import javax.microedition.khronos.egl.EGLDisplay;
|
|
||||||
import javax.microedition.khronos.egl.EGLSurface;
|
|
||||||
import javax.microedition.khronos.opengles.GL;
|
|
||||||
import javax.microedition.khronos.opengles.GL10;
|
|
||||||
|
|
||||||
import android.opengl.EGL14; // Android 4.2 or newer
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
import android.app.KeyguardManager;
|
|
||||||
|
import javax.microedition.khronos.egl.*;
|
||||||
|
import javax.microedition.khronos.opengles.GL;
|
||||||
|
import javax.microedition.khronos.opengles.GL10;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.Semaphore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of SurfaceView that uses the dedicated surface for
|
* An implementation of SurfaceView that uses the dedicated surface for
|
||||||
@ -149,7 +141,6 @@ import android.app.KeyguardManager;
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("ALL")
|
@SuppressWarnings("ALL")
|
||||||
public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Callback {
|
public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Callback {
|
||||||
@ -213,7 +204,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
SurfaceHolder holder = getHolder();
|
SurfaceHolder holder = getHolder();
|
||||||
holder.addCallback(this);
|
holder.addCallback(this);
|
||||||
holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
|
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.
|
* Wrapping is typically used for debugging purposes.
|
||||||
* <p>
|
* <p>
|
||||||
* The default value is null.
|
* The default value is null.
|
||||||
|
*
|
||||||
* @param glWrapper the new GLWrapper
|
* @param glWrapper the new GLWrapper
|
||||||
*/
|
*/
|
||||||
public void setGLWrapper(GLWrapper glWrapper) {
|
public void setGLWrapper(GLWrapper glWrapper) {
|
||||||
@ -238,6 +230,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
* constructed by OR-together zero or more
|
* constructed by OR-together zero or more
|
||||||
* of the DEBUG_CHECK_* constants. The debug flags take effect
|
* of the DEBUG_CHECK_* constants. The debug flags take effect
|
||||||
* whenever a surface is created. The default value is zero.
|
* whenever a surface is created. The default value is zero.
|
||||||
|
*
|
||||||
* @param debugFlags the new debug flags
|
* @param debugFlags the new debug flags
|
||||||
* @see #DEBUG_CHECK_GL_ERROR
|
* @see #DEBUG_CHECK_GL_ERROR
|
||||||
* @see #DEBUG_LOG_GL_CALLS
|
* @see #DEBUG_LOG_GL_CALLS
|
||||||
@ -248,6 +241,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current value of the debug flags.
|
* Get the current value of the debug flags.
|
||||||
|
*
|
||||||
* @return the current value of the debug flags.
|
* @return the current value of the debug flags.
|
||||||
*/
|
*/
|
||||||
public int getDebugFlags() {
|
public int getDebugFlags() {
|
||||||
@ -301,6 +295,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
* If no setEGLConfigChooser method is called, then by default the
|
* If no setEGLConfigChooser method is called, then by default the
|
||||||
* view will choose a config as close to 16-bit RGB as possible, with
|
* view will choose a config as close to 16-bit RGB as possible, with
|
||||||
* a depth buffer as close to 16 bits as possible.
|
* a depth buffer as close to 16 bits as possible.
|
||||||
|
*
|
||||||
* @param configChooser
|
* @param configChooser
|
||||||
*/
|
*/
|
||||||
public void setEGLConfigChooser(EGLConfigChooser configChooser) {
|
public void setEGLConfigChooser(EGLConfigChooser configChooser) {
|
||||||
@ -340,13 +335,13 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
* If no setEGLConfigChooser method is called, then by default the
|
* If no setEGLConfigChooser method is called, then by default the
|
||||||
* view will choose a config as close to 16-bit RGB as possible, with
|
* view will choose a config as close to 16-bit RGB as possible, with
|
||||||
* a depth buffer as close to 16 bits as possible.
|
* a depth buffer as close to 16 bits as possible.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void setEGLConfigChooser(int redSize, int greenSize, int blueSize,
|
public void setEGLConfigChooser(int redSize, int greenSize, int blueSize,
|
||||||
int alphaSize, int depthSize, int stencilSize, boolean gles2, boolean gles3) {
|
int alphaSize, int depthSize, int stencilSize, boolean gles2, boolean gles3) {
|
||||||
setEGLConfigChooser(new ComponentSizeChooser(redSize, greenSize,
|
setEGLConfigChooser(new ComponentSizeChooser(redSize, greenSize,
|
||||||
blueSize, alphaSize, depthSize, stencilSize, gles2, gles3));
|
blueSize, alphaSize, depthSize, stencilSize, gles2, gles3));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the rendering mode. When renderMode is
|
* Set the rendering mode. When renderMode is
|
||||||
* RENDERMODE_CONTINUOUSLY, the renderer is called
|
* RENDERMODE_CONTINUOUSLY, the renderer is called
|
||||||
@ -370,6 +365,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
/**
|
/**
|
||||||
* Get the current rendering mode. May be called
|
* Get the current rendering mode. May be called
|
||||||
* from any thread. Must not be called before a renderer has been set.
|
* from any thread. Must not be called before a renderer has been set.
|
||||||
|
*
|
||||||
* @return the current rendering mode.
|
* @return the current rendering mode.
|
||||||
* @see #RENDERMODE_CONTINUOUSLY
|
* @see #RENDERMODE_CONTINUOUSLY
|
||||||
* @see #RENDERMODE_WHEN_DIRTY
|
* @see #RENDERMODE_WHEN_DIRTY
|
||||||
@ -439,6 +435,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
* Queue a runnable to be run on the GL rendering thread. This can be used
|
* Queue a runnable to be run on the GL rendering thread. This can be used
|
||||||
* to communicate with the Renderer on the rendering thread.
|
* to communicate with the Renderer on the rendering thread.
|
||||||
* Must not be called before a renderer has been set.
|
* Must not be called before a renderer has been set.
|
||||||
|
*
|
||||||
* @param r the runnable to be run on the GL rendering thread.
|
* @param r the runnable to be run on the GL rendering thread.
|
||||||
*/
|
*/
|
||||||
public void queueEvent(Runnable r) {
|
public void queueEvent(Runnable r) {
|
||||||
@ -477,11 +474,13 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @see #setGLWrapper(GLWrapper)
|
* @see #setGLWrapper(GLWrapper)
|
||||||
*/
|
*/
|
||||||
public interface GLWrapper {
|
public interface GLWrapper {
|
||||||
/**
|
/**
|
||||||
* Wraps a gl interface in another gl interface.
|
* Wraps a gl interface in another gl interface.
|
||||||
|
*
|
||||||
* @param gl a GL interface that is to be wrapped.
|
* @param gl a GL interface that is to be wrapped.
|
||||||
* @return either the input argument or another GL object that wraps the input argument.
|
* @return either the input argument or another GL object that wraps the input argument.
|
||||||
*/
|
*/
|
||||||
@ -514,12 +513,13 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
* that it still needs. The {@link #onSurfaceCreated(GL10, EGLConfig)} method
|
* that it still needs. The {@link #onSurfaceCreated(GL10, EGLConfig)} method
|
||||||
* is a convenient place to do this.
|
* is a convenient place to do this.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @see #setRenderer(Renderer)
|
* @see #setRenderer(Renderer)
|
||||||
*/
|
*/
|
||||||
public static interface SwapBuffersCallback {
|
public static interface SwapBuffersCallback {
|
||||||
public boolean SwapBuffers();
|
public boolean SwapBuffers();
|
||||||
|
|
||||||
public void ResetVideoSurface();
|
public void ResetVideoSurface();
|
||||||
|
|
||||||
public void onWindowResize(int width, int height);
|
public void onWindowResize(int width, int height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,6 +543,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
* the corresponding "glDelete" methods such as glDeleteTextures to
|
* the corresponding "glDelete" methods such as glDeleteTextures to
|
||||||
* manually delete these lost resources.
|
* manually delete these lost resources.
|
||||||
* <p>
|
* <p>
|
||||||
|
*
|
||||||
* @param gl the GL interface. Use <code>instanceof</code> to
|
* @param gl the GL interface. Use <code>instanceof</code> to
|
||||||
* test if the interface supports GL11 or higher interfaces.
|
* test if the interface supports GL11 or higher interfaces.
|
||||||
* @param config the EGLConfig of the created surface. Can be used
|
* @param config the EGLConfig of the created surface. Can be used
|
||||||
@ -570,6 +571,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
* gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);
|
* gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param gl the GL interface. Use <code>instanceof</code> to
|
* @param gl the GL interface. Use <code>instanceof</code> to
|
||||||
* test if the interface supports GL11 or higher interfaces.
|
* test if the interface supports GL11 or higher interfaces.
|
||||||
* @param width
|
* @param width
|
||||||
@ -577,10 +579,11 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
*/
|
*/
|
||||||
public abstract void onSurfaceChanged(GL10 gl, int width, int height);
|
public abstract void onSurfaceChanged(GL10 gl, int width, int height);
|
||||||
|
|
||||||
/** Called when screen size changes */
|
/**
|
||||||
public void onWindowResize(int width, int height)
|
* Called when screen size changes
|
||||||
{
|
*/
|
||||||
if( mSwapBuffersCallback != null )
|
public void onWindowResize(int width, int height) {
|
||||||
|
if (mSwapBuffersCallback != null)
|
||||||
mSwapBuffersCallback.onWindowResize(width, height);
|
mSwapBuffersCallback.onWindowResize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,23 +599,24 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
* //... other gl calls to render the scene ...
|
* //... other gl calls to render the scene ...
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param gl the GL interface. Use <code>instanceof</code> to
|
* @param gl the GL interface. Use <code>instanceof</code> to
|
||||||
* test if the interface supports GL11 or higher interfaces.
|
* test if the interface supports GL11 or higher interfaces.
|
||||||
*/
|
*/
|
||||||
public abstract void onDrawFrame(GL10 gl);
|
public abstract void onDrawFrame(GL10 gl);
|
||||||
|
|
||||||
public boolean SwapBuffers() {
|
public boolean SwapBuffers() {
|
||||||
if( mSwapBuffersCallback != null )
|
if (mSwapBuffersCallback != null)
|
||||||
return mSwapBuffersCallback.SwapBuffers();
|
return mSwapBuffersCallback.SwapBuffers();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetVideoSurface() {
|
public void ResetVideoSurface() {
|
||||||
if( mSwapBuffersCallback != null )
|
if (mSwapBuffersCallback != null)
|
||||||
mSwapBuffersCallback.ResetVideoSurface();
|
mSwapBuffersCallback.ResetVideoSurface();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSwapBuffersCallback( SwapBuffersCallback c ) {
|
public void setSwapBuffersCallback(SwapBuffersCallback c) {
|
||||||
mSwapBuffersCallback = c;
|
mSwapBuffersCallback = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -632,12 +636,15 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
* implement this method by calling
|
* implement this method by calling
|
||||||
* {@link EGL10#eglChooseConfig} and iterating through the results. Please consult the
|
* {@link EGL10#eglChooseConfig} and iterating through the results. Please consult the
|
||||||
* EGL specification available from The Khronos Group to learn how to call eglChooseConfig.
|
* EGL specification available from The Khronos Group to learn how to call eglChooseConfig.
|
||||||
|
*
|
||||||
* @param egl the EGL10 for the current display.
|
* @param egl the EGL10 for the current display.
|
||||||
* @param display the current display.
|
* @param display the current display.
|
||||||
* @return the chosen configuration.
|
* @return the chosen configuration.
|
||||||
*/
|
*/
|
||||||
EGLConfig chooseConfig(EGL10 egl, EGLDisplay display);
|
EGLConfig chooseConfig(EGL10 egl, EGLDisplay display);
|
||||||
|
|
||||||
public boolean isGles2Required();
|
public boolean isGles2Required();
|
||||||
|
|
||||||
public boolean isGles3Required();
|
public boolean isGles3Required();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,6 +653,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
public BaseConfigChooser(int[] configSpec) {
|
public BaseConfigChooser(int[] configSpec) {
|
||||||
mConfigSpec = configSpec;
|
mConfigSpec = configSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
|
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
|
||||||
int[] num_config = new int[1];
|
int[] num_config = new int[1];
|
||||||
egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config);
|
egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config);
|
||||||
@ -676,7 +684,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
private static class ComponentSizeChooser extends BaseConfigChooser {
|
private static class ComponentSizeChooser extends BaseConfigChooser {
|
||||||
public ComponentSizeChooser(int redSize, int greenSize, int blueSize,
|
public ComponentSizeChooser(int redSize, int greenSize, int blueSize,
|
||||||
int alphaSize, int depthSize, int stencilSize, boolean isGles2, boolean isGles3) {
|
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];
|
mValue = new int[1];
|
||||||
mRedSize = redSize;
|
mRedSize = redSize;
|
||||||
mGreenSize = greenSize;
|
mGreenSize = greenSize;
|
||||||
@ -698,8 +706,8 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
int selectidx = -1;
|
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"));
|
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) {
|
for (EGLConfig config : configs) {
|
||||||
if ( config == null )
|
if (config == null)
|
||||||
continue;
|
continue;
|
||||||
int r = findConfigAttrib(egl, display, config,
|
int r = findConfigAttrib(egl, display, config,
|
||||||
EGL10.EGL_RED_SIZE, 0);
|
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);
|
EGL10.EGL_CONFIG_CAVEAT, EGL10.EGL_NONE);
|
||||||
int distance = Math.abs(r - mRedSize) + Math.abs(g - mGreenSize) + Math.abs(b - mBlueSize);
|
int distance = Math.abs(r - mRedSize) + Math.abs(g - mGreenSize) + Math.abs(b - mBlueSize);
|
||||||
int dist1 = distance;
|
int dist1 = distance;
|
||||||
if( mAlphaSize - a > 0 )
|
if (mAlphaSize - a > 0)
|
||||||
distance += mAlphaSize - a;
|
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
|
distance += 1; // Small penalty if we don't need alpha channel but it is present
|
||||||
int dist2 = distance;
|
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
|
distance += (mDepthSize > 0) ? 5 : 1; // Small penalty if we don't need zbuffer but it is present
|
||||||
int dist3 = distance;
|
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
|
distance += (mStencilSize > 0) ? 5 : 1; // Small penalty if we don't need stencil buffer but it is present
|
||||||
int dist4 = distance;
|
int dist4 = distance;
|
||||||
if( (rendertype & desiredtype) == 0 )
|
if ((rendertype & desiredtype) == 0)
|
||||||
distance += 5;
|
distance += 5;
|
||||||
int dist5 = distance;
|
int dist5 = distance;
|
||||||
if( caveat == EGL10.EGL_SLOW_CONFIG )
|
if (caveat == EGL10.EGL_SLOW_CONFIG)
|
||||||
distance += 4;
|
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;
|
distance += 1;
|
||||||
|
|
||||||
String cfgcur = "R" + r + "G" + g + "B" + b + "A" + a + " depth " + d + " stencil " + s +
|
String cfgcur = "R" + r + "G" + g + "B" + b + "A" + a + " depth " + d + " stencil " + s +
|
||||||
" type " + rendertype + " (";
|
" type " + rendertype + " (";
|
||||||
if((rendertype & EGL_OPENGL_ES_BIT) != 0)
|
if ((rendertype & EGL_OPENGL_ES_BIT) != 0)
|
||||||
cfgcur += "GLES";
|
cfgcur += "GLES";
|
||||||
if((rendertype & EGL_OPENGL_ES2_BIT) != 0)
|
if ((rendertype & EGL_OPENGL_ES2_BIT) != 0)
|
||||||
cfgcur += " GLES2";
|
cfgcur += " GLES2";
|
||||||
if((rendertype & EGL_OPENGL_ES3_BIT) != 0)
|
if ((rendertype & EGL_OPENGL_ES3_BIT) != 0)
|
||||||
cfgcur += " GLES3";
|
cfgcur += " GLES3";
|
||||||
if((rendertype & EGL_OPENGL_BIT) != 0)
|
if ((rendertype & EGL_OPENGL_BIT) != 0)
|
||||||
cfgcur += " OPENGL";
|
cfgcur += " OPENGL";
|
||||||
if((rendertype & EGL_OPENVG_BIT) != 0)
|
if ((rendertype & EGL_OPENVG_BIT) != 0)
|
||||||
cfgcur += " OPENVG";
|
cfgcur += " OPENVG";
|
||||||
cfgcur += ")";
|
cfgcur += ")";
|
||||||
cfgcur += " caveat " + (caveat == EGL10.EGL_NONE ? "none" :
|
cfgcur += " caveat " + (caveat == EGL10.EGL_NONE ? "none" :
|
||||||
@ -769,7 +777,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
}
|
}
|
||||||
idx += 1;
|
idx += 1;
|
||||||
}
|
}
|
||||||
Log.v("SDL", "GLSurfaceView_SDL::EGLConfigChooser::chooseConfig(): selected " + selectidx + ": " + cfglog );
|
Log.v("SDL", "GLSurfaceView_SDL::EGLConfigChooser::chooseConfig(): selected " + selectidx + ": " + cfglog);
|
||||||
return closestConfig;
|
return closestConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -783,13 +791,11 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGles2Required()
|
public boolean isGles2Required() {
|
||||||
{
|
|
||||||
return mIsGles2;
|
return mIsGles2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGles3Required()
|
public boolean isGles3Required() {
|
||||||
{
|
|
||||||
return mIsGles3;
|
return mIsGles3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -814,7 +820,6 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
/**
|
/**
|
||||||
* This class will choose a supported surface as close to
|
* This class will choose a supported surface as close to
|
||||||
* RGB565 as possible, with or without a depth buffer.
|
* RGB565 as possible, with or without a depth buffer.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private static class SimpleEGLConfigChooser16 extends ComponentSizeChooser {
|
private static class SimpleEGLConfigChooser16 extends ComponentSizeChooser {
|
||||||
public SimpleEGLConfigChooser16(boolean withDepthBuffer, boolean stencil, boolean gles2, boolean gles3) {
|
public SimpleEGLConfigChooser16(boolean withDepthBuffer, boolean stencil, boolean gles2, boolean gles3) {
|
||||||
@ -845,15 +850,18 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
mAlphaSize = 8;
|
mAlphaSize = 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ComponentSizeChooser getEglConfigChooser(int videoDepthBpp, boolean withDepthBuffer, boolean stencil, boolean gles2, boolean gles3) {
|
private static ComponentSizeChooser getEglConfigChooser(int videoDepthBpp, boolean withDepthBuffer, boolean stencil, boolean gles2, boolean gles3) {
|
||||||
if(videoDepthBpp == 16)
|
if (videoDepthBpp == 16)
|
||||||
return new SimpleEGLConfigChooser16(withDepthBuffer, stencil, gles2, gles3);
|
return new SimpleEGLConfigChooser16(withDepthBuffer, stencil, gles2, gles3);
|
||||||
if(videoDepthBpp == 24)
|
if (videoDepthBpp == 24)
|
||||||
return new SimpleEGLConfigChooser24(withDepthBuffer, stencil, gles2, gles3);
|
return new SimpleEGLConfigChooser24(withDepthBuffer, stencil, gles2, gles3);
|
||||||
if(videoDepthBpp == 32)
|
if (videoDepthBpp == 32)
|
||||||
return new SimpleEGLConfigChooser32(withDepthBuffer, stencil, gles2, gles3);
|
return new SimpleEGLConfigChooser32(withDepthBuffer, stencil, gles2, gles3);
|
||||||
return null;
|
return null;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An EGL helper class.
|
* An EGL helper class.
|
||||||
@ -866,9 +874,10 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize EGL for a given configuration spec.
|
* Initialize EGL for a given configuration spec.
|
||||||
|
*
|
||||||
* @param configSpec
|
* @param configSpec
|
||||||
*/
|
*/
|
||||||
public void start(){
|
public void start() {
|
||||||
|
|
||||||
Log.v("SDL", "GLSurfaceView_SDL::EglHelper::start(): creating GL context");
|
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];
|
int[] version = new int[2];
|
||||||
mEgl.eglInitialize(mEglDisplay, version);
|
mEgl.eglInitialize(mEglDisplay, version);
|
||||||
mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);
|
mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);
|
||||||
if( mEglConfig == null )
|
if (mEglConfig == null)
|
||||||
Log.e("SDL", "GLSurfaceView_SDL::EglHelper::start(): mEglConfig is 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.
|
* OpenGL context is a somewhat heavy object.
|
||||||
*/
|
*/
|
||||||
final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
|
final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
|
||||||
final int[] gles2_attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, 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 };
|
final int[] gles3_attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL10.EGL_NONE};
|
||||||
|
|
||||||
mEglContext = mEgl.eglCreateContext(mEglDisplay, mEglConfig,
|
mEglContext = mEgl.eglCreateContext(mEglDisplay, mEglConfig,
|
||||||
EGL10.EGL_NO_CONTEXT,
|
EGL10.EGL_NO_CONTEXT,
|
||||||
mEGLConfigChooser.isGles3Required() ? gles3_attrib_list :
|
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());
|
Log.e("SDL", "GLSurfaceView_SDL::EglHelper::start(): mEglContext is EGL_NO_CONTEXT, error: " + mEgl.eglGetError());
|
||||||
|
|
||||||
mEglSurface = null;
|
mEglSurface = null;
|
||||||
@ -961,6 +970,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the current render surface.
|
* Display the current render surface.
|
||||||
|
*
|
||||||
* @return false if the context has been lost.
|
* @return false if the context has been lost.
|
||||||
*/
|
*/
|
||||||
public boolean swap() {
|
public boolean swap() {
|
||||||
@ -1005,7 +1015,6 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
* A generic GL Thread. Takes care of initializing EGL and GL. Delegates
|
* A generic GL Thread. Takes care of initializing EGL and GL. Delegates
|
||||||
* to a Renderer instance to do the actual drawing. Can be configured to
|
* to a Renderer instance to do the actual drawing. Can be configured to
|
||||||
* render continuously or on request.
|
* render continuously or on request.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class GLThread extends Thread implements SwapBuffersCallback {
|
class GLThread extends Thread implements SwapBuffersCallback {
|
||||||
GLThread(Renderer renderer) {
|
GLThread(Renderer renderer) {
|
||||||
@ -1066,7 +1075,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
boolean tellRendererSurfaceCreated = false;
|
boolean tellRendererSurfaceCreated = false;
|
||||||
boolean tellRendererSurfaceChanged = 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;
|
int w, h;
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
@ -1075,19 +1084,16 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
mRenderer.onSurfaceDestroyed();
|
mRenderer.onSurfaceDestroyed();
|
||||||
mEglHelper.finish();
|
mEglHelper.finish();
|
||||||
mNeedStart = true;
|
mNeedStart = true;
|
||||||
if( Globals.NonBlockingSwapBuffers )
|
if (Globals.NonBlockingSwapBuffers)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (needToWait()) {
|
while (needToWait()) {
|
||||||
//Log.v("SDL", "GLSurfaceView_SDL::run(): paused");
|
//Log.v("SDL", "GLSurfaceView_SDL::run(): paused");
|
||||||
synchronized(this) {
|
synchronized (this) {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
wait(500);
|
wait(500);
|
||||||
}
|
} catch (InterruptedException e) {
|
||||||
catch(InterruptedException e)
|
|
||||||
{
|
|
||||||
Log.v("SDL", "GLSurfaceView_SDL::GLThread::SwapBuffers(): Who dared to interrupt my slumber?");
|
Log.v("SDL", "GLSurfaceView_SDL::GLThread::SwapBuffers(): Who dared to interrupt my slumber?");
|
||||||
Thread.interrupted(); // Clear the flag
|
Thread.interrupted(); // Clear the flag
|
||||||
}
|
}
|
||||||
@ -1124,14 +1130,14 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
* Once we're done with GL, we need to call swapBuffers()
|
* Once we're done with GL, we need to call swapBuffers()
|
||||||
* to instruct the system to display the rendered frame
|
* to instruct the system to display the rendered frame
|
||||||
*/
|
*/
|
||||||
if( !mResetVideoSurface && mEglHelper.swap() )
|
if (!mResetVideoSurface && mEglHelper.swap())
|
||||||
return true;
|
return true;
|
||||||
// We've lost GL context - recreate it
|
// We've lost GL context - recreate it
|
||||||
mResetVideoSurface = false;
|
mResetVideoSurface = false;
|
||||||
mRenderer.onSurfaceDestroyed();
|
mRenderer.onSurfaceDestroyed();
|
||||||
mEglHelper.finish();
|
mEglHelper.finish();
|
||||||
mNeedStart = true;
|
mNeedStart = true;
|
||||||
if( Globals.NonBlockingSwapBuffers )
|
if (Globals.NonBlockingSwapBuffers)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1146,10 +1152,10 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Globals.HorizontalOrientation != (mWidth > mHeight) )
|
if (Globals.HorizontalOrientation != (mWidth > mHeight))
|
||||||
return true; // Wait until screen orientation changes
|
return true; // Wait until screen orientation changes
|
||||||
|
|
||||||
if (mPaused || (! mHasSurface)) {
|
if (mPaused || (!mHasSurface)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1162,10 +1168,10 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setRenderMode(int renderMode) {
|
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");
|
throw new IllegalArgumentException("renderMode");
|
||||||
}
|
}
|
||||||
synchronized(this) {
|
synchronized (this) {
|
||||||
mRenderMode = renderMode;
|
mRenderMode = renderMode;
|
||||||
if (renderMode == RENDERMODE_CONTINUOUSLY) {
|
if (renderMode == RENDERMODE_CONTINUOUSLY) {
|
||||||
notify();
|
notify();
|
||||||
@ -1174,27 +1180,27 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getRenderMode() {
|
public int getRenderMode() {
|
||||||
synchronized(this) {
|
synchronized (this) {
|
||||||
return mRenderMode;
|
return mRenderMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestRender() {
|
public void requestRender() {
|
||||||
synchronized(this) {
|
synchronized (this) {
|
||||||
mRequestRender = true;
|
mRequestRender = true;
|
||||||
notify();
|
notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void surfaceCreated() {
|
public void surfaceCreated() {
|
||||||
synchronized(this) {
|
synchronized (this) {
|
||||||
mHasSurface = true;
|
mHasSurface = true;
|
||||||
notify();
|
notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void surfaceDestroyed() {
|
public void surfaceDestroyed() {
|
||||||
synchronized(this) {
|
synchronized (this) {
|
||||||
mHasSurface = false;
|
mHasSurface = false;
|
||||||
notify();
|
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
|
// don't call this from GLThread thread or it is a guaranteed
|
||||||
// deadlock!
|
// deadlock!
|
||||||
Log.v("SDL", "GLSurfaceView_SDL::requestExitAndWait()");
|
Log.v("SDL", "GLSurfaceView_SDL::requestExitAndWait()");
|
||||||
synchronized(this) {
|
synchronized (this) {
|
||||||
mDone = true;
|
mDone = true;
|
||||||
notify();
|
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.
|
* Queue an "event" to be run on the GL rendering thread.
|
||||||
|
*
|
||||||
* @param r the runnable to be run on the GL rendering thread.
|
* @param r the runnable to be run on the GL rendering thread.
|
||||||
*/
|
*/
|
||||||
public void queueEvent(Runnable r) {
|
public void queueEvent(Runnable r) {
|
||||||
synchronized(this) {
|
synchronized (this) {
|
||||||
mEventQueue.add(r);
|
mEventQueue.add(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Runnable getEvent() {
|
private Runnable getEvent() {
|
||||||
synchronized(this) {
|
synchronized (this) {
|
||||||
if (mEventQueue.size() > 0) {
|
if (mEventQueue.size() > 0) {
|
||||||
return mEventQueue.remove(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) {
|
@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];
|
char c = buf[offset + i];
|
||||||
if ( c == '\n') {
|
if (c == '\n') {
|
||||||
flushBuilder();
|
flushBuilder();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
mBuilder.append(c);
|
mBuilder.append(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,16 +22,14 @@ freely, subject to the following restrictions:
|
|||||||
|
|
||||||
package io.neoterm;
|
package io.neoterm;
|
||||||
|
|
||||||
import java.lang.String;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
|
|
||||||
// Autogenerated by hand with a command:
|
// Autogenerated by hand with a command:
|
||||||
// grep 'SDLK_' SDL_keysym.h | sed 's/SDLK_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java
|
// grep 'SDLK_' SDL_keysym.h | sed 's/SDLK_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java
|
||||||
class SDL_1_2_Keycodes
|
class SDL_1_2_Keycodes {
|
||||||
{
|
|
||||||
public static final int SDLK_UNKNOWN = 0;
|
public static final int SDLK_UNKNOWN = 0;
|
||||||
public static final int SDLK_BACKSPACE = 8;
|
public static final int SDLK_BACKSPACE = 8;
|
||||||
public static final int SDLK_TAB = 9;
|
public static final int SDLK_TAB = 9;
|
||||||
@ -279,8 +277,7 @@ class SDL_1_2_Keycodes
|
|||||||
|
|
||||||
// Autogenerated by hand with a command:
|
// Autogenerated by hand with a command:
|
||||||
// grep 'SDL_SCANCODE_' SDL_scancode.h | sed 's/SDL_SCANCODE_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java
|
// grep 'SDL_SCANCODE_' SDL_scancode.h | sed 's/SDL_SCANCODE_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java
|
||||||
class SDL_1_3_Keycodes
|
class SDL_1_3_Keycodes {
|
||||||
{
|
|
||||||
public static final int SDLK_UNKNOWN = 0;
|
public static final int SDLK_UNKNOWN = 0;
|
||||||
public static final int SDLK_A = 4;
|
public static final int SDLK_A = 4;
|
||||||
public static final int SDLK_B = 5;
|
public static final int SDLK_B = 5;
|
||||||
@ -533,56 +530,48 @@ class SDL_1_3_Keycodes
|
|||||||
public static final int SDLK_NO_REMAP = 512;
|
public static final int SDLK_NO_REMAP = 512;
|
||||||
}
|
}
|
||||||
|
|
||||||
class SDL_Keys
|
class SDL_Keys {
|
||||||
{
|
public static String[] names = null;
|
||||||
public static String [] names = null;
|
public static Integer[] values = null;
|
||||||
public static Integer [] values = null;
|
|
||||||
|
|
||||||
public static String [] namesSorted = null;
|
public static String[] namesSorted = null;
|
||||||
public static Integer [] namesSortedIdx = null;
|
public static Integer[] namesSortedIdx = null;
|
||||||
public static Integer [] namesSortedBackIdx = 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 final int JAVA_KEYCODE_LAST = 255; // Android 2.3 added several new gaming keys, Android 3.1 added even more - keep in sync with javakeycodes.h
|
||||||
|
|
||||||
static String getName(int v)
|
static String getName(int v) {
|
||||||
{
|
for (int f = 0; f < values.length; f++) {
|
||||||
for( int f = 0; f < values.length; f++ )
|
if (values[f] == v)
|
||||||
{
|
|
||||||
if( values[f] == v )
|
|
||||||
return names[f];
|
return names[f];
|
||||||
}
|
}
|
||||||
return names[0];
|
return names[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static {
|
||||||
{
|
ArrayList<String> Names = new ArrayList<String>();
|
||||||
ArrayList<String> Names = new ArrayList<String> ();
|
ArrayList<Integer> Values = new ArrayList<Integer>();
|
||||||
ArrayList<Integer> Values = new ArrayList<Integer> ();
|
Field[] fields = SDL_1_2_Keycodes.class.getDeclaredFields();
|
||||||
Field [] fields = SDL_1_2_Keycodes.class.getDeclaredFields();
|
if (Globals.Using_SDL_1_3) {
|
||||||
if( Globals.Using_SDL_1_3 )
|
|
||||||
{
|
|
||||||
fields = SDL_1_3_Keycodes.class.getDeclaredFields();
|
fields = SDL_1_3_Keycodes.class.getDeclaredFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for(Field f: fields)
|
for (Field f : fields) {
|
||||||
{
|
if (!f.getName().startsWith("SDLK_")) {
|
||||||
if( !f.getName().startsWith("SDLK_") )
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Values.add(f.getInt(null));
|
Values.add(f.getInt(null));
|
||||||
Names.add(f.getName().substring(5).toUpperCase());
|
Names.add(f.getName().substring(5).toUpperCase());
|
||||||
}
|
}
|
||||||
} catch(IllegalAccessException e) {};
|
} catch (IllegalAccessException e) {
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
// Sort by value
|
// Sort by value
|
||||||
for( int i = 0; i < Values.size(); i++ )
|
for (int i = 0; i < Values.size(); i++) {
|
||||||
{
|
for (int j = i; j < Values.size(); j++) {
|
||||||
for( int j = i; j < Values.size(); j++ )
|
if (Values.get(i) > Values.get(j)) {
|
||||||
{
|
|
||||||
if( Values.get(i) > Values.get(j) )
|
|
||||||
{
|
|
||||||
int x = Values.get(i);
|
int x = Values.get(i);
|
||||||
Values.set(i, Values.get(j));
|
Values.set(i, Values.get(j));
|
||||||
Values.set(j, x);
|
Values.set(j, x);
|
||||||
@ -599,12 +588,9 @@ class SDL_Keys
|
|||||||
namesSortedIdx = new Integer[values.length];
|
namesSortedIdx = new Integer[values.length];
|
||||||
namesSortedBackIdx = new Integer[values.length];
|
namesSortedBackIdx = new Integer[values.length];
|
||||||
Arrays.sort(namesSorted);
|
Arrays.sort(namesSorted);
|
||||||
for( int i = 0; i < namesSorted.length; i++ )
|
for (int i = 0; i < namesSorted.length; i++) {
|
||||||
{
|
for (int j = 0; j < namesSorted.length; j++) {
|
||||||
for( int j = 0; j < namesSorted.length; j++ )
|
if (namesSorted[i].equals(names[j])) {
|
||||||
{
|
|
||||||
if( namesSorted[i].equals( names[j] ) )
|
|
||||||
{
|
|
||||||
namesSortedIdx[i] = j;
|
namesSortedIdx[i] = j;
|
||||||
namesSortedBackIdx[j] = i;
|
namesSortedBackIdx[j] = i;
|
||||||
break;
|
break;
|
||||||
|
@ -39,38 +39,22 @@ import android.inputmethodservice.Keyboard;
|
|||||||
import android.inputmethodservice.KeyboardView;
|
import android.inputmethodservice.KeyboardView;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.SpannedString;
|
import android.text.SpannedString;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Display;
|
import android.view.*;
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.Surface;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnKeyListener;
|
import android.view.View.OnKeyListener;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.Button;
|
import android.widget.*;
|
||||||
import android.widget.EditText;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import android.widget.FrameLayout;
|
import io.neoterm.xorg.NeoXorgViewClient;
|
||||||
import android.widget.ImageView;
|
import io.neoterm.xorg.R;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
|
|
||||||
import io.neoterm.xorg.NeoXorgViewClient;
|
|
||||||
import io.neoterm.xorg.R;
|
|
||||||
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements NeoXorgViewClient {
|
public class MainActivity extends AppCompatActivity implements NeoXorgViewClient {
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,22 +28,14 @@ import android.os.Environment;
|
|||||||
import android.os.StatFs;
|
import android.os.StatFs;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import io.neoterm.xorg.NeoXorgViewClient;
|
||||||
|
import io.neoterm.xorg.R;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
import io.neoterm.xorg.NeoXorgViewClient;
|
|
||||||
import io.neoterm.xorg.R;
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: too much code here, split into multiple files, possibly auto-generated menus?
|
// TODO: too much code here, split into multiple files, possibly auto-generated menus?
|
||||||
@SuppressWarnings("JniMissingFunction")
|
@SuppressWarnings("JniMissingFunction")
|
||||||
|
@ -24,69 +24,58 @@ package io.neoterm;
|
|||||||
|
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import io.neoterm.xorg.R;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import io.neoterm.xorg.R;
|
|
||||||
|
|
||||||
|
class SettingsMenu {
|
||||||
class SettingsMenu
|
public static abstract class Menu {
|
||||||
{
|
|
||||||
public static abstract class Menu
|
|
||||||
{
|
|
||||||
// Should be overridden by children
|
// Should be overridden by children
|
||||||
abstract void run(final MainActivity p);
|
abstract void run(final MainActivity p);
|
||||||
|
|
||||||
abstract String title(final MainActivity p);
|
abstract String title(final MainActivity p);
|
||||||
boolean enabled()
|
|
||||||
{
|
boolean enabled() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should not be overridden
|
// Should not be overridden
|
||||||
boolean enabledOrHidden()
|
boolean enabledOrHidden() {
|
||||||
{
|
for (Menu m : Globals.HiddenMenuOptions) {
|
||||||
for( Menu m: Globals.HiddenMenuOptions )
|
if (m.getClass().getName().equals(this.getClass().getName()))
|
||||||
{
|
|
||||||
if( m.getClass().getName().equals( this.getClass().getName() ) )
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return enabled();
|
return enabled();
|
||||||
}
|
}
|
||||||
void showMenuOptionsList(final MainActivity p, final Menu[] list)
|
|
||||||
{
|
void showMenuOptionsList(final MainActivity p, final Menu[] list) {
|
||||||
menuStack.add(this);
|
menuStack.add(this);
|
||||||
ArrayList<CharSequence> items = new ArrayList<CharSequence> ();
|
ArrayList<CharSequence> items = new ArrayList<CharSequence>();
|
||||||
for( Menu m: list )
|
for (Menu m : list) {
|
||||||
{
|
if (m.enabledOrHidden())
|
||||||
if(m.enabledOrHidden())
|
|
||||||
items.add(m.title(p));
|
items.add(m.title(p));
|
||||||
}
|
}
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(title(p));
|
builder.setTitle(title(p));
|
||||||
builder.setItems(items.toArray(new CharSequence[0]), new DialogInterface.OnClickListener()
|
builder.setItems(items.toArray(new CharSequence[0]), new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
|
|
||||||
for( Menu m: list )
|
for (Menu m : list) {
|
||||||
{
|
if (m.enabledOrHidden()) {
|
||||||
if(m.enabledOrHidden())
|
if (selected == item) {
|
||||||
{
|
|
||||||
if( selected == item )
|
|
||||||
{
|
|
||||||
m.run(p);
|
m.run(p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
selected ++;
|
selected++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBackOuterMenu(p);
|
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;
|
Settings.settingsChanged = true;
|
||||||
if( Globals.OptionalDataDownload == null )
|
if (Globals.OptionalDataDownload == null) {
|
||||||
{
|
|
||||||
String downloads[] = Globals.DataDownloadUrl;
|
String downloads[] = Globals.DataDownloadUrl;
|
||||||
Globals.OptionalDataDownload = new boolean[downloads.length];
|
Globals.OptionalDataDownload = new boolean[downloads.length];
|
||||||
boolean oldFormat = true;
|
boolean oldFormat = true;
|
||||||
for( int i = 0; i < downloads.length; i++ )
|
for (int i = 0; i < downloads.length; i++) {
|
||||||
{
|
if (downloads[i].indexOf("!") == 0) {
|
||||||
if( downloads[i].indexOf("!") == 0 )
|
|
||||||
{
|
|
||||||
Globals.OptionalDataDownload[i] = true;
|
Globals.OptionalDataDownload[i] = true;
|
||||||
oldFormat = false;
|
oldFormat = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( oldFormat )
|
if (oldFormat)
|
||||||
Globals.OptionalDataDownload[0] = true;
|
Globals.OptionalDataDownload[0] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!firstStart)
|
if (!firstStart)
|
||||||
new MainMenu().run(p);
|
new MainMenu().run(p);
|
||||||
else
|
else {
|
||||||
{
|
if (Globals.StartupMenuButtonTimeout > 0) // If we did not disable startup menu altogether
|
||||||
if( Globals.StartupMenuButtonTimeout > 0 ) // If we did not disable startup menu altogether
|
|
||||||
{
|
|
||||||
for( Menu m: Globals.FirstStartMenuOptions )
|
|
||||||
{
|
{
|
||||||
|
for (Menu m : Globals.FirstStartMenuOptions) {
|
||||||
boolean hidden = false;
|
boolean hidden = false;
|
||||||
for( Menu m1: Globals.HiddenMenuOptions )
|
for (Menu m1 : Globals.HiddenMenuOptions) {
|
||||||
{
|
if (m1.getClass().getName().equals(m.getClass().getName()))
|
||||||
if( m1.getClass().getName().equals( m.getClass().getName() ) )
|
|
||||||
hidden = true;
|
hidden = true;
|
||||||
}
|
}
|
||||||
if( ! hidden )
|
if (!hidden)
|
||||||
menuStack.add(0, m);
|
menuStack.add(0, m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,58 +122,47 @@ class SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void goBack(final MainActivity p)
|
static void goBack(final MainActivity p) {
|
||||||
{
|
if (menuStack.isEmpty()) {
|
||||||
if(menuStack.isEmpty())
|
|
||||||
{
|
|
||||||
Settings.Save(p);
|
Settings.Save(p);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Menu c = menuStack.remove(menuStack.size() - 1);
|
Menu c = menuStack.remove(menuStack.size() - 1);
|
||||||
c.run(p);
|
c.run(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void goBackOuterMenu(final MainActivity p)
|
static void goBackOuterMenu(final MainActivity p) {
|
||||||
{
|
if (!menuStack.isEmpty())
|
||||||
if(!menuStack.isEmpty())
|
|
||||||
menuStack.remove(menuStack.size() - 1);
|
menuStack.remove(menuStack.size() - 1);
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class OkButton extends Menu
|
static class OkButton extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.ok);
|
return p.getResources().getString(R.string.ok);
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
goBackOuterMenu(p);
|
goBackOuterMenu(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class DummyMenu extends Menu
|
static class DummyMenu extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.ok);
|
return p.getResources().getString(R.string.ok);
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class MainMenu extends Menu
|
static class MainMenu extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.device_config);
|
return p.getResources().getString(R.string.device_config);
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
Menu options[] =
|
Menu options[] =
|
||||||
{
|
{
|
||||||
new SettingsMenuMisc.DownloadConfig(),
|
new SettingsMenuMisc.DownloadConfig(),
|
||||||
|
@ -27,7 +27,6 @@ import android.graphics.Bitmap;
|
|||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
@ -35,26 +34,23 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import io.neoterm.xorg.R;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import io.neoterm.xorg.R;
|
|
||||||
|
|
||||||
|
class SettingsMenuKeyboard extends SettingsMenu {
|
||||||
class SettingsMenuKeyboard extends SettingsMenu
|
static class KeyboardConfigMainMenu extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
static class KeyboardConfigMainMenu extends Menu
|
|
||||||
{
|
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.controls_screenkb);
|
return p.getResources().getString(R.string.controls_screenkb);
|
||||||
}
|
}
|
||||||
boolean enabled()
|
|
||||||
{
|
boolean enabled() {
|
||||||
return Globals.UseTouchscreenKeyboard;
|
return Globals.UseTouchscreenKeyboard;
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
Menu options[] =
|
Menu options[] =
|
||||||
{
|
{
|
||||||
new ScreenKeyboardThemeConfig(),
|
new ScreenKeyboardThemeConfig(),
|
||||||
@ -70,38 +66,32 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ScreenKeyboardSizeConfig extends Menu
|
static class ScreenKeyboardSizeConfig extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.controls_screenkb_size);
|
return p.getResources().getString(R.string.controls_screenkb_size);
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_large),
|
final CharSequence[] items = {p.getResources().getString(R.string.controls_screenkb_large),
|
||||||
p.getResources().getString(R.string.controls_screenkb_medium),
|
p.getResources().getString(R.string.controls_screenkb_medium),
|
||||||
p.getResources().getString(R.string.controls_screenkb_small),
|
p.getResources().getString(R.string.controls_screenkb_small),
|
||||||
p.getResources().getString(R.string.controls_screenkb_tiny),
|
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);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_size));
|
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_size));
|
||||||
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardSize, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardSize, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.TouchscreenKeyboardSize = item;
|
Globals.TouchscreenKeyboardSize = item;
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
if( Globals.TouchscreenKeyboardSize == Globals.TOUCHSCREEN_KEYBOARD_CUSTOM )
|
if (Globals.TouchscreenKeyboardSize == Globals.TOUCHSCREEN_KEYBOARD_CUSTOM)
|
||||||
new CustomizeScreenKbLayout().run(p);
|
new CustomizeScreenKbLayout().run(p);
|
||||||
else
|
else
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -111,35 +101,29 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ScreenKeyboardDrawSizeConfig extends Menu
|
static class ScreenKeyboardDrawSizeConfig extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.controls_screenkb_drawsize);
|
return p.getResources().getString(R.string.controls_screenkb_drawsize);
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_large),
|
final CharSequence[] items = {p.getResources().getString(R.string.controls_screenkb_large),
|
||||||
p.getResources().getString(R.string.controls_screenkb_medium),
|
p.getResources().getString(R.string.controls_screenkb_medium),
|
||||||
p.getResources().getString(R.string.controls_screenkb_small),
|
p.getResources().getString(R.string.controls_screenkb_small),
|
||||||
p.getResources().getString(R.string.controls_screenkb_tiny) };
|
p.getResources().getString(R.string.controls_screenkb_tiny)};
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_drawsize));
|
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_drawsize));
|
||||||
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardDrawSize, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardDrawSize, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.TouchscreenKeyboardDrawSize = item;
|
Globals.TouchscreenKeyboardDrawSize = item;
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -149,14 +133,12 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ScreenKeyboardThemeConfig extends Menu
|
static class ScreenKeyboardThemeConfig extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.controls_screenkb_theme);
|
return p.getResources().getString(R.string.controls_screenkb_theme);
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
final CharSequence[] items = {
|
final CharSequence[] items = {
|
||||||
p.getResources().getString(R.string.controls_screenkb_by, "Ultimate Droid", "Sean Stieber"),
|
p.getResources().getString(R.string.controls_screenkb_by, "Ultimate Droid", "Sean Stieber"),
|
||||||
p.getResources().getString(R.string.controls_screenkb_by, "Simple Theme", "Beholder"),
|
p.getResources().getString(R.string.controls_screenkb_by, "Simple Theme", "Beholder"),
|
||||||
@ -172,20 +154,16 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_theme));
|
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_theme));
|
||||||
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTheme, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTheme, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.TouchscreenKeyboardTheme = item;
|
Globals.TouchscreenKeyboardTheme = item;
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -195,36 +173,30 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ScreenKeyboardTransparencyConfig extends Menu
|
static class ScreenKeyboardTransparencyConfig extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.controls_screenkb_transparency);
|
return p.getResources().getString(R.string.controls_screenkb_transparency);
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_trans_0),
|
final CharSequence[] items = {p.getResources().getString(R.string.controls_screenkb_trans_0),
|
||||||
p.getResources().getString(R.string.controls_screenkb_trans_1),
|
p.getResources().getString(R.string.controls_screenkb_trans_1),
|
||||||
p.getResources().getString(R.string.controls_screenkb_trans_2),
|
p.getResources().getString(R.string.controls_screenkb_trans_2),
|
||||||
p.getResources().getString(R.string.controls_screenkb_trans_3),
|
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);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_transparency));
|
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_transparency));
|
||||||
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTransparency, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTransparency, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.TouchscreenKeyboardTransparency = item;
|
Globals.TouchscreenKeyboardTransparency = item;
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -234,34 +206,30 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class RemapHwKeysConfig extends Menu
|
static class RemapHwKeysConfig extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.remap_hwkeys);
|
return p.getResources().getString(R.string.remap_hwkeys);
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
|
p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
|
||||||
p.getVideoLayout().setOnKeyListener(new KeyRemapTool(p));
|
p.getVideoLayout().setOnKeyListener(new KeyRemapTool(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class KeyRemapTool implements View.OnKeyListener
|
public static class KeyRemapTool implements View.OnKeyListener {
|
||||||
{
|
|
||||||
MainActivity p;
|
MainActivity p;
|
||||||
public KeyRemapTool(MainActivity _p)
|
|
||||||
{
|
public KeyRemapTool(MainActivity _p) {
|
||||||
p = _p;
|
p = _p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKey(View v, int keyCode, KeyEvent event)
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||||
{
|
|
||||||
p.getVideoLayout().setOnKeyListener(null);
|
p.getVideoLayout().setOnKeyListener(null);
|
||||||
int keyIndex = keyCode;
|
int keyIndex = keyCode;
|
||||||
if( keyIndex < 0 )
|
if (keyIndex < 0)
|
||||||
keyIndex = 0;
|
keyIndex = 0;
|
||||||
if( keyIndex > SDL_Keys.JAVA_KEYCODE_LAST )
|
if (keyIndex > SDL_Keys.JAVA_KEYCODE_LAST)
|
||||||
keyIndex = 0;
|
keyIndex = 0;
|
||||||
|
|
||||||
final int KeyIndexFinal = keyIndex;
|
final int KeyIndexFinal = keyIndex;
|
||||||
@ -275,29 +243,24 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
p.getResources().getString(R.string.remap_hwkeys_select_more_keys),
|
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("_", " ");
|
items[i] = Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(R.string.remap_hwkeys_select_simple);
|
builder.setTitle(R.string.remap_hwkeys_select_simple);
|
||||||
builder.setItems(items, new DialogInterface.OnClickListener()
|
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
if( item >= 6 )
|
if (item >= 6)
|
||||||
ShowAllKeys(KeyIndexFinal);
|
ShowAllKeys(KeyIndexFinal);
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
Globals.RemapHwKeycode[KeyIndexFinal] = Globals.RemapScreenKbKeycode[item];
|
Globals.RemapHwKeycode[KeyIndexFinal] = Globals.RemapScreenKbKeycode[item];
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -306,24 +269,20 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
alert.show();
|
alert.show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public void ShowAllKeys(final int KeyIndex)
|
|
||||||
{
|
public void ShowAllKeys(final int KeyIndex) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(R.string.remap_hwkeys_select);
|
builder.setTitle(R.string.remap_hwkeys_select);
|
||||||
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapHwKeycode[KeyIndex]], new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapHwKeycode[KeyIndex]], new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.RemapHwKeycode[KeyIndex] = SDL_Keys.namesSortedIdx[item];
|
Globals.RemapHwKeycode[KeyIndex] = SDL_Keys.namesSortedIdx[item];
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -334,15 +293,13 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class RemapScreenKbConfig extends Menu
|
static class RemapScreenKbConfig extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.remap_screenkb);
|
return p.getResources().getString(R.string.remap_screenkb);
|
||||||
}
|
}
|
||||||
|
|
||||||
//boolean enabled() { return true; };
|
//boolean enabled() { return true; };
|
||||||
void run (final MainActivity p)
|
void run(final MainActivity p) {
|
||||||
{
|
|
||||||
CharSequence[] items = {
|
CharSequence[] items = {
|
||||||
p.getResources().getString(R.string.remap_screenkb_joystick),
|
p.getResources().getString(R.string.remap_screenkb_joystick),
|
||||||
p.getResources().getString(R.string.remap_screenkb_button_text),
|
p.getResources().getString(R.string.remap_screenkb_button_text),
|
||||||
@ -355,45 +312,37 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
};
|
};
|
||||||
|
|
||||||
boolean defaults[] = Arrays.copyOf(Globals.ScreenKbControlsShown, Globals.ScreenKbControlsShown.length);
|
boolean defaults[] = Arrays.copyOf(Globals.ScreenKbControlsShown, Globals.ScreenKbControlsShown.length);
|
||||||
if( Globals.AppUsesSecondJoystick )
|
if (Globals.AppUsesSecondJoystick) {
|
||||||
{
|
|
||||||
items = Arrays.copyOf(items, items.length + 1);
|
items = Arrays.copyOf(items, items.length + 1);
|
||||||
items[items.length - 1] = p.getResources().getString(R.string.remap_screenkb_joystick) + " 2";
|
items[items.length - 1] = p.getResources().getString(R.string.remap_screenkb_joystick) + " 2";
|
||||||
defaults = Arrays.copyOf(defaults, defaults.length + 1);
|
defaults = Arrays.copyOf(defaults, defaults.length + 1);
|
||||||
defaults[defaults.length - 1] = true;
|
defaults[defaults.length - 1] = true;
|
||||||
}
|
}
|
||||||
if( Globals.AppUsesThirdJoystick )
|
if (Globals.AppUsesThirdJoystick) {
|
||||||
{
|
|
||||||
items = Arrays.copyOf(items, items.length + 1);
|
items = Arrays.copyOf(items, items.length + 1);
|
||||||
items[items.length - 1] = p.getResources().getString(R.string.remap_screenkb_joystick) + " 3";
|
items[items.length - 1] = p.getResources().getString(R.string.remap_screenkb_joystick) + " 3";
|
||||||
defaults = Arrays.copyOf(defaults, defaults.length + 1);
|
defaults = Arrays.copyOf(defaults, defaults.length + 1);
|
||||||
defaults[defaults.length - 1] = true;
|
defaults[defaults.length - 1] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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+2] = items[i+2] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
items[i + 2] = items[i + 2] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(p.getResources().getString(R.string.remap_screenkb));
|
builder.setTitle(p.getResources().getString(R.string.remap_screenkb));
|
||||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item, boolean isChecked) {
|
||||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
|
||||||
{
|
|
||||||
Globals.ScreenKbControlsShown[item] = isChecked;
|
Globals.ScreenKbControlsShown[item] = isChecked;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
showRemapScreenKbConfig2(p, 0);
|
showRemapScreenKbConfig2(p, 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -402,8 +351,7 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void showRemapScreenKbConfig2(final MainActivity p, final int currentButton)
|
static void showRemapScreenKbConfig2(final MainActivity p, final int currentButton) {
|
||||||
{
|
|
||||||
CharSequence[] items = {
|
CharSequence[] items = {
|
||||||
p.getResources().getString(R.string.remap_screenkb_button) + " 1",
|
p.getResources().getString(R.string.remap_screenkb_button) + " 1",
|
||||||
p.getResources().getString(R.string.remap_screenkb_button) + " 2",
|
p.getResources().getString(R.string.remap_screenkb_button) + " 2",
|
||||||
@ -413,36 +361,30 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
p.getResources().getString(R.string.remap_screenkb_button) + " 6",
|
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("_", " ");
|
items[i] = items[i] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
||||||
|
|
||||||
if( currentButton >= Globals.RemapScreenKbKeycode.length )
|
if (currentButton >= Globals.RemapScreenKbKeycode.length) {
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if( ! Globals.ScreenKbControlsShown[currentButton + 2] )
|
if (!Globals.ScreenKbControlsShown[currentButton + 2]) {
|
||||||
{
|
|
||||||
showRemapScreenKbConfig2(p, currentButton + 1);
|
showRemapScreenKbConfig2(p, currentButton + 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(items[currentButton]);
|
builder.setTitle(items[currentButton]);
|
||||||
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapScreenKbKeycode[currentButton]], new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapScreenKbKeycode[currentButton]], new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.RemapScreenKbKeycode[currentButton] = SDL_Keys.namesSortedIdx[item];
|
Globals.RemapScreenKbKeycode[currentButton] = SDL_Keys.namesSortedIdx[item];
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
showRemapScreenKbConfig2(p, currentButton + 1);
|
showRemapScreenKbConfig2(p, currentButton + 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -452,15 +394,13 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ScreenGesturesConfig extends Menu
|
static class ScreenGesturesConfig extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.remap_screenkb_button_gestures);
|
return p.getResources().getString(R.string.remap_screenkb_button_gestures);
|
||||||
}
|
}
|
||||||
|
|
||||||
//boolean enabled() { return true; };
|
//boolean enabled() { return true; };
|
||||||
void run (final MainActivity p)
|
void run(final MainActivity p) {
|
||||||
{
|
|
||||||
CharSequence[] items = {
|
CharSequence[] items = {
|
||||||
p.getResources().getString(R.string.remap_screenkb_button_zoomin),
|
p.getResources().getString(R.string.remap_screenkb_button_zoomin),
|
||||||
p.getResources().getString(R.string.remap_screenkb_button_zoomout),
|
p.getResources().getString(R.string.remap_screenkb_button_zoomout),
|
||||||
@ -477,25 +417,19 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(p.getResources().getString(R.string.remap_screenkb_button_gestures));
|
builder.setTitle(p.getResources().getString(R.string.remap_screenkb_button_gestures));
|
||||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item, boolean isChecked) {
|
||||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
|
||||||
{
|
|
||||||
Globals.MultitouchGesturesUsed[item] = isChecked;
|
Globals.MultitouchGesturesUsed[item] = isChecked;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
showScreenGesturesConfig2(p);
|
showScreenGesturesConfig2(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -504,8 +438,7 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void showScreenGesturesConfig2(final MainActivity p)
|
static void showScreenGesturesConfig2(final MainActivity p) {
|
||||||
{
|
|
||||||
final CharSequence[] items = {
|
final CharSequence[] items = {
|
||||||
p.getResources().getString(R.string.accel_slow),
|
p.getResources().getString(R.string.accel_slow),
|
||||||
p.getResources().getString(R.string.accel_medium),
|
p.getResources().getString(R.string.accel_medium),
|
||||||
@ -515,20 +448,16 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(R.string.remap_screenkb_button_gestures_sensitivity);
|
builder.setTitle(R.string.remap_screenkb_button_gestures_sensitivity);
|
||||||
builder.setSingleChoiceItems(items, Globals.MultitouchGestureSensitivity, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.MultitouchGestureSensitivity, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.MultitouchGestureSensitivity = item;
|
Globals.MultitouchGestureSensitivity = item;
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
showScreenGesturesConfig3(p, 0);
|
showScreenGesturesConfig3(p, 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -537,8 +466,7 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void showScreenGesturesConfig3(final MainActivity p, final int currentButton)
|
static void showScreenGesturesConfig3(final MainActivity p, final int currentButton) {
|
||||||
{
|
|
||||||
CharSequence[] items = {
|
CharSequence[] items = {
|
||||||
p.getResources().getString(R.string.remap_screenkb_button_zoomin),
|
p.getResources().getString(R.string.remap_screenkb_button_zoomin),
|
||||||
p.getResources().getString(R.string.remap_screenkb_button_zoomout),
|
p.getResources().getString(R.string.remap_screenkb_button_zoomout),
|
||||||
@ -546,33 +474,27 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
p.getResources().getString(R.string.remap_screenkb_button_rotateright),
|
p.getResources().getString(R.string.remap_screenkb_button_rotateright),
|
||||||
};
|
};
|
||||||
|
|
||||||
if( currentButton >= Globals.RemapMultitouchGestureKeycode.length )
|
if (currentButton >= Globals.RemapMultitouchGestureKeycode.length) {
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if( ! Globals.MultitouchGesturesUsed[currentButton] )
|
if (!Globals.MultitouchGesturesUsed[currentButton]) {
|
||||||
{
|
|
||||||
showScreenGesturesConfig3(p, currentButton + 1);
|
showScreenGesturesConfig3(p, currentButton + 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(items[currentButton]);
|
builder.setTitle(items[currentButton]);
|
||||||
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapMultitouchGestureKeycode[currentButton]], new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapMultitouchGestureKeycode[currentButton]], new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.RemapMultitouchGestureKeycode[currentButton] = SDL_Keys.namesSortedIdx[item];
|
Globals.RemapMultitouchGestureKeycode[currentButton] = SDL_Keys.namesSortedIdx[item];
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
showScreenGesturesConfig3(p, currentButton + 1);
|
showScreenGesturesConfig3(p, currentButton + 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -582,22 +504,19 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class CustomizeScreenKbLayout extends Menu
|
static class CustomizeScreenKbLayout extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.screenkb_custom_layout);
|
return p.getResources().getString(R.string.screenkb_custom_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
//boolean enabled() { return true; };
|
//boolean enabled() { return true; };
|
||||||
void run (final MainActivity p)
|
void run(final MainActivity p) {
|
||||||
{
|
|
||||||
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help));
|
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help));
|
||||||
CustomizeScreenKbLayoutTool tool = new CustomizeScreenKbLayoutTool(p);
|
CustomizeScreenKbLayoutTool tool = new CustomizeScreenKbLayoutTool(p);
|
||||||
Globals.TouchscreenKeyboardSize = Globals.TOUCHSCREEN_KEYBOARD_CUSTOM;
|
Globals.TouchscreenKeyboardSize = Globals.TOUCHSCREEN_KEYBOARD_CUSTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class CustomizeScreenKbLayoutTool implements View.OnTouchListener, View.OnKeyListener
|
static class CustomizeScreenKbLayoutTool implements View.OnTouchListener, View.OnKeyListener {
|
||||||
{
|
|
||||||
MainActivity p;
|
MainActivity p;
|
||||||
FrameLayout layout = null;
|
FrameLayout layout = null;
|
||||||
ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length];
|
ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length];
|
||||||
@ -620,8 +539,7 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
int oldX = 0, oldY = 0;
|
int oldX = 0, oldY = 0;
|
||||||
boolean resizing = false;
|
boolean resizing = false;
|
||||||
|
|
||||||
public CustomizeScreenKbLayoutTool(MainActivity _p)
|
public CustomizeScreenKbLayoutTool(MainActivity _p) {
|
||||||
{
|
|
||||||
p = _p;
|
p = _p;
|
||||||
layout = new FrameLayout(p);
|
layout = new FrameLayout(p);
|
||||||
p.getVideoLayout().addView(layout);
|
p.getVideoLayout().addView(layout);
|
||||||
@ -633,13 +551,12 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
boundary = new ImageView(p);
|
boundary = new ImageView(p);
|
||||||
boundary.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
boundary.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||||
boundary.setScaleType(ImageView.ScaleType.MATRIX);
|
boundary.setScaleType(ImageView.ScaleType.MATRIX);
|
||||||
boundaryBmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.rectangle );
|
boundaryBmp = BitmapFactory.decodeResource(p.getResources(), R.drawable.rectangle);
|
||||||
boundary.setImageBitmap(boundaryBmp);
|
boundary.setImageBitmap(boundaryBmp);
|
||||||
layout.addView(boundary);
|
layout.addView(boundary);
|
||||||
currentButton = -1;
|
currentButton = -1;
|
||||||
if( Globals.TouchscreenKeyboardTheme == 2 )
|
if (Globals.TouchscreenKeyboardTheme == 2) {
|
||||||
{
|
buttons = new int[]{
|
||||||
buttons = new int[] {
|
|
||||||
R.drawable.sun_dpad,
|
R.drawable.sun_dpad,
|
||||||
R.drawable.sun_keyboard,
|
R.drawable.sun_keyboard,
|
||||||
R.drawable.sun_b1,
|
R.drawable.sun_b1,
|
||||||
@ -660,41 +577,37 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
p.getWindowManager().getDefaultDisplay().getMetrics(dm);
|
p.getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||||
displayX = dm.widthPixels;
|
displayX = dm.widthPixels;
|
||||||
displayY = dm.heightPixels;
|
displayY = dm.heightPixels;
|
||||||
} catch (Exception eeeee) {}
|
} catch (Exception eeeee) {
|
||||||
|
}
|
||||||
|
|
||||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
for (int i = 0; i < Globals.ScreenKbControlsLayout.length; i++) {
|
||||||
{
|
if (!Globals.ScreenKbControlsShown[i])
|
||||||
if( ! Globals.ScreenKbControlsShown[i] )
|
|
||||||
continue;
|
continue;
|
||||||
if( currentButton == -1 )
|
if (currentButton == -1)
|
||||||
currentButton = i;
|
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] );
|
//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
|
// Check if the button is off screen edge or shrunk to zero
|
||||||
if( Globals.ScreenKbControlsLayout[i][0] > Globals.ScreenKbControlsLayout[i][2] - displayY/12 )
|
if (Globals.ScreenKbControlsLayout[i][0] > Globals.ScreenKbControlsLayout[i][2] - displayY / 12)
|
||||||
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 )
|
if (Globals.ScreenKbControlsLayout[i][1] > Globals.ScreenKbControlsLayout[i][3] - displayY / 12)
|
||||||
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 )
|
if (Globals.ScreenKbControlsLayout[i][0] < Globals.ScreenKbControlsLayout[i][2] - displayY * 2 / 3)
|
||||||
Globals.ScreenKbControlsLayout[i][0] = Globals.ScreenKbControlsLayout[i][2] - displayY*2/3;
|
Globals.ScreenKbControlsLayout[i][0] = Globals.ScreenKbControlsLayout[i][2] - displayY * 2 / 3;
|
||||||
if( Globals.ScreenKbControlsLayout[i][1] < Globals.ScreenKbControlsLayout[i][3] - displayY*2/3 )
|
if (Globals.ScreenKbControlsLayout[i][1] < Globals.ScreenKbControlsLayout[i][3] - displayY * 2 / 3)
|
||||||
Globals.ScreenKbControlsLayout[i][1] = Globals.ScreenKbControlsLayout[i][3] - displayY*2/3;
|
Globals.ScreenKbControlsLayout[i][1] = Globals.ScreenKbControlsLayout[i][3] - displayY * 2 / 3;
|
||||||
if( Globals.ScreenKbControlsLayout[i][0] < 0 )
|
if (Globals.ScreenKbControlsLayout[i][0] < 0) {
|
||||||
{
|
|
||||||
Globals.ScreenKbControlsLayout[i][2] += -Globals.ScreenKbControlsLayout[i][0];
|
Globals.ScreenKbControlsLayout[i][2] += -Globals.ScreenKbControlsLayout[i][0];
|
||||||
Globals.ScreenKbControlsLayout[i][0] = 0;
|
Globals.ScreenKbControlsLayout[i][0] = 0;
|
||||||
}
|
}
|
||||||
if( Globals.ScreenKbControlsLayout[i][2] > displayX )
|
if (Globals.ScreenKbControlsLayout[i][2] > displayX) {
|
||||||
{
|
|
||||||
Globals.ScreenKbControlsLayout[i][0] -= Globals.ScreenKbControlsLayout[i][2] - displayX;
|
Globals.ScreenKbControlsLayout[i][0] -= Globals.ScreenKbControlsLayout[i][2] - displayX;
|
||||||
Globals.ScreenKbControlsLayout[i][2] = displayX;
|
Globals.ScreenKbControlsLayout[i][2] = displayX;
|
||||||
}
|
}
|
||||||
if( Globals.ScreenKbControlsLayout[i][1] < 0 )
|
if (Globals.ScreenKbControlsLayout[i][1] < 0) {
|
||||||
{
|
|
||||||
Globals.ScreenKbControlsLayout[i][3] += -Globals.ScreenKbControlsLayout[i][1];
|
Globals.ScreenKbControlsLayout[i][3] += -Globals.ScreenKbControlsLayout[i][1];
|
||||||
Globals.ScreenKbControlsLayout[i][1] = 0;
|
Globals.ScreenKbControlsLayout[i][1] = 0;
|
||||||
}
|
}
|
||||||
if( Globals.ScreenKbControlsLayout[i][3] > displayY )
|
if (Globals.ScreenKbControlsLayout[i][3] > displayY) {
|
||||||
{
|
|
||||||
Globals.ScreenKbControlsLayout[i][1] -= Globals.ScreenKbControlsLayout[i][3] - displayY;
|
Globals.ScreenKbControlsLayout[i][1] -= Globals.ScreenKbControlsLayout[i][3] - displayY;
|
||||||
Globals.ScreenKbControlsLayout[i][3] = displayY;
|
Globals.ScreenKbControlsLayout[i][3] = displayY;
|
||||||
}
|
}
|
||||||
@ -703,7 +616,7 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
imgs[i] = new ImageView(p);
|
imgs[i] = new ImageView(p);
|
||||||
imgs[i].setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
imgs[i].setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||||
imgs[i].setScaleType(ImageView.ScaleType.MATRIX);
|
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].setImageBitmap(bmps[i]);
|
||||||
imgs[i].setAlpha(128);
|
imgs[i].setAlpha(128);
|
||||||
layout.addView(imgs[i]);
|
layout.addView(imgs[i]);
|
||||||
@ -715,14 +628,13 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
imgs[i].setImageMatrix(m);
|
imgs[i].setImageMatrix(m);
|
||||||
}
|
}
|
||||||
boundary.bringToFront();
|
boundary.bringToFront();
|
||||||
if( currentButton == -1 )
|
if (currentButton == -1)
|
||||||
onKey( null, KeyEvent.KEYCODE_BACK, null ); // All buttons disabled - do not show anything
|
onKey(null, KeyEvent.KEYCODE_BACK, null); // All buttons disabled - do not show anything
|
||||||
else
|
else
|
||||||
setupButton(currentButton);
|
setupButton(currentButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupButton(int i)
|
void setupButton(int i) {
|
||||||
{
|
|
||||||
Matrix m = new Matrix();
|
Matrix m = new Matrix();
|
||||||
RectF src = new RectF(0, 0, bmps[i].getWidth(), bmps[i].getHeight());
|
RectF src = new RectF(0, 0, bmps[i].getWidth(), bmps[i].getHeight());
|
||||||
RectF dst = new RectF(Globals.ScreenKbControlsLayout[i][0], Globals.ScreenKbControlsLayout[i][1],
|
RectF dst = new RectF(Globals.ScreenKbControlsLayout[i][0], Globals.ScreenKbControlsLayout[i][1],
|
||||||
@ -734,38 +646,34 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||||
boundary.setImageMatrix(m);
|
boundary.setImageMatrix(m);
|
||||||
String buttonText = "";
|
String buttonText = "";
|
||||||
if( i >= 2 && i <= 7 )
|
if (i >= 2 && i <= 7)
|
||||||
buttonText = p.getResources().getString(R.string.remap_screenkb_button) + (i - 2);
|
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("_", " ");
|
buttonText = Globals.AppTouchscreenKeyboardKeysNames[i - 2].replace("_", " ");
|
||||||
if( i == 0 )
|
if (i == 0)
|
||||||
buttonText = "Joystick";
|
buttonText = "Joystick";
|
||||||
if( i == 1 )
|
if (i == 1)
|
||||||
buttonText = "Text input";
|
buttonText = "Text input";
|
||||||
if( i == 8 )
|
if (i == 8)
|
||||||
buttonText = "Joystick 2";
|
buttonText = "Joystick 2";
|
||||||
if( i == 9 )
|
if (i == 9)
|
||||||
buttonText = "Joystick 3";
|
buttonText = "Joystick 3";
|
||||||
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help) + "\n" + buttonText);
|
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help) + "\n" + buttonText);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent ev)
|
public boolean onTouch(View v, MotionEvent ev) {
|
||||||
{
|
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
if( ev.getAction() == MotionEvent.ACTION_DOWN )
|
oldX = (int) ev.getX();
|
||||||
{
|
oldY = (int) ev.getY();
|
||||||
oldX = (int)ev.getX();
|
|
||||||
oldY = (int)ev.getY();
|
|
||||||
resizing = true;
|
resizing = true;
|
||||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
for (int i = 0; i < Globals.ScreenKbControlsLayout.length; i++) {
|
||||||
{
|
if (!Globals.ScreenKbControlsShown[i])
|
||||||
if( ! Globals.ScreenKbControlsShown[i] )
|
|
||||||
continue;
|
continue;
|
||||||
if( Globals.ScreenKbControlsLayout[i][0] <= oldX &&
|
if (Globals.ScreenKbControlsLayout[i][0] <= oldX &&
|
||||||
Globals.ScreenKbControlsLayout[i][2] >= oldX &&
|
Globals.ScreenKbControlsLayout[i][2] >= oldX &&
|
||||||
Globals.ScreenKbControlsLayout[i][1] <= oldY &&
|
Globals.ScreenKbControlsLayout[i][1] <= oldY &&
|
||||||
Globals.ScreenKbControlsLayout[i][3] >= oldY )
|
Globals.ScreenKbControlsLayout[i][3] >= oldY) {
|
||||||
{
|
|
||||||
currentButton = i;
|
currentButton = i;
|
||||||
setupButton(currentButton);
|
setupButton(currentButton);
|
||||||
resizing = false;
|
resizing = false;
|
||||||
@ -773,30 +681,24 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( ev.getAction() == MotionEvent.ACTION_MOVE )
|
if (ev.getAction() == MotionEvent.ACTION_MOVE) {
|
||||||
{
|
int dx = (int) ev.getX() - oldX;
|
||||||
int dx = (int)ev.getX() - oldX;
|
int dy = (int) ev.getY() - oldY;
|
||||||
int dy = (int)ev.getY() - oldY;
|
if (resizing) {
|
||||||
if( resizing )
|
|
||||||
{
|
|
||||||
// Resize slowly, with 1/3 of movement speed
|
// Resize slowly, with 1/3 of movement speed
|
||||||
dx /= 6;
|
dx /= 6;
|
||||||
dy /= 6;
|
dy /= 6;
|
||||||
if( Globals.ScreenKbControlsLayout[currentButton][0] <= Globals.ScreenKbControlsLayout[currentButton][2] + dx*2 )
|
if (Globals.ScreenKbControlsLayout[currentButton][0] <= Globals.ScreenKbControlsLayout[currentButton][2] + dx * 2) {
|
||||||
{
|
|
||||||
Globals.ScreenKbControlsLayout[currentButton][0] -= dx;
|
Globals.ScreenKbControlsLayout[currentButton][0] -= dx;
|
||||||
Globals.ScreenKbControlsLayout[currentButton][2] += dx;
|
Globals.ScreenKbControlsLayout[currentButton][2] += dx;
|
||||||
}
|
}
|
||||||
if( Globals.ScreenKbControlsLayout[currentButton][1] <= Globals.ScreenKbControlsLayout[currentButton][3] + dy*2 )
|
if (Globals.ScreenKbControlsLayout[currentButton][1] <= Globals.ScreenKbControlsLayout[currentButton][3] + dy * 2) {
|
||||||
{
|
|
||||||
Globals.ScreenKbControlsLayout[currentButton][1] += dy;
|
Globals.ScreenKbControlsLayout[currentButton][1] += dy;
|
||||||
Globals.ScreenKbControlsLayout[currentButton][3] -= dy;
|
Globals.ScreenKbControlsLayout[currentButton][3] -= dy;
|
||||||
}
|
}
|
||||||
dx *= 6;
|
dx *= 6;
|
||||||
dy *= 6;
|
dy *= 6;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Globals.ScreenKbControlsLayout[currentButton][0] += dx;
|
Globals.ScreenKbControlsLayout[currentButton][0] += dx;
|
||||||
Globals.ScreenKbControlsLayout[currentButton][2] += dx;
|
Globals.ScreenKbControlsLayout[currentButton][2] += dx;
|
||||||
Globals.ScreenKbControlsLayout[currentButton][1] += dy;
|
Globals.ScreenKbControlsLayout[currentButton][1] += dy;
|
||||||
@ -819,10 +721,8 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKey(View v, int keyCode, KeyEvent event)
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||||
{
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
if( keyCode == KeyEvent.KEYCODE_BACK )
|
|
||||||
{
|
|
||||||
p.getVideoLayout().removeView(layout);
|
p.getVideoLayout().removeView(layout);
|
||||||
layout = null;
|
layout = null;
|
||||||
goBack(p);
|
goBack(p);
|
||||||
@ -832,15 +732,13 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ScreenKeyboardAdvanced extends Menu
|
static class ScreenKeyboardAdvanced extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.advanced);
|
return p.getResources().getString(R.string.advanced);
|
||||||
}
|
}
|
||||||
|
|
||||||
//boolean enabled() { return true; };
|
//boolean enabled() { return true; };
|
||||||
void run (final MainActivity p)
|
void run(final MainActivity p) {
|
||||||
{
|
|
||||||
CharSequence[] items = {
|
CharSequence[] items = {
|
||||||
p.getResources().getString(R.string.screenkb_floating_joystick),
|
p.getResources().getString(R.string.screenkb_floating_joystick),
|
||||||
};
|
};
|
||||||
@ -851,26 +749,20 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(p.getResources().getString(R.string.advanced));
|
builder.setTitle(p.getResources().getString(R.string.advanced));
|
||||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item, boolean isChecked) {
|
||||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
if (item == 0)
|
||||||
{
|
|
||||||
if( item == 0 )
|
|
||||||
Globals.FloatingScreenJoystick = isChecked;
|
Globals.FloatingScreenJoystick = isChecked;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -26,60 +26,47 @@ import android.content.DialogInterface;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.StatFs;
|
import android.os.StatFs;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.*;
|
||||||
import android.widget.EditText;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import android.widget.FrameLayout;
|
import io.neoterm.xorg.R;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ScrollView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import io.neoterm.xorg.R;
|
|
||||||
|
|
||||||
|
class SettingsMenuMisc extends SettingsMenu {
|
||||||
class SettingsMenuMisc extends SettingsMenu
|
static class DownloadConfig extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
static class DownloadConfig extends Menu
|
|
||||||
{
|
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.storage_question);
|
return p.getResources().getString(R.string.storage_question);
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
long freeSdcard = 0;
|
long freeSdcard = 0;
|
||||||
long freePhone = 0;
|
long freePhone = 0;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
StatFs phone = new StatFs(p.getFilesDir().getAbsolutePath());
|
StatFs phone = new StatFs(p.getFilesDir().getAbsolutePath());
|
||||||
freePhone = (long)phone.getAvailableBlocks() * phone.getBlockSize() / 1024 / 1024;
|
freePhone = (long) phone.getAvailableBlocks() * phone.getBlockSize() / 1024 / 1024;
|
||||||
StatFs sdcard = new StatFs(Settings.SdcardAppPath.get().bestPath(p));
|
StatFs sdcard = new StatFs(Settings.SdcardAppPath.get().bestPath(p));
|
||||||
freeSdcard = (long)sdcard.getAvailableBlocks() * sdcard.getBlockSize() / 1024 / 1024;
|
freeSdcard = (long) sdcard.getAvailableBlocks() * sdcard.getBlockSize() / 1024 / 1024;
|
||||||
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
catch(Exception e) {}
|
|
||||||
|
|
||||||
final CharSequence[] items = { p.getResources().getString(R.string.storage_phone, freePhone),
|
final CharSequence[] items = {p.getResources().getString(R.string.storage_phone, freePhone),
|
||||||
p.getResources().getString(R.string.storage_sd, freeSdcard),
|
p.getResources().getString(R.string.storage_sd, freeSdcard),
|
||||||
p.getResources().getString(R.string.storage_custom) };
|
p.getResources().getString(R.string.storage_custom)};
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(p.getResources().getString(R.string.storage_question));
|
builder.setTitle(p.getResources().getString(R.string.storage_question));
|
||||||
builder.setSingleChoiceItems(items, Globals.DownloadToSdcard ? 1 : 0, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.DownloadToSdcard ? 1 : 0, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
if( item == 2 )
|
if (item == 2)
|
||||||
showCustomDownloadDirConfig(p);
|
showCustomDownloadDirConfig(p);
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
Globals.DownloadToSdcard = (item != 0);
|
Globals.DownloadToSdcard = (item != 0);
|
||||||
Globals.DataDir = Globals.DownloadToSdcard ?
|
Globals.DataDir = Globals.DownloadToSdcard ?
|
||||||
Settings.SdcardAppPath.get().bestPath(p) :
|
Settings.SdcardAppPath.get().bestPath(p) :
|
||||||
@ -88,10 +75,8 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -99,8 +84,8 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
alert.setOwnerActivity(p);
|
alert.setOwnerActivity(p);
|
||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
static void showCustomDownloadDirConfig(final MainActivity p)
|
|
||||||
{
|
static void showCustomDownloadDirConfig(final MainActivity p) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(p.getResources().getString(R.string.storage_custom));
|
builder.setTitle(p.getResources().getString(R.string.storage_custom));
|
||||||
|
|
||||||
@ -110,19 +95,15 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
edit.setText(Globals.DataDir);
|
edit.setText(Globals.DataDir);
|
||||||
builder.setView(edit);
|
builder.setView(edit);
|
||||||
|
|
||||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.DataDir = edit.getText().toString();
|
Globals.DataDir = edit.getText().toString();
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -132,24 +113,23 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class OptionalDownloadConfig extends Menu
|
static class OptionalDownloadConfig extends Menu {
|
||||||
{
|
|
||||||
boolean firstStart = false;
|
boolean firstStart = false;
|
||||||
OptionalDownloadConfig()
|
|
||||||
{
|
OptionalDownloadConfig() {
|
||||||
firstStart = true;
|
firstStart = true;
|
||||||
}
|
}
|
||||||
OptionalDownloadConfig(boolean firstStart)
|
|
||||||
{
|
OptionalDownloadConfig(boolean firstStart) {
|
||||||
this.firstStart = firstStart;
|
this.firstStart = firstStart;
|
||||||
}
|
}
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
return p.getResources().getString(R.string.downloads);
|
return p.getResources().getString(R.string.downloads);
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
String [] downloadFiles = Globals.DataDownloadUrl;
|
String[] downloadFiles = Globals.DataDownloadUrl;
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(p.getResources().getString(R.string.downloads));
|
builder.setTitle(p.getResources().getString(R.string.downloads));
|
||||||
@ -157,79 +137,64 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
final int itemsIdx[] = new int[downloadFiles.length];
|
final int itemsIdx[] = new int[downloadFiles.length];
|
||||||
ArrayList<CharSequence> items = new ArrayList<CharSequence>();
|
ArrayList<CharSequence> items = new ArrayList<CharSequence>();
|
||||||
ArrayList<Boolean> enabledItems = new ArrayList<Boolean>();
|
ArrayList<Boolean> enabledItems = new ArrayList<Boolean>();
|
||||||
for(int i = 0; i < downloadFiles.length; i++ )
|
for (int i = 0; i < downloadFiles.length; i++) {
|
||||||
{
|
|
||||||
String item = new String(downloadFiles[i].split("[|]")[0]);
|
String item = new String(downloadFiles[i].split("[|]")[0]);
|
||||||
boolean enabled = false;
|
boolean enabled = false;
|
||||||
if( item.toString().indexOf("!") == 0 )
|
if (item.toString().indexOf("!") == 0) {
|
||||||
{
|
|
||||||
item = item.toString().substring(1);
|
item = item.toString().substring(1);
|
||||||
enabled = true;
|
enabled = true;
|
||||||
}
|
}
|
||||||
if( item.toString().indexOf("!") == 0 ) // Download is mandatory
|
if (item.toString().indexOf("!") == 0) // Download is mandatory
|
||||||
continue;
|
continue;
|
||||||
itemsIdx[items.size()] = i;
|
itemsIdx[items.size()] = i;
|
||||||
items.add(item);
|
items.add(item);
|
||||||
enabledItems.add(enabled);
|
enabledItems.add(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Globals.OptionalDataDownload == null || Globals.OptionalDataDownload.length != downloadFiles.length )
|
if (Globals.OptionalDataDownload == null || Globals.OptionalDataDownload.length != downloadFiles.length) {
|
||||||
{
|
|
||||||
Globals.OptionalDataDownload = new boolean[downloadFiles.length];
|
Globals.OptionalDataDownload = new boolean[downloadFiles.length];
|
||||||
boolean oldFormat = true;
|
boolean oldFormat = true;
|
||||||
for( int i = 0; i < downloadFiles.length; i++ )
|
for (int i = 0; i < downloadFiles.length; i++) {
|
||||||
{
|
if (downloadFiles[i].indexOf("!") == 0) {
|
||||||
if( downloadFiles[i].indexOf("!") == 0 )
|
|
||||||
{
|
|
||||||
Globals.OptionalDataDownload[i] = true;
|
Globals.OptionalDataDownload[i] = true;
|
||||||
oldFormat = false;
|
oldFormat = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( oldFormat )
|
if (oldFormat)
|
||||||
Globals.OptionalDataDownload[0] = true;
|
Globals.OptionalDataDownload[0] = true;
|
||||||
}
|
}
|
||||||
if( enabledItems.size() <= 0 )
|
if (enabledItems.size() <= 0) {
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert Boolean[] to boolean[], meh
|
// Convert Boolean[] to boolean[], meh
|
||||||
boolean[] enabledItems2 = new boolean[enabledItems.size()];
|
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);
|
enabledItems2[i] = enabledItems.get(i);
|
||||||
|
|
||||||
builder.setMultiChoiceItems(items.toArray(new CharSequence[0]), enabledItems2, new DialogInterface.OnMultiChoiceClickListener()
|
builder.setMultiChoiceItems(items.toArray(new CharSequence[0]), enabledItems2, new DialogInterface.OnMultiChoiceClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item, boolean isChecked) {
|
||||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
|
||||||
{
|
|
||||||
Globals.OptionalDataDownload[itemsIdx[item]] = isChecked;
|
Globals.OptionalDataDownload[itemsIdx[item]] = isChecked;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if( firstStart )
|
if (firstStart) {
|
||||||
{
|
builder.setNegativeButton(p.getResources().getString(R.string.show_more_options), new DialogInterface.OnClickListener() {
|
||||||
builder.setNegativeButton(p.getResources().getString(R.string.show_more_options), new DialogInterface.OnClickListener()
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
{
|
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
menuStack.clear();
|
menuStack.clear();
|
||||||
new MainMenu().run(p);
|
new MainMenu().run(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -239,34 +204,28 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class AudioConfig extends Menu
|
static class AudioConfig extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.audiobuf_question);
|
return p.getResources().getString(R.string.audiobuf_question);
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
final CharSequence[] items = { p.getResources().getString(R.string.audiobuf_verysmall),
|
final CharSequence[] items = {p.getResources().getString(R.string.audiobuf_verysmall),
|
||||||
p.getResources().getString(R.string.audiobuf_small),
|
p.getResources().getString(R.string.audiobuf_small),
|
||||||
p.getResources().getString(R.string.audiobuf_medium),
|
p.getResources().getString(R.string.audiobuf_medium),
|
||||||
p.getResources().getString(R.string.audiobuf_large) };
|
p.getResources().getString(R.string.audiobuf_large)};
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(R.string.audiobuf_question);
|
builder.setTitle(R.string.audiobuf_question);
|
||||||
builder.setSingleChoiceItems(items, Globals.AudioBufferConfig, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.AudioBufferConfig, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.AudioBufferConfig = item;
|
Globals.AudioBufferConfig = item;
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -276,16 +235,15 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class VideoSettingsConfig extends Menu
|
static class VideoSettingsConfig extends Menu {
|
||||||
{
|
|
||||||
static int debugMenuShowCount = 0;
|
static int debugMenuShowCount = 0;
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
return p.getResources().getString(R.string.video);
|
return p.getResources().getString(R.string.video);
|
||||||
}
|
}
|
||||||
|
|
||||||
//boolean enabled() { return true; };
|
//boolean enabled() { return true; };
|
||||||
void run (final MainActivity p)
|
void run(final MainActivity p) {
|
||||||
{
|
|
||||||
debugMenuShowCount++;
|
debugMenuShowCount++;
|
||||||
CharSequence[] items = {
|
CharSequence[] items = {
|
||||||
p.getResources().getString(R.string.mouse_keepaspectratio),
|
p.getResources().getString(R.string.mouse_keepaspectratio),
|
||||||
@ -306,8 +264,7 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
Globals.TvBorders,
|
Globals.TvBorders,
|
||||||
};
|
};
|
||||||
|
|
||||||
if(Globals.SwVideoMode && !Globals.CompatibilityHacksVideo)
|
if (Globals.SwVideoMode && !Globals.CompatibilityHacksVideo) {
|
||||||
{
|
|
||||||
CharSequence[] items2 = {
|
CharSequence[] items2 = {
|
||||||
p.getResources().getString(R.string.mouse_keepaspectratio),
|
p.getResources().getString(R.string.mouse_keepaspectratio),
|
||||||
p.getResources().getString(R.string.video_smooth),
|
p.getResources().getString(R.string.video_smooth),
|
||||||
@ -332,8 +289,7 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
defaults = defaults2;
|
defaults = defaults2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Globals.Using_SDL_1_3)
|
if (Globals.Using_SDL_1_3) {
|
||||||
{
|
|
||||||
CharSequence[] items2 = {
|
CharSequence[] items2 = {
|
||||||
p.getResources().getString(R.string.mouse_keepaspectratio),
|
p.getResources().getString(R.string.mouse_keepaspectratio),
|
||||||
};
|
};
|
||||||
@ -346,40 +302,34 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(p.getResources().getString(R.string.video));
|
builder.setTitle(p.getResources().getString(R.string.video));
|
||||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item, boolean isChecked) {
|
||||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
if (item == 0)
|
||||||
{
|
|
||||||
if( item == 0 )
|
|
||||||
Globals.KeepAspectRatio = isChecked;
|
Globals.KeepAspectRatio = isChecked;
|
||||||
if( item == 1 )
|
if (item == 1)
|
||||||
Globals.VideoLinearFilter = isChecked;
|
Globals.VideoLinearFilter = isChecked;
|
||||||
if( item == 2 )
|
if (item == 2)
|
||||||
Globals.ImmersiveMode = isChecked;
|
Globals.ImmersiveMode = isChecked;
|
||||||
if( item == 3 )
|
if (item == 3)
|
||||||
Globals.AutoDetectOrientation = isChecked;
|
Globals.AutoDetectOrientation = isChecked;
|
||||||
if( item == 4 )
|
if (item == 4)
|
||||||
Globals.HorizontalOrientation = !isChecked;
|
Globals.HorizontalOrientation = !isChecked;
|
||||||
if( item == 5 )
|
if (item == 5)
|
||||||
Globals.VideoDepthBpp = (isChecked ? 24 : 16);
|
Globals.VideoDepthBpp = (isChecked ? 24 : 16);
|
||||||
if( item == 6 )
|
if (item == 6)
|
||||||
Globals.TvBorders = isChecked;
|
Globals.TvBorders = isChecked;
|
||||||
if( item == 7 )
|
if (item == 7)
|
||||||
Globals.MultiThreadedVideo = isChecked;
|
Globals.MultiThreadedVideo = isChecked;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -389,41 +339,35 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ShowReadme extends Menu
|
static class ShowReadme extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return "Readme";
|
return "Readme";
|
||||||
}
|
}
|
||||||
boolean enabled()
|
|
||||||
{
|
boolean enabled() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
String readmes[] = Globals.ReadmeText.split("\\^");
|
String readmes[] = Globals.ReadmeText.split("\\^");
|
||||||
String lang = new String(Locale.getDefault().getLanguage()) + ":";
|
String lang = new String(Locale.getDefault().getLanguage()) + ":";
|
||||||
if( p.isRunningOnOUYA() )
|
if (p.isRunningOnOUYA())
|
||||||
lang = "tv:";
|
lang = "tv:";
|
||||||
String readme = readmes[0];
|
String readme = readmes[0];
|
||||||
String buttonName = "", buttonUrl = "";
|
String buttonName = "", buttonUrl = "";
|
||||||
for( String r: readmes )
|
for (String r : readmes) {
|
||||||
{
|
if (r.startsWith(lang))
|
||||||
if( r.startsWith(lang) )
|
|
||||||
readme = r.substring(lang.length());
|
readme = r.substring(lang.length());
|
||||||
if( r.startsWith("button:") )
|
if (r.startsWith("button:")) {
|
||||||
{
|
|
||||||
buttonName = r.substring("button:".length());
|
buttonName = r.substring("button:".length());
|
||||||
if( buttonName.indexOf(":") != -1 )
|
if (buttonName.indexOf(":") != -1) {
|
||||||
{
|
|
||||||
buttonUrl = buttonName.substring(buttonName.indexOf(":") + 1);
|
buttonUrl = buttonName.substring(buttonName.indexOf(":") + 1);
|
||||||
buttonName = buttonName.substring(0, buttonName.indexOf(":"));
|
buttonName = buttonName.substring(0, buttonName.indexOf(":"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
readme = readme.trim();
|
readme = readme.trim();
|
||||||
if( readme.length() <= 2 )
|
if (readme.length() <= 2) {
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -445,10 +389,8 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
scroll.addView(text, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
scroll.addView(text, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
final Button ok = new Button(p);
|
final Button ok = new Button(p);
|
||||||
final AlertDialog alertDismiss[] = new AlertDialog[1];
|
final AlertDialog alertDismiss[] = new AlertDialog[1];
|
||||||
ok.setOnClickListener(new View.OnClickListener()
|
ok.setOnClickListener(new View.OnClickListener() {
|
||||||
{
|
public void onClick(View v) {
|
||||||
public void onClick(View v)
|
|
||||||
{
|
|
||||||
alertDismiss[0].cancel();
|
alertDismiss[0].cancel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -457,17 +399,13 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
layout.setOrientation(LinearLayout.VERTICAL);
|
layout.setOrientation(LinearLayout.VERTICAL);
|
||||||
layout.addView(scroll);
|
layout.addView(scroll);
|
||||||
layout.addView(ok);
|
layout.addView(ok);
|
||||||
if( buttonName.length() > 0 )
|
if (buttonName.length() > 0) {
|
||||||
{
|
|
||||||
Button cancel = new Button(p);
|
Button cancel = new Button(p);
|
||||||
cancel.setText(buttonName);
|
cancel.setText(buttonName);
|
||||||
final String url = buttonUrl;
|
final String url = buttonUrl;
|
||||||
cancel.setOnClickListener(new View.OnClickListener()
|
cancel.setOnClickListener(new View.OnClickListener() {
|
||||||
{
|
public void onClick(View v) {
|
||||||
public void onClick(View v)
|
if (url.length() > 0) {
|
||||||
{
|
|
||||||
if( url.length() > 0 )
|
|
||||||
{
|
|
||||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||||
i.setData(Uri.parse(url));
|
i.setData(Uri.parse(url));
|
||||||
p.startActivity(i);
|
p.startActivity(i);
|
||||||
@ -479,10 +417,8 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
layout.addView(cancel);
|
layout.addView(cancel);
|
||||||
}
|
}
|
||||||
builder.setView(layout);
|
builder.setView(layout);
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -493,30 +429,26 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class GyroscopeCalibration extends Menu
|
static class GyroscopeCalibration extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
boolean enabled()
|
|
||||||
{
|
boolean enabled() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class CommandlineConfig extends Menu
|
static class CommandlineConfig extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.storage_commandline);
|
return p.getResources().getString(R.string.storage_commandline);
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(p.getResources().getString(R.string.storage_commandline));
|
builder.setTitle(p.getResources().getString(R.string.storage_commandline));
|
||||||
|
|
||||||
@ -533,17 +465,14 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
//edit.setMaxLines(100);
|
//edit.setMaxLines(100);
|
||||||
builder.setView(edit);
|
builder.setView(edit);
|
||||||
|
|
||||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.CommandLine = "SDL_app";
|
Globals.CommandLine = "SDL_app";
|
||||||
String args[] = edit.getText().toString().split("\n");
|
String args[] = edit.getText().toString().split("\n");
|
||||||
boolean firstArg = true;
|
boolean firstArg = true;
|
||||||
for( String arg: args )
|
for (String arg : args) {
|
||||||
{
|
|
||||||
Globals.CommandLine += " ";
|
Globals.CommandLine += " ";
|
||||||
if( firstArg )
|
if (firstArg)
|
||||||
Globals.CommandLine += arg;
|
Globals.CommandLine += arg;
|
||||||
else
|
else
|
||||||
Globals.CommandLine += arg.replace(" ", " ");
|
Globals.CommandLine += arg.replace(" ", " ");
|
||||||
@ -553,10 +482,8 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -566,43 +493,35 @@ class SettingsMenuMisc extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ResetToDefaultsConfig extends Menu
|
static class ResetToDefaultsConfig extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.reset_config);
|
return p.getResources().getString(R.string.reset_config);
|
||||||
}
|
}
|
||||||
boolean enabled()
|
|
||||||
{
|
boolean enabled() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(p.getResources().getString(R.string.reset_config_ask));
|
builder.setTitle(p.getResources().getString(R.string.reset_config_ask));
|
||||||
builder.setMessage(p.getResources().getString(R.string.reset_config_ask));
|
builder.setMessage(p.getResources().getString(R.string.reset_config_ask));
|
||||||
|
|
||||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Settings.DeleteSdlConfigOnUpgradeAndRestart(p); // Never returns
|
Settings.DeleteSdlConfigOnUpgradeAndRestart(p); // Never returns
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(p.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener()
|
builder.setNegativeButton(p.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -27,33 +27,29 @@ import android.graphics.Bitmap;
|
|||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import io.neoterm.xorg.R;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import io.neoterm.xorg.R;
|
|
||||||
|
|
||||||
|
class SettingsMenuMouse extends SettingsMenu {
|
||||||
class SettingsMenuMouse extends SettingsMenu
|
static class MouseConfigMainMenu extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
static class MouseConfigMainMenu extends Menu
|
|
||||||
{
|
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.mouse_emulation);
|
return p.getResources().getString(R.string.mouse_emulation);
|
||||||
}
|
}
|
||||||
boolean enabled()
|
|
||||||
{
|
boolean enabled() {
|
||||||
return Globals.AppUsesMouse;
|
return Globals.AppUsesMouse;
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
Menu options[] =
|
Menu options[] =
|
||||||
{
|
{
|
||||||
new DisplaySizeConfig(false),
|
new DisplaySizeConfig(false),
|
||||||
@ -69,23 +65,22 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class DisplaySizeConfig extends Menu
|
static class DisplaySizeConfig extends Menu {
|
||||||
{
|
|
||||||
boolean firstStart = false;
|
boolean firstStart = false;
|
||||||
DisplaySizeConfig()
|
|
||||||
{
|
DisplaySizeConfig() {
|
||||||
this.firstStart = true;
|
this.firstStart = true;
|
||||||
}
|
}
|
||||||
DisplaySizeConfig(boolean firstStart)
|
|
||||||
{
|
DisplaySizeConfig(boolean firstStart) {
|
||||||
this.firstStart = firstStart;
|
this.firstStart = firstStart;
|
||||||
}
|
}
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
return p.getResources().getString(R.string.display_size_mouse);
|
return p.getResources().getString(R.string.display_size_mouse);
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
CharSequence[] items = {
|
CharSequence[] items = {
|
||||||
p.getResources().getString(R.string.display_size_small),
|
p.getResources().getString(R.string.display_size_small),
|
||||||
p.getResources().getString(R.string.display_size_small_touchpad),
|
p.getResources().getString(R.string.display_size_small_touchpad),
|
||||||
@ -98,8 +93,7 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
int _size_desktop = 3;
|
int _size_desktop = 3;
|
||||||
int _more_options = 4;
|
int _more_options = 4;
|
||||||
|
|
||||||
if( ! Globals.SwVideoMode )
|
if (!Globals.SwVideoMode) {
|
||||||
{
|
|
||||||
CharSequence[] items2 = {
|
CharSequence[] items2 = {
|
||||||
p.getResources().getString(R.string.display_size_small_touchpad),
|
p.getResources().getString(R.string.display_size_small_touchpad),
|
||||||
p.getResources().getString(R.string.display_size_large),
|
p.getResources().getString(R.string.display_size_large),
|
||||||
@ -111,8 +105,7 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
_size_desktop = 2;
|
_size_desktop = 2;
|
||||||
_size_small = 1000;
|
_size_small = 1000;
|
||||||
}
|
}
|
||||||
if( firstStart )
|
if (firstStart) {
|
||||||
{
|
|
||||||
CharSequence[] items2 = {
|
CharSequence[] items2 = {
|
||||||
p.getResources().getString(R.string.display_size_small),
|
p.getResources().getString(R.string.display_size_small),
|
||||||
p.getResources().getString(R.string.display_size_small_touchpad),
|
p.getResources().getString(R.string.display_size_small_touchpad),
|
||||||
@ -121,8 +114,7 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
p.getResources().getString(R.string.show_more_options),
|
p.getResources().getString(R.string.show_more_options),
|
||||||
};
|
};
|
||||||
items = items2;
|
items = items2;
|
||||||
if( ! Globals.SwVideoMode )
|
if (!Globals.SwVideoMode) {
|
||||||
{
|
|
||||||
CharSequence[] items3 = {
|
CharSequence[] items3 = {
|
||||||
p.getResources().getString(R.string.display_size_small_touchpad),
|
p.getResources().getString(R.string.display_size_small_touchpad),
|
||||||
p.getResources().getString(R.string.display_size_large),
|
p.getResources().getString(R.string.display_size_large),
|
||||||
@ -142,41 +134,34 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(R.string.display_size);
|
builder.setTitle(R.string.display_size);
|
||||||
class ClickListener implements DialogInterface.OnClickListener
|
class ClickListener implements DialogInterface.OnClickListener {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
if( item == size_desktop )
|
if (item == size_desktop) {
|
||||||
{
|
|
||||||
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NORMAL;
|
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NORMAL;
|
||||||
Globals.RelativeMouseMovement = false;
|
Globals.RelativeMouseMovement = false;
|
||||||
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
|
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
|
||||||
Globals.ForceHardwareMouse = true;
|
Globals.ForceHardwareMouse = true;
|
||||||
}
|
}
|
||||||
if( item == size_large )
|
if (item == size_large) {
|
||||||
{
|
|
||||||
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NORMAL;
|
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NORMAL;
|
||||||
Globals.RelativeMouseMovement = false;
|
Globals.RelativeMouseMovement = false;
|
||||||
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
|
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
|
||||||
Globals.ForceHardwareMouse = false;
|
Globals.ForceHardwareMouse = false;
|
||||||
}
|
}
|
||||||
if( item == size_small )
|
if (item == size_small) {
|
||||||
{
|
|
||||||
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR;
|
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR;
|
||||||
Globals.RelativeMouseMovement = false;
|
Globals.RelativeMouseMovement = false;
|
||||||
Globals.ShowScreenUnderFinger = Mouse.ZOOM_MAGNIFIER;
|
Globals.ShowScreenUnderFinger = Mouse.ZOOM_MAGNIFIER;
|
||||||
Globals.ForceHardwareMouse = false;
|
Globals.ForceHardwareMouse = false;
|
||||||
}
|
}
|
||||||
if( item == size_small_touchpad )
|
if (item == size_small_touchpad) {
|
||||||
{
|
|
||||||
Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT;
|
Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT;
|
||||||
Globals.RelativeMouseMovement = true;
|
Globals.RelativeMouseMovement = true;
|
||||||
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
|
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
|
||||||
Globals.ForceHardwareMouse = false;
|
Globals.ForceHardwareMouse = false;
|
||||||
}
|
}
|
||||||
if( item == more_options )
|
if (item == more_options) {
|
||||||
{
|
|
||||||
menuStack.clear();
|
menuStack.clear();
|
||||||
new MainMenu().run(p);
|
new MainMenu().run(p);
|
||||||
return;
|
return;
|
||||||
@ -194,10 +179,8 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
Globals.ShowScreenUnderFinger + 1,
|
Globals.ShowScreenUnderFinger + 1,
|
||||||
new ClickListener());
|
new ClickListener());
|
||||||
*/
|
*/
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -207,43 +190,37 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class LeftClickConfig extends Menu
|
static class LeftClickConfig extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.leftclick_question);
|
return p.getResources().getString(R.string.leftclick_question);
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
final CharSequence[] items = { p.getResources().getString(R.string.leftclick_normal),
|
final CharSequence[] items = {p.getResources().getString(R.string.leftclick_normal),
|
||||||
p.getResources().getString(R.string.leftclick_near_cursor),
|
p.getResources().getString(R.string.leftclick_near_cursor),
|
||||||
p.getResources().getString(R.string.leftclick_multitouch),
|
p.getResources().getString(R.string.leftclick_multitouch),
|
||||||
p.getResources().getString(R.string.leftclick_pressure),
|
p.getResources().getString(R.string.leftclick_pressure),
|
||||||
p.getResources().getString(R.string.rightclick_key),
|
p.getResources().getString(R.string.rightclick_key),
|
||||||
p.getResources().getString(R.string.leftclick_timeout),
|
p.getResources().getString(R.string.leftclick_timeout),
|
||||||
p.getResources().getString(R.string.leftclick_tap),
|
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);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(R.string.leftclick_question);
|
builder.setTitle(R.string.leftclick_question);
|
||||||
builder.setSingleChoiceItems(items, Globals.LeftClickMethod, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.LeftClickMethod, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
Globals.LeftClickMethod = item;
|
Globals.LeftClickMethod = item;
|
||||||
if( item == Mouse.LEFT_CLICK_WITH_KEY )
|
if (item == Mouse.LEFT_CLICK_WITH_KEY)
|
||||||
p.getVideoLayout().setOnKeyListener(new KeyRemapToolMouseClick(p, true));
|
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);
|
showLeftClickTimeoutConfig(p);
|
||||||
else
|
else
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -251,28 +228,25 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
alert.setOwnerActivity(p);
|
alert.setOwnerActivity(p);
|
||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void showLeftClickTimeoutConfig(final MainActivity p) {
|
static void showLeftClickTimeoutConfig(final MainActivity p) {
|
||||||
final CharSequence[] items = { p.getResources().getString(R.string.leftclick_timeout_time_0),
|
final CharSequence[] items = {p.getResources().getString(R.string.leftclick_timeout_time_0),
|
||||||
p.getResources().getString(R.string.leftclick_timeout_time_1),
|
p.getResources().getString(R.string.leftclick_timeout_time_1),
|
||||||
p.getResources().getString(R.string.leftclick_timeout_time_2),
|
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_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);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(R.string.leftclick_timeout_time);
|
builder.setTitle(R.string.leftclick_timeout_time);
|
||||||
builder.setSingleChoiceItems(items, Globals.LeftClickTimeout, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.LeftClickTimeout, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.LeftClickTimeout = item;
|
Globals.LeftClickTimeout = item;
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -282,44 +256,38 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class RightClickConfig extends Menu
|
static class RightClickConfig extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.rightclick_question);
|
return p.getResources().getString(R.string.rightclick_question);
|
||||||
}
|
}
|
||||||
boolean enabled()
|
|
||||||
{
|
boolean enabled() {
|
||||||
return Globals.AppNeedsTwoButtonMouse;
|
return Globals.AppNeedsTwoButtonMouse;
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
final CharSequence[] items = { p.getResources().getString(R.string.rightclick_none),
|
final CharSequence[] items = {p.getResources().getString(R.string.rightclick_none),
|
||||||
p.getResources().getString(R.string.rightclick_multitouch),
|
p.getResources().getString(R.string.rightclick_multitouch),
|
||||||
p.getResources().getString(R.string.rightclick_pressure),
|
p.getResources().getString(R.string.rightclick_pressure),
|
||||||
p.getResources().getString(R.string.rightclick_key),
|
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);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(R.string.rightclick_question);
|
builder.setTitle(R.string.rightclick_question);
|
||||||
builder.setSingleChoiceItems(items, Globals.RightClickMethod, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.RightClickMethod, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.RightClickMethod = item;
|
Globals.RightClickMethod = item;
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
if( item == Mouse.RIGHT_CLICK_WITH_KEY )
|
if (item == Mouse.RIGHT_CLICK_WITH_KEY)
|
||||||
p.getVideoLayout().setOnKeyListener(new KeyRemapToolMouseClick(p, false));
|
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);
|
showRightClickTimeoutConfig(p);
|
||||||
else
|
else
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -329,27 +297,23 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void showRightClickTimeoutConfig(final MainActivity p) {
|
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_1),
|
||||||
p.getResources().getString(R.string.leftclick_timeout_time_2),
|
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_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);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(R.string.leftclick_timeout_time);
|
builder.setTitle(R.string.leftclick_timeout_time);
|
||||||
builder.setSingleChoiceItems(items, Globals.RightClickTimeout, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.RightClickTimeout, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.RightClickTimeout = item;
|
Globals.RightClickTimeout = item;
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -359,28 +323,26 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class KeyRemapToolMouseClick implements View.OnKeyListener
|
public static class KeyRemapToolMouseClick implements View.OnKeyListener {
|
||||||
{
|
|
||||||
MainActivity p;
|
MainActivity p;
|
||||||
boolean leftClick;
|
boolean leftClick;
|
||||||
public KeyRemapToolMouseClick(MainActivity _p, boolean leftClick)
|
|
||||||
{
|
public KeyRemapToolMouseClick(MainActivity _p, boolean leftClick) {
|
||||||
p = _p;
|
p = _p;
|
||||||
p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
|
p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
|
||||||
this.leftClick = leftClick;
|
this.leftClick = leftClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKey(View v, int keyCode, KeyEvent event)
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||||
{
|
|
||||||
p.getVideoLayout().setOnKeyListener(null);
|
p.getVideoLayout().setOnKeyListener(null);
|
||||||
int keyIndex = keyCode;
|
int keyIndex = keyCode;
|
||||||
if( keyIndex < 0 )
|
if (keyIndex < 0)
|
||||||
keyIndex = 0;
|
keyIndex = 0;
|
||||||
if( keyIndex > SDL_Keys.JAVA_KEYCODE_LAST )
|
if (keyIndex > SDL_Keys.JAVA_KEYCODE_LAST)
|
||||||
keyIndex = 0;
|
keyIndex = 0;
|
||||||
|
|
||||||
if( leftClick )
|
if (leftClick)
|
||||||
Globals.LeftClickKey = keyIndex;
|
Globals.LeftClickKey = keyIndex;
|
||||||
else
|
else
|
||||||
Globals.RightClickKey = keyIndex;
|
Globals.RightClickKey = keyIndex;
|
||||||
@ -390,14 +352,12 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class AdditionalMouseConfig extends Menu
|
static class AdditionalMouseConfig extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.advanced);
|
return p.getResources().getString(R.string.advanced);
|
||||||
}
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
void run(final MainActivity p) {
|
||||||
CharSequence[] items = {
|
CharSequence[] items = {
|
||||||
p.getResources().getString(R.string.mouse_hover_jitter_filter),
|
p.getResources().getString(R.string.mouse_hover_jitter_filter),
|
||||||
p.getResources().getString(R.string.mouse_joystickmouse),
|
p.getResources().getString(R.string.mouse_joystickmouse),
|
||||||
@ -420,38 +380,32 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(p.getResources().getString(R.string.advanced));
|
builder.setTitle(p.getResources().getString(R.string.advanced));
|
||||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item, boolean isChecked) {
|
||||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
if (item == 0)
|
||||||
{
|
|
||||||
if( item == 0 )
|
|
||||||
Globals.HoverJitterFilter = isChecked;
|
Globals.HoverJitterFilter = isChecked;
|
||||||
if( item == 1 )
|
if (item == 1)
|
||||||
Globals.MoveMouseWithJoystick = isChecked;
|
Globals.MoveMouseWithJoystick = isChecked;
|
||||||
if( item == 2 )
|
if (item == 2)
|
||||||
Globals.ClickMouseWithDpad = isChecked;
|
Globals.ClickMouseWithDpad = isChecked;
|
||||||
if( item == 3 )
|
if (item == 3)
|
||||||
Globals.RelativeMouseMovement = isChecked;
|
Globals.RelativeMouseMovement = isChecked;
|
||||||
if( item == 4 )
|
if (item == 4)
|
||||||
Globals.MoveMouseWithGyroscope = isChecked;
|
Globals.MoveMouseWithGyroscope = isChecked;
|
||||||
if( item == 5 )
|
if (item == 5)
|
||||||
Globals.FingerHover = isChecked;
|
Globals.FingerHover = isChecked;
|
||||||
if( item == 6 )
|
if (item == 6)
|
||||||
Globals.GenerateSubframeTouchEvents = isChecked;
|
Globals.GenerateSubframeTouchEvents = isChecked;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
showGyroscopeMouseMovementConfig(p);
|
showGyroscopeMouseMovementConfig(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -460,36 +414,30 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void showGyroscopeMouseMovementConfig(final MainActivity p)
|
static void showGyroscopeMouseMovementConfig(final MainActivity p) {
|
||||||
{
|
if (!Globals.MoveMouseWithGyroscope) {
|
||||||
if( !Globals.MoveMouseWithGyroscope )
|
|
||||||
{
|
|
||||||
showRelativeMouseMovementConfig(p);
|
showRelativeMouseMovementConfig(p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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_slow),
|
||||||
p.getResources().getString(R.string.accel_medium),
|
p.getResources().getString(R.string.accel_medium),
|
||||||
p.getResources().getString(R.string.accel_fast),
|
p.getResources().getString(R.string.accel_fast),
|
||||||
p.getResources().getString(R.string.accel_veryfast) };
|
p.getResources().getString(R.string.accel_veryfast)};
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(R.string.mouse_gyroscope_mouse_sensitivity);
|
builder.setTitle(R.string.mouse_gyroscope_mouse_sensitivity);
|
||||||
builder.setSingleChoiceItems(items, Globals.MoveMouseWithGyroscopeSpeed, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.MoveMouseWithGyroscopeSpeed, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.MoveMouseWithGyroscopeSpeed = item;
|
Globals.MoveMouseWithGyroscopeSpeed = item;
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
showRelativeMouseMovementConfig(p);
|
showRelativeMouseMovementConfig(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -498,36 +446,30 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void showRelativeMouseMovementConfig(final MainActivity p)
|
static void showRelativeMouseMovementConfig(final MainActivity p) {
|
||||||
{
|
if (!Globals.RelativeMouseMovement) {
|
||||||
if( !Globals.RelativeMouseMovement )
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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_slow),
|
||||||
p.getResources().getString(R.string.accel_medium),
|
p.getResources().getString(R.string.accel_medium),
|
||||||
p.getResources().getString(R.string.accel_fast),
|
p.getResources().getString(R.string.accel_fast),
|
||||||
p.getResources().getString(R.string.accel_veryfast) };
|
p.getResources().getString(R.string.accel_veryfast)};
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(R.string.mouse_relative_speed);
|
builder.setTitle(R.string.mouse_relative_speed);
|
||||||
builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementSpeed, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementSpeed, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.RelativeMouseMovementSpeed = item;
|
Globals.RelativeMouseMovementSpeed = item;
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
showRelativeMouseMovementConfig1(p);
|
showRelativeMouseMovementConfig1(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -536,29 +478,24 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void showRelativeMouseMovementConfig1(final MainActivity p)
|
static void showRelativeMouseMovementConfig1(final MainActivity p) {
|
||||||
{
|
final CharSequence[] items = {p.getResources().getString(R.string.none),
|
||||||
final CharSequence[] items = { p.getResources().getString(R.string.none),
|
|
||||||
p.getResources().getString(R.string.accel_slow),
|
p.getResources().getString(R.string.accel_slow),
|
||||||
p.getResources().getString(R.string.accel_medium),
|
p.getResources().getString(R.string.accel_medium),
|
||||||
p.getResources().getString(R.string.accel_fast) };
|
p.getResources().getString(R.string.accel_fast)};
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(R.string.mouse_relative_accel);
|
builder.setTitle(R.string.mouse_relative_accel);
|
||||||
builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementAccel, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementAccel, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.RelativeMouseMovementAccel = item;
|
Globals.RelativeMouseMovementAccel = item;
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -568,38 +505,34 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class JoystickMouseConfig extends Menu
|
static class JoystickMouseConfig extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.mouse_joystickmousespeed);
|
return p.getResources().getString(R.string.mouse_joystickmousespeed);
|
||||||
}
|
}
|
||||||
boolean enabled()
|
|
||||||
{
|
boolean enabled() {
|
||||||
return Globals.MoveMouseWithJoystick;
|
return Globals.MoveMouseWithJoystick;
|
||||||
};
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
;
|
||||||
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_medium),
|
||||||
p.getResources().getString(R.string.accel_fast) };
|
p.getResources().getString(R.string.accel_fast)};
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(R.string.mouse_joystickmousespeed);
|
builder.setTitle(R.string.mouse_joystickmousespeed);
|
||||||
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickSpeed, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickSpeed, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.MoveMouseWithJoystickSpeed = item;
|
Globals.MoveMouseWithJoystickSpeed = item;
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
showJoystickMouseAccelConfig(p);
|
showJoystickMouseAccelConfig(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -608,29 +541,24 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void showJoystickMouseAccelConfig(final MainActivity p)
|
static void showJoystickMouseAccelConfig(final MainActivity p) {
|
||||||
{
|
final CharSequence[] items = {p.getResources().getString(R.string.none),
|
||||||
final CharSequence[] items = { p.getResources().getString(R.string.none),
|
|
||||||
p.getResources().getString(R.string.accel_slow),
|
p.getResources().getString(R.string.accel_slow),
|
||||||
p.getResources().getString(R.string.accel_medium),
|
p.getResources().getString(R.string.accel_medium),
|
||||||
p.getResources().getString(R.string.accel_fast) };
|
p.getResources().getString(R.string.accel_fast)};
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||||
builder.setTitle(R.string.mouse_joystickmouseaccel);
|
builder.setTitle(R.string.mouse_joystickmouseaccel);
|
||||||
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickAccel, new DialogInterface.OnClickListener()
|
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickAccel, new DialogInterface.OnClickListener() {
|
||||||
{
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
public void onClick(DialogInterface dialog, int item)
|
|
||||||
{
|
|
||||||
Globals.MoveMouseWithJoystickAccel = item;
|
Globals.MoveMouseWithJoystickAccel = item;
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
{
|
public void onCancel(DialogInterface dialog) {
|
||||||
public void onCancel(DialogInterface dialog)
|
|
||||||
{
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -640,47 +568,44 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class TouchPressureMeasurementTool extends Menu
|
static class TouchPressureMeasurementTool extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.measurepressure);
|
return p.getResources().getString(R.string.measurepressure);
|
||||||
}
|
}
|
||||||
boolean enabled()
|
|
||||||
{
|
boolean enabled() {
|
||||||
return Globals.RightClickMethod == Mouse.RIGHT_CLICK_WITH_PRESSURE ||
|
return Globals.RightClickMethod == Mouse.RIGHT_CLICK_WITH_PRESSURE ||
|
||||||
Globals.LeftClickMethod == Mouse.LEFT_CLICK_WITH_PRESSURE;
|
Globals.LeftClickMethod == Mouse.LEFT_CLICK_WITH_PRESSURE;
|
||||||
};
|
}
|
||||||
void run (final MainActivity p)
|
|
||||||
{
|
;
|
||||||
|
|
||||||
|
void run(final MainActivity p) {
|
||||||
p.setText(p.getResources().getString(R.string.measurepressure_touchplease));
|
p.setText(p.getResources().getString(R.string.measurepressure_touchplease));
|
||||||
p.getVideoLayout().setOnTouchListener(new TouchMeasurementTool(p));
|
p.getVideoLayout().setOnTouchListener(new TouchMeasurementTool(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TouchMeasurementTool implements View.OnTouchListener
|
public static class TouchMeasurementTool implements View.OnTouchListener {
|
||||||
{
|
|
||||||
MainActivity p;
|
MainActivity p;
|
||||||
ArrayList<Integer> force = new ArrayList<Integer>();
|
ArrayList<Integer> force = new ArrayList<Integer>();
|
||||||
ArrayList<Integer> radius = new ArrayList<Integer>();
|
ArrayList<Integer> radius = new ArrayList<Integer>();
|
||||||
static final int maxEventAmount = 100;
|
static final int maxEventAmount = 100;
|
||||||
|
|
||||||
public TouchMeasurementTool(MainActivity _p)
|
public TouchMeasurementTool(MainActivity _p) {
|
||||||
{
|
|
||||||
p = _p;
|
p = _p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent ev)
|
public boolean onTouch(View v, MotionEvent ev) {
|
||||||
{
|
force.add(new Integer((int) (ev.getPressure() * 1000.0)));
|
||||||
force.add(new Integer((int)(ev.getPressure() * 1000.0)));
|
radius.add(new Integer((int) (ev.getSize() * 1000.0)));
|
||||||
radius.add(new Integer((int)(ev.getSize() * 1000.0)));
|
p.setText(p.getResources().getString(R.string.measurepressure_response, force.get(force.size() - 1), radius.get(radius.size() - 1)));
|
||||||
p.setText(p.getResources().getString(R.string.measurepressure_response, force.get(force.size()-1), radius.get(radius.size()-1)));
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(10L);
|
Thread.sleep(10L);
|
||||||
} catch (InterruptedException e) { }
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
|
||||||
if( force.size() >= maxEventAmount )
|
if (force.size() >= maxEventAmount) {
|
||||||
{
|
|
||||||
p.getVideoLayout().setOnTouchListener(null);
|
p.getVideoLayout().setOnTouchListener(null);
|
||||||
Globals.ClickScreenPressure = getAverageForce();
|
Globals.ClickScreenPressure = getAverageForce();
|
||||||
Globals.ClickScreenTouchspotSize = getAverageRadius();
|
Globals.ClickScreenTouchspotSize = getAverageRadius();
|
||||||
@ -690,20 +615,17 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getAverageForce()
|
int getAverageForce() {
|
||||||
{
|
|
||||||
int avg = 0;
|
int avg = 0;
|
||||||
for(Integer f: force)
|
for (Integer f : force) {
|
||||||
{
|
|
||||||
avg += f;
|
avg += f;
|
||||||
}
|
}
|
||||||
return avg / force.size();
|
return avg / force.size();
|
||||||
}
|
}
|
||||||
int getAverageRadius()
|
|
||||||
{
|
int getAverageRadius() {
|
||||||
int avg = 0;
|
int avg = 0;
|
||||||
for(Integer r: radius)
|
for (Integer r : radius) {
|
||||||
{
|
|
||||||
avg += r;
|
avg += r;
|
||||||
}
|
}
|
||||||
return avg / radius.size();
|
return avg / radius.size();
|
||||||
@ -711,15 +633,13 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class CalibrateTouchscreenMenu extends Menu
|
static class CalibrateTouchscreenMenu extends Menu {
|
||||||
{
|
String title(final MainActivity p) {
|
||||||
String title(final MainActivity p)
|
|
||||||
{
|
|
||||||
return p.getResources().getString(R.string.calibrate_touchscreen);
|
return p.getResources().getString(R.string.calibrate_touchscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
//boolean enabled() { return true; };
|
//boolean enabled() { return true; };
|
||||||
void run (final MainActivity p)
|
void run(final MainActivity p) {
|
||||||
{
|
|
||||||
p.setText(p.getResources().getString(R.string.calibrate_touchscreen_touch));
|
p.setText(p.getResources().getString(R.string.calibrate_touchscreen_touch));
|
||||||
Globals.TouchscreenCalibration[0] = 0;
|
Globals.TouchscreenCalibration[0] = 0;
|
||||||
Globals.TouchscreenCalibration[1] = 0;
|
Globals.TouchscreenCalibration[1] = 0;
|
||||||
@ -730,19 +650,17 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
p.getVideoLayout().setOnKeyListener(tool);
|
p.getVideoLayout().setOnKeyListener(tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ScreenEdgesCalibrationTool implements View.OnTouchListener, View.OnKeyListener
|
static class ScreenEdgesCalibrationTool implements View.OnTouchListener, View.OnKeyListener {
|
||||||
{
|
|
||||||
MainActivity p;
|
MainActivity p;
|
||||||
ImageView img;
|
ImageView img;
|
||||||
Bitmap bmp;
|
Bitmap bmp;
|
||||||
|
|
||||||
public ScreenEdgesCalibrationTool(MainActivity _p)
|
public ScreenEdgesCalibrationTool(MainActivity _p) {
|
||||||
{
|
|
||||||
p = _p;
|
p = _p;
|
||||||
img = new ImageView(p);
|
img = new ImageView(p);
|
||||||
img.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
img.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||||
img.setScaleType(ImageView.ScaleType.MATRIX);
|
img.setScaleType(ImageView.ScaleType.MATRIX);
|
||||||
bmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.calibrate );
|
bmp = BitmapFactory.decodeResource(p.getResources(), R.drawable.calibrate);
|
||||||
img.setImageBitmap(bmp);
|
img.setImageBitmap(bmp);
|
||||||
Matrix m = new Matrix();
|
Matrix m = new Matrix();
|
||||||
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
|
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
|
||||||
@ -754,25 +672,23 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent ev)
|
public boolean onTouch(View v, MotionEvent ev) {
|
||||||
{
|
if (Globals.TouchscreenCalibration[0] == Globals.TouchscreenCalibration[1] &&
|
||||||
if( Globals.TouchscreenCalibration[0] == Globals.TouchscreenCalibration[1] &&
|
|
||||||
Globals.TouchscreenCalibration[1] == Globals.TouchscreenCalibration[2] &&
|
Globals.TouchscreenCalibration[1] == Globals.TouchscreenCalibration[2] &&
|
||||||
Globals.TouchscreenCalibration[2] == Globals.TouchscreenCalibration[3] )
|
Globals.TouchscreenCalibration[2] == Globals.TouchscreenCalibration[3]) {
|
||||||
{
|
Globals.TouchscreenCalibration[0] = (int) ev.getX();
|
||||||
Globals.TouchscreenCalibration[0] = (int)ev.getX();
|
Globals.TouchscreenCalibration[1] = (int) ev.getY();
|
||||||
Globals.TouchscreenCalibration[1] = (int)ev.getY();
|
Globals.TouchscreenCalibration[2] = (int) ev.getX();
|
||||||
Globals.TouchscreenCalibration[2] = (int)ev.getX();
|
Globals.TouchscreenCalibration[3] = (int) ev.getY();
|
||||||
Globals.TouchscreenCalibration[3] = (int)ev.getY();
|
|
||||||
}
|
}
|
||||||
if( ev.getX() < Globals.TouchscreenCalibration[0] )
|
if (ev.getX() < Globals.TouchscreenCalibration[0])
|
||||||
Globals.TouchscreenCalibration[0] = (int)ev.getX();
|
Globals.TouchscreenCalibration[0] = (int) ev.getX();
|
||||||
if( ev.getY() < Globals.TouchscreenCalibration[1] )
|
if (ev.getY() < Globals.TouchscreenCalibration[1])
|
||||||
Globals.TouchscreenCalibration[1] = (int)ev.getY();
|
Globals.TouchscreenCalibration[1] = (int) ev.getY();
|
||||||
if( ev.getX() > Globals.TouchscreenCalibration[2] )
|
if (ev.getX() > Globals.TouchscreenCalibration[2])
|
||||||
Globals.TouchscreenCalibration[2] = (int)ev.getX();
|
Globals.TouchscreenCalibration[2] = (int) ev.getX();
|
||||||
if( ev.getY() > Globals.TouchscreenCalibration[3] )
|
if (ev.getY() > Globals.TouchscreenCalibration[3])
|
||||||
Globals.TouchscreenCalibration[3] = (int)ev.getY();
|
Globals.TouchscreenCalibration[3] = (int) ev.getY();
|
||||||
Matrix m = new Matrix();
|
Matrix m = new Matrix();
|
||||||
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
|
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
|
||||||
RectF dst = new RectF(Globals.TouchscreenCalibration[0], Globals.TouchscreenCalibration[1],
|
RectF dst = new RectF(Globals.TouchscreenCalibration[0], Globals.TouchscreenCalibration[1],
|
||||||
@ -783,8 +699,7 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKey(View v, int keyCode, KeyEvent event)
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||||
{
|
|
||||||
p.getVideoLayout().setOnTouchListener(null);
|
p.getVideoLayout().setOnTouchListener(null);
|
||||||
p.getVideoLayout().setOnKeyListener(null);
|
p.getVideoLayout().setOnKeyListener(null);
|
||||||
p.getVideoLayout().removeView(img);
|
p.getVideoLayout().removeView(img);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -22,11 +22,8 @@ freely, subject to the following restrictions:
|
|||||||
|
|
||||||
package io.neoterm;
|
package io.neoterm;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.EOFException;
|
import java.io.InputStream;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decompresses a .xz file in streamed mode (no seeking).
|
* Decompresses a .xz file in streamed mode (no seeking).
|
||||||
@ -34,8 +31,7 @@ import android.util.Log;
|
|||||||
* but using liblzma and JNI instead of Java, because Java heap
|
* but using liblzma and JNI instead of Java, because Java heap
|
||||||
* is very limited, and we're hitting memory limit on emulator.
|
* is very limited, and we're hitting memory limit on emulator.
|
||||||
*/
|
*/
|
||||||
public class XZInputStream extends InputStream
|
public class XZInputStream extends InputStream {
|
||||||
{
|
|
||||||
private long nativeData = 0;
|
private long nativeData = 0;
|
||||||
private InputStream in = null;
|
private InputStream in = null;
|
||||||
private final byte[] inBuf = new byte[8192];
|
private final byte[] inBuf = new byte[8192];
|
||||||
@ -46,36 +42,29 @@ public class XZInputStream extends InputStream
|
|||||||
|
|
||||||
private final byte[] tempBuf = new byte[1];
|
private final byte[] tempBuf = new byte[1];
|
||||||
|
|
||||||
public XZInputStream(InputStream in) throws IOException
|
public XZInputStream(InputStream in) throws IOException {
|
||||||
{
|
|
||||||
this.in = in;
|
this.in = in;
|
||||||
if (in == null)
|
if (in == null) {
|
||||||
{
|
|
||||||
throw new NullPointerException("InputStream == null");
|
throw new NullPointerException("InputStream == null");
|
||||||
}
|
}
|
||||||
nativeData = nativeInit();
|
nativeData = nativeInit();
|
||||||
if (nativeData == 0)
|
if (nativeData == 0) {
|
||||||
{
|
|
||||||
throw new OutOfMemoryError("Cannot initialize JNI liblzma object");
|
throw new OutOfMemoryError("Cannot initialize JNI liblzma object");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int available() throws IOException
|
public int available() throws IOException {
|
||||||
{
|
|
||||||
return 0; // Don't care
|
return 0; // Don't care
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException
|
public void close() throws IOException {
|
||||||
{
|
synchronized (this) {
|
||||||
synchronized (this)
|
|
||||||
{
|
|
||||||
if (nativeData != 0)
|
if (nativeData != 0)
|
||||||
nativeClose(nativeData);
|
nativeClose(nativeData);
|
||||||
nativeData = 0;
|
nativeData = 0;
|
||||||
if (in != null)
|
if (in != null) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
in.close();
|
in.close();
|
||||||
} finally {
|
} finally {
|
||||||
@ -86,8 +75,7 @@ public class XZInputStream extends InputStream
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void finalize() throws IOException
|
protected void finalize() throws IOException {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
close();
|
close();
|
||||||
} finally {
|
} finally {
|
||||||
@ -100,14 +88,12 @@ public class XZInputStream extends InputStream
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read() throws IOException
|
public int read() throws IOException {
|
||||||
{
|
|
||||||
return read(tempBuf, 0, 1) == -1 ? -1 : (tempBuf[0] & 0xFF);
|
return read(tempBuf, 0, 1) == -1 ? -1 : (tempBuf[0] & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read(byte[] outBuf, int outOffset, int outCount) throws IOException
|
public int read(byte[] outBuf, int outOffset, int outCount) throws IOException {
|
||||||
{
|
|
||||||
//Log.i("SDL", "XZInputStream.read: outOffset " + outOffset + " outCount " + outCount + " outBufEof " + outBufEof +
|
//Log.i("SDL", "XZInputStream.read: outOffset " + outOffset + " outCount " + outCount + " outBufEof " + outBufEof +
|
||||||
// " inOffset " + inOffset + " inAvailable " + inAvailable);
|
// " inOffset " + inOffset + " inAvailable " + inAvailable);
|
||||||
if (outBufEof)
|
if (outBufEof)
|
||||||
@ -117,8 +103,7 @@ public class XZInputStream extends InputStream
|
|||||||
|
|
||||||
int oldOutOffset = outOffset;
|
int oldOutOffset = outOffset;
|
||||||
|
|
||||||
if (inOffset >= inAvailable && inAvailable != -1)
|
if (inOffset >= inAvailable && inAvailable != -1) {
|
||||||
{
|
|
||||||
inAvailable = in.read(inBuf, 0, inBuf.length);
|
inAvailable = in.read(inBuf, 0, inBuf.length);
|
||||||
inOffset = 0;
|
inOffset = 0;
|
||||||
//Log.i("SDL", "XZInputStream.read: in.read: inOffset " + inOffset + " inAvailable " + inAvailable);
|
//Log.i("SDL", "XZInputStream.read: in.read: inOffset " + inOffset + " inAvailable " + inAvailable);
|
||||||
@ -132,10 +117,8 @@ public class XZInputStream extends InputStream
|
|||||||
//Log.i("SDL", "XZInputStream.read: nativeRead: outOffset " + outOffset + " outCount " + outCount + " outBufEof " + outBufEof +
|
//Log.i("SDL", "XZInputStream.read: nativeRead: outOffset " + outOffset + " outCount " + outCount + " outBufEof " + outBufEof +
|
||||||
// " inOffset " + inOffset + " inAvailable " + inAvailable + " ret " + ret);
|
// " inOffset " + inOffset + " inAvailable " + inAvailable + " ret " + ret);
|
||||||
|
|
||||||
if (ret != 0)
|
if (ret != 0) {
|
||||||
{
|
if (ret == 1) {
|
||||||
if (ret == 1)
|
|
||||||
{
|
|
||||||
if (inOffset < inAvailable)
|
if (inOffset < inAvailable)
|
||||||
throw new IOException("Garbage at the end of LZMA stream");
|
throw new IOException("Garbage at the end of LZMA stream");
|
||||||
if (inAvailable != -1)
|
if (inAvailable != -1)
|
||||||
@ -143,9 +126,7 @@ public class XZInputStream extends InputStream
|
|||||||
if (inAvailable != -1)
|
if (inAvailable != -1)
|
||||||
throw new IOException("Garbage at the end of LZMA stream");
|
throw new IOException("Garbage at the end of LZMA stream");
|
||||||
outBufEof = true;
|
outBufEof = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new IOException("LZMA error " + ret);
|
throw new IOException("LZMA error " + ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,7 +136,9 @@ public class XZInputStream extends InputStream
|
|||||||
}
|
}
|
||||||
|
|
||||||
private native long nativeInit();
|
private native long nativeInit();
|
||||||
|
|
||||||
private native void nativeClose(long nativeData);
|
private native void nativeClose(long nativeData);
|
||||||
|
|
||||||
private native int nativeRead(long nativeData, byte[] inBuf, int inAvailable, byte[] outBuf, int outCount, int[] offsets);
|
private native int nativeRead(long nativeData, byte[] inBuf, int inAvailable, byte[] outBuf, int outCount, int[] offsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package io.neoterm.xorg;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import io.neoterm.NeoGLView;
|
import io.neoterm.NeoGLView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<string name="download_unneeded">没有需要下载的内容</string>
|
<string name="download_unneeded">没有需要下载的内容</string>
|
||||||
<string name="connecting_to">正在连接到 %s</string>
|
<string name="connecting_to">正在连接到 %s</string>
|
||||||
<string name="failed_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="dl_from">正在从 %s 下载数据</string>
|
||||||
<string name="error_dl_from">从 %s 下载数据时出错</string>
|
<string name="error_dl_from">从 %s 下载数据时出错</string>
|
||||||
<string name="error_write">写入到 %s 时出错</string>
|
<string name="error_write">写入到 %s 时出错</string>
|
||||||
@ -189,7 +189,9 @@
|
|||||||
|
|
||||||
<!-- Play Game Services strings -->
|
<!-- Play Game Services strings -->
|
||||||
<string name="gamehelper_sign_in_failed">无法登录,请检查您的网络连接,然后重试。</string>
|
<string name="gamehelper_sign_in_failed">无法登录,请检查您的网络连接,然后重试。</string>
|
||||||
<string name="gamehelper_app_misconfigured">应用程序配置不正确。请检查包名和签名证书是否与开发者控制台中创建的客户端ID一致。此外,如果应用程序尚未发布,请检查您的帐户是否为测试人员帐户。详细信息,请参阅日志。</string>
|
<string name="gamehelper_app_misconfigured">
|
||||||
|
应用程序配置不正确。请检查包名和签名证书是否与开发者控制台中创建的客户端ID一致。此外,如果应用程序尚未发布,请检查您的帐户是否为测试人员帐户。详细信息,请参阅日志。
|
||||||
|
</string>
|
||||||
<string name="gamehelper_license_failed">许可证检查失败。</string>
|
<string name="gamehelper_license_failed">许可证检查失败。</string>
|
||||||
<string name="gamehelper_unknown_error">未知错误。</string>
|
<string name="gamehelper_unknown_error">未知错误。</string>
|
||||||
<string name="accessing_network">正在访问网络,请稍候</string>
|
<string name="accessing_network">正在访问网络,请稍候</string>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<item name="left" type="id" />
|
<item name="left" type="id"/>
|
||||||
<item name="right" type="id" />
|
<item name="right" type="id"/>
|
||||||
<item name="top" type="id" />
|
<item name="top" type="id"/>
|
||||||
<item name="bottom" type="id" />
|
<item name="bottom" type="id"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -151,7 +151,8 @@
|
|||||||
|
|
||||||
<string name="video">Video settings</string>
|
<string name="video">Video settings</string>
|
||||||
<string name="video_smooth">Linear video filtering</string>
|
<string name="video_smooth">Linear video filtering</string>
|
||||||
<string name="video_separatethread">Separate thread for video, it can increase FPS, it also can crash the app</string>
|
<string name="video_separatethread">Separate thread for video, it can increase FPS, it also can crash the app
|
||||||
|
</string>
|
||||||
<string name="video_orientation_vertical">Portrait/vertical screen orientation</string>
|
<string name="video_orientation_vertical">Portrait/vertical screen orientation</string>
|
||||||
<string name="video_orientation_autodetect">Auto-detect screen orientation</string>
|
<string name="video_orientation_autodetect">Auto-detect screen orientation</string>
|
||||||
<string name="video_bpp_24">24 bpp screen color depth</string>
|
<string name="video_bpp_24">24 bpp screen color depth</string>
|
||||||
@ -190,8 +191,13 @@
|
|||||||
<string name="no">No</string>
|
<string name="no">No</string>
|
||||||
|
|
||||||
<!-- Play Game Services strings -->
|
<!-- Play Game Services strings -->
|
||||||
<string name="gamehelper_sign_in_failed">Failed to sign in. Please check your network connection and try again.</string>
|
<string name="gamehelper_sign_in_failed">Failed to sign in. Please check your network connection and try again.
|
||||||
<string name="gamehelper_app_misconfigured">The application is incorrectly configured. Check that the package name and signing certificate match the client ID created in Developer Console. Also, if the application is not yet published, check that the account you are trying to sign in with is listed as a tester account. See logs for more information.</string>
|
</string>
|
||||||
|
<string name="gamehelper_app_misconfigured">The application is incorrectly configured. Check that the package name
|
||||||
|
and signing certificate match the client ID created in Developer Console. Also, if the application is not yet
|
||||||
|
published, check that the account you are trying to sign in with is listed as a tester account. See logs for
|
||||||
|
more information.
|
||||||
|
</string>
|
||||||
<string name="gamehelper_license_failed">License check failed.</string>
|
<string name="gamehelper_license_failed">License check failed.</string>
|
||||||
<string name="gamehelper_unknown_error">Unknown error.</string>
|
<string name="gamehelper_unknown_error">Unknown error.</string>
|
||||||
<string name="accessing_network">Accessing network, please wait</string>
|
<string name="accessing_network">Accessing network, please wait</string>
|
||||||
|
@ -1,49 +1,50 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Keyboard android:keyWidth="10.000002%p" android:keyHeight="10.000002%p" android:horizontalGap="0.0px" android:verticalGap="0.0px"
|
<Keyboard android:keyWidth="10.000002%p" android:keyHeight="10.000002%p" android:horizontalGap="0.0px"
|
||||||
|
android:verticalGap="0.0px"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<Row>
|
<Row>
|
||||||
<Key android:codes="45" android:keyEdgeFlags="left" android:keyLabel="q" />
|
<Key android:codes="45" android:keyEdgeFlags="left" android:keyLabel="q"/>
|
||||||
<Key android:codes="51" android:keyLabel="w" />
|
<Key android:codes="51" android:keyLabel="w"/>
|
||||||
<Key android:codes="33" android:keyLabel="e" />
|
<Key android:codes="33" android:keyLabel="e"/>
|
||||||
<Key android:codes="46" android:keyLabel="r" />
|
<Key android:codes="46" android:keyLabel="r"/>
|
||||||
<Key android:codes="48" android:keyLabel="t" />
|
<Key android:codes="48" android:keyLabel="t"/>
|
||||||
<Key android:codes="53" android:keyLabel="y" />
|
<Key android:codes="53" android:keyLabel="y"/>
|
||||||
<Key android:codes="49" android:keyLabel="u" />
|
<Key android:codes="49" android:keyLabel="u"/>
|
||||||
<Key android:codes="37" android:keyLabel="i" />
|
<Key android:codes="37" android:keyLabel="i"/>
|
||||||
<Key android:codes="43" android:keyLabel="o" />
|
<Key android:codes="43" android:keyLabel="o"/>
|
||||||
<Key android:codes="44" android:keyEdgeFlags="right" android:keyLabel="p" />
|
<Key android:codes="44" android:keyEdgeFlags="right" android:keyLabel="p"/>
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
<Key android:codes="29" android:keyEdgeFlags="left" android:keyLabel="a" />
|
<Key android:codes="29" android:keyEdgeFlags="left" android:keyLabel="a"/>
|
||||||
<Key android:codes="47" android:keyLabel="s" />
|
<Key android:codes="47" android:keyLabel="s"/>
|
||||||
<Key android:codes="32" android:keyLabel="d" />
|
<Key android:codes="32" android:keyLabel="d"/>
|
||||||
<Key android:codes="34" android:keyLabel="f" />
|
<Key android:codes="34" android:keyLabel="f"/>
|
||||||
<Key android:codes="35" android:keyLabel="g" />
|
<Key android:codes="35" android:keyLabel="g"/>
|
||||||
<Key android:codes="36" android:keyLabel="h" />
|
<Key android:codes="36" android:keyLabel="h"/>
|
||||||
<Key android:codes="38" android:keyLabel="j" />
|
<Key android:codes="38" android:keyLabel="j"/>
|
||||||
<Key android:codes="39" android:keyLabel="k" />
|
<Key android:codes="39" android:keyLabel="k"/>
|
||||||
<Key android:codes="40" android:keyLabel="l" />
|
<Key android:codes="40" android:keyLabel="l"/>
|
||||||
<Key android:codes="74" android:keyEdgeFlags="right" android:keyLabel=";" />
|
<Key android:codes="74" android:keyEdgeFlags="right" android:keyLabel=";"/>
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
<Key android:codes="-1" android:keyEdgeFlags="left" android:keyLabel="⇪" />
|
<Key android:codes="-1" android:keyEdgeFlags="left" android:keyLabel="⇪"/>
|
||||||
<Key android:codes="54" android:keyLabel="z" />
|
<Key android:codes="54" android:keyLabel="z"/>
|
||||||
<Key android:codes="52" android:keyLabel="x" />
|
<Key android:codes="52" android:keyLabel="x"/>
|
||||||
<Key android:codes="31" android:keyLabel="c" />
|
<Key android:codes="31" android:keyLabel="c"/>
|
||||||
<Key android:codes="50" android:keyLabel="v" />
|
<Key android:codes="50" android:keyLabel="v"/>
|
||||||
<Key android:codes="30" android:keyLabel="b" />
|
<Key android:codes="30" android:keyLabel="b"/>
|
||||||
<Key android:codes="42" android:keyLabel="n" />
|
<Key android:codes="42" android:keyLabel="n"/>
|
||||||
<Key android:codes="41" android:keyLabel="m" />
|
<Key android:codes="41" android:keyLabel="m"/>
|
||||||
<Key android:keyWidth="20.000004%p" android:codes="67" android:keyEdgeFlags="right" android:keyLabel="≪ ×" />
|
<Key android:keyWidth="20.000004%p" android:codes="67" android:keyEdgeFlags="right" android:keyLabel="≪ ×"/>
|
||||||
</Row>
|
</Row>
|
||||||
<Row android:rowEdgeFlags="bottom">
|
<Row android:rowEdgeFlags="bottom">
|
||||||
<Key android:codes="-6" android:keyEdgeFlags="left" android:keyLabel="123…" />
|
<Key android:codes="-6" android:keyEdgeFlags="left" android:keyLabel="123…"/>
|
||||||
<Key android:codes="71" android:keyLabel="[" />
|
<Key android:codes="71" android:keyLabel="["/>
|
||||||
<Key android:codes="72" android:keyLabel="]" />
|
<Key android:codes="72" android:keyLabel="]"/>
|
||||||
<Key android:codes="76" android:keyLabel="/" />
|
<Key android:codes="76" android:keyLabel="/"/>
|
||||||
<Key android:keyWidth="20.000004%p" android:codes="62" android:keyLabel="Space" />
|
<Key android:keyWidth="20.000004%p" android:codes="62" android:keyLabel="Space"/>
|
||||||
<Key android:codes="55" android:keyLabel="," />
|
<Key android:codes="55" android:keyLabel=","/>
|
||||||
<Key android:codes="56" 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:keyWidth="20.000004%p" android:codes="66" android:keyEdgeFlags="right" android:keyLabel="Enter"/>
|
||||||
</Row>
|
</Row>
|
||||||
</Keyboard>
|
</Keyboard>
|
@ -28,7 +28,7 @@
|
|||||||
<Key android:codes="92" android:keyLabel="PgUp"/>
|
<Key android:codes="92" android:keyLabel="PgUp"/>
|
||||||
<Key android:codes="122" android:keyLabel="Home"/>
|
<Key android:codes="122" android:keyLabel="Home"/>
|
||||||
<Key android:codes="19" android:keyLabel="↑"/>
|
<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>
|
||||||
<Row>
|
<Row>
|
||||||
<Key android:codes="-1" android:keyLabel="!@#…" android:keyEdgeFlags="left"/>
|
<Key android:codes="-1" android:keyLabel="!@#…" android:keyEdgeFlags="left"/>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<Key android:codes="131" android:keyLabel="F1"/>
|
<Key android:codes="131" android:keyLabel="F1"/>
|
||||||
<Key android:codes="132" android:keyLabel="F2"/>
|
<Key android:codes="132" android:keyLabel="F2"/>
|
||||||
<Key android:codes="133" android:keyLabel="F3"/>
|
<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>
|
||||||
<Row>
|
<Row>
|
||||||
<Key android:codes="-1" android:keyLabel="123…" android:keyEdgeFlags="left"/>
|
<Key android:codes="-1" android:keyLabel="123…" android:keyEdgeFlags="left"/>
|
||||||
@ -49,7 +49,7 @@
|
|||||||
<Key android:codes="156" android:keyLabel="Kp -"/>
|
<Key android:codes="156" android:keyLabel="Kp -"/>
|
||||||
<Key android:codes="157" android:keyLabel="Kp +"/>
|
<Key android:codes="157" android:keyLabel="Kp +"/>
|
||||||
<Key android:codes="160" 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="140" android:keyLabel="F10"/>
|
||||||
<Key android:codes="141" android:keyLabel="F11"/>
|
<Key android:codes="141" android:keyLabel="F11"/>
|
||||||
<Key android:codes="142" android:keyLabel="F12" android:keyEdgeFlags="right"/>
|
<Key android:codes="142" android:keyLabel="F12" android:keyEdgeFlags="right"/>
|
||||||
|
@ -7,16 +7,16 @@
|
|||||||
android:keyHeight="10%p">
|
android:keyHeight="10%p">
|
||||||
<Row>
|
<Row>
|
||||||
<Key android:codes="111" android:keyLabel="ESC" android:keyEdgeFlags="left"/>
|
<Key android:codes="111" android:keyLabel="ESC" android:keyEdgeFlags="left"/>
|
||||||
<Key android:codes="131" android:keyLabel="F1" />
|
<Key android:codes="131" android:keyLabel="F1"/>
|
||||||
<Key android:codes="132" android:keyLabel="F2" />
|
<Key android:codes="132" android:keyLabel="F2"/>
|
||||||
<Key android:codes="133" android:keyLabel="F3" />
|
<Key android:codes="133" android:keyLabel="F3"/>
|
||||||
<Key android:codes="134" android:keyLabel="F4" />
|
<Key android:codes="134" android:keyLabel="F4"/>
|
||||||
<Key android:codes="135" android:keyLabel="F5" />
|
<Key android:codes="135" android:keyLabel="F5"/>
|
||||||
<Key android:codes="136" android:keyLabel="F6" />
|
<Key android:codes="136" android:keyLabel="F6"/>
|
||||||
<Key android:codes="137" android:keyLabel="F7" />
|
<Key android:codes="137" android:keyLabel="F7"/>
|
||||||
<Key android:codes="138" android:keyLabel="F8" />
|
<Key android:codes="138" android:keyLabel="F8"/>
|
||||||
<Key android:codes="139" android:keyLabel="F9" />
|
<Key android:codes="139" android:keyLabel="F9"/>
|
||||||
<Key android:codes="140" android:keyLabel="F10" />
|
<Key android:codes="140" android:keyLabel="F10"/>
|
||||||
<Key android:codes="124" android:keyLabel="HELP" android:keyEdgeFlags="right"/>
|
<Key android:codes="124" android:keyLabel="HELP" android:keyEdgeFlags="right"/>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
@ -78,10 +78,10 @@
|
|||||||
</Row>
|
</Row>
|
||||||
<Row android:rowEdgeFlags="bottom">
|
<Row android:rowEdgeFlags="bottom">
|
||||||
<Key android:codes="57" android:keyLabel="ALT" android:keyEdgeFlags="left"/>
|
<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="73" android:keyLabel="\\"/>
|
||||||
<Key android:codes="69" 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="70" android:keyLabel="="/>
|
||||||
<Key android:codes="71" android:keyLabel="["/>
|
<Key android:codes="71" android:keyLabel="["/>
|
||||||
<Key android:codes="72" android:keyLabel="]"/>
|
<Key android:codes="72" android:keyLabel="]"/>
|
||||||
|
@ -38,7 +38,8 @@
|
|||||||
<Key android:codes="30" android:keyLabel="B" android:isRepeatable="true"/>
|
<Key android:codes="30" android:keyLabel="B" android:isRepeatable="true"/>
|
||||||
<Key android:codes="42" android:keyLabel="N" android:isRepeatable="true"/>
|
<Key android:codes="42" android:keyLabel="N" android:isRepeatable="true"/>
|
||||||
<Key android:codes="41" android:keyLabel="M" android:isRepeatable="true"/>
|
<Key android:codes="41" android:keyLabel="M" android:isRepeatable="true"/>
|
||||||
<Key android:codes="67" android:keyLabel="≪ ×" android:keyWidth="20%p" android:keyEdgeFlags="right" android:isRepeatable="true"/>
|
<Key android:codes="67" android:keyLabel="≪ ×" android:keyWidth="20%p" android:keyEdgeFlags="right"
|
||||||
|
android:isRepeatable="true"/>
|
||||||
</Row>
|
</Row>
|
||||||
<Row android:rowEdgeFlags="bottom">
|
<Row android:rowEdgeFlags="bottom">
|
||||||
<Key android:codes="-6" android:keyLabel="!@#…" android:keyEdgeFlags="left" android:isRepeatable="true"/>
|
<Key android:codes="-6" android:keyLabel="!@#…" android:keyEdgeFlags="left" android:isRepeatable="true"/>
|
||||||
@ -48,6 +49,7 @@
|
|||||||
<Key android:codes="62" android:keyLabel="Space" android:keyWidth="20%p" android:isRepeatable="true"/>
|
<Key android:codes="62" android:keyLabel="Space" android:keyWidth="20%p" android:isRepeatable="true"/>
|
||||||
<Key android:codes="55" android:keyLabel="<" android:isRepeatable="true"/>
|
<Key android:codes="55" android:keyLabel="<" android:isRepeatable="true"/>
|
||||||
<Key android:codes="56" android:keyLabel=">" android:isRepeatable="true"/>
|
<Key android:codes="56" android:keyLabel=">" android:isRepeatable="true"/>
|
||||||
<Key android:codes="66" android:keyLabel="Enter" android:keyWidth="20%p" android:keyEdgeFlags="right" android:isRepeatable="true"/>
|
<Key android:codes="66" android:keyLabel="Enter" android:keyWidth="20%p" android:keyEdgeFlags="right"
|
||||||
|
android:isRepeatable="true"/>
|
||||||
</Row>
|
</Row>
|
||||||
</Keyboard>
|
</Keyboard>
|
||||||
|
@ -7,12 +7,12 @@
|
|||||||
android:keyHeight="10%p">
|
android:keyHeight="10%p">
|
||||||
<Row>
|
<Row>
|
||||||
<Key android:codes="111" android:keyLabel="Esc" android:keyEdgeFlags="left"/>
|
<Key android:codes="111" android:keyLabel="Esc" android:keyEdgeFlags="left"/>
|
||||||
<Key android:codes="122" android:keyLabel="Clear" />
|
<Key android:codes="122" android:keyLabel="Clear"/>
|
||||||
<Key android:codes="124" android:keyLabel="Insert" />
|
<Key android:codes="124" android:keyLabel="Insert"/>
|
||||||
<Key android:codes="123" android:keyLabel="Help" />
|
<Key android:codes="123" android:keyLabel="Help"/>
|
||||||
<Key android:codes="129" android:keyLabel="Start" />
|
<Key android:codes="129" android:keyLabel="Start"/>
|
||||||
<Key android:codes="128" android:keyLabel="Select" />
|
<Key android:codes="128" android:keyLabel="Select"/>
|
||||||
<Key android:codes="127" android:keyLabel="Option" />
|
<Key android:codes="127" android:keyLabel="Option"/>
|
||||||
<Key android:codes="130" android:keyLabel="Reset" android:keyEdgeFlags="right"/>
|
<Key android:codes="130" android:keyLabel="Reset" android:keyEdgeFlags="right"/>
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
@ -76,7 +76,7 @@
|
|||||||
<Key android:codes="69" android:keyLabel="-"/>
|
<Key android:codes="69" android:keyLabel="-"/>
|
||||||
<Key android:codes="81" android:keyLabel="+"/>
|
<Key android:codes="81" android:keyLabel="+"/>
|
||||||
<Key android:codes="70" 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="71" android:keyLabel="["/>
|
||||||
<Key android:codes="72" android:keyLabel="]"/>
|
<Key android:codes="72" android:keyLabel="]"/>
|
||||||
<Key android:codes="18" android:keyLabel="#"/>
|
<Key android:codes="18" android:keyLabel="#"/>
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
android:keyHeight="10%p">
|
android:keyHeight="10%p">
|
||||||
<Row>
|
<Row>
|
||||||
<Key android:codes="113" android:keyLabel="C=" android:keyEdgeFlags="left"/>
|
<Key android:codes="113" android:keyLabel="C=" android:keyEdgeFlags="left"/>
|
||||||
<Key android:codes="111" android:keyLabel="RS" />
|
<Key android:codes="111" android:keyLabel="RS"/>
|
||||||
<Key android:codes="5" android:keyLabel="CTRL" />
|
<Key android:codes="5" android:keyLabel="CTRL"/>
|
||||||
<Key android:codes="126" android:keyLabel="F1" />
|
<Key android:codes="126" android:keyLabel="F1"/>
|
||||||
<Key android:codes="103" android:keyLabel="F3" />
|
<Key android:codes="103" android:keyLabel="F3"/>
|
||||||
<Key android:codes="104" android:keyLabel="F5" />
|
<Key android:codes="104" android:keyLabel="F5"/>
|
||||||
<Key android:codes="105" android:keyLabel="F7" />
|
<Key android:codes="105" android:keyLabel="F7"/>
|
||||||
<Key android:codes="3" android:keyLabel="Home" />
|
<Key android:codes="3" android:keyLabel="Home"/>
|
||||||
<Key android:codes="71" android:keyLabel="\@" />
|
<Key android:codes="71" android:keyLabel="\@"/>
|
||||||
<Key android:codes="67" android:keyLabel="DEL" android:keyEdgeFlags="right"/>
|
<Key android:codes="67" android:keyLabel="DEL" android:keyEdgeFlags="right"/>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
@ -28,8 +28,8 @@
|
|||||||
<Key android:codes="14" android:keyLabel="7"/>
|
<Key android:codes="14" android:keyLabel="7"/>
|
||||||
<Key android:codes="15" android:keyLabel="8"/>
|
<Key android:codes="15" android:keyLabel="8"/>
|
||||||
<Key android:codes="16" android:keyLabel="9"/>
|
<Key android:codes="16" android:keyLabel="9"/>
|
||||||
<Key android:codes="7" android:keyLabel="0" />
|
<Key android:codes="7" android:keyLabel="0"/>
|
||||||
<Key android:codes="69" android:keyLabel="+" />
|
<Key android:codes="69" android:keyLabel="+"/>
|
||||||
<Key android:codes="70" android:keyLabel="-" android:keyEdgeFlags="right"/>
|
<Key android:codes="70" android:keyLabel="-" android:keyEdgeFlags="right"/>
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
|
@ -38,7 +38,8 @@
|
|||||||
<Key android:codes="30" android:keyLabel="b" android:isRepeatable="true"/>
|
<Key android:codes="30" android:keyLabel="b" android:isRepeatable="true"/>
|
||||||
<Key android:codes="42" android:keyLabel="n" android:isRepeatable="true"/>
|
<Key android:codes="42" android:keyLabel="n" android:isRepeatable="true"/>
|
||||||
<Key android:codes="41" android:keyLabel="m" android:isRepeatable="true"/>
|
<Key android:codes="41" android:keyLabel="m" android:isRepeatable="true"/>
|
||||||
<Key android:codes="67" android:keyLabel="≪ ×" android:keyWidth="20%p" android:keyEdgeFlags="right" android:isRepeatable="true"/>
|
<Key android:codes="67" android:keyLabel="≪ ×" android:keyWidth="20%p" android:keyEdgeFlags="right"
|
||||||
|
android:isRepeatable="true"/>
|
||||||
</Row>
|
</Row>
|
||||||
<Row android:rowEdgeFlags="bottom">
|
<Row android:rowEdgeFlags="bottom">
|
||||||
<Key android:codes="-6" android:keyLabel="123…" android:keyEdgeFlags="left"/>
|
<Key android:codes="-6" android:keyLabel="123…" android:keyEdgeFlags="left"/>
|
||||||
@ -48,6 +49,7 @@
|
|||||||
<Key android:codes="62" android:keyLabel="Space" android:keyWidth="20%p" android:isRepeatable="true"/>
|
<Key android:codes="62" android:keyLabel="Space" android:keyWidth="20%p" android:isRepeatable="true"/>
|
||||||
<Key android:codes="55" android:keyLabel="," android:isRepeatable="true"/>
|
<Key android:codes="55" android:keyLabel="," android:isRepeatable="true"/>
|
||||||
<Key android:codes="56" android:keyLabel="." android:isRepeatable="true"/>
|
<Key android:codes="56" android:keyLabel="." android:isRepeatable="true"/>
|
||||||
<Key android:codes="66" android:keyLabel="Enter" android:keyWidth="20%p" android:keyEdgeFlags="right" android:isRepeatable="true"/>
|
<Key android:codes="66" android:keyLabel="Enter" android:keyWidth="20%p" android:keyEdgeFlags="right"
|
||||||
|
android:isRepeatable="true"/>
|
||||||
</Row>
|
</Row>
|
||||||
</Keyboard>
|
</Keyboard>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<Key android:codes="92" android:keyLabel="PgUp" android:isRepeatable="true"/>
|
<Key android:codes="92" android:keyLabel="PgUp" android:isRepeatable="true"/>
|
||||||
<Key android:codes="122" android:keyLabel="Home" 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="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>
|
||||||
<Row>
|
<Row>
|
||||||
<Key android:codes="-1" android:keyLabel="!@#…" android:keyEdgeFlags="left"/>
|
<Key android:codes="-1" android:keyLabel="!@#…" android:keyEdgeFlags="left"/>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<Key android:codes="131" android:keyLabel="F1" android:isRepeatable="true"/>
|
<Key android:codes="131" android:keyLabel="F1" android:isRepeatable="true"/>
|
||||||
<Key android:codes="132" android:keyLabel="F2" 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="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>
|
||||||
<Row>
|
<Row>
|
||||||
<Key android:codes="-1" android:keyLabel="123…" android:keyEdgeFlags="left"/>
|
<Key android:codes="-1" android:keyLabel="123…" android:keyEdgeFlags="left"/>
|
||||||
|
@ -38,7 +38,8 @@
|
|||||||
<Key android:codes="30" android:keyLabel="B" android:isRepeatable="true"/>
|
<Key android:codes="30" android:keyLabel="B" android:isRepeatable="true"/>
|
||||||
<Key android:codes="42" android:keyLabel="N" android:isRepeatable="true"/>
|
<Key android:codes="42" android:keyLabel="N" android:isRepeatable="true"/>
|
||||||
<Key android:codes="41" android:keyLabel="M" android:isRepeatable="true"/>
|
<Key android:codes="41" android:keyLabel="M" android:isRepeatable="true"/>
|
||||||
<Key android:codes="67" android:keyLabel="≪ ×" android:keyWidth="20%p" android:keyEdgeFlags="right" android:isRepeatable="true"/>
|
<Key android:codes="67" android:keyLabel="≪ ×" android:keyWidth="20%p" android:keyEdgeFlags="right"
|
||||||
|
android:isRepeatable="true"/>
|
||||||
</Row>
|
</Row>
|
||||||
<Row android:rowEdgeFlags="bottom">
|
<Row android:rowEdgeFlags="bottom">
|
||||||
<Key android:codes="-6" android:keyLabel="!@#…" android:keyEdgeFlags="left"/>
|
<Key android:codes="-6" android:keyLabel="!@#…" android:keyEdgeFlags="left"/>
|
||||||
@ -48,6 +49,7 @@
|
|||||||
<Key android:codes="62" android:keyLabel="Space" android:keyWidth="20%p" android:isRepeatable="true"/>
|
<Key android:codes="62" android:keyLabel="Space" android:keyWidth="20%p" android:isRepeatable="true"/>
|
||||||
<Key android:codes="55" android:keyLabel="<" android:isRepeatable="true"/>
|
<Key android:codes="55" android:keyLabel="<" android:isRepeatable="true"/>
|
||||||
<Key android:codes="56" android:keyLabel=">" android:isRepeatable="true"/>
|
<Key android:codes="56" android:keyLabel=">" android:isRepeatable="true"/>
|
||||||
<Key android:codes="66" android:keyLabel="Enter" android:keyWidth="20%p" android:keyEdgeFlags="right" android:isRepeatable="true"/>
|
<Key android:codes="66" android:keyLabel="Enter" android:keyWidth="20%p" android:keyEdgeFlags="right"
|
||||||
|
android:isRepeatable="true"/>
|
||||||
</Row>
|
</Row>
|
||||||
</Keyboard>
|
</Keyboard>
|
||||||
|
@ -2,7 +2,7 @@ package io.neoterm;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Example local unit test, which will execute on the development machine (host).
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
|
@ -4,18 +4,18 @@
|
|||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.touchscreen"
|
android:name="android.hardware.touchscreen"
|
||||||
android:required="false" />
|
android:required="false"/>
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.software.leanback"
|
android:name="android.software.leanback"
|
||||||
android:required="false" />
|
android:required="false"/>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
<uses-permission android:name="android.permission.READ_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.WAKE_LOCK"/>
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".App"
|
android:name=".App"
|
||||||
@ -37,28 +37,28 @@
|
|||||||
android:theme="@style/AppTheme.NoActionBar.Dark"
|
android:theme="@style/AppTheme.NoActionBar.Dark"
|
||||||
android:windowSoftInputMode="adjustResize|stateHidden">
|
android:windowSoftInputMode="adjustResize|stateHidden">
|
||||||
<intent-filter>
|
<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>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
|
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.app.shortcuts"
|
android:name="android.app.shortcuts"
|
||||||
android:resource="@xml/app_shortcuts" />
|
android:resource="@xml/app_shortcuts"/>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity-alias
|
<activity-alias
|
||||||
android:name=".NeoLotMainActivity"
|
android:name=".NeoLotMainActivity"
|
||||||
android:targetActivity="io.neoterm.ui.term.NeoTermActivity">
|
android:targetActivity="io.neoterm.ui.term.NeoTermActivity">
|
||||||
<intent-filter>
|
<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.IOT_LAUNCHER"/>
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity-alias>
|
</activity-alias>
|
||||||
|
|
||||||
@ -69,7 +69,7 @@
|
|||||||
android:theme="@style/AppTheme.Dark"
|
android:theme="@style/AppTheme.Dark"
|
||||||
android:windowSoftInputMode="adjustResize|stateHidden">
|
android:windowSoftInputMode="adjustResize|stateHidden">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
@ -79,11 +79,11 @@
|
|||||||
android:label="@string/term_here"
|
android:label="@string/term_here"
|
||||||
android:targetActivity=".ui.term.NeoTermRemoteInterface">
|
android:targetActivity=".ui.term.NeoTermRemoteInterface">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEND" />
|
<action android:name="android.intent.action.SEND"/>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
|
||||||
<data android:mimeType="*/*" />
|
<data android:mimeType="*/*"/>
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity-alias>
|
</activity-alias>
|
||||||
|
|
||||||
@ -93,34 +93,34 @@
|
|||||||
android:label="@string/user_script"
|
android:label="@string/user_script"
|
||||||
android:targetActivity=".ui.term.NeoTermRemoteInterface">
|
android:targetActivity=".ui.term.NeoTermRemoteInterface">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEND" />
|
<action android:name="android.intent.action.SEND"/>
|
||||||
<action android:name="android.intent.action.SEND_MULTIPLE" />
|
<action android:name="android.intent.action.SEND_MULTIPLE"/>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
|
||||||
<data android:mimeType="*/*" />
|
<data android:mimeType="*/*"/>
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<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.VIEW"/>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
|
||||||
<data android:mimeType="*/*" />
|
<data android:mimeType="*/*"/>
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<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.BROWSABLE"/>
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
|
||||||
<data android:scheme="http" />
|
<data android:scheme="http"/>
|
||||||
<data android:scheme="https" />
|
<data android:scheme="https"/>
|
||||||
<data android:scheme="ftp" />
|
<data android:scheme="ftp"/>
|
||||||
<data android:mimeType="application/*" />
|
<data android:mimeType="application/*"/>
|
||||||
<data android:mimeType="audio/*" />
|
<data android:mimeType="audio/*"/>
|
||||||
<data android:mimeType="video/*" />
|
<data android:mimeType="video/*"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity-alias>
|
</activity-alias>
|
||||||
|
|
||||||
@ -128,67 +128,67 @@
|
|||||||
android:name=".ui.support.AboutActivity"
|
android:name=".ui.support.AboutActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/about"
|
android:label="@string/about"
|
||||||
android:theme="@style/AppTheme.NoActionBar.Dark" />
|
android:theme="@style/AppTheme.NoActionBar.Dark"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.crash.CrashActivity"
|
android:name=".ui.crash.CrashActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/error"
|
android:label="@string/error"
|
||||||
android:theme="@style/AppTheme.NoActionBar.Dark" />
|
android:theme="@style/AppTheme.NoActionBar.Dark"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.setup.SetupActivity"
|
android:name=".ui.setup.SetupActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:theme="@style/AppTheme.NoActionBar" />
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.bonus.BonusActivity"
|
android:name=".ui.bonus.BonusActivity"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/AppTheme.NoActionBar.Dark" />
|
android:theme="@style/AppTheme.NoActionBar.Dark"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.pm.PackageManagerActivity"
|
android:name=".ui.pm.PackageManagerActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/package_settings"
|
android:label="@string/package_settings"
|
||||||
android:theme="@style/AppTheme.NoActionBar.Dark" />
|
android:theme="@style/AppTheme.NoActionBar.Dark"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.customize.CustomizeActivity"
|
android:name=".ui.customize.CustomizeActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/customization_settings"
|
android:label="@string/customization_settings"
|
||||||
android:theme="@style/AppTheme.NoActionBar.Dark" />
|
android:theme="@style/AppTheme.NoActionBar.Dark"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.customize.ColorSchemeActivity"
|
android:name=".ui.customize.ColorSchemeActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/pref_customization_color_scheme"
|
android:label="@string/pref_customization_color_scheme"
|
||||||
android:theme="@style/AppTheme.NoActionBar.Dark" />
|
android:theme="@style/AppTheme.NoActionBar.Dark"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.support.HelpActivity"
|
android:name=".ui.support.HelpActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/faq"
|
android:label="@string/faq"
|
||||||
android:theme="@style/AppTheme.NoActionBar.Dark" />
|
android:theme="@style/AppTheme.NoActionBar.Dark"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.settings.SettingActivity"
|
android:name=".ui.settings.SettingActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/AppTheme.Dark" />
|
android:theme="@style/AppTheme.Dark"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.settings.GeneralSettingsActivity"
|
android:name=".ui.settings.GeneralSettingsActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/AppTheme.Dark" />
|
android:theme="@style/AppTheme.Dark"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.settings.UISettingsActivity"
|
android:name=".ui.settings.UISettingsActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/AppTheme.Dark" />
|
android:theme="@style/AppTheme.Dark"/>
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".services.NeoTermService"
|
android:name=".services.NeoTermService"
|
||||||
android:enabled="true" />
|
android:enabled="true"/>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.sec.android.support.multiwindow"
|
android:name="com.sec.android.support.multiwindow"
|
||||||
android:value="true" />
|
android:value="true"/>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.lge.support.SPLIT_WINDOW"
|
android:name="com.lge.support.SPLIT_WINDOW"
|
||||||
android:value="true" />
|
android:value="true"/>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -1,6 +1,8 @@
|
|||||||
package io.neoterm.backend;
|
package io.neoterm.backend;
|
||||||
|
|
||||||
/** A circular byte buffer allowing one producer and one consumer thread. */
|
/**
|
||||||
|
* A circular byte buffer allowing one producer and one consumer thread.
|
||||||
|
*/
|
||||||
final class ByteQueue {
|
final class ByteQueue {
|
||||||
|
|
||||||
private final byte[] mBuffer;
|
private final byte[] mBuffer;
|
||||||
|
@ -4,7 +4,9 @@ import android.util.Log;
|
|||||||
|
|
||||||
public final class EmulatorDebug {
|
public final class EmulatorDebug {
|
||||||
|
|
||||||
/** The tag to use with {@link Log}. */
|
/**
|
||||||
|
* The tag to use with {@link Log}.
|
||||||
|
*/
|
||||||
public static final String LOG_TAG = "NeoTerm-Emulator";
|
public static final String LOG_TAG = "NeoTerm-Emulator";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,9 @@ final class JNI {
|
|||||||
*/
|
*/
|
||||||
public static native int createSubprocess(String cmd, String cwd, String[] args, String[] envVars, int[] processId, int rows, int columns);
|
public static native int createSubprocess(String cmd, String cwd, String[] args, String[] envVars, int[] processId, int rows, int columns);
|
||||||
|
|
||||||
/** Set the window size for a given pty, which allows connected programs to learn how large their screen is. */
|
/**
|
||||||
|
* Set the window size for a given pty, which allows connected programs to learn how large their screen is.
|
||||||
|
*/
|
||||||
public static native void setPtyWindowSize(int fd, int rows, int cols);
|
public static native void setPtyWindowSize(int fd, int rows, int cols);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,7 +37,9 @@ final class JNI {
|
|||||||
*/
|
*/
|
||||||
public static native int waitFor(int processId);
|
public static native int waitFor(int processId);
|
||||||
|
|
||||||
/** Close a file descriptor through the close(2) system call. */
|
/**
|
||||||
|
* Close a file descriptor through the close(2) system call.
|
||||||
|
*/
|
||||||
public static native void close(int fileDescriptor);
|
public static native void close(int fileDescriptor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,56 +3,7 @@ package io.neoterm.backend;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static android.view.KeyEvent.KEYCODE_BACK;
|
import static android.view.KeyEvent.*;
|
||||||
import static android.view.KeyEvent.KEYCODE_BREAK;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_DEL;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_DPAD_CENTER;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_DPAD_DOWN;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_DPAD_LEFT;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_DPAD_RIGHT;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_DPAD_UP;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_ENTER;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_ESCAPE;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_F1;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_F10;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_F11;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_F12;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_F2;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_F3;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_F4;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_F5;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_F6;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_F7;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_F8;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_F9;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_FORWARD_DEL;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_INSERT;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_MOVE_END;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_MOVE_HOME;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_0;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_1;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_2;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_3;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_4;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_5;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_6;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_7;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_8;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_9;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_ADD;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_COMMA;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_DIVIDE;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_DOT;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_ENTER;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_EQUALS;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_MULTIPLY;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUMPAD_SUBTRACT;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_NUM_LOCK;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_PAGE_DOWN;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_PAGE_UP;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_SPACE;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_SYSRQ;
|
|
||||||
import static android.view.KeyEvent.KEYCODE_TAB;
|
|
||||||
|
|
||||||
public final class KeyHandler {
|
public final class KeyHandler {
|
||||||
|
|
||||||
|
@ -9,13 +9,21 @@ package io.neoterm.backend;
|
|||||||
public final class TerminalBuffer {
|
public final class TerminalBuffer {
|
||||||
|
|
||||||
TerminalRow[] mLines;
|
TerminalRow[] mLines;
|
||||||
/** The length of {@link #mLines}. */
|
/**
|
||||||
|
* The length of {@link #mLines}.
|
||||||
|
*/
|
||||||
int mTotalRows;
|
int mTotalRows;
|
||||||
/** The number of rows and columns visible on the screen. */
|
/**
|
||||||
|
* The number of rows and columns visible on the screen.
|
||||||
|
*/
|
||||||
int mScreenRows, mColumns;
|
int mScreenRows, mColumns;
|
||||||
/** The number of rows kept in history. */
|
/**
|
||||||
|
* The number of rows kept in history.
|
||||||
|
*/
|
||||||
private int mActiveTranscriptRows = 0;
|
private int mActiveTranscriptRows = 0;
|
||||||
/** The index in the circular buffer where the visible screen starts. */
|
/**
|
||||||
|
* The index in the circular buffer where the visible screen starts.
|
||||||
|
*/
|
||||||
private int mScreenFirstRow = 0;
|
private int mScreenFirstRow = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -397,7 +405,9 @@ public final class TerminalBuffer {
|
|||||||
return allocateFullLineIfNecessary(externalToInternalRow(externalRow)).getStyle(column);
|
return allocateFullLineIfNecessary(externalToInternalRow(externalRow)).getStyle(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Support for http://vt100.net/docs/vt510-rm/DECCARA and http://vt100.net/docs/vt510-rm/DECCARA */
|
/**
|
||||||
|
* Support for http://vt100.net/docs/vt510-rm/DECCARA and http://vt100.net/docs/vt510-rm/DECCARA
|
||||||
|
*/
|
||||||
public void setOrClearEffect(int bits, boolean setOrClear, boolean reverse, boolean rectangular, int leftMargin, int rightMargin, int top, int left,
|
public void setOrClearEffect(int bits, boolean setOrClear, boolean reverse, boolean rectangular, int leftMargin, int rightMargin, int top, int left,
|
||||||
int bottom, int right) {
|
int bottom, int right) {
|
||||||
for (int y = top; y < bottom; y++) {
|
for (int y = top; y < bottom; y++) {
|
||||||
|
@ -11,7 +11,9 @@ import java.util.Properties;
|
|||||||
*/
|
*/
|
||||||
public final class TerminalColorScheme {
|
public final class TerminalColorScheme {
|
||||||
|
|
||||||
/** http://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg, but with blue color brighter. */
|
/**
|
||||||
|
* http://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg, but with blue color brighter.
|
||||||
|
*/
|
||||||
public static final int[] DEFAULT_COLORS = {
|
public static final int[] DEFAULT_COLORS = {
|
||||||
// 16 original colors. First 8 are dim.
|
// 16 original colors. First 8 are dim.
|
||||||
0xff000000, // black
|
0xff000000, // black
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
package io.neoterm.backend;
|
package io.neoterm.backend;
|
||||||
|
|
||||||
/** Current terminal colors (if different from default). */
|
/**
|
||||||
|
* Current terminal colors (if different from default).
|
||||||
|
*/
|
||||||
public final class TerminalColors {
|
public final class TerminalColors {
|
||||||
|
|
||||||
/** Static data - a bit ugly but ok for now. */
|
/**
|
||||||
|
* Static data - a bit ugly but ok for now.
|
||||||
|
*/
|
||||||
public static final TerminalColorScheme COLOR_SCHEME = new TerminalColorScheme();
|
public static final TerminalColorScheme COLOR_SCHEME = new TerminalColorScheme();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,17 +16,23 @@ public final class TerminalColors {
|
|||||||
*/
|
*/
|
||||||
public final int[] mCurrentColors = new int[TextStyle.NUM_INDEXED_COLORS];
|
public final int[] mCurrentColors = new int[TextStyle.NUM_INDEXED_COLORS];
|
||||||
|
|
||||||
/** Create a new instance with default colors from the theme. */
|
/**
|
||||||
|
* Create a new instance with default colors from the theme.
|
||||||
|
*/
|
||||||
public TerminalColors() {
|
public TerminalColors() {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reset a particular indexed color with the default color from the color theme. */
|
/**
|
||||||
|
* Reset a particular indexed color with the default color from the color theme.
|
||||||
|
*/
|
||||||
public void reset(int index) {
|
public void reset(int index) {
|
||||||
mCurrentColors[index] = COLOR_SCHEME.mDefaultColors[index];
|
mCurrentColors[index] = COLOR_SCHEME.mDefaultColors[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reset all indexed colors with the default color from the color theme. */
|
/**
|
||||||
|
* Reset all indexed colors with the default color from the color theme.
|
||||||
|
*/
|
||||||
public void reset() {
|
public void reset() {
|
||||||
reset(COLOR_SCHEME);
|
reset(COLOR_SCHEME);
|
||||||
}
|
}
|
||||||
@ -72,7 +82,9 @@ public final class TerminalColors {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Try parse a color from a text parameter and into a specified index. */
|
/**
|
||||||
|
* Try parse a color from a text parameter and into a specified index.
|
||||||
|
*/
|
||||||
public void tryParseColor(int intoIndex, String textParameter) {
|
public void tryParseColor(int intoIndex, String textParameter) {
|
||||||
int c = parse(textParameter);
|
int c = parse(textParameter);
|
||||||
if (c != 0) mCurrentColors[intoIndex] = c;
|
if (c != 0) mCurrentColors[intoIndex] = c;
|
||||||
|
@ -2,25 +2,37 @@ package io.neoterm.backend;
|
|||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/** A client which receives callbacks from events triggered by feeding input to a {@link TerminalEmulator}. */
|
/**
|
||||||
|
* A client which receives callbacks from events triggered by feeding input to a {@link TerminalEmulator}.
|
||||||
|
*/
|
||||||
public abstract class TerminalOutput {
|
public abstract class TerminalOutput {
|
||||||
|
|
||||||
/** Write a string using the UTF-8 encoding to the terminal client. */
|
/**
|
||||||
|
* Write a string using the UTF-8 encoding to the terminal client.
|
||||||
|
*/
|
||||||
public final void write(String data) {
|
public final void write(String data) {
|
||||||
byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
|
byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
|
||||||
write(bytes, 0, bytes.length);
|
write(bytes, 0, bytes.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Write bytes to the terminal client. */
|
/**
|
||||||
|
* Write bytes to the terminal client.
|
||||||
|
*/
|
||||||
public abstract void write(byte[] data, int offset, int count);
|
public abstract void write(byte[] data, int offset, int count);
|
||||||
|
|
||||||
/** Notify the terminal client that the terminal title has changed. */
|
/**
|
||||||
|
* Notify the terminal client that the terminal title has changed.
|
||||||
|
*/
|
||||||
public abstract void titleChanged(String oldTitle, String newTitle);
|
public abstract void titleChanged(String oldTitle, String newTitle);
|
||||||
|
|
||||||
/** Notify the terminal client that the terminal title has changed. */
|
/**
|
||||||
|
* Notify the terminal client that the terminal title has changed.
|
||||||
|
*/
|
||||||
public abstract void clipboardText(String text);
|
public abstract void clipboardText(String text);
|
||||||
|
|
||||||
/** Notify the terminal client that a bell character (ASCII 7, bell, BEL, \a, ^G)) has been received. */
|
/**
|
||||||
|
* Notify the terminal client that a bell character (ASCII 7, bell, BEL, \a, ^G)) has been received.
|
||||||
|
*/
|
||||||
public abstract void onBell();
|
public abstract void onBell();
|
||||||
|
|
||||||
public abstract void onColorsChanged();
|
public abstract void onColorsChanged();
|
||||||
|
@ -11,20 +11,34 @@ public final class TerminalRow {
|
|||||||
|
|
||||||
private static final float SPARE_CAPACITY_FACTOR = 1.5f;
|
private static final float SPARE_CAPACITY_FACTOR = 1.5f;
|
||||||
|
|
||||||
/** The number of columns in this terminal row. */
|
/**
|
||||||
|
* The number of columns in this terminal row.
|
||||||
|
*/
|
||||||
private final int mColumns;
|
private final int mColumns;
|
||||||
/** The text filling this terminal row. */
|
/**
|
||||||
|
* The text filling this terminal row.
|
||||||
|
*/
|
||||||
public char[] mText;
|
public char[] mText;
|
||||||
/** The number of java char:s used in {@link #mText}. */
|
/**
|
||||||
|
* The number of java char:s used in {@link #mText}.
|
||||||
|
*/
|
||||||
private short mSpaceUsed;
|
private short mSpaceUsed;
|
||||||
/** If this row has been line wrapped due to text output at the end of line. */
|
/**
|
||||||
|
* If this row has been line wrapped due to text output at the end of line.
|
||||||
|
*/
|
||||||
boolean mLineWrap;
|
boolean mLineWrap;
|
||||||
/** The style bits of each cell in the row. See {@link TextStyle}. */
|
/**
|
||||||
|
* The style bits of each cell in the row. See {@link TextStyle}.
|
||||||
|
*/
|
||||||
final long[] mStyle;
|
final long[] mStyle;
|
||||||
/** If this row might contain chars with width != 1, used for deactivating fast path */
|
/**
|
||||||
|
* If this row might contain chars with width != 1, used for deactivating fast path
|
||||||
|
*/
|
||||||
boolean mHasNonOneWidthOrSurrogateChars;
|
boolean mHasNonOneWidthOrSurrogateChars;
|
||||||
|
|
||||||
/** Construct a blank row (containing only whitespace, ' ') with a specified style. */
|
/**
|
||||||
|
* Construct a blank row (containing only whitespace, ' ') with a specified style.
|
||||||
|
*/
|
||||||
public TerminalRow(int columns, long style) {
|
public TerminalRow(int columns, long style) {
|
||||||
mColumns = columns;
|
mColumns = columns;
|
||||||
mText = new char[(int) (SPARE_CAPACITY_FACTOR * columns)];
|
mText = new char[(int) (SPARE_CAPACITY_FACTOR * columns)];
|
||||||
@ -32,7 +46,9 @@ public final class TerminalRow {
|
|||||||
clear(style);
|
clear(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** NOTE: The sourceX2 is exclusive. */
|
/**
|
||||||
|
* NOTE: The sourceX2 is exclusive.
|
||||||
|
*/
|
||||||
public void copyInterval(TerminalRow line, int sourceX1, int sourceX2, int destinationX) {
|
public void copyInterval(TerminalRow line, int sourceX1, int sourceX2, int destinationX) {
|
||||||
mHasNonOneWidthOrSurrogateChars |= line.mHasNonOneWidthOrSurrogateChars;
|
mHasNonOneWidthOrSurrogateChars |= line.mHasNonOneWidthOrSurrogateChars;
|
||||||
final int x1 = line.findStartOfColumn(sourceX1);
|
final int x1 = line.findStartOfColumn(sourceX1);
|
||||||
@ -62,7 +78,9 @@ public final class TerminalRow {
|
|||||||
return mSpaceUsed;
|
return mSpaceUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Note that the column may end of second half of wide character. */
|
/**
|
||||||
|
* Note that the column may end of second half of wide character.
|
||||||
|
*/
|
||||||
public int findStartOfColumn(int column) {
|
public int findStartOfColumn(int column) {
|
||||||
if (column == mColumns) return getSpaceUsed();
|
if (column == mColumns) return getSpaceUsed();
|
||||||
|
|
||||||
|
@ -8,11 +8,7 @@ import android.system.Os;
|
|||||||
import android.system.OsConstants;
|
import android.system.OsConstants;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.*;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -30,7 +26,9 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class TerminalSession extends TerminalOutput {
|
public class TerminalSession extends TerminalOutput {
|
||||||
|
|
||||||
/** Callback to be invoked when a {@link TerminalSession} changes. */
|
/**
|
||||||
|
* Callback to be invoked when a {@link TerminalSession} changes.
|
||||||
|
*/
|
||||||
public interface SessionChangedCallback {
|
public interface SessionChangedCallback {
|
||||||
void onTextChanged(TerminalSession changedSession);
|
void onTextChanged(TerminalSession changedSession);
|
||||||
|
|
||||||
@ -83,20 +81,28 @@ public class TerminalSession extends TerminalOutput {
|
|||||||
* writing to the {@link #mTerminalFileDescriptor}.
|
* writing to the {@link #mTerminalFileDescriptor}.
|
||||||
*/
|
*/
|
||||||
private final ByteQueue mTerminalToProcessIOQueue = new ByteQueue(4096);
|
private final ByteQueue mTerminalToProcessIOQueue = new ByteQueue(4096);
|
||||||
/** Buffer to write translate code points into utf8 before writing to mTerminalToProcessIOQueue */
|
/**
|
||||||
|
* Buffer to write translate code points into utf8 before writing to mTerminalToProcessIOQueue
|
||||||
|
*/
|
||||||
private final byte[] mUtf8InputBuffer = new byte[5];
|
private final byte[] mUtf8InputBuffer = new byte[5];
|
||||||
|
|
||||||
public SessionChangedCallback getSessionChangedCallback() {
|
public SessionChangedCallback getSessionChangedCallback() {
|
||||||
return mChangeCallback;
|
return mChangeCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Callback which gets notified when a session finishes or changes title. */
|
/**
|
||||||
|
* Callback which gets notified when a session finishes or changes title.
|
||||||
|
*/
|
||||||
private final SessionChangedCallback mChangeCallback;
|
private final SessionChangedCallback mChangeCallback;
|
||||||
|
|
||||||
/** The pid of the executablePath process. 0 if not started and -1 if finished running. */
|
/**
|
||||||
|
* The pid of the executablePath process. 0 if not started and -1 if finished running.
|
||||||
|
*/
|
||||||
private int mShellPid;
|
private int mShellPid;
|
||||||
|
|
||||||
/** The exit status of the executablePath process. Only valid if ${@link #mShellPid} is -1. */
|
/**
|
||||||
|
* The exit status of the executablePath process. Only valid if ${@link #mShellPid} is -1.
|
||||||
|
*/
|
||||||
private int mShellExitStatus;
|
private int mShellExitStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,7 +111,9 @@ public class TerminalSession extends TerminalOutput {
|
|||||||
*/
|
*/
|
||||||
private int mTerminalFileDescriptor;
|
private int mTerminalFileDescriptor;
|
||||||
|
|
||||||
/** Set by the application for user identification of session, not by terminal. */
|
/**
|
||||||
|
* Set by the application for user identification of session, not by terminal.
|
||||||
|
*/
|
||||||
public String mSessionName;
|
public String mSessionName;
|
||||||
|
|
||||||
@SuppressLint("HandlerLeak")
|
@SuppressLint("HandlerLeak")
|
||||||
@ -147,7 +155,9 @@ public class TerminalSession extends TerminalOutput {
|
|||||||
this.mEnv = env;
|
this.mEnv = env;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Inform the attached pty of the new size and reflow or initialize the emulator. */
|
/**
|
||||||
|
* Inform the attached pty of the new size and reflow or initialize the emulator.
|
||||||
|
*/
|
||||||
public void updateSize(int columns, int rows) {
|
public void updateSize(int columns, int rows) {
|
||||||
if (mEmulator == null) {
|
if (mEmulator == null) {
|
||||||
initializeEmulator(columns, rows);
|
initializeEmulator(columns, rows);
|
||||||
@ -157,7 +167,9 @@ public class TerminalSession extends TerminalOutput {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The terminal title as set through escape sequences or null if none set. */
|
/**
|
||||||
|
* The terminal title as set through escape sequences or null if none set.
|
||||||
|
*/
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return (mEmulator == null) ? null : mEmulator.getTitle();
|
return (mEmulator == null) ? null : mEmulator.getTitle();
|
||||||
}
|
}
|
||||||
@ -219,13 +231,17 @@ public class TerminalSession extends TerminalOutput {
|
|||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Write data to the executablePath process. */
|
/**
|
||||||
|
* Write data to the executablePath process.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void write(byte[] data, int offset, int count) {
|
public void write(byte[] data, int offset, int count) {
|
||||||
if (mShellPid > 0) mTerminalToProcessIOQueue.write(data, offset, count);
|
if (mShellPid > 0) mTerminalToProcessIOQueue.write(data, offset, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Write the Unicode code point to the terminal encoded in UTF-8. */
|
/**
|
||||||
|
* Write the Unicode code point to the terminal encoded in UTF-8.
|
||||||
|
*/
|
||||||
public void writeCodePoint(boolean prependEscape, int codePoint) {
|
public void writeCodePoint(boolean prependEscape, int codePoint) {
|
||||||
if (codePoint > 1114111 || (codePoint >= 0xD800 && codePoint <= 0xDFFF)) {
|
if (codePoint > 1114111 || (codePoint >= 0xD800 && codePoint <= 0xDFFF)) {
|
||||||
// 1114111 (= 2**16 + 1024**2 - 1) is the highest code point, [0xD800,0xDFFF] is the surrogate range.
|
// 1114111 (= 2**16 + 1024**2 - 1) is the highest code point, [0xD800,0xDFFF] is the surrogate range.
|
||||||
@ -266,18 +282,24 @@ public class TerminalSession extends TerminalOutput {
|
|||||||
return mEmulator;
|
return mEmulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Notify the {@link #mChangeCallback} that the screen has changed. */
|
/**
|
||||||
|
* Notify the {@link #mChangeCallback} that the screen has changed.
|
||||||
|
*/
|
||||||
private void notifyScreenUpdate() {
|
private void notifyScreenUpdate() {
|
||||||
mChangeCallback.onTextChanged(this);
|
mChangeCallback.onTextChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reset state for terminal emulator state. */
|
/**
|
||||||
|
* Reset state for terminal emulator state.
|
||||||
|
*/
|
||||||
public void reset() {
|
public void reset() {
|
||||||
mEmulator.reset();
|
mEmulator.reset();
|
||||||
notifyScreenUpdate();
|
notifyScreenUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Finish this terminal session by sending SIGKILL to the executablePath. */
|
/**
|
||||||
|
* Finish this terminal session by sending SIGKILL to the executablePath.
|
||||||
|
*/
|
||||||
public void finishIfRunning() {
|
public void finishIfRunning() {
|
||||||
if (isRunning()) {
|
if (isRunning()) {
|
||||||
try {
|
try {
|
||||||
@ -302,7 +324,9 @@ public class TerminalSession extends TerminalOutput {
|
|||||||
return exitDescription;
|
return exitDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Cleanup resources when the process exits. */
|
/**
|
||||||
|
* Cleanup resources when the process exits.
|
||||||
|
*/
|
||||||
private void cleanupResources(int exitStatus) {
|
private void cleanupResources(int exitStatus) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
mShellPid = -1;
|
mShellPid = -1;
|
||||||
@ -324,7 +348,9 @@ public class TerminalSession extends TerminalOutput {
|
|||||||
return mShellPid != -1;
|
return mShellPid != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Only valid if not {@link #isRunning()}. */
|
/**
|
||||||
|
* Only valid if not {@link #isRunning()}.
|
||||||
|
*/
|
||||||
public synchronized int getExitStatus() {
|
public synchronized int getExitStatus() {
|
||||||
return mShellExitStatus;
|
return mShellExitStatus;
|
||||||
}
|
}
|
||||||
|
@ -29,21 +29,31 @@ public final class TextStyle {
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public final static int CHARACTER_ATTRIBUTE_PROTECTED = 1 << 7;
|
public final static int CHARACTER_ATTRIBUTE_PROTECTED = 1 << 7;
|
||||||
/** Dim colors. Also known as faint or half intensity. */
|
/**
|
||||||
|
* Dim colors. Also known as faint or half intensity.
|
||||||
|
*/
|
||||||
public final static int CHARACTER_ATTRIBUTE_DIM = 1 << 8;
|
public final static int CHARACTER_ATTRIBUTE_DIM = 1 << 8;
|
||||||
/** If true (24-bit) color is used for the cell for foregroundColor. */
|
/**
|
||||||
|
* If true (24-bit) color is used for the cell for foregroundColor.
|
||||||
|
*/
|
||||||
private final static int CHARACTER_ATTRIBUTE_TRUECOLOR_FOREGROUND = 1 << 9;
|
private final static int CHARACTER_ATTRIBUTE_TRUECOLOR_FOREGROUND = 1 << 9;
|
||||||
/** If true (24-bit) color is used for the cell for foregroundColor. */
|
/**
|
||||||
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_FOREGROUND = 256;
|
||||||
public final static int COLOR_INDEX_BACKGROUND = 257;
|
public final static int COLOR_INDEX_BACKGROUND = 257;
|
||||||
public final static int COLOR_INDEX_CURSOR = 258;
|
public final static int COLOR_INDEX_CURSOR = 258;
|
||||||
|
|
||||||
/** The 256 standard color entries and the three special (foregroundColor, backgroundColor and cursorColor) ones. */
|
/**
|
||||||
|
* The 256 standard color entries and the three special (foregroundColor, backgroundColor and cursorColor) ones.
|
||||||
|
*/
|
||||||
public final static int NUM_INDEXED_COLORS = 259;
|
public final static int NUM_INDEXED_COLORS = 259;
|
||||||
|
|
||||||
/** Normal foregroundColor and backgroundColor colors and no effects. */
|
/**
|
||||||
|
* Normal foregroundColor and backgroundColor colors and no effects.
|
||||||
|
*/
|
||||||
final static long NORMAL = encode(COLOR_INDEX_FOREGROUND, COLOR_INDEX_BACKGROUND, 0);
|
final static long NORMAL = encode(COLOR_INDEX_FOREGROUND, COLOR_INDEX_BACKGROUND, 0);
|
||||||
|
|
||||||
static long encode(int foreColor, int backColor, int effect) {
|
static long encode(int foreColor, int backColor, int effect) {
|
||||||
|
@ -2,7 +2,7 @@ package io.neoterm.backend;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of wcwidth(3) for Unicode 9.
|
* Implementation of wcwidth(3) for Unicode 9.
|
||||||
*
|
* <p>
|
||||||
* Implementation from https://github.com/jquast/wcwidth but we return 0 for unprintable characters.
|
* Implementation from https://github.com/jquast/wcwidth but we return 0 for unprintable characters.
|
||||||
*/
|
*/
|
||||||
public final class WcWidth {
|
public final class WcWidth {
|
||||||
@ -427,7 +427,9 @@ public final class WcWidth {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the terminal display width of a code point: 0, 1 || 2. */
|
/**
|
||||||
|
* Return the terminal display width of a code point: 0, 1 || 2.
|
||||||
|
*/
|
||||||
public static int width(int ucs) {
|
public static int width(int ucs) {
|
||||||
if (ucs == 0 ||
|
if (ucs == 0 ||
|
||||||
ucs == 0x034F ||
|
ucs == 0x034F ||
|
||||||
@ -449,7 +451,9 @@ public final class WcWidth {
|
|||||||
return intable(WIDE_EASTASIAN, ucs) ? 2 : 1;
|
return intable(WIDE_EASTASIAN, ucs) ? 2 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The width at an index position in a java char array. */
|
/**
|
||||||
|
* The width at an index position in a java char array.
|
||||||
|
*/
|
||||||
public static int width(char[] chars, int index) {
|
public static int width(char[] chars, int index) {
|
||||||
char c = chars[index];
|
char c = chars[index];
|
||||||
return Character.isHighSurrogate(c) ? width(Character.toCodePoint(c, chars[index + 1])) : width(c);
|
return Character.isHighSurrogate(c) ? width(Character.toCodePoint(c, chars[index + 1])) : width(c);
|
||||||
|
@ -40,8 +40,12 @@ class NeoColorGenerator(parameter: CodeGenParameter) : CodeGenerator(parameter)
|
|||||||
val component = ComponentManager.getComponent<ConfigureComponent>()
|
val component = ComponentManager.getComponent<ConfigureComponent>()
|
||||||
|
|
||||||
builder.append(" ${NeoColorScheme.COLOR_META_NAME}: \"${colorScheme.colorName}\"\n")
|
builder.append(" ${NeoColorScheme.COLOR_META_NAME}: \"${colorScheme.colorName}\"\n")
|
||||||
builder.append(" ${NeoColorScheme.COLOR_META_VERSION}: ${colorScheme.colorVersion
|
builder.append(
|
||||||
?: component.getLoaderVersion()}\n")
|
" ${NeoColorScheme.COLOR_META_VERSION}: ${
|
||||||
|
colorScheme.colorVersion
|
||||||
|
?: component.getLoaderVersion()
|
||||||
|
}\n"
|
||||||
|
)
|
||||||
builder.append("\n")
|
builder.append("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,8 @@ class ColorSchemeComponent : ConfigFileBasedComponent<NeoColorScheme>(NeoTermPat
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getCurrentColorSchemeName(): String {
|
fun getCurrentColorSchemeName(): String {
|
||||||
var currentColorName = NeoPreference.loadString(R.string.key_customization_color_scheme, DefaultColorScheme.colorName)
|
var currentColorName =
|
||||||
|
NeoPreference.loadString(R.string.key_customization_color_scheme, DefaultColorScheme.colorName)
|
||||||
if (!colors.containsKey(currentColorName)) {
|
if (!colors.containsKey(currentColorName)) {
|
||||||
currentColorName = DefaultColorScheme.colorName
|
currentColorName = DefaultColorScheme.colorName
|
||||||
NeoPreference.store(R.string.key_customization_color_scheme, DefaultColorScheme.colorName)
|
NeoPreference.store(R.string.key_customization_color_scheme, DefaultColorScheme.colorName)
|
||||||
|
@ -6,5 +6,5 @@ import io.neoterm.frontend.config.NeoConfigureFile
|
|||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
interface IConfigureLoader {
|
interface IConfigureLoader {
|
||||||
fun loadConfigure() : NeoConfigureFile?
|
fun loadConfigure(): NeoConfigureFile?
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package io.neoterm.component.pm;
|
package io.neoterm.component.pm;
|
||||||
|
|
||||||
|
import io.neoterm.frontend.component.NeoComponent;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import io.neoterm.frontend.component.NeoComponent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package io.neoterm.component.session
|
package io.neoterm.component.session
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import io.neoterm.Globals
|
import io.neoterm.Globals
|
||||||
import io.neoterm.frontend.component.NeoComponent
|
import io.neoterm.frontend.component.NeoComponent
|
||||||
import io.neoterm.frontend.config.NeoTermPath
|
import io.neoterm.frontend.config.NeoTermPath
|
||||||
@ -48,8 +48,10 @@ class SessionComponent : NeoComponent {
|
|||||||
try {
|
try {
|
||||||
System.load(soPath)
|
System.load(soPath)
|
||||||
} catch (error: UnsatisfiedLinkError) {
|
} catch (error: UnsatisfiedLinkError) {
|
||||||
NLog.e("SessionComponent", "Error loading lib " + soPath
|
NLog.e(
|
||||||
+ ", reason: " + error.localizedMessage)
|
"SessionComponent", "Error loading lib " + soPath
|
||||||
|
+ ", reason: " + error.localizedMessage
|
||||||
|
)
|
||||||
result = false
|
result = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,28 +5,17 @@ import android.database.Cursor;
|
|||||||
import android.database.SQLException;
|
import android.database.SQLException;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
import io.neoterm.App;
|
||||||
|
import io.neoterm.framework.database.*;
|
||||||
|
import io.neoterm.framework.database.bean.TableInfo;
|
||||||
|
import io.neoterm.framework.reflection.Reflect;
|
||||||
|
import io.neoterm.frontend.logging.NLog;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import io.neoterm.App;
|
|
||||||
import io.neoterm.framework.database.DatabaseDataType;
|
|
||||||
import io.neoterm.framework.database.OnDatabaseUpgradedListener;
|
|
||||||
import io.neoterm.framework.database.SQLStatementHelper;
|
|
||||||
import io.neoterm.framework.database.SQLTypeParser;
|
|
||||||
import io.neoterm.framework.database.NeoTermSQLiteConfig;
|
|
||||||
import io.neoterm.framework.database.TableHelper;
|
|
||||||
import io.neoterm.framework.database.ValueHelper;
|
|
||||||
import io.neoterm.framework.database.bean.TableInfo;
|
|
||||||
import io.neoterm.framework.reflection.Reflect;
|
|
||||||
import io.neoterm.frontend.logging.NLog;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Lody, Kiva
|
* @author Lody, Kiva
|
||||||
|
@ -107,6 +107,7 @@ public class NeoTermSQLiteConfig implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* App 更新时是否默认删除所有存在的表
|
* App 更新时是否默认删除所有存在的表
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isDefaultDropAllTables() {
|
public boolean isDefaultDropAllTables() {
|
||||||
@ -115,6 +116,7 @@ public class NeoTermSQLiteConfig implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置 App 更新时是否默认删除所有存在的表
|
* 设置 App 更新时是否默认删除所有存在的表
|
||||||
|
*
|
||||||
* @param defaultDropAllTables
|
* @param defaultDropAllTables
|
||||||
*/
|
*/
|
||||||
public void setDefaultDropAllTables(boolean defaultDropAllTables) {
|
public void setDefaultDropAllTables(boolean defaultDropAllTables) {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package io.neoterm.framework.database;
|
package io.neoterm.framework.database;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import io.neoterm.framework.database.annotation.ID;
|
import io.neoterm.framework.database.annotation.ID;
|
||||||
import io.neoterm.framework.database.bean.TableInfo;
|
import io.neoterm.framework.database.bean.TableInfo;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package io.neoterm.framework.database;
|
package io.neoterm.framework.database;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import io.neoterm.framework.database.annotation.Ignore;
|
import io.neoterm.framework.database.annotation.Ignore;
|
||||||
import io.neoterm.framework.database.annotation.NotNull;
|
import io.neoterm.framework.database.annotation.NotNull;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package io.neoterm.framework.database;
|
package io.neoterm.framework.database;
|
||||||
|
|
||||||
|
import io.neoterm.framework.NeoTermDatabase;
|
||||||
|
import io.neoterm.framework.database.annotation.ID;
|
||||||
|
import io.neoterm.framework.database.annotation.Table;
|
||||||
|
import io.neoterm.framework.database.bean.TableInfo;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import io.neoterm.framework.NeoTermDatabase;
|
|
||||||
import io.neoterm.framework.database.annotation.ID;
|
|
||||||
import io.neoterm.framework.database.annotation.Table;
|
|
||||||
import io.neoterm.framework.database.bean.TableInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package io.neoterm.framework.database.bean;
|
package io.neoterm.framework.database.bean;
|
||||||
|
|
||||||
|
|
||||||
|
import io.neoterm.framework.database.DatabaseDataType;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import io.neoterm.framework.database.DatabaseDataType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
|
@ -2,6 +2,7 @@ package io.neoterm.framework.reflection;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* class representing null pointer.
|
* class representing null pointer.
|
||||||
|
*
|
||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
public class NullPointer {
|
public class NullPointer {
|
||||||
|
@ -45,9 +45,11 @@ class CandidatePopupWindow(val context: Context) {
|
|||||||
rootView.setMaxHeight(maxHeight)
|
rootView.setMaxHeight(maxHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
popWindow.showAtLocation(terminalView, Gravity.BOTTOM.and(Gravity.START),
|
popWindow.showAtLocation(
|
||||||
|
terminalView, Gravity.BOTTOM.and(Gravity.START),
|
||||||
terminalView.cursorAbsoluteX,
|
terminalView.cursorAbsoluteX,
|
||||||
terminalView.cursorAbsoluteY)
|
terminalView.cursorAbsoluteY
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,10 @@ class MaxHeightView : LinearLayout {
|
|||||||
else
|
else
|
||||||
maxHeight
|
maxHeight
|
||||||
}
|
}
|
||||||
finalHeightMeasureSpec = View.MeasureSpec.makeMeasureSpec(heightSize,
|
finalHeightMeasureSpec = View.MeasureSpec.makeMeasureSpec(
|
||||||
heightMode)
|
heightSize,
|
||||||
|
heightMode
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onMeasure(widthMeasureSpec, finalHeightMeasureSpec)
|
super.onMeasure(widthMeasureSpec, finalHeightMeasureSpec)
|
||||||
|
@ -26,9 +26,9 @@ object ComponentManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
fun <T : NeoComponent> getComponent(componentInterface: Class<T>, errorThrow: Boolean = true) : T {
|
fun <T : NeoComponent> getComponent(componentInterface: Class<T>, errorThrow: Boolean = true): T {
|
||||||
val component: NeoComponent = COMPONENTS[componentInterface] ?:
|
val component: NeoComponent =
|
||||||
throw ComponentNotFoundException(componentInterface.simpleName)
|
COMPONENTS[componentInterface] ?: throw ComponentNotFoundException(componentInterface.simpleName)
|
||||||
|
|
||||||
component.onServiceObtained()
|
component.onServiceObtained()
|
||||||
return component as T
|
return component as T
|
||||||
|
@ -10,7 +10,7 @@ import java.nio.file.Files
|
|||||||
*/
|
*/
|
||||||
open class NeoConfigureFile(val configureFile: File) {
|
open class NeoConfigureFile(val configureFile: File) {
|
||||||
private val configParser = NeoLangParser()
|
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.")
|
fun getVisitor() = configVisitor ?: throw IllegalStateException("Configure file not loaded or parse failed.")
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package io.neoterm.frontend.config
|
package io.neoterm.frontend.config
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import android.content.ActivityNotFoundException
|
import android.content.ActivityNotFoundException
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
|
||||||
@ -21,12 +21,18 @@ object NeoPermission {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ContextCompat.checkSelfPermission(context,
|
if (ContextCompat.checkSelfPermission(
|
||||||
Manifest.permission.READ_EXTERNAL_STORAGE)
|
context,
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||||
|
)
|
||||||
|
!= PackageManager.PERMISSION_GRANTED
|
||||||
|
) {
|
||||||
|
|
||||||
if (ActivityCompat.shouldShowRequestPermissionRationale(context,
|
if (ActivityCompat.shouldShowRequestPermissionRationale(
|
||||||
Manifest.permission.READ_EXTERNAL_STORAGE)) {
|
context,
|
||||||
|
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||||
|
)
|
||||||
|
) {
|
||||||
AlertDialog.Builder(context).setMessage("需要存储权限来访问存储设备上的文件")
|
AlertDialog.Builder(context).setMessage("需要存储权限来访问存储设备上的文件")
|
||||||
.setPositiveButton(android.R.string.ok, { _: DialogInterface, _: Int ->
|
.setPositiveButton(android.R.string.ok, { _: DialogInterface, _: Int ->
|
||||||
doRequestPermission(context, requestCode)
|
doRequestPermission(context, requestCode)
|
||||||
@ -41,9 +47,11 @@ object NeoPermission {
|
|||||||
|
|
||||||
private fun doRequestPermission(context: AppCompatActivity, requestCode: Int) {
|
private fun doRequestPermission(context: AppCompatActivity, requestCode: Int) {
|
||||||
try {
|
try {
|
||||||
ActivityCompat.requestPermissions(context,
|
ActivityCompat.requestPermissions(
|
||||||
|
context,
|
||||||
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE),
|
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE),
|
||||||
requestCode)
|
requestCode
|
||||||
|
)
|
||||||
} catch (ignore: ActivityNotFoundException) {
|
} catch (ignore: ActivityNotFoundException) {
|
||||||
// for MIUI, we ignore it.
|
// for MIUI, we ignore it.
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package io.neoterm.frontend.floating
|
package io.neoterm.frontend.floating
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import io.neoterm.R
|
import io.neoterm.R
|
||||||
import io.neoterm.backend.TerminalSession
|
import io.neoterm.backend.TerminalSession
|
||||||
import io.neoterm.frontend.session.shell.ShellParameter
|
import io.neoterm.frontend.session.shell.ShellParameter
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package io.neoterm.frontend.logging
|
package io.neoterm.frontend.logging
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.annotation.IntDef
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import androidx.annotation.IntDef
|
||||||
import java.io.*
|
import java.io.*
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@ -21,7 +21,14 @@ object NLog {
|
|||||||
const val E = Log.ERROR
|
const val E = Log.ERROR
|
||||||
const val A = Log.ASSERT
|
const val A = Log.ASSERT
|
||||||
|
|
||||||
@IntDef(V.toLong().toInt(), D.toLong().toInt(), I.toLong().toInt(), W.toLong().toInt(), E.toLong().toInt(), A.toLong().toInt())
|
@IntDef(
|
||||||
|
V.toLong().toInt(),
|
||||||
|
D.toLong().toInt(),
|
||||||
|
I.toLong().toInt(),
|
||||||
|
W.toLong().toInt(),
|
||||||
|
E.toLong().toInt(),
|
||||||
|
A.toLong().toInt()
|
||||||
|
)
|
||||||
@Retention(AnnotationRetention.SOURCE)
|
@Retention(AnnotationRetention.SOURCE)
|
||||||
private annotation class TYPE
|
private annotation class TYPE
|
||||||
|
|
||||||
@ -152,11 +159,13 @@ object NLog {
|
|||||||
}
|
}
|
||||||
if (sLogHeadSwitch) {
|
if (sLogHeadSwitch) {
|
||||||
val head = Formatter()
|
val head = Formatter()
|
||||||
.format("[Thread:%s], %s(%s:%d): ",
|
.format(
|
||||||
|
"[Thread:%s], %s(%s:%d): ",
|
||||||
Thread.currentThread().name,
|
Thread.currentThread().name,
|
||||||
targetElement.methodName,
|
targetElement.methodName,
|
||||||
targetElement.fileName,
|
targetElement.fileName,
|
||||||
targetElement.lineNumber)
|
targetElement.lineNumber
|
||||||
|
)
|
||||||
.toString()
|
.toString()
|
||||||
return arrayOf(returnTag, head, head)
|
return arrayOf(returnTag, head, head)
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class ShellProfile : NeoProfile() {
|
|||||||
private const val COLOR_SCHEME = "color-scheme"
|
private const val COLOR_SCHEME = "color-scheme"
|
||||||
private const val WORD_BASED_IME = "word-based-ime"
|
private const val WORD_BASED_IME = "word-based-ime"
|
||||||
|
|
||||||
fun create() : ShellProfile {
|
fun create(): ShellProfile {
|
||||||
return ShellProfile()
|
return ShellProfile()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,13 @@ import java.io.File
|
|||||||
/**
|
/**
|
||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
open class ShellTermSession private constructor(shellPath: String, cwd: String,
|
open class ShellTermSession private constructor(
|
||||||
|
shellPath: String, cwd: String,
|
||||||
args: Array<String>, env: Array<String>,
|
args: Array<String>, env: Array<String>,
|
||||||
changeCallback: SessionChangedCallback,
|
changeCallback: SessionChangedCallback,
|
||||||
private val initialCommand: String?,
|
private val initialCommand: String?,
|
||||||
val shellProfile: ShellProfile)
|
val shellProfile: ShellProfile
|
||||||
: TerminalSession(shellPath, cwd, args, env, changeCallback) {
|
) : TerminalSession(shellPath, cwd, args, env, changeCallback) {
|
||||||
|
|
||||||
var exitPrompt = App.get().getString(R.string.process_exit_prompt)
|
var exitPrompt = App.get().getString(R.string.process_exit_prompt)
|
||||||
|
|
||||||
@ -148,8 +149,7 @@ open class ShellTermSession private constructor(shellPath: String, cwd: String,
|
|||||||
fun create(context: Context): ShellTermSession {
|
fun create(context: Context): ShellTermSession {
|
||||||
val cwd = this.cwd ?: NeoTermPath.HOME_PATH
|
val cwd = this.cwd ?: NeoTermPath.HOME_PATH
|
||||||
|
|
||||||
val shell = this.executablePath ?:
|
val shell = this.executablePath ?: if (systemShell)
|
||||||
if (systemShell)
|
|
||||||
"/system/bin/sh"
|
"/system/bin/sh"
|
||||||
else
|
else
|
||||||
shellProfile.loginShell
|
shellProfile.loginShell
|
||||||
@ -157,8 +157,10 @@ open class ShellTermSession private constructor(shellPath: String, cwd: String,
|
|||||||
val args = this.args ?: mutableListOf(shell)
|
val args = this.args ?: mutableListOf(shell)
|
||||||
val env = transformEnvironment(this.env) ?: buildEnvironment(cwd, systemShell)
|
val env = transformEnvironment(this.env) ?: buildEnvironment(cwd, systemShell)
|
||||||
val callback = changeCallback ?: TermSessionCallback()
|
val callback = changeCallback ?: TermSessionCallback()
|
||||||
return ShellTermSession(shell, cwd, args.toTypedArray(), env, callback,
|
return ShellTermSession(
|
||||||
initialCommand ?: "", shellProfile)
|
shell, cwd, args.toTypedArray(), env, callback,
|
||||||
|
initialCommand ?: "", shellProfile
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun transformEnvironment(env: MutableList<Pair<String, String>>?): Array<String>? {
|
private fun transformEnvironment(env: MutableList<Pair<String, String>>?): Array<String>? {
|
||||||
@ -191,9 +193,11 @@ open class ShellTermSession private constructor(shellPath: String, cwd: String,
|
|||||||
|
|
||||||
return if (systemShell) {
|
return if (systemShell) {
|
||||||
val pathEnv = "PATH=" + System.getenv("PATH")
|
val pathEnv = "PATH=" + System.getenv("PATH")
|
||||||
arrayOf(termEnv, homeEnv, androidRootEnv, androidDataEnv,
|
arrayOf(
|
||||||
|
termEnv, homeEnv, androidRootEnv, androidDataEnv,
|
||||||
externalStorageEnv, pathEnv, neotermIdEnv, prefixEnv,
|
externalStorageEnv, pathEnv, neotermIdEnv, prefixEnv,
|
||||||
originLdEnv, originPathEnv, colorterm)
|
originLdEnv, originPathEnv, colorterm
|
||||||
|
)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
val ps1Env = "PS1=$ "
|
val ps1Env = "PS1=$ "
|
||||||
@ -211,10 +215,12 @@ open class ShellTermSession private constructor(shellPath: String, cwd: String,
|
|||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
||||||
arrayOf(termEnv, homeEnv, ps1Env, ldEnv, langEnv, pathEnv, pwdEnv,
|
arrayOf(
|
||||||
|
termEnv, homeEnv, ps1Env, ldEnv, langEnv, pathEnv, pwdEnv,
|
||||||
androidRootEnv, androidDataEnv, externalStorageEnv,
|
androidRootEnv, androidDataEnv, externalStorageEnv,
|
||||||
tmpdirEnv, neotermIdEnv, originPathEnv, originLdEnv,
|
tmpdirEnv, neotermIdEnv, originPathEnv, originLdEnv,
|
||||||
ldPreloadEnv, prefixEnv, colorterm)
|
ldPreloadEnv, prefixEnv, colorterm
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.filter { it.isNotEmpty() }
|
.filter { it.isNotEmpty() }
|
||||||
.toTypedArray()
|
.toTypedArray()
|
||||||
|
@ -9,7 +9,6 @@ import io.neoterm.frontend.completion.listener.OnCandidateSelectedListener
|
|||||||
import io.neoterm.frontend.completion.model.CompletionCandidate
|
import io.neoterm.frontend.completion.model.CompletionCandidate
|
||||||
import io.neoterm.frontend.completion.model.CompletionResult
|
import io.neoterm.frontend.completion.model.CompletionResult
|
||||||
import io.neoterm.frontend.completion.view.CandidatePopupWindow
|
import io.neoterm.frontend.completion.view.CandidatePopupWindow
|
||||||
import io.neoterm.frontend.logging.NLog
|
|
||||||
import io.neoterm.frontend.terminal.TerminalView
|
import io.neoterm.frontend.terminal.TerminalView
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@ -80,8 +79,10 @@ class TermCompleteListener(var terminalView: TerminalView?) : OnAutoCompleteList
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
Log.e("NeoTerm-AC", "currentEditing: $textNeedCompletion, " +
|
Log.e(
|
||||||
"deleteLength: $deleteLength, completeString: $newText")
|
"NeoTerm-AC", "currentEditing: $textNeedCompletion, " +
|
||||||
|
"deleteLength: $deleteLength, completeString: $newText"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pushString(newText)
|
pushString(newText)
|
||||||
|
@ -37,7 +37,11 @@ class TermSessionData {
|
|||||||
profile = null
|
profile = null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun initializeSessionWith(session: TerminalSession, sessionCallback: TermSessionCallback?, viewClient: TermViewClient?) {
|
fun initializeSessionWith(
|
||||||
|
session: TerminalSession,
|
||||||
|
sessionCallback: TermSessionCallback?,
|
||||||
|
viewClient: TermViewClient?
|
||||||
|
) {
|
||||||
this.termSession = session
|
this.termSession = session
|
||||||
this.sessionCallback = sessionCallback
|
this.sessionCallback = sessionCallback
|
||||||
this.viewClient = viewClient
|
this.viewClient = viewClient
|
||||||
|
@ -167,14 +167,25 @@ class TermViewClient(val context: Context) : TerminalViewClient {
|
|||||||
'v' -> {
|
'v' -> {
|
||||||
resultingCodePoint = -1
|
resultingCodePoint = -1
|
||||||
val audio = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
val audio = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||||
audio.adjustSuggestedStreamVolume(AudioManager.ADJUST_SAME, AudioManager.USE_DEFAULT_STREAM_TYPE, AudioManager.FLAG_SHOW_UI)
|
audio.adjustSuggestedStreamVolume(
|
||||||
|
AudioManager.ADJUST_SAME,
|
||||||
|
AudioManager.USE_DEFAULT_STREAM_TYPE,
|
||||||
|
AudioManager.FLAG_SHOW_UI
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resultingKeyCode != -1) {
|
if (resultingKeyCode != -1) {
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
val term = session.emulator
|
val term = session.emulator
|
||||||
session.write(KeyHandler.getCode(resultingKeyCode, 0, term.isCursorKeysApplicationMode, term.isKeypadApplicationMode))
|
session.write(
|
||||||
|
KeyHandler.getCode(
|
||||||
|
resultingKeyCode,
|
||||||
|
0,
|
||||||
|
term.isCursorKeysApplicationMode,
|
||||||
|
term.isKeypadApplicationMode
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else if (resultingCodePoint != -1) {
|
} else if (resultingCodePoint != -1) {
|
||||||
session?.writeCodePoint(altDown, resultingCodePoint)
|
session?.writeCodePoint(altDown, resultingCodePoint)
|
||||||
@ -220,7 +231,8 @@ class TermViewClient(val context: Context) : TerminalViewClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((lastTitle != title || force)
|
if ((lastTitle != title || force)
|
||||||
&& updateExtraKeysVisibility()) {
|
&& updateExtraKeysVisibility()
|
||||||
|
) {
|
||||||
removeExtraKeys()
|
removeExtraKeys()
|
||||||
ComponentManager.getComponent<ExtraKeyComponent>().showShortcutKeys(title, extraKeysView)
|
ComponentManager.getComponent<ExtraKeyComponent>().showShortcutKeys(title, extraKeysView)
|
||||||
extraKeysView.updateButtons()
|
extraKeysView.updateButtons()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package io.neoterm.frontend.session.xorg
|
package io.neoterm.frontend.session.xorg
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import android.app.UiModeManager
|
import android.app.UiModeManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.ActivityInfo
|
import android.content.pm.ActivityInfo
|
||||||
@ -14,6 +13,7 @@ import android.view.*
|
|||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import io.neoterm.*
|
import io.neoterm.*
|
||||||
import io.neoterm.frontend.session.xorg.client.XSessionData
|
import io.neoterm.frontend.session.xorg.client.XSessionData
|
||||||
import io.neoterm.xorg.NeoXorgViewClient
|
import io.neoterm.xorg.NeoXorgViewClient
|
||||||
@ -24,13 +24,16 @@ import java.util.*
|
|||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class XSession constructor(private val mActivity: AppCompatActivity, val mSessionData: XSessionData) : NeoXorgViewClient {
|
class XSession constructor(private val mActivity: AppCompatActivity, val mSessionData: XSessionData) :
|
||||||
|
NeoXorgViewClient {
|
||||||
var mSessionName = "";
|
var mSessionName = "";
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (Globals.InhibitSuspend) {
|
if (Globals.InhibitSuspend) {
|
||||||
window.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
|
window.setFlags(
|
||||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
|
||||||
|
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
mSessionData.client = this
|
mSessionData.client = this
|
||||||
@ -104,7 +107,10 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
|
|||||||
}
|
}
|
||||||
if (key > 100000) {
|
if (key > 100000) {
|
||||||
key -= 100000
|
key -= 100000
|
||||||
mActivity.onKeyDown(KeyEvent.KEYCODE_SHIFT_LEFT, KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT))
|
mActivity.onKeyDown(
|
||||||
|
KeyEvent.KEYCODE_SHIFT_LEFT,
|
||||||
|
KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
mActivity.onKeyDown(key, KeyEvent(KeyEvent.ACTION_DOWN, key))
|
mActivity.onKeyDown(key, KeyEvent(KeyEvent.ACTION_DOWN, key))
|
||||||
}
|
}
|
||||||
@ -119,16 +125,25 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
|
|||||||
if (key == Keyboard.KEYCODE_SHIFT) {
|
if (key == Keyboard.KEYCODE_SHIFT) {
|
||||||
builtinKeyboard.shift = !builtinKeyboard.shift
|
builtinKeyboard.shift = !builtinKeyboard.shift
|
||||||
if (builtinKeyboard.shift && !builtinKeyboard.alt)
|
if (builtinKeyboard.shift && !builtinKeyboard.alt)
|
||||||
mActivity.onKeyDown(KeyEvent.KEYCODE_SHIFT_LEFT, KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT))
|
mActivity.onKeyDown(
|
||||||
|
KeyEvent.KEYCODE_SHIFT_LEFT,
|
||||||
|
KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT)
|
||||||
|
)
|
||||||
else
|
else
|
||||||
mActivity.onKeyUp(KeyEvent.KEYCODE_SHIFT_LEFT, KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT))
|
mActivity.onKeyUp(
|
||||||
|
KeyEvent.KEYCODE_SHIFT_LEFT,
|
||||||
|
KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT)
|
||||||
|
)
|
||||||
builtinKeyboard.changeKeyboard(keyboard)
|
builtinKeyboard.changeKeyboard(keyboard)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (key == Keyboard.KEYCODE_ALT) {
|
if (key == Keyboard.KEYCODE_ALT) {
|
||||||
builtinKeyboard.alt = !builtinKeyboard.alt
|
builtinKeyboard.alt = !builtinKeyboard.alt
|
||||||
if (builtinKeyboard.alt)
|
if (builtinKeyboard.alt)
|
||||||
mActivity.onKeyUp(KeyEvent.KEYCODE_SHIFT_LEFT, KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT))
|
mActivity.onKeyUp(
|
||||||
|
KeyEvent.KEYCODE_SHIFT_LEFT,
|
||||||
|
KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT)
|
||||||
|
)
|
||||||
else
|
else
|
||||||
builtinKeyboard.shift = false
|
builtinKeyboard.shift = false
|
||||||
builtinKeyboard.changeKeyboard(keyboard)
|
builtinKeyboard.changeKeyboard(keyboard)
|
||||||
@ -158,7 +173,10 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
|
|||||||
mActivity.onKeyUp(key, KeyEvent(KeyEvent.ACTION_UP, key))
|
mActivity.onKeyUp(key, KeyEvent(KeyEvent.ACTION_UP, key))
|
||||||
|
|
||||||
if (shifted) {
|
if (shifted) {
|
||||||
mActivity.onKeyUp(KeyEvent.KEYCODE_SHIFT_LEFT, KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT))
|
mActivity.onKeyUp(
|
||||||
|
KeyEvent.KEYCODE_SHIFT_LEFT,
|
||||||
|
KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT)
|
||||||
|
)
|
||||||
builtinKeyboard.stickyKeys.remove(KeyEvent.KEYCODE_SHIFT_LEFT)
|
builtinKeyboard.stickyKeys.remove(KeyEvent.KEYCODE_SHIFT_LEFT)
|
||||||
for (k in builtinKeyboard.keyboard.keys) {
|
for (k in builtinKeyboard.keyboard.keys) {
|
||||||
if (k.sticky && k.codes[0] == KeyEvent.KEYCODE_SHIFT_LEFT && k.on) {
|
if (k.sticky && k.codes[0] == KeyEvent.KEYCODE_SHIFT_LEFT && k.on) {
|
||||||
@ -182,7 +200,11 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
|
|||||||
override fun onKey(p1: Int, p2: IntArray) {}
|
override fun onKey(p1: Int, p2: IntArray) {}
|
||||||
})
|
})
|
||||||
mSessionData.screenKeyboard = builtinKeyboard
|
mSessionData.screenKeyboard = builtinKeyboard
|
||||||
val layout = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM)
|
val layout = FrameLayout.LayoutParams(
|
||||||
|
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||||
|
FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||||
|
Gravity.BOTTOM
|
||||||
|
)
|
||||||
mSessionData.videoLayout!!.addView(mSessionData.screenKeyboard, layout)
|
mSessionData.videoLayout!!.addView(mSessionData.screenKeyboard, layout)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -220,10 +242,12 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
|
|||||||
if (mSessionData.screenKeyboard != null)
|
if (mSessionData.screenKeyboard != null)
|
||||||
return
|
return
|
||||||
|
|
||||||
val screenKeyboard = EditText(mActivity, null,
|
val screenKeyboard = EditText(
|
||||||
|
mActivity, null,
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP)
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP)
|
||||||
android.R.style.TextAppearance_Material_Widget_EditText
|
android.R.style.TextAppearance_Material_Widget_EditText
|
||||||
else android.R.style.TextAppearance_Widget_EditText)
|
else android.R.style.TextAppearance_Widget_EditText
|
||||||
|
)
|
||||||
|
|
||||||
val hint = mSessionData.screenKeyboardHintMessage
|
val hint = mSessionData.screenKeyboardHintMessage
|
||||||
screenKeyboard.hint = hint ?: mActivity.getString(R.string.text_edit_click_here)
|
screenKeyboard.hint = hint ?: mActivity.getString(R.string.text_edit_click_here)
|
||||||
@ -243,8 +267,26 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
|
|||||||
screenKeyboard.isFocusable = true
|
screenKeyboard.isFocusable = true
|
||||||
screenKeyboard.postDelayed({
|
screenKeyboard.postDelayed({
|
||||||
screenKeyboard.requestFocus()
|
screenKeyboard.requestFocus()
|
||||||
screenKeyboard.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 0f, 0f, 0))
|
screenKeyboard.dispatchTouchEvent(
|
||||||
screenKeyboard.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, 0f, 0f, 0))
|
MotionEvent.obtain(
|
||||||
|
SystemClock.uptimeMillis(),
|
||||||
|
SystemClock.uptimeMillis(),
|
||||||
|
MotionEvent.ACTION_DOWN,
|
||||||
|
0f,
|
||||||
|
0f,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
screenKeyboard.dispatchTouchEvent(
|
||||||
|
MotionEvent.obtain(
|
||||||
|
SystemClock.uptimeMillis(),
|
||||||
|
SystemClock.uptimeMillis(),
|
||||||
|
MotionEvent.ACTION_UP,
|
||||||
|
0f,
|
||||||
|
0f,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
)
|
||||||
screenKeyboard.postDelayed({
|
screenKeyboard.postDelayed({
|
||||||
screenKeyboard.requestFocus()
|
screenKeyboard.requestFocus()
|
||||||
screenKeyboard.setSelection(screenKeyboard.text.length)
|
screenKeyboard.setSelection(screenKeyboard.text.length)
|
||||||
@ -279,7 +321,8 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
|
|||||||
override fun updateScreenOrientation() {
|
override fun updateScreenOrientation() {
|
||||||
var rotation: Int = windowManager.defaultDisplay.rotation
|
var rotation: Int = windowManager.defaultDisplay.rotation
|
||||||
NeoAccelerometerReader.setGyroInvertedOrientation(
|
NeoAccelerometerReader.setGyroInvertedOrientation(
|
||||||
rotation == Surface.ROTATION_180 || rotation == Surface.ROTATION_270)
|
rotation == Surface.ROTATION_180 || rotation == Surface.ROTATION_270
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initScreenOrientation() {
|
override fun initScreenOrientation() {
|
||||||
@ -306,9 +349,11 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
|
|||||||
|
|
||||||
override fun setSystemMousePointerVisible(visible: Int) {
|
override fun setSystemMousePointerVisible(visible: Int) {
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||||
glView?.pointerIcon = android.view.PointerIcon.getSystemIcon(mActivity,
|
glView?.pointerIcon = android.view.PointerIcon.getSystemIcon(
|
||||||
|
mActivity,
|
||||||
if (visible == 0) android.view.PointerIcon.TYPE_NULL
|
if (visible == 0) android.view.PointerIcon.TYPE_NULL
|
||||||
else android.view.PointerIcon.TYPE_DEFAULT)
|
else android.view.PointerIcon.TYPE_DEFAULT
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,7 +370,8 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
|
|||||||
keyCode == KeyEvent.KEYCODE_BUTTON_1 ||
|
keyCode == KeyEvent.KEYCODE_BUTTON_1 ||
|
||||||
keyCode == KeyEvent.KEYCODE_BUTTON_2 ||
|
keyCode == KeyEvent.KEYCODE_BUTTON_2 ||
|
||||||
keyCode == KeyEvent.KEYCODE_BUTTON_3 ||
|
keyCode == KeyEvent.KEYCODE_BUTTON_3 ||
|
||||||
keyCode == KeyEvent.KEYCODE_BUTTON_4)) {
|
keyCode == KeyEvent.KEYCODE_BUTTON_4)
|
||||||
|
) {
|
||||||
client.hideScreenKeyboard()
|
client.hideScreenKeyboard()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -343,7 +389,8 @@ class XSession constructor(private val mActivity: AppCompatActivity, val mSessio
|
|||||||
return false
|
return false
|
||||||
if (ev.action == MotionEvent.ACTION_DOWN || ev.action == MotionEvent.ACTION_UP || ev.action == MotionEvent.ACTION_MOVE) {
|
if (ev.action == MotionEvent.ACTION_DOWN || ev.action == MotionEvent.ACTION_UP || ev.action == MotionEvent.ACTION_MOVE) {
|
||||||
// Convert pointer coords, this will lose multitiouch data, however KeyboardView does not support multitouch anyway
|
// Convert pointer coords, this will lose multitiouch data, however KeyboardView does not support multitouch anyway
|
||||||
val converted = MotionEvent.obtain(ev.downTime, ev.eventTime, ev.action, ev.x, ev.y - top.toFloat(), ev.metaState)
|
val converted =
|
||||||
|
MotionEvent.obtain(ev.downTime, ev.eventTime, ev.action, ev.x, ev.y - top.toFloat(), ev.metaState)
|
||||||
return super.dispatchTouchEvent(converted)
|
return super.dispatchTouchEvent(converted)
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -4,12 +4,7 @@ import android.graphics.Canvas;
|
|||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
|
import io.neoterm.backend.*;
|
||||||
import io.neoterm.backend.TerminalBuffer;
|
|
||||||
import io.neoterm.backend.TerminalEmulator;
|
|
||||||
import io.neoterm.backend.TerminalRow;
|
|
||||||
import io.neoterm.backend.TextStyle;
|
|
||||||
import io.neoterm.backend.WcWidth;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderer of a {@link TerminalEmulator} into a {@link Canvas}.
|
* Renderer of a {@link TerminalEmulator} into a {@link Canvas}.
|
||||||
@ -22,16 +17,26 @@ final class TerminalRenderer {
|
|||||||
final Typeface mTypeface;
|
final Typeface mTypeface;
|
||||||
private final Paint mTextPaint = new Paint();
|
private final Paint mTextPaint = new Paint();
|
||||||
|
|
||||||
/** The width of a single mono spaced character obtained by {@link Paint#measureText(String)} on a single 'X'. */
|
/**
|
||||||
|
* The width of a single mono spaced character obtained by {@link Paint#measureText(String)} on a single 'X'.
|
||||||
|
*/
|
||||||
final float mFontWidth;
|
final float mFontWidth;
|
||||||
/** The {@link Paint#getFontSpacing()}. See http://www.fampennings.nl/maarten/android/08numgrid/font.png */
|
/**
|
||||||
|
* The {@link Paint#getFontSpacing()}. See http://www.fampennings.nl/maarten/android/08numgrid/font.png
|
||||||
|
*/
|
||||||
final int mFontLineSpacing;
|
final int mFontLineSpacing;
|
||||||
/** The {@link Paint#ascent()}. See http://www.fampennings.nl/maarten/android/08numgrid/font.png */
|
/**
|
||||||
|
* The {@link Paint#ascent()}. See http://www.fampennings.nl/maarten/android/08numgrid/font.png
|
||||||
|
*/
|
||||||
private final int mFontAscent;
|
private final int mFontAscent;
|
||||||
/** The {@link #mFontLineSpacing} + {@link #mFontAscent}. */
|
/**
|
||||||
|
* The {@link #mFontLineSpacing} + {@link #mFontAscent}.
|
||||||
|
*/
|
||||||
final int mFontLineSpacingAndAscent;
|
final int mFontLineSpacingAndAscent;
|
||||||
|
|
||||||
/** AutoCompletion PopupWindow need them to show popup window */
|
/**
|
||||||
|
* AutoCompletion PopupWindow need them to show popup window
|
||||||
|
*/
|
||||||
protected float savedLastDrawnLineX;
|
protected float savedLastDrawnLineX;
|
||||||
protected float savedLastDrawnLineY;
|
protected float savedLastDrawnLineY;
|
||||||
|
|
||||||
@ -57,7 +62,9 @@ final class TerminalRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Render the terminal to a canvas with at a specified row scroll, and an optional rectangular selection. */
|
/**
|
||||||
|
* Render the terminal to a canvas with at a specified row scroll, and an optional rectangular selection.
|
||||||
|
*/
|
||||||
public final void render(TerminalEmulator mEmulator, Canvas canvas, int topRow,
|
public final void render(TerminalEmulator mEmulator, Canvas canvas, int topRow,
|
||||||
int selectionY1, int selectionY2, int selectionX1, int selectionX2) {
|
int selectionY1, int selectionY2, int selectionX1, int selectionX2) {
|
||||||
final boolean reverseVideo = mEmulator.isReverseVideo();
|
final boolean reverseVideo = mEmulator.isReverseVideo();
|
||||||
|
@ -15,27 +15,14 @@ import android.text.InputType;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.ActionMode;
|
import android.view.*;
|
||||||
import android.view.HapticFeedbackConstants;
|
|
||||||
import android.view.InputDevice;
|
|
||||||
import android.view.KeyCharacterMap;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
import android.view.inputmethod.BaseInputConnection;
|
import android.view.inputmethod.BaseInputConnection;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputConnection;
|
import android.view.inputmethod.InputConnection;
|
||||||
import android.widget.Scroller;
|
import android.widget.Scroller;
|
||||||
|
|
||||||
import io.neoterm.R;
|
import io.neoterm.R;
|
||||||
import io.neoterm.backend.EmulatorDebug;
|
import io.neoterm.backend.*;
|
||||||
import io.neoterm.backend.KeyHandler;
|
|
||||||
import io.neoterm.backend.TerminalBuffer;
|
|
||||||
import io.neoterm.backend.TerminalEmulator;
|
|
||||||
import io.neoterm.backend.TerminalSession;
|
|
||||||
import io.neoterm.frontend.completion.listener.OnAutoCompleteListener;
|
import io.neoterm.frontend.completion.listener.OnAutoCompleteListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,7 +3,6 @@ package io.neoterm.frontend.terminal;
|
|||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.ScaleGestureDetector;
|
import android.view.ScaleGestureDetector;
|
||||||
|
|
||||||
import io.neoterm.backend.TerminalSession;
|
import io.neoterm.backend.TerminalSession;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,8 +166,10 @@ class ExtraKeysView(context: Context, attrs: AttributeSet) : LinearLayout(contex
|
|||||||
if (NeoPreference.isExplicitExtraKeysWeightEnabled())
|
if (NeoPreference.isExplicitExtraKeysWeightEnabled())
|
||||||
LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f)
|
LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f)
|
||||||
else
|
else
|
||||||
LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
LinearLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT)
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
|
)
|
||||||
|
|
||||||
layoutParams.setMargins(0, 0, 0, 0)
|
layoutParams.setMargins(0, 0, 0, 0)
|
||||||
line.setPadding(0, 0, 0, 0)
|
line.setPadding(0, 0, 0, 0)
|
||||||
|
@ -3,10 +3,10 @@ package io.neoterm.frontend.terminal.extrakey.button
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import androidx.appcompat.widget.AppCompatButton
|
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
|
import androidx.appcompat.widget.AppCompatButton
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,8 +18,8 @@ open class RepeatableButton(buttonText: String) : ControlButton(buttonText) {
|
|||||||
return RepeatableButtonWidget(context, attrs, defStyleAttr)
|
return RepeatableButtonWidget(context, attrs, defStyleAttr)
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RepeatableButtonWidget(context: Context?, attrs: AttributeSet?, defStyleAttr: Int)
|
private class RepeatableButtonWidget(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) :
|
||||||
: AppCompatButton(context!!, attrs, defStyleAttr) {
|
AppCompatButton(context!!, attrs, defStyleAttr) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Milliseconds how long we trigger an action
|
* Milliseconds how long we trigger an action
|
||||||
|
@ -10,7 +10,8 @@ import android.widget.ToggleButton
|
|||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
|
|
||||||
open class StatedControlButton @JvmOverloads constructor(text: String, var initState: Boolean = false) : ControlButton(text) {
|
open class StatedControlButton @JvmOverloads constructor(text: String, var initState: Boolean = false) :
|
||||||
|
ControlButton(text) {
|
||||||
var toggleButton: ToggleButton? = null
|
var toggleButton: ToggleButton? = null
|
||||||
|
|
||||||
override fun onClick(view: View) {
|
override fun onClick(view: View) {
|
||||||
|
@ -9,8 +9,8 @@ import android.os.Binder
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import androidx.core.app.NotificationCompat
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.app.NotificationCompat
|
||||||
import io.neoterm.R
|
import io.neoterm.R
|
||||||
import io.neoterm.backend.EmulatorDebug
|
import io.neoterm.backend.EmulatorDebug
|
||||||
import io.neoterm.backend.TerminalSession
|
import io.neoterm.backend.TerminalSession
|
||||||
@ -156,7 +156,11 @@ class NeoTermService : Service() {
|
|||||||
builder.priority = if (lockAcquired) Notification.PRIORITY_HIGH else Notification.PRIORITY_LOW
|
builder.priority = if (lockAcquired) Notification.PRIORITY_HIGH else Notification.PRIORITY_LOW
|
||||||
|
|
||||||
val exitIntent = Intent(this, NeoTermService::class.java).setAction(ACTION_SERVICE_STOP)
|
val exitIntent = Intent(this, NeoTermService::class.java).setAction(ACTION_SERVICE_STOP)
|
||||||
builder.addAction(android.R.drawable.ic_delete, getString(R.string.exit), PendingIntent.getService(this, 0, exitIntent, 0))
|
builder.addAction(
|
||||||
|
android.R.drawable.ic_delete,
|
||||||
|
getString(R.string.exit),
|
||||||
|
PendingIntent.getService(this, 0, exitIntent, 0)
|
||||||
|
)
|
||||||
|
|
||||||
val newWakeAction = if (lockAcquired) ACTION_RELEASE_LOCK else ACTION_ACQUIRE_LOCK
|
val newWakeAction = if (lockAcquired) ACTION_RELEASE_LOCK else ACTION_ACQUIRE_LOCK
|
||||||
val toggleWakeLockIntent = Intent(this, NeoTermService::class.java).setAction(newWakeAction)
|
val toggleWakeLockIntent = Intent(this, NeoTermService::class.java).setAction(newWakeAction)
|
||||||
@ -164,7 +168,8 @@ class NeoTermService : Service() {
|
|||||||
if (lockAcquired)
|
if (lockAcquired)
|
||||||
R.string.service_release_lock
|
R.string.service_release_lock
|
||||||
else
|
else
|
||||||
R.string.service_acquire_lock)
|
R.string.service_acquire_lock
|
||||||
|
)
|
||||||
val actionIcon = if (lockAcquired) android.R.drawable.ic_lock_idle_lock else android.R.drawable.ic_lock_lock
|
val actionIcon = if (lockAcquired) android.R.drawable.ic_lock_idle_lock else android.R.drawable.ic_lock_lock
|
||||||
builder.addAction(actionIcon, actionTitle, PendingIntent.getService(this, 0, toggleWakeLockIntent, 0))
|
builder.addAction(actionIcon, actionTitle, PendingIntent.getService(this, 0, toggleWakeLockIntent, 0))
|
||||||
|
|
||||||
@ -184,8 +189,10 @@ class NeoTermService : Service() {
|
|||||||
private fun acquireLock() {
|
private fun acquireLock() {
|
||||||
if (mWakeLock == null) {
|
if (mWakeLock == null) {
|
||||||
val pm = getSystemService(Context.POWER_SERVICE) as PowerManager
|
val pm = getSystemService(Context.POWER_SERVICE) as PowerManager
|
||||||
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
mWakeLock = pm.newWakeLock(
|
||||||
EmulatorDebug.LOG_TAG + ":")
|
PowerManager.PARTIAL_WAKE_LOCK,
|
||||||
|
EmulatorDebug.LOG_TAG + ":"
|
||||||
|
)
|
||||||
mWakeLock!!.acquire()
|
mWakeLock!!.acquire()
|
||||||
|
|
||||||
val wm = applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
|
val wm = applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package io.neoterm.setup
|
package io.neoterm.setup
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import android.app.ProgressDialog
|
import android.app.ProgressDialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import io.neoterm.App
|
import io.neoterm.App
|
||||||
import io.neoterm.R
|
import io.neoterm.R
|
||||||
import io.neoterm.frontend.config.NeoTermPath
|
import io.neoterm.frontend.config.NeoTermPath
|
||||||
@ -20,8 +20,10 @@ object SetupHelper {
|
|||||||
return !PREFIX_FILE.isDirectory
|
return !PREFIX_FILE.isDirectory
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setup(activity: AppCompatActivity, connection: SourceConnection,
|
fun setup(
|
||||||
resultListener: ResultListener) {
|
activity: AppCompatActivity, connection: SourceConnection,
|
||||||
|
resultListener: ResultListener
|
||||||
|
) {
|
||||||
if (!needSetup()) {
|
if (!needSetup()) {
|
||||||
resultListener.onResult(null)
|
resultListener.onResult(null)
|
||||||
return
|
return
|
||||||
@ -71,7 +73,9 @@ object SetupHelper {
|
|||||||
"x86_64" -> return "x86_64"
|
"x86_64" -> return "x86_64"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw RuntimeException("Unable to determine arch from Build.SUPPORTED_ABIS = "
|
throw RuntimeException(
|
||||||
+ Arrays.toString(Build.SUPPORTED_ABIS))
|
"Unable to determine arch from Build.SUPPORTED_ABIS = "
|
||||||
|
+ Arrays.toString(Build.SUPPORTED_ABIS)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,19 @@
|
|||||||
package io.neoterm.setup;
|
package io.neoterm.setup;
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import android.system.Os;
|
import android.system.Os;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import io.neoterm.backend.EmulatorDebug;
|
||||||
|
import io.neoterm.frontend.config.NeoTermPath;
|
||||||
|
import io.neoterm.frontend.logging.NLog;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.*;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
import io.neoterm.backend.EmulatorDebug;
|
|
||||||
import io.neoterm.frontend.config.NeoTermPath;
|
|
||||||
import io.neoterm.frontend.logging.NLog;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
|
@ -12,11 +12,11 @@ import android.graphics.drawable.RippleDrawable
|
|||||||
import android.graphics.drawable.ShapeDrawable
|
import android.graphics.drawable.ShapeDrawable
|
||||||
import android.graphics.drawable.shapes.OvalShape
|
import android.graphics.drawable.shapes.OvalShape
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.view.animation.PathInterpolator
|
import android.view.animation.PathInterpolator
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import io.neoterm.R
|
import io.neoterm.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,14 +36,17 @@ class BonusActivity : AppCompatActivity() {
|
|||||||
lollipopBackground.paint.color = FLAVORS[idx]
|
lollipopBackground.paint.color = FLAVORS[idx]
|
||||||
return RippleDrawable(
|
return RippleDrawable(
|
||||||
ColorStateList.valueOf(FLAVORS[idx + 1]),
|
ColorStateList.valueOf(FLAVORS[idx + 1]),
|
||||||
lollipopBackground, null)
|
lollipopBackground, null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
mLayout = FrameLayout(this)
|
mLayout = FrameLayout(this)
|
||||||
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
window.setFlags(
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||||
|
WindowManager.LayoutParams.FLAG_FULLSCREEN
|
||||||
|
)
|
||||||
setContentView(mLayout)
|
setContentView(mLayout)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,8 +88,12 @@ class BonusActivity : AppCompatActivity() {
|
|||||||
c.drawPath(mShadow, mPaint)
|
c.drawPath(mShadow, mPaint)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mLayout.addView(stick, FrameLayout.LayoutParams((32 * dp).toInt(),
|
mLayout.addView(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER_HORIZONTAL))
|
stick, FrameLayout.LayoutParams(
|
||||||
|
(32 * dp).toInt(),
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER_HORIZONTAL
|
||||||
|
)
|
||||||
|
)
|
||||||
stick.alpha = 0f
|
stick.alpha = 0f
|
||||||
|
|
||||||
val im = ImageView(this)
|
val im = ImageView(this)
|
||||||
@ -100,8 +107,10 @@ class BonusActivity : AppCompatActivity() {
|
|||||||
im.isClickable = true
|
im.isClickable = true
|
||||||
val highlight = ShapeDrawable(OvalShape())
|
val highlight = ShapeDrawable(OvalShape())
|
||||||
highlight.paint.color = 0x10FFFFFF
|
highlight.paint.color = 0x10FFFFFF
|
||||||
highlight.setBounds((size * .15f).toInt(), (size * .15f).toInt(),
|
highlight.setBounds(
|
||||||
(size * .6f).toInt(), (size * .6f).toInt())
|
(size * .15f).toInt(), (size * .15f).toInt(),
|
||||||
|
(size * .6f).toInt(), (size * .6f).toInt()
|
||||||
|
)
|
||||||
im.overlay.add(highlight)
|
im.overlay.add(highlight)
|
||||||
im.setOnClickListener {
|
im.setOnClickListener {
|
||||||
if (mTapCount == 0) {
|
if (mTapCount == 0) {
|
||||||
@ -161,11 +170,13 @@ class BonusActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
internal val FLAVORS = intArrayOf(0xFF9C27B0.toInt(), 0xFFBA68C8.toInt(), // grape
|
internal val FLAVORS = intArrayOf(
|
||||||
|
0xFF9C27B0.toInt(), 0xFFBA68C8.toInt(), // grape
|
||||||
0xFFFF9800.toInt(), 0xFFFFB74D.toInt(), // orange
|
0xFFFF9800.toInt(), 0xFFFFB74D.toInt(), // orange
|
||||||
0xFFF06292.toInt(), 0xFFF8BBD0.toInt(), // bubblegum
|
0xFFF06292.toInt(), 0xFFF8BBD0.toInt(), // bubblegum
|
||||||
0xFFAFB42B.toInt(), 0xFFCDDC39.toInt(), // lime
|
0xFFAFB42B.toInt(), 0xFFCDDC39.toInt(), // lime
|
||||||
0xFF795548.toInt(), 0xFFA1887F.toInt())// mystery flavor
|
0xFF795548.toInt(), 0xFFA1887F.toInt()
|
||||||
|
)// mystery flavor
|
||||||
|
|
||||||
internal fun newColorIndex(): Int {
|
internal fun newColorIndex(): Int {
|
||||||
return 2 * (Math.random() * FLAVORS.size / 2).toInt()
|
return 2 * (Math.random() * FLAVORS.size / 2).toInt()
|
||||||
|
@ -2,8 +2,8 @@ package io.neoterm.ui.crash
|
|||||||
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import io.neoterm.R
|
import io.neoterm.R
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.PrintStream
|
import java.io.PrintStream
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package io.neoterm.ui.customize
|
package io.neoterm.ui.customize
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.view.MenuItem
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
import android.view.MenuItem
|
|
||||||
import io.neoterm.R
|
import io.neoterm.R
|
||||||
import io.neoterm.backend.TerminalSession
|
import io.neoterm.backend.TerminalSession
|
||||||
import io.neoterm.frontend.config.NeoTermPath
|
import io.neoterm.frontend.config.NeoTermPath
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package io.neoterm.ui.customize
|
package io.neoterm.ui.customize
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
@ -13,6 +10,8 @@ import android.view.MenuItem
|
|||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.github.wrdlbrnft.sortedlistadapter.SortedListAdapter
|
import com.github.wrdlbrnft.sortedlistadapter.SortedListAdapter
|
||||||
import es.dmoral.coloromatic.ColorOMaticDialog
|
import es.dmoral.coloromatic.ColorOMaticDialog
|
||||||
import es.dmoral.coloromatic.IndicatorMode
|
import es.dmoral.coloromatic.IndicatorMode
|
||||||
|
@ -9,13 +9,16 @@ import io.neoterm.R
|
|||||||
import io.neoterm.component.colorscheme.NeoColorScheme
|
import io.neoterm.component.colorscheme.NeoColorScheme
|
||||||
import io.neoterm.ui.customize.adapter.holder.ColorItemViewHolder
|
import io.neoterm.ui.customize.adapter.holder.ColorItemViewHolder
|
||||||
import io.neoterm.ui.customize.model.ColorItem
|
import io.neoterm.ui.customize.model.ColorItem
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
class ColorItemAdapter(context: Context, initColorScheme: NeoColorScheme, comparator: Comparator<ColorItem>, private val listener: ColorItemAdapter.Listener)
|
class ColorItemAdapter(
|
||||||
: SortedListAdapter<ColorItem>(context, ColorItem::class.java, comparator), FastScrollRecyclerView.SectionedAdapter {
|
context: Context,
|
||||||
|
initColorScheme: NeoColorScheme,
|
||||||
|
comparator: Comparator<ColorItem>,
|
||||||
|
private val listener: ColorItemAdapter.Listener
|
||||||
|
) : SortedListAdapter<ColorItem>(context, ColorItem::class.java, comparator), FastScrollRecyclerView.SectionedAdapter {
|
||||||
|
|
||||||
val colorList = mutableListOf<ColorItem>()
|
val colorList = mutableListOf<ColorItem>()
|
||||||
|
|
||||||
@ -35,7 +38,11 @@ class ColorItemAdapter(context: Context, initColorScheme: NeoColorScheme, compar
|
|||||||
return colorList[position].colorName[0].toString()
|
return colorList[position].colorName[0].toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup, viewType: Int): SortedListAdapter.ViewHolder<out ColorItem> {
|
override fun onCreateViewHolder(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
parent: ViewGroup,
|
||||||
|
viewType: Int
|
||||||
|
): SortedListAdapter.ViewHolder<out ColorItem> {
|
||||||
val rootView = inflater.inflate(R.layout.item_color, parent, false)
|
val rootView = inflater.inflate(R.layout.item_color, parent, false)
|
||||||
return ColorItemViewHolder(rootView, listener)
|
return ColorItemViewHolder(rootView, listener)
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,8 @@ import io.neoterm.backend.TerminalColors
|
|||||||
import io.neoterm.ui.customize.adapter.ColorItemAdapter
|
import io.neoterm.ui.customize.adapter.ColorItemAdapter
|
||||||
import io.neoterm.ui.customize.model.ColorItem
|
import io.neoterm.ui.customize.model.ColorItem
|
||||||
|
|
||||||
class ColorItemViewHolder(private val rootView: View, private val listener: ColorItemAdapter.Listener) : SortedListAdapter.ViewHolder<ColorItem>(rootView) {
|
class ColorItemViewHolder(private val rootView: View, private val listener: ColorItemAdapter.Listener) :
|
||||||
|
SortedListAdapter.ViewHolder<ColorItem>(rootView) {
|
||||||
private val colorItemName: TextView = rootView.findViewById<TextView>(R.id.color_item_name)
|
private val colorItemName: TextView = rootView.findViewById<TextView>(R.id.color_item_name)
|
||||||
private val colorItemDesc: TextView = rootView.findViewById<TextView>(R.id.color_item_description)
|
private val colorItemDesc: TextView = rootView.findViewById<TextView>(R.id.color_item_description)
|
||||||
private val colorView: View = rootView.findViewById<View>(R.id.color_item_view)
|
private val colorView: View = rootView.findViewById<View>(R.id.color_item_view)
|
||||||
|
@ -2,19 +2,18 @@ package io.neoterm.ui.pm
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.core.view.MenuItemCompat
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import androidx.appcompat.widget.SearchView
|
|
||||||
import androidx.appcompat.widget.Toolbar
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.appcompat.widget.SearchView
|
||||||
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
import androidx.core.view.MenuItemCompat
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.github.wrdlbrnft.sortedlistadapter.SortedListAdapter
|
import com.github.wrdlbrnft.sortedlistadapter.SortedListAdapter
|
||||||
import io.neoterm.R
|
import io.neoterm.R
|
||||||
import io.neoterm.backend.TerminalSession
|
import io.neoterm.backend.TerminalSession
|
||||||
@ -77,8 +76,10 @@ class PackageManagerActivity : AppCompatActivity(), SearchView.OnQueryTextListen
|
|||||||
private fun installPackage(packageName: String?) {
|
private fun installPackage(packageName: String?) {
|
||||||
if (packageName != null) {
|
if (packageName != null) {
|
||||||
TerminalDialog(this@PackageManagerActivity)
|
TerminalDialog(this@PackageManagerActivity)
|
||||||
.execute(NeoTermPath.APT_BIN_PATH,
|
.execute(
|
||||||
arrayOf("apt", "install", "-y", packageName))
|
NeoTermPath.APT_BIN_PATH,
|
||||||
|
arrayOf("apt", "install", "-y", packageName)
|
||||||
|
)
|
||||||
.onFinish(object : TerminalDialog.SessionFinishedCallback {
|
.onFinish(object : TerminalDialog.SessionFinishedCallback {
|
||||||
override fun onSessionFinished(dialog: TerminalDialog, finishedSession: TerminalSession?) {
|
override fun onSessionFinished(dialog: TerminalDialog, finishedSession: TerminalSession?) {
|
||||||
dialog.setTitle(getString(R.string.done))
|
dialog.setTitle(getString(R.string.done))
|
||||||
@ -197,7 +198,7 @@ class PackageManagerActivity : AppCompatActivity(), SearchView.OnQueryTextListen
|
|||||||
}
|
}
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
|
|
||||||
PackageUtils.apt(this, "upgrade", arrayOf("-y"), out@ { exitStatus, dialog ->
|
PackageUtils.apt(this, "upgrade", arrayOf("-y"), out@{ exitStatus, dialog ->
|
||||||
if (exitStatus != 0) {
|
if (exitStatus != 0) {
|
||||||
dialog.setTitle(getString(R.string.error))
|
dialog.setTitle(getString(R.string.error))
|
||||||
return@out
|
return@out
|
||||||
@ -230,8 +231,10 @@ class PackageManagerActivity : AppCompatActivity(), SearchView.OnQueryTextListen
|
|||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sortDistance(models: List<PackageModel>, query: String,
|
private fun sortDistance(
|
||||||
mapper: (NeoPackageInfo) -> String): List<Pair<PackageModel, Int>> {
|
models: List<PackageModel>, query: String,
|
||||||
|
mapper: (NeoPackageInfo) -> String
|
||||||
|
): List<Pair<PackageModel, Int>> {
|
||||||
return models
|
return models
|
||||||
.map({
|
.map({
|
||||||
Pair(it, StringDistance.distance(mapper(it.packageInfo).toLowerCase(), query.toLowerCase()))
|
Pair(it, StringDistance.distance(mapper(it.packageInfo).toLowerCase(), query.toLowerCase()))
|
||||||
|
@ -8,9 +8,13 @@ import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
|||||||
import io.neoterm.R
|
import io.neoterm.R
|
||||||
import io.neoterm.ui.pm.adapter.holder.PackageViewHolder
|
import io.neoterm.ui.pm.adapter.holder.PackageViewHolder
|
||||||
import io.neoterm.ui.pm.model.PackageModel
|
import io.neoterm.ui.pm.model.PackageModel
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class PackageAdapter(context: Context, comparator: Comparator<PackageModel>, private val listener: PackageAdapter.Listener) : SortedListAdapter<PackageModel>(context, PackageModel::class.java, comparator), FastScrollRecyclerView.SectionedAdapter {
|
class PackageAdapter(
|
||||||
|
context: Context,
|
||||||
|
comparator: Comparator<PackageModel>,
|
||||||
|
private val listener: PackageAdapter.Listener
|
||||||
|
) : SortedListAdapter<PackageModel>(context, PackageModel::class.java, comparator),
|
||||||
|
FastScrollRecyclerView.SectionedAdapter {
|
||||||
|
|
||||||
override fun getSectionName(position: Int): String {
|
override fun getSectionName(position: Int): String {
|
||||||
return getItem(position).packageInfo.packageName?.substring(0, 1) ?: "#"
|
return getItem(position).packageInfo.packageName?.substring(0, 1) ?: "#"
|
||||||
@ -20,7 +24,11 @@ class PackageAdapter(context: Context, comparator: Comparator<PackageModel>, pri
|
|||||||
fun onModelClicked(model: PackageModel)
|
fun onModelClicked(model: PackageModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup, viewType: Int): SortedListAdapter.ViewHolder<out PackageModel> {
|
override fun onCreateViewHolder(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
parent: ViewGroup,
|
||||||
|
viewType: Int
|
||||||
|
): SortedListAdapter.ViewHolder<out PackageModel> {
|
||||||
val rootView = inflater.inflate(R.layout.item_package, parent, false)
|
val rootView = inflater.inflate(R.layout.item_package, parent, false)
|
||||||
return PackageViewHolder(rootView, listener)
|
return PackageViewHolder(rootView, listener)
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,8 @@ import io.neoterm.R
|
|||||||
import io.neoterm.ui.pm.adapter.PackageAdapter
|
import io.neoterm.ui.pm.adapter.PackageAdapter
|
||||||
import io.neoterm.ui.pm.model.PackageModel
|
import io.neoterm.ui.pm.model.PackageModel
|
||||||
|
|
||||||
class PackageViewHolder(private val rootView: View, private val listener: PackageAdapter.Listener) : SortedListAdapter.ViewHolder<PackageModel>(rootView) {
|
class PackageViewHolder(private val rootView: View, private val listener: PackageAdapter.Listener) :
|
||||||
|
SortedListAdapter.ViewHolder<PackageModel>(rootView) {
|
||||||
private val packageNameView: TextView = rootView.findViewById(R.id.package_item_name)
|
private val packageNameView: TextView = rootView.findViewById(R.id.package_item_name)
|
||||||
private val packageDescView: TextView = rootView.findViewById(R.id.package_item_desc)
|
private val packageDescView: TextView = rootView.findViewById(R.id.package_item_desc)
|
||||||
|
|
||||||
|
@ -24,10 +24,12 @@ class PackageModel(val packageInfo: NeoPackageInfo) : SortedListAdapter.ViewMode
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getPackageDetails(context: Context): String {
|
fun getPackageDetails(context: Context): String {
|
||||||
return context.getString(R.string.package_details,
|
return context.getString(
|
||||||
|
R.string.package_details,
|
||||||
packageInfo.packageName, packageInfo.version,
|
packageInfo.packageName, packageInfo.version,
|
||||||
packageInfo.dependenciesString,
|
packageInfo.dependenciesString,
|
||||||
FileUtils.formatSizeInKB(packageInfo.installedSizeInBytes),
|
FileUtils.formatSizeInKB(packageInfo.installedSizeInBytes),
|
||||||
packageInfo.description, packageInfo.homePage)
|
packageInfo.description, packageInfo.homePage
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,19 +22,18 @@ import android.content.res.ColorStateList;
|
|||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import androidx.core.view.ViewCompat;
|
|
||||||
import androidx.viewpager.widget.ViewPager;
|
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
|
||||||
import androidx.appcompat.widget.AppCompatTextView;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
|
import androidx.appcompat.widget.AppCompatTextView;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
import io.neoterm.R;
|
import io.neoterm.R;
|
||||||
|
|
||||||
public class RecyclerTabLayout extends RecyclerView {
|
public class RecyclerTabLayout extends RecyclerView {
|
||||||
@ -264,7 +263,7 @@ public class RecyclerTabLayout extends RecyclerView {
|
|||||||
if (position == 0) {
|
if (position == 0) {
|
||||||
float indicatorGap = (nextView.getMeasuredWidth() - selectedView.getMeasuredWidth()) / 2;
|
float indicatorGap = (nextView.getMeasuredWidth() - selectedView.getMeasuredWidth()) / 2;
|
||||||
mIndicatorGap = (int) (indicatorGap * positionOffset);
|
mIndicatorGap = (int) (indicatorGap * positionOffset);
|
||||||
mIndicatorScroll = (int)((selectedView.getMeasuredWidth() + indicatorGap) * positionOffset);
|
mIndicatorScroll = (int) ((selectedView.getMeasuredWidth() + indicatorGap) * positionOffset);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
float indicatorGap = (nextView.getMeasuredWidth() - selectedView.getMeasuredWidth()) / 2;
|
float indicatorGap = (nextView.getMeasuredWidth() - selectedView.getMeasuredWidth()) / 2;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user