mirror of
https://github.com/DanielPollithy/flashwifi.git
synced 2025-10-16 11:45:32 +00:00
fix seed problem
start to refactor the service<->ui problem
This commit is contained in:
parent
2f8c6e3a33
commit
cb57557acc
@ -79,26 +79,7 @@ public class HotspotFragment extends Fragment {
|
|||||||
|
|
||||||
//if (intent.hasExtra("what") && intent.getExtras().getString("what", "").equals("connectivity_changed")) {
|
//if (intent.hasExtra("what") && intent.getExtras().getString("what", "").equals("connectivity_changed")) {
|
||||||
|
|
||||||
NetworkInfo network_info = getmService().getNetwork_info();
|
|
||||||
WifiP2pInfo p2p_info = getmService().getP2p_info();
|
|
||||||
WifiP2pGroup wifiP2pGroup = getmService().getP2p_group();
|
|
||||||
|
|
||||||
if (intent.hasExtra("currentDeviceConnected")) {
|
|
||||||
//String macAddress = intent.getExtras().getString("currentDeviceConnected");
|
|
||||||
if (network_info.getState() == NetworkInfo.State.CONNECTED) {
|
|
||||||
// ToDo: look for the other device and make sure we are only two
|
|
||||||
|
|
||||||
if (p2p_info.isGroupOwner) {
|
|
||||||
Snackbar.make(activity_view, "You are the group owner", Snackbar.LENGTH_LONG).setAction("Action", null).show();
|
|
||||||
getmService().startNegotiationServer(false, null);
|
|
||||||
} else {
|
|
||||||
InetAddress groupOwnerAddress = p2p_info.groupOwnerAddress;
|
|
||||||
Snackbar.make(activity_view, "You are only a member of the group", Snackbar.LENGTH_LONG).setAction("Action", null).show();
|
|
||||||
getmService().startNegotiationClient(groupOwnerAddress, false, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -285,7 +285,7 @@ public class MainActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateBalance() {
|
private void updateBalance() {
|
||||||
WalletBalanceChecker balanceChecker = new WalletBalanceChecker(this,this.getString(R.string.preference_file_key),seed, balanceHandler,PREF_UPDATE,true);
|
WalletBalanceChecker balanceChecker = new WalletBalanceChecker(this,this.getString(R.string.preference_file_key), seed, balanceHandler,PREF_UPDATE,true);
|
||||||
balanceChecker.execute();
|
balanceChecker.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,6 @@ import java.net.InetAddress;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import com.flashwifi.wifip2p.broadcast.WiFiDirectBroadcastService;
|
import com.flashwifi.wifip2p.broadcast.WiFiDirectBroadcastService;
|
||||||
import com.flashwifi.wifip2p.iotaFlashWrapper.Main;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fragment that appears in the "content_frame", shows a planet
|
* Fragment that appears in the "content_frame", shows a planet
|
||||||
|
|||||||
@ -127,7 +127,8 @@ public class WelcomeActivity extends AppCompatActivity {
|
|||||||
} else if(!firstTimeNoSeed) {
|
} else if(!firstTimeNoSeed) {
|
||||||
launchHomeScreen();
|
launchHomeScreen();
|
||||||
} else {
|
} else {
|
||||||
startActivity(new Intent(WelcomeActivity.this, MainActivity.class));
|
launchHomeScreenNormal();
|
||||||
|
//startActivity(new Intent(WelcomeActivity.this, MainActivity.class));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -165,6 +166,14 @@ public class WelcomeActivity extends AppCompatActivity {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void launchHomeScreenNormal() {
|
||||||
|
Intent intent = new Intent(this, MainActivity.class);
|
||||||
|
intent.putExtra("seed", seed);
|
||||||
|
intent.putExtra("password", password);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
// viewpager change listener
|
// viewpager change listener
|
||||||
ViewPager.OnPageChangeListener viewPagerPageChangeListener = new ViewPager.OnPageChangeListener() {
|
ViewPager.OnPageChangeListener viewPagerPageChangeListener = new ViewPager.OnPageChangeListener() {
|
||||||
|
|
||||||
@ -292,11 +301,10 @@ public class WelcomeActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private boolean decryptSeed(String password) {
|
private boolean decryptSeed(String password) {
|
||||||
EncryptedPreferences encryptedPreferences = new EncryptedPreferences.Builder(this).withEncryptionPassword(password).build();
|
EncryptedPreferences encryptedPreferences = new EncryptedPreferences.Builder(this).withEncryptionPassword(password).build();
|
||||||
String seed = encryptedPreferences.getString(getString(R.string.encrypted_seed), null);
|
seed = encryptedPreferences.getString(getString(R.string.encrypted_seed), null);
|
||||||
View view = findViewById(R.id.home_view);
|
|
||||||
|
|
||||||
if (seed != null) {
|
if (seed != null) {
|
||||||
//Snackbar.make(view, getString(R.string.seed_decrypted), Snackbar.LENGTH_LONG).setAction("Action", null).show();
|
this.password = password;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
final EditText field = (EditText) findViewById(R.id.password);
|
final EditText field = (EditText) findViewById(R.id.password);
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import android.graphics.Bitmap;
|
|||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.net.DhcpInfo;
|
import android.net.DhcpInfo;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
|
import android.net.wifi.WifiInfo;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.net.wifi.p2p.WifiP2pConfig;
|
import android.net.wifi.p2p.WifiP2pConfig;
|
||||||
import android.net.wifi.p2p.WifiP2pDevice;
|
import android.net.wifi.p2p.WifiP2pDevice;
|
||||||
@ -826,6 +827,22 @@ public class WiFiDirectBroadcastService extends Service {
|
|||||||
if (p2p_info.groupFormed) {
|
if (p2p_info.groupFormed) {
|
||||||
currentDeviceConnected = p2p_info.groupOwnerAddress.getHostAddress();
|
currentDeviceConnected = p2p_info.groupOwnerAddress.getHostAddress();
|
||||||
sendUpdateUIBroadcastNewConnection();
|
sendUpdateUIBroadcastNewConnection();
|
||||||
|
NetworkInfo network_info = getNetwork_info();
|
||||||
|
WifiP2pInfo p2p_info = getP2p_info();
|
||||||
|
WifiP2pGroup wifiP2pGroup = getP2p_group();
|
||||||
|
|
||||||
|
if (network_info.getState() == NetworkInfo.State.CONNECTED) {
|
||||||
|
// ToDo: look for the other device and make sure we are only two
|
||||||
|
if (p2p_info.isGroupOwner) {
|
||||||
|
//Snackbar.make(activity_view, "You are the group owner", Snackbar.LENGTH_LONG).setAction("Action", null).show();
|
||||||
|
startNegotiationServer(false, wifiP2pGroup.getOwner().deviceAddress);
|
||||||
|
} else {
|
||||||
|
InetAddress groupOwnerAddress = p2p_info.groupOwnerAddress;
|
||||||
|
//Snackbar.make(activity_view, "You are only a member of the group", Snackbar.LENGTH_LONG).setAction("Action", null).show();
|
||||||
|
startNegotiationClient(groupOwnerAddress, false, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="The blablablablabla App"
|
android:text="Share remaining megabytes for iota"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="20dp"
|
android:textSize="20dp"
|
||||||
android:layout_marginTop="15dp"/>
|
android:layout_marginTop="15dp"/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user