Skip to content

Commit

Permalink
added delete screen
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoh12 committed Apr 21, 2016
1 parent 69da64a commit 64939ed
Showing 10 changed files with 185 additions and 28 deletions.
2 changes: 1 addition & 1 deletion PensieveSkeleton/.idea/misc.xml

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

5 changes: 4 additions & 1 deletion PensieveSkeleton/mobile/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -33,8 +33,11 @@
<activity android:name=".Settings"/>
<activity android:name=".OverviewGraph"/>

<activity android:name=".Notification"/>
<activity android:name=".Notification">
</activity>

<activity android:name=".NotificationResolved"/>
<activity android:name=".DeleteTask" />


<service android:name=".PhoneToWatchService" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.gseyf.pensieveskeleton;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

/**
* Created by david on 4/20/16.
*/
public class DeleteTask extends Activity {
private String TAG = "@>@>@>";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.family_member_delete_action_activity);
}

public void goBack(View view){
Intent i = new Intent(DeleteTask.this, FamilyMemberMainActivity.class);
startActivity(i);
}
}
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
@@ -15,11 +16,11 @@
*/
public class FamilyMemberMainActivity extends Activity {
//Timer timer = new Timer();
private String TAG = "@>@>@>";

@Override
public void onCreate(Bundle b) {
super.onCreate(b);

setContentView(R.layout.family_member_main_activity);

TextView txtView = (TextView) findViewById(R.id.familymemberbreakfast);
@@ -41,6 +42,21 @@ public void onClick(View v) {
}
});


TextView parag = (TextView) findViewById(R.id.delete);
parag.setOnTouchListener(new OnSwipeTouchListener(getBaseContext()) {
@Override
public void onSwipeRight() {
super.onSwipeRight();
Toast.makeText(FamilyMemberMainActivity.this, "right", Toast.LENGTH_SHORT).show();

Intent intent = new Intent(FamilyMemberMainActivity.this, DeleteTask.class);
startActivity(intent);
Log.d(TAG, "swipe right");
}

});

}

public void onStartFamilyMemberAddTaskActivity(View view) {
Original file line number Diff line number Diff line change
@@ -3,17 +3,20 @@
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

/**
* Created by david on 4/20/16.
*/
public class Notification extends Activity {
private String TAG = "@>@>@>";

@Override
public void onCreate(Bundle b) {
super.onCreate(b);
setContentView(R.layout.family_member_notification_activity);
Log.d(TAG, "notification created");
}

public void hesOk(View view){
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.example.gseyf.pensieveskeleton;

/**
* Created by david on 4/19/16.
*/

import android.content.Context;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;

public class OnSwipeTouchListener implements OnTouchListener {

private final GestureDetector gestureDetector;

public OnSwipeTouchListener(Context ctx){
gestureDetector = new GestureDetector(ctx, new GestureListener());
}

@Override
public boolean onTouch(View v, MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}

private final class GestureListener extends SimpleOnGestureListener {

private static final int SWIPE_THRESHOLD = 100;
private static final int SWIPE_VELOCITY_THRESHOLD = 100;

@Override
public boolean onDown(MotionEvent e) {
return true;
}

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
boolean result = false;
try {
float diffY = e2.getY() - e1.getY();
float diffX = e2.getX() - e1.getX();
if (Math.abs(diffX) > Math.abs(diffY)) {
if (Math.abs(diffX) > SWIPE_THRESHOLD && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
if (diffX > 0) {
onSwipeRight();
} else {
onSwipeLeft();
}
}
result = true;
}
else if (Math.abs(diffY) > SWIPE_THRESHOLD && Math.abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) {
if (diffY > 0) {
onSwipeBottom();
} else {
onSwipeTop();
}
}
result = true;

} catch (Exception exception) {
exception.printStackTrace();
}
return result;
}
}

public void onSwipeRight() {
}

public void onSwipeLeft() {
}

public void onSwipeTop() {
}

public void onSwipeBottom() {
}
}
Original file line number Diff line number Diff line change
@@ -6,4 +6,11 @@
android:background="@drawable/family_member_delete_action"
>

<TextView
android:onClick="goBack"
android:id="@+id/trashcan"
android:layout_marginTop="80dp"
android:layout_width="80dp"
android:layout_height="80dp"/>

</RelativeLayout>
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@
android:id="@+id/familymemberbreakfast"
android:layout_width="match_parent"
android:layout_height="91dp"
android:background="#00ffffff"
android:layout_below="@+id/plusbutton"
android:layout_alignParentStart="true"/>

@@ -32,5 +31,12 @@
android:layout_alignParentRight="true"
android:onClick="onClickSettings"/>

<TextView
android:id="@+id/delete"
android:layout_width="match_parent"
android:layout_height="91dp"
android:layout_below="@+id/plusbutton"
android:layout_alignParentStart="true"/>


</RelativeLayout>
3 changes: 2 additions & 1 deletion PensieveSkeleton/wear/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -25,7 +25,8 @@
</activity>

<activity android:name=".MainWatchScreen" />
<activity android:name=".cantRemember" />
<activity android:name=".cantRemember" >
</activity>
<activity android:name=".Confirmation" />
<activity android:name=".yes" />

Original file line number Diff line number Diff line change
@@ -24,30 +24,30 @@ public class WatchToPhoneService extends Service {
private String status;

private static final String TAG = "@>@>@>@>";
private GoogleApiClient mWatchApiClient;
// private GoogleApiClient mWatchApiClient;
final Service _this = this;

@Override
public void onCreate() {
super.onCreate();
mWatchApiClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(Bundle connectionHint) {
}

@Override
public void onConnectionSuspended(int cause) {
}
}).build();
// mWatchApiClient = new GoogleApiClient.Builder(this)
// .addApi(Wearable.API)
// .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
// @Override
// public void onConnected(Bundle connectionHint) {
// }
//
// @Override
// public void onConnectionSuspended(int cause) {
// }
// }).build();
Log.d(TAG, "in watch to phone");
}

@Override
public void onDestroy() {
super.onDestroy();
mWatchApiClient.disconnect();
// mWatchApiClient.disconnect();
}

@Override
@@ -56,44 +56,59 @@ public int onStartCommand(Intent intent, int flags, int startId) {

Log.d(TAG, "WtoP: on start command");

status = extras.getString("status");
Log.d(TAG, status);
this.status = extras.getString("status");

Log.d(TAG, this.status);

new Thread(new Runnable() {
@Override
public void run() {
mWatchApiClient.connect();
if(status.equals("needHelp")){
sendMessage("/need_help", status);
WatchToPhoneService service = new WatchToPhoneService();
service.sendMessage("/need_help", status);
Log.d(TAG, "sent need Help");
} else {
sendMessage("/good", status);
WatchToPhoneService service = new WatchToPhoneService();
service.sendMessage("/good", status);
Log.d(TAG, "sent good");
}

Log.wtf(TAG, "sent");
}
}).start();


return START_STICKY;
}


@Override
public IBinder onBind(Intent intent) { return null; }

private void sendMessage(final String path, final String text){
public void sendMessage(final String path, final String text){
Log.d(TAG, "Sending...");

final GoogleApiClient mWatchApiClient = new GoogleApiClient.Builder(this.getBaseContext())
.addApi(Wearable.API)
.addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(Bundle connectionHint) {
}

@Override
public void onConnectionSuspended(int cause) {
}
}).build();

new Thread(new Runnable() {
@Override
public void run() {

NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(mWatchApiClient).await();
Log.d(TAG, "nodes " + nodes.toString());
for (Node node : nodes.getNodes()) {
MessageApi.SendMessageResult result = Wearable.MessageApi.sendMessage(
mWatchApiClient, node.getId(), path, text.getBytes()).await();
Log.d(TAG, "result " + result.toString());
}
}
}).start();
}

}

0 comments on commit 64939ed

Please sign in to comment.