Simple network info page
This commit is contained in:
@@ -37,6 +37,9 @@
|
||||
<activity
|
||||
android:name="i2p.bote.android.addressbook.EditContactActivity"
|
||||
android:parentActivityName="i2p.bote.android.addressbook.AddressBookActivity" />
|
||||
<activity
|
||||
android:name="i2p.bote.android.NetworkInfoActivity"
|
||||
android:parentActivityName="i2p.bote.android.EmailListActivity" />
|
||||
<activity
|
||||
android:name="i2p.bote.android.config.SettingsActivity"
|
||||
android:parentActivityName="i2p.bote.android.EmailListActivity" />
|
||||
|
||||
51
res/layout/fragment_network_info.xml
Normal file
51
res/layout/fragment_network_info.xml
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/local_destination" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/local_destination"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/not_set" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/kademlia_peers" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/kademlia_peers"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="0" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/relay_peers" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/relay_peers"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="0" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/banned_peers" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/banned_peers"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="0" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -58,6 +58,12 @@
|
||||
<string name="label_browse">Browse</string>
|
||||
<string name="save_contact">Save contact</string>
|
||||
|
||||
<string name="local_destination">Local Destination:</string>
|
||||
<string name="not_set">Not set</string>
|
||||
<string name="kademlia_peers">Kademlia Peers:</string>
|
||||
<string name="relay_peers">Relay Peers:</string>
|
||||
<string name="banned_peers">Banned Peers:</string>
|
||||
|
||||
<string name="pref_title_general">General</string>
|
||||
<string name="pref_summ_general">General settings and default identity settings</string>
|
||||
<string name="pref_title_autoMail">Auto-check mail</string>
|
||||
|
||||
@@ -164,7 +164,8 @@ public class EmailListActivity extends ActionBarActivity implements
|
||||
});
|
||||
mNetworkStatus.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
// TODO: network status page
|
||||
Intent nii = new Intent(EmailListActivity.this, NetworkInfoActivity.class);
|
||||
startActivity(nii);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
21
src/i2p/bote/android/NetworkInfoActivity.java
Normal file
21
src/i2p/bote/android/NetworkInfoActivity.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package i2p.bote.android;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
|
||||
public class NetworkInfoActivity extends ActionBarActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setTitle(R.string.compose);
|
||||
|
||||
// Enable ActionBar app icon to behave as action to go back
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
NetworkInfoFragment f = new NetworkInfoFragment();
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.add(android.R.id.content, f).commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
48
src/i2p/bote/android/NetworkInfoFragment.java
Normal file
48
src/i2p/bote/android/NetworkInfoFragment.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package i2p.bote.android;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import net.i2p.data.Destination;
|
||||
import i2p.bote.I2PBote;
|
||||
import i2p.bote.Util;
|
||||
import i2p.bote.network.BannedPeer;
|
||||
import i2p.bote.network.DhtPeerStats;
|
||||
import i2p.bote.network.RelayPeer;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class NetworkInfoFragment extends Fragment {
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_network_info, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
Destination dest = I2PBote.getInstance().getLocalDestination();
|
||||
if (dest != null)
|
||||
((TextView) view.findViewById(R.id.local_destination)).setText(
|
||||
Util.toBase32(dest));
|
||||
|
||||
DhtPeerStats dhtStats = I2PBote.getInstance().getDhtStats();
|
||||
if (dhtStats != null)
|
||||
((TextView) view.findViewById(R.id.kademlia_peers)).setText(
|
||||
"" + dhtStats.getData().size());
|
||||
|
||||
Set<RelayPeer> relayPeers = I2PBote.getInstance().getRelayPeers();
|
||||
((TextView) view.findViewById(R.id.relay_peers)).setText(
|
||||
"" + relayPeers.size());
|
||||
|
||||
Collection<BannedPeer> bannedPeers = I2PBote.getInstance().getBannedPeers();
|
||||
((TextView) view.findViewById(R.id.banned_peers)).setText(
|
||||
"" + bannedPeers.size());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user