Commit 117d7489 authored by Nguyen Cong's avatar Nguyen Cong

fix lost text when turn off then turn on screen, hide keyboard when change room chat

parent 13837af2
......@@ -36,6 +36,10 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
if (savedInstanceState == null) {
handleIntent(getIntent());
}
ConnectivityManager.getInstance(getApplicationContext()).keepAliveServer();
updateHostnameIfNeeded(rocketChatCache.getSelectedServerHostname());
updateRoomIdIfNeeded(rocketChatCache.getSelectedRoomId());
}
@Override
......@@ -148,10 +152,6 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
@Override
protected void onResume() {
super.onResume();
ConnectivityManager.getInstance(getApplicationContext()).keepAliveServer();
updateHostnameIfNeeded(rocketChatCache.getSelectedServerHostname());
updateRoomIdIfNeeded(rocketChatCache.getSelectedRoomId());
subscribeToConfigChanges();
}
......
......@@ -15,6 +15,7 @@ import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.fragment.chatroom.HomeFragment;
import chat.rocket.android.fragment.chatroom.RoomFragment;
import chat.rocket.android.fragment.sidebar.SidebarMainFragment;
import chat.rocket.android.helper.KeyboardHelper;
import chat.rocket.core.interactors.CanCreateRoomInteractor;
import chat.rocket.core.interactors.RoomInteractor;
import chat.rocket.core.interactors.SessionInteractor;
......@@ -51,7 +52,7 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
@Override
protected void onPause() {
if (presenter != null) {
presenter.release();
// presenter.release();
}
super.onPause();
......@@ -172,6 +173,8 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
public void showRoom(String hostname, String roomId) {
showFragment(RoomFragment.create(hostname, roomId));
closeSidebarIfNeeded();
//TODO: Hide keyboard
KeyboardHelper.hideSoftKeyboard(this);
}
@Override
......
package chat.rocket.android.helper;
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
public class KeyboardHelper {
public static void hideSoftKeyboard(Activity activity) {
if (activity.getCurrentFocus() != null) {
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
}
}
public static void showSoftKeyboard(View view) {
InputMethodManager inputMethodManager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
view.requestFocus();
inputMethodManager.showSoftInput(view, 0);
}
public static void toggleKeyBoard(Context context) {
InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
}
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