Simple network info page

This commit is contained in:
str4d
2014-05-17 03:46:27 +00:00
parent b648c1e369
commit a132e7e077
6 changed files with 131 additions and 1 deletions

View File

@@ -37,6 +37,9 @@
<activity <activity
android:name="i2p.bote.android.addressbook.EditContactActivity" android:name="i2p.bote.android.addressbook.EditContactActivity"
android:parentActivityName="i2p.bote.android.addressbook.AddressBookActivity" /> android:parentActivityName="i2p.bote.android.addressbook.AddressBookActivity" />
<activity
android:name="i2p.bote.android.NetworkInfoActivity"
android:parentActivityName="i2p.bote.android.EmailListActivity" />
<activity <activity
android:name="i2p.bote.android.config.SettingsActivity" android:name="i2p.bote.android.config.SettingsActivity"
android:parentActivityName="i2p.bote.android.EmailListActivity" /> android:parentActivityName="i2p.bote.android.EmailListActivity" />

View 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>

View File

@@ -58,6 +58,12 @@
<string name="label_browse">Browse</string> <string name="label_browse">Browse</string>
<string name="save_contact">Save contact</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_title_general">General</string>
<string name="pref_summ_general">General settings and default identity settings</string> <string name="pref_summ_general">General settings and default identity settings</string>
<string name="pref_title_autoMail">Auto-check mail</string> <string name="pref_title_autoMail">Auto-check mail</string>

View File

@@ -164,7 +164,8 @@ public class EmailListActivity extends ActionBarActivity implements
}); });
mNetworkStatus.setOnClickListener(new View.OnClickListener() { mNetworkStatus.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) { public void onClick(View view) {
// TODO: network status page Intent nii = new Intent(EmailListActivity.this, NetworkInfoActivity.class);
startActivity(nii);
} }
}); });

View 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();
}
}
}

View 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());
}
}