Skip to content

Commit 1c09b24

Browse files
committed
升级编程系统到 AS 3.2.1 gradle
好久没有更新了,添加google translate的支持。 - 单点 某个单词 - 长点 前后 20个单词
1 parent bf18d3b commit 1c09b24

File tree

11 files changed

+86
-87
lines changed

11 files changed

+86
-87
lines changed

.idea/misc.xml

+1-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131
## 应用运行图片
3232
mdict Android安装包[下载地址](http://www.mdict.cn/wp/?lang=zh)
3333

34+
V1.1
35+
apk文件[下载地址]()
36+
好久没有更新了,添加google translate的支持。
37+
- 单点 某个单词
38+
- 长点 前后 20个单词
39+
<img src="./apkandimg/v1_1_screen.png" width = "240" height = "400" alt="截图一" align=center />
40+
41+
3442
V1.0
3543
debug-apk文件[下载地址](https://raw.githubusercontent.com/talengu/WordWarrior/master/apkandimg/app-debug.apk)
3644
最稳定版本 [Google Play下载](https://play.google.com/store/apps/details?id=com.talengu.wordwarrior)

app/build.gradle

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 23
5-
buildToolsVersion '25.0.0'
4+
compileSdkVersion 26
5+
buildToolsVersion '28.0.3'
66
defaultConfig {
77
applicationId "com.talengu.wordwarrior"
88
minSdkVersion 21
9-
targetSdkVersion 23
9+
targetSdkVersion 26
1010
versionCode 1
1111
versionName "1.0"
1212
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -20,12 +20,12 @@ android {
2020
}
2121

2222
dependencies {
23-
compile fileTree(dir: 'libs', include: ['*.jar'])
24-
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
23+
implementation fileTree(dir: 'libs', include: ['*.jar'])
24+
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
2525
exclude group: 'com.android.support', module: 'support-annotations'
2626
})
27-
compile 'com.android.support:appcompat-v7:23.4.0'
28-
compile 'com.android.support:design:23.4.0'
29-
compile 'org.jsoup:jsoup:1.10.3'
30-
testCompile 'junit:junit:4.12'
27+
implementation 'com.android.support:appcompat-v7:23.4.0'
28+
implementation 'com.android.support:design:23.4.0'
29+
implementation 'org.jsoup:jsoup:1.10.3'
30+
testImplementation 'junit:junit:4.12'
3131
}

app/src/androidTest/java/com/talengu/wordwarrior/ExampleInstrumentedTest.java

-26
This file was deleted.

app/src/main/AndroidManifest.xml

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.talengu.wordwarrior"
4-
android:versionCode="1"
5-
android:versionName="1.0">
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.talengu.wordwarrior">
5+
66

7-
<uses-sdk
8-
android:minSdkVersion="11"
9-
android:targetSdkVersion="17" />
107

118
<!--读写内部存储权限-->
129
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
@@ -20,7 +17,8 @@
2017
android:allowBackup="true"
2118
android:icon="@mipmap/ic_launcher"
2219
android:label="@string/app_name"
23-
android:theme="@style/AppTheme">
20+
android:theme="@style/AppTheme"
21+
tools:ignore="GoogleAppIndexingWarning">
2422
<activity
2523
android:name=".MainActivity"
2624
android:label="@string/app_name">
@@ -33,11 +31,11 @@
3331
<activity
3432
android:name=".TXTActivity"
3533
android:label="@string/title_activity_txt"
36-
android:theme="@style/AppTheme.NoActionBar"></activity>
34+
android:theme="@style/AppTheme.NoActionBar" />
3735
<activity
3836
android:name=".others.TextToSpeechActivity"
3937
android:label="@string/tts_activity_txt"
40-
android:theme="@style/AppTheme.NoActionBar"></activity>
38+
android:theme="@style/AppTheme.NoActionBar" />
4139
</application>
4240

4341
</manifest>

app/src/main/java/com/talengu/wordwarrior/MainActivity.java

+42-22
Original file line numberDiff line numberDiff line change
@@ -293,33 +293,53 @@ public void onSwipeStart(int position) {// swipe start
293293
public void onSwipeEnd(int position) {// swipe end
294294
}
295295
});
296+
mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
297+
@Override
298+
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
299+
// 打开google translate
300+
String word_string="";
301+
for (int i = 0; i < mEwordList.size(); i++) {
302+
if (i>=position-10 && i<=position+10)
303+
word_string+=mEwordList.get(i).getWordSpell()+".\n";
304+
}
305+
try {
306+
Intent intent = new Intent();
307+
intent.setAction(Intent.ACTION_PROCESS_TEXT);
308+
intent.setType("text/plain");
309+
intent.putExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, true);
310+
intent.putExtra(Intent.EXTRA_PROCESS_TEXT, word_string);
311+
startActivity(intent);
312+
} catch (ActivityNotFoundException e) {
313+
// TODO Auto-generated catch block
314+
Toast.makeText(getApplication(), "Sorry, No Google Translation Installed",
315+
Toast.LENGTH_SHORT).show();
316+
}
317+
296318

319+
320+
return false;
321+
}
322+
});
297323
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
298324

299325
@Override
300326
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
301-
// TODO 自动生成的方法存根
302-
// try {
303-
//
304-
// Intent i = new Intent();
305-
// i.setAction(Intent.ACTION_VIEW);
306-
// i.putExtra("key_text_input", "hello");
307-
// i.putExtra("key_text_output", "");
308-
// i.putExtra("key_language_from", "en");
309-
// i.putExtra("key_language_to", "zh-CN");
310-
// //i.putExtra("key_suggest_translation", "");
311-
// //i.putExtra("key_from_floating_window", false);
312-
// i.setComponent(
313-
// new ComponentName(
314-
// "com.google.android.apps.translate",
315-
// "com.google.android.apps.translate.translation.TranslateActivity"));
316-
// startActivity(i);
317-
// } catch (ActivityNotFoundException e) {
318-
//
319-
// Toast.makeText(getApplication(),"Sorry, No Google Translation Installed",
320-
// Toast.LENGTH_SHORT).show();
321-
// }
322-
//bundle.putString("word", mEwordList.get(position).getspelling());
327+
328+
String word_string=mEwordList.get(position).getWordSpell();
329+
try {
330+
Intent intent = new Intent();
331+
intent.setAction(Intent.ACTION_PROCESS_TEXT);
332+
intent.setType("text/plain");
333+
intent.putExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, true);
334+
intent.putExtra(Intent.EXTRA_PROCESS_TEXT, word_string);
335+
startActivity(intent);
336+
} catch (ActivityNotFoundException e) {
337+
// TODO Auto-generated catch block
338+
Toast.makeText(getApplication(), "Sorry, No Google Translation Installed",
339+
Toast.LENGTH_SHORT).show();
340+
}
341+
342+
323343
ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
324344

325345
// 将文本内容放到系统剪贴板里。

app/src/main/java/com/talengu/wordwarrior/others/TextToSpeechActivity.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package com.talengu.wordwarrior.others;
44

55
import android.app.Activity;
6+
import android.content.Intent;
67
import android.os.Bundle;
78
import android.speech.tts.TextToSpeech;
89
import android.view.View;
@@ -92,10 +93,16 @@ public void onInit(int status) {
9293
}
9394

9495
private void sayHello(String hello) {
95-
96-
mTts.speak(hello,
97-
TextToSpeech.QUEUE_FLUSH, // Drop all pending entries in the playback queue.
98-
null);
96+
Intent intent = new Intent();
97+
intent.setAction(Intent.ACTION_PROCESS_TEXT);
98+
intent.setType("text/plain");
99+
intent.putExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, true);
100+
intent.putExtra(Intent.EXTRA_PROCESS_TEXT, hello);
101+
startActivity(intent);
102+
// tts 在我的手机上不工作
103+
// mTts.speak(hello,
104+
// TextToSpeech.QUEUE_FLUSH, // Drop all pending entries in the playback queue.
105+
// null);
99106
}
100107

101108

app/src/main/res/layout/item_list_app.xml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
android:layout_marginLeft="10dp"
1919
android:layout_toRightOf="@+id/iv_icon"
2020
android:text="name"
21+
android:textColor="@color/white_txt"
2122
android:textSize="18sp" />
2223
<!--android:textColor="@color/black"-->
2324
</RelativeLayout>

app/src/main/res/values/colors.xml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<resources>
33

44
<color name="white">#fff</color>
5+
<color name="white_txt">#fafff0</color>
6+
57
<color name="black">#000</color>
68
<color name="grey">#ff5b5a5a</color>
79
<color name="oldgrey">#ffF93F25</color>

build.gradle

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
buildscript {
44
repositories {
55
jcenter()
6+
google()
67
}
78
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.3.3'
9+
classpath 'com.android.tools.build:gradle:3.2.1'
910

1011
// NOTE: Do not place your application dependencies here; they belong
1112
// in the individual module build.gradle files
@@ -15,6 +16,7 @@ buildscript {
1516
allprojects {
1617
repositories {
1718
jcenter()
19+
google()
1820
}
1921
}
2022

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Thu Mar 09 12:41:48 CST 2017
1+
#Sun Dec 02 15:26:15 CST 2018
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

0 commit comments

Comments
 (0)