Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
xabber-android
Commits
7dca2c1a
Commit
7dca2c1a
authored
Jan 19, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BaseListEditor, AccountList and PhraseList: xml resources used to create options menu.
parent
4b73b403
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
23 deletions
+48
-23
BaseListEditor.java
...ain/java/com/xabber/android/ui/helper/BaseListEditor.java
+12
-13
AccountList.java
...n/java/com/xabber/android/ui/preferences/AccountList.java
+10
-5
PhraseList.java
...in/java/com/xabber/android/ui/preferences/PhraseList.java
+10
-5
add_account.xml
app/src/main/res/menu/add_account.xml
+8
-0
add_phrase.xml
app/src/main/res/menu/add_phrase.xml
+8
-0
No files found.
app/src/main/java/com/xabber/android/ui/helper/BaseListEditor.java
View file @
7dca2c1a
...
...
@@ -44,8 +44,7 @@ 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
CONTEXT_MENU_DELETE_ID
=
0x10
;
private
static
final
int
DIALOG_DELETE_ID
=
0x100
;
private
T
actionWith
;
...
...
@@ -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
();
...
...
@@ -114,17 +115,15 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements
putSavedValue
(
outState
,
SAVED_ACTION_WITH
,
actionWith
);
}
@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
);
return
true
;
}
@Override
public
boolean
onCreateOptionsMenu
(
Menu
menu
)
{
super
.
onCreateOptionsMenu
(
menu
);
getMenuInflater
().
inflate
(
getOptionsMenuId
(),
menu
);
menu
.
findItem
(
getAddActionId
()).
setIntent
(
getAddIntent
());
return
true
;
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
@Override
public
void
onCreateContextMenu
(
ContextMenu
menu
,
View
v
,
ContextMenuInfo
menuInfo
)
{
...
...
app/src/main/java/com/xabber/android/ui/preferences/AccountList.java
View file @
7dca2c1a
...
...
@@ -49,11 +49,16 @@ public class AccountList extends BaseListEditor<String> implements
}
@Override
protected
int
getAddTextResource
Id
()
{
return
R
.
string
.
account_add
;
}
protected
int
getOptionsMenu
Id
()
{
return
R
.
menu
.
add_account
;
}
@Override
@Override
protected
int
getAddActionId
()
{
return
R
.
id
.
action_add_account
;
}
@Override
protected
Intent
getAddIntent
()
{
return
AccountAdd
.
createIntent
(
this
);
}
...
...
@@ -142,7 +147,7 @@ public class AccountList extends BaseListEditor<String> implements
bundle
.
putString
(
key
,
actionWith
);
}
public
static
Intent
createIntent
(
Context
context
)
{
public
static
Intent
createIntent
(
Context
context
)
{
return
new
Intent
(
context
,
AccountList
.
class
);
}
...
...
app/src/main/java/com/xabber/android/ui/preferences/PhraseList.java
View file @
7dca2c1a
...
...
@@ -35,11 +35,16 @@ public class PhraseList extends BaseListEditor<Integer> {
}
@Override
protected
int
getAddTextResource
Id
()
{
return
R
.
string
.
phrase_add
;
}
protected
int
getOptionsMenu
Id
()
{
return
R
.
menu
.
add_phrase
;
}
@Override
@Override
protected
int
getAddActionId
()
{
return
R
.
id
.
action_add_phrase
;
}
@Override
protected
Intent
getAddIntent
()
{
return
PhraseEditor
.
createIntent
(
this
);
}
...
...
@@ -83,7 +88,7 @@ public class PhraseList extends BaseListEditor<Integer> {
bundle
.
putInt
(
key
,
actionWith
);
}
public
static
Intent
createIntent
(
Context
context
)
{
public
static
Intent
createIntent
(
Context
context
)
{
return
new
Intent
(
context
,
PhraseList
.
class
);
}
...
...
app/src/main/res/menu/add_account.xml
0 → 100644
View file @
7dca2c1a
<?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
app/src/main/res/menu/add.xml
→
app/src/main/res/menu/add
_phrase
.xml
View file @
7dca2c1a
<?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
"
a
ndroid
: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
"
a
pp
:showAsAction=
"always"
android:icon=
"@drawable/ic_add_white_24dp"
/>
</menu>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment