Skip to content

Commit

Permalink
New saving method added!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
ddmanfire committed Sep 2, 2015
1 parent dc2e199 commit 03fa878
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 18 deletions.
58 changes: 42 additions & 16 deletions app/src/main/java/com/marz/snapprefs/Saving.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public class Saving {

//New Array Saving Method (ddmanfire)
public static LinkedHashMap<Integer, Snap> snapsMap = new LinkedHashMap<>();
public static int currentViewingSnap = 0;
public static int currentSavingSnap = 0;
public static int currentViewingSnap = -1;
public static int currentSavingSnap = -1;

// Length of toasts
public static final int TOAST_LENGTH_SHORT = 0;
Expand Down Expand Up @@ -100,11 +100,27 @@ static void newSaveMethod(FileInputStream mVideo, Bitmap mImage, boolean isOverl
currentSavingSnap++;
if (mImage == null)
snapsMap.put(currentSavingSnap, new Snap(mVideo));
if (mVideo == null)
else if (mVideo == null)
snapsMap.put(currentSavingSnap, new Snap(mImage, isOverlay));
Logger.log("Added To HashMap!");
}
}

static void newSaveMethod2(Context snapContext){
Snap toSave = snapsMap.get(currentViewingSnap);
if(toSave.getMediaType() == MediaType.IMAGE){
mImage = toSave.getImage();
saveReceivedSnap(snapContext, receivedSnap, MediaType.GESTUREDIMAGE);
}else if(toSave.getMediaType() == MediaType.VIDEO){
mVideo = toSave.getVideo();
saveReceivedSnap(snapContext, receivedSnap, MediaType.GESTUREDVIDEO);
}else if(toSave.getMediaType() == MediaType.IMAGE_OVERLAY){
mImage = toSave.getImage();
saveReceivedSnap(snapContext, receivedSnap, MediaType.GESTUREDOVERLAY);
}
Logger.log("Saving Done!");
}

static void initSaving(final XC_LoadPackage.LoadPackageParam lpparam, final XModuleResources modRes, final Context snapContext) {
mResources = modRes;
if (mSCResources == null) mSCResources = snapContext.getResources();
Expand Down Expand Up @@ -219,8 +235,9 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// Meaning it's at least 70% back to the start point and the gesture was longer then 20% of the screen
if ((currentDistance < (gestureModel.getDistance() * 0.3)) && (gestureModel.getDistance() > (gestureModel.getDisplayHeight() * 0.2))) {
gestureModel.setSaved();
//TODO add new saving method
saveReceivedSnap(snapContext, gestureModel.getReceivedSnap(), gestureModel.mediaType);
//TODO add new saving method (also added image overlay saving to S2S)
newSaveMethod2(snapContext);
//saveReceivedSnap(snapContext, gestureModel.getReceivedSnap(), gestureModel.mediaType);
}
}
}
Expand Down Expand Up @@ -379,6 +396,9 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
viewingSnap = false;

//TODO clear maps & values
snapsMap.clear();
currentSavingSnap = -1;
currentViewingSnap = -1;
}
});
/**
Expand Down Expand Up @@ -440,9 +460,9 @@ private static void saveReceivedSnap(Context context, Object receivedSnap, Media
setAdditionalInstanceField(receivedSnap, "snap_media_type", MediaType.VIDEO);
Logger.log("Video " + snapType.name + " opened");
int saveMode = (snapType == SnapType.SNAP ? mModeSnapVideo : mModeStoryVideo);
if (saveMode == SAVE_S2S) {
saveMode = SAVE_AUTO;
}
//if (saveMode == SAVE_S2S) {
// saveMode = SAVE_AUTO;
//}
if (saveMode == DO_NOT_SAVE) {
Logger.log("Mode: don't save");
} else if (saveMode == SAVE_S2S) {
Expand All @@ -459,9 +479,9 @@ private static void saveReceivedSnap(Context context, Object receivedSnap, Media
setAdditionalInstanceField(receivedSnap, "snap_media_type", MediaType.IMAGE);
Logger.log("Image " + snapType.name + " opened");
int saveMode = (snapType == SnapType.SNAP ? mModeSnapImage : mModeStoryImage);
if (saveMode == SAVE_S2S) {
saveMode = SAVE_AUTO;
}
//if (saveMode == SAVE_S2S) {
// saveMode = SAVE_AUTO;
//}
if (saveMode == DO_NOT_SAVE) {
Logger.log("Mode: don't save");
} else if (saveMode == SAVE_S2S) {
Expand All @@ -476,12 +496,12 @@ private static void saveReceivedSnap(Context context, Object receivedSnap, Media
}
case IMAGE_OVERLAY: {
int saveMode = (snapType == SnapType.SNAP ? mModeSnapVideo : mModeStoryVideo);
if (saveMode == SAVE_S2S) {
saveMode = SAVE_AUTO;
}
//if (saveMode == SAVE_S2S) {
// saveMode = SAVE_AUTO;
//}
if (saveMode == DO_NOT_SAVE) {
} else if (saveMode == SAVE_S2S) {
gestureModel = new GestureModel(receivedSnap, screenHeight, MediaType.GESTUREDVIDEO);
gestureModel = new GestureModel(receivedSnap, screenHeight, MediaType.GESTUREDOVERLAY);
} else {
gestureModel = null;
saveSnap(snapType, MediaType.IMAGE_OVERLAY, context, image, video, filename, sender);
Expand All @@ -498,6 +518,11 @@ private static void saveReceivedSnap(Context context, Object receivedSnap, Media
saveSnap(snapType, MediaType.VIDEO, context, image, video, filename, sender);
break;
}
case GESTUREDOVERLAY: {
Logger.log("GESTUREDOVERLAY is coming", true);
saveSnap(snapType, MediaType.IMAGE_OVERLAY, context, image, video, filename, sender);
break;
}
default: {
Logger.log("Unknown MediaType");
}
Expand Down Expand Up @@ -705,7 +730,8 @@ public enum MediaType {
IMAGE_OVERLAY(".png"),
VIDEO(".mp4"),
GESTUREDIMAGE(".png"),
GESTUREDVIDEO(".mp4");
GESTUREDVIDEO(".mp4"),
GESTUREDOVERLAY(".png");

private final String fileExtension;

Expand Down
4 changes: 2 additions & 2 deletions local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Tue Sep 01 12:13:33 CDT 2015
sdk.dir=C\:\\Users\\723183\\AppData\\Local\\Android\\sdk
#Tue Sep 01 20:48:18 CDT 2015
sdk.dir=C\:\\Users\\Dalton\\AppData\\Local\\Android\\sdk1

0 comments on commit 03fa878

Please sign in to comment.