From 5cc5235ba94277c62f24f414a98eb5301caed37c Mon Sep 17 00:00:00 2001 From: shengdi1995 <378978764@qq.com> Date: Thu, 2 Apr 2020 23:45:03 +0800 Subject: [PATCH] [Add] English locale. --- .../to3g/snipasteandroid/QDApplication.java | 3 -- .../fragment/HomeFragment.java | 46 +++++++++---------- .../service/ScreenshotService.java | 1 - app/src/main/res/layout/home_layout.xml | 4 +- app/src/main/res/values-en-rUS/strings.xml | 36 +++++++++++++++ app/src/main/res/values/strings.xml | 20 +++++--- 6 files changed, 75 insertions(+), 35 deletions(-) create mode 100644 app/src/main/res/values-en-rUS/strings.xml diff --git a/app/src/main/java/com/to3g/snipasteandroid/QDApplication.java b/app/src/main/java/com/to3g/snipasteandroid/QDApplication.java index 13db5fe..ae80315 100644 --- a/app/src/main/java/com/to3g/snipasteandroid/QDApplication.java +++ b/app/src/main/java/com/to3g/snipasteandroid/QDApplication.java @@ -26,9 +26,6 @@ import com.qmuiteam.qmui.arch.QMUISwipeBackActivityManager; import com.qmuiteam.qmui.qqface.QMUIQQFaceCompiler; -/** - * Snipaste 的 Application 入口。 - */ public class QDApplication extends Application { public static boolean openSkinMake = false; diff --git a/app/src/main/java/com/to3g/snipasteandroid/fragment/HomeFragment.java b/app/src/main/java/com/to3g/snipasteandroid/fragment/HomeFragment.java index d310cf0..3d7d38a 100644 --- a/app/src/main/java/com/to3g/snipasteandroid/fragment/HomeFragment.java +++ b/app/src/main/java/com/to3g/snipasteandroid/fragment/HomeFragment.java @@ -98,13 +98,13 @@ public class HomeFragment extends BaseFragment { @Override protected View onCreateView() { - // 绑定视图 + // bind view View root = LayoutInflater.from(getContext()).inflate(R.layout.home_layout, null); ButterKnife.bind(this, root); - // 初始化TopBar + // init the top bar initTopBar(); - // 滑块 + // init the bottom slider slider.setPosition(1); slider.setPositionListener(pos -> { opacity = pos; @@ -145,7 +145,7 @@ private void setFloatViewOpacity () { } /** - * 相机按钮点击事件 + * When click the camera button */ @OnClick(R.id.cameraButton) protected void onCameraButtonClick () { @@ -169,7 +169,7 @@ protected void onCameraButtonClick () { } /** - * 相册按钮点击事件 + * When click the album button */ @OnClick(R.id.albumButton) protected void onAlbumButtonClick () { @@ -195,7 +195,7 @@ protected void onAlbumButtonClick () { } /** - * 屏幕区域按钮点击事件 + * When click the screenButton */ @OnClick(R.id.screenButton) protected void onScreenButtonClick () { @@ -244,13 +244,13 @@ private ViewGroup.LayoutParams getDefaultParams (String path, ViewGroup.LayoutPa Size size = ImageUtil.getImageSize(path); int imgWidth = size.getWidth(); int imgHeight = size.getHeight(); - Log.d(TAG, String.format("initImageView: 图片大小:%d, %d", imgWidth, imgHeight)); + Log.d(TAG, String.format("initImageView: image size:%d, %d", imgWidth, imgHeight)); float rate = 0.8f; layoutParams.width = (int) (rate * screenWidth); layoutParams.height = (int) (layoutParams.width * 1.0f / imgWidth * imgHeight); - Log.d(TAG, String.format("initImageView: layout 大小:%d, %d", layoutParams.width, layoutParams.height)); + Log.d(TAG, String.format("initImageView: layout size:%d, %d", layoutParams.width, layoutParams.height)); return layoutParams; } @@ -263,13 +263,13 @@ private ViewGroup.LayoutParams getDefaultParams (Bitmap bitmap, ViewGroup.Layout // 获取图片宽高 int imgWidth = bitmap.getWidth(); int imgHeight = bitmap.getHeight(); - Log.d(TAG, String.format("initImageView: 图片大小:%d, %d", imgWidth, imgHeight)); + Log.d(TAG, String.format("initImageView: image size:%d, %d", imgWidth, imgHeight)); float rate = 0.8f; layoutParams.width = (int) (rate * screenWidth); layoutParams.height = (int) (layoutParams.width * 1.0f / imgWidth * imgHeight); - Log.d(TAG, String.format("initImageView: layout 大小:%d, %d", layoutParams.width, layoutParams.height)); + Log.d(TAG, String.format("initImageView: layout size:%d, %d", layoutParams.width, layoutParams.height)); return layoutParams; } @@ -368,24 +368,24 @@ protected void onPasteTextButtonClick () { @OnClick(R.id.pasteClipboardButton) protected void onPasteClickboardButtonClick () { String content = ClipBoardUtil.get(Objects.requireNonNull(getContext())); - Log.d(TAG, "剪切板内容: " + content); + Log.d(TAG, "clipboard content: " + content); editText.setText(content); floatText(content); } private void showFloatText (String content) { - // 查看是否已经创建过这个弹窗 + // check if the floating window has been created View view = EasyFloat.getAppFloatView(content); if (content == null || content.equals("")) { - Toast.makeText(getContext(), "内容为空", Toast.LENGTH_SHORT).show(); + Toast.makeText(getContext(), getText(R.string.blankContent), Toast.LENGTH_SHORT).show(); return; } - // 如果已经创建,返回 false + // if alerady created, return false if (view != null) { - Toast.makeText(getContext(), "已悬浮", Toast.LENGTH_SHORT).show(); + Toast.makeText(getContext(), getText(R.string.textFloated), Toast.LENGTH_SHORT).show(); return; } - // 创建一个新的 + // create new one EasyFloat .with(Objects.requireNonNull(getActivity())) .setLayout(R.layout.text_paste) @@ -409,20 +409,20 @@ public void onDoubleClick(View v) { } private void floatText(String content) { - // 检查权限 + // check the permission if (PermissionUtils.checkPermission(Objects.requireNonNull(getContext()))) { showFloatText(content); } else { - // 提示用户要申请权限了 + // prompt to request permission new QMUIDialog.MessageDialogBuilder(getActivity()) - .setMessage("使用浮窗功能,需要您授予悬浮窗权限。") - .addAction("取消", new QMUIDialogAction.ActionListener() { + .setMessage(getText(R.string.floatingPermissionText)) + .addAction(getText(R.string.cancelText), new QMUIDialogAction.ActionListener() { @Override public void onClick(QMUIDialog dialog, int index) { dialog.dismiss(); } }) - .addAction(0, "去开启", QMUIDialogAction.ACTION_PROP_POSITIVE, new QMUIDialogAction.ActionListener() { + .addAction(0, getText(R.string.toOpen), QMUIDialogAction.ACTION_PROP_POSITIVE, new QMUIDialogAction.ActionListener() { @Override public void onClick(QMUIDialog dialog, int index) { dialog.dismiss(); @@ -430,7 +430,7 @@ public void onClick(QMUIDialog dialog, int index) { if(result) { showFloatText(content); } else { - Toast.makeText(getContext(), "需要悬浮窗权限才能悬浮", Toast.LENGTH_SHORT).show(); + Toast.makeText(getContext(), getText(R.string.needFloatingPermission), Toast.LENGTH_SHORT).show(); } }); } @@ -448,7 +448,7 @@ private void initTopBar() { } /** - * 清空所有文本悬浮 + * Clear all text floating windows */ private void clearAllTextFloatViews () { for (String content : floatings) { diff --git a/app/src/main/java/com/to3g/snipasteandroid/service/ScreenshotService.java b/app/src/main/java/com/to3g/snipasteandroid/service/ScreenshotService.java index 7f24618..6c25375 100644 --- a/app/src/main/java/com/to3g/snipasteandroid/service/ScreenshotService.java +++ b/app/src/main/java/com/to3g/snipasteandroid/service/ScreenshotService.java @@ -19,7 +19,6 @@ public IBinder onBind(Intent intent) { @Override public int onStartCommand(Intent intent, int flags, int startId) { -// Toast.makeText(this, "截屏服务", Toast.LENGTH_SHORT).show(); Intent it = new Intent(); it.setAction(MyReceiver.ACTION_SCREENSHOT); sendBroadcast(it); diff --git a/app/src/main/res/layout/home_layout.xml b/app/src/main/res/layout/home_layout.xml index be38df3..062ead6 100644 --- a/app/src/main/res/layout/home_layout.xml +++ b/app/src/main/res/layout/home_layout.xml @@ -102,8 +102,8 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + ScreenPaste + about + album + blank content + clear + camera + cancel + close all text floating windows + clipboard + default text + To use the floating window function, you need to grant the floating window permission. + help + Double-click the floating window to close + floating window permission needed + Click for partial screenshot + opacity + float text + piture + text + float clipboard text + input some text ... + float on the screen + float picture + partial screen + settings + first item + second item + test activity + content already floated + go to grant + go to home page + transparent + opaque + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f9a41b2..66d9a15 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3,18 +3,18 @@ 剪贴板 默认文字 - OK - CANCEL + OK + CANCEL 关于 访问官网 - GitHub - © %1$s QMUI Team All rights reserved. + GitHub + © %1$s QMUI Team All rights reserved. - Item 1 - Item 2 + Item 1 + Item 2 这是第一个 Item 的内容区 这是第二个 Item 的内容区 @@ -37,4 +37,12 @@ 屏幕区域 测试activity 点按区域截图 + 内容为空 + 已悬浮 + 使用浮窗功能,需要您授予悬浮窗权限。 + 取消 + 去开启 + 需要悬浮窗权限才能悬浮 + 透明 + 不透明