Skip to content

Commit

Permalink
fix to clip tip
Browse files Browse the repository at this point in the history
  • Loading branch information
littleWhiteDuck committed Mar 4, 2023
1 parent 2a10ee9 commit 2ad137e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/src/main/java/me/duck/hooktest/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private void readAssetsText() {
} catch (IOException e) {
result = "error";
}
showMessageDialog("读取Assets文件", result);
showMessageDialog(getString(R.string.main_read_assets_file), result);
}

private void showPutClipDialog() {
Expand All @@ -212,7 +212,7 @@ private void showPutClipDialog() {
.setPositiveButton(R.string.main_dialog_confirm, (dialog, which) -> {
EditText editText = ((AlertDialog) dialog).findViewById(R.id.text_input_edit);
//noinspection ConstantConditions
toClip(editText.getText().toString().trim());
toClip(editText.getText().toString().trim(), "Copied!!!");
})
.setNegativeButton(getString(R.string.main_dialog_cancel), null)
.show();
Expand Down Expand Up @@ -339,10 +339,10 @@ private String getReturnValue() {
}

@SuppressLint("WrongConstant")
private void toClip(String text) {
private void toClip(String text, String tip) {
ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
clipboardManager.setPrimaryClip(ClipData.newPlainText("label", text));
Toast.makeText(this, R.string.main_copy_config_tip, Toast.LENGTH_SHORT).show();
Toast.makeText(this, tip, Toast.LENGTH_SHORT).show();
}


Expand All @@ -356,7 +356,7 @@ public boolean onCreateOptionsMenu(@NonNull Menu menu) {
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
int id = item.getItemId();
if (id == R.id.menu_copy) {
toClip(config);
toClip(config, getString(R.string.main_copy_config_tip));
}
return true;
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@
<string name="input_hint">输入文字</string>
<string name="main_exit_app">退出应用</string>
<string name="main_test_crash">测试闪退</string>
<string name="main_read_assets_file">读取Assets文件</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<string name="input_hint">input text</string>
<string name="main_exit_app">Exit app</string>
<string name="main_test_crash">Test Crash</string>
<string name="main_read_assets_file">Read Assets file</string>
<array name="exit_app_items">
<item>Finish()</item>
<item>System.exit()</item>
Expand Down

0 comments on commit 2ad137e

Please sign in to comment.