6.6.1 - Alpha2 - 尝试修复脚本快捷方式添加问题
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
{
|
{
|
||||||
"$data": {
|
"$data": {
|
||||||
"v6.6.1": {
|
"v6.6.1": {
|
||||||
"released_date": "2024/12/05",
|
"released_date": "2024/12/07",
|
||||||
"feature": [
|
"feature": [
|
||||||
"pinyin 模块, 用于汉语拼音转换 (参阅 项目文档 > [汉语拼音](https://docs.autojs6.com/#/pinyin))"
|
"pinyin 模块, 用于汉语拼音转换 (参阅 项目文档 > [汉语拼音](https://docs.autojs6.com/#/pinyin))"
|
||||||
],
|
],
|
||||||
"fix": [
|
"fix": [
|
||||||
"部分环境因回退版本过低而无法正常编译项目的问题",
|
"部分环境因回退版本过低而无法正常编译项目的问题",
|
||||||
"调用不存在的方法时可能出现的 \"非原始类型值\" 异常"
|
"调用不存在的方法时可能出现的 \"非原始类型值\" 异常",
|
||||||
|
"部分设备无法正常添加脚本快捷方式的问题 (试修) _[`issue #221`](http://issues.autojs6.com/221)_"
|
||||||
],
|
],
|
||||||
"improvement": [
|
"improvement": [
|
||||||
"脚本项目识别在 project.json 损坏情况下尽可能还原关键信息",
|
"脚本项目识别在 project.json 损坏情况下尽可能还原关键信息",
|
||||||
|
|||||||
166
.idea/codeStyles/Project.xml
generated
166
.idea/codeStyles/Project.xml
generated
@@ -1,9 +1,6 @@
|
|||||||
<component name="ProjectCodeStyleConfiguration">
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
<code_scheme name="Project" version="173">
|
<code_scheme name="Project" version="173">
|
||||||
<option name="RIGHT_MARGIN" value="1000" />
|
<option name="RIGHT_MARGIN" value="1000" />
|
||||||
<AndroidXmlCodeStyleSettings>
|
|
||||||
<option name="USE_CUSTOM_SETTINGS" value="true" />
|
|
||||||
</AndroidXmlCodeStyleSettings>
|
|
||||||
<JSCodeStyleSettings version="0">
|
<JSCodeStyleSettings version="0">
|
||||||
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
||||||
<option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACKETS" value="true" />
|
<option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACKETS" value="true" />
|
||||||
@@ -13,175 +10,14 @@
|
|||||||
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
||||||
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
||||||
</JSCodeStyleSettings>
|
</JSCodeStyleSettings>
|
||||||
<JavaCodeStyleSettings>
|
|
||||||
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" />
|
|
||||||
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="10" />
|
|
||||||
</JavaCodeStyleSettings>
|
|
||||||
<JetCodeStyleSettings>
|
<JetCodeStyleSettings>
|
||||||
<option name="LINE_BREAK_AFTER_MULTILINE_WHEN_ENTRY" value="false" />
|
|
||||||
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
|
|
||||||
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
|
|
||||||
<option name="ALLOW_TRAILING_COMMA" value="true" />
|
|
||||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
</JetCodeStyleSettings>
|
</JetCodeStyleSettings>
|
||||||
<TypeScriptCodeStyleSettings version="0">
|
|
||||||
<option name="VAR_DECLARATION_WRAP" value="0" />
|
|
||||||
<option name="UNION_TYPES_WRAP" value="0" />
|
|
||||||
<option name="BLANK_LINES_AROUND_FUNCTION" value="0" />
|
|
||||||
</TypeScriptCodeStyleSettings>
|
|
||||||
<XML>
|
|
||||||
<option name="XML_KEEP_LINE_BREAKS" value="false" />
|
|
||||||
<option name="XML_ALIGN_ATTRIBUTES" value="false" />
|
|
||||||
<option name="XML_SPACE_INSIDE_EMPTY_TAG" value="true" />
|
|
||||||
</XML>
|
|
||||||
<codeStyleSettings language="Groovy">
|
|
||||||
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" />
|
|
||||||
<option name="BLOCK_COMMENT_AT_FIRST_COLUMN" value="false" />
|
|
||||||
<option name="LINE_COMMENT_ADD_SPACE" value="true" />
|
|
||||||
<option name="BLOCK_COMMENT_ADD_SPACE" value="true" />
|
|
||||||
<option name="LINE_COMMENT_ADD_SPACE_ON_REFORMAT" value="true" />
|
|
||||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
|
||||||
</codeStyleSettings>
|
|
||||||
<codeStyleSettings language="JAVA">
|
<codeStyleSettings language="JAVA">
|
||||||
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" />
|
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" />
|
||||||
<option name="BLOCK_COMMENT_AT_FIRST_COLUMN" value="false" />
|
|
||||||
<option name="LINE_COMMENT_ADD_SPACE" value="true" />
|
|
||||||
<option name="BLOCK_COMMENT_ADD_SPACE" value="true" />
|
|
||||||
<option name="LINE_COMMENT_ADD_SPACE_ON_REFORMAT" value="true" />
|
|
||||||
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
|
|
||||||
</codeStyleSettings>
|
|
||||||
<codeStyleSettings language="TypeScript">
|
|
||||||
<option name="BLANK_LINES_AROUND_CLASS" value="0" />
|
|
||||||
<option name="BLANK_LINES_AROUND_METHOD" value="0" />
|
|
||||||
<option name="BLANK_LINES_AROUND_METHOD_IN_INTERFACE" value="0" />
|
|
||||||
<option name="KEEP_SIMPLE_BLOCKS_IN_ONE_LINE" value="true" />
|
|
||||||
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
|
|
||||||
</codeStyleSettings>
|
|
||||||
<codeStyleSettings language="XML">
|
|
||||||
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" />
|
|
||||||
<option name="BLOCK_COMMENT_AT_FIRST_COLUMN" value="false" />
|
|
||||||
<option name="BLOCK_COMMENT_ADD_SPACE" value="true" />
|
|
||||||
<option name="FORCE_REARRANGE_MODE" value="1" />
|
|
||||||
<indentOptions>
|
|
||||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
|
||||||
<option name="SMART_TABS" value="true" />
|
|
||||||
</indentOptions>
|
|
||||||
<arrangement>
|
|
||||||
<rules>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>xmlns:android</NAME>
|
|
||||||
<XML_ATTRIBUTE />
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>xmlns:.*</NAME>
|
|
||||||
<XML_ATTRIBUTE />
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:id</NAME>
|
|
||||||
<XML_ATTRIBUTE />
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:name</NAME>
|
|
||||||
<XML_ATTRIBUTE />
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>name</NAME>
|
|
||||||
<XML_ATTRIBUTE />
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>style</NAME>
|
|
||||||
<XML_ATTRIBUTE />
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*</NAME>
|
|
||||||
<XML_ATTRIBUTE />
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*</NAME>
|
|
||||||
<XML_ATTRIBUTE />
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*</NAME>
|
|
||||||
<XML_ATTRIBUTE />
|
|
||||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
</rules>
|
|
||||||
</arrangement>
|
|
||||||
</codeStyleSettings>
|
</codeStyleSettings>
|
||||||
<codeStyleSettings language="kotlin">
|
<codeStyleSettings language="kotlin">
|
||||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" />
|
|
||||||
<option name="BLOCK_COMMENT_AT_FIRST_COLUMN" value="false" />
|
|
||||||
<option name="LINE_COMMENT_ADD_SPACE" value="true" />
|
|
||||||
<option name="BLOCK_COMMENT_ADD_SPACE" value="true" />
|
|
||||||
<option name="LINE_COMMENT_ADD_SPACE_ON_REFORMAT" value="true" />
|
|
||||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
|
||||||
</codeStyleSettings>
|
</codeStyleSettings>
|
||||||
</code_scheme>
|
</code_scheme>
|
||||||
</component>
|
</component>
|
||||||
@@ -11,6 +11,7 @@ import android.view.View;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.core.content.pm.ShortcutManagerCompat;
|
||||||
import com.afollestad.materialdialogs.DialogAction;
|
import com.afollestad.materialdialogs.DialogAction;
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
import com.tencent.bugly.crashreport.BuglyLog;
|
import com.tencent.bugly.crashreport.BuglyLog;
|
||||||
@@ -38,6 +39,7 @@ import org.autojs.autojs.ui.filechooser.FileChooserDialogBuilder;
|
|||||||
import org.autojs.autojs.ui.shortcut.ShortcutCreateActivity;
|
import org.autojs.autojs.ui.shortcut.ShortcutCreateActivity;
|
||||||
import org.autojs.autojs.ui.timing.TimedTaskSettingActivity;
|
import org.autojs.autojs.ui.timing.TimedTaskSettingActivity;
|
||||||
import org.autojs.autojs.util.EnvironmentUtils;
|
import org.autojs.autojs.util.EnvironmentUtils;
|
||||||
|
import org.autojs.autojs.util.ShortcutUtils;
|
||||||
import org.autojs.autojs.util.ViewUtils;
|
import org.autojs.autojs.util.ViewUtils;
|
||||||
import org.autojs.autojs.util.WorkingDirectoryUtils;
|
import org.autojs.autojs.util.WorkingDirectoryUtils;
|
||||||
import org.autojs.autojs6.R;
|
import org.autojs.autojs6.R;
|
||||||
@@ -363,8 +365,14 @@ public class ScriptOperations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void createShortcut(ScriptFile file) {
|
public void createShortcut(ScriptFile file) {
|
||||||
mContext.startActivity(new Intent(mContext, ShortcutCreateActivity.class)
|
if (!ShortcutManagerCompat.isRequestPinShortcutSupported(mContext)) {
|
||||||
.putExtra(ShortcutCreateActivity.EXTRA_FILE, file));
|
ShortcutUtils.showPinShortcutNotSupportedDialog(mContext);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Intent intent = new Intent(mContext, ShortcutCreateActivity.class)
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
.putExtra(ShortcutCreateActivity.EXTRA_FILE, file);
|
||||||
|
mContext.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(final ScriptFile scriptFile) {
|
public void delete(final ScriptFile scriptFile) {
|
||||||
@@ -390,7 +398,7 @@ public class ScriptOperations {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String content = mContext.getString(R.string.text_old_path) + ": " + oldPath + "\n"
|
String content = mContext.getString(R.string.text_old_path) + ": " + oldPath + "\n"
|
||||||
+ mContext.getString(R.string.text_new_path) + ": " + newPath;
|
+ mContext.getString(R.string.text_new_path) + ": " + newPath;
|
||||||
new MaterialDialog.Builder(mContext)
|
new MaterialDialog.Builder(mContext)
|
||||||
.title(mContext.getString(R.string.text_prompt))
|
.title(mContext.getString(R.string.text_prompt))
|
||||||
.content(content)
|
.content(content)
|
||||||
|
|||||||
@@ -12,19 +12,19 @@ import org.autojs.autojs6.databinding.ActivityDocumentationBinding
|
|||||||
*/
|
*/
|
||||||
class DocumentationActivity : BaseActivity() {
|
class DocumentationActivity : BaseActivity() {
|
||||||
|
|
||||||
private lateinit var binding: ActivityDocumentationBinding
|
private var binding: ActivityDocumentationBinding? = null
|
||||||
|
|
||||||
private lateinit var mWebView: WebView
|
private lateinit var mWebView: WebView
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityDocumentationBinding.inflate(layoutInflater)
|
binding = ActivityDocumentationBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding!!.root)
|
||||||
setupViews()
|
setupViews()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupViews() {
|
private fun setupViews() {
|
||||||
mWebView = binding.ewebView.webView.also {
|
mWebView = binding!!.ewebView.webView.also {
|
||||||
it.loadUrl(intent.getStringExtra(EXTRA_URL) ?: getUrl("index.html"))
|
it.loadUrl(intent.getStringExtra(EXTRA_URL) ?: getUrl("index.html"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,11 @@ class DocumentationActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
binding = null
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
const val EXTRA_URL = "url"
|
const val EXTRA_URL = "url"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package org.autojs.autojs.ui.settings
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.widget.LinearLayout
|
import android.view.LayoutInflater
|
||||||
import androidx.core.content.pm.ShortcutManagerCompat
|
import androidx.core.content.pm.ShortcutManagerCompat
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import org.autojs.autojs.theme.preference.MaterialPreference
|
import org.autojs.autojs.theme.preference.MaterialPreference
|
||||||
@@ -10,54 +10,57 @@ import org.autojs.autojs.ui.doc.DocumentationActivity
|
|||||||
import org.autojs.autojs.ui.log.LogActivity
|
import org.autojs.autojs.ui.log.LogActivity
|
||||||
import org.autojs.autojs.util.ShortcutUtils
|
import org.autojs.autojs.util.ShortcutUtils
|
||||||
import org.autojs.autojs6.R
|
import org.autojs.autojs6.R
|
||||||
|
import org.autojs.autojs6.databinding.SelectLauncherShortcutBinding
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by SuperMonster003 on Sep 25, 2022.
|
* Created by SuperMonster003 on Sep 25, 2022.
|
||||||
*/
|
*/
|
||||||
class LauncherShortcutsPreference : MaterialPreference {
|
class LauncherShortcutsPreference : MaterialPreference {
|
||||||
|
|
||||||
private val mDialog = MaterialDialog.Builder(prefContext)
|
private var binding: SelectLauncherShortcutBinding? = null
|
||||||
.customView(R.layout.select_launcher_shortcut, true)
|
|
||||||
.build()
|
|
||||||
.also { dialog ->
|
|
||||||
val view = dialog.customView as LinearLayout
|
|
||||||
|
|
||||||
view.findViewById<LinearLayout?>(R.id.launcher_shortcut_settings).setOnClickListener {
|
private val mDialog by lazy {
|
||||||
dialog.dismiss()
|
|
||||||
ShortcutUtils.requestPinShortcut(
|
|
||||||
prefContext,
|
|
||||||
R.string.id_launcher_shortcut_settings,
|
|
||||||
PreferencesActivity::class.java.name,
|
|
||||||
R.string.text_app_shortcut_settings_long_label,
|
|
||||||
R.string.text_app_shortcut_settings_short_label,
|
|
||||||
R.mipmap.ic_app_shortcut_settings_adaptive,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
view.findViewById<LinearLayout?>(R.id.launcher_shortcut_docs).setOnClickListener {
|
val binding = SelectLauncherShortcutBinding.inflate(LayoutInflater.from(prefContext)).also { binding = it }
|
||||||
dialog.dismiss()
|
|
||||||
ShortcutUtils.requestPinShortcut(
|
|
||||||
prefContext,
|
|
||||||
R.string.id_launcher_shortcut_docs,
|
|
||||||
DocumentationActivity::class.java.name,
|
|
||||||
R.string.text_app_shortcut_docs_long_label,
|
|
||||||
R.string.text_app_shortcut_docs_short_label,
|
|
||||||
R.mipmap.ic_app_shortcut_docs_adaptive,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
view.findViewById<LinearLayout?>(R.id.launcher_shortcut_log).setOnClickListener {
|
MaterialDialog.Builder(prefContext)
|
||||||
dialog.dismiss()
|
.customView(binding.root, true)
|
||||||
ShortcutUtils.requestPinShortcut(
|
.build()
|
||||||
prefContext,
|
.also { dialog ->
|
||||||
R.string.id_launcher_shortcut_log,
|
binding.launcherShortcutSettings.setOnClickListener {
|
||||||
LogActivity::class.java.name,
|
ShortcutUtils.requestPinShortcut(
|
||||||
R.string.text_app_shortcut_log_long_label,
|
prefContext,
|
||||||
R.string.text_app_shortcut_log_short_label,
|
R.string.id_launcher_shortcut_settings,
|
||||||
R.mipmap.ic_app_shortcut_log_adaptive,
|
PreferencesActivity::class.java.name,
|
||||||
)
|
R.string.text_app_shortcut_settings_long_label,
|
||||||
|
R.string.text_app_shortcut_settings_short_label,
|
||||||
|
R.mipmap.ic_app_shortcut_settings_adaptive,
|
||||||
|
).also { dialog.dismiss() }
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.launcherShortcutDocs.setOnClickListener {
|
||||||
|
ShortcutUtils.requestPinShortcut(
|
||||||
|
prefContext,
|
||||||
|
R.string.id_launcher_shortcut_docs,
|
||||||
|
DocumentationActivity::class.java.name,
|
||||||
|
R.string.text_app_shortcut_docs_long_label,
|
||||||
|
R.string.text_app_shortcut_docs_short_label,
|
||||||
|
R.mipmap.ic_app_shortcut_docs_adaptive,
|
||||||
|
).also { dialog.dismiss() }
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.launcherShortcutLog.setOnClickListener {
|
||||||
|
ShortcutUtils.requestPinShortcut(
|
||||||
|
prefContext,
|
||||||
|
R.string.id_launcher_shortcut_log,
|
||||||
|
LogActivity::class.java.name,
|
||||||
|
R.string.text_app_shortcut_log_long_label,
|
||||||
|
R.string.text_app_shortcut_log_short_label,
|
||||||
|
R.mipmap.ic_app_shortcut_log_adaptive,
|
||||||
|
).also { dialog.dismiss() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
|
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||||
|
|
||||||
@@ -71,22 +74,18 @@ class LauncherShortcutsPreference : MaterialPreference {
|
|||||||
if (ShortcutManagerCompat.isRequestPinShortcutSupported(prefContext)) {
|
if (ShortcutManagerCompat.isRequestPinShortcutSupported(prefContext)) {
|
||||||
showShortcutsSelectionDialog()
|
showShortcutsSelectionDialog()
|
||||||
} else {
|
} else {
|
||||||
showPinShortcutNotSupportedDialog()
|
ShortcutUtils.showPinShortcutNotSupportedDialog(prefContext)
|
||||||
}
|
}
|
||||||
super.onClick()
|
super.onClick()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDetached() {
|
||||||
|
super.onDetached()
|
||||||
|
binding = null
|
||||||
|
}
|
||||||
|
|
||||||
private fun showShortcutsSelectionDialog() {
|
private fun showShortcutsSelectionDialog() {
|
||||||
if (!mDialog.isShowing) mDialog.show()
|
if (!mDialog.isShowing) mDialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showPinShortcutNotSupportedDialog() {
|
|
||||||
MaterialDialog.Builder(prefContext)
|
|
||||||
.title(R.string.text_prompt)
|
|
||||||
.content(R.string.text_pin_shortcut_not_unsupported)
|
|
||||||
.positiveText(R.string.dialog_button_dismiss)
|
|
||||||
.build()
|
|
||||||
.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,18 +99,34 @@ public class ShortcutCreateActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.N_MR1)
|
@RequiresApi(api = Build.VERSION_CODES.N_MR1)
|
||||||
private void createShortcutByShortcutManager() {
|
private void createShortcutByShortcutManager() {
|
||||||
CharSequence name = mName.getText();
|
|
||||||
|
// @Caution by SuperMonster003 on Dec 7, 2024.
|
||||||
|
// ! It is necessary to convert to String type here,
|
||||||
|
// ! rather than retaining the CharSequence type obtained from getText().
|
||||||
|
// ! This is because on certain devices [such as MIUI 14 (Android 13)],
|
||||||
|
// ! ShortcutInfoCompat.Builder#setShortLabel and setLongLabel
|
||||||
|
// ! can only accept String type data returned by getText().
|
||||||
|
// ! If CharSequence type data is directly passed in, the shortcut will fail to create properly.
|
||||||
|
// !
|
||||||
|
// ! zh-CN:
|
||||||
|
// !
|
||||||
|
// ! 此处需要转换为 String 类型, 而不能保留 getText() 方法得到的 CharSequence 类型.
|
||||||
|
// ! 这是因为在一些特殊设备上 [如 MIUI 14 (Android 13)],
|
||||||
|
// ! ShortcutInfoCompat.Builder#setShortLabel 及 setLongLabel 只能接受 getText() 返回的 String 类型数据,
|
||||||
|
// ! 如果直接传入 CharSequence 类型数据, 快捷方式将无法正常创建.
|
||||||
|
// !
|
||||||
|
// # CharSequence name = mName.getText();
|
||||||
|
String name = mName.getText().toString();
|
||||||
|
|
||||||
/* To make each script be able to have its own individual icon. */
|
/* To make each script be able to have its own individual icon. */
|
||||||
String id = ShortcutActivity.class.getName() + "$" + name + "@" + System.currentTimeMillis();
|
String id = ShortcutActivity.class.getName() + "$" + name + "@" + System.currentTimeMillis();
|
||||||
Intent intent = new Intent(this, ShortcutActivity.class)
|
Intent intent = new Intent(this, ShortcutActivity.class)
|
||||||
.putExtra(ScriptIntents.EXTRA_KEY_PATH, mScriptFile.getPath())
|
.putExtra(ScriptIntents.EXTRA_KEY_PATH, mScriptFile.getPath())
|
||||||
.setAction(Intent.ACTION_MAIN);
|
.setAction(Intent.ACTION_MAIN);
|
||||||
if (mIsDefaultIcon) {
|
if (mIsDefaultIcon) {
|
||||||
Icon icon = Icon.createWithResource(this, R.drawable.ic_file_type_js_dark_green);
|
ShortcutUtils.requestPinShortcut(this, id, intent, name, name, R.drawable.ic_file_type_js_dark_green);
|
||||||
ShortcutUtils.requestPinShortcut(this, id, intent, name, name, icon);
|
|
||||||
} else {
|
} else {
|
||||||
Bitmap bitmap = BitmapUtils.drawableToBitmap(mIcon.getDrawable());
|
ShortcutUtils.requestPinShortcut(this, id, intent, name, name, mIcon.getDrawable());
|
||||||
ShortcutUtils.requestPinShortcut(this, id, intent, name, name, bitmap);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,13 @@ import android.app.PendingIntent
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
import android.graphics.drawable.Icon
|
import android.graphics.drawable.Icon
|
||||||
import androidx.core.content.pm.ShortcutInfoCompat
|
import androidx.core.content.pm.ShortcutInfoCompat
|
||||||
import androidx.core.content.pm.ShortcutManagerCompat
|
import androidx.core.content.pm.ShortcutManagerCompat
|
||||||
import androidx.core.graphics.drawable.IconCompat
|
import androidx.core.graphics.drawable.IconCompat
|
||||||
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
|
import org.autojs.autojs6.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by SuperMonster003 on Oct 11, 2022.
|
* Created by SuperMonster003 on Oct 11, 2022.
|
||||||
@@ -19,6 +22,16 @@ object ShortcutUtils {
|
|||||||
requestPinShortcut(context, context.getString(id), className, context.getString(longLabelResId), context.getString(shortLabelResId), IconCompat.createWithResource(context, iconResId))
|
requestPinShortcut(context, context.getString(id), className, context.getString(longLabelResId), context.getString(shortLabelResId), IconCompat.createWithResource(context, iconResId))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun requestPinShortcut(context: Context, id: String, intent: Intent, longLabel: CharSequence, shortLabel: CharSequence, iconResId: Int) {
|
||||||
|
requestPinShortcut(context, id, intent, longLabel, shortLabel, IconCompat.createWithResource(context, iconResId))
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun requestPinShortcut(context: Context, id: String, intent: Intent, longLabel: CharSequence, shortLabel: CharSequence, drawable: Drawable) {
|
||||||
|
requestPinShortcut(context, id, intent, longLabel, shortLabel, BitmapUtils.drawableToBitmap(drawable))
|
||||||
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun requestPinShortcut(context: Context, id: String, className: String, longLabel: CharSequence, shortLabel: CharSequence, icon: IconCompat) {
|
fun requestPinShortcut(context: Context, id: String, className: String, longLabel: CharSequence, shortLabel: CharSequence, icon: IconCompat) {
|
||||||
requestPinShortcut(context, id, Intent("android.intent.action.VIEW").setClassName(context, className), longLabel, shortLabel, icon)
|
requestPinShortcut(context, id, Intent("android.intent.action.VIEW").setClassName(context, className), longLabel, shortLabel, icon)
|
||||||
@@ -39,7 +52,7 @@ object ShortcutUtils {
|
|||||||
// The shortcut must be enabled.
|
// The shortcut must be enabled.
|
||||||
// The "id" for ShortcutInfoCompat.Builder must contain stable, constant strings.
|
// The "id" for ShortcutInfoCompat.Builder must contain stable, constant strings.
|
||||||
val pinShortcutInfo = ShortcutInfoCompat.Builder(context, id)
|
val pinShortcutInfo = ShortcutInfoCompat.Builder(context, id)
|
||||||
.setIntent(intent)
|
.setIntent(intent.apply { action = action ?: Intent.ACTION_VIEW })
|
||||||
.setLongLabel(longLabel)
|
.setLongLabel(longLabel)
|
||||||
.setShortLabel(shortLabel)
|
.setShortLabel(shortLabel)
|
||||||
.setIcon(icon)
|
.setIcon(icon)
|
||||||
@@ -55,9 +68,18 @@ object ShortcutUtils {
|
|||||||
|
|
||||||
// Configure the intent so that your app's broadcast receiver gets
|
// Configure the intent so that your app's broadcast receiver gets
|
||||||
// the callback successfully.For details, see PendingIntent.getBroadcast().
|
// the callback successfully.For details, see PendingIntent.getBroadcast().
|
||||||
val successCallback = PendingIntent.getBroadcast(context, 0, pinnedShortcutCallbackIntent, PendingIntent.FLAG_IMMUTABLE)
|
val successCallback = PendingIntent.getBroadcast(context, 0, pinnedShortcutCallbackIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
||||||
|
|
||||||
ShortcutManagerCompat.requestPinShortcut(context, pinShortcutInfo, successCallback.intentSender)
|
ShortcutManagerCompat.requestPinShortcut(context, pinShortcutInfo, successCallback.intentSender)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun showPinShortcutNotSupportedDialog(context: Context): MaterialDialog {
|
||||||
|
return MaterialDialog.Builder(context)
|
||||||
|
.title(R.string.text_prompt)
|
||||||
|
.content(R.string.text_pin_shortcut_not_unsupported)
|
||||||
|
.positiveText(R.string.dialog_button_dismiss)
|
||||||
|
.build().also { it.show() }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#Thu Dec 05 01:41:07 CST 2024
|
#Sat Dec 07 17:46:27 CST 2024
|
||||||
BUILD_TIME=1733334067701
|
BUILD_TIME=1733564787201
|
||||||
COMPILE_SDK_VERSION=34
|
COMPILE_SDK_VERSION=34
|
||||||
JAVA_VERSION=23
|
JAVA_VERSION=23
|
||||||
JAVA_VERSION_MIN_RADICAL=0
|
JAVA_VERSION_MIN_RADICAL=0
|
||||||
@@ -17,6 +17,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13
|
|||||||
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
|
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
|
||||||
TARGET_SDK_VERSION=34
|
TARGET_SDK_VERSION=34
|
||||||
TARGET_SDK_VERSION_INRT=29
|
TARGET_SDK_VERSION_INRT=29
|
||||||
VERSION_BUILD=2893
|
VERSION_BUILD=2896
|
||||||
VERSION_NAME=6.6.1 Alpha2
|
VERSION_NAME=6.6.1 Alpha2
|
||||||
VSCODE_EXT_REQUIRED_VERSION=1.0.8
|
VSCODE_EXT_REQUIRED_VERSION=1.0.8
|
||||||
|
|||||||
Reference in New Issue
Block a user