Added ActionBar to Addressbook, placeholder add action
This commit is contained in:
@ -57,7 +57,7 @@
|
||||
android:launchMode="singleTop" >
|
||||
</activity>
|
||||
<activity android:name=".activity.AddressbookActivity"
|
||||
android:label="I2P Address Book"
|
||||
android:label="Addressbook"
|
||||
android:launchMode="singleTop" >
|
||||
</activity>
|
||||
<activity android:name=".activity.LogActivity"
|
||||
|
BIN
res/drawable-hdpi/ic_content_new.png
Normal file
BIN
res/drawable-hdpi/ic_content_new.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
res/drawable-xhdpi/ic_content_new.png
Normal file
BIN
res/drawable-xhdpi/ic_content_new.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
res/drawable/ic_content_new.png
Normal file
BIN
res/drawable/ic_content_new.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
8
res/layout/activity_addressbook.xml
Normal file
8
res/layout/activity_addressbook.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?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>
|
12
res/menu/activity_addressbook_actions.xml
Normal file
12
res/menu/activity_addressbook_actions.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?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 @@
|
||||
<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="action_add">Add</string>
|
||||
|
||||
<string name="menu_settings">Settings</string>
|
||||
<string name="settings_enable">Enable</string>
|
||||
<string name="settings_label_subscriptions">I2P Addressbook</string>
|
||||
|
@ -4,6 +4,10 @@ import android.app.ListActivity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
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.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
@ -18,11 +22,12 @@ import net.i2p.I2PAppContext;
|
||||
import net.i2p.android.router.R;
|
||||
import net.i2p.client.naming.NamingService;
|
||||
|
||||
public class AddressbookActivity extends ListActivity {
|
||||
public class AddressbookActivity extends ActionBarActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_addressbook);
|
||||
|
||||
// Grab context if router has started, otherwise create new
|
||||
// FIXME dup contexts, locking, ...
|
||||
@ -49,14 +54,14 @@ public class AddressbookActivity extends ListActivity {
|
||||
tv.setText("1 host in address book.");
|
||||
else
|
||||
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.setTextFilterEnabled(sz > 1);
|
||||
|
||||
// set the list
|
||||
List<String> nameList = new ArrayList<String>(names);
|
||||
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
|
||||
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user