fix: linear.showDividers, text.ellipsize
This commit is contained in:
@@ -13,6 +13,7 @@ import com.stardust.app.SimpleActivityLifecycleCallbacks;
|
||||
import com.stardust.autojs.core.accessibility.AccessibilityBridge;
|
||||
import com.stardust.autojs.core.console.GlobalStardustConsole;
|
||||
import com.stardust.autojs.core.console.StardustConsole;
|
||||
import com.stardust.autojs.core.image.OpenCVHelper;
|
||||
import com.stardust.autojs.core.image.capture.ScreenCaptureRequestActivity;
|
||||
import com.stardust.autojs.core.image.capture.ScreenCaptureRequester;
|
||||
import com.stardust.autojs.core.record.accessibility.AccessibilityActionRecorder;
|
||||
@@ -76,8 +77,6 @@ public abstract class AutoJs {
|
||||
protected void init() {
|
||||
addAccessibilityServiceDelegates();
|
||||
registerActivityLifecycleCallbacks();
|
||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_13, mContext, new BaseLoaderCallback(mContext) {
|
||||
});
|
||||
}
|
||||
|
||||
public abstract void ensureAccessibilityServiceEnabled();
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
package com.stardust.autojs.core.image;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
|
||||
import org.opencv.android.InstallCallbackInterface;
|
||||
import org.opencv.android.LoaderCallbackInterface;
|
||||
import org.opencv.android.OpenCVLoader;
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
/**
|
||||
@@ -11,8 +17,12 @@ import org.opencv.core.Mat;
|
||||
|
||||
public class OpenCVHelper {
|
||||
|
||||
public interface InitializeCallback {
|
||||
void onInitFinish();
|
||||
}
|
||||
|
||||
private static final String LOG_TAG = "OpenCv";
|
||||
private static final String LOG_TAG = "OpenCVHelper";
|
||||
private static boolean mInitialized = false;
|
||||
|
||||
public static void release(@Nullable Mat mat) {
|
||||
if (mat == null)
|
||||
@@ -20,4 +30,100 @@ public class OpenCVHelper {
|
||||
mat.release();
|
||||
}
|
||||
|
||||
public static void initIfNeeded(Activity activity, InitializeCallback callback) {
|
||||
if(mInitialized){
|
||||
callback.onInitFinish();
|
||||
return;
|
||||
}
|
||||
mInitialized = true;
|
||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_13, activity.getApplicationContext(), new LoaderCallback(activity) {
|
||||
|
||||
@Override
|
||||
protected void finish() {
|
||||
callback.onInitFinish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static class LoaderCallback implements LoaderCallbackInterface {
|
||||
private Activity mActivity;
|
||||
|
||||
public LoaderCallback(Activity activity) {
|
||||
this.mActivity = activity;
|
||||
}
|
||||
|
||||
public void onManagerConnected(int status) {
|
||||
switch (status) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
Log.e(LOG_TAG, "OpenCV loading failed!");
|
||||
new MaterialDialog.Builder(mActivity)
|
||||
.title("OpenCV error")
|
||||
.content("OpenCV was not initialised correctly. Application will be shut down")
|
||||
.cancelable(false)
|
||||
.positiveText("OK")
|
||||
.onPositive((dialog, which) -> finish())
|
||||
.show();
|
||||
break;
|
||||
case 2:
|
||||
Log.e(LOG_TAG, "Package installation failed!");
|
||||
new MaterialDialog.Builder(mActivity)
|
||||
.title("OpenCV Manager")
|
||||
.content("Package installation failed!")
|
||||
.cancelable(false)
|
||||
.positiveText("OK")
|
||||
.onPositive((dialog, which) -> finish())
|
||||
.show();
|
||||
break;
|
||||
case 3:
|
||||
Log.d(LOG_TAG, "OpenCV library instalation was canceled by user");
|
||||
finish();
|
||||
break;
|
||||
case 4:
|
||||
Log.d(LOG_TAG, "OpenCV Manager Service is uncompatible with this app!");
|
||||
new MaterialDialog.Builder(mActivity)
|
||||
.title("OpenCV Manager")
|
||||
.content("OpenCV Manager service is incompatible with this app. Try to update it via Google Play.")
|
||||
.cancelable(false)
|
||||
.positiveText("OK")
|
||||
.onPositive((dialog, which) -> finish())
|
||||
.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onPackageInstall(int operation, final InstallCallbackInterface callback) {
|
||||
switch (operation) {
|
||||
case 0:
|
||||
new MaterialDialog.Builder(mActivity)
|
||||
.title("Package not found")
|
||||
.content(callback.getPackageName() + " package was not found! Try to install it?")
|
||||
.cancelable(false)
|
||||
.positiveText("Yes")
|
||||
.onPositive((dialog, which) -> callback.install())
|
||||
.negativeText("No")
|
||||
.onNegative(((dialog, which) -> callback.cancel()))
|
||||
.show();
|
||||
break;
|
||||
case 1:
|
||||
new MaterialDialog.Builder(mActivity)
|
||||
.title("OpenCV is not ready")
|
||||
.content("Installation is in progress. Wait or exit?")
|
||||
.cancelable(false)
|
||||
.positiveText("Wait")
|
||||
.onPositive((dialog, which) -> callback.wait_install())
|
||||
.negativeText("Exit")
|
||||
.onNegative(((dialog, which) -> callback.cancel()))
|
||||
.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void finish() {
|
||||
mActivity.finish();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,12 @@ public class LinearLayoutInflater<V extends LinearLayout> extends ViewGroupInfla
|
||||
.map("vertical", LinearLayout.VERTICAL)
|
||||
.map("horizontal", LinearLayout.HORIZONTAL);
|
||||
|
||||
static final ValueMapper<Integer> SHOW_DIVIDERS = new ValueMapper<Integer>("showDividers")
|
||||
.map("beginning", LinearLayout.SHOW_DIVIDER_BEGINNING)
|
||||
.map("middle", LinearLayout.SHOW_DIVIDER_MIDDLE)
|
||||
.map("end", LinearLayout.SHOW_DIVIDER_END)
|
||||
.map("none", LinearLayout.SHOW_DIVIDER_NONE);
|
||||
|
||||
public LinearLayoutInflater(ResourceParser resourceParser) {
|
||||
super(resourceParser);
|
||||
}
|
||||
@@ -44,6 +50,9 @@ public class LinearLayoutInflater<V extends LinearLayout> extends ViewGroupInfla
|
||||
case "orientation":
|
||||
view.setOrientation(ORIENTATIONS.get(value));
|
||||
break;
|
||||
case "showDividers":
|
||||
view.setShowDividers(SHOW_DIVIDERS.split(value));
|
||||
break;
|
||||
case "weightSum":
|
||||
view.setWeightSum(Float.valueOf(value));
|
||||
break;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TextViewInflater<V extends TextView> extends BaseViewInflater<V> {
|
||||
.map("web", Linkify.WEB_URLS);
|
||||
private static final ValueMapper<TextUtils.TruncateAt> ELLIPSIZE = new ValueMapper<TextUtils.TruncateAt>("ellipsize")
|
||||
.map("end", TextUtils.TruncateAt.END)
|
||||
.map("marquee", TextUtils.TruncateAt.MIDDLE)
|
||||
.map("marquee", TextUtils.TruncateAt.MARQUEE)
|
||||
.map("none", null)
|
||||
.map("start", TextUtils.TruncateAt.START)
|
||||
.map("middle", TextUtils.TruncateAt.MIDDLE);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.stardust.autojs.core.ui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@@ -4,7 +4,9 @@ import android.content.Context;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
|
||||
import com.stardust.autojs.runtime.api.UI;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user