1
0
Fork 0

Fix a little slowness and update build scripts

This commit is contained in:
Clam 2014-02-17 19:05:58 +11:00
parent fe425a6715
commit 65da823bd8
4 changed files with 72 additions and 12 deletions

1
.gitignore vendored
View file

@ -31,3 +31,4 @@ proguard/
#Other #Other
.gradle/ .gradle/
assets/dict.properties assets/dict.properties
t9build.properties

View file

@ -17,6 +17,65 @@ dependencies {
compile fileTree(dir: 'libs', include: '*.jar') compile fileTree(dir: 'libs', include: '*.jar')
} }
def execThing ( String cmdStr ) {
def stdout = new ByteArrayOutputStream()
String prefix = System.getenv("GITCMDPREFIX")
if (prefix != null) {
String cmd = prefix + cmdStr
exec {
commandLine cmd.tokenize()
standardOutput = stdout
}
} else {
exec {
commandLine cmdStr.tokenize()
standardOutput = stdout
}
}
return stdout
}
def computeVersionName = { ->
String ver = "git-source"
try {
if (execThing(" git status -z").toString().trim().equals("")) {
return execThing(' git log -1 --format="%h"').toString().trim()
} else {
return ver
}
} catch (all) {
ant.echo("Cannot run git (not in path?), using default versioning")
}
return ver
}
def getProps() {
Properties props = new Properties()
File f = new File("t9build.properties")
if (!f.exists()) {
f.createNewFile()
}
props.load(new FileInputStream(f))
return props
}
def saveProps(Properties props) {
props.store(new FileOutputStream(new File("t9build.properties")))
}
def computeVersionNumber = { ->
Properties props = getProps()
int verNum = Integer.valueOf(props.getProperty("verNum", "0"))
if (hasProperty('incrementBuildNumber')) {
verNum++
props.setProperty("verNum", String.valueOf(verNum))
saveProps(props)
}
return verNum
}
android { android {
compileSdkVersion 10 compileSdkVersion 10
buildToolsVersion "19.0.0" buildToolsVersion "19.0.0"
@ -45,6 +104,12 @@ android {
release.setRoot('build-types/release') release.setRoot('build-types/release')
} }
defaultConfig {
versionCode computeVersionNumber()
versionName computeVersionName()
}
// http://stackoverflow.com/a/19130098 // http://stackoverflow.com/a/19130098
signingConfigs { signingConfigs {
release { release {
@ -62,15 +127,10 @@ android {
} }
} }
task getDictSizes { task getDictSizes {
inputs.files 'assets/en-utf8.txt', 'assets/ru-utf8.txt' inputs.files 'assets/en-utf8.txt', 'assets/ru-utf8.txt'
outputs.file "assets/dict.properties" outputs.file "t9build.properties"
doLast { doLast {
ant.echo("Deleting old file...")
delete 'assets/dict.properties'
ant.echo("Calculating dict size...") ant.echo("Calculating dict size...")
FileCollection dicts = files("assets/en-utf8.txt", "assets/ru-utf8.txt") FileCollection dicts = files("assets/en-utf8.txt", "assets/ru-utf8.txt")

View file

@ -32,6 +32,8 @@ public class T9DB {
// 50k, 10k // 50k, 10k
private static final int FREQ_MAX = 50000; private static final int FREQ_MAX = 50000;
private static final int FREQ_DIV = 10000; private static final int FREQ_DIV = 10000;
// This seems to be pretty fast on my phone. 10 is pretty slow (Might be because > MAX_RESULTS (8).)
private static final int MINHITS = 4;
protected static final String COLUMN_ID = BaseColumns._ID; protected static final String COLUMN_ID = BaseColumns._ID;
protected static final String COLUMN_LANG = "lang"; protected static final String COLUMN_LANG = "lang";
@ -257,8 +259,7 @@ public class T9DB {
} }
cur.close(); cur.close();
// TODO: profile this and if it takes too long to only do it when hits is super low... if (hits < MINHITS) {
if (hits < 10) {
char c = is.charAt(islen - 1); char c = is.charAt(islen - 1);
c++; c++;
String q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD + String q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD +
@ -363,7 +364,7 @@ public class T9DB {
hits++; hits++;
} }
cur.close(); cur.close();
if (hits < 4) { if (hits < MINHITS) {
char c = is.charAt(islen - 1); char c = is.charAt(islen - 1);
c++; c++;
q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD + ", " + COLUMN_FREQUENCY + q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD + ", " + COLUMN_FREQUENCY +

View file

@ -270,9 +270,7 @@ public class TraditionalT9 extends InputMethodService implements
updateCandidates(); updateCandidates();
if (!restarting) { //TODO: Check if "restarting" variable will make things faster/more effecient
// Clear shift states.
}
mKeyMode = MODE_TEXT; mKeyMode = MODE_TEXT;