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