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
49d92809
Commit
49d92809
authored
Mar 26, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ContactAddFragment: account selector used both in list header and as separate view.
parent
cf537c65
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
76 deletions
+118
-76
ContactAddFragment.java
...c/main/java/com/xabber/android/ui/ContactAddFragment.java
+50
-33
account_select_spinner.xml
app/src/main/res/layout/account_select_spinner.xml
+19
-0
contact_add_fragment.xml
app/src/main/res/layout/contact_add_fragment.xml
+24
-0
contact_add_header.xml
app/src/main/res/layout/contact_add_header.xml
+25
-43
No files found.
app/src/main/java/com/xabber/android/ui/ContactAddFragment.java
View file @
49d92809
...
...
@@ -5,6 +5,7 @@ import android.content.Context;
import
android.os.Bundle
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.AdapterView
;
import
android.widget.EditText
;
import
android.widget.Spinner
;
...
...
@@ -31,9 +32,10 @@ public class ContactAddFragment extends GroupEditorFragment implements AdapterVi
private
Spinner
accountView
;
private
EditText
userView
;
private
EditText
nameView
;
private
View
accountSpecificPanel
;
Listener
listenerActivity
;
private
String
name
;
private
View
accountSelectorPanel
;
public
static
ContactAddFragment
newInstance
(
String
account
,
String
user
)
{
ContactAddFragment
fragment
=
new
ContactAddFragment
();
...
...
@@ -51,26 +53,9 @@ public class ContactAddFragment extends GroupEditorFragment implements AdapterVi
}
@Override
public
void
onActivityCreated
(
Bundle
savedInstanceState
)
{
super
.
onActivityCreated
(
savedInstanceState
);
View
headerView
=
((
LayoutInflater
)
getActivity
().
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
))
.
inflate
(
R
.
layout
.
contact_add_header
,
null
,
false
);
getListView
().
addHeaderView
(
headerView
);
accountView
=
(
Spinner
)
headerView
.
findViewById
(
R
.
id
.
contact_account
);
accountView
.
setAdapter
(
new
AccountChooseAdapter
(
getActivity
()));
accountView
.
setOnItemSelectedListener
(
this
);
userView
=
(
EditText
)
headerView
.
findViewById
(
R
.
id
.
contact_user
);
nameView
=
(
EditText
)
headerView
.
findViewById
(
R
.
id
.
contact_name
);
accountSpecificPanel
=
headerView
.
findViewById
(
R
.
id
.
account_specific_panel
);
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
View
view
=
inflater
.
inflate
(
R
.
layout
.
contact_add_fragment
,
container
,
false
);
hideAdditionalInputs
();
String
name
;
if
(
savedInstanceState
!=
null
)
{
name
=
savedInstanceState
.
getString
(
SAVED_NAME
);
...
...
@@ -92,6 +77,19 @@ public class ContactAddFragment extends GroupEditorFragment implements AdapterVi
setAccount
(
accounts
.
iterator
().
next
());
}
}
accountSelectorPanel
=
view
.
findViewById
(
R
.
id
.
account_selector
);
setUpAccountView
((
Spinner
)
view
.
findViewById
(
R
.
id
.
contact_account
));
return
view
;
}
private
void
setUpAccountView
(
Spinner
view
)
{
accountView
=
view
;
accountView
.
setAdapter
(
new
AccountChooseAdapter
(
getActivity
()));
accountView
.
setOnItemSelectedListener
(
this
);
if
(
getAccount
()
!=
null
)
{
for
(
int
position
=
0
;
position
<
accountView
.
getCount
();
position
++)
{
if
(
getAccount
().
equals
(
accountView
.
getItemAtPosition
(
position
)))
{
...
...
@@ -100,18 +98,33 @@ public class ContactAddFragment extends GroupEditorFragment implements AdapterVi
}
}
}
}
@Override
public
void
onActivityCreated
(
Bundle
savedInstanceState
)
{
super
.
onActivityCreated
(
savedInstanceState
);
getListView
().
setVisibility
(
View
.
GONE
);
}
private
void
setUpListView
()
{
View
headerView
=
((
LayoutInflater
)
getActivity
().
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
))
.
inflate
(
R
.
layout
.
contact_add_header
,
null
,
false
);
getListView
().
addHeaderView
(
headerView
);
accountSelectorPanel
.
setVisibility
(
View
.
GONE
);
setUpAccountView
((
Spinner
)
headerView
.
findViewById
(
R
.
id
.
contact_account
));
userView
=
(
EditText
)
headerView
.
findViewById
(
R
.
id
.
contact_user
);
nameView
=
(
EditText
)
headerView
.
findViewById
(
R
.
id
.
contact_name
);
if
(
getUser
()
!=
null
)
{
userView
.
setText
(
getUser
());
}
if
(
name
!=
null
)
{
nameView
.
setText
(
name
);
}
}
private
void
hideAdditionalInputs
()
{
accountSpecificPanel
.
setVisibility
(
View
.
GONE
);
getFooterView
().
setVisibility
(
View
.
GONE
);
}
@Override
...
...
@@ -144,21 +157,25 @@ public class ContactAddFragment extends GroupEditorFragment implements AdapterVi
setAccountGroups
();
updateGroups
();
}
setAdditionalPanelVisibility
(
View
.
VISIBLE
);
}
}
private
void
setAdditionalPanelVisibility
(
int
visible
)
{
getFooterView
().
setVisibility
(
visible
);
accountSpecificPanel
.
setVisibility
(
visible
);
if
(
getListView
().
getVisibility
()
==
View
.
GONE
)
{
setUpListView
();
getListView
().
setVisibility
(
View
.
VISIBLE
);
}
}
}
@Override
public
void
onNothingSelected
(
AdapterView
<?>
parent
)
{
setAdditionalPanelVisibility
(
View
.
GONE
);
}
public
void
addContact
()
{
if
(
getAccount
()
==
null
)
{
Toast
.
makeText
(
getActivity
(),
getString
(
R
.
string
.
EMPTY_ACCOUNT
),
Toast
.
LENGTH_LONG
).
show
();
return
;
}
String
user
=
userView
.
getText
().
toString
();
if
(
""
.
equals
(
user
))
{
Toast
.
makeText
(
getActivity
(),
getString
(
R
.
string
.
EMPTY_USER_NAME
),
...
...
app/src/main/res/layout/account_select_spinner.xml
0 → 100644
View file @
49d92809
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<TextView
android:text=
"@string/contact_account"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
<com.xabber.android.ui.widget.NoDefaultSpinner
android:id=
"@+id/contact_account"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:prompt=
"@string/choose_account"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/contact_add_fragment.xml
0 → 100644
View file @
49d92809
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingRight=
"16dp"
android:paddingLeft=
"16dp"
android:paddingTop=
"16dp"
android:id=
"@+id/account_selector"
>
<include
layout=
"@layout/account_select_spinner"
/>
</FrameLayout>
<ListView
android:id=
"@android:id/list"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:drawSelectorOnTop=
"false"
>
</ListView>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/contact_add_header.xml
View file @
49d92809
...
...
@@ -22,59 +22,41 @@
android:paddingTop=
"16dp"
>
<include
layout=
"@layout/account_select_spinner"
/>
<TextView
android:text=
"@string/contact_
account
"
android:text=
"@string/contact_
user
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
<com.xabber.android.ui.widget.NoDefaultSpinner
android:id=
"@+id/contact_
account
"
<EditText
android:text=
""
android:id=
"@+id/contact_
user
"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:prompt=
"@string/choose_account"
android:hint=
"user@domain.name"
android:singleLine=
"true"
android:inputType=
"textEmailAddress"
/>
<LinearLayout
android:id=
"@+id/account_specific_panel"
<TextView
android:text=
"@string/contact_name"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
<EditText
android:text=
""
android:id=
"@+id/contact_name"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<TextView
android:text=
"@string/contact_user"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
<EditText
android:text=
""
android:id=
"@+id/contact_user"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:hint=
"user@domain.name"
android:singleLine=
"true"
android:inputType=
"textEmailAddress"
/>
<TextView
android:text=
"@string/contact_name"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
<EditText
android:text=
""
android:id=
"@+id/contact_name"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:singleLine=
"true"
/>
android:singleLine=
"true"
/>
<TextView
android:id=
"@+id/select_groups_text_view"
android:text=
"@string/contact_group"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
<TextView
android:id=
"@+id/select_groups_text_view"
android:text=
"@string/contact_group"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
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