diff --git a/res/raw/router_config b/res/raw/router_config index 761dc98663e74fdde02df37daecf0b37400c6545..3cb424459eff3f3870ff9c84fc2cd0fae47460b9 100644 --- a/res/raw/router_config +++ b/res/raw/router_config @@ -26,7 +26,7 @@ i2cp.disableInterface=true # Todo: implement a NamingService using the android native SQLite # i2p.naming.impl=net.i2p.client.naming.HostsTxtNamingService -i2p.hostsfilelist=hosts.txt +i2p.hostsfilelist=privatehosts.txt,hosts.txt # ##### Tunnels # diff --git a/src/net/i2p/android/router/activity/AddressbookActivity.java b/src/net/i2p/android/router/activity/AddressbookActivity.java index c89e4ac5c48ae99cd51ccbdf3df6fe710dc06a0d..9716c2638750e21fcbd6675a5c683f647dd63ec0 100644 --- a/src/net/i2p/android/router/activity/AddressbookActivity.java +++ b/src/net/i2p/android/router/activity/AddressbookActivity.java @@ -44,7 +44,8 @@ public class AddressbookActivity extends I2PActivityBase // Router book tab AddressbookFragment rf = new AddressbookFragment(); Bundle args = new Bundle(); - args.putString(AddressbookFragment.BOOK_NAME, "router"); + args.putString(AddressbookFragment.BOOK_NAME, + AddressbookFragment.ROUTER_BOOK); rf.setArguments(args); Tab tab = actionBar.newTab() .setText("Router") @@ -54,7 +55,8 @@ public class AddressbookActivity extends I2PActivityBase // Private book tab AddressbookFragment pf = new AddressbookFragment(); args = new Bundle(); - args.putString(AddressbookFragment.BOOK_NAME, "private"); + args.putString(AddressbookFragment.BOOK_NAME, + AddressbookFragment.PRIVATE_BOOK); pf.setArguments(args); tab = actionBar.newTab() .setText("Private") diff --git a/src/net/i2p/android/router/fragment/AddressbookFragment.java b/src/net/i2p/android/router/fragment/AddressbookFragment.java index a42df2855bf8ae25f87ce4400d393a9123e55c2f..173452689199429aa574df11ae7cacae57d91e05 100644 --- a/src/net/i2p/android/router/fragment/AddressbookFragment.java +++ b/src/net/i2p/android/router/fragment/AddressbookFragment.java @@ -1,7 +1,6 @@ package net.i2p.android.router.fragment; import android.app.Activity; -import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.ListFragment; @@ -14,8 +13,6 @@ import android.view.MenuItem; import android.view.View; import android.widget.ListView; import android.widget.TextView; -import android.widget.Toast; - import java.util.List; import net.i2p.android.router.R; import net.i2p.android.router.activity.AddressbookSettingsActivity; @@ -29,6 +26,8 @@ import net.i2p.router.RouterContext; public class AddressbookFragment extends ListFragment implements LoaderManager.LoaderCallbacks<List<AddressEntry>> { public static final String BOOK_NAME = "book_name"; + public static final String ROUTER_BOOK = "hosts.txt"; + public static final String PRIVATE_BOOK = "privatehosts.txt"; private static final int ROUTER_LOADER_ID = 1; private static final int PRIVATE_LOADER_ID = 2; @@ -84,12 +83,12 @@ public class AddressbookFragment extends ListFragment implements LoaderManager lm = getLoaderManager(); // If the Router is running, or there is an existing Loader - if (getRouterContext() != null || lm.getLoader("private".equals(mBook) ? + if (getRouterContext() != null || lm.getLoader(PRIVATE_BOOK.equals(mBook) ? PRIVATE_LOADER_ID : ROUTER_LOADER_ID) != null) { setEmptyText("No hosts in address book " + mBook); setListShown(false); - lm.initLoader("private".equals(mBook) ? + lm.initLoader(PRIVATE_BOOK.equals(mBook) ? PRIVATE_LOADER_ID : ROUTER_LOADER_ID, null, this); } else { setEmptyText(getResources().getString( @@ -132,7 +131,7 @@ public class AddressbookFragment extends ListFragment implements public void filterAddresses(String query) { mCurFilter = !TextUtils.isEmpty(query) ? query : null; setListShown(false); - getLoaderManager().restartLoader("private".equals(mBook) ? + getLoaderManager().restartLoader(PRIVATE_BOOK.equals(mBook) ? PRIVATE_LOADER_ID : ROUTER_LOADER_ID, null, this); } @@ -150,7 +149,7 @@ public class AddressbookFragment extends ListFragment implements public void onLoadFinished(Loader<List<AddressEntry>> loader, List<AddressEntry> data) { - if (loader.getId() == ("private".equals(mBook) ? + if (loader.getId() == (PRIVATE_BOOK.equals(mBook) ? PRIVATE_LOADER_ID : ROUTER_LOADER_ID)) { mAdapter.setData(data); @@ -163,7 +162,7 @@ public class AddressbookFragment extends ListFragment implements } public void onLoaderReset(Loader<List<AddressEntry>> loader) { - if (loader.getId() == ("private".equals(mBook) ? + if (loader.getId() == (PRIVATE_BOOK.equals(mBook) ? PRIVATE_LOADER_ID : ROUTER_LOADER_ID)) { mAdapter.setData(null); }