6.7.0 - Alpha12 - Fine tuning
This commit is contained in:
@@ -226,7 +226,7 @@ class ConsoleFloaty(private val console: ConsoleImpl) : AbstractResizableExpanda
|
||||
internal fun setCloseButton(resId: Int) {
|
||||
mCloseButton?.let {
|
||||
val res = console.uiHandler.applicationContext.resources
|
||||
val padding = (7 * res.displayMetrics.density).toInt()
|
||||
val padding = (7 * res.displayMetrics.density).roundToInt()
|
||||
it.post {
|
||||
it.setImageDrawable(ResourcesCompat.getDrawable(res, resId, null))
|
||||
it.setPadding(padding, padding, padding, padding)
|
||||
|
||||
@@ -132,8 +132,11 @@ public class DevPluginResponseHandler implements Handler {
|
||||
if (message == null) {
|
||||
ViewUtils.showToast(mContext, R.string.text_invalid_project, true);
|
||||
} else {
|
||||
// 使用 ErrorDialogActivity 代替直接显示 MaterialDialog
|
||||
// 这样可以避免在非UI线程或Activity不可见状态下调用对话框的问题
|
||||
// Use ErrorDialogActivity instead of showing MaterialDialog directly
|
||||
// This avoids issues when calling dialogs from non-UI threads or when Activity is not visible.
|
||||
// zh-CN:
|
||||
// 使用 ErrorDialogActivity 代替直接显示 MaterialDialog,
|
||||
// 这样可以避免在非 UI 线程或 Activity 不可见状态下调用对话框的问题.
|
||||
ErrorDialogActivity.showErrorDialog(
|
||||
mContext.getApplicationContext(),
|
||||
R.string.text_invalid_project,
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.autojs.autojs.extension.MaterialDialogExtensions.setCopyableText
|
||||
import org.autojs.autojs.runtime.api.augment.colors.Colors
|
||||
import org.autojs.autojs.util.ColorUtils
|
||||
import org.autojs.autojs6.R
|
||||
import org.autojs.autojs6.databinding.ColorInfoDialogListItemBinding
|
||||
import org.autojs.autojs6.databinding.ColorInfoDialogItemsBinding
|
||||
|
||||
object ColorInfoDialogManager {
|
||||
|
||||
@@ -38,7 +38,7 @@ object ColorInfoDialogManager {
|
||||
.show()
|
||||
return
|
||||
}
|
||||
val binding = ColorInfoDialogListItemBinding.inflate(LayoutInflater.from(context))
|
||||
val binding = ColorInfoDialogItemsBinding.inflate(LayoutInflater.from(context))
|
||||
|
||||
val colorWithoutAlpha = color or -0x1000000
|
||||
|
||||
@@ -73,7 +73,7 @@ object ColorInfoDialogManager {
|
||||
}
|
||||
}
|
||||
|
||||
private fun restoreEssentialViews(binding: ColorInfoDialogListItemBinding) {
|
||||
private fun restoreEssentialViews(binding: ColorInfoDialogItemsBinding) {
|
||||
listOf(
|
||||
binding.colorHexColon to binding.colorHexValue,
|
||||
binding.colorRgbColon to binding.colorRgbValue,
|
||||
@@ -87,7 +87,7 @@ object ColorInfoDialogManager {
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateGuidelines(binding: ColorInfoDialogListItemBinding) {
|
||||
private fun updateGuidelines(binding: ColorInfoDialogItemsBinding) {
|
||||
val filteredBindings = listOf(
|
||||
binding.colorHexLabel to binding.colorHexGuideline,
|
||||
binding.colorRgbLabel to binding.colorRgbGuideline,
|
||||
|
||||
@@ -54,15 +54,13 @@ class ColorSelectActivity : ColorSelectBaseActivity() {
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_toggle_color_select_layout -> {
|
||||
isLegacyLayout = false
|
||||
startActivity(this, isToggled = true)
|
||||
true
|
||||
}
|
||||
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
|
||||
R.id.action_toggle_color_select_layout -> {
|
||||
isLegacyLayout = false
|
||||
startActivity(this, isToggled = true)
|
||||
true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,21 @@
|
||||
package org.autojs.autojs.ui.error;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import org.autojs.autojs.extension.MaterialDialogExtensions;
|
||||
import org.autojs.autojs.ui.BaseActivity;
|
||||
import org.autojs.autojs.util.ClipboardUtils;
|
||||
import org.autojs.autojs.util.ViewUtils;
|
||||
import org.autojs.autojs6.R;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A simple activity to show error dialogs when a context is not available or valid
|
||||
* for showing dialogs directly.
|
||||
* zh-CN: 一个简单的 Activity,用于在上下文不可用或无效而无法直接显示对话框时显示错误对话框.
|
||||
*/
|
||||
public class ErrorDialogActivity extends BaseActivity {
|
||||
|
||||
@@ -21,35 +27,51 @@ public class ErrorDialogActivity extends BaseActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Get extras from intent
|
||||
// Get extras from intent.
|
||||
// zh-CN: 从 Intent 获取附加数据.
|
||||
Intent intent = getIntent();
|
||||
String title = intent.getStringExtra(EXTRA_TITLE);
|
||||
String message = intent.getStringExtra(EXTRA_MESSAGE);
|
||||
String positiveButtonText = intent.getStringExtra(EXTRA_POSITIVE_BUTTON_TEXT);
|
||||
|
||||
// If no positive button text provided, use default dismiss text
|
||||
// If no positive button text provided, use default dismiss text.
|
||||
// zh-CN: 如果没有提供确认按钮文本,则使用默认的关闭文本.
|
||||
if (positiveButtonText == null) {
|
||||
positiveButtonText = getString(R.string.dialog_button_dismiss);
|
||||
}
|
||||
|
||||
// Show dialog
|
||||
var materialDialog = new MaterialDialog.Builder(this)
|
||||
.title(title)
|
||||
.content(message)
|
||||
String content = Objects.requireNonNullElse(message, "");
|
||||
|
||||
MaterialDialog.Builder builder = new MaterialDialog.Builder(this)
|
||||
.title(Objects.requireNonNullElse(title, getString(R.string.text_prompt)))
|
||||
.content(content)
|
||||
.positiveText(positiveButtonText)
|
||||
.positiveColorRes(R.color.dialog_button_default)
|
||||
.autoDismiss(false)
|
||||
.cancelable(false)
|
||||
.canceledOnTouchOutside(false)
|
||||
.onPositive((dialog, which) -> finish())
|
||||
.show();
|
||||
.onPositive((dialog, which) -> dialog.dismiss())
|
||||
.dismissListener(dialog -> finish());
|
||||
|
||||
if (!content.isBlank()) {
|
||||
builder.neutralText(R.string.text_copy_all);
|
||||
builder.neutralColorRes(R.color.dialog_button_hint);
|
||||
builder.onNeutral((dialog, which) -> {
|
||||
ClipboardUtils.setClip(dialog.getContext(), content);
|
||||
ViewUtils.showSnack(dialog.getView(), R.string.text_already_copied_to_clip, false);
|
||||
});
|
||||
}
|
||||
|
||||
var materialDialog = builder.show();
|
||||
|
||||
MaterialDialogExtensions.makeTextCopyable(materialDialog, materialDialog.getContentView());
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to show an error dialog from any context
|
||||
* Helper method to show an error dialog from any context.
|
||||
* zh-CN: 用于从任何上下文显示错误对话框的辅助方法.
|
||||
*/
|
||||
public static void showErrorDialog(android.content.Context context, int titleRes, String message) {
|
||||
public static void showErrorDialog(Context context, int titleRes, String message) {
|
||||
Intent intent = new Intent(context, ErrorDialogActivity.class);
|
||||
intent.putExtra(EXTRA_TITLE, context.getString(titleRes));
|
||||
intent.putExtra(EXTRA_MESSAGE, message);
|
||||
@@ -58,9 +80,10 @@ public class ErrorDialogActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to show an error dialog from any context with custom positive button text
|
||||
* Helper method to show an error dialog from any context with custom positive button text.
|
||||
* zh-CN: 用于从任何上下文显示带有自定义确认按钮文本的错误对话框的辅助方法.
|
||||
*/
|
||||
public static void showErrorDialog(android.content.Context context, int titleRes, String message, int positiveButtonTextRes) {
|
||||
public static void showErrorDialog(Context context, int titleRes, String message, int positiveButtonTextRes) {
|
||||
Intent intent = new Intent(context, ErrorDialogActivity.class);
|
||||
intent.putExtra(EXTRA_TITLE, context.getString(titleRes));
|
||||
intent.putExtra(EXTRA_MESSAGE, message);
|
||||
@@ -68,4 +91,5 @@ public class ErrorDialogActivity extends BaseActivity {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class WindowSwitchingDialog extends AppLevelThemeDialogBuilder {
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.window_switching_dialog_list_item, parent, false));
|
||||
return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.window_switching_dialog_items, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.autojs.autojs.util.IntentUtils.SnackExceptionHolder
|
||||
import org.autojs.autojs.util.StringUtils
|
||||
import org.autojs.autojs.util.StringUtils.dropBom
|
||||
import org.autojs.autojs6.R
|
||||
import org.autojs.autojs6.databinding.EditableFileInfoDialogListItemBinding
|
||||
import org.autojs.autojs6.databinding.EditableFileInfoDialogItemsBinding
|
||||
import java.io.File
|
||||
import java.nio.charset.Charset
|
||||
import java.nio.file.Files
|
||||
@@ -40,7 +40,7 @@ object EditableFileInfoDialogManager {
|
||||
.show()
|
||||
return
|
||||
}
|
||||
val binding = EditableFileInfoDialogListItemBinding.inflate(LayoutInflater.from(context))
|
||||
val binding = EditableFileInfoDialogItemsBinding.inflate(LayoutInflater.from(context))
|
||||
|
||||
val textUnknown = context.getString(R.string.text_unknown)
|
||||
|
||||
@@ -119,7 +119,7 @@ object EditableFileInfoDialogManager {
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateGuidelines(binding: EditableFileInfoDialogListItemBinding) {
|
||||
private fun updateGuidelines(binding: EditableFileInfoDialogItemsBinding) {
|
||||
val bindings = listOf(
|
||||
binding.filePathLabel to binding.filePathGuideline,
|
||||
binding.fileSizeLabel to binding.fileSizeGuideline,
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.autojs.autojs.extension.MaterialDialogExtensions.setCopyableText
|
||||
import org.autojs.autojs.model.explorer.ExplorerItem
|
||||
import org.autojs.autojs.util.ViewUtils
|
||||
import org.autojs.autojs6.R
|
||||
import org.autojs.autojs6.databinding.MediaFileInfoDialogListItemBinding
|
||||
import org.autojs.autojs6.databinding.MediaFileInfoDialogItemsBinding
|
||||
import org.mediainfo.android.MediaInfo
|
||||
import org.mediainfo.android.MediaInfo.StreamKind.AUDIO
|
||||
import org.mediainfo.android.MediaInfo.StreamKind.GENERAL
|
||||
@@ -34,7 +34,7 @@ object MediaInfoDialogManager {
|
||||
@JvmStatic
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun showMediaInfoDialog(context: Context, explorerItem: ExplorerItem) {
|
||||
val binding = MediaFileInfoDialogListItemBinding.inflate(LayoutInflater.from(context))
|
||||
val binding = MediaFileInfoDialogItemsBinding.inflate(LayoutInflater.from(context))
|
||||
|
||||
// Create an independent Scope for the Dialog, bind its lifecycle with the Dialog.
|
||||
// zh-CN: 针对 Dialog 独立创建一个 Scope, 生命周期与 Dialog 绑定.
|
||||
@@ -154,7 +154,7 @@ object MediaInfoDialogManager {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setViewsAsVideoPlaceholder(binding: MediaFileInfoDialogListItemBinding) {
|
||||
private fun setViewsAsVideoPlaceholder(binding: MediaFileInfoDialogItemsBinding) {
|
||||
binding.videoFormatParent.isVisible = true
|
||||
binding.bitRateForVideoParent.isVisible = true
|
||||
binding.resolutionParent.isVisible = true
|
||||
@@ -162,7 +162,7 @@ object MediaInfoDialogManager {
|
||||
binding.frameRateParent.isVisible = true
|
||||
}
|
||||
|
||||
private fun setViewsAsMediaPlaceholder(binding: MediaFileInfoDialogListItemBinding) {
|
||||
private fun setViewsAsMediaPlaceholder(binding: MediaFileInfoDialogItemsBinding) {
|
||||
binding.audioFormatParent.isVisible = true
|
||||
binding.bitRateForAudioParent.isVisible = true
|
||||
binding.albumParent.isVisible = true
|
||||
@@ -171,16 +171,16 @@ object MediaInfoDialogManager {
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER", "unused")
|
||||
private fun setViewsAsMediaMenuPlaceholder(binding: MediaFileInfoDialogListItemBinding) {
|
||||
private fun setViewsAsMediaMenuPlaceholder(binding: MediaFileInfoDialogItemsBinding) {
|
||||
/* Nothing to do yet. */
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER", "unused")
|
||||
private fun setViewsAsLeastPlaceholder(binding: MediaFileInfoDialogListItemBinding) {
|
||||
private fun setViewsAsLeastPlaceholder(binding: MediaFileInfoDialogItemsBinding) {
|
||||
/* Nothing to do yet. */
|
||||
}
|
||||
|
||||
private fun restoreEssentialViews(binding: MediaFileInfoDialogListItemBinding, context: Context) {
|
||||
private fun restoreEssentialViews(binding: MediaFileInfoDialogItemsBinding, context: Context) {
|
||||
binding.containerFormatLabel.text = context.getString(R.string.media_info_container_format_label)
|
||||
binding.containerFormatColon.isVisible = true
|
||||
binding.containerFormatValue.isVisible = true
|
||||
@@ -201,7 +201,7 @@ object MediaInfoDialogManager {
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateGuidelines(binding: MediaFileInfoDialogListItemBinding) {
|
||||
private fun updateGuidelines(binding: MediaFileInfoDialogItemsBinding) {
|
||||
val filteredBindings = listOf(
|
||||
binding.containerFormatLabel to binding.containerFormatGuideline,
|
||||
binding.videoFormatLabel to binding.videoFormatGuideline,
|
||||
@@ -228,7 +228,7 @@ object MediaInfoDialogManager {
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateSplitLineVisibility(binding: MediaFileInfoDialogListItemBinding) {
|
||||
private fun updateSplitLineVisibility(binding: MediaFileInfoDialogItemsBinding) {
|
||||
binding.splitLine.isVisible = listOf(
|
||||
binding.bitRateForVideoParent,
|
||||
binding.resolutionParent,
|
||||
|
||||
@@ -358,7 +358,7 @@ object IntentUtils {
|
||||
context.startActivity(launchIntent)
|
||||
} else {
|
||||
// All scripts will call the scheduleAppLaunch method.
|
||||
// zh-CM: 脚本一律调用 scheduleAppLaunch 方法.
|
||||
// zh-CN: 脚本一律调用 scheduleAppLaunch 方法.
|
||||
scheduleAppLaunch(context, launchIntent)
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ object IntentUtils {
|
||||
// zh-CN: 主页抽屉 "重启" 按钮点击时, 如果启用了 "快速重启", 则不调用 finishAllAppTasksSafely 方法.
|
||||
} else {
|
||||
// All scripts will call the finishAllAppTasksSafely method.
|
||||
// zh-CM: 脚本一律调用 finishAllAppTasksSafely 方法.
|
||||
// zh-CN: 脚本一律调用 finishAllAppTasksSafely 方法.
|
||||
finishAllAppTasksSafely(context)
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,8 @@ class MediaInfo {
|
||||
getMediaInfoOption(param)
|
||||
}
|
||||
|
||||
fun getIsCanceled() = mIsCanceled
|
||||
|
||||
fun getMediaInfoTrimmed(filename: String): String = checkAvailability {
|
||||
var result = getMediaInfo(filename)
|
||||
|
||||
@@ -141,7 +143,7 @@ class MediaInfo {
|
||||
|
||||
private fun countSpacesBeforeColon(input: String): Int {
|
||||
val index = input.indexOf(':')
|
||||
if (index == -1) return 0 // 如果没有冒号, 则返回0
|
||||
if (index == -1) return 0
|
||||
|
||||
var count = 0
|
||||
for (i in index - 1 downTo 0) {
|
||||
|
||||
Reference in New Issue
Block a user