Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-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
AloqaIM-Android
Commits
4fc1e719
Commit
4fc1e719
authored
Dec 12, 2017
by
Aniket
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:dismiss soft keyboard on pressing submit button in server url fragment
parent
21c0f5b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
86 deletions
+96
-86
InputHostnameFragment.java
...et/android/fragment/add_server/InputHostnameFragment.java
+96
-86
No files found.
app/src/main/java/chat/rocket/android/fragment/add_server/InputHostnameFragment.java
View file @
4fc1e719
...
...
@@ -6,6 +6,7 @@ import android.support.annotation.Nullable;
import
android.support.constraint.ConstraintLayout
;
import
android.support.design.widget.Snackbar
;
import
android.view.View
;
import
android.view.inputmethod.InputMethodManager
;
import
android.widget.TextView
;
import
chat.rocket.android.BuildConfig
;
...
...
@@ -21,90 +22,99 @@ import chat.rocket.android.service.ConnectivityManager;
*/
public
class
InputHostnameFragment
extends
AbstractFragment
implements
InputHostnameContract
.
View
{
private
InputHostnameContract
.
Presenter
presenter
;
private
ConstraintLayout
container
;
private
View
waitingView
;
public
InputHostnameFragment
()
{}
@Override
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
Context
appContext
=
getContext
().
getApplicationContext
();
presenter
=
new
InputHostnamePresenter
(
new
RocketChatCache
(
appContext
),
ConnectivityManager
.
getInstance
(
appContext
));
}
@Override
protected
int
getLayout
()
{
return
R
.
layout
.
fragment_input_hostname
;
}
@Override
protected
void
onSetupView
()
{
setupVersionInfo
();
container
=
rootView
.
findViewById
(
R
.
id
.
container
);
waitingView
=
rootView
.
findViewById
(
R
.
id
.
waiting
);
rootView
.
findViewById
(
R
.
id
.
btn_connect
).
setOnClickListener
(
view
->
handleConnect
());
}
private
void
setupVersionInfo
()
{
TextView
versionInfoView
=
(
TextView
)
rootView
.
findViewById
(
R
.
id
.
version_info
);
versionInfoView
.
setText
(
getString
(
R
.
string
.
version_info_text
,
BuildConfig
.
VERSION_NAME
));
}
private
void
handleConnect
()
{
presenter
.
connectTo
(
getHostname
());
}
@Override
public
void
onViewCreated
(
View
view
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
presenter
.
bindView
(
this
);
}
@Override
public
void
onDestroyView
()
{
presenter
.
release
();
super
.
onDestroyView
();
}
private
String
getHostname
()
{
final
TextView
editor
=
(
TextView
)
rootView
.
findViewById
(
R
.
id
.
editor_hostname
);
return
TextUtils
.
or
(
TextUtils
.
or
(
editor
.
getText
(),
editor
.
getHint
()),
""
).
toString
().
toLowerCase
();
}
private
void
showError
(
String
errString
)
{
Snackbar
.
make
(
rootView
,
errString
,
Snackbar
.
LENGTH_LONG
).
show
();
}
@Override
public
void
showLoader
()
{
container
.
setVisibility
(
View
.
GONE
);
waitingView
.
setVisibility
(
View
.
VISIBLE
);
}
@Override
public
void
hideLoader
()
{
waitingView
.
setVisibility
(
View
.
GONE
);
container
.
setVisibility
(
View
.
VISIBLE
);
}
@Override
public
void
showInvalidServerError
()
{
showError
(
getString
(
R
.
string
.
input_hostname_invalid_server_message
));
}
@Override
public
void
showConnectionError
()
{
showError
(
getString
(
R
.
string
.
connection_error_try_later
));
}
@Override
public
void
showHome
()
{
LaunchUtil
.
showMainActivity
(
getContext
());
getActivity
().
overridePendingTransition
(
android
.
R
.
anim
.
fade_in
,
android
.
R
.
anim
.
fade_out
);
}
private
InputHostnameContract
.
Presenter
presenter
;
private
ConstraintLayout
container
;
private
View
waitingView
;
public
InputHostnameFragment
()
{
}
@Override
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
Context
appContext
=
getContext
().
getApplicationContext
();
presenter
=
new
InputHostnamePresenter
(
new
RocketChatCache
(
appContext
),
ConnectivityManager
.
getInstance
(
appContext
));
}
@Override
protected
int
getLayout
()
{
return
R
.
layout
.
fragment_input_hostname
;
}
@Override
protected
void
onSetupView
()
{
setupVersionInfo
();
container
=
rootView
.
findViewById
(
R
.
id
.
container
);
waitingView
=
rootView
.
findViewById
(
R
.
id
.
waiting
);
rootView
.
findViewById
(
R
.
id
.
btn_connect
).
setOnClickListener
(
view
->
handleConnect
());
}
private
void
setupVersionInfo
()
{
TextView
versionInfoView
=
(
TextView
)
rootView
.
findViewById
(
R
.
id
.
version_info
);
versionInfoView
.
setText
(
getString
(
R
.
string
.
version_info_text
,
BuildConfig
.
VERSION_NAME
));
}
private
void
handleConnect
()
{
hideSoftKeyboard
();
presenter
.
connectTo
(
getHostname
());
}
private
void
hideSoftKeyboard
()
{
InputMethodManager
inputManager
=
(
InputMethodManager
)
getActivity
().
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
inputManager
.
hideSoftInputFromWindow
(
getActivity
().
getCurrentFocus
().
getWindowToken
(),
InputMethodManager
.
HIDE_NOT_ALWAYS
);
}
@Override
public
void
onViewCreated
(
View
view
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
presenter
.
bindView
(
this
);
}
@Override
public
void
onDestroyView
()
{
presenter
.
release
();
super
.
onDestroyView
();
}
private
String
getHostname
()
{
final
TextView
editor
=
(
TextView
)
rootView
.
findViewById
(
R
.
id
.
editor_hostname
);
return
TextUtils
.
or
(
TextUtils
.
or
(
editor
.
getText
(),
editor
.
getHint
()),
""
).
toString
().
toLowerCase
();
}
private
void
showError
(
String
errString
)
{
Snackbar
.
make
(
rootView
,
errString
,
Snackbar
.
LENGTH_LONG
).
show
();
}
@Override
public
void
showLoader
()
{
container
.
setVisibility
(
View
.
GONE
);
waitingView
.
setVisibility
(
View
.
VISIBLE
);
}
@Override
public
void
hideLoader
()
{
waitingView
.
setVisibility
(
View
.
GONE
);
container
.
setVisibility
(
View
.
VISIBLE
);
}
@Override
public
void
showInvalidServerError
()
{
showError
(
getString
(
R
.
string
.
input_hostname_invalid_server_message
));
}
@Override
public
void
showConnectionError
()
{
showError
(
getString
(
R
.
string
.
connection_error_try_later
));
}
@Override
public
void
showHome
()
{
LaunchUtil
.
showMainActivity
(
getContext
());
getActivity
().
overridePendingTransition
(
android
.
R
.
anim
.
fade_in
,
android
.
R
.
anim
.
fade_out
);
}
}
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