Skip to content

Commit

Permalink
moved constants and strings to new library project, added swipe to ch…
Browse files Browse the repository at this point in the history
…ange picture preview
  • Loading branch information
grubFX committed Jun 19, 2015
1 parent c0317f0 commit 537a771
Show file tree
Hide file tree
Showing 24 changed files with 249 additions and 271 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ android {
}

dependencies {
compile project(':mylibrary')
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.google.android.gms:play-services-ads:7.3.0'
compile 'com.google.android.support:wearable:+'
Expand Down
9 changes: 4 additions & 5 deletions mobile/mobile.iml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/mediarouter-v7/22.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/22.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/7.5.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-analytics/7.5.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-appindexing/7.5.0/jars" />
Expand Down Expand Up @@ -114,16 +112,16 @@
</content>
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="appcompat-v7-22.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-wallet-7.5.0" level="project" />
<orderEntry type="library" exported="" name="play-services-cast-7.5.0" level="project" />
<orderEntry type="library" exported="" name="mediarouter-v7-22.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-drive-7.5.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
<orderEntry type="library" exported="" name="play-services-analytics-7.5.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-22.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-panorama-7.5.0" level="project" />
<orderEntry type="library" exported="" name="play-services-appindexing-7.5.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.0.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="play-services-location-7.5.0" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-7.5.0" level="project" />
<orderEntry type="library" exported="" name="play-services-safetynet-7.5.0" level="project" />
Expand All @@ -132,7 +130,7 @@
<orderEntry type="library" exported="" name="play-services-gcm-7.5.0" level="project" />
<orderEntry type="library" exported="" name="wearable-1.2.0" level="project" />
<orderEntry type="library" exported="" name="play-services-appinvite-7.5.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" name="play-services-fitness-7.5.0" level="project" />
<orderEntry type="library" exported="" name="play-services-nearby-7.5.0" level="project" />
<orderEntry type="library" exported="" name="play-services-plus-7.5.0" level="project" />
Expand All @@ -141,5 +139,6 @@
<orderEntry type="library" exported="" name="play-services-games-7.5.0" level="project" />
<orderEntry type="library" exported="" name="play-services-identity-7.5.0" level="project" />
<orderEntry type="library" exported="" name="play-services-maps-7.5.0" level="project" />
<orderEntry type="module" module-name="mylibrary" exported="" />
</component>
</module>
60 changes: 29 additions & 31 deletions mobile/src/main/java/mc/fhooe/at/wearcam/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
public class MainActivity extends Activity implements DataApi.DataListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, Camera.PreviewCallback, MessageListener, NodeApi.NodeListener, SurfaceHolder.Callback, Camera.PictureCallback, Camera.ShutterCallback, View.OnTouchListener {
private GoogleApiClient mGoogleApiClient;
private String TAG = "PhoneTag", path = null;
public static final String PHOTO_ALBUM = "wearcam";
private int currentCameraId = Camera.CameraInfo.CAMERA_FACING_BACK, index, angleRotateMatrix, anglePreview;
private static final int REQUEST_RESOLVE_ERROR = 1001, IMG_SIZE = 200, QUALITY_IN_PERCENT = 20;
private Camera cam;
Expand All @@ -76,17 +75,14 @@ public class MainActivity extends Activity implements DataApi.DataListener, Goog
private float mDist;
private Vector<Node> mNodeList;
private OrientationEventListener mOrientationEventListener;
private Utils utils;
private ArrayList<String> imagePaths = new ArrayList<String>();

//----------------------------------------------------
// SD card image directory

public static final String PHOTO_ALBUM = "wearcam";
// supported file formats
public static final List<String> FILE_EXTN = Arrays.asList("jpg", "jpeg", "png");

private Utils utils;
private ArrayList<String> imagePaths = new ArrayList<String>();


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -111,15 +107,19 @@ protected void onCreate(Bundle savedInstanceState) {
pictureButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
takePicture();
if (!isGalleryModeOn) {
takePicture();
}
}
});

videoButton = (ImageButton) findViewById(R.id.videoButton);
videoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
takeVideo();
if (!isGalleryModeOn) {
takeVideo();
}
}
});

Expand Down Expand Up @@ -341,7 +341,7 @@ protected void onStart() {
mGoogleApiClient.connect();
Log.d(TAG, "connedted, jippieeeeeeee!!!!! ");
}
Uri uri = new Uri.Builder().scheme(PutDataRequest.WEAR_URI_SCHEME).path("/image").build();
Uri uri = new Uri.Builder().scheme(PutDataRequest.WEAR_URI_SCHEME).path(MyConstants.PATH_IMAGE).build();
Wearable.DataApi.deleteDataItems(mGoogleApiClient, uri).setResultCallback(new ResultCallback<DataApi.DeleteDataItemsResult>() {
@Override
public void onResult(DataApi.DeleteDataItemsResult deleteDataItemsResult) {
Expand Down Expand Up @@ -389,8 +389,6 @@ public void onOrientationChanged(int _rot) {
if (mOrientationEventListener.canDetectOrientation()) {
mOrientationEventListener.enable();
}


}

@Override
Expand Down Expand Up @@ -464,9 +462,9 @@ public void onPreviewFrame(byte[] data, Camera camera) {
}
}
if (asset != null) {
PutDataMapRequest dataMap = PutDataMapRequest.create("/image");
dataMap.getDataMap().putLong("timestamp", System.currentTimeMillis());
dataMap.getDataMap().putAsset("img", asset);
PutDataMapRequest dataMap = PutDataMapRequest.create(MyConstants.PATH_IMAGE);
dataMap.getDataMap().putLong(MyConstants.DATA_ITEM_TIMESTAMP, System.currentTimeMillis());
dataMap.getDataMap().putAsset(MyConstants.DATA_ITEM_IMAGE, asset);
PutDataRequest request = dataMap.asPutDataRequest();

PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi
Expand All @@ -485,49 +483,49 @@ public void onResult(DataApi.DataItemResult dataItemResult) {
public void onMessageReceived(MessageEvent messageEvent) {
final String temp = messageEvent.getPath();

Log.d("LOG", "received path: " + temp);
Log.d(TAG, "received path: " + temp);

if (temp.equals("/cam")) {
if (temp.equals(MyConstants.PATH_CAM)) {
isGalleryModeOn = false;
changeView();

} else if (temp.equals("/gallery")) {
} else if (temp.equals(MyConstants.PATH_GALLERY)) {
isGalleryModeOn = true;
changeView();
sendStoredImageToPhone(index);
} else if (temp.equals("/stop")) {
} else if (temp.equals(MyConstants.PATH_STOP)) {
finish();
} else if (temp.equals("/takePic")) {
} else if (temp.equals(MyConstants.PATH_TAKE_PIC)) {
runOnUiThread(new Runnable() {
@Override
public void run() {
takePicture();
}
});
} else if (temp.equals("/flash")) {
} else if (temp.equals(MyConstants.PATH_FLASH)) {
runOnUiThread(new Runnable() {
@Override
public void run() {
flashLightAction();
}
});
} else if (temp.equals("/changeCam")) {
} else if (temp.equals(MyConstants.PATH_CHANGE_CAM)) {
runOnUiThread(new Runnable() {
@Override
public void run() {
changeCamera();
}
});
} else if (temp.equals("/takeVid")) {
} else if (temp.equals(MyConstants.PATH_TAKE_VID)) {
runOnUiThread(new Runnable() {
@Override
public void run() {
takeVideo();
}
});
} else if (temp.equals("/nextPic")) {
} else if (temp.equals(MyConstants.PATH_NEXT_PIC)) {
sendStoredImageToPhone((++index) % imagePaths.size());
} else if (temp.equals("/prevPic")) {
} else if (temp.equals(MyConstants.PATH_PREV_PIC)) {
sendStoredImageToPhone((--index) % imagePaths.size());
}
runOnUiThread(new Runnable() {
Expand All @@ -545,9 +543,9 @@ private void sendStoredImageToPhone(int _index) {
Bitmap bitmap = BitmapFactory.decodeFile(imagePaths.get(_index), options);
Bitmap resizedBitmap = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth() / 2, bitmap.getHeight() / 2, true);
Asset asset = createAssetFromBitmap(resizedBitmap);
PutDataMapRequest dataMap = PutDataMapRequest.create("/galleryimage");
dataMap.getDataMap().putAsset("img", asset);
dataMap.getDataMap().putLong("timestamp", System.currentTimeMillis());
PutDataMapRequest dataMap = PutDataMapRequest.create(MyConstants.PATH_GALLERY_IMAGE);
dataMap.getDataMap().putAsset(MyConstants.DATA_ITEM_IMAGE, asset);
dataMap.getDataMap().putLong(MyConstants.DATA_ITEM_TIMESTAMP, System.currentTimeMillis());
PutDataRequest request = dataMap.asPutDataRequest();

PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi
Expand Down Expand Up @@ -684,7 +682,9 @@ private void handleZoom(MotionEvent event, Camera.Parameters params) {
}
mDist = newDist;
params.setZoom(zoom);
cam.setParameters(params);
if (cam != null) {
cam.setParameters(params);
}
}

public void handleFocus(MotionEvent event, Camera.Parameters params) {
Expand Down Expand Up @@ -810,9 +810,7 @@ public void surfaceDestroyed(SurfaceHolder holder) {

@Override
public void onPictureTaken(byte[] data, Camera camera) {

if (data != null) {

int angleToRotate = getRoatationAngle(MainActivity.this, currentCameraId);
Bitmap orignalImage = BitmapFactory.decodeByteArray(data, 0, data.length);
// TODO: front camera portrait picture is reverted
Expand Down
4 changes: 1 addition & 3 deletions mobile/src/main/java/mc/fhooe/at/wearcam/MobileListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ public void onMessageReceived(MessageEvent messageEvent) {
super.onMessageReceived(messageEvent);
Log.d(TAG, "onMessageReceived: " + messageEvent.getPath());

if (messageEvent.getPath().equals("/start")) {
if (messageEvent.getPath().equals(MyConstants.PATH_START)) {
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
} else if (messageEvent.getPath().equals("/stop")) {

}
}
}
1 change: 1 addition & 0 deletions mylibrary/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
24 changes: 24 additions & 0 deletions mylibrary/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"

defaultConfig {
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
}
Loading

0 comments on commit 537a771

Please sign in to comment.