Skip to content

Commit

Permalink
[Add] English locale.
Browse files Browse the repository at this point in the history
  • Loading branch information
sheng-di committed Apr 2, 2020
1 parent 531f6b1 commit 5cc5235
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 35 deletions.
3 changes: 0 additions & 3 deletions app/src/main/java/com/to3g/snipasteandroid/QDApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -145,7 +145,7 @@ private void setFloatViewOpacity () {
}

/**
* 相机按钮点击事件
* When click the camera button
*/
@OnClick(R.id.cameraButton)
protected void onCameraButtonClick () {
Expand All @@ -169,7 +169,7 @@ protected void onCameraButtonClick () {
}

/**
* 相册按钮点击事件
* When click the album button
*/
@OnClick(R.id.albumButton)
protected void onAlbumButtonClick () {
Expand All @@ -195,7 +195,7 @@ protected void onAlbumButtonClick () {
}

/**
* 屏幕区域按钮点击事件
* When click the screenButton
*/
@OnClick(R.id.screenButton)
protected void onScreenButtonClick () {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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)
Expand All @@ -409,28 +409,28 @@ 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();
PermissionUtils.requestPermission(getActivity(), result -> {
if(result) {
showFloatText(content);
} else {
Toast.makeText(getContext(), "需要悬浮窗权限才能悬浮", Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(), getText(R.string.needFloatingPermission), Toast.LENGTH_SHORT).show();
}
});
}
Expand All @@ -448,7 +448,7 @@ private void initTopBar() {
}

/**
* 清空所有文本悬浮
* Clear all text floating windows
*/
private void clearAllTextFloatViews () {
for (String content : floatings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/home_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.ramotion.fluidslider.FluidSlider
app:start_text="透明"
app:end_text="不透明"
app:start_text="@string/transparent"
app:end_text="@string/opaque"
android:id="@+id/slider"
app:bar_color="#eeeeee"
app:bubble_text_color="@color/picture_color_white"
Expand Down
36 changes: 36 additions & 0 deletions app/src/main/res/values-en-rUS/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">ScreenPaste</string>
<string name="about_title">about</string>
<string name="album">album</string>
<string name="blankContent">blank content</string>
<string name="button_clear_text">clear</string>
<string name="cameraText">camera</string>
<string name="cancelText">cancel</string>
<string name="clear_all_text">close all text floating windows</string>
<string name="clipboard_button_text">clipboard</string>
<string name="default_text">default text</string>
<string name="floatingPermissionText">To use the floating window function, you need to grant the floating window permission.</string>
<string name="help">help</string>
<string name="helpText">Double-click the floating window to close</string>
<string name="needFloatingPermission">floating window permission needed</string>
<string name="notification_content">Click for partial screenshot</string>
<string name="opacity">opacity</string>
<string name="pasteSectionTitle1">float text</string>
<string name="pasteSegment_tab_picture">piture</string>
<string name="pasteSegment_tab_text">text</string>
<string name="pasteTextButtonText">float clipboard text</string>
<string name="pasteTextEditHint">input some text ...</string>
<string name="paste_on_screen">float on the screen</string>
<string name="paste_title_2">float picture</string>
<string name="screen_area">partial screen</string>
<string name="setting">settings</string>
<string name="tabSegment_item_1_content">first item</string>
<string name="tabSegment_item_2_content">second item</string>
<string name="test_activity">test activity</string>
<string name="textFloated">content already floated</string>
<string name="toOpen">go to grant</string>
<string name="about_item_homepage">go to home page</string>
<string name="transparent">transparent</string>
<string name="opaque">opaque</string>
</resources>
20 changes: 14 additions & 6 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
<string name="clipboard_button_text">剪贴板</string>
<string name="default_text">默认文字</string>

<string name="ok">OK</string>
<string name="cancel">CANCEL</string>
<string name="ok" translatable="false">OK</string>
<string name="cancel" translatable="false">CANCEL</string>

<!-- 关于界面 -->
<string name="about_title">关于</string>
<string name="about_item_homepage">访问官网</string>
<string name="about_item_github">GitHub</string>
<string name="about_copyright">© %1$s QMUI Team All rights reserved.</string>
<string name="about_item_github" translatable="false">GitHub</string>
<string name="about_copyright" translatable="false">© %1$s QMUI Team All rights reserved.</string>

<!-- TabSegmentFragment 选项卡展示界面 -->
<string name="tabSegment_item_1_title">Item 1</string>
<string name="tabSegment_item_2_title">Item 2</string>
<string name="tabSegment_item_1_title" translatable="false">Item 1</string>
<string name="tabSegment_item_2_title" translatable="false">Item 2</string>
<string name="tabSegment_item_1_content">这是第一个 Item 的内容区</string>
<string name="tabSegment_item_2_content">这是第二个 Item 的内容区</string>

Expand All @@ -37,4 +37,12 @@
<string name="screen_area">屏幕区域</string>
<string name="test_activity">测试activity</string>
<string name="notification_content">点按区域截图</string>
<string name="blankContent">内容为空</string>
<string name="textFloated">已悬浮</string>
<string name="floatingPermissionText">使用浮窗功能,需要您授予悬浮窗权限。</string>
<string name="cancelText">取消</string>
<string name="toOpen">去开启</string>
<string name="needFloatingPermission">需要悬浮窗权限才能悬浮</string>
<string name="transparent">透明</string>
<string name="opaque">不透明</string>
</resources>

0 comments on commit 5cc5235

Please sign in to comment.