tests + proguard
This commit is contained in:
@@ -1,56 +1,105 @@
|
||||
-target 1.6
|
||||
-dontusemixedcaseclassnames
|
||||
-dontskipnonpubliclibraryclasses
|
||||
-dontpreverify
|
||||
-repackageclasses ''
|
||||
-allowaccessmodification
|
||||
-optimizations !code/simplification/arithmetic
|
||||
-keepattributes *Annotation*
|
||||
|
||||
-keep public class * extends android.app.Activity
|
||||
-keep public class * extends android.app.Application
|
||||
-keep public class * extends android.app.Service
|
||||
-keep public class * extends android.content.BroadcastReceiver
|
||||
-keep public class * extends android.content.ContentProvider
|
||||
|
||||
-keep public class * extends android.view.View {
|
||||
public <init>(android.content.Context);
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
public void set*(...);
|
||||
}
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
}
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
|
||||
-keepclassmembers class * extends android.content.Context {
|
||||
public void *(android.view.View);
|
||||
public void *(android.view.MenuItem);
|
||||
}
|
||||
|
||||
-keepclassmembers class * implements android.os.Parcelable {
|
||||
static android.os.Parcelable$Creator CREATOR;
|
||||
}
|
||||
|
||||
-keepclassmembers class **.R$* {
|
||||
public static <fields>;
|
||||
}
|
||||
|
||||
-keepclassmembers enum * {
|
||||
public static **[] values();
|
||||
public static ** valueOf(java.lang.String);
|
||||
}
|
||||
|
||||
-dontwarn javax.xml.stream.**
|
||||
-dontwarn com.bea.xml.stream.**
|
||||
-dontwarn sun.misc.Unsafe
|
||||
-dontwarn android.annotation.TargetApi
|
||||
|
||||
-keep class org.simpleframework.xml.** { *; }
|
||||
-keep class com.actionbarsherlock.** { *; }
|
||||
-keep class * implements org.solovyev.android.calculator.model.MathPersistenceEntity
|
||||
-target 1.6
|
||||
-dontusemixedcaseclassnames
|
||||
-dontskipnonpubliclibraryclasses
|
||||
-dontpreverify
|
||||
-repackageclasses ''
|
||||
-allowaccessmodification
|
||||
-optimizations !code/simplification/arithmetic
|
||||
-keepattributes *Annotation*
|
||||
|
||||
-keep public class * extends android.app.Activity
|
||||
-keep public class * extends android.app.Application
|
||||
-keep public class * extends android.app.Service
|
||||
-keep public class * extends android.content.BroadcastReceiver
|
||||
-keep public class * extends android.content.ContentProvider
|
||||
|
||||
-keep public class * extends android.view.View {
|
||||
public <init>(android.content.Context);
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
public void set*(...);
|
||||
}
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
}
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
|
||||
-keepclassmembers class * extends android.content.Context {
|
||||
public void *(android.view.View);
|
||||
public void *(android.view.MenuItem);
|
||||
}
|
||||
|
||||
-keepclassmembers class * implements android.os.Parcelable {
|
||||
static android.os.Parcelable$Creator CREATOR;
|
||||
}
|
||||
|
||||
-keepclassmembers class **.R$* {
|
||||
public static <fields>;
|
||||
}
|
||||
|
||||
-keepclassmembers enum * {
|
||||
public static **[] values();
|
||||
public static ** valueOf(java.lang.String);
|
||||
}
|
||||
|
||||
-keep @org.simpleframework.xml.Root public class * {
|
||||
*;
|
||||
}
|
||||
|
||||
-dontwarn javax.xml.stream.**
|
||||
-dontwarn com.bea.xml.stream.**
|
||||
-dontwarn sun.misc.Unsafe
|
||||
-dontwarn android.annotation.TargetApi
|
||||
-dontwarn org.solovyev.common.math.visualisation.**
|
||||
-dontwarn org.solovyev.common.math.graph.**
|
||||
-dontwarn org.solovyev.common.math.algorithms.**
|
||||
-dontwarn org.solovyev.common.drawing.**
|
||||
-dontwarn org.joda.**
|
||||
-dontwarn jscl.mathml.**
|
||||
-dontwarn com.google.common.collect.MinMaxPriorityQueue
|
||||
|
||||
-keep class org.simpleframework.xml.** { *; }
|
||||
-keep class com.actionbarsherlock.** { *; }
|
||||
-keep class * implements org.solovyev.android.calculator.model.MathPersistenceEntity
|
||||
|
||||
#
|
||||
#*********************************************************************
|
||||
#
|
||||
# ACRA
|
||||
#
|
||||
#*********************************************************************
|
||||
#
|
||||
|
||||
# we need line numbers in our stack traces otherwise they are pretty useless
|
||||
-renamesourcefileattribute SourceFile
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# ACRA needs "annotations" so add this...
|
||||
-keepattributes *Annotation*
|
||||
|
||||
# keep this class so that logging will show 'ACRA' and not a obfuscated name like 'a'.
|
||||
# Note: if you are removing log messages elsewhere in this file then this isn't necessary
|
||||
-keep class org.acra.ACRA {
|
||||
*;
|
||||
}
|
||||
|
||||
# keep this around for some enums that ACRA needs
|
||||
-keep class org.acra.ReportingInteractionMode {
|
||||
*;
|
||||
}
|
||||
|
||||
# keep this otherwise it is removed by ProGuard
|
||||
-keep public class org.acra.ErrorReporter
|
||||
{
|
||||
public void addCustomData(java.lang.String,java.lang.String);
|
||||
}
|
||||
|
||||
# keep this otherwise it is removed by ProGuard
|
||||
-keep public class org.acra.ErrorReporter
|
||||
{
|
||||
public org.acra.ErrorReporter$ReportsSenderWorker handleSilentException(java.lang.Throwable);
|
||||
}
|
||||
|
@@ -1,95 +1,99 @@
|
||||
package org.solovyev.android.calculator.model;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.preference.PreferenceManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.simpleframework.xml.Serializer;
|
||||
import org.simpleframework.xml.core.Persister;
|
||||
import org.solovyev.android.calculator.MathEntityDao;
|
||||
import org.solovyev.android.calculator.MathEntityPersistenceContainer;
|
||||
import org.solovyev.android.calculator.MathPersistenceEntity;
|
||||
import org.solovyev.android.calculator.R;
|
||||
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 10/7/12
|
||||
* Time: 6:46 PM
|
||||
*/
|
||||
public class AndroidMathEntityDao<T extends MathPersistenceEntity> implements MathEntityDao<T> {
|
||||
|
||||
@Nullable
|
||||
private final Integer preferenceStringId;
|
||||
|
||||
@NotNull
|
||||
private final Context context;
|
||||
|
||||
@Nullable
|
||||
private final Class<? extends MathEntityPersistenceContainer<T>> persistenceContainerClass;
|
||||
|
||||
public AndroidMathEntityDao(@Nullable Integer preferenceStringId,
|
||||
@NotNull Application application,
|
||||
@Nullable Class<? extends MathEntityPersistenceContainer<T>> persistenceContainerClass) {
|
||||
this.preferenceStringId = preferenceStringId;
|
||||
this.context = application;
|
||||
this.persistenceContainerClass = persistenceContainerClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(@NotNull MathEntityPersistenceContainer<T> container) {
|
||||
if (preferenceStringId != null) {
|
||||
final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
final SharedPreferences.Editor editor = settings.edit();
|
||||
|
||||
final StringWriter sw = new StringWriter();
|
||||
final Serializer serializer = new Persister();
|
||||
try {
|
||||
serializer.write(container, sw);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
editor.putString(context.getString(preferenceStringId), sw.toString());
|
||||
|
||||
editor.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public MathEntityPersistenceContainer<T> load() {
|
||||
if (persistenceContainerClass != null && preferenceStringId != null) {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
if (preferences != null) {
|
||||
final String value = preferences.getString(context.getString(preferenceStringId), null);
|
||||
if (value != null) {
|
||||
final Serializer serializer = new Persister();
|
||||
try {
|
||||
return serializer.read(persistenceContainerClass, value);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription(@NotNull String descriptionId) {
|
||||
final Resources resources = context.getResources();
|
||||
final int stringId = resources.getIdentifier(descriptionId, "string", R.class.getPackage().getName());
|
||||
try {
|
||||
return resources.getString(stringId);
|
||||
} catch (Resources.NotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
package org.solovyev.android.calculator.model;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.preference.PreferenceManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.simpleframework.xml.Serializer;
|
||||
import org.simpleframework.xml.core.Persister;
|
||||
import org.solovyev.android.calculator.CalculatorApplication;
|
||||
import org.solovyev.android.calculator.MathEntityDao;
|
||||
import org.solovyev.android.calculator.MathEntityPersistenceContainer;
|
||||
import org.solovyev.android.calculator.MathPersistenceEntity;
|
||||
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 10/7/12
|
||||
* Time: 6:46 PM
|
||||
*/
|
||||
public class AndroidMathEntityDao<T extends MathPersistenceEntity> implements MathEntityDao<T> {
|
||||
|
||||
@NotNull
|
||||
private static final String TAG = AndroidMathEntityDao.class.getSimpleName();
|
||||
|
||||
@Nullable
|
||||
private final Integer preferenceStringId;
|
||||
|
||||
@NotNull
|
||||
private final Context context;
|
||||
|
||||
@Nullable
|
||||
private final Class<? extends MathEntityPersistenceContainer<T>> persistenceContainerClass;
|
||||
|
||||
public AndroidMathEntityDao(@Nullable Integer preferenceStringId,
|
||||
@NotNull Application application,
|
||||
@Nullable Class<? extends MathEntityPersistenceContainer<T>> persistenceContainerClass) {
|
||||
this.preferenceStringId = preferenceStringId;
|
||||
this.context = application;
|
||||
this.persistenceContainerClass = persistenceContainerClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(@NotNull MathEntityPersistenceContainer<T> container) {
|
||||
if (preferenceStringId != null) {
|
||||
final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
final SharedPreferences.Editor editor = settings.edit();
|
||||
|
||||
final StringWriter sw = new StringWriter();
|
||||
final Serializer serializer = new Persister();
|
||||
try {
|
||||
serializer.write(container, sw);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
editor.putString(context.getString(preferenceStringId), sw.toString());
|
||||
|
||||
editor.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public MathEntityPersistenceContainer<T> load() {
|
||||
if (persistenceContainerClass != null && preferenceStringId != null) {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
if (preferences != null) {
|
||||
final String value = preferences.getString(context.getString(preferenceStringId), null);
|
||||
if (value != null) {
|
||||
final Serializer serializer = new Persister();
|
||||
try {
|
||||
return serializer.read(persistenceContainerClass, value);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription(@NotNull String descriptionId) {
|
||||
final Resources resources = context.getResources();
|
||||
|
||||
final int stringId = resources.getIdentifier(descriptionId, "string", CalculatorApplication.class.getPackage().getName());
|
||||
try {
|
||||
return resources.getString(stringId);
|
||||
} catch (Resources.NotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user