mirror of
https://github.com/DanielPollithy/flashwifi.git
synced 2025-10-16 11:45:32 +00:00
Billing channel
This commit is contained in:
parent
1081a17b66
commit
9a75b7bca2
@ -59,11 +59,16 @@ public class MainActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initUi() {
|
private void initUi() {
|
||||||
Switch switch_ = (Switch) findViewById(R.id.wifiSwitch);
|
final Switch switch_ = (Switch) findViewById(R.id.wifiSwitch);
|
||||||
switch_.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() {
|
switch_.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() {
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
mService.enableService();
|
if (!mBound) {
|
||||||
|
switch_.setChecked(false);
|
||||||
|
Toast.makeText(getApplicationContext(), "Wifi Broadcast not bound", Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
mService.enableService();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mService.disableService();
|
mService.disableService();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,16 +13,20 @@ import android.net.wifi.p2p.WifiP2pInfo;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
import android.support.v4.app.TaskStackBuilder;
|
import android.support.v4.app.TaskStackBuilder;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -31,7 +35,7 @@ import com.flashwifi.wifip2p.broadcast.WiFiDirectBroadcastService;
|
|||||||
|
|
||||||
|
|
||||||
public class RoamingActivity extends AppCompatActivity {
|
public class RoamingActivity extends AppCompatActivity {
|
||||||
|
private static final String TAG = "RoamingActivity";
|
||||||
ArrayList<String> arrayList;
|
ArrayList<String> arrayList;
|
||||||
ArrayAdapter<String> listAdapter;
|
ArrayAdapter<String> listAdapter;
|
||||||
ListView listView;
|
ListView listView;
|
||||||
@ -55,6 +59,7 @@ public class RoamingActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction("com.flashwifi.wifip2p.update_ui");
|
filter.addAction("com.flashwifi.wifip2p.update_ui");
|
||||||
|
filter.addAction("com.flashwifi.wifip2p.update_roaming");
|
||||||
|
|
||||||
updateUIReceiver = new BroadcastReceiver() {
|
updateUIReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
@ -74,8 +79,25 @@ public class RoamingActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateUi(Intent intent) {
|
private void updateUi(Intent intent) {
|
||||||
NetworkInfo network_info = mService.getNetwork_info();
|
if (intent.getAction().equals("com.flashwifi.wifip2p.update_roaming")) {
|
||||||
WifiP2pInfo p2p_info = mService.getP2p_info();
|
Log.d(TAG, "updateUi: Received change from AsyncTask");
|
||||||
|
String message = intent.getStringExtra("message");
|
||||||
|
if (message != null) {
|
||||||
|
Log.d(TAG, "updateUi: message=" + message);
|
||||||
|
CheckBox apConnected = (CheckBox)findViewById(R.id.accessPointActive);
|
||||||
|
if (message.equals("AP SUCCESS")) {
|
||||||
|
apConnected.setChecked(true);
|
||||||
|
// when the AP is setup we can start the server
|
||||||
|
startBillingProtocol();
|
||||||
|
} else if (message.equals("AP FAILED")) {
|
||||||
|
apConnected.setChecked(false);
|
||||||
|
Toast.makeText(getApplicationContext(), "Could not create Access point", Toast.LENGTH_LONG).show();
|
||||||
|
} else if (message.equals("AP STOPPED")) {
|
||||||
|
apConnected.setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//TextView connection_status = (TextView) findViewById(R.id.connection_status);
|
//TextView connection_status = (TextView) findViewById(R.id.connection_status);
|
||||||
//final View activity_view = findViewById(R.id.chatView);
|
//final View activity_view = findViewById(R.id.chatView);
|
||||||
@ -84,9 +106,19 @@ public class RoamingActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startBillingProtocol() {
|
||||||
|
// setup the flash channel etc...
|
||||||
|
if (mService.isInRoleHotspot()) {
|
||||||
|
mService.startBillingServer();
|
||||||
|
} else {
|
||||||
|
mService.startBillingClient();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
|
unregisterReceiver(updateUIReceiver);
|
||||||
unbindService(mConnection);
|
unbindService(mConnection);
|
||||||
mBound = false;
|
mBound = false;
|
||||||
}
|
}
|
||||||
@ -102,21 +134,29 @@ public class RoamingActivity extends AppCompatActivity {
|
|||||||
address = intent.getStringExtra("address");
|
address = intent.getStringExtra("address");
|
||||||
|
|
||||||
initUI();
|
initUI();
|
||||||
showNotification();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void cancelNotification() {
|
||||||
|
NotificationManager mNotificationManager =
|
||||||
|
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
|
mNotificationManager.cancel(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void showNotification() {
|
private void showNotification() {
|
||||||
// The id of the channel.
|
// The id of the channel.
|
||||||
String CHANNEL_ID = "com.flashwifi.wifip2p.roaming_1";
|
String CHANNEL_ID = "com.flashwifi.wifip2p.roaming_1";
|
||||||
|
|
||||||
|
String contentText = mService.isInRoleHotspot() ? "You are providing" : "You are consuming";
|
||||||
|
|
||||||
// ToDo: make this work on high API version
|
// ToDo: make this work on high API version
|
||||||
NotificationCompat.Builder mBuilder =
|
NotificationCompat.Builder mBuilder =
|
||||||
new NotificationCompat.Builder(this)
|
new NotificationCompat.Builder(this)
|
||||||
.setSmallIcon(R.drawable.icon_tethering_on)
|
.setSmallIcon(R.drawable.icon_tethering_on)
|
||||||
.setContentTitle("My notification")
|
.setContentTitle("IOTA HOTSPOT")
|
||||||
.setContentText("Hello World!");
|
.setContentText(contentText);
|
||||||
// Creates an explicit intent for an Activity in your app
|
// Creates an explicit intent for an Activity in your app
|
||||||
Intent resultIntent = new Intent(this, RoamingActivity.class);
|
Intent resultIntent = new Intent(this, RoamingActivity.class);
|
||||||
|
|
||||||
@ -146,7 +186,6 @@ public class RoamingActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
|
|
||||||
private void initUI() {
|
private void initUI() {
|
||||||
|
|
||||||
//final EditText input = (EditText) findViewById(R.id.chat_input);
|
//final EditText input = (EditText) findViewById(R.id.chat_input);
|
||||||
//Button button = (Button) findViewById(R.id.btn_send);
|
//Button button = (Button) findViewById(R.id.btn_send);
|
||||||
/*button.setOnClickListener(new View.OnClickListener() {
|
/*button.setOnClickListener(new View.OnClickListener() {
|
||||||
@ -199,13 +238,40 @@ public class RoamingActivity extends AppCompatActivity {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private void initUIWithService() {
|
private void initUIWithService() {
|
||||||
|
|
||||||
|
TextView info_text = (TextView) findViewById(R.id.info_text);
|
||||||
|
if (mService.isInRoleHotspot()) {
|
||||||
|
info_text.setText(R.string.roaming_title);
|
||||||
|
} else {
|
||||||
|
info_text.setText(R.string.roaming_title_client);
|
||||||
|
}
|
||||||
|
|
||||||
stopButton = (Button) findViewById(R.id.stopRoamingButton);
|
stopButton = (Button) findViewById(R.id.stopRoamingButton);
|
||||||
stopButton.setOnClickListener(new View.OnClickListener() {
|
stopButton.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
// ToDo: stop the roaming here
|
cancelNotification();
|
||||||
|
if (mService.isInRoleHotspot()){
|
||||||
|
mService.stopAP();
|
||||||
|
} else {
|
||||||
|
mService.disconnectAP();
|
||||||
|
}
|
||||||
|
mService.setRoaming(false);
|
||||||
|
Toast.makeText(getApplicationContext(), "Press BACK now", Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// ToDo: change the status text
|
|
||||||
|
showNotification();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if (mBound) {
|
||||||
|
if (mService.isRoaming()) {
|
||||||
|
Toast.makeText(getApplicationContext(), "stop roaming before leaving", Toast.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,9 +102,9 @@ public class SearchFragment extends Fragment {
|
|||||||
what = "";
|
what = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToDo: do we need this???
|
|
||||||
if (what.equals("connectivity_changed")) {
|
if (what.equals("connectivity_changed")) {
|
||||||
// startNegotiationProtocol();
|
String currentDeviceConnected = intent.getStringExtra("currentDeviceConnected");
|
||||||
|
startNegotiationProtocol(currentDeviceConnected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,6 +191,7 @@ public class SearchFragment extends Fragment {
|
|||||||
toggle.setOnClickListener(new View.OnClickListener() {
|
toggle.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(final View view) {
|
public void onClick(final View view) {
|
||||||
|
updateList();
|
||||||
if (toggle.isChecked()) {
|
if (toggle.isChecked()) {
|
||||||
if (mBound) {
|
if (mBound) {
|
||||||
mService.setInRoleHotspot(false);
|
mService.setInRoleHotspot(false);
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.flashwifi.wifip2p.accesspoint;
|
package com.flashwifi.wifip2p.accesspoint;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.net.wifi.WifiConfiguration;
|
import android.net.wifi.WifiConfiguration;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
@ -15,12 +16,19 @@ import static android.content.Context.WIFI_SERVICE;
|
|||||||
public class AccessPointTask extends AsyncTask<Context, Void, String> {
|
public class AccessPointTask extends AsyncTask<Context, Void, String> {
|
||||||
|
|
||||||
private final static String TAG = "AccessPointTask";
|
private final static String TAG = "AccessPointTask";
|
||||||
private Context context;
|
private Context context;
|
||||||
String ssid = "Iotify";
|
String ssid = "Iotify";
|
||||||
String key = "1234567890";
|
String key = "1234567890";
|
||||||
WifiManager wifi;
|
WifiManager wifi;
|
||||||
WifiInfo w;
|
WifiInfo w;
|
||||||
|
|
||||||
|
private void sendUpdateUIBroadcastWithMessage(String message){
|
||||||
|
Intent local = new Intent();
|
||||||
|
local.putExtra("message", message);
|
||||||
|
local.setAction("com.flashwifi.wifip2p.update_roaming");
|
||||||
|
context.sendBroadcast(local);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String doInBackground(Context... params) {
|
protected String doInBackground(Context... params) {
|
||||||
context = params[0];
|
context = params[0];
|
||||||
@ -67,17 +75,11 @@ public class AccessPointTask extends AsyncTask<Context, Void, String> {
|
|||||||
|
|
||||||
if(apstatus)
|
if(apstatus)
|
||||||
{
|
{
|
||||||
System.out.println("SUCCESS");
|
sendUpdateUIBroadcastWithMessage("AP SUCCESS");
|
||||||
//statusView.append("\nAccess Point Created!");
|
|
||||||
//finish();
|
|
||||||
//Intent searchSensorsIntent = new Intent(this,SearchSensors.class);
|
|
||||||
//startActivity(searchSensorsIntent);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
System.out.println("FAILED");
|
sendUpdateUIBroadcastWithMessage("AP FAILED");
|
||||||
|
|
||||||
//statusView.append("\nAccess Point Creation failed!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException e) {
|
catch (IllegalArgumentException e) {
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.flashwifi.wifip2p.accesspoint;
|
package com.flashwifi.wifip2p.accesspoint;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.net.wifi.WifiConfiguration;
|
import android.net.wifi.WifiConfiguration;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
@ -21,9 +22,18 @@ public class ConnectTask extends AsyncTask<Context, Void, String> {
|
|||||||
WifiManager wifi;
|
WifiManager wifi;
|
||||||
WifiInfo w;
|
WifiInfo w;
|
||||||
|
|
||||||
|
Context context;
|
||||||
|
|
||||||
|
private void sendUpdateUIBroadcastWithMessage(String message){
|
||||||
|
Intent local = new Intent();
|
||||||
|
local.putExtra("message", message);
|
||||||
|
local.setAction("com.flashwifi.wifip2p.update_roaming");
|
||||||
|
context.sendBroadcast(local);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String doInBackground(Context... params) {
|
protected String doInBackground(Context... params) {
|
||||||
Context context = params[0];
|
context = params[0];
|
||||||
WifiManager wifiManager = (WifiManager) context.getSystemService(WIFI_SERVICE);
|
WifiManager wifiManager = (WifiManager) context.getSystemService(WIFI_SERVICE);
|
||||||
|
|
||||||
WifiInfo info = wifiManager.getConnectionInfo(); //get WifiInfo
|
WifiInfo info = wifiManager.getConnectionInfo(); //get WifiInfo
|
||||||
@ -35,11 +45,6 @@ public class ConnectTask extends AsyncTask<Context, Void, String> {
|
|||||||
wifiConfig.preSharedKey = String.format("\"%s\"", key);
|
wifiConfig.preSharedKey = String.format("\"%s\"", key);
|
||||||
|
|
||||||
Log.d(TAG, "doInBackground: GO to sleep");
|
Log.d(TAG, "doInBackground: GO to sleep");
|
||||||
try {
|
|
||||||
Thread.sleep(30 * 1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
Log.d(TAG, "doInBackground: disconnect");
|
Log.d(TAG, "doInBackground: disconnect");
|
||||||
int netId = wifiManager.addNetwork(wifiConfig);
|
int netId = wifiManager.addNetwork(wifiConfig);
|
||||||
|
|
||||||
@ -56,8 +61,10 @@ public class ConnectTask extends AsyncTask<Context, Void, String> {
|
|||||||
boolean worked = wifiManager.enableNetwork(i.networkId, true);
|
boolean worked = wifiManager.enableNetwork(i.networkId, true);
|
||||||
if (worked) {
|
if (worked) {
|
||||||
Log.d(TAG, "doInBackground: WORKED enableNetwork");
|
Log.d(TAG, "doInBackground: WORKED enableNetwork");
|
||||||
|
sendUpdateUIBroadcastWithMessage("AP SUCCESS");
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "doInBackground: ERROROROROROROROORORORORORO------x error");
|
Log.d(TAG, "doInBackground: Error connecting to the network");
|
||||||
|
sendUpdateUIBroadcastWithMessage("AP FAILED");
|
||||||
}
|
}
|
||||||
wifiManager.reconnect();
|
wifiManager.reconnect();
|
||||||
|
|
||||||
@ -67,7 +74,7 @@ public class ConnectTask extends AsyncTask<Context, Void, String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, "doInBackground: now wait");
|
/*Log.d(TAG, "doInBackground: now wait");
|
||||||
|
|
||||||
int number_minutes = 60;
|
int number_minutes = 60;
|
||||||
for (int i=0; i<number_minutes; i++) {
|
for (int i=0; i<number_minutes; i++) {
|
||||||
@ -76,7 +83,7 @@ public class ConnectTask extends AsyncTask<Context, Void, String> {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.flashwifi.wifip2p.accesspoint;
|
package com.flashwifi.wifip2p.accesspoint;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.net.wifi.WifiConfiguration;
|
import android.net.wifi.WifiConfiguration;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
@ -20,6 +21,13 @@ public class StopAccessPointTask extends AsyncTask<Context, Void, String> {
|
|||||||
WifiManager wifi;
|
WifiManager wifi;
|
||||||
WifiInfo w;
|
WifiInfo w;
|
||||||
|
|
||||||
|
private void sendUpdateUIBroadcastWithMessage(String message){
|
||||||
|
Intent local = new Intent();
|
||||||
|
local.putExtra("message", message);
|
||||||
|
local.setAction("com.flashwifi.wifip2p.update_roaming");
|
||||||
|
context.sendBroadcast(local);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String doInBackground(Context... params) {
|
protected String doInBackground(Context... params) {
|
||||||
context = params[0];
|
context = params[0];
|
||||||
@ -51,6 +59,8 @@ public class StopAccessPointTask extends AsyncTask<Context, Void, String> {
|
|||||||
wifi.setWifiEnabled(true);
|
wifi.setWifiEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendUpdateUIBroadcastWithMessage("AP STOPPED");
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,6 +92,7 @@ public class BillingClient {
|
|||||||
// ToDo: mark bill accepted
|
// ToDo: mark bill accepted
|
||||||
// ToDo: flash object -> diff()
|
// ToDo: flash object -> diff()
|
||||||
// ToDo: sign flash transaction
|
// ToDo: sign flash transaction
|
||||||
|
// ToDo: update UI
|
||||||
latestBillAnswer = new BillMessageAnswer("id", true, "", false);
|
latestBillAnswer = new BillMessageAnswer("id", true, "", false);
|
||||||
latestBillAnswerString = gson.toJson(latestBillAnswer);
|
latestBillAnswerString = gson.toJson(latestBillAnswer);
|
||||||
socketWrapper.sendLine(latestBillAnswerString);
|
socketWrapper.sendLine(latestBillAnswerString);
|
||||||
|
|||||||
@ -1,5 +1,23 @@
|
|||||||
package com.flashwifi.wifip2p.billing;
|
package com.flashwifi.wifip2p.billing;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.flashwifi.wifip2p.negotiation.SocketWrapper;
|
||||||
|
import com.flashwifi.wifip2p.protocol.BillMessage;
|
||||||
|
import com.flashwifi.wifip2p.protocol.BillMessageAnswer;
|
||||||
|
import com.flashwifi.wifip2p.protocol.BillingCloseChannel;
|
||||||
|
import com.flashwifi.wifip2p.protocol.BillingCloseChannelAnswer;
|
||||||
|
import com.flashwifi.wifip2p.protocol.BillingOpenChannel;
|
||||||
|
import com.flashwifi.wifip2p.protocol.BillingOpenChannelAnswer;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.ServerSocket;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.net.SocketException;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1) This class keeps the socket connection alive.
|
* 1) This class keeps the socket connection alive.
|
||||||
* 2) It tracks the state of the communication.
|
* 2) It tracks the state of the communication.
|
||||||
@ -10,38 +28,132 @@ package com.flashwifi.wifip2p.billing;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class BillingServer {
|
public class BillingServer {
|
||||||
|
private static final String TAG = "BillingServer";
|
||||||
|
private final Gson gson;
|
||||||
private State state = State.NOT_PAIRED;
|
private State state = State.NOT_PAIRED;
|
||||||
|
private ServerSocket serverSocket;
|
||||||
|
private Socket socket;
|
||||||
|
private SocketWrapper socketWrapper;
|
||||||
|
private int PORT = 9199;
|
||||||
|
private static final int serverTimeoutMillis = 2 * 60 * 1000;
|
||||||
|
|
||||||
public BillingServer(int bookedMegabytes, int timeoutMinutes){
|
public BillingServer(int bookedMegabytes, int timeoutMinutes){
|
||||||
Accountant.getInstance().start(bookedMegabytes,timeoutMinutes);
|
Accountant.getInstance().start(bookedMegabytes,timeoutMinutes);
|
||||||
|
gson = new GsonBuilder().create();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() throws IOException {
|
||||||
// 0) create deadline guard
|
// 0) create deadline guard
|
||||||
createDeadlineGuard();
|
createDeadlineGuard();
|
||||||
// 1) create a socket
|
// 1) create a socket
|
||||||
|
|
||||||
while (state != State.ERROR || state != State.FULLY_ATTACHED) {
|
while (state != State.CLOSED) {
|
||||||
// 2) accept a connection
|
try {
|
||||||
if (state == State.NOT_PAIRED) {
|
// create server socket
|
||||||
// 3) pair client and hotspot and synchronize states
|
serverSocket = new ServerSocket(PORT);
|
||||||
}
|
serverSocket.setSoTimeout(serverTimeoutMillis);
|
||||||
while (state == State.ROAMING) {
|
Log.d(TAG, "doInBackground: Server is waiting for connection");
|
||||||
// 4) sleep(60)
|
|
||||||
// 5) createNewBill
|
socket = serverSocket.accept();
|
||||||
// 6) send the bill and the signed flash object
|
socket.setSoTimeout(serverTimeoutMillis);
|
||||||
}
|
Log.d(TAG, "start: Server accepted a connection");
|
||||||
if (state == State.CLOSED) {
|
|
||||||
// 7) close the channel and sign the final settlement
|
// wrap the socket
|
||||||
// 8) receive the signed settlement from client
|
socketWrapper = new SocketWrapper(socket);
|
||||||
}
|
|
||||||
while (state == State.CLOSED) {
|
if (state == State.NOT_PAIRED) {
|
||||||
// 9) reattach and rebroadcast the final transaction
|
// await current state of client
|
||||||
}
|
String clientState = socketWrapper.getLineThrowing();
|
||||||
if (state == State.FULLY_ATTACHED) {
|
if (!clientState.contains("NOT_PAIRED")) {
|
||||||
// DONE!
|
Log.d(TAG, "start: PROBLEM PROBLEM PROBLEM! States not synced.");
|
||||||
|
// ToDo: How to synchronize client and server states?
|
||||||
|
}
|
||||||
|
// ToDo: send an eventually stored flash channel
|
||||||
|
socketWrapper.sendLine("Hello, Client! I am in state: NOT_PAIRED");
|
||||||
|
|
||||||
|
// receive the BillingOpenChannel message
|
||||||
|
String billingOpenChannelString = socketWrapper.getLineThrowing();
|
||||||
|
BillingOpenChannel billingOpenChannel = gson.fromJson(billingOpenChannelString, BillingOpenChannel.class);
|
||||||
|
|
||||||
|
// answer with billingOpenChannelAnswerString
|
||||||
|
// ToDo: create the flash channel
|
||||||
|
String[] myDigests = new String[]{"1234", "2345", "3456"};
|
||||||
|
BillingOpenChannelAnswer billingOpenChannelAnswer = new BillingOpenChannelAnswer(0, 0, "", "", myDigests);
|
||||||
|
String billingOpenChannelAnswerString = gson.toJson(billingOpenChannelAnswer);
|
||||||
|
socketWrapper.sendLine(billingOpenChannelAnswerString);
|
||||||
|
|
||||||
|
// OK
|
||||||
|
state = State.ROAMING;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == State.ROAMING) {
|
||||||
|
String latestBillString;
|
||||||
|
BillMessage latestBill;
|
||||||
|
Bill b;
|
||||||
|
String latestBillAnswerString;
|
||||||
|
BillMessageAnswer latestBillAnswer;
|
||||||
|
|
||||||
|
// loop until roaming ends
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
while (state == State.ROAMING) {
|
||||||
|
// sleep 1 minute
|
||||||
|
Log.d(TAG, "start: I go to sleep for 1 minute!");
|
||||||
|
Thread.sleep(60 * 1000);
|
||||||
|
Log.d(TAG, "start: Good morning!");
|
||||||
|
// create new bill
|
||||||
|
// ToDo: integrate real network data
|
||||||
|
// ToDo: calculate time correctly
|
||||||
|
b = Accountant.getInstance().createBill(0,0,1);
|
||||||
|
// ToDo: integrate real flash channel
|
||||||
|
latestBill = new BillMessage(b, "", false);
|
||||||
|
latestBillString = gson.toJson(latestBill);
|
||||||
|
socketWrapper.sendLine(latestBillString);
|
||||||
|
|
||||||
|
// get answer
|
||||||
|
latestBillAnswerString = socketWrapper.getLineThrowing();
|
||||||
|
latestBillAnswer = gson.fromJson(latestBillAnswerString, BillMessageAnswer.class);
|
||||||
|
// ToDo: check signature
|
||||||
|
// ToDo: flash object -> diff()
|
||||||
|
// ToDo: update UI
|
||||||
|
|
||||||
|
// close the channel if the last invoice has <closeAfterwards>
|
||||||
|
// or the last answer had <closeAfterwards>
|
||||||
|
if (latestBill.isCloseAfterwards() || latestBillAnswer.isCloseAfterwards()) {
|
||||||
|
state = State.CLOSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == State.CLOSE) {
|
||||||
|
// ToDo: handle the final deposit of the flash channel
|
||||||
|
// ToDo: sign the transaction
|
||||||
|
BillingCloseChannel billingCloseChannel = new BillingCloseChannel(0,0,0,0,"", "", "");
|
||||||
|
String closeChannelString = gson.toJson(billingCloseChannel);
|
||||||
|
socketWrapper.sendLine(closeChannelString);
|
||||||
|
|
||||||
|
String billingCloseChannelAnswerString = socketWrapper.getLineThrowing();
|
||||||
|
BillingCloseChannelAnswer billingCloseChannelAnswer = gson.fromJson(billingCloseChannelAnswerString, BillingCloseChannelAnswer.class);
|
||||||
|
// ToDo: validate the signature
|
||||||
|
state = State.CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == State.CLOSED) {
|
||||||
|
// ToDo: attach the last transaction to the tangle
|
||||||
|
boolean attached = false;
|
||||||
|
while (!attached) {
|
||||||
|
Log.d(TAG, "start: Attach to tangle please");
|
||||||
|
}
|
||||||
|
state = State.FULLY_ATTACHED;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createDeadlineGuard() {
|
private void createDeadlineGuard() {
|
||||||
@ -53,6 +165,7 @@ public class BillingServer {
|
|||||||
NOT_PAIRED,
|
NOT_PAIRED,
|
||||||
INITIAL,
|
INITIAL,
|
||||||
ROAMING,
|
ROAMING,
|
||||||
|
CLOSE,
|
||||||
CLOSED,
|
CLOSED,
|
||||||
FULLY_ATTACHED,
|
FULLY_ATTACHED,
|
||||||
ERROR
|
ERROR
|
||||||
|
|||||||
@ -19,8 +19,11 @@ import android.util.Log;
|
|||||||
import com.flashwifi.wifip2p.accesspoint.AccessPointTask;
|
import com.flashwifi.wifip2p.accesspoint.AccessPointTask;
|
||||||
import com.flashwifi.wifip2p.accesspoint.ConnectTask;
|
import com.flashwifi.wifip2p.accesspoint.ConnectTask;
|
||||||
import com.flashwifi.wifip2p.accesspoint.StopAccessPointTask;
|
import com.flashwifi.wifip2p.accesspoint.StopAccessPointTask;
|
||||||
|
import com.flashwifi.wifip2p.billing.BillingClient;
|
||||||
|
import com.flashwifi.wifip2p.billing.BillingServer;
|
||||||
import com.flashwifi.wifip2p.negotiation.Negotiator;
|
import com.flashwifi.wifip2p.negotiation.Negotiator;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.NetworkInterface;
|
import java.net.NetworkInterface;
|
||||||
@ -37,6 +40,9 @@ public class WiFiDirectBroadcastService extends Service {
|
|||||||
private boolean setup = false;
|
private boolean setup = false;
|
||||||
private boolean inRoleHotspot = false;
|
private boolean inRoleHotspot = false;
|
||||||
private boolean inRoleConsumer = false;
|
private boolean inRoleConsumer = false;
|
||||||
|
private boolean isRoaming = false;
|
||||||
|
private boolean billingServerIsRunning = false;
|
||||||
|
private boolean billingClientIsRunning = false;
|
||||||
|
|
||||||
private boolean enabled = false;
|
private boolean enabled = false;
|
||||||
|
|
||||||
@ -87,28 +93,76 @@ public class WiFiDirectBroadcastService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startBillingServer(){
|
public void startBillingServer(){
|
||||||
|
if (!billingServerIsRunning) {
|
||||||
|
billingServerIsRunning = true;
|
||||||
|
|
||||||
|
Runnable task = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// ToDo: remove magic numbers
|
||||||
|
BillingServer billingServer = new BillingServer(100, 20);
|
||||||
|
|
||||||
|
try {
|
||||||
|
billingServer.start();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// ToDo: handle billingServer EXIT CODES
|
||||||
|
// -> close the roaming etc.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Thread thread = new Thread(task);
|
||||||
|
threads.add(thread);
|
||||||
|
AsyncTask.execute(thread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void startBillingClient() {
|
||||||
|
if (!billingClientIsRunning) {
|
||||||
|
billingClientIsRunning = true;
|
||||||
|
|
||||||
|
Runnable task = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// ToDo: remove magic numbers
|
||||||
|
BillingClient billingClient = new BillingClient();
|
||||||
|
// ToDo: get the AP gateway ip address
|
||||||
|
// https://stackoverflow.com/questions/9035784/how-to-know-ip-address-of-the-router-from-code-in-android
|
||||||
|
billingClient.start("192.168.43.1");
|
||||||
|
// ToDo: handle billingServer EXIT CODES
|
||||||
|
// -> close the roaming etc.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Thread thread = new Thread(task);
|
||||||
|
threads.add(thread);
|
||||||
|
AsyncTask.execute(thread);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect2AP(String ssid, String key) {
|
public void connect2AP(String ssid, String key) {
|
||||||
connectTask = new ConnectTask();
|
connectTask = new ConnectTask();
|
||||||
Log.d("xxxxxxxxxxxxxx", "CONNECT TO THE HOTSPOT");
|
Log.d(TAG, "connect2AP: CONNECT TO THE HOTSPOT");
|
||||||
connectTask.execute(getApplicationContext());
|
connectTask.execute(getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void disconnectAP() {
|
||||||
|
}
|
||||||
|
|
||||||
public void startAP() {
|
public void startAP() {
|
||||||
Log.d("xxxxxxxxxxxxxx", "start AP");
|
|
||||||
if (!apRuns) {
|
if (!apRuns) {
|
||||||
|
Log.d(TAG, "start Access point");
|
||||||
apRuns = true;
|
apRuns = true;
|
||||||
apTask = new AccessPointTask();
|
apTask = new AccessPointTask();
|
||||||
apTask.execute(getApplicationContext());
|
apTask.execute(getApplicationContext());
|
||||||
} else {
|
} else {
|
||||||
Log.d("", "startSocketServer: ALREADY RUNNING");
|
Log.d(TAG, "Access point ALREADY RUNNING");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopAP() {
|
public void stopAP() {
|
||||||
Log.d("xxxxxxxxxxxxxx", "stop AP");
|
Log.d(TAG, "stop AP");
|
||||||
if (apRuns) {
|
if (apRuns) {
|
||||||
apRuns = false;
|
apRuns = false;
|
||||||
new StopAccessPointTask().execute(getApplicationContext());
|
new StopAccessPointTask().execute(getApplicationContext());
|
||||||
@ -160,10 +214,9 @@ public class WiFiDirectBroadcastService extends Service {
|
|||||||
public void run() {
|
public void run() {
|
||||||
Negotiator negotiator = new Negotiator(isClient, getWFDMacAddress());
|
Negotiator negotiator = new Negotiator(isClient, getWFDMacAddress());
|
||||||
String peer_mac_address = null;
|
String peer_mac_address = null;
|
||||||
while (enabled && peer_mac_address == null) {
|
while (!isRoaming && enabled && peer_mac_address == null) {
|
||||||
Log.d(TAG, "run: " + enabled);
|
Log.d(TAG, "run: " + enabled);
|
||||||
peer_mac_address = negotiator.workAsServer();
|
peer_mac_address = negotiator.workAsServer();
|
||||||
deletePersistentGroups();
|
|
||||||
// ToDo: use other broadcast for this
|
// ToDo: use other broadcast for this
|
||||||
// sendUpdateUIBroadcast();
|
// sendUpdateUIBroadcast();
|
||||||
try {
|
try {
|
||||||
@ -171,17 +224,27 @@ public class WiFiDirectBroadcastService extends Service {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
if (peer_mac_address == null) {
|
||||||
|
deletePersistentGroups();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (peer_mac_address != null) {
|
if (peer_mac_address != null) {
|
||||||
|
// block the discovery mode due to switch to roaming state
|
||||||
|
setRoaming(true);
|
||||||
|
// tell the UI
|
||||||
sendStartRoamingBroadcast(peer_mac_address);
|
sendStartRoamingBroadcast(peer_mac_address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
Thread thread = new Thread(task);
|
if (!isRoaming()) {
|
||||||
threads.add(thread);
|
Thread thread = new Thread(task);
|
||||||
AsyncTask.execute(thread);
|
threads.add(thread);
|
||||||
|
AsyncTask.execute(thread);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "startNegServer: BLOCKED due to roaming state");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendStartRoamingBroadcast(String peer_mac_address) {
|
private void sendStartRoamingBroadcast(String peer_mac_address) {
|
||||||
@ -197,25 +260,35 @@ public class WiFiDirectBroadcastService extends Service {
|
|||||||
public void run() {
|
public void run() {
|
||||||
Negotiator negotiator = new Negotiator(isClient, getWFDMacAddress());
|
Negotiator negotiator = new Negotiator(isClient, getWFDMacAddress());
|
||||||
String peer_mac_address = null;
|
String peer_mac_address = null;
|
||||||
while (enabled && peer_mac_address == null) {
|
while (!isRoaming && enabled && peer_mac_address == null) {
|
||||||
Log.d(TAG, "run: " + enabled);
|
Log.d(TAG, "run: " + enabled);
|
||||||
System.out.println(" *******+ work as client *******");
|
System.out.println(" *******+ work as client *******");
|
||||||
peer_mac_address = negotiator.workAsClient(address.getHostAddress());
|
peer_mac_address = negotiator.workAsClient(address.getHostAddress());
|
||||||
deletePersistentGroups();
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
if (peer_mac_address == null) {
|
||||||
|
deletePersistentGroups();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (peer_mac_address != null) {
|
if (peer_mac_address != null) {
|
||||||
|
// block the discovery mode due to switch to roaming state
|
||||||
|
setRoaming(true);
|
||||||
|
// tell the UI
|
||||||
sendStartRoamingBroadcast(peer_mac_address);
|
sendStartRoamingBroadcast(peer_mac_address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Thread thread = new Thread(task);
|
if (!isRoaming()) {
|
||||||
threads.add(thread);
|
Thread thread = new Thread(task);
|
||||||
AsyncTask.execute(thread);
|
threads.add(thread);
|
||||||
|
AsyncTask.execute(thread);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "startNegotiationClient: BLOCKED due to roaming state");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,6 +386,18 @@ public class WiFiDirectBroadcastService extends Service {
|
|||||||
this.inRoleConsumer = inRoleConsumer;
|
this.inRoleConsumer = inRoleConsumer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isRoaming() {
|
||||||
|
return isRoaming;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoaming(boolean roaming) {
|
||||||
|
if (roaming) {
|
||||||
|
stopAllTasks();
|
||||||
|
}
|
||||||
|
isRoaming = roaming;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class used for the client Binder. Because we know this service always
|
* Class used for the client Binder. Because we know this service always
|
||||||
* runs in the same process as its clients, we don't need to deal with IPC.
|
* runs in the same process as its clients, we don't need to deal with IPC.
|
||||||
@ -388,7 +473,7 @@ public class WiFiDirectBroadcastService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendUpdateUIBroadcastNewConnection(){
|
private void sendUpdateUIBroadcastNewConnection(){
|
||||||
Log.d(TAG, "sendUpdateUIBroadcastNewConnection: SEND THEEM SHIIIIIIIT");
|
Log.d(TAG, "sendUpdateUIBroadcastNewConnection: NOTIFY UI ABOUT NEW CONNECTION");
|
||||||
Intent local = new Intent();
|
Intent local = new Intent();
|
||||||
local.setAction("com.flashwifi.wifip2p.update_ui");
|
local.setAction("com.flashwifi.wifip2p.update_ui");
|
||||||
local.putExtra("what", "connectivity_changed");
|
local.putExtra("what", "connectivity_changed");
|
||||||
|
|||||||
@ -43,15 +43,7 @@ public class PeerListAdapter extends ArrayAdapter<PeerInformation> {
|
|||||||
TextView tt3 = (TextView) v.findViewById(R.id.description);
|
TextView tt3 = (TextView) v.findViewById(R.id.description);
|
||||||
TextView tt4 = (TextView) v.findViewById(R.id.ipAddr);
|
TextView tt4 = (TextView) v.findViewById(R.id.ipAddr);
|
||||||
TextView tt5 = (TextView) v.findViewById(R.id.iotaPrice);
|
TextView tt5 = (TextView) v.findViewById(R.id.iotaPrice);
|
||||||
TableRow row = (TableRow) v.findViewById(R.id.talkingRow);
|
|
||||||
|
|
||||||
if (row != null) {
|
|
||||||
if (p.isSelected()) {
|
|
||||||
row.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
row.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WifiP2pDevice device = p.getWifiP2pDevice();
|
WifiP2pDevice device = p.getWifiP2pDevice();
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
|
|||||||
@ -269,7 +269,7 @@ public class Negotiator {
|
|||||||
// ToDo: Don't mock this
|
// ToDo: Don't mock this
|
||||||
hotspot_state = HotspotState.GENERATE_PASSWORD;
|
hotspot_state = HotspotState.GENERATE_PASSWORD;
|
||||||
String password = "123456789";
|
String password = "123456789";
|
||||||
String hotspotName = "Iotify-123";
|
String hotspotName = "Iotify";
|
||||||
|
|
||||||
// send password and hotspot name
|
// send password and hotspot name
|
||||||
NegotiationFinalization finalization = new NegotiationFinalization(hotspotName, password,
|
NegotiationFinalization finalization = new NegotiationFinalization(hotspotName, password,
|
||||||
|
|||||||
7
app/src/main/res/drawable/listview_colours.xml
Normal file
7
app/src/main/res/drawable/listview_colours.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@color/colour_highlight_grey" android:state_pressed="true"/>
|
||||||
|
<item android:drawable="@color/colour_dark_blue" android:state_selected="true"/>
|
||||||
|
<item android:drawable="@color/colour_dark_green" android:state_activated="true"/>
|
||||||
|
<item android:drawable="@color/colour_dark_blue" android:state_focused="true"/>
|
||||||
|
</selector>
|
||||||
@ -39,23 +39,24 @@
|
|||||||
android:text="@string/roamingTitle"
|
android:text="@string/roamingTitle"
|
||||||
android:textSize="20sp" />
|
android:textSize="20sp" />
|
||||||
|
|
||||||
<CheckedTextView
|
<CheckBox
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:layout_marginRight="15dp"
|
android:layout_marginRight="15dp"
|
||||||
android:checkMark="@android:drawable/checkbox_on_background"
|
android:checked="false"
|
||||||
android:checked="true"
|
android:clickable="false"
|
||||||
|
android:id="@+id/accessPointActive"
|
||||||
android:text="Access point connection" />
|
android:text="Access point connection" />
|
||||||
|
|
||||||
<CheckedTextView
|
<CheckBox
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:layout_marginRight="15dp"
|
android:layout_marginRight="15dp"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
android:checkMark="@android:drawable/checkbox_on_background"
|
android:checked="false"
|
||||||
android:checked="true"
|
android:clickable="false"
|
||||||
android:text="Flash channel" />
|
android:text="Flash channel" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@ -29,8 +29,10 @@
|
|||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/peer_list"
|
android:id="@+id/peer_list"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/cardview_light_background"
|
||||||
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@ -1,86 +1,95 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_height="wrap_content" android:orientation="vertical"
|
|
||||||
android:layout_width="fill_parent">
|
|
||||||
|
|
||||||
<TableRow android:layout_width="fill_parent"
|
<LinearLayout
|
||||||
android:id="@+id/TableRow01"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent">
|
||||||
|
|
||||||
<TextView android:textColor="#000000"
|
<android.support.v7.widget.CardView
|
||||||
android:id="@+id/deviceName"
|
android:id="@+id/ly_root"
|
||||||
android:layout_width="fill_parent"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_height="wrap_content"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:text="Device name"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:textStyle="bold"
|
android:layout_width="match_parent"
|
||||||
android:gravity="left"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:typeface="monospace"
|
|
||||||
android:height="40sp" />
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow android:layout_height="wrap_content"
|
|
||||||
android:layout_width="fill_parent">
|
|
||||||
|
|
||||||
<TextView android:textColor="#000000"
|
|
||||||
android:id="@+id/categoryId"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="macAddress"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:height="20sp" />
|
|
||||||
|
|
||||||
<TextView android:layout_height="wrap_content"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:textColor="#000000"
|
|
||||||
android:gravity="right"
|
|
||||||
android:id="@+id/description"
|
|
||||||
android:text="description"
|
|
||||||
android:height="20sp" />
|
|
||||||
</TableRow>
|
|
||||||
<TableRow android:layout_height="wrap_content"
|
|
||||||
android:layout_width="fill_parent">
|
|
||||||
|
|
||||||
<TextView android:textColor="#000000"
|
|
||||||
android:id="@+id/ipAddr"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="ipAddr"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:height="20sp" />
|
|
||||||
|
|
||||||
<TextView android:layout_height="wrap_content"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:textColor="#000000"
|
|
||||||
android:gravity="right"
|
|
||||||
android:id="@+id/iotaPrice"
|
|
||||||
android:text="iotaPrice"
|
|
||||||
android:height="20sp" />
|
|
||||||
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="invisible"
|
android:background="#9f9e9e"
|
||||||
android:id="@+id/talkingRow">
|
android:layout_margin="15dp"
|
||||||
|
app:cardCornerRadius="4dp"
|
||||||
|
android:padding="15dp"
|
||||||
|
android:listSelector="@drawable/listview_colours" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
<ProgressBar
|
android:layout_width="fill_parent"
|
||||||
style="?android:attr/progressBarStyle"
|
|
||||||
android:layout_width="63dp"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:orientation="vertical">
|
||||||
android:text="Stop Talking" />
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_margin="15dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/deviceName"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="left"
|
||||||
|
android:layout_marginRight="50dp"
|
||||||
|
android:text="Device name"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Headline" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/categoryId"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:text="macAddress"
|
||||||
|
android:textColor="#000000" />
|
||||||
|
|
||||||
|
|
||||||
</TableRow>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginLeft="15dp"
|
||||||
|
android:layout_marginRight="15dp"
|
||||||
|
android:layout_marginBottom="15dp"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:textColor="#000000"
|
||||||
|
android:gravity="right"
|
||||||
|
android:id="@+id/description"
|
||||||
|
android:text="description"
|
||||||
|
android:layout_marginRight="20dp"/>
|
||||||
|
|
||||||
|
<TextView android:textColor="#000000"
|
||||||
|
android:id="@+id/ipAddr"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="ipAddr"
|
||||||
|
android:layout_marginRight="20dp"/>
|
||||||
|
|
||||||
|
<TextView android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textColor="#000000"
|
||||||
|
android:id="@+id/iotaPrice"
|
||||||
|
android:text="iotaPrice" />
|
||||||
|
|
||||||
|
|
||||||
</TableLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</android.support.v7.widget.CardView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@ -3,4 +3,9 @@
|
|||||||
<color name="colorPrimary">#3F51B5</color>
|
<color name="colorPrimary">#3F51B5</color>
|
||||||
<color name="colorPrimaryDark">#303F9F</color>
|
<color name="colorPrimaryDark">#303F9F</color>
|
||||||
<color name="colorAccent">#07daff</color>
|
<color name="colorAccent">#07daff</color>
|
||||||
|
|
||||||
|
<color name="black_overlay">#66000000</color>
|
||||||
|
<color name="colour_highlight_grey">#ff666666</color>
|
||||||
|
<color name="colour_dark_blue">#ff000066</color>
|
||||||
|
<color name="colour_dark_green">#ff006600</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@ -62,5 +62,7 @@
|
|||||||
<string name="roamingTitle">Roaming</string>
|
<string name="roamingTitle">Roaming</string>
|
||||||
<string name="searchIntroduction">Do you want to search for a hotspot?</string>
|
<string name="searchIntroduction">Do you want to search for a hotspot?</string>
|
||||||
<string name="startSearch">Start Search</string>
|
<string name="startSearch">Start Search</string>
|
||||||
|
<string name="roaming_title">Roaming (This is your hotspot)</string>
|
||||||
|
<string name="roaming_title_client">Roaming (You are consuming)</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in New Issue
Block a user