Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ android {

signingConfigs {
release {
storeFile file("touch_helper.keystore")
storePassword project.findProperty("KEYSTORE_PASSWORD") ?: System.getenv("KEYSTORE_PASSWORD")
keyAlias project.findProperty("KEY_ALIAS") ?: System.getenv("KEY_ALIAS")
keyPassword project.findProperty("KEY_PASSWORD") ?: System.getenv("KEY_PASSWORD")
def keystoreFile = file("touch_helper.keystore")
def storePass = project.findProperty("KEYSTORE_PASSWORD") ?: System.getenv("KEYSTORE_PASSWORD")
def keyAliasName = project.findProperty("KEY_ALIAS") ?: System.getenv("KEY_ALIAS")
def keyPass = project.findProperty("KEY_PASSWORD") ?: System.getenv("KEY_PASSWORD")
if (keystoreFile.exists() && storePass && keyAliasName && keyPass) {
storeFile keystoreFile
storePassword storePass
keyAlias keyAliasName
keyPassword keyPass
}
}
}

Expand All @@ -47,7 +53,9 @@ android {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
if (signingConfigs.release.storeFile != null) {
signingConfig signingConfigs.release
}
}
}
testOptions {
Expand All @@ -57,22 +65,15 @@ android {
}
}
packagingOptions {
jniLibs {
excludes += ['pinyindb/*']
}
resources {
excludes += ['pinyindb/*']
excludes += ['META-INF/DEPENDENCIES', 'META-INF/LICENSE', 'META-INF/NOTICE']
}
}

// http://www.sollyu.com/android-apk-studio-generated-automatically-appends-a-version-number/
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
if(buildType.name == "release") {
output.outputFileName = new File("TouchHelper" + "-" + buildType.name + "-v" + defaultConfig.versionName + ".apk" );
} else {
output.outputFileName = new File("TouchHelper" + "-" + buildType.name + "-v" + defaultConfig.versionName + ".apk" );
}
output.outputFileName = "TouchHelper-${variant.buildType.name}-v${defaultConfig.versionName}.apk"
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-renamesourcefileattribute SourceFile

-keep class * extends java.io.Serializable { *; }

# Keep project model classes serialized with GSON
-keepclassmembers class com.zfdang.touchhelper.PackagePositionDescription { <fields>; }
-keepclassmembers class com.zfdang.touchhelper.PackageWidgetDescription { <fields>; }

# Keep pinyin4j resources and classes
-keep class net.sourceforge.pinyin4j.** { *; }

##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.zfdang.touchhelper;

import java.io.Serializable;
import java.util.Objects;

public class PackagePositionDescription implements Serializable {
public String packageName;
Expand All @@ -16,16 +17,48 @@ public PackagePositionDescription() {
}

public PackagePositionDescription(String packageName, String activityName, int x, int y) {
this.packageName = packageName;
this.activityName = activityName;
this.packageName = packageName != null ? packageName : "";
this.activityName = activityName != null ? activityName : "";
this.x = x;
this.y = y;
}

public PackagePositionDescription(PackagePositionDescription positionDescription) {
this.packageName = positionDescription.packageName;
this.activityName = positionDescription.activityName;
this.x = positionDescription.x;
this.y = positionDescription.y;
if (positionDescription != null) {
this.packageName = positionDescription.packageName != null ? positionDescription.packageName : "";
this.activityName = positionDescription.activityName != null ? positionDescription.activityName : "";
this.x = positionDescription.x;
this.y = positionDescription.y;
} else {
this.packageName = "";
this.activityName = "";
this.x = 0;
this.y = 0;
}
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PackagePositionDescription that = (PackagePositionDescription) o;
return x == that.x && y == that.y
&& Objects.equals(packageName, that.packageName)
&& Objects.equals(activityName, that.activityName);
}

@Override
public int hashCode() {
return Objects.hash(packageName, activityName, x, y);
}

@Override
public String toString() {
return "PackagePositionDescription{" +
"packageName='" + packageName + '\'' +
", activityName='" + activityName + '\'' +
", x=" + x +
", y=" + y +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,47 @@ public PackageWidgetDescription() {
}

public PackageWidgetDescription(String packageName, String activityName, String className, String idName, String description, String text, Rect position, boolean clickable, boolean onlyClick) {
this.packageName = packageName;
this.activityName = activityName;
this.className = className;
this.idName = idName;
this.description = description;
this.text = text;
this.position = position;
this.packageName = packageName != null ? packageName : "";
this.activityName = activityName != null ? activityName : "";
this.className = className != null ? className : "";
this.idName = idName != null ? idName : "";
this.description = description != null ? description : "";
this.text = text != null ? text : "";
this.position = position != null ? new Rect(position) : null;
this.clickable = clickable;
this.onlyClick = onlyClick;
}

public PackageWidgetDescription(PackageWidgetDescription widgetDescription) {
this.packageName = widgetDescription.packageName;
this.activityName = widgetDescription.activityName;
this.className = widgetDescription.className;
this.idName = widgetDescription.idName;
this.description = widgetDescription.description;
this.text = widgetDescription.text;
if (widgetDescription.position != null) {
this.position = new Rect();
this.position.left = widgetDescription.position.left;
this.position.top = widgetDescription.position.top;
this.position.right = widgetDescription.position.right;
this.position.bottom = widgetDescription.position.bottom;
if (widgetDescription != null) {
this.packageName = widgetDescription.packageName != null ? widgetDescription.packageName : "";
this.activityName = widgetDescription.activityName != null ? widgetDescription.activityName : "";
this.className = widgetDescription.className != null ? widgetDescription.className : "";
this.idName = widgetDescription.idName != null ? widgetDescription.idName : "";
this.description = widgetDescription.description != null ? widgetDescription.description : "";
this.text = widgetDescription.text != null ? widgetDescription.text : "";
if (widgetDescription.position != null) {
this.position = new Rect();
this.position.left = widgetDescription.position.left;
this.position.top = widgetDescription.position.top;
this.position.right = widgetDescription.position.right;
this.position.bottom = widgetDescription.position.bottom;
} else {
this.position = null;
}
this.clickable = widgetDescription.clickable;
this.onlyClick = widgetDescription.onlyClick;
} else {
this.packageName = "";
this.activityName = "";
this.className = "";
this.idName = "";
this.description = "";
this.text = "";
this.position = null;
this.clickable = false;
this.onlyClick = false;
}
this.clickable = widgetDescription.clickable;
this.onlyClick = widgetDescription.onlyClick;
}

@Override
Expand Down
Loading