Skip to content

Commit

Permalink
2.0.2,修复 promeG#11 ,添加Android demo promeG#12
Browse files Browse the repository at this point in the history
  • Loading branch information
YacongGu committed Feb 5, 2017
1 parent f344a39 commit 59befc0
Show file tree
Hide file tree
Showing 15 changed files with 184 additions and 14 deletions.
17 changes: 16 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,25 @@ android:
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'

# Emulator Management: Create, Start and Wait
before_script:
- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
- emulator -avd test -no-audio -no-window &
- chmod +x gradlew

script:
- echo "Travis branch is $TRAVIS_BRANCH"
- echo "Travis branch is in pull request $TRAVIS_PULL+REQUEST"
- ./gradlew clean build :lib:test :tinypinyin-lexicons-android-cncity:test :tinypinyin-android-asset-lexicons:test
- android-wait-for-emulator
- adb shell input keyevent 82
- ./gradlew clean build :lib:test :tinypinyin-lexicons-android-cncity:test :tinypinyin-android-asset-lexicons:test :android-sample:connectedAndroidTest


notifications:
email:
- [email protected]

cache:
directories:
- $HOME/.m2
- $HOME/.gradle
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ buildscript {
}

dependencies {
compile 'com.github.promeg:tinypinyin:2.0.1' // TinyPinyin核心包,约80KB
compile 'com.github.promeg:tinypinyin:2.0.2' // TinyPinyin核心包,约80KB

compile 'com.github.promeg:tinypinyin-lexicons-android-cncity:2.0.1' // 可选,适用于Android的中国地区词典
compile 'com.github.promeg:tinypinyin-lexicons-android-cncity:2.0.2' // 可选,适用于Android的中国地区词典

compile 'com.github.promeg:tinypinyin-lexicons-java-cncity:2.0.1' // 可选,适用于Java的中国地区词典
compile 'com.github.promeg:tinypinyin-lexicons-java-cncity:2.0.2' // 可选,适用于Java的中国地区词典
}
}
```
Expand Down Expand Up @@ -100,7 +100,7 @@ buildscript {
采用以下命令运行test:

```groovy
./gradlew clean build :lib:test :tinypinyin-lexicons-android-cncity:test :tinypinyin-android-asset-lexicons:test
./gradlew clean build :lib:test :tinypinyin-lexicons-android-cncity:test :tinypinyin-android-asset-lexicons:test :android-sample:connectedAndroidTest
```

### 3\. Effectiveness
Expand Down
1 change: 1 addition & 0 deletions android-sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
32 changes: 32 additions & 0 deletions android-sample/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.github.promeg:tinypinyin-lexicons-android-cncity:' + rootProject.ext.releaseVersionName

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
}
17 changes: 17 additions & 0 deletions android-sample/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/guyacong/Documents/android-sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.github.promeg.tinypinyin.android_sample;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

/**
* Created by guyacong on 2017/2/5.
*/
@RunWith(AndroidJUnit4.class)
public class MainActivityTest {
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class);

@Test
public void tinypinyin_should_work(){
onView(withId(R.id.mTvText)).check(matches(withText("ZHONGGUOCHONGQING")));
}
}
16 changes: 16 additions & 0 deletions android-sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.promeg.tinypinyin.android_sample">

<application android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.github.promeg.tinypinyin.android_sample;

import com.github.promeg.pinyinhelper.Pinyin;
import com.github.promeg.tinypinyin.lexicons.android.cncity.CnCityDict;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends Activity {

TextView mTvText;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mTvText = (TextView) findViewById(R.id.mTvText);

Pinyin.init(Pinyin.newConfig().with(CnCityDict.getInstance(MainActivity.this)));

mTvText.setText(Pinyin.toPinyin("中国重庆", ""));
}
}
14 changes: 14 additions & 0 deletions android-sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:layout_centerInParent="true"
android:id="@+id/mTvText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"/>
</RelativeLayout>
3 changes: 3 additions & 0 deletions android-sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">TinyPinyin-Sample</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.github.promeg.tinypinyin.android_sample;

import org.junit.Test;

import static org.junit.Assert.*;

/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {

@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
14 changes: 8 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
group 'com.github.promeg'
version '1.0-SNAPSHOT'


buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1'
classpath 'com.android.tools.build:gradle:2.2.3'

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1"
classpath "gradle.plugin.com.kageiit:lintrules:1.1.2"
}
}

Expand Down Expand Up @@ -38,7 +40,7 @@ ext {


groupName = 'com.github.promeg'
releaseVersionName = "2.0.1"
releaseVersionName = "2.0.2"
releaseVersionCode = 4

// Android
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include ':tinypinyin-lexicons-android-cncity', ':tinypinyin-lexicons-java-cncity',
':android-sample',
':tinypinyin-android-asset-lexicons'
rootProject.name = 'tinypinyin'
include 'lib'
2 changes: 1 addition & 1 deletion tinypinyin-android-asset-lexicons/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:2.2.3'
}

}
Expand Down
3 changes: 1 addition & 2 deletions tinypinyin-lexicons-android-cncity/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:2.2.3'
}

}
Expand Down Expand Up @@ -62,7 +62,6 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.github.promeg:tinypinyin:' + rootProject.ext.releaseVersionName
compile 'com.github.promeg:tinypinyin-android-asset-lexicons:' + rootProject.ext.releaseVersionName

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
Expand Down

0 comments on commit 59befc0

Please sign in to comment.