├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── src │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── woc │ │ │ └── chaizi │ │ │ └── ApplicationTest.java │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── assets │ │ │ └── db_data.db │ │ ├── java │ │ │ └── com │ │ │ │ └── woc │ │ │ │ └── chaizi │ │ │ │ ├── MainActivity.java │ │ │ │ ├── activity │ │ │ │ └── SettingActivity.java │ │ │ │ ├── db │ │ │ │ ├── DBOpenHandler.java │ │ │ │ └── SQLiteDAOImpl.java │ │ │ │ ├── entity │ │ │ │ └── Words.java │ │ │ │ └── util │ │ │ │ └── IO.java │ │ └── res │ │ │ ├── layout │ │ │ └── content_main.xml │ │ │ ├── menu │ │ │ └── menu_main.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ │ └── xml │ │ │ └── preferences.xml │ └── test │ │ └── java │ │ └── com │ │ └── woc │ │ └── chaizi │ │ └── ExampleUnitTest.java └── 拆字1.0.2.apk ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screenshot └── main.png └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | chaizi -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 22 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 49 | 50 | 51 | 52 | 53 | 1.8 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # chaizi 2 | 3 | ## 介绍 4 | 5 | Android 平台上的拆字软件,只支持拆汉字,拆字通过查询数据库实现。 6 | 7 | ## 截图 8 | 9 | ![截图](/screenshot/main.png) 10 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 22 5 | buildToolsVersion "22.0.1" 6 | 7 | defaultConfig { 8 | applicationId "com.woc.chaizi" 9 | minSdkVersion 15 10 | targetSdkVersion 22 11 | versionCode 3 12 | versionName "1.0.2" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled true 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | debug { 20 | minifyEnabled true 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | } 25 | 26 | dependencies { 27 | compile fileTree(include: ['*.jar'], dir: 'libs') 28 | testCompile 'junit:junit:4.12' 29 | } 30 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in d:\Users\Administrator\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/woc/chaizi/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.woc.chaizi; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/assets/db_data.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luoyesiqiu/chaizi/162dec23c9c9ecdcc13901056ca1e24cf4209be1/app/src/main/assets/db_data.db -------------------------------------------------------------------------------- /app/src/main/java/com/woc/chaizi/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.woc.chaizi; 2 | 3 | import android.app.Activity; 4 | import android.app.ProgressDialog; 5 | import android.content.DialogInterface; 6 | import android.content.Intent; 7 | import android.content.SharedPreferences; 8 | import android.net.Uri; 9 | import android.os.Bundle; 10 | import android.os.Environment; 11 | import android.preference.PreferenceManager; 12 | import android.view.View; 13 | import android.view.Menu; 14 | import android.view.MenuItem; 15 | import android.widget.EditText; 16 | import android.widget.Toast; 17 | 18 | import com.woc.chaizi.activity.SettingActivity; 19 | import com.woc.chaizi.db.SQLiteDAOImpl; 20 | import com.woc.chaizi.util.IO; 21 | 22 | import java.io.File; 23 | 24 | public class MainActivity extends Activity { 25 | public static final String SD_PATH= Environment.getExternalStorageDirectory().getAbsolutePath()+"/Android/data/com.woc.chaizi/"; 26 | public static final String DB_NAME="db_data.db"; 27 | private final String KEY="notIsFirstRun";//更新数据库要更新 28 | private SharedPreferences sharedPreferences; 29 | private SharedPreferences preferences; 30 | private EditText edit_source,edit_result; 31 | private ProgressDialog progressDialog; 32 | private Thread thread; 33 | @Override 34 | protected void onCreate(Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | setContentView(R.layout.content_main); 37 | sharedPreferences=getSharedPreferences("data",MODE_PRIVATE); 38 | preferences= PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); 39 | //如果是第一次,或者数据库文件不存在 40 | if(!sharedPreferences.getBoolean(KEY,false)||!new File(SD_PATH+DB_NAME).exists()) 41 | { 42 | IO.copyAssetToSD(this,DB_NAME,SD_PATH); 43 | sharedPreferences.edit().putBoolean(KEY,true).apply(); 44 | } 45 | edit_result=(EditText)findViewById(R.id.editText2); 46 | edit_source=(EditText)findViewById(R.id.editText1); 47 | } 48 | 49 | public void buttonClick(View v) 50 | { 51 | String sourceText=edit_source.getText().toString(); 52 | final char[] chs=sourceText.toCharArray(); 53 | progressDialog=ProgressDialog.show(this, "", "拆字中...", false, false); 54 | thread= new Thread(new Runnable() { 55 | @Override 56 | public void run() { 57 | 58 | SQLiteDAOImpl sqLiteDAO=new SQLiteDAOImpl(MainActivity.this); 59 | final StringBuilder sb=new StringBuilder(); 60 | int n=Integer.parseInt(preferences.getString("space_count","0")); 61 | for (int i=0;i findAll() { 80 | List lists = new ArrayList(); 81 | Words words = null; 82 | SQLiteDatabase db = dbOpenHandler.getReadableDatabase(); 83 | 84 | Cursor cursor = db.rawQuery("select * from words ", null); 85 | while (cursor.moveToNext()) { 86 | words = new Words(); 87 | words.setId(cursor.getInt(cursor.getColumnIndex("id"))); 88 | words.setSource(cursor.getString(cursor.getColumnIndex("source"))); 89 | words.setChai(cursor.getString(cursor.getColumnIndex("chai"))); 90 | lists.add(words); 91 | } 92 | db.close(); 93 | return lists; 94 | } 95 | 96 | /** 97 | * 获取所有条目 98 | * @return 99 | */ 100 | public long getCount() { 101 | SQLiteDatabase db = dbOpenHandler.getReadableDatabase(); 102 | Cursor cursor = db.rawQuery("select count(*) from words ", null); 103 | cursor.moveToFirst(); 104 | db.close(); 105 | return cursor.getLong(0); 106 | } 107 | } 108 | 109 | -------------------------------------------------------------------------------- /app/src/main/java/com/woc/chaizi/entity/Words.java: -------------------------------------------------------------------------------- 1 | package com.woc.chaizi.entity; 2 | 3 | /** 4 | * Created by zyw on 2016/4/9. 5 | */ 6 | public class Words { 7 | public String getChai() { 8 | return chai; 9 | } 10 | 11 | public void setChai(String chai) { 12 | this.chai = chai; 13 | } 14 | 15 | public String getSource() { 16 | return source; 17 | } 18 | 19 | public void setSource(String source) { 20 | this.source = source; 21 | } 22 | 23 | 24 | public int getId() { 25 | return id; 26 | } 27 | 28 | public void setId(int id) { 29 | this.id = id; 30 | } 31 | 32 | private int id; 33 | 34 | 35 | private String source; 36 | private String chai; 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/woc/chaizi/util/IO.java: -------------------------------------------------------------------------------- 1 | package com.woc.chaizi.util; 2 | 3 | import android.content.Context; 4 | import android.content.res.AssetManager; 5 | 6 | import com.woc.chaizi.db.SQLiteDAOImpl; 7 | import com.woc.chaizi.entity.Words; 8 | 9 | import java.io.BufferedInputStream; 10 | import java.io.BufferedOutputStream; 11 | import java.io.BufferedReader; 12 | import java.io.File; 13 | import java.io.FileOutputStream; 14 | import java.io.FileReader; 15 | import java.io.IOException; 16 | import java.io.InputStream; 17 | 18 | /** 19 | * Created by zyw on 2016/4/10. 20 | */ 21 | public class IO { 22 | 23 | /** 24 | * 拷贝文件到内存卡 25 | * @param path 26 | */ 27 | public static void copyAssetToSD(Context context,String fileName,String path) 28 | { 29 | File f=new File(path); 30 | if(!f.exists()) 31 | { 32 | f.mkdirs(); 33 | } 34 | f=new File(path+"db_data.db"); 35 | AssetManager assetManager=context.getAssets(); 36 | BufferedInputStream bufferedInputStream = null; 37 | BufferedOutputStream bufferedOutputStream = null; 38 | try { 39 | bufferedInputStream=new BufferedInputStream(assetManager.open(fileName)); 40 | bufferedOutputStream= new BufferedOutputStream(new FileOutputStream(f)); 41 | byte[] temp=new byte[1024]; 42 | while((bufferedInputStream.read(temp))!=-1) 43 | { 44 | bufferedOutputStream.write(temp); 45 | bufferedOutputStream.flush(); 46 | } 47 | 48 | } catch (IOException e) { 49 | e.printStackTrace(); 50 | } 51 | finally { 52 | try { 53 | if(bufferedInputStream!=null) 54 | bufferedInputStream.close(); 55 | } catch (IOException e) { 56 | e.printStackTrace(); 57 | } 58 | try { 59 | if(bufferedOutputStream!=null) 60 | bufferedOutputStream.close(); 61 | } catch (IOException e) { 62 | e.printStackTrace(); 63 | } 64 | } 65 | 66 | } 67 | 68 | /** 69 | * 写内容到数据库 70 | */ 71 | public static void writeToDB(Context context) 72 | { 73 | SQLiteDAOImpl op=new SQLiteDAOImpl(context); 74 | BufferedReader bufferedReader=null; 75 | try { 76 | bufferedReader=new BufferedReader(new FileReader("/sdcard/chaizi.txt")); 77 | String line=null; 78 | while((line=bufferedReader.readLine())!=null) 79 | { 80 | Words words= new Words(); 81 | words.setSource(line.substring(0, 1)); 82 | words.setChai(line.substring(3, line.length())); 83 | op.add(words); 84 | } 85 | } catch (Exception e) { 86 | // TODO Auto-generated catch block 87 | e.printStackTrace(); 88 | }finally { 89 | try { 90 | bufferedReader.close(); 91 | } catch (IOException e) { 92 | // TODO Auto-generated catch block 93 | e.printStackTrace(); 94 | } 95 | } 96 | 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 20 | 21 |