Fix a little slowness and update build scripts
This commit is contained in:
parent
fe425a6715
commit
65da823bd8
4 changed files with 72 additions and 12 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -31,3 +31,4 @@ proguard/
|
|||
#Other
|
||||
.gradle/
|
||||
assets/dict.properties
|
||||
t9build.properties
|
||||
72
build.gradle
72
build.gradle
|
|
@ -17,6 +17,65 @@ dependencies {
|
|||
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 {
|
||||
compileSdkVersion 10
|
||||
buildToolsVersion "19.0.0"
|
||||
|
|
@ -45,6 +104,12 @@ android {
|
|||
release.setRoot('build-types/release')
|
||||
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
versionCode computeVersionNumber()
|
||||
versionName computeVersionName()
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/a/19130098
|
||||
signingConfigs {
|
||||
release {
|
||||
|
|
@ -62,15 +127,10 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
task getDictSizes {
|
||||
inputs.files 'assets/en-utf8.txt', 'assets/ru-utf8.txt'
|
||||
outputs.file "assets/dict.properties"
|
||||
outputs.file "t9build.properties"
|
||||
doLast {
|
||||
ant.echo("Deleting old file...")
|
||||
|
||||
delete 'assets/dict.properties'
|
||||
|
||||
ant.echo("Calculating dict size...")
|
||||
|
||||
FileCollection dicts = files("assets/en-utf8.txt", "assets/ru-utf8.txt")
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ public class T9DB {
|
|||
// 50k, 10k
|
||||
private static final int FREQ_MAX = 50000;
|
||||
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_LANG = "lang";
|
||||
|
|
@ -257,8 +259,7 @@ public class T9DB {
|
|||
}
|
||||
cur.close();
|
||||
|
||||
// TODO: profile this and if it takes too long to only do it when hits is super low...
|
||||
if (hits < 10) {
|
||||
if (hits < MINHITS) {
|
||||
char c = is.charAt(islen - 1);
|
||||
c++;
|
||||
String q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD +
|
||||
|
|
@ -363,7 +364,7 @@ public class T9DB {
|
|||
hits++;
|
||||
}
|
||||
cur.close();
|
||||
if (hits < 4) {
|
||||
if (hits < MINHITS) {
|
||||
char c = is.charAt(islen - 1);
|
||||
c++;
|
||||
q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD + ", " + COLUMN_FREQUENCY +
|
||||
|
|
|
|||
|
|
@ -270,9 +270,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
|
||||
updateCandidates();
|
||||
|
||||
if (!restarting) {
|
||||
// Clear shift states.
|
||||
}
|
||||
//TODO: Check if "restarting" variable will make things faster/more effecient
|
||||
|
||||
mKeyMode = MODE_TEXT;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue