Bugfixes: Keyboard hides after convert; cursor is now shown

This commit is contained in:
mmk2410 2015-05-19 18:10:12 +02:00
parent 9a8059577e
commit 20badbff2b
5 changed files with 21 additions and 18 deletions

View file

@ -109,15 +109,7 @@ public class MainActivity extends MaterialNavigationDrawer implements BillingPro
super.onDrawerOpened(view); super.onDrawerOpened(view);
// This closes the soft keyboard, when the drawer is opened // This closes the soft keyboard, when the drawer is opened
try { try {
InputMethodManager imm = (InputMethodManager) getSystemService( closeKeyboard();
Context.INPUT_METHOD_SERVICE);
if (getCurrentSection() == writtenMorse) {
EditText myEditText = (EditText) findViewById(R.id.editTextWrittenMorse);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
} else if (getCurrentSection() == normalMorse) {
EditText myEditText = (EditText) findViewById(R.id.editTextNormalMorse);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
}
} catch (Exception e){ } catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
@ -174,6 +166,18 @@ public class MainActivity extends MaterialNavigationDrawer implements BillingPro
super.onDestroy(); super.onDestroy();
} }
public void closeKeyboard(){
InputMethodManager imm = (InputMethodManager) getSystemService(
Context.INPUT_METHOD_SERVICE);
if (getCurrentSection() == writtenMorse) {
EditText myEditText = (EditText) findViewById(R.id.editTextWrittenMorse);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
} else if (getCurrentSection() == normalMorse) {
EditText myEditText = (EditText) findViewById(R.id.editTextNormalMorse);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
}
}
public void normalMorseEncode(View view){ public void normalMorseEncode(View view){
try{ try{
EditText input = (EditText) findViewById(R.id.editTextNormalMorse); EditText input = (EditText) findViewById(R.id.editTextNormalMorse);
@ -183,6 +187,7 @@ public class MainActivity extends MaterialNavigationDrawer implements BillingPro
cardView.setVisibility(View.VISIBLE); cardView.setVisibility(View.VISIBLE);
} }
output.setText(EncodeNormalMorseManager.getEncodedString(input.getText().toString())); output.setText(EncodeNormalMorseManager.getEncodedString(input.getText().toString()));
closeKeyboard();
} catch (Exception e){ } catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
@ -197,7 +202,7 @@ public class MainActivity extends MaterialNavigationDrawer implements BillingPro
cardView.setVisibility(View.VISIBLE); cardView.setVisibility(View.VISIBLE);
} }
output.setText(DecodeNormalMorseManager.getDecodedString(input.getText().toString())); output.setText(DecodeNormalMorseManager.getDecodedString(input.getText().toString()));
closeKeyboard();
} catch (Exception e){ } catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
@ -212,6 +217,7 @@ public class MainActivity extends MaterialNavigationDrawer implements BillingPro
cardView.setVisibility(View.VISIBLE); cardView.setVisibility(View.VISIBLE);
} }
output.setText(EncodeWrittenMorseManager.getEncodedString(input.getText().toString())); output.setText(EncodeWrittenMorseManager.getEncodedString(input.getText().toString()));
closeKeyboard();
} catch (Exception e){ } catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
@ -226,6 +232,7 @@ public class MainActivity extends MaterialNavigationDrawer implements BillingPro
cardView.setVisibility(View.VISIBLE); cardView.setVisibility(View.VISIBLE);
} }
output.setText(DecodeWrittenMorseManager.getDecodedString(input.getText().toString())); output.setText(DecodeWrittenMorseManager.getDecodedString(input.getText().toString()));
closeKeyboard();
} catch (Exception e){ } catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -70,8 +70,7 @@
android:scrollbars="vertical" android:scrollbars="vertical"
android:minLines="5" android:minLines="5"
android:singleLine="false" android:singleLine="false"
android:background="@color/cardview_light_background" android:background="@color/cardview_light_background"/>
android:textCursorDrawable="@color/colorPrimary"/>
<View <View
style="@style/Divider" style="@style/Divider"

View file

@ -70,8 +70,7 @@
android:ems="10" android:ems="10"
android:hint="@string/edit_message" android:hint="@string/edit_message"
android:background="@color/cardview_light_background" android:background="@color/cardview_light_background"
android:minLines="5" android:minLines="5">
android:textCursorDrawable="@color/colorPrimary">
</EditText> </EditText>
<View <View

View file

@ -69,8 +69,7 @@
android:scrollbars="vertical" android:scrollbars="vertical"
android:minLines="5" android:minLines="5"
android:singleLine="false" android:singleLine="false"
android:background="@color/cardview_light_background" android:background="@color/cardview_light_background"/>
android:textCursorDrawable="@color/colorPrimary"/>
<View <View
style="@style/Divider" style="@style/Divider"

View file

@ -69,8 +69,7 @@
android:ems="10" android:ems="10"
android:hint="@string/edit_message" android:hint="@string/edit_message"
android:background="@color/cardview_light_background" android:background="@color/cardview_light_background"
android:minLines="5" android:minLines="5">
android:textCursorDrawable="@color/colorPrimary">
</EditText> </EditText>
<View <View