diff --git a/app/src/main/assets/docs/images.html b/app/src/main/assets/docs/images.html index 5b36f480..2221100e 100644 --- a/app/src/main/assets/docs/images.html +++ b/app/src/main/assets/docs/images.html @@ -2,7 +2,7 @@ - Images | Auto.js 3.0.0 文档 + colors | Auto.js 3.0.0 文档 @@ -72,6 +72,19 @@

目录

-

Images#

+

colors#

+
Stability: 2 - Stable

在Auto.js有两种方式表示一个颜色。

+

一种是使用一个字符串"#AARRGGBB"或"#RRGGBB",其中 AA 是Alpha通道(透明度)的值,RR 是R通道(红色)的值,GG 是G通道(绿色)的值,BB是B通道(蓝色)的值。例如"#ffffff"表示白色, "#7F000000"表示半透明的黑色。

+

另一种是使用一个16进制的"32位整数" 0xAARRGGBB 来表示一个颜色,例如 0xFF112233表示颜色"#112233", 0x11223344表示颜色"#11223344"。

+

可以通过colors.toString()把颜色整数转换为字符串,通过colors.parseColor()把颜色字符串解析为颜色整数。

+

colors.toString(color)#

+
+

返回颜色值的字符串,格式为 "#AARRGGBB"。

+

colors.red(color)#

+
+

返回颜色color的R通道的值,范围0~255.

+

colors.green(color)#

+
+

返回颜色color的G通道的值,范围0~255.

+

colors.blue(color)#

+
+

返回颜色color的B通道的值,范围0~255.

+

colors.alpha(color)#

+
+

返回颜色color的Alpha通道的值,范围0~255.

+

colors.rgb(red, green, blue)#

+
+

返回这些颜色通道构成的整数颜色值。Alpha通道将是255(不透明)。

+

colors.argb(alpha, red, green, blue)#

+
+

返回这些颜色通道构成的整数颜色值。

+

colors.parseColor(colorStr)#

+
+

返回颜色的整数值。

+

colors.isSimilar(color2, color2[, threshold, algorithm])#

+
+

返回两个颜色是否相似。

+

colors.equals(color1, color2)#

+
+

返回两个颜色是否相等。*注意该函数会忽略Alpha通道的值进行比较

+
log(colors.equals("#112233", "#112234"));
+log(colors.equals(0xFF112233, 0xFF223344));
+

Images#

Stability: 2 - Stable

images模块提供了一些手机设备中常见的图片处理函数,包括截图、读写图片、图片剪裁、找色、找图等。

images.requestScreenCapture([landscape])#

向系统申请屏幕截图权限,返回是否请求成功。

第一次使用该函数会弹出截图权限请求,建议选择“总是允许”。

-

这个函数只是申请截图权限,并不会真正执行截图,真正的截图函数是[captureScreen][]。

-

该函数在截图脚本中只需执行一次,而无需每次调用[captureScreen][]都调用一次。

+

这个函数只是申请截图权限,并不会真正执行截图,真正的截图函数是captureScreen()

+

该函数在截图脚本中只需执行一次,而无需每次调用captureScreen()都调用一次。

如果不指定landscape值,则截图方向由当前设备屏幕方向决定,因此务必注意执行该函数时的屏幕方向。

建议在本软件界面运行该函数,在其他软件界面运行时容易出现一闪而过的黑屏现象。

示例:

@@ -379,48 +464,6 @@ if(p){ threshold: threshold })

该函数也可以作为全局函数使用。

-

colors#

-
Stability: 2 - Stable

colors是颜色处理的工具对象。包含一些常用方法,包括android.graphics.Color的所有方法以及toString方法。

-

colors.toString(color)#

-
-

返回颜色值的字符串,格式为 #AARRGGBB。

-

colors.red(color)#

-
-

返回颜色color的R通道的值,范围0~255.

-

colors.green(color)#

-
-

返回颜色color的G通道的值,范围0~255.

-

colors.blue(color)#

-
-

返回颜色color的B通道的值,范围0~255.

-

colors.alpha(color)#

-
-

返回颜色color的Alpha通道的值,范围0~255.

-

colors.rgb(red, green, blue)#

-
-

返回这些颜色通道构成的整数颜色值。Alpha通道将是255(不透明)。

-

colors.argb(alpha, red, green, blue)#

-
-

返回这些颜色通道构成的整数颜色值。

Image#

表示一张图片,可以是截图的图片,或者本地读取的图片,或者从网络获取的图片。

Image.getWidth()#

diff --git a/app/src/main/assets/docs/overview.html b/app/src/main/assets/docs/overview.html index 41a2c3ae..2350f9f2 100644 --- a/app/src/main/assets/docs/overview.html +++ b/app/src/main/assets/docs/overview.html @@ -103,6 +103,7 @@
  • threads: 多线程支持。
  • ui: UI界面。用于显示自定义的UI界面,和用户交互。
  • +

    除此之外,Auto.js内置了对Promise

    diff --git a/app/src/main/assets/indices/all.json b/app/src/main/assets/indices/all.json index 1b9202a7..ed6a4d4a 100644 --- a/app/src/main/assets/indices/all.json +++ b/app/src/main/assets/indices/all.json @@ -53,28 +53,28 @@ }, { "key": "openAppSetting", - "url": "globals.html#globals_getappname_packagename", + "url": "app.html#app_app_openappsetting_packagename", "summary": "应用设置页" }, { "key": "sendEmail", - "url": "globals.html#globals_getappname_packagename", - "summary": "应用设置页" + "url": "app.html#app_app_sendemail_options", + "summary": "发送邮件" }, { "key": "intent", - "url": "globals.html#globals_getpackagename_appname", - "summary": "获取包名" + "url": "app.html#app_app_intent_options", + "summary": "意图" }, { "key": "startActivity", - "url": "globals.html#globals_getpackagename_appname", - "summary": "获取包名" + "url": "app.html#app_app_startactivity_options", + "summary": "启动活动" }, { "key": "sendBroadcast", - "url": "globals.html#globals_getpackagename_appname", - "summary": "获取包名" + "url": "app.html#app_app_sendbroadcast_options", + "summary": "发送广播" } ] }, @@ -206,6 +206,26 @@ "key": "assert", "url": "console.html#console_console_assert_value_message", "summary": "断言" + }, + { + "key": "input", + "url": "console.html#console_console_input_data_args", + "summary": "输入" + }, + { + "key": "rawInput", + "url": "console.html#console_console_rawinput_data_args", + "summary": "输入字符串" + }, + { + "key": "setSize", + "url": "console.html#console_console_setsize_w_h", + "summary": "输入字符串" + }, + { + "key": "setPosition", + "url": "console.html#console_console_setposition_x_y", + "summary": "设置位置" } ] }, @@ -216,42 +236,42 @@ "properties": [ { "key": "select", - "url": "", + "url": "dialogs.html#dialogs_dialogs_select_title_items_callback", "summary": "选择" }, { "key": "singleChoice", - "url": "", + "url": "dialogs.html#dialogs_dialogs_singlechoice_title_items_index_callback", "summary": "单选" }, { "key": "multiChoice", - "url": "", + "url": "dialogs.html#dialogs_dialogs_multichoice_title_items_indices_callback", "summary": "多选" }, { "key": "rawInput", - "url": "", + "url": "dialogs.html#dialogs_dialogs_rawinput_title_prefill_callback", "summary": "输入字符串" }, { "key": "input", - "url": "", + "url": "dialogs.html#dialogs_dialogs_input_title_prefill_callback", "summary": "输入" }, { "key": "alert", - "url": "", + "url": "dialogs.html#dialogs_dialogs_alert_title_content_callback", "summary": "消息框" }, { "key": "confirm", - "url": "", + "url": "dialogs.html#dialogs_dialogs_confirm_title_content_callback", "summary": "确认框" }, { "key": "prompt", - "url": "", + "url": "dialogs.html#dialogs_dialogs_prompt_title_prefill_callback", "summary": "输入字符串" } ] @@ -262,8 +282,8 @@ "summary": "图色", "properties": [ { - "key": "saveImage", - "url": "images.html#images_images_saveimage_image_path", + "key": "save", + "url": "images.html#images_images_save_image_path", "summary": "保存图片" }, { @@ -273,12 +293,22 @@ }, { "key": "read", - "url": "", + "url": "images.html#images_images_read_path", "summary": "读取图片" }, + { + "key": "load", + "url": "images.html#images_images_load_url", + "summary": "加载图片" + }, + { + "key": "clip", + "url": "images.html#images_images_clip_img_x_y_w_h", + "summary": "剪切图片" + }, { "key": "requestScreenCapture", - "url": "images.html#images_requestscreencapture_width_height", + "url": "images.html#images_images_requestscreencapture_landscape", "summary": "请求截屏", "global": true }, @@ -305,6 +335,29 @@ "url": "images.html#images_images_findcolorequals_img_color_x_y_width_height_threads", "summary": "精确找色", "global": true + }, + { + "key": "findMultiColors", + "url": "images.html#images_images_clip_img_x_y_w_h", + "summary": "多点找色", + "global": true + }, + { + "key": "detectsColor", + "url": "images.html#images_images_detectscolor_image_color_x_y_threshold_16_algorithm_diff", + "summary": "颜色检测" + }, + { + "key": "findImage", + "url":"images.html#images_images_findimage_img_template_options", + "summary": "找图", + "global": true + }, + { + "key": "findImageInRegion", + "url":"images.html#images_images_findimageinregion_img_template_x_y_width_height_threshold", + "summary": "区域找图", + "global": true } ] }, @@ -341,12 +394,27 @@ { "key": "rgb", "url": "images.html#images_colors_rgb_red_green_blue", - "summary": "" + "summary": "RGB" }, { "key": "argb", "url": "images.html#images_colors_argb_alpha_red_green_blue", - "summary": "" + "summary": "ARGB" + }, + { + "key": "parseColor", + "url": "images.html#images_colors_parsecolor_colorstr", + "summary": "字符串转颜色" + }, + { + "key": "isSimilar", + "url": "images.html#images_colors_issimilar_color2_color2_threshold_algorithm", + "summary": "颜色相似" + }, + { + "key": "equals", + "url": "images.html#images_colors_equals_color1_color2", + "summary": "颜色相等" } ] }, @@ -549,8 +617,8 @@ "summary": "创建文件" }, { - "key": "createIfNotExists", - "url": "files.html#files_files_createifnotexists_path", + "key": "createWithDirs", + "url": "files.html#files_files_createwithdirs_path", "summary": "创建文件" }, { diff --git a/app/src/main/java/com/stardust/scriptdroid/ui/BaseActivity.java b/app/src/main/java/com/stardust/scriptdroid/ui/BaseActivity.java index 207d0923..62be27ea 100644 --- a/app/src/main/java/com/stardust/scriptdroid/ui/BaseActivity.java +++ b/app/src/main/java/com/stardust/scriptdroid/ui/BaseActivity.java @@ -85,12 +85,7 @@ public abstract class BaseActivity extends AppCompatActivity { toolbar.setTitle(title); activity.setSupportActionBar(toolbar); if (activity.getSupportActionBar() != null) { - toolbar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - activity.finish(); - } - }); + toolbar.setNavigationOnClickListener(v -> activity.finish()); activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); } } diff --git a/app/src/main/java/com/stardust/scriptdroid/ui/floating/CircularMenu.java b/app/src/main/java/com/stardust/scriptdroid/ui/floating/CircularMenu.java index fb6ac6d0..a82f2858 100644 --- a/app/src/main/java/com/stardust/scriptdroid/ui/floating/CircularMenu.java +++ b/app/src/main/java/com/stardust/scriptdroid/ui/floating/CircularMenu.java @@ -5,14 +5,13 @@ import android.content.Intent; import android.text.TextUtils; import android.view.ContextThemeWrapper; import android.view.View; -import android.widget.ImageView; import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; +import com.makeramen.roundedimageview.RoundedImageView; import com.stardust.app.DialogUtils; import com.stardust.app.OperationDialogBuilder; import com.stardust.autojs.core.record.Recorder; -import com.stardust.autojs.runtime.api.Dialogs; import com.stardust.enhancedfloaty.FloatyService; import com.stardust.floatingcircularactionmenu.CircularActionMenu; import com.stardust.floatingcircularactionmenu.CircularActionMenuFloatingWindow; @@ -34,7 +33,6 @@ import com.stardust.theme.dialog.ThemeColorMaterialDialogBuilder; import com.stardust.util.ClipboardUtil; import com.stardust.view.accessibility.LayoutInspector; import com.stardust.view.accessibility.NodeInfo; -import com.stericson.RootShell.RootShell; import org.greenrobot.eventbus.EventBus; import org.jdeferred.Deferred; @@ -77,7 +75,7 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp CircularActionMenuFloatingWindow mWindow; private int mState; - private ImageView mActionViewIcon; + private RoundedImageView mActionViewIcon; private Context mContext; private GlobalActionRecorder mRecorder; private MaterialDialog mSettingsDialog; @@ -113,7 +111,7 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp @Override public View inflateActionView(FloatyService service, CircularActionMenuFloatingWindow window) { View actionView = View.inflate(service, R.layout.circular_action_view, null); - mActionViewIcon = (ImageView) actionView.findViewById(R.id.icon); + mActionViewIcon = (RoundedImageView) actionView.findViewById(R.id.icon); return actionView; } @@ -169,13 +167,13 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp mState = state; mActionViewIcon.setImageResource(mState == STATE_RECORDING ? R.drawable.ic_ali_record : IC_ACTION_VIEW); + // mActionViewIcon.setBackgroundColor(mState == STATE_RECORDING ? mContext.getResources().getColor(R.color.color_red) : + // Color.WHITE); mActionViewIcon.setBackgroundResource(mState == STATE_RECORDING ? R.drawable.circle_red : - 0); - if (state == STATE_RECORDING) { - mActionViewIcon.setPadding(28, 28, 28, 28); - } else { - mActionViewIcon.setPadding(0, 0, 0, 0); - } + R.drawable.circle_white); + int padding = (int) mContext.getResources().getDimension(mState == STATE_RECORDING ? + R.dimen.padding_circular_menu_recording : R.dimen.padding_circular_menu_normal); + mActionViewIcon.setPadding(padding, padding, padding, padding); EventBus.getDefault().post(new StateChangeEvent(mState, previousState)); } diff --git a/app/src/main/java/com/stardust/scriptdroid/ui/main/drawer/DrawerFragment.java b/app/src/main/java/com/stardust/scriptdroid/ui/main/drawer/DrawerFragment.java index 760a1908..cae6b939 100644 --- a/app/src/main/java/com/stardust/scriptdroid/ui/main/drawer/DrawerFragment.java +++ b/app/src/main/java/com/stardust/scriptdroid/ui/main/drawer/DrawerFragment.java @@ -131,6 +131,7 @@ public class DrawerFragment extends android.support.v4.app.Fragment { ThemeColorManager.addViewBackground(mHeaderView); initMenuItems(); if (Pref.isFloatingMenuShown()) { + FloatyWindowManger.showCircularMenu(); setChecked(mFloatingWindowItem, true); } setChecked(mConnectionItem, DevPluginService.getInstance().isConnected()); diff --git a/app/src/main/res/layout/circular_action_view.xml b/app/src/main/res/layout/circular_action_view.xml index ae70d58f..af8682fa 100644 --- a/app/src/main/res/layout/circular_action_view.xml +++ b/app/src/main/res/layout/circular_action_view.xml @@ -10,8 +10,9 @@ android:layout_width="42dp" android:layout_height="42dp" android:background="@drawable/circle_white" - android:padding="5dp" + android:padding="@dimen/padding_circular_menu_normal" android:src="@drawable/ic_android_eat_js" app:riv_corner_radius="16dp" + app:riv_mutate_background="true" app:riv_oval="true"/> \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index a872500f..360d82f4 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -10,4 +10,5 @@ #9DA0A2 #282C2F #f0f0f0 + #ef5350 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 914e8e39..6efe6a89 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -9,4 +9,6 @@ 16dp 14sp 6dp + 8dp + 5dp diff --git a/autojs/src/main/AndroidManifest.xml b/autojs/src/main/AndroidManifest.xml index de84f1c7..4089509f 100644 --- a/autojs/src/main/AndroidManifest.xml +++ b/autojs/src/main/AndroidManifest.xml @@ -15,6 +15,7 @@ android:name=".execution.ScriptExecuteActivity" android:theme="@style/AppTheme"/> + >> 24; } colors.red = function(color){ + color = parseColor(color); return (color >> 16) & 0xFF; } colors.green = function(color){ + color = parseColor(color); return (color >> 8) & 0xFF; } colors.blue = function(color){ + color = parseColor(color); return color & 0xFF; } + + colors.isSimilar = function(c1, c2, threshold, algorithm){ + c1 = parseColor(c1); + c2 = parseColor(c2); + threshold = threshold == undefined ? 4 : threshold; + algorithm = algorithm == undefined ? "diff" : algorithm; + var colorDetector = getColorDetector(c1, algorithm, threshold); + return colorDetector.detectsColor(colors.red(c2), colors.green(c2), colors.blue(c2)); + } + if(android.os.Build.VERSION.SDK_INT < 19){ return images; } @@ -167,12 +181,8 @@ module.exports = function(__runtime__, scope){ function parseColor(color){ if(typeof(color) == 'string'){ - if(color.startsWith('#')){ - return parseInt('0x' + color.substring(1)); - }else{ - return parseInt('0x' + color); - } - } + color = colors.parseColor(color); + } return color; } diff --git a/autojs/src/main/assets/modules/lodash.js b/autojs/src/main/assets/modules/lodash.js deleted file mode 100644 index b909d31c..00000000 --- a/autojs/src/main/assets/modules/lodash.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Lodash (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE - * Build: `lodash core -o ./dist/lodash.core.js` - */ -;(function(){function n(n){return K(n)&&pn.call(n,"callee")&&!bn.call(n,"callee")}function t(n,t){return n.push.apply(n,t),n}function r(n){return function(t){return null==t?nn:t[n]}}function e(n,t,r,e,u){return u(n,function(n,u,o){r=e?(e=false,n):t(r,n,u,o)}),r}function u(n,t){return j(t,function(t){return n[t]})}function o(n){return n instanceof i?n:new i(n)}function i(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t}function c(n,t,r){if(typeof n!="function")throw new TypeError("Expected a function"); -return setTimeout(function(){n.apply(nn,r)},t)}function f(n,t){var r=true;return mn(n,function(n,e,u){return r=!!t(n,e,u)}),r}function a(n,t,r){for(var e=-1,u=n.length;++et}function y(n,t,r,e,u){return n===t||(null==n||null==t||!K(n)&&!K(t)?n!==n&&t!==t:b(n,t,r,e,y,u))}function b(n,t,r,e,u,o){var i=Nn(n),c=Nn(t),f=i?"[object Array]":hn.call(n),a=c?"[object Array]":hn.call(t),f="[object Arguments]"==f?"[object Object]":f,a="[object Arguments]"==a?"[object Object]":a,l="[object Object]"==f,c="[object Object]"==a,a=f==a;o||(o=[]);var p=An(o,function(t){return t[0]==n}),s=An(o,function(n){ -return n[0]==t});if(p&&s)return p[1]==t;if(o.push([n,t]),o.push([t,n]),a&&!l){if(i)r=B(n,t,r,e,u,o);else n:{switch(f){case"[object Boolean]":case"[object Date]":case"[object Number]":r=M(+n,+t);break n;case"[object Error]":r=n.name==t.name&&n.message==t.message;break n;case"[object RegExp]":case"[object String]":r=n==t+"";break n}r=false}return o.pop(),r}return 1&r||(i=l&&pn.call(n,"__wrapped__"),f=c&&pn.call(t,"__wrapped__"),!i&&!f)?!!a&&(r=R(n,t,r,e,u,o),o.pop(),r):(i=i?n.value():n,f=f?t.value():t, -r=u(i,f,r,e,o),o.pop(),r)}function g(n){return typeof n=="function"?n:null==n?Y:(typeof n=="object"?d:r)(n)}function _(n,t){return nt&&(t=-t>u?0:u+t),r=r>u?u:r,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Array(u);++ei))return false;for(var c=-1,f=true,a=2&r?[]:nn;++cr?jn(e+r,0):r:0,r=(r||0)-1;for(var u=t===t;++rarguments.length,mn)}function J(n,t){var r;if(typeof t!="function")throw new TypeError("Expected a function");return n=Fn(n),function(){return 0<--n&&(r=t.apply(this,arguments)),1>=n&&(t=nn),r}}function M(n,t){return n===t||n!==n&&t!==t}function U(n){var t;return(t=null!=n)&&(t=n.length,t=typeof t=="number"&&-1=t),t&&!V(n)}function V(n){return!!H(n)&&(n=hn.call(n),"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n); -}function H(n){var t=typeof n;return null!=n&&("object"==t||"function"==t)}function K(n){return null!=n&&typeof n=="object"}function L(n){return typeof n=="number"||K(n)&&"[object Number]"==hn.call(n)}function Q(n){return typeof n=="string"||!Nn(n)&&K(n)&&"[object String]"==hn.call(n)}function W(n){return typeof n=="string"?n:null==n?"":n+""}function X(n){return null==n?[]:u(n,In(n))}function Y(n){return n}function Z(n,r,e){var u=In(r),o=h(r,u);null!=e||H(r)&&(o.length||!u.length)||(e=r,r=n,n=this,o=h(r,In(r))); -var i=!(H(e)&&"chain"in e&&!e.chain),c=V(n);return mn(o,function(e){var u=r[e];n[e]=u,c&&(n.prototype[e]=function(){var r=this.__chain__;if(i||r){var e=n(this.__wrapped__);return(e.__actions__=A(this.__actions__)).push({func:u,args:arguments,thisArg:n}),e.__chain__=r,e}return u.apply(n,t([this.value()],arguments))})}),n}var nn,tn=1/0,rn=/[&<>"']/g,en=RegExp(rn.source),un=typeof self=="object"&&self&&self.Object===Object&&self,on=typeof global=="object"&&global&&global.Object===Object&&global||un||Function("return this")(),cn=(un=typeof exports=="object"&&exports&&!exports.nodeType&&exports)&&typeof module=="object"&&module&&!module.nodeType&&module,fn=function(n){ -return function(t){return null==n?nn:n[t]}}({"&":"&","<":"<",">":">",'"':""","'":"'"}),an=Array.prototype,ln=Object.prototype,pn=ln.hasOwnProperty,sn=0,hn=ln.toString,vn=on._,yn=Object.create,bn=ln.propertyIsEnumerable,gn=on.isFinite,_n=function(n,t){return function(r){return n(t(r))}}(Object.keys,Object),jn=Math.max,dn=function(){function n(){}return function(t){return H(t)?yn?yn(t):(n.prototype=t,t=new n,n.prototype=nn,t):{}}}();i.prototype=dn(o.prototype),i.prototype.constructor=i; -var mn=function(n,t){return function(r,e){if(null==r)return r;if(!U(r))return n(r,e);for(var u=r.length,o=t?u:-1,i=Object(r);(t?o--:++or&&(r=jn(e+r,0));n:{for(t=g(t),e=n.length,r+=-1;++re||o&&c&&a||!u&&a||!i){r=1;break n}if(!o&&r + + + + diff --git a/inrt/src/main/assets/roboto_medium.ttf b/inrt/src/main/assets/roboto_medium.ttf new file mode 100644 index 00000000..1a7f3b0b Binary files /dev/null and b/inrt/src/main/assets/roboto_medium.ttf differ diff --git a/inrt/src/main/java/com/stardust/auojs/inrt/Pref.java b/inrt/src/main/java/com/stardust/auojs/inrt/Pref.java index 23a9d03b..7b19237b 100644 --- a/inrt/src/main/java/com/stardust/auojs/inrt/Pref.java +++ b/inrt/src/main/java/com/stardust/auojs/inrt/Pref.java @@ -9,6 +9,7 @@ import android.preference.PreferenceManager; public class Pref { + private static final String KEY_FIRST_USING = "key_first_using"; private static SharedPreferences sPreferences; public static SharedPreferences getPreferences() { @@ -36,4 +37,12 @@ public class Pref { public static boolean shouldStopAllScriptsWhenVolumeUp() { return getPreferences().getBoolean(getString(R.string.key_use_volume_control_running), true); } + + public static boolean isFirstUsing() { + boolean firstUsing = getPreferences().getBoolean(KEY_FIRST_USING, true); + if (firstUsing) { + getPreferences().edit().putBoolean(KEY_FIRST_USING, false).apply(); + } + return firstUsing; + } } diff --git a/inrt/src/main/java/com/stardust/auojs/inrt/SettingsActivity.java b/inrt/src/main/java/com/stardust/auojs/inrt/SettingsActivity.java index 51ce8a7e..195f307e 100644 --- a/inrt/src/main/java/com/stardust/auojs/inrt/SettingsActivity.java +++ b/inrt/src/main/java/com/stardust/auojs/inrt/SettingsActivity.java @@ -28,8 +28,8 @@ public class SettingsActivity extends AppCompatActivity { getFragmentManager().beginTransaction().replace(R.id.fragment_setting, new PreferenceFragment()).commit(); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(R.string.text_settings); - toolbar.setNavigationOnClickListener(v -> finish()); setSupportActionBar(toolbar); + toolbar.setNavigationOnClickListener(v -> finish()); getSupportActionBar().setDisplayHomeAsUpEnabled(true); } diff --git a/inrt/src/main/java/com/stardust/auojs/inrt/SplashActivity.java b/inrt/src/main/java/com/stardust/auojs/inrt/SplashActivity.java new file mode 100644 index 00000000..8f57fdcb --- /dev/null +++ b/inrt/src/main/java/com/stardust/auojs/inrt/SplashActivity.java @@ -0,0 +1,36 @@ +package com.stardust.auojs.inrt; + +import android.content.Intent; +import android.graphics.Typeface; +import android.os.Bundle; +import android.os.Handler; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; +import android.widget.TextView; + +/** + * Created by Stardust on 2018/2/2. + */ + +public class SplashActivity extends AppCompatActivity { + + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (!Pref.isFirstUsing()) { + main(); + return; + } + setContentView(R.layout.activity_splash); + TextView slug = (TextView) findViewById(R.id.slug); + slug.setTypeface(Typeface.createFromAsset(getAssets(), "roboto_medium.ttf")); + new Handler().postDelayed(this::main, 2500); + } + + private void main() { + startActivity(new Intent(this, MainActivity.class)); + finish(); + } +} + diff --git a/inrt/src/main/res/layout/activity_main.xml b/inrt/src/main/res/layout/activity_main.xml index d4181dc6..b05fcb7e 100644 --- a/inrt/src/main/res/layout/activity_main.xml +++ b/inrt/src/main/res/layout/activity_main.xml @@ -10,12 +10,14 @@ + android:layout_height="wrap_content" + android:theme="@style/AppTheme.AppBarOverlay"> + android:layout_height="wrap_content" + app:popupTheme="@style/AppTheme.PopupOverlay"/> diff --git a/inrt/src/main/res/layout/activity_settings.xml b/inrt/src/main/res/layout/activity_settings.xml index 9af8c441..4a945afa 100644 --- a/inrt/src/main/res/layout/activity_settings.xml +++ b/inrt/src/main/res/layout/activity_settings.xml @@ -10,12 +10,14 @@ + android:layout_height="wrap_content" + android:theme="@style/AppTheme.AppBarOverlay"> + android:layout_height="wrap_content" + app:popupTheme="@style/AppTheme.PopupOverlay"/> diff --git a/inrt/src/main/res/layout/activity_splash.xml b/inrt/src/main/res/layout/activity_splash.xml new file mode 100644 index 00000000..63daaafc --- /dev/null +++ b/inrt/src/main/res/layout/activity_splash.xml @@ -0,0 +1,22 @@ + + + + + + + \ No newline at end of file diff --git a/inrt/src/main/res/values/colors.xml b/inrt/src/main/res/values/colors.xml deleted file mode 100644 index 3ab3e9cb..00000000 --- a/inrt/src/main/res/values/colors.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - #3F51B5 - #303F9F - #FF4081 - diff --git a/inrt/src/main/res/values/strings.xml b/inrt/src/main/res/values/strings.xml index f99c11c0..16d7fa2f 100644 --- a/inrt/src/main/res/values/strings.xml +++ b/inrt/src/main/res/values/strings.xml @@ -19,4 +19,5 @@ key_dont_show_main_activity 打开应用后直接运行脚本 其他 + Powered by Auto.js diff --git a/inrt/src/main/res/values/styles.xml b/inrt/src/main/res/values/styles.xml index 0eb88fe3..f0f88212 100644 --- a/inrt/src/main/res/values/styles.xml +++ b/inrt/src/main/res/values/styles.xml @@ -8,4 +8,15 @@ @color/colorAccent + + + +