修复 脚本文件过大时崩溃的问题
This commit is contained in:
@@ -78,33 +78,33 @@ public class ApkBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public AppConfig setAppName(String appName) {
|
public AppConfig setAppName(String appName) {
|
||||||
appName = appName;
|
this.appName = appName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppConfig setVersionName(String versionName) {
|
public AppConfig setVersionName(String versionName) {
|
||||||
versionName = versionName;
|
this.versionName = versionName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppConfig setVersionCode(int versionCode) {
|
public AppConfig setVersionCode(int versionCode) {
|
||||||
versionCode = versionCode;
|
this.versionCode = versionCode;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppConfig setSourcePath(String sourcePath) {
|
public AppConfig setSourcePath(String sourcePath) {
|
||||||
sourcePath = sourcePath;
|
this.sourcePath = sourcePath;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppConfig setPackageName(String packageName) {
|
public AppConfig setPackageName(String packageName) {
|
||||||
packageName = packageName;
|
this.packageName = packageName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AppConfig setIcon(Callable<Bitmap> icon) {
|
public AppConfig setIcon(Callable<Bitmap> icon) {
|
||||||
icon = icon;
|
this.icon = icon;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class TmpScriptFiles {
|
public class TmpScriptFiles {
|
||||||
|
|
||||||
|
|
||||||
public static File create(Context context) throws IOException {
|
public static File create(Context context) throws IOException {
|
||||||
ensureTmpDir(context);
|
ensureTmpDir(context);
|
||||||
File tmp = new File(getTmpDir(context), "tmp-" + System.currentTimeMillis() + ".js");
|
File tmp = new File(getTmpDir(context), "tmp-" + System.currentTimeMillis() + ".js");
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import android.graphics.Typeface;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.service.autofill.AutofillService;
|
|
||||||
import android.support.annotation.RequiresApi;
|
import android.support.annotation.RequiresApi;
|
||||||
import android.support.v7.widget.AppCompatEditText;
|
import android.support.v7.widget.AppCompatEditText;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
@@ -35,7 +34,8 @@ import android.util.Log;
|
|||||||
import android.util.TimingLogger;
|
import android.util.TimingLogger;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.autofill.AutofillManager;
|
import android.widget.TextView;
|
||||||
|
import android.widget.TextViewHelper;
|
||||||
|
|
||||||
import org.autojs.autojs.ui.edit.theme.Theme;
|
import org.autojs.autojs.ui.edit.theme.Theme;
|
||||||
import org.autojs.autojs.ui.edit.theme.TokenMapping;
|
import org.autojs.autojs.ui.edit.theme.TokenMapping;
|
||||||
@@ -450,8 +450,13 @@ public class CodeEditText extends AppCompatEditText {
|
|||||||
@Override
|
@Override
|
||||||
public Parcelable onSaveInstanceState() {
|
public Parcelable onSaveInstanceState() {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
Parcelable superData = super.onSaveInstanceState();
|
Editable text = getText();
|
||||||
bundle.putParcelable("super_data", superData);
|
TextView.SavedState savedState = (SavedState) super.onSaveInstanceState();
|
||||||
|
if (text != null && text.length() > 50 * 1024) {
|
||||||
|
// avoid TransactionTooLargeException
|
||||||
|
TextViewHelper.setText(savedState, "");
|
||||||
|
}
|
||||||
|
bundle.putParcelable("super_data", savedState);
|
||||||
bundle.putInt("debugging_line", mDebuggingLine);
|
bundle.putInt("debugging_line", mDebuggingLine);
|
||||||
int[] breakpoints = new int[mBreakpoints.size()];
|
int[] breakpoints = new int[mBreakpoints.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|||||||
@@ -21,15 +21,10 @@ import android.widget.FrameLayout;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
import com.stardust.app.OnActivityResultDelegate;
|
import com.stardust.app.OnActivityResultDelegate;
|
||||||
|
|
||||||
import org.autojs.autojs.R;
|
import org.autojs.autojs.R;
|
||||||
import org.autojs.autojs.tool.ImageSelector;
|
import org.autojs.autojs.tool.ImageSelector;
|
||||||
import com.stardust.util.IntentUtil;
|
|
||||||
|
|
||||||
import org.androidannotations.annotations.OnActivityResult;
|
|
||||||
import org.androidannotations.annotations.ViewById;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|||||||
30
common/src/main/java/android/widget/TextViewHelper.java
Normal file
30
common/src/main/java/android/widget/TextViewHelper.java
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package android.widget;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
public class TextViewHelper {
|
||||||
|
|
||||||
|
private static final Field sSavedStateText;
|
||||||
|
|
||||||
|
static {
|
||||||
|
Field text = null;
|
||||||
|
try {
|
||||||
|
text = TextView.SavedState.class.getDeclaredField("text");
|
||||||
|
text.setAccessible(true);
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
sSavedStateText = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setText(TextView.SavedState state, CharSequence text) {
|
||||||
|
if (sSavedStateText == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
sSavedStateText.set(state, text);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user