Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc086a1e0b | ||
|
|
2a056aeb2e | ||
|
|
9e70ebc2a6 | ||
|
|
9686127f81 | ||
|
|
395c36ee83 | ||
|
|
906ff24e76 | ||
|
|
c8af974852 | ||
|
|
481339e2f5 | ||
|
|
b2ecae63a8 | ||
|
|
a67f798f2f | ||
|
|
d69485b70b | ||
|
|
421dfcca39 | ||
|
|
3aaa0ab267 | ||
|
|
e7f9647beb | ||
|
|
5558f371b4 | ||
|
|
0882ed6470 | ||
|
|
5c02448521 | ||
|
|
17382fb190 | ||
|
|
d6eea83bfc | ||
|
|
51181c2d49 | ||
|
|
480b8a4f7e | ||
|
|
f989157f10 | ||
|
|
0e942f90a6 | ||
|
|
5b8eca46a1 | ||
|
|
493900d60b | ||
|
|
c6d6a63637 | ||
|
|
ca71265f23 | ||
|
|
46c9c4b80e |
@@ -12,3 +12,5 @@ root = true
|
|||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|||||||
229
.idea/codeStyleSettings.xml
generated
229
.idea/codeStyleSettings.xml
generated
@@ -1,229 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectCodeStyleSettingsManager">
|
|
||||||
<option name="PER_PROJECT_SETTINGS">
|
|
||||||
<value>
|
|
||||||
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
|
|
||||||
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
|
|
||||||
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
|
|
||||||
<value />
|
|
||||||
</option>
|
|
||||||
<option name="IMPORT_LAYOUT_TABLE">
|
|
||||||
<value>
|
|
||||||
<package name="android" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="com" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="junit" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="net" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="org" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="java" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="javax" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="" withSubpackages="true" static="true" />
|
|
||||||
<emptyLine />
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
<option name="RIGHT_MARGIN" value="100" />
|
|
||||||
<AndroidXmlCodeStyleSettings>
|
|
||||||
<option name="USE_CUSTOM_SETTINGS" value="true" />
|
|
||||||
</AndroidXmlCodeStyleSettings>
|
|
||||||
<Objective-C-extensions>
|
|
||||||
<option name="GENERATE_INSTANCE_VARIABLES_FOR_PROPERTIES" value="ASK" />
|
|
||||||
<option name="RELEASE_STYLE" value="IVAR" />
|
|
||||||
<option name="TYPE_QUALIFIERS_PLACEMENT" value="BEFORE" />
|
|
||||||
<file>
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
|
|
||||||
</file>
|
|
||||||
<class>
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
|
|
||||||
</class>
|
|
||||||
<extensions>
|
|
||||||
<pair source="cpp" header="h" />
|
|
||||||
<pair source="c" header="h" />
|
|
||||||
</extensions>
|
|
||||||
</Objective-C-extensions>
|
|
||||||
<XML>
|
|
||||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
|
||||||
</XML>
|
|
||||||
<codeStyleSettings language="XML">
|
|
||||||
<option name="FORCE_REARRANGE_MODE" value="1" />
|
|
||||||
<indentOptions>
|
|
||||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
|
||||||
</indentOptions>
|
|
||||||
<arrangement>
|
|
||||||
<rules>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>xmlns:android</NAME>
|
|
||||||
<XML_NAMESPACE>Namespace:</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>xmlns:.*</NAME>
|
|
||||||
<XML_NAMESPACE>Namespace:</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:id</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:name</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>name</NAME>
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>style</NAME>
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*</NAME>
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:layout_width</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:layout_height</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:layout_.*</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:width</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:height</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*</NAME>
|
|
||||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
</rules>
|
|
||||||
</arrangement>
|
|
||||||
</codeStyleSettings>
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="TermuxCodeStyle" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
8
.idea/gradle.xml
generated
8
.idea/gradle.xml
generated
@@ -3,16 +3,20 @@
|
|||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="disableWrapperSourceDistributionNotification" value="true" />
|
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="1.8" />
|
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
<option value="$PROJECT_DIR$/app" />
|
<option value="$PROJECT_DIR$/app" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
|
<option name="myModules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
15
.idea/inspectionProfiles/Project_Default.xml
generated
15
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -1,15 +0,0 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
|
||||||
<profile version="1.0">
|
|
||||||
<option name="myName" value="Project Default" />
|
|
||||||
<inspection_tool class="AndroidLintGoogleAppIndexingWarning" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="EmptyStatementBody" enabled="true" level="WARNING" enabled_by_default="true">
|
|
||||||
<option name="m_reportEmptyBlocks" value="true" />
|
|
||||||
<option name="commentsAreContent" value="true" />
|
|
||||||
</inspection_tool>
|
|
||||||
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
|
||||||
<option name="processCode" value="true" />
|
|
||||||
<option name="processLiterals" value="true" />
|
|
||||||
<option name="processComments" value="true" />
|
|
||||||
</inspection_tool>
|
|
||||||
</profile>
|
|
||||||
</component>
|
|
||||||
7
.idea/inspectionProfiles/profiles_settings.xml
generated
7
.idea/inspectionProfiles/profiles_settings.xml
generated
@@ -1,7 +0,0 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
|
||||||
<settings>
|
|
||||||
<option name="PROJECT_PROFILE" value="Project Default" />
|
|
||||||
<option name="USE_PROJECT_PROFILE" value="true" />
|
|
||||||
<version value="1.0" />
|
|
||||||
</settings>
|
|
||||||
</component>
|
|
||||||
@@ -18,8 +18,8 @@ android {
|
|||||||
applicationId "com.termux"
|
applicationId "com.termux"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
versionCode 30
|
versionCode 33
|
||||||
versionName "0.30"
|
versionName "0.33"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|||||||
@@ -43,6 +43,36 @@
|
|||||||
android:parentActivityName=".app.TermuxActivity"
|
android:parentActivityName=".app.TermuxActivity"
|
||||||
android:label="@string/application_name" />
|
android:label="@string/application_name" />
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name="com.termux.filepicker.TermuxFileReceiverActivity"
|
||||||
|
android:label="@string/application_name"
|
||||||
|
android:taskAffinity="com.termux.filereceiver"
|
||||||
|
android:excludeFromRecents="true"
|
||||||
|
android:noHistory="true">
|
||||||
|
<!-- Accept multiple file types when sending. -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.SEND"/>
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:mimeType="application/*" />
|
||||||
|
<data android:mimeType="audio/*" />
|
||||||
|
<data android:mimeType="image/*" />
|
||||||
|
<data android:mimeType="message/*" />
|
||||||
|
<data android:mimeType="multipart/*" />
|
||||||
|
<data android:mimeType="text/*" />
|
||||||
|
<data android:mimeType="video/*" />
|
||||||
|
</intent-filter>
|
||||||
|
<!-- Be more restrictive for viewing files, restricting ourselves to text files. -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:mimeType="text/*" />
|
||||||
|
<data android:mimeType="application/json" />
|
||||||
|
<data android:mimeType="application/*xml*" />
|
||||||
|
<data android:mimeType="application/*latex*" />
|
||||||
|
<data android:mimeType="application/javascript" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.termux.filepicker.TermuxFilePickerActivity"
|
android:name="com.termux.filepicker.TermuxFilePickerActivity"
|
||||||
android:label="@string/application_name"
|
android:label="@string/application_name"
|
||||||
@@ -63,7 +93,7 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<provider android:authorities="com.termux.filepicker.provider"
|
<provider android:authorities="com.termux.filepicker.provider"
|
||||||
android:readPermission="com.termux.filepickder.READ"
|
android:readPermission="com.termux.filepicker.READ"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:grantUriPermissions="true"
|
android:grantUriPermissions="true"
|
||||||
android:name="com.termux.filepicker.TermuxFilePickerProvider" />
|
android:name="com.termux.filepicker.TermuxFilePickerProvider" />
|
||||||
|
|||||||
@@ -3,24 +3,25 @@ package com.termux.app;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.text.Selection;
|
import android.text.Selection;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.ViewGroup.LayoutParams;
|
import android.view.ViewGroup.LayoutParams;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
final class DialogUtils {
|
public final class DialogUtils {
|
||||||
|
|
||||||
public interface TextSetListener {
|
public interface TextSetListener {
|
||||||
void onTextSet(String text);
|
void onTextSet(String text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void textInput(Activity activity, int titleText, int positiveButtonText, String initialText, final TextSetListener onPositive,
|
public static void textInput(Activity activity, int titleText, String initialText,
|
||||||
int neutralButtonText, final TextSetListener onNeutral) {
|
int positiveButtonText, final TextSetListener onPositive,
|
||||||
|
int neutralButtonText, final TextSetListener onNeutral,
|
||||||
|
int negativeButtonText, final TextSetListener onNegative,
|
||||||
|
final DialogInterface.OnDismissListener onDismiss) {
|
||||||
final EditText input = new EditText(activity);
|
final EditText input = new EditText(activity);
|
||||||
input.setSingleLine();
|
input.setSingleLine();
|
||||||
if (initialText != null) {
|
if (initialText != null) {
|
||||||
@@ -57,23 +58,32 @@ final class DialogUtils {
|
|||||||
public void onClick(DialogInterface d, int whichButton) {
|
public void onClick(DialogInterface d, int whichButton) {
|
||||||
onPositive.onTextSet(input.getText().toString());
|
onPositive.onTextSet(input.getText().toString());
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.setNegativeButton(android.R.string.cancel, null);
|
|
||||||
|
|
||||||
if (onNeutral != null) {
|
|
||||||
builder.setNeutralButton(neutralButtonText, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
onNeutral.onTextSet(input.getText().toString());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
if (onNeutral != null) {
|
||||||
|
builder.setNeutralButton(neutralButtonText, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
onNeutral.onTextSet(input.getText().toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onNegative == null) {
|
||||||
|
builder.setNegativeButton(android.R.string.cancel, null);
|
||||||
|
} else {
|
||||||
|
builder.setNegativeButton(negativeButtonText, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
onNegative.onTextSet(input.getText().toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onDismiss != null) builder.setOnDismissListener(onDismiss);
|
||||||
|
|
||||||
dialogHolder[0] = builder.create();
|
dialogHolder[0] = builder.create();
|
||||||
if ((activity.getResources().getConfiguration().hardKeyboardHidden & Configuration.HARDKEYBOARDHIDDEN_YES) == 0) {
|
dialogHolder[0].setCanceledOnTouchOutside(false);
|
||||||
// Show soft keyboard unless hardware keyboard available.
|
|
||||||
dialogHolder[0].getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
|
||||||
}
|
|
||||||
dialogHolder[0].show();
|
dialogHolder[0].show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import android.text.SpannableString;
|
|||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.style.StyleSpan;
|
import android.text.style.StyleSpan;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
@@ -287,28 +288,27 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
newSessionButton.setOnLongClickListener(new OnLongClickListener() {
|
newSessionButton.setOnLongClickListener(new OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
Resources res = getResources();
|
DialogUtils.textInput(TermuxActivity.this, R.string.session_new_named_title, null, R.string.session_new_named_positive_button,
|
||||||
DialogUtils.textInput(TermuxActivity.this, R.string.session_new_named_title, R.string.session_new_named_positive_button, null,
|
new DialogUtils.TextSetListener() {
|
||||||
new DialogUtils.TextSetListener() {
|
@Override
|
||||||
@Override
|
public void onTextSet(String text) {
|
||||||
public void onTextSet(String text) {
|
addNewSession(false, text);
|
||||||
addNewSession(false, text);
|
}
|
||||||
}
|
}, R.string.new_session_failsafe, new DialogUtils.TextSetListener() {
|
||||||
}, R.string.new_session_failsafe, new DialogUtils.TextSetListener() {
|
@Override
|
||||||
@Override
|
public void onTextSet(String text) {
|
||||||
public void onTextSet(String text) {
|
addNewSession(true, text);
|
||||||
addNewSession(true, text);
|
}
|
||||||
}
|
}
|
||||||
}
|
, -1, null, null);
|
||||||
);
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
findViewById(R.id.toggle_keyboard_button).setOnClickListener(new OnClickListener() {
|
findViewById(R.id.toggle_keyboard_button).setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
@@ -492,14 +492,13 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
void renameSession(final TerminalSession sessionToRename) {
|
void renameSession(final TerminalSession sessionToRename) {
|
||||||
DialogUtils.textInput(this, R.string.session_rename_title, R.string.session_rename_positive_button, sessionToRename.mSessionName,
|
DialogUtils.textInput(this, R.string.session_rename_title, sessionToRename.mSessionName, R.string.session_rename_positive_button, new DialogUtils.TextSetListener() {
|
||||||
new DialogUtils.TextSetListener() {
|
@Override
|
||||||
@Override
|
public void onTextSet(String text) {
|
||||||
public void onTextSet(String text) {
|
sessionToRename.mSessionName = text;
|
||||||
sessionToRename.mSessionName = text;
|
}
|
||||||
}
|
}, -1, null, -1, null, null);
|
||||||
}, -1, null);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
@@ -680,7 +679,13 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
String url = (String) urls[position];
|
String url = (String) urls[position];
|
||||||
startActivity(Intent.createChooser(new Intent(Intent.ACTION_VIEW, Uri.parse(url)), null));
|
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||||
|
try {
|
||||||
|
startActivity(i, null);
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
// If no applications match, Android displays a system message.
|
||||||
|
startActivity(Intent.createChooser(i, null));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -731,21 +736,23 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case CONTEXTMENU_STYLING_ID: {
|
case CONTEXTMENU_STYLING_ID: {
|
||||||
Intent stylingIntent = new Intent();
|
Intent stylingIntent = new Intent();
|
||||||
stylingIntent.setClassName("com.termux.styling", "com.termux.styling.TermuxStyleActivity");
|
stylingIntent.setClassName("com.termux.styling", "com.termux.styling.TermuxStyleActivity");
|
||||||
try {
|
try {
|
||||||
startActivity(stylingIntent);
|
startActivity(stylingIntent);
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException | IllegalArgumentException e) {
|
||||||
new AlertDialog.Builder(this).setMessage(R.string.styling_not_installed)
|
// The startActivity() call is not documented to throw IllegalArgumentException.
|
||||||
.setPositiveButton(R.string.styling_install, new android.content.DialogInterface.OnClickListener() {
|
// However, crash reporting shows that it sometimes does, so catch it here.
|
||||||
@Override
|
new AlertDialog.Builder(this).setMessage(R.string.styling_not_installed)
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
.setPositiveButton(R.string.styling_install, new android.content.DialogInterface.OnClickListener() {
|
||||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=com.termux.styling")));
|
@Override
|
||||||
}
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
}).setNegativeButton(android.R.string.cancel, null).show();
|
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=com.termux.styling")));
|
||||||
}
|
}
|
||||||
}
|
}).setNegativeButton(android.R.string.cancel, null).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
case CONTEXTMENU_TOGGLE_FULLSCREEN_ID:
|
case CONTEXTMENU_TOGGLE_FULLSCREEN_ID:
|
||||||
toggleImmersive();
|
toggleImmersive();
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.DialogInterface.OnClickListener;
|
import android.content.DialogInterface.OnClickListener;
|
||||||
import android.content.DialogInterface.OnDismissListener;
|
import android.content.DialogInterface.OnDismissListener;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.system.Os;
|
import android.system.Os;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -23,6 +24,7 @@ import java.io.InputStreamReader;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
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;
|
||||||
@@ -176,17 +178,28 @@ final class TermuxInstaller {
|
|||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get bootstrap zip url for this systems cpu architecture. */
|
/** Get bootstrap zip url for this systems cpu architecture. */
|
||||||
static URL determineZipUrl() throws MalformedURLException {
|
static URL determineZipUrl() throws MalformedURLException {
|
||||||
String arch = System.getProperty("os.arch");
|
String termuxArch = null;
|
||||||
if (arch.startsWith("arm") || arch.equals("aarch64")) {
|
// Note that we cannot use System.getProperty("os.arch") since that may give e.g. "aarch64"
|
||||||
// Handle different arm variants such as armv7l:
|
// while a 64-bit runtime may not be installed (like on the Samsung Galaxy S5 Neo).
|
||||||
arch = "arm";
|
// Instead we search through the supported abi:s on the device, see:
|
||||||
} else if (arch.startsWith("x86")) { // "x86" on arcwelder, "x86_64" on 64-bit android.
|
// http://developer.android.com/ndk/guides/abis.html
|
||||||
arch = "i686";
|
// Note that we search for abi:s in preferred order, and want to avoid installing arm on
|
||||||
}
|
// an x86 system where arm emulation is available.
|
||||||
return new URL("https://termux.net/bootstrap/bootstrap-" + arch + ".zip");
|
final String[] androidArchNames = {"arm64-v8a", "x86", "armeabi-v7a"};
|
||||||
}
|
final String[] termuxArchNames = {"aarch64", "i686", "arm"};
|
||||||
|
|
||||||
|
final List<String> supportedArches = Arrays.asList(Build.SUPPORTED_ABIS);
|
||||||
|
for (int i = 0; i < termuxArchNames.length; i++) {
|
||||||
|
if (supportedArches.contains(androidArchNames[i])) {
|
||||||
|
termuxArch = termuxArchNames[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new URL("https://termux.net/bootstrap/bootstrap-" + termuxArch + ".zip");
|
||||||
|
}
|
||||||
|
|
||||||
/** Delete a folder and all its content or throw. */
|
/** Delete a folder and all its content or throw. */
|
||||||
static void deleteFolder(File fileOrDirectory) {
|
static void deleteFolder(File fileOrDirectory) {
|
||||||
|
|||||||
@@ -55,7 +55,11 @@ public final class TermuxService extends Service implements SessionChangedCallba
|
|||||||
/** Intent action to toggle the wifi lock, {@link #mWifiLock}, which this service may hold. */
|
/** Intent action to toggle the wifi lock, {@link #mWifiLock}, which this service may hold. */
|
||||||
private static final String ACTION_LOCK_WIFI = "com.termux.service_toggle_wifi_lock";
|
private static final String ACTION_LOCK_WIFI = "com.termux.service_toggle_wifi_lock";
|
||||||
/** Intent action to launch a new terminal session. Executed from TermuxWidgetProvider. */
|
/** Intent action to launch a new terminal session. Executed from TermuxWidgetProvider. */
|
||||||
private static final String ACTION_EXECUTE = "com.termux.service_execute";
|
public static final String ACTION_EXECUTE = "com.termux.service_execute";
|
||||||
|
|
||||||
|
public static final String EXTRA_ARGUMENTS = "com.termux.execute.arguments";
|
||||||
|
|
||||||
|
public static final String EXTRA_CURRENT_WORKING_DIRECTORY = "com.termux.execute.cwd";
|
||||||
|
|
||||||
/** This service is only bound from inside the same process and never uses IPC. */
|
/** This service is only bound from inside the same process and never uses IPC. */
|
||||||
class LocalBinder extends Binder {
|
class LocalBinder extends Binder {
|
||||||
@@ -113,8 +117,8 @@ public final class TermuxService extends Service implements SessionChangedCallba
|
|||||||
} else if (ACTION_EXECUTE.equals(action)) {
|
} else if (ACTION_EXECUTE.equals(action)) {
|
||||||
Uri executableUri = intent.getData();
|
Uri executableUri = intent.getData();
|
||||||
String executablePath = (executableUri == null ? null : executableUri.getPath());
|
String executablePath = (executableUri == null ? null : executableUri.getPath());
|
||||||
String[] arguments = (executableUri == null ? null : intent.getStringArrayExtra("com.termux.execute.arguments"));
|
String[] arguments = (executableUri == null ? null : intent.getStringArrayExtra(EXTRA_ARGUMENTS));
|
||||||
String cwd = intent.getStringExtra("com.termux.execute.cwd");
|
String cwd = intent.getStringExtra(EXTRA_CURRENT_WORKING_DIRECTORY);
|
||||||
TerminalSession newSession = createTermSession(executablePath, arguments, cwd, false);
|
TerminalSession newSession = createTermSession(executablePath, arguments, cwd, false);
|
||||||
|
|
||||||
// Transform executable path to session name, e.g. "/bin/do-something.sh" => "do something.sh".
|
// Transform executable path to session name, e.g. "/bin/do-something.sh" => "do something.sh".
|
||||||
@@ -237,17 +241,22 @@ public final class TermuxService extends Service implements SessionChangedCallba
|
|||||||
final String prefixEnv = "PREFIX=" + PREFIX_PATH;
|
final String prefixEnv = "PREFIX=" + PREFIX_PATH;
|
||||||
final String androidRootEnv = "ANDROID_ROOT=" + System.getenv("ANDROID_ROOT");
|
final String androidRootEnv = "ANDROID_ROOT=" + System.getenv("ANDROID_ROOT");
|
||||||
final String androidDataEnv = "ANDROID_DATA=" + System.getenv("ANDROID_DATA");
|
final String androidDataEnv = "ANDROID_DATA=" + System.getenv("ANDROID_DATA");
|
||||||
|
// EXTERNAL_STORAGE is needed for /system/bin/am to work on at least
|
||||||
|
// Samsung S7 - see https://plus.google.com/110070148244138185604/posts/gp8Lk3aCGp3.
|
||||||
|
final String externalStorageEnv = "EXTERNAL_STORAGE=" + System.getenv("EXTERNAL_STORAGE");
|
||||||
String[] env;
|
String[] env;
|
||||||
if (failSafe) {
|
if (failSafe) {
|
||||||
env = new String[] { termEnv, homeEnv, prefixEnv, androidRootEnv, androidDataEnv };
|
// Keep the default path so that system binaries can be used in the failsafe session.
|
||||||
|
final String pathEnv = "PATH=" + System.getenv("PATH");
|
||||||
|
env = new String[] { termEnv, homeEnv, prefixEnv, androidRootEnv, androidDataEnv, pathEnv, externalStorageEnv };
|
||||||
} else {
|
} else {
|
||||||
final String ps1Env = "PS1=$ ";
|
final String ps1Env = "PS1=$ ";
|
||||||
final String ldEnv = "LD_LIBRARY_PATH=" + PREFIX_PATH + "/lib";
|
final String ldEnv = "LD_LIBRARY_PATH=" + PREFIX_PATH + "/lib";
|
||||||
final String langEnv = "LANG=en_US.UTF-8";
|
final String langEnv = "LANG=en_US.UTF-8";
|
||||||
final String pathEnv = "PATH=" + PREFIX_PATH + "/bin:" + PREFIX_PATH + "/bin/applets:" + System.getenv("PATH");
|
final String pathEnv = "PATH=" + PREFIX_PATH + "/bin:" + PREFIX_PATH + "/bin/applets";
|
||||||
final String pwdEnv = "PWD=" + cwd;
|
final String pwdEnv = "PWD=" + cwd;
|
||||||
|
|
||||||
env = new String[] { termEnv, homeEnv, prefixEnv, ps1Env, ldEnv, langEnv, pathEnv, pwdEnv, androidRootEnv, androidDataEnv };
|
env = new String[] { termEnv, homeEnv, prefixEnv, ps1Env, ldEnv, langEnv, pathEnv, pwdEnv, androidRootEnv, androidDataEnv, externalStorageEnv };
|
||||||
}
|
}
|
||||||
|
|
||||||
String shellName;
|
String shellName;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.termux.filepicker;
|
package com.termux.filepicker;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -12,6 +11,7 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
import com.termux.R;
|
import com.termux.R;
|
||||||
|
import com.termux.app.TermuxService;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -23,9 +23,6 @@ import java.util.List;
|
|||||||
/** Activity allowing picking files from the $HOME folder. */
|
/** Activity allowing picking files from the $HOME folder. */
|
||||||
public class TermuxFilePickerActivity extends ListActivity {
|
public class TermuxFilePickerActivity extends ListActivity {
|
||||||
|
|
||||||
@SuppressLint("SdCardPath")
|
|
||||||
final String TERMUX_HOME = "/data/data/com.termux/files/home";
|
|
||||||
|
|
||||||
private File mCurrentDirectory;
|
private File mCurrentDirectory;
|
||||||
private final List<File> mFiles = new ArrayList<>();
|
private final List<File> mFiles = new ArrayList<>();
|
||||||
private final List<String> mFileNames = new ArrayList<>();
|
private final List<String> mFileNames = new ArrayList<>();
|
||||||
@@ -38,7 +35,7 @@ public class TermuxFilePickerActivity extends ListActivity {
|
|||||||
|
|
||||||
mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mFileNames);
|
mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mFileNames);
|
||||||
|
|
||||||
enterDirectory(new File(TERMUX_HOME));
|
enterDirectory(new File(TermuxService.HOME_PATH));
|
||||||
setListAdapter(mAdapter);
|
setListAdapter(mAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,11 +66,11 @@ public class TermuxFilePickerActivity extends ListActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void enterDirectory(File directory) {
|
void enterDirectory(File directory) {
|
||||||
getActionBar().setDisplayHomeAsUpEnabled(!directory.getAbsolutePath().equals(TERMUX_HOME));
|
getActionBar().setDisplayHomeAsUpEnabled(!directory.getAbsolutePath().equals(TermuxService.HOME_PATH));
|
||||||
|
|
||||||
String title = directory.getAbsolutePath() + "/";
|
String title = directory.getAbsolutePath() + "/";
|
||||||
if (title.startsWith(TERMUX_HOME)) {
|
if (title.startsWith(TermuxService.HOME_PATH)) {
|
||||||
title = "~" + title.substring(TERMUX_HOME.length(), title.length());
|
title = "~" + title.substring(TermuxService.HOME_PATH.length(), title.length());
|
||||||
}
|
}
|
||||||
setTitle(title);
|
setTitle(title);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,215 @@
|
|||||||
|
package com.termux.filepicker;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.provider.OpenableColumns;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.util.Patterns;
|
||||||
|
|
||||||
|
import com.termux.R;
|
||||||
|
import com.termux.app.DialogUtils;
|
||||||
|
import com.termux.app.TermuxService;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
public class TermuxFileReceiverActivity extends Activity {
|
||||||
|
|
||||||
|
static final String TERMUX_RECEIVEDIR = TermuxService.FILES_PATH + "/home/downloads";
|
||||||
|
static final String EDITOR_PROGRAM = TermuxService.HOME_PATH + "/bin/termux-file-editor";
|
||||||
|
static final String URL_OPENER_PROGRAM = TermuxService.HOME_PATH + "/bin/termux-url-opener";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the activity should be finished when the name input dialog is dismissed. This is disabled
|
||||||
|
* before showing an error dialog, since the act of showing the error dialog will cause the
|
||||||
|
* name input dialog to be implicitly dismissed, and we do not want to finish the activity directly
|
||||||
|
* when showing the error dialog.
|
||||||
|
*/
|
||||||
|
private boolean mFinishOnDismissNameDialog = true;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
final Intent intent = getIntent();
|
||||||
|
final String action = intent.getAction();
|
||||||
|
final String type = intent.getType();
|
||||||
|
final String scheme = intent.getScheme();
|
||||||
|
|
||||||
|
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||||
|
final String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||||
|
final Uri sharedUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||||
|
|
||||||
|
if (sharedText != null) {
|
||||||
|
if (Patterns.WEB_URL.matcher(sharedText).matches()) {
|
||||||
|
handleUrlAndFinish(sharedText);
|
||||||
|
} else {
|
||||||
|
String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
|
||||||
|
if (subject == null) subject = intent.getStringExtra(Intent.EXTRA_TITLE);
|
||||||
|
if (subject != null) subject += ".txt";
|
||||||
|
promptNameAndSave(new ByteArrayInputStream(sharedText.getBytes(StandardCharsets.UTF_8)), subject);
|
||||||
|
}
|
||||||
|
} else if (sharedUri != null) {
|
||||||
|
handleContentUri(sharedUri, intent.getStringExtra(Intent.EXTRA_TITLE));
|
||||||
|
} else {
|
||||||
|
showErrorDialogAndQuit("Send action without content - nothing to save.");
|
||||||
|
}
|
||||||
|
} else if ("content".equals(scheme)) {
|
||||||
|
handleContentUri(intent.getData(), intent.getStringExtra(Intent.EXTRA_TITLE));
|
||||||
|
} else if ("file".equals(scheme)) {
|
||||||
|
// When e.g. clicking on a downloaded apk:
|
||||||
|
String path = intent.getData().getPath();
|
||||||
|
File file = new File(path);
|
||||||
|
try {
|
||||||
|
FileInputStream in = new FileInputStream(file);
|
||||||
|
promptNameAndSave(in, file.getName());
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
showErrorDialogAndQuit("Cannot open file: " + e.getMessage() + ".");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
showErrorDialogAndQuit("Unable to receive any file or URL.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void showErrorDialogAndQuit(String message) {
|
||||||
|
mFinishOnDismissNameDialog = false;
|
||||||
|
new AlertDialog.Builder(this).setMessage(message).setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialog) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleContentUri(final Uri uri, String subjectFromIntent) {
|
||||||
|
try {
|
||||||
|
String attachmentFileName = null;
|
||||||
|
|
||||||
|
String[] projection = new String[]{OpenableColumns.DISPLAY_NAME};
|
||||||
|
try (Cursor c = getContentResolver().query(uri, projection, null, null, null)) {
|
||||||
|
if (c != null && c.moveToFirst()) {
|
||||||
|
final int fileNameColumnId = c.getColumnIndex(OpenableColumns.DISPLAY_NAME);
|
||||||
|
if (fileNameColumnId >= 0) attachmentFileName = c.getString(fileNameColumnId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attachmentFileName == null) attachmentFileName = subjectFromIntent;
|
||||||
|
|
||||||
|
InputStream in = getContentResolver().openInputStream(uri);
|
||||||
|
promptNameAndSave(in, attachmentFileName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
showErrorDialogAndQuit("Unable to handle shared content:\n\n" + e.getMessage());
|
||||||
|
Log.e("termux", "handleContentUri(uri=" + uri + ") failed", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void promptNameAndSave(final InputStream in, final String attachmentFileName) {
|
||||||
|
DialogUtils.textInput(this, R.string.file_received_title, attachmentFileName, R.string.file_received_edit_button, new DialogUtils.TextSetListener() {
|
||||||
|
@Override
|
||||||
|
public void onTextSet(String text) {
|
||||||
|
File outFile = saveStreamWithName(in, text);
|
||||||
|
if (outFile == null) return;
|
||||||
|
|
||||||
|
final File editorProgramFile = new File(EDITOR_PROGRAM);
|
||||||
|
if (!editorProgramFile.isFile()) {
|
||||||
|
showErrorDialogAndQuit("The following file does not exist:\n$HOME/bin/termux-file-editor\n\n"
|
||||||
|
+ "Create this file as a script or a symlink - it will be called with the received file as only argument.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do this for the user if necessary:
|
||||||
|
editorProgramFile.setExecutable(true);
|
||||||
|
|
||||||
|
final Uri scriptUri = new Uri.Builder().scheme("file").path(EDITOR_PROGRAM).build();
|
||||||
|
|
||||||
|
Intent executeIntent = new Intent(TermuxService.ACTION_EXECUTE, scriptUri);
|
||||||
|
executeIntent.setClass(TermuxFileReceiverActivity.this, TermuxService.class);
|
||||||
|
executeIntent.putExtra(TermuxService.EXTRA_ARGUMENTS, new String[]{outFile.getAbsolutePath()});
|
||||||
|
startService(executeIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
R.string.file_received_open_folder_button, new DialogUtils.TextSetListener() {
|
||||||
|
@Override
|
||||||
|
public void onTextSet(String text) {
|
||||||
|
if (saveStreamWithName(in, text) == null) return;
|
||||||
|
|
||||||
|
Intent executeIntent = new Intent(TermuxService.ACTION_EXECUTE);
|
||||||
|
executeIntent.putExtra(TermuxService.EXTRA_CURRENT_WORKING_DIRECTORY, TERMUX_RECEIVEDIR);
|
||||||
|
executeIntent.setClass(TermuxFileReceiverActivity.this, TermuxService.class);
|
||||||
|
startService(executeIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
android.R.string.cancel, new DialogUtils.TextSetListener() {
|
||||||
|
@Override
|
||||||
|
public void onTextSet(final String text) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}, new DialogInterface.OnDismissListener() {
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialog) {
|
||||||
|
if (mFinishOnDismissNameDialog) finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public File saveStreamWithName(InputStream in, String attachmentFileName) {
|
||||||
|
File receiveDir = new File(TERMUX_RECEIVEDIR);
|
||||||
|
if (!receiveDir.isDirectory() && !receiveDir.mkdirs()) {
|
||||||
|
showErrorDialogAndQuit("Cannot create directory: " + receiveDir.getAbsolutePath());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
final File outFile = new File(receiveDir, attachmentFileName);
|
||||||
|
try (FileOutputStream f = new FileOutputStream(outFile)) {
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int readBytes;
|
||||||
|
while ((readBytes = in.read(buffer)) > 0) {
|
||||||
|
f.write(buffer, 0, readBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return outFile;
|
||||||
|
} catch (IOException e) {
|
||||||
|
showErrorDialogAndQuit("Error saving file:\n\n" + e);
|
||||||
|
Log.e("termux", "Error saving file", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleUrlAndFinish(final String url) {
|
||||||
|
final File urlOpenerProgramFile = new File(URL_OPENER_PROGRAM);
|
||||||
|
if (!urlOpenerProgramFile.isFile()) {
|
||||||
|
showErrorDialogAndQuit("The following file does not exist:\n$HOME/bin/termux-url-opener\n\n"
|
||||||
|
+ "Create this file as a script or a symlink - it will be called with the shared URL as only argument.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do this for the user if necessary:
|
||||||
|
urlOpenerProgramFile.setExecutable(true);
|
||||||
|
|
||||||
|
final Uri urlOpenerProgramUri = new Uri.Builder().scheme("file").path(URL_OPENER_PROGRAM).build();
|
||||||
|
|
||||||
|
Intent executeIntent = new Intent(TermuxService.ACTION_EXECUTE, urlOpenerProgramUri);
|
||||||
|
executeIntent.setClass(TermuxFileReceiverActivity.this, TermuxService.class);
|
||||||
|
executeIntent.putExtra(TermuxService.EXTRA_ARGUMENTS, new String[]{url});
|
||||||
|
startService(executeIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -127,10 +127,14 @@ public final class TerminalBuffer {
|
|||||||
mLines[externalToInternalRow(row)].mLineWrap = true;
|
mLines[externalToInternalRow(row)].mLineWrap = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getLineWrap(int row) {
|
public boolean getLineWrap(int row) {
|
||||||
return mLines[externalToInternalRow(row)].mLineWrap;
|
return mLines[externalToInternalRow(row)].mLineWrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearLineWrap(int row) {
|
||||||
|
mLines[externalToInternalRow(row)].mLineWrap = false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resize the screen which this transcript backs. Currently, this only works if the number of columns does not
|
* Resize the screen which this transcript backs. Currently, this only works if the number of columns does not
|
||||||
* change or the rows expand (that is, it only works when shrinking the number of rows).
|
* change or the rows expand (that is, it only works when shrinking the number of rows).
|
||||||
|
|||||||
@@ -475,7 +475,16 @@ public final class TerminalEmulator {
|
|||||||
mSession.onBell();
|
mSession.onBell();
|
||||||
break;
|
break;
|
||||||
case 8: // Backspace (BS, ^H).
|
case 8: // Backspace (BS, ^H).
|
||||||
setCursorCol(Math.max(mLeftMargin, mCursorCol - 1));
|
if (mLeftMargin == mCursorCol) {
|
||||||
|
// Jump to previous line if it was auto-wrapped.
|
||||||
|
int previousRow = mCursorRow - 1;
|
||||||
|
if (previousRow >= 0 && mScreen.getLineWrap(previousRow)) {
|
||||||
|
mScreen.clearLineWrap(previousRow);
|
||||||
|
setCursorRowCol(previousRow, mRightMargin - 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setCursorCol(mCursorCol - 1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 9: // Horizontal tab (HT, \t) - move to next tab stop, but not past edge of screen
|
case 9: // Horizontal tab (HT, \t) - move to next tab stop, but not past edge of screen
|
||||||
// XXX: Should perhaps use color if writing to new cells. Try with
|
// XXX: Should perhaps use color if writing to new cells. Try with
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public final class TerminalSession extends TerminalOutput {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The file descriptor referencing the master half of a pseudo-terminal pair, resulting from calling
|
* The file descriptor referencing the master half of a pseudo-terminal pair, resulting from calling
|
||||||
* {@link JNI#createSubprocess(String, String, String[], String[], int[])}.
|
* {@link JNI#createSubprocess(String, String, String[], String[], int[], int, int)}.
|
||||||
*/
|
*/
|
||||||
private int mTerminalFileDescriptor;
|
private int mTerminalFileDescriptor;
|
||||||
|
|
||||||
|
|||||||
@@ -779,8 +779,9 @@ public final class TerminalView extends View {
|
|||||||
|
|
||||||
public void checkForFontAndColors() {
|
public void checkForFontAndColors() {
|
||||||
try {
|
try {
|
||||||
File fontFile = new File("/data/data/com.termux/files/home/.termux/font.ttf");
|
// Hard-coded paths since this file is used also in Termux:Float.
|
||||||
File colorsFile = new File("/data/data/com.termux/files/home/.termux/colors.properties");
|
@SuppressLint("SdCardPath") File fontFile = new File("/data/data/com.termux/files/home/.termux/font.ttf");
|
||||||
|
@SuppressLint("SdCardPath") File colorsFile = new File("/data/data/com.termux/files/home/.termux/colors.properties");
|
||||||
|
|
||||||
final Properties props = new Properties();
|
final Properties props = new Properties();
|
||||||
if (colorsFile.isFile()) {
|
if (colorsFile.isFile()) {
|
||||||
@@ -896,12 +897,16 @@ public final class TerminalView extends View {
|
|||||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||||
final int[] ACTION_MODE_ATTRS = { android.R.attr.actionModeCopyDrawable, android.R.attr.actionModePasteDrawable, };
|
final int[] ACTION_MODE_ATTRS = { android.R.attr.actionModeCopyDrawable, android.R.attr.actionModePasteDrawable, };
|
||||||
TypedArray styledAttributes = getContext().obtainStyledAttributes(ACTION_MODE_ATTRS);
|
TypedArray styledAttributes = getContext().obtainStyledAttributes(ACTION_MODE_ATTRS);
|
||||||
int show = MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT;
|
try {
|
||||||
|
int show = MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT;
|
||||||
|
|
||||||
ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
menu.add(Menu.NONE, 1, Menu.NONE, R.string.copy_text).setIcon(styledAttributes.getResourceId(0, 0)).setShowAsAction(show);
|
menu.add(Menu.NONE, 1, Menu.NONE, R.string.copy_text).setIcon(styledAttributes.getResourceId(0, 0)).setShowAsAction(show);
|
||||||
menu.add(Menu.NONE, 2, Menu.NONE, R.string.paste_text).setIcon(styledAttributes.getResourceId(1, 0)).setEnabled(clipboard.hasPrimaryClip()).setShowAsAction(show);
|
menu.add(Menu.NONE, 2, Menu.NONE, R.string.paste_text).setIcon(styledAttributes.getResourceId(1, 0)).setEnabled(clipboard.hasPrimaryClip()).setShowAsAction(show);
|
||||||
menu.add(Menu.NONE, 3, Menu.NONE, R.string.text_selection_more);
|
menu.add(Menu.NONE, 3, Menu.NONE, R.string.text_selection_more);
|
||||||
|
} finally {
|
||||||
|
styledAttributes.recycle();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
APP_ABI := armeabi-v7a x86
|
APP_ABI := arm64-v8a armeabi-v7a x86
|
||||||
APP_PLATFORM := android-21
|
APP_PLATFORM := android-21
|
||||||
NDK_TOOLCHAIN_VERSION := 4.9
|
NDK_TOOLCHAIN_VERSION := 4.9
|
||||||
APP_CFLAGS := -std=c11 -Wall -Wextra -Os -fno-stack-protector
|
APP_CFLAGS := -std=c11 -Wall -Wextra -Os -fno-stack-protector
|
||||||
|
|||||||
@@ -55,4 +55,8 @@
|
|||||||
|
|
||||||
<string name="empty_folder">Empty folder.</string>
|
<string name="empty_folder">Empty folder.</string>
|
||||||
|
|
||||||
|
<string name="file_received_title">Save file in ~/downloads/</string>
|
||||||
|
<string name="file_received_edit_button">Edit</string>
|
||||||
|
<string name="file_received_open_folder_button">Open folder</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -218,4 +218,13 @@ public class CursorAndScreenTest extends TerminalTestCase {
|
|||||||
" -");
|
" -");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBackspaceAcrossWrappedLines() {
|
||||||
|
// Backspace should not go to previous line if not auto-wrapped:
|
||||||
|
withTerminalSized(3, 3).enterString("hi\r\n\b\byou").assertLinesAre("hi ", "you", " ");
|
||||||
|
// Backspace should go to previous line if auto-wrapped:
|
||||||
|
withTerminalSized(3, 3).enterString("hi y").assertLinesAre("hi ", "y ", " ").enterString("\b\b#").assertLinesAre("hi#", "y ", " ");
|
||||||
|
// Initial backspace should do nothing:
|
||||||
|
withTerminalSized(3, 3).enterString("\b\b\b\bhi").assertLinesAre("hi ", " ", " ");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.5.0'
|
classpath 'com.android.tools.build:gradle:2.0.0'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Wed Dec 23 01:44:47 CET 2015
|
#Tue Mar 15 00:24:33 CET 2016
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-bin.zip
|
||||||
|
|||||||
Reference in New Issue
Block a user