Skip to content

Commit

Permalink
Merge pull request #3 from Northshoot/issiue#1
Browse files Browse the repository at this point in the history
fixed
  • Loading branch information
Northshoot committed Oct 15, 2014
2 parents aabc872 + 15bd38c commit cda11dc
Show file tree
Hide file tree
Showing 19 changed files with 108 additions and 145 deletions.
Binary file modified bin/HelenaShow.apk
Binary file not shown.
Binary file modified bin/classes.dex
Binary file not shown.
Binary file modified bin/resources.ap_
Binary file not shown.
32 changes: 18 additions & 14 deletions gen/edu/stanford/cs/sing/helena/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,23 @@ public static final class drawable {
public static final class id {
public static final int connection_state=0x7f080001;
public static final int device_address=0x7f080000;
public static final int device_name=0x7f080008;
public static final int fire_adress=0x7f080003;
public static final int fire_list=0x7f080002;
public static final int fire_number=0x7f080004;
public static final int last_seen=0x7f080009;
public static final int last_updated=0x7f080005;
public static final int menu_connect=0x7f08000c;
public static final int menu_disconnect=0x7f08000d;
public static final int menu_refresh=0x7f08000b;
public static final int menu_scan=0x7f08000e;
public static final int menu_stop=0x7f08000f;
public static final int observ_time=0x7f080007;
public static final int observation_list=0x7f08000a;
public static final int observed_addr=0x7f080006;
public static final int device_name=0x7f08000b;
public static final int fire_adress=0x7f080006;
public static final int fire_list=0x7f080005;
public static final int fire_number=0x7f080007;
public static final int header_columt_1=0x7f080002;
public static final int header_columt_2=0x7f080003;
public static final int header_columt_3=0x7f080004;
public static final int last_seen=0x7f08000c;
public static final int last_updated=0x7f080008;
public static final int menu_connect=0x7f08000f;
public static final int menu_disconnect=0x7f080010;
public static final int menu_refresh=0x7f08000e;
public static final int menu_scan=0x7f080011;
public static final int menu_stop=0x7f080012;
public static final int observ_time=0x7f08000a;
public static final int observation_list=0x7f08000d;
public static final int observed_addr=0x7f080009;
}
public static final class layout {
public static final int actionbar_indeterminate_progress=0x7f030000;
Expand All @@ -69,6 +72,7 @@ public static final class string {
public static final int ble_not_supported=0x7f050002;
public static final int connected=0x7f050007;
public static final int disconnected=0x7f050008;
public static final int empty=0x7f050017;
public static final int error_bluetooth_not_supported=0x7f05000a;
public static final int label_data=0x7f050003;
public static final int label_device_address=0x7f050004;
Expand Down
9 changes: 6 additions & 3 deletions res/layout/device_control_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,32 @@
android:layout_height="wrap_content" >

<TextView
android:id="@+id/header_columt_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/addr"

android:textColor="@color/brown"
android:textSize="18sp" />

<Space android:layout_width="120dp"
android:layout_height="wrap_content"/>

<TextView
android:id="@+id/header_columt_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/number"

android:textColor="@color/green"
android:textSize="18sp" />

<Space android:layout_width="20dp"
android:layout_height="wrap_content"/>

<TextView
android:id="@+id/header_columt_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_last_seen"

android:textColor="@color/blue3"
android:textSize="18sp" />
</LinearLayout>
Expand Down
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<string name="observed_device">Observed device</string>

<string name="observation_time">Observation time</string>
<string name="empty"></string>


</resources>
15 changes: 15 additions & 0 deletions src/edu/stanford/cs/sing/common/helper/TimeWorks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package edu.stanford.cs.sing.common.helper;

import java.sql.Timestamp;

import android.text.format.Time;

public class TimeWorks {

public static String timestampToString(Timestamp timestamp , String format) {
Time today = new Time(Time.getCurrentTimezone());
today.set(timestamp.getTime());
return today.format(format);
}

}
89 changes: 55 additions & 34 deletions src/edu/stanford/cs/sing/helena/DeviceControlActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@

package edu.stanford.cs.sing.helena;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.squareup.otto.Bus;

import android.app.Activity;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattService;
Expand All @@ -33,7 +29,6 @@
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcelable;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -48,7 +43,6 @@
import edu.stanford.cs.sing.helena.nodes.FireAdapter;
import edu.stanford.cs.sing.helena.nodes.FireArray;
import edu.stanford.cs.sing.helena.nodes.ObservAdapter;
import edu.stanford.cs.sing.helena.nodes.ObserverActivity;



Expand Down Expand Up @@ -80,7 +74,7 @@ public class DeviceControlActivity extends Activity {
public FireArray mFirestormArray;
private FireAdapter mFireAdapter;
private ObservAdapter mObserverAdapter;

private boolean mFireLitDisplay;

// Code to manage Service lifecycle.
private final ServiceConnection mServiceConnection = new ServiceConnection() {
Expand Down Expand Up @@ -133,6 +127,8 @@ public void onReceive(Context context, Intent intent) {
}
};

private OnItemClickListener mFireListOnClickListner;



private void dealWithData(byte[] data){
Expand All @@ -154,51 +150,76 @@ private void clearUI() {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mFireLitDisplay = false;
mFirestormArray = new FireArray();
mFireListOnClickListner= new FireListOnClickListner();
setContentView(R.layout.device_control_activity);

//
final Intent intent = getIntent();
mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);
Log.d(TAG, "Connected to " + mDeviceAddress );
Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
getActionBar().setTitle(mDeviceName);
getActionBar().setDisplayHomeAsUpEnabled(true);
((TextView) findViewById(R.id.device_address)).setText(mDeviceAddress);

//mGattServicesList.setOnChildClickListener(servicesListClickListner);
mConnectionState = (TextView) findViewById(R.id.connection_state);
Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
addList();
// Create the adapter to convert the array to views
mFireAdapter = new FireAdapter(this, mFirestormArray);
addFireList();

Log.d(TAG, "onCreate bindService");
}

private void addList(){
// Create the adapter to convert the array to views
mFireAdapter = new FireAdapter(this, mFirestormArray);

// Attach the adapter to a ListView
ListView listView = (ListView) findViewById(R.id.fire_list);
listView.setAdapter(mFireAdapter);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
Log.d(TAG, "onClick " + position);
mObserverAdapter = new ObservAdapter(
view.getContext(), mFirestormArray.get(position).getObservationList());
ListView listView = (ListView) findViewById(R.id.fire_list);
listView.setAdapter(mObserverAdapter);
//Intent i = new Intent(DeviceControlActivity.this, ObserverActivity.class);
// //If you wanna send any data to nextActicity.class you can use
// i.putParcelableArrayListExtra("firestorm",
// (ArrayList<? extends Parcelable>) mFirestorsm.mArrayList.get(position).getObservationList());
//
// startActivity(i);
}
});

public void onBackPressed(){
Log.d(TAG,"OnBackPress");
if(mFireLitDisplay){
super.onBackPressed();
} else {
addFireList();
}
}

private void addDetailList(AdapterView<?> parent, View view, int position, long id){
mFireLitDisplay = false;
((TextView) findViewById(R.id.header_columt_1)).setText(R.string.addr);
((TextView) findViewById(R.id.header_columt_2)).setText(R.string.label_last_seen);
((TextView) findViewById(R.id.header_columt_3)).setText(R.string.empty);
mObserverAdapter = new ObservAdapter(
view.getContext(), mFirestormArray.get(position).getObservationList());
ListView listView = (ListView) findViewById(R.id.fire_list);
listView.setAdapter(mObserverAdapter);

}

class FireListOnClickListner implements OnItemClickListener{

@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
addDetailList( parent, view, position, id);
Log.d(TAG, "onClick " + position);



}

}
private void addFireList(){
if(!mFireLitDisplay){
Log.d(TAG, "Connected to " + mDeviceAddress );
mFireLitDisplay = true;
((TextView) findViewById(R.id.header_columt_1)).setText(R.string.addr);
((TextView) findViewById(R.id.header_columt_2)).setText(R.string.number);
((TextView) findViewById(R.id.header_columt_3)).setText(R.string.label_last_seen);
// Attach the adapter to a ListView
ListView listView = (ListView) findViewById(R.id.fire_list);
listView.setAdapter(mFireAdapter);
listView.setOnItemClickListener(mFireListOnClickListner);
}
}

@Override
Expand Down
5 changes: 0 additions & 5 deletions src/edu/stanford/cs/sing/helena/ble/BleManager.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import android.os.IBinder;
import edu.stanford.cs.sing.common.logger.Log;
import edu.stanford.cs.sing.helena.BusProvider;
import edu.stanford.cs.sing.helena.NodeListUpdatedEvent;

/**
* @author lauril
Expand Down
9 changes: 2 additions & 7 deletions src/edu/stanford/cs/sing/helena/ble/DeviceScanActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package edu.stanford.cs.sing.helena.ble;

import java.util.ArrayList;

import android.app.Activity;
import android.app.ListActivity;
import android.bluetooth.BluetoothAdapter;
Expand All @@ -35,15 +37,8 @@
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;

import edu.stanford.cs.sing.helena.DeviceControlActivity;
import edu.stanford.cs.sing.helena.R;
import edu.stanford.cs.sing.helena.R.id;
import edu.stanford.cs.sing.helena.R.layout;
import edu.stanford.cs.sing.helena.R.menu;
import edu.stanford.cs.sing.helena.R.string;

/**
* Activity for scanning and displaying available Bluetooth LE devices.
Expand Down
60 changes: 0 additions & 60 deletions src/edu/stanford/cs/sing/helena/nodes/CopyOfObservAdapter.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/edu/stanford/cs/sing/helena/nodes/FireAdapter.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package edu.stanford.cs.sing.helena.nodes;

import edu.stanford.cs.sing.helena.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import edu.stanford.cs.sing.helena.R;

public class FireAdapter extends ArrayAdapter<Firestorm> {
// View lookup cache
Expand Down
1 change: 0 additions & 1 deletion src/edu/stanford/cs/sing/helena/nodes/FireArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.io.Serializable;
import java.util.ArrayList;


import android.support.v4.util.ArrayMap;


Expand Down
3 changes: 1 addition & 2 deletions src/edu/stanford/cs/sing/helena/nodes/Firestorm.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package edu.stanford.cs.sing.helena.nodes;

import java.sql.Timestamp;
import java.util.ArrayList;


import android.support.v4.util.ArrayMap;
import android.text.format.Time;
Expand Down Expand Up @@ -32,6 +30,7 @@ private String getTimeNow(){
today.setToNow();
return today.format("%k:%M:%S");
}

public void addObservation(Observation observed) {
mObservedDevices.put(new Timestamp(System.currentTimeMillis()), observed);
mObservationArray.add(observed);
Expand Down
Loading

0 comments on commit cda11dc

Please sign in to comment.