Skip to content

Commit 2a61ef1

Browse files
committed
fixed problem that prevented the wallpaper from persisting on device shutdown, improved exception logging
1 parent ee26451 commit 2a61ef1

4 files changed

Lines changed: 25 additions & 11 deletions

File tree

app/proguard-rules.pro

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
-printconfiguration
22
-optimizationpasses 5
33
-allowaccessmodification
4-
-repackageclasses ''
4+
-repackageclasses ''
5+
6+
-assumenosideeffects class android.util.Log {
7+
public static *** d(...);
8+
public static *** w(...);
9+
public static *** v(...);
10+
public static *** i(...);
11+
public static *** e(...);
12+
public static *** getStackTraceString(...);
13+
}

app/src/main/java/at/connyduck/pixelwallpaper/IntList.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package at.connyduck.pixelwallpaper;
22

3-
public class IntList {
3+
import java.io.Serializable;
4+
5+
public class IntList implements Serializable {
46

57
private static final int MIN_CAPACITY_INCREMENT = 12;
8+
private static final long serialVersionUID = -4046407753817880014L;
69

710
private int size;
811
private int[] array;

app/src/main/java/at/connyduck/pixelwallpaper/PersistenceManager.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.content.Context;
44
import android.content.SharedPreferences;
5+
import android.util.Log;
56

67
import java.io.FileInputStream;
78
import java.io.FileNotFoundException;
@@ -13,7 +14,7 @@
1314

1415
public class PersistenceManager {
1516

16-
private static final String fileID = "at.connyduck.pixelwallpaper save file";
17+
private static final String fileID = "at.connyduck.pixelwallpaper.save";
1718
private static final String preferenceID = "at.connyduck.pixelwallpaper prefs";
1819

1920
private Context context;
@@ -45,6 +46,7 @@ public boolean load() {
4546
fis = context.openFileInput(fileID);
4647
} catch (FileNotFoundException e) {
4748
//first time load
49+
Log.i("PersistenceManager", Log.getStackTraceString(e));
4850
return false;
4951
}
5052

@@ -58,11 +60,10 @@ public boolean load() {
5860
i.close();
5961
fis.close();
6062

61-
} catch (IOException e) {
63+
} catch (IOException | ClassNotFoundException e) {
64+
Log.w("PersistenceManager", Log.getStackTraceString(e));
6265
return false;
63-
} catch (ClassNotFoundException e) {
64-
return false;
65-
}
66+
}
6667
}
6768

6869
SharedPreferences pref = context.getSharedPreferences(preferenceID, 0);
@@ -86,7 +87,7 @@ public void save() {
8687
try {
8788
fos = context.openFileOutput(fileID, Context.MODE_PRIVATE);
8889
} catch (FileNotFoundException e) {
89-
//Log.d("PersistenceManager", "FileNotFoundException");
90+
Log.w("PersistenceManager", Log.getStackTraceString(e));
9091
}
9192

9293
ObjectOutputStream o;
@@ -102,7 +103,7 @@ public void save() {
102103
}
103104

104105
} catch (IOException e) {
105-
//Log.d("PersistenceManager", "IOException "+e);
106+
Log.w("PersistenceManager", Log.getStackTraceString(e));
106107
}
107108

108109
SharedPreferences.Editor editor = context.getSharedPreferences(preferenceID, 0).edit();

app/src/main/java/at/connyduck/pixelwallpaper/ShutdownReceiver.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.content.BroadcastReceiver;
44
import android.content.Context;
55
import android.content.Intent;
6+
import android.util.Log;
67

78
public class ShutdownReceiver extends BroadcastReceiver {
89
private PixelWallpaperService.PixelWallpaperEngine pwe;
@@ -13,8 +14,8 @@ public ShutdownReceiver(PixelWallpaperService.PixelWallpaperEngine pwe) {
1314

1415
@Override
1516
public void onReceive(Context context, Intent intent) {
16-
17-
if("android.intent.action.ACTION_SHUTDOWN".equals(intent.getAction())) {
17+
18+
if(Intent.ACTION_SHUTDOWN.equals(intent.getAction())) {
1819
pwe.onShutdown();
1920
}
2021

0 commit comments

Comments
 (0)