I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 07fafb03 authored by str4d's avatar str4d
Browse files

Added ActionBar to Addressbook, placeholder add action

parent e98f86b2
No related branches found
No related tags found
No related merge requests found
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
android:launchMode="singleTop" > android:launchMode="singleTop" >
</activity> </activity>
<activity android:name=".activity.AddressbookActivity" <activity android:name=".activity.AddressbookActivity"
android:label="I2P Address Book" android:label="Addressbook"
android:launchMode="singleTop" > android:launchMode="singleTop" >
</activity> </activity>
<activity android:name=".activity.LogActivity" <activity android:name=".activity.LogActivity"
......
res/drawable-hdpi/ic_content_new.png

1.12 KiB

res/drawable-xhdpi/ic_content_new.png

1.19 KiB

res/drawable/ic_content_new.png

1.06 KiB

<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/addressbook_list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:i2pandroid="http://schemas.android.com/apk/res-auto" >
<!-- Add, should appear as action buttons -->
<item android:id="@+id/action_add_to_addressbook"
android:title="@string/action_add"
android:icon="@drawable/ic_content_new"
i2pandroid:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
<item android:id="@+id/action_addressbook_settings"
android:title="@string/menu_settings"
i2pandroid:showAsAction="never" /></menu>
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
<string name="welcome_new_install">Welcome to I2P! This app is ALPHA software and it does not provide strong anonymity. Please read the release notes and license information.</string> <string name="welcome_new_install">Welcome to I2P! This app is ALPHA software and it does not provide strong anonymity. Please read the release notes and license information.</string>
<string name="welcome_new_version">New version installed. Please read the release notes. Version:</string> <string name="welcome_new_version">New version installed. Please read the release notes. Version:</string>
<string name="action_add">Add</string>
<string name="menu_settings">Settings</string> <string name="menu_settings">Settings</string>
<string name="settings_enable">Enable</string> <string name="settings_enable">Enable</string>
<string name="settings_label_subscriptions">I2P Addressbook</string> <string name="settings_label_subscriptions">I2P Addressbook</string>
......
...@@ -4,6 +4,10 @@ import android.app.ListActivity; ...@@ -4,6 +4,10 @@ import android.app.ListActivity;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
...@@ -18,11 +22,12 @@ import net.i2p.I2PAppContext; ...@@ -18,11 +22,12 @@ import net.i2p.I2PAppContext;
import net.i2p.android.router.R; import net.i2p.android.router.R;
import net.i2p.client.naming.NamingService; import net.i2p.client.naming.NamingService;
public class AddressbookActivity extends ListActivity { public class AddressbookActivity extends ActionBarActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_addressbook);
// Grab context if router has started, otherwise create new // Grab context if router has started, otherwise create new
// FIXME dup contexts, locking, ... // FIXME dup contexts, locking, ...
...@@ -49,14 +54,14 @@ public class AddressbookActivity extends ListActivity { ...@@ -49,14 +54,14 @@ public class AddressbookActivity extends ListActivity {
tv.setText("1 host in address book."); tv.setText("1 host in address book.");
else else
tv.setText("No hosts in address book, or your router is not up."); tv.setText("No hosts in address book, or your router is not up.");
ListView lv = getListView(); ListView lv = (ListView) findViewById(R.id.addressbook_list);
lv.addHeaderView(tv, "", false); lv.addHeaderView(tv, "", false);
lv.setTextFilterEnabled(sz > 1); lv.setTextFilterEnabled(sz > 1);
// set the list // set the list
List<String> nameList = new ArrayList<String>(names); List<String> nameList = new ArrayList<String>(names);
Collections.sort(nameList); Collections.sort(nameList);
setListAdapter(new ArrayAdapter<String>(this, R.layout.addressbook_list_item, nameList)); lv.setAdapter(new ArrayAdapter<String>(this, R.layout.addressbook_list_item, nameList));
// set the callback // set the callback
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
...@@ -68,4 +73,30 @@ public class AddressbookActivity extends ListActivity { ...@@ -68,4 +73,30 @@ public class AddressbookActivity extends ListActivity {
} }
}); });
} }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_addressbook_actions, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items
switch (item.getItemId()) {
case R.id.action_add_to_addressbook:
return true;
case R.id.action_addressbook_settings:
openSettings();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public void openSettings() {
Intent intent = new Intent(this, AddressbookSettingsActivity.class);
startActivity(intent);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment