Commit 7dca2c1a authored by Grigory Fedorov's avatar Grigory Fedorov

BaseListEditor, AccountList and PhraseList: xml resources used to create options menu.

parent 4b73b403
...@@ -44,7 +44,6 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements ...@@ -44,7 +44,6 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements
private static final String SAVED_ACTION_WITH = "com.xabber.android.ui.BaseListActivity.SAVED_ACTION_WITH"; private static final String SAVED_ACTION_WITH = "com.xabber.android.ui.BaseListActivity.SAVED_ACTION_WITH";
private static final int OPTION_MENU_ADD_ID = Menu.FIRST;
private static final int CONTEXT_MENU_DELETE_ID = 0x10; private static final int CONTEXT_MENU_DELETE_ID = 0x10;
private static final int DIALOG_DELETE_ID = 0x100; private static final int DIALOG_DELETE_ID = 0x100;
...@@ -83,7 +82,9 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements ...@@ -83,7 +82,9 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements
protected abstract void putSavedValue(Bundle bundle, String key, protected abstract void putSavedValue(Bundle bundle, String key,
T actionWith); T actionWith);
protected abstract int getAddTextResourceId(); protected abstract int getOptionsMenuId();
protected abstract int getAddActionId();
protected abstract Intent getAddIntent(); protected abstract Intent getAddIntent();
...@@ -117,10 +118,8 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements ...@@ -117,10 +118,8 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);
menu.add(0, OPTION_MENU_ADD_ID, 0, getString(getAddTextResourceId())) getMenuInflater().inflate(getOptionsMenuId(), menu);
.setIcon(R.drawable.ic_add_white_24dp) menu.findItem(getAddActionId()).setIntent(getAddIntent());
.setIntent(getAddIntent())
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
return true; return true;
} }
......
...@@ -49,8 +49,13 @@ public class AccountList extends BaseListEditor<String> implements ...@@ -49,8 +49,13 @@ public class AccountList extends BaseListEditor<String> implements
} }
@Override @Override
protected int getAddTextResourceId() { protected int getOptionsMenuId() {
return R.string.account_add; return R.menu.add_account;
}
@Override
protected int getAddActionId() {
return R.id.action_add_account;
} }
@Override @Override
......
...@@ -35,8 +35,13 @@ public class PhraseList extends BaseListEditor<Integer> { ...@@ -35,8 +35,13 @@ public class PhraseList extends BaseListEditor<Integer> {
} }
@Override @Override
protected int getAddTextResourceId() { protected int getOptionsMenuId() {
return R.string.phrase_add; return R.menu.add_phrase;
}
@Override
protected int getAddActionId() {
return R.id.action_add_phrase;
} }
@Override @Override
......
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_add_account"
android:title="@string/account_add"
app:showAsAction="always"
android:icon="@drawable/ic_add_white_24dp"/>
</menu>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android"
<item android:id="@+id/action_add" xmlns:app="http://schemas.android.com/apk/res-auto">
android:title="Add" <item android:id="@+id/action_add_phrase"
android:orderInCategory="105" android:title="@string/phrase_add"
android:showAsAction="always" app:showAsAction="always"
android:icon="@drawable/ic_add_white_24dp"/> android:icon="@drawable/ic_add_white_24dp"/>
</menu> </menu>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment