Skip to content

Commit

Permalink
Adding the new saving method. 60% done :)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddmanfire committed Sep 1, 2015
1 parent beb9901 commit dc2e199
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
<orderEntry type="library" exported="" name="aspectjrt-1.8.2" level="project" />
<orderEntry type="library" exported="" name="library-2.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.1" level="project" />
<orderEntry type="library" exported="" name="isoparser-1.0.5.4" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.1" level="project" />
<orderEntry type="library" exported="" name="isoparser-1.0.5.4" level="project" />
<orderEntry type="library" exported="" name="play-services-maps-7.8.0" level="project" />
<orderEntry type="library" exported="" name="play-services-base-7.8.0" level="project" />
<orderEntry type="library" exported="" name="XposedBridgeApi-54" level="project" />
Expand Down
32 changes: 31 additions & 1 deletion app/src/main/java/com/marz/snapprefs/Saving.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;

Expand All @@ -49,7 +50,10 @@ public class Saving {
public static final int SAVE_S2S = 1;
public static final int DO_NOT_SAVE = 2;

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

// Length of toasts
public static final int TOAST_LENGTH_SHORT = 0;
Expand Down Expand Up @@ -88,6 +92,19 @@ public class Saving {
private static GestureModel gestureModel;
private static int screenHeight;


static void newSaveMethod(FileInputStream mVideo, Bitmap mImage, boolean isOverlay){
if(mVideo == null && mImage == null) {
Logger.log("Skipping null");
}else{
currentSavingSnap++;
if (mImage == null)
snapsMap.put(currentSavingSnap, new Snap(mVideo));
if (mVideo == null)
snapsMap.put(currentSavingSnap, new Snap(mImage, isOverlay));
}
}

static void initSaving(final XC_LoadPackage.LoadPackageParam lpparam, final XModuleResources modRes, final Context snapContext) {
mResources = modRes;
if (mSCResources == null) mSCResources = snapContext.getResources();
Expand All @@ -104,6 +121,9 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
mVideo = new FileInputStream(param.args[0].toString());
Logger.log(param.args[0].toString(), true);

newSaveMethod(mVideo, null, false);

//Logger.log("It is a Video", true);
saveReceivedSnap(snapContext, receivedSnap, MediaType.VIDEO);
//mVideo = null;
Expand All @@ -125,6 +145,9 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {

if (((BitmapDrawable) param.args[0]).getBitmap() == null) return;
mImage = ((BitmapDrawable) param.args[0]).getBitmap();

newSaveMethod(null, mImage, false);

//Logger.log("It is a Bitmap", true);
saveReceivedSnap(snapContext, receivedSnap, MediaType.IMAGE);
} catch (NullPointerException | Resources.NotFoundException ignore) {
Expand All @@ -143,6 +166,9 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {

if (((BitmapDrawable) param.args[0]).getBitmap() == null) return;
mImage = ((BitmapDrawable) param.args[0]).getBitmap();

newSaveMethod(null, mImage, true);

//Logger.log("It is a Bitmap", true);
saveReceivedSnap(snapContext, receivedSnap, MediaType.IMAGE_OVERLAY);
} catch (NullPointerException | Resources.NotFoundException ignore) {
Expand All @@ -160,6 +186,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
viewingSnap = true;
currentViewingSnap++;
Logger.log("Starting to view a snap, plus viewingSnap: " + viewingSnap, true);
}
});
Expand Down Expand Up @@ -192,6 +219,7 @@ 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);
}
}
Expand Down Expand Up @@ -349,6 +377,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
//Logger.log("Stopped viewing the Snap", true);
viewingSnap = false;

//TODO clear maps & values
}
});
/**
Expand Down
40 changes: 40 additions & 0 deletions app/src/main/java/com/marz/snapprefs/Snap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.marz.snapprefs;

import android.graphics.Bitmap;

import java.io.FileInputStream;

/**
* Created by 723183 on 9/1/2015.
*/
public class Snap {
public Bitmap img;
public FileInputStream vid;
public Saving.MediaType mediaType;


public Snap (Bitmap b, boolean overlay) {
img = b;
if(overlay)
mediaType = Saving.MediaType.IMAGE_OVERLAY;
else
mediaType = Saving.MediaType.IMAGE;
}

public Snap (FileInputStream fis) {
vid = fis;
mediaType = Saving.MediaType.VIDEO;
}

public Bitmap getImage() {
return img;
}

public FileInputStream getVideo() {
return vid;
}

public Saving.MediaType getMediaType() {
return mediaType;
}
}
2 changes: 1 addition & 1 deletion 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:08:47 CDT 2015
#Tue Sep 01 12:13:33 CDT 2015
sdk.dir=C\:\\Users\\723183\\AppData\\Local\\Android\\sdk

0 comments on commit dc2e199

Please sign in to comment.