Browse Source

improved bluetooth sync UI and fixed some sync bugs

Alexander Brakowski 9 years ago
parent
commit
4383433779

+ 3 - 3
AndroidManifest.xml

@@ -66,12 +66,12 @@
         <activity
             android:name=".sync.tracing.TracingSyncActivity"
             android:label="@string/gui_tracing"
-            android:theme="@android:style/Theme.Dialog" >
+            android:theme="@android:style/Theme.Holo.Dialog" >
         </activity>
         <activity
             android:name=".sync.bluetooth.BluetoothSyncActivity"
             android:label="@string/gui_bluetooth"
-            android:theme="@android:style/Theme.Dialog" >
+            android:theme="@android:style/Theme.Holo.Dialog" >
         </activity>
         <activity
             android:name=".sync.nfc.NFCSyncActivity"
@@ -115,7 +115,7 @@
             android:parentActivityName=".ui.activity.MainActivity" >
             <meta-data
                 android:name="android.support.PARENT_ACTIVITY"
-                android:value="de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity" />
+                android:value="de.tudarmstadt.informatik.hostage.ui.activity.MainActivity" />
         </activity>
     </application>
 

+ 26 - 7
res/layout/activity_bluetooth.xml

@@ -1,4 +1,4 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
@@ -9,17 +9,36 @@
     android:paddingTop="@dimen/activity_vertical_margin"
     android:id="@+id/bluetoothLayout" >
 
-    <TextView
-        android:id="@+id/bluetoothInfoText"
+    <ProgressBar
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        />
-    
+        android:id="@+id/bluetoothProgressBar"
+        android:layout_gravity="center_horizontal"
+        android:layout_centerVertical="true"
+        android:layout_centerHorizontal="true"
+        android:indeterminate="true"
+        android:indeterminateOnly="true"
+        android:textAlignment="center"
+        android:visibility="gone"
+        android:layout_marginBottom="10dp" />
+
     <ListView
         android:id="@+id/bluetoothListView"
         android:visibility="gone"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/bluetoothInfoText"
+        android:layout_centerHorizontal="true"
+        android:paddingTop="2dp" />
+
+    <TextView
+        android:id="@+id/bluetoothInfoText"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        />
+        android:gravity="center|top"
+        android:layout_below="@+id/bluetoothProgressBar"
+        android:layout_centerHorizontal="true"
+        android:layout_marginTop="10dp"
+        android:visibility="visible" />
 
-</LinearLayout>
+</RelativeLayout>

+ 1 - 1
src/de/tudarmstadt/informatik/hostage/persistence/HostageDBOpenHelper.java

@@ -1990,7 +1990,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
             String selectQuery = "SELECT * FROM " + AttackEntry.TABLE_NAME + " A "
                     + " WHERE "
                     +" ( "
-                    + " AND " + " A." + AttackEntry.COLUMN_NAME_DEVICE + " = " + "'" + deviceID + "'"
+                    + " A." + AttackEntry.COLUMN_NAME_DEVICE + " = " + "'" + deviceID + "'"
                     + " AND " + " A." + AttackEntry.COLUMN_NAME_SYNC_ID + " > " + maxID
                     + " ) "
                     //+ " GROUP BY " + AttackEntry.TABLE_NAME + "." + AttackEntry.COLUMN_NAME_DEVICE

+ 19 - 6
src/de/tudarmstadt/informatik/hostage/sync/bluetooth/BluetoothSyncActivity.java

@@ -17,6 +17,7 @@ import android.view.View;
 import android.widget.AdapterView;
 import android.widget.ArrayAdapter;
 import android.widget.ListView;
+import android.widget.ProgressBar;
 import android.widget.TextView;
 import android.widget.AdapterView.OnItemClickListener;
 import de.tudarmstadt.informatik.hostage.R;
@@ -34,8 +35,9 @@ public class BluetoothSyncActivity extends Activity{
 	public static final int CONNECTING = 0x0;
     public static final int CONNECTION_ESTABLISHED = 0x1;
     public static final int CONNECTION_FAILED = 0x2;
-    public static final int SYNC_SUCCESSFUL = 0x3;
-    public static final int SYNC_FAILED = 0x4;
+    public static final int SYNC_START = 0x3;
+    public static final int SYNC_SUCCESSFUL = 0x4;
+    public static final int SYNC_FAILED = 0x5;
     
     public static UUID serviceUUID;
 	
@@ -49,6 +51,7 @@ public class BluetoothSyncActivity extends Activity{
 	
 	private TextView mInfoText;
 	private ListView listView;
+    private ProgressBar progressBar;
 
 
 	@Override
@@ -213,6 +216,8 @@ public class BluetoothSyncActivity extends Activity{
 	 */
 	private void setLayoutElement(){
 		mInfoText = (TextView) findViewById(R.id.bluetoothInfoText);
+        progressBar = (ProgressBar) findViewById(R.id.bluetoothProgressBar);
+
 		listView = (ListView) findViewById(R.id.bluetoothListView);
 		listView.setAdapter(arrayAdapter);
 		listView.setOnItemClickListener(new OnItemClickListener() {
@@ -250,22 +255,30 @@ public class BluetoothSyncActivity extends Activity{
         	switch(msg.what){
         		case CONNECTING:       
         			listView.setVisibility(View.GONE);
-        			mInfoText.setText("Connecting to " + (String)msg.obj + "!");
+                    progressBar.setVisibility(View.VISIBLE);
+        			mInfoText.setText("Connecting to " + (String)msg.obj + "...");
         			break;
         		case CONNECTION_ESTABLISHED: 
         			BluetoothSocket socket = (BluetoothSocket) msg.obj;
         			manageConnectedSocket(socket);
         			break;
+                case SYNC_START:
+                    progressBar.setVisibility(View.VISIBLE);
+                    mInfoText.setText("Synchronizing data...");
+                    break;
         		case CONNECTION_FAILED: 
         			mInfoText.setText("Failed to connect to device!");
+                    progressBar.setVisibility(View.GONE);
         			break;
         		case SYNC_SUCCESSFUL: 
-        			mInfoText.setText("Synchronization successfull!");
-        			break;	
+        			mInfoText.setText("Synchronization successful!");
+                    progressBar.setVisibility(View.GONE);
+                    break;
         		case SYNC_FAILED: 
         			commThread.cancel();
         			mInfoText.setText("Synchronization failed!");
-        			break;	
+                    progressBar.setVisibility(View.GONE);
+                    break;
         	}        		
         }
 	};

+ 1 - 0
src/de/tudarmstadt/informatik/hostage/sync/bluetooth/CommunicationThread.java

@@ -99,6 +99,7 @@ public class CommunicationThread extends Thread {
 		Log.i("CommunicationThread", "Recieved: " + message.getMessage_code());
 		switch(message.getMessage_code()){
 			case SyncMessage.SYNC_REQUEST:
+                mHandler.obtainMessage(BluetoothSyncActivity.SYNC_START).sendToTarget();
                 SyncInfo thisSyncInfo = synchronizer.getSyncInfo();
 
                 System.out.println("----------------------- Sent: " + Arrays.toString(thisSyncInfo.bssids.toArray()));