Skip to content

Commit

Permalink
convert to android studio
Browse files Browse the repository at this point in the history
  • Loading branch information
ispedals committed Mar 5, 2015
1 parent c08c410 commit 143f31b
Show file tree
Hide file tree
Showing 47 changed files with 685 additions and 311 deletions.
3 changes: 0 additions & 3 deletions .settings/org.eclipse.core.resources.prefs

This file was deleted.

284 changes: 0 additions & 284 deletions .settings/org.eclipse.jdt.core.prefs

This file was deleted.

3 changes: 0 additions & 3 deletions .settings/org.eclipse.jdt.ui.prefs

This file was deleted.

15 changes: 15 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}

allprojects {
repositories {
jcenter()
}
}
101 changes: 101 additions & 0 deletions etc/sql.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
CREATE TABLE dict (kanji TEXT, kana TEXT, entry TEXT);
INSERT INTO table VALUES('軍車','ぐんしゃ','(n) tank (military vehicle)');
INSERT INTO table VALUES('他州','たしゅう','(n) another state/different region');
INSERT INTO table VALUES('押しこむ','おしこむ','(v5m,vi,vt) to push into/to cram into/to stuff into/to crowd into/to break in/to burglarize');
INSERT INTO table VALUES('米話','べいわ','(n) American spoken English');
INSERT INTO table VALUES(NULL,'どーなつ','ドーナツ /(n) doughnut/(P)/');
INSERT INTO table VALUES('大宮司','だいぐうじ','(n) high priest of a great shrine');
INSERT INTO table VALUES('成書','せいしょ','(n) book');
INSERT INTO table VALUES('ちきん南蛮','ちきんなんばん','チキン南蛮 [チキンなんばん] /(n) fried chicken with vinegar and tartar sauce/');
INSERT INTO table VALUES('一定不変','いっていふへん','(n) invariable/permanent');
INSERT INTO table VALUES('つむじ風','つむじかぜ','(n) whirlwind');
INSERT INTO table VALUES('躁病','そうびょう','(n,adj-no) mania');
INSERT INTO table VALUES(NULL,'おーしゃのーと','オーシャノート /(n) oceanaut/');
INSERT INTO table VALUES(NULL,'ちゃんばら','(n,abbr) sword fight/sword play');
INSERT INTO table VALUES(NULL,'たいむれこーだー','タイムレコーダー /(n) time clock/time recorder/');
INSERT INTO table VALUES(NULL,'めがねべにはぜ','メガネベニハゼ /(n) redface dwarfgoby (Trimma benjamini, species found in the Western Pacific)/ring-eye pygmy-goby/');
INSERT INTO table VALUES('炊立て','たきたて','(adj-no) freshly cooked');
INSERT INTO table VALUES('食い掛け','くいかけ','(adj-no) half-eaten');
INSERT INTO table VALUES('溢れる','こぼれる','(v1,vi,uk) to spill/to fall out of/to overflow/to peek through/to become visible (although normally not)/to escape (of a smile, tear, etc.)/(P)');
INSERT INTO table VALUES('梯子の段','はしごのだん','(n) rung of a ladder');
INSERT INTO table VALUES('相好','そうごう','(n) features/appearance');
INSERT INTO table VALUES('閉会のことば','へいかいのことば','(exp) closing address');
INSERT INTO table VALUES('不明','ふめい','(adj-na,n) unknown/obscure/indistinct/uncertain/ambiguous/ignorant/lack of wisdom/anonymous/unidentified/(P)');
INSERT INTO table VALUES('謝謝','しえしえ','謝謝 [シエシエ] /(int) thank you/');
INSERT INTO table VALUES('丸写し','まるうつし','(n,vs) copying in entirety (verbatim)');
INSERT INTO table VALUES('下足場','げそくば','(n) area for storing (outdoor) footwear');
INSERT INTO table VALUES(NULL,'こんしゃすねす','コンシャスネス /(n) consciousness/');
INSERT INTO table VALUES('一転','いってん','(n-adv) turn/complete change');
INSERT INTO table VALUES('言い返し','いいかえし','(n) replying/reply');
INSERT INTO table VALUES('一人天下','ひとりてんか','(n) being the sole master of the situation/reigning supreme/standing unchallenged');
INSERT INTO table VALUES(NULL,'もざんびーく','モザンビーク /(n) Mozambique/(P)/');
INSERT INTO table VALUES('多様性','たようせい','(n) diversity/variety');
INSERT INTO table VALUES('路用','ろよう','(n) travelling expenses/traveling expenses');
INSERT INTO table VALUES('序詞','じょし','(n) foreword/preface/introduction/prefatory modifying statement (of a waka, etc.)');
INSERT INTO table VALUES('かみ合せ','かみあわせ','(n) engaging or meshing (of gears)/occlusion (of teeth)');
INSERT INTO table VALUES('雷名','らいめい','(n) fame/renown/great name');
INSERT INTO table VALUES(NULL,'べるがもっと','ベルガモット /(n) bergamot (Citrus aurantium ssp. bergamia)/bergamot orange/bergamot (Monarda didyma)/bee balm/Oswego tea/');
INSERT INTO table VALUES('鈎','はり','(n,ctr,n-suf) needle/pin/hook/stinger/thorn/hand (e.g. clock, etc.)/pointer/staple (for a stapler)/needlework/sewing/malice/counter for stitches/(P)');
INSERT INTO table VALUES('詰物','つめもの','(n) filling or packing material/stuffing/padding');
INSERT INTO table VALUES('気宇仙','きゅうせん','(n,uk) multicolorfin rainbowfish (Parajulis poecilepterus, was Halichoeres poecilopterus)');
INSERT INTO table VALUES('火山灰','かざんばい','(n) volcanic ash');
INSERT INTO table VALUES('鱝','えい','(n,uk,gikun,oK) ray (fish)/stingray');
INSERT INTO table VALUES('引き据える','ひきすえる','(v1) to (physically) force someone to sit down');
INSERT INTO table VALUES(NULL,'ぐりーくらぶ','グリークラブ /(n) glee club/(P)/');
INSERT INTO table VALUES('捏ねくり回す','こねくりまわす','(v5s) to knead/to turn');
INSERT INTO table VALUES('踞る','うずくまる','(v5r,vi,uk) to crouch/to squat/to cower/(P)');
INSERT INTO table VALUES('嘴太海烏','はしぶとうみがらす','(n,uk) thick-billed murre (Uria lomvia)/Brunnich''s guillemot');
INSERT INTO table VALUES('可変数','かへんすう','(n) variable number');
INSERT INTO table VALUES(NULL,'ないとがうん','ナイトガウン /(n) nightgown/');
INSERT INTO table VALUES('結婚祝い','けっこんいわい','(n) wedding present');
INSERT INTO table VALUES('秋風落莫','しゅうふうらくばく','(n) forlorn and helpless/lonely and desolate');
INSERT INTO table VALUES('群衆','ぐんじゅ','(n,vs) group (of people)/crowd/horde/throng/mob/multitude/(P)');
INSERT INTO table VALUES('天津','あまつ','(adj-f,arch) heavenly/imperial');
INSERT INTO table VALUES('老優','ろうゆう','(n) elderly or veteran actor');
INSERT INTO table VALUES('動物ういるす','どうぶつういるす','動物ウイルス [どうぶつウイルス] /(n) animal virus/');
INSERT INTO table VALUES('竈','かま','(n) stove/furnace/kiln');
INSERT INTO table VALUES('似鯉','にごい','似鯉 [ニゴイ] /(n,uk) Hemibarbus barbus (species of cyprinid)/');
INSERT INTO table VALUES(NULL,'おーあーるでーびー','オーアールデービー /(n) ORDB/');
INSERT INTO table VALUES('銀鍍金','ぎんめっき','(n,vs,adj-no) silvering/silver-plating');
INSERT INTO table VALUES('行燈','あんどう','(n,oK) fixed paper-enclosed lantern/paper-covered wooden stand housing an (oil) lamp');
INSERT INTO table VALUES('竜の落し子','たつのおとしご','竜の落し子 [タツノオトシゴ] /(n) seahorse/sea horse/');
INSERT INTO table VALUES('体位','たいい','(n,adj-no) physique/physical standard/posture/sexual position');
INSERT INTO table VALUES('執','たらし','(n,arch) bow (and arrow; esp. of a noble)');
INSERT INTO table VALUES('桂男','かつらお','(n,arch) man in the moon');
INSERT INTO table VALUES('申込書','もうしこみしょ','(n) application form/written application/(P)');
INSERT INTO table VALUES('食事をとる','しょくじをとる','(exp,v5r) to take a meal/to have a meal/to catch a meal/to get grub/to grub/to break bread/to chow down/to eat dinner/to have a bite/to strap on a feed-bag');
INSERT INTO table VALUES(NULL,'らいぶらりけーす','ライブラリケース /(n) library case/');
INSERT INTO table VALUES(NULL,'さんどばす','サンドバス /(n) sand bath/');
INSERT INTO table VALUES('値段を高く付ける','ねだんをたかくつける','(exp,v1) to put a high price on');
INSERT INTO table VALUES('書き難い','かきにくい','(adj-i) difficult to write or draw/does not write well (pen, brush, etc.)');
INSERT INTO table VALUES(NULL,'えらーこーど','エラーコード /(n) error code/');
INSERT INTO table VALUES('銘文','めいぶん','(n) inscription');
INSERT INTO table VALUES('光学','こうがく','(n,adj-no) optics');
INSERT INTO table VALUES('くーろんの法則','くーろんのほうそく','クーロンの法則 [クーロンのほうそく] /(n) Coulomb''s law/');
INSERT INTO table VALUES('癒し','いやし','(n,adj-no) healing/soothing/therapy/comfort/solace');
INSERT INTO table VALUES('先込め銃','さきごめじゅう','(n) muzzle loader');
INSERT INTO table VALUES('軍備縮小','ぐんびしゅくしょう','(n) reduction of armaments/disarmament');
INSERT INTO table VALUES('配電','はいでん','(n,vs) distribution of electricity');
INSERT INTO table VALUES('悪手','あくしゅ','(n) poor move');
INSERT INTO table VALUES('外股','そともも','(n) outer thigh');
INSERT INTO table VALUES('汚染','おせん','(n,vs) pollution/contamination/(P)');
INSERT INTO table VALUES('憧憬','しょうけい','(n,vs) longing/aspiration');
INSERT INTO table VALUES('輔星','ほせい','(n,obsc) Alcor/the Little Horseman star');
INSERT INTO table VALUES('食器洗い機','しょっきあらいき','(n) dishwasher/dishwashing machine');
INSERT INTO table VALUES('耳が痛い','みみがいたい','(exp,adj-i) (e.g. of a reprimand) being painfully-true/striking home');
INSERT INTO table VALUES('肝臓茸','かんぞうたけ','(n,uk) beefsteak fungus (Fistulina hepatica)/beefsteak mushroom');
INSERT INTO table VALUES(NULL,'ふらっとぱねる','フラットパネル /(n) flat panel (monitor, e.g.)/');
INSERT INTO table VALUES(NULL,'すたんだーどらいぶらり','スタンダードライブラリ /(n) standard library (programming)/');
INSERT INTO table VALUES('許すまじ','ゆるすまじ','(exp) to be unforgivable/to never forgive something');
INSERT INTO table VALUES('南方仏教','なんぽうぶっきょう','(n) Southern Buddhism (as practiced in Sri Lanka and Southeast Asia)');
INSERT INTO table VALUES('南海偽角平虫','なんかいにせつのひらむし','南海偽角平虫 [ナンカイニセツノヒラムシ] /(n,uk) Persian carpet flatworm (Pseudobiceros bedfordi)/Bedford''s flatworm/');
INSERT INTO table VALUES(NULL,'べんちぷれす','ベンチプレス /(n) bench press/');
INSERT INTO table VALUES('外国人持ち株比率','がいこくじんもちかぶひりつ','(n) foreign stock ownership ratio/foreign stockholding ratio');
INSERT INTO table VALUES('身元調査','みもとちょうさ','(n,col) identity or background check (often to see if someone is a burakumin)');
INSERT INTO table VALUES(NULL,'おんざまーく','オンザマーク /(n) on the mark/');
INSERT INTO table VALUES('原子力時代','げんしりょくじだい','(n) atomic age');
INSERT INTO table VALUES(NULL,'そんな','(adj-pn) such (about the actions of the listener, or about ideas expressed or understood by the listener)/like that/that sort of/(P)');
INSERT INTO table VALUES('恬','てん','(adj-t,adv-to) nonchalant');
INSERT INTO table VALUES(NULL,'そーだふろーと','ソーダフロート /(n) soda float/');
INSERT INTO table VALUES('保守ぱねる','ほしゅぱねる','保守パネル [ほしゅパネル] /(n) maintenance panel/');
INSERT INTO table VALUES('帯電体','たいでんたい','(n) charged body');
27 changes: 27 additions & 0 deletions floatingJapaneseDictionary/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
applicationId "pedals.is.floatingjapanesedictionary"
minSdkVersion 11
targetSdkVersion 21

testApplicationId "pedals.is.floatingjapanesedictionary.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}

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

dependencies {
compile 'com.github.sherpya:standout:1.0.2'
compile 'com.android.support:support-v4:21.0.0'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package pedals.is.floatingjapanesedictionary.test;

import java.util.ArrayList;

import pedals.is.floatingjapanesedictionary.deinflector.DeInflector;
import pedals.is.floatingjapanesedictionary.deinflector.DeinflectorTerm;
import junit.framework.TestCase;

public class DeinflectorTest extends TestCase {


/**
* @param name
*/
public DeinflectorTest(String name) {
super(name);
}

/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
}

/* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
*/
protected void tearDown() throws Exception {
super.tearDown();
}

/**
* Test something
*/
public final void testDeinflect() {
ArrayList<DeinflectorTerm> words = DeInflector.deInflect("来ます");
assertTrue("Kanji deinflected", words.get(0).word.equals("来る"));
words = DeInflector.deInflect("きます");
assertTrue("Hiragana deinflected", words.get(0).word.equals("くる"));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package pedals.is.floatingjapanesedictionary.test;

import pedals.is.floatingjapanesedictionary.downloader.DictionaryManagerService;
import android.content.Intent;
import android.test.ServiceTestCase;

public class DictionaryManagerServiceTest extends
ServiceTestCase<DictionaryManagerService> {

public DictionaryManagerServiceTest() {
super(DictionaryManagerService.class);
}

public final void testStarts() {
startService(new Intent(getContext(), DictionaryManagerService.class));
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
assertFalse("DictionaryManagerService stops when given no action",
DictionaryManagerService.RUNNING);

}

public final void testDeletingNothing() {
Intent intent = new Intent(getContext(), DictionaryManagerService.class);
intent.putExtra("action", "reset");
startService(intent);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
assertFalse(
"DictionaryManagerService stops when told to reset and there are no files",
DictionaryManagerService.RUNNING);

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package pedals.is.floatingjapanesedictionary.test;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabase;
import android.test.AndroidTestCase;
import pedals.is.floatingjapanesedictionary.dictionarysearcher.DictionaryOpenHelper;

public class DictionaryOpenHelperTest extends AndroidTestCase {

public DictionaryOpenHelperTest() {
super();
}

public final void testRawQuery() {
DictionaryOpenHelper dictOpener = new DictionaryOpenHelper(getContext());
SQLiteDatabase dictionary = dictOpener.getReadableDatabase();
Cursor c = dictionary.rawQuery(
"select distinct kanji, kana, entry from dict", null);
assertTrue("Raw query fetched one row", c.moveToNext());
// fail(DatabaseUtils.dumpCurrentRowToString(c));
}

public final void testKanjiQuery() {
DictionaryOpenHelper dictOpener = new DictionaryOpenHelper(getContext());
SQLiteDatabase dictionary = dictOpener.getReadableDatabase();
Cursor c = dictionary.rawQuery(
"select distinct kanji, kana, entry from dict where kanji=?",
new String[] { "軍車" });
c.moveToNext();
ContentValues values = new ContentValues();
DatabaseUtils.cursorRowToContentValues(c, values);
assertTrue(values.getAsString("kanji").equals("軍車"));
}

public final void testKanaWithKanjiQuery() {
DictionaryOpenHelper dictOpener = new DictionaryOpenHelper(getContext());
SQLiteDatabase dictionary = dictOpener.getReadableDatabase();
Cursor c = dictionary.rawQuery(
"select distinct kanji, kana, entry from dict where kana=?",
new String[] { "ぐんしゃ" });
c.moveToNext();
ContentValues values = new ContentValues();
DatabaseUtils.cursorRowToContentValues(c, values);
assertTrue(values.getAsString("kana").equals("ぐんしゃ"));
}

public final void testOrQuerywithKanjiOnly() {
DictionaryOpenHelper dictOpener = new DictionaryOpenHelper(getContext());
SQLiteDatabase dictionary = dictOpener.getReadableDatabase();
Cursor c = dictionary
.rawQuery(
"select distinct kanji, kana, entry from dict where kanji=? or kana=?",
new String[] { "軍車", "軍車" });
c.moveToNext();
ContentValues values = new ContentValues();
DatabaseUtils.cursorRowToContentValues(c, values);
assertTrue(values.getAsString("kanji").equals("軍車"));
}

public final void testOrQuerywithKanaOnly() {
DictionaryOpenHelper dictOpener = new DictionaryOpenHelper(getContext());
SQLiteDatabase dictionary = dictOpener.getReadableDatabase();
Cursor c = dictionary
.rawQuery(
"select distinct kanji, kana, entry from dict where kanji=? or kana=?",
new String[] { "ぐんしゃ", "ぐんしゃ" });
c.moveToNext();
ContentValues values = new ContentValues();
DatabaseUtils.cursorRowToContentValues(c, values);
assertTrue(values.getAsString("kana").equals("ぐんしゃ"));
}

public final void testQuerywithBothKanjiandKana() {
DictionaryOpenHelper dictOpener = new DictionaryOpenHelper(getContext());
SQLiteDatabase dictionary = dictOpener.getReadableDatabase();
Cursor c = dictionary
.rawQuery(
"select distinct kanji, kana, entry from dict where kanji=? or kana=?",
new String[] { "軍車", "ぐんしゃ" });
c.moveToNext();
ContentValues values = new ContentValues();
DatabaseUtils.cursorRowToContentValues(c, values);
assertTrue(values.getAsString("kanji").equals("軍車"));
assertTrue(values.getAsString("kana").equals("ぐんしゃ"));
}

public final void testKanaOnlyQuery() {
DictionaryOpenHelper dictOpener = new DictionaryOpenHelper(getContext());
SQLiteDatabase dictionary = dictOpener.getReadableDatabase();
Cursor c = dictionary.rawQuery(
"select distinct kanji, kana, entry from dict where kana=?",
new String[] { "どーなつ" });
c.moveToNext();
ContentValues values = new ContentValues();
DatabaseUtils.cursorRowToContentValues(c, values);
assertTrue(values.getAsString("kana").equals("どーなつ"));
}

}
Loading

0 comments on commit 143f31b

Please sign in to comment.