Skip to content
This repository has been archived by the owner on Apr 26, 2020. It is now read-only.

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DreierF committed Apr 4, 2015
1 parent 41859f7 commit 2d40e08
Show file tree
Hide file tree
Showing 19 changed files with 163 additions and 55 deletions.
Binary file modified .gradle/2.2.1/taskArtifacts/outputFileStates.bin
Binary file not shown.
Binary file modified app/app-release.apk
Binary file not shown.
13 changes: 12 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
-keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}
-dontobfuscate
-keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}
-keepnames class * implements java.io.Serializable
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
!static !transient <fields>;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,10 @@ private SightSetting(Parcel in) {
}

public void update() {
distanceVal = (int) distance.getSelectedItemId();
value = setting.getText().toString();
if (distance != null && setting != null) {
distanceVal = (int) distance.getSelectedItemId();
value = setting.getText().toString();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ protected Boolean doInBackground(Uri... params) {
mImageView.getWidth(),
mImageView.getHeight());
File f = File
.createTempFile("png", null, getFilesDir());
.createTempFile("photo", "png", getFilesDir());
FileOutputStream out = new FileOutputStream(f);
imageBitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
mImageFile = f.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
import de.dreier.mytargets.managers.DatabaseManager;
import de.dreier.mytargets.managers.WearMessageManager;
import de.dreier.mytargets.models.Bow;
import de.dreier.mytargets.models.NotificationInfo;
import de.dreier.mytargets.models.Passe;
import de.dreier.mytargets.models.Round;
import de.dreier.mytargets.models.Shot;
import de.dreier.mytargets.utils.OnTargetSetListener;
import de.dreier.mytargets.utils.Target;
import de.dreier.mytargets.utils.WearableUtils;
import de.dreier.mytargets.views.TargetView;

public class InputActivity extends ActionBarActivity implements OnTargetSetListener {
Expand Down Expand Up @@ -133,7 +133,7 @@ private void startWearNotification() {
}
image = ThumbnailUtils.extractThumbnail(image, 320, 320);

WearableUtils.NotificationInfo info = buildInfo();
NotificationInfo info = buildInfo();
manager = new WearMessageManager(this, image, info);
}

Expand Down Expand Up @@ -292,7 +292,7 @@ public void onBackPressed() {
overridePendingTransition(R.anim.left_in, R.anim.right_out);
}

private WearableUtils.NotificationInfo buildInfo() {
private NotificationInfo buildInfo() {
String title = getString(R.string.passe_n, savedPasses);
String text = "";

Expand All @@ -311,6 +311,6 @@ private WearableUtils.NotificationInfo buildInfo() {
if (r.bow > 0) {
text += r.distance + ": " + db.getSetting(r.bow, r.distanceVal);
}
return new WearableUtils.NotificationInfo(r, title, text);
return new NotificationInfo(r, title, text);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import de.dreier.mytargets.utils.Target;

public class DatabaseManager extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 6;
private static final int DATABASE_VERSION = 7;

private static final String ID = "_id";
public static final String DATABASE_NAME = "database";
Expand Down Expand Up @@ -297,6 +297,9 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
cur.close();
}
if (oldVersion < 7) {
cleanup(db);
}
onCreate(db);
}

Expand Down Expand Up @@ -937,6 +940,7 @@ public <T extends IdProvider> void delete(T id) {

void deleteEntry(String table, long id) {
db.delete(table, "_id=" + id, null);
cleanup(db);
}

////// BACKUP DATABASE //////
Expand Down Expand Up @@ -1006,4 +1010,21 @@ public ArrayList<Integer> getDistances(int dist) {
Collections.sort(distances);
return distances;
}

public static void cleanup(SQLiteDatabase db) {
// Clean up rounds
db.execSQL("DELETE FROM ROUND WHERE _id IN (SELECT r._id " +
"FROM ROUND r LEFT JOIN TRAINING t ON t._id=r.training " +
"WHERE t._id IS NULL)");

// Clean up passes
db.execSQL("DELETE FROM PASSE WHERE _id IN (SELECT p._id " +
"FROM PASSE p LEFT JOIN ROUND r ON r._id=p.round " +
"WHERE r._id IS NULL)");

// Clean up shots
db.execSQL("DELETE FROM SHOOT WHERE _id IN (SELECT s._id " +
"FROM SHOOT s LEFT JOIN PASSE p ON p._id=s.passe " +
"WHERE p._id IS NULL)");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Collection;
import java.util.HashSet;

import de.dreier.mytargets.models.NotificationInfo;
import de.dreier.mytargets.models.Passe;
import de.dreier.mytargets.utils.OnTargetSetListener;
import de.dreier.mytargets.utils.WearableUtils;
Expand All @@ -35,12 +36,12 @@ public class WearMessageManager

private static final String TAG = "wearMessageManager";
private final OnTargetSetListener mListener;
private final WearableUtils.NotificationInfo info;
private final NotificationInfo info;
private final Bitmap image;

private final GoogleApiClient mGoogleApiClient;

public WearMessageManager(Context context, Bitmap image, WearableUtils.NotificationInfo info) {
public WearMessageManager(Context context, Bitmap image, NotificationInfo info) {
this.image = image;
this.info = info;
mGoogleApiClient = new GoogleApiClient.Builder(context)
Expand Down Expand Up @@ -78,7 +79,7 @@ Collection<String> getNodes() {
return results;
}

void sendMessage(Bitmap image, WearableUtils.NotificationInfo info) {
void sendMessage(Bitmap image, NotificationInfo info) {
// Serialize bundle to byte array
try {
final byte[] data = WearableUtils.serialize(image, info);
Expand All @@ -93,7 +94,7 @@ public void run() {
}
}

public void sendMessage(WearableUtils.NotificationInfo info) {
public void sendMessage(NotificationInfo info) {
// Serialize info to byte array
try {
final byte[] data = WearableUtils.serialize(info);
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<string name="my_share_text">Эй! Посмотрите как я стреляю. Я выбил:\n%1$d по X\n%2$d по 10\n%3$d по 9\nИтого %4$d из %5$d возможных.</string>
<string name="comments">Комментарии</string>
<string name="text">Текст</string>
<string name="dispersion_pattern">Расброс</string>
<string name="dispersion_pattern">Pазброс</string>
<string name="sharing_failed">Не удалось поделиться!</string>

<!-- Export -->
Expand Down Expand Up @@ -210,9 +210,9 @@
<item quantity="few">%d секунд</item>
<item quantity="many">%d секунды</item>
</plurals>
<string name="info">Information</string>
<string name="data">Data</string>
<string name="create_backup_on_sd">Creates a backup on sd card</string>
<string name="restore_backup">Restores a backup</string>
<string name="info">Информация</string>
<string name="data">Данные</string>
<string name="create_backup_on_sd">Сохранить резервную копию на флэш-карте</string>
<string name="restore_backup">Восстановить данные из резервной копии</string>

</resources>
Binary file modified app/wearable-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
signing.properties=C\:\\Users\\Florian\\Documents\\Repositories\\signing.properties
VERSION_CODE=29
VERSION_NAME=2.0.9
VERSION_CODE=30
VERSION_NAME=2.1.0
28 changes: 26 additions & 2 deletions shared/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apply plugin: 'com.android.library'

Properties props = new Properties()
props.load(new FileInputStream(file(project.property('signing.properties'))))

android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
Expand All @@ -10,7 +13,28 @@ android {
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
}
dependencies {
compile 'com.android.support:support-annotations:21.0.3'

signingConfigs {
release {
storeFile file(props['keystore'])
storePassword props['keystore.password']
keyAlias 'mytargets'
keyPassword props['keystore.password']
}
}

buildTypes {
debug {
signingConfig signingConfigs.release
}
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile 'com.android.support:support-annotations:21.0.3'
}
14 changes: 13 additions & 1 deletion shared/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
-keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}
-dontshrink
-dontobfuscate
-keep class **
-keepnames class * implements java.io.Serializable
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
!static !transient <fields>;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* MyTargets Archery
*
* Copyright (C) 2015 Florian Dreier
* All rights reserved
*/
package de.dreier.mytargets.models;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import java.io.Serializable;

public class BitmapDataObject implements Serializable {
static final long serialVersionUID = 46L;
public byte[] imageByteArray;

public BitmapDataObject() {
}

public Bitmap getBitmap() {
return BitmapFactory.decodeByteArray(imageByteArray, 0, imageByteArray.length);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* MyTargets Archery
*
* Copyright (C) 2015 Florian Dreier
* All rights reserved
*/
package de.dreier.mytargets.models;

import java.io.Serializable;

public class NotificationInfo implements Serializable {
static final long serialVersionUID = 43L;
public String title;
public String text;
public Round round;
public NotificationInfo(Round round, String title, String text) {
this.round = round;
this.title = title;
this.text = text;
}
}
29 changes: 2 additions & 27 deletions shared/src/main/java/de/dreier/mytargets/utils/WearableUtils.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package de.dreier.mytargets.utils;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

import de.dreier.mytargets.models.BitmapDataObject;
import de.dreier.mytargets.models.NotificationInfo;
import de.dreier.mytargets.models.Passe;
import de.dreier.mytargets.models.Round;

public class WearableUtils {
public static final String STARTED_ROUND = "round/started";
Expand Down Expand Up @@ -78,28 +77,4 @@ public static Bundle deserializeToBundle(byte[] data)
bundle.putSerializable(BUNDLE_INFO, (NotificationInfo) is.readObject());
return bundle;
}

public static class NotificationInfo implements Serializable {
static final long serialVersionUID = 43L;
public String title;
public String text;
public Round round;
public NotificationInfo(Round round, String title, String text) {
this.round = round;
this.title = title;
this.text = text;
}
}

public static class BitmapDataObject implements Serializable {
private static final long serialVersionUID = 111696345129311948L;
private byte[] imageByteArray;

public BitmapDataObject() {
}

public Bitmap getBitmap() {
return BitmapFactory.decodeByteArray(imageByteArray, 0, imageByteArray.length);
}
}
}
13 changes: 12 additions & 1 deletion wearable/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
-keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}
-dontobfuscate
-keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}
-keepnames class * implements java.io.Serializable
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
!static !transient <fields>;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
4 changes: 4 additions & 0 deletions wearable/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
package="de.dreier.mytargets">

<uses-feature android:name="android.hardware.type.watch" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="com.android.vending.BILLING"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<application
android:allowBackup="true"
Expand Down
Loading

0 comments on commit 2d40e08

Please sign in to comment.