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
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 DIALOG_DELETE_ID = 0x100;
......@@ -83,7 +82,9 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements
protected abstract void putSavedValue(Bundle bundle, String key,
T actionWith);
protected abstract int getAddTextResourceId();
protected abstract int getOptionsMenuId();
protected abstract int getAddActionId();
protected abstract Intent getAddIntent();
......@@ -117,10 +118,8 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, OPTION_MENU_ADD_ID, 0, getString(getAddTextResourceId()))
.setIcon(R.drawable.ic_add_white_24dp)
.setIntent(getAddIntent())
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
getMenuInflater().inflate(getOptionsMenuId(), menu);
menu.findItem(getAddActionId()).setIntent(getAddIntent());
return true;
}
......
......@@ -49,8 +49,13 @@ public class AccountList extends BaseListEditor<String> implements
}
@Override
protected int getAddTextResourceId() {
return R.string.account_add;
protected int getOptionsMenuId() {
return R.menu.add_account;
}
@Override
protected int getAddActionId() {
return R.id.action_add_account;
}
@Override
......
......@@ -35,8 +35,13 @@ public class PhraseList extends BaseListEditor<Integer> {
}
@Override
protected int getAddTextResourceId() {
return R.string.phrase_add;
protected int getOptionsMenuId() {
return R.menu.add_phrase;
}
@Override
protected int getAddActionId() {
return R.id.action_add_phrase;
}
@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"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/action_add"
android:title="Add"
android:orderInCategory="105"
android:showAsAction="always"
<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_phrase"
android:title="@string/phrase_add"
app:showAsAction="always"
android:icon="@drawable/ic_add_white_24dp"/>
</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