From 20badbff2bb95420295bb1ab0ab6729eb5ee0999 Mon Sep 17 00:00:00 2001 From: mmk2410 Date: Tue, 19 May 2015 18:10:12 +0200 Subject: [PATCH] Bugfixes: Keyboard hides after convert; cursor is now shown --- .../morseconverter/MainActivity.java | 27 ++++++++++++------- .../res/layout-large-land/fragment_main.xml | 3 +-- .../res/layout-large-land/fragment_morse.xml | 3 +-- app/src/main/res/layout/fragment_main.xml | 3 +-- app/src/main/res/layout/fragment_morse.xml | 3 +-- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/de/marcelkapfer/morseconverter/MainActivity.java b/app/src/main/java/de/marcelkapfer/morseconverter/MainActivity.java index 34ff622..bb812c6 100644 --- a/app/src/main/java/de/marcelkapfer/morseconverter/MainActivity.java +++ b/app/src/main/java/de/marcelkapfer/morseconverter/MainActivity.java @@ -109,15 +109,7 @@ public class MainActivity extends MaterialNavigationDrawer implements BillingPro super.onDrawerOpened(view); // This closes the soft keyboard, when the drawer is opened try { - 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); - } + closeKeyboard(); } catch (Exception e){ e.printStackTrace(); } @@ -174,6 +166,18 @@ public class MainActivity extends MaterialNavigationDrawer implements BillingPro 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){ try{ EditText input = (EditText) findViewById(R.id.editTextNormalMorse); @@ -183,6 +187,7 @@ public class MainActivity extends MaterialNavigationDrawer implements BillingPro cardView.setVisibility(View.VISIBLE); } output.setText(EncodeNormalMorseManager.getEncodedString(input.getText().toString())); + closeKeyboard(); } catch (Exception e){ e.printStackTrace(); } @@ -197,7 +202,7 @@ public class MainActivity extends MaterialNavigationDrawer implements BillingPro cardView.setVisibility(View.VISIBLE); } output.setText(DecodeNormalMorseManager.getDecodedString(input.getText().toString())); - + closeKeyboard(); } catch (Exception e){ e.printStackTrace(); } @@ -212,6 +217,7 @@ public class MainActivity extends MaterialNavigationDrawer implements BillingPro cardView.setVisibility(View.VISIBLE); } output.setText(EncodeWrittenMorseManager.getEncodedString(input.getText().toString())); + closeKeyboard(); } catch (Exception e){ e.printStackTrace(); } @@ -226,6 +232,7 @@ public class MainActivity extends MaterialNavigationDrawer implements BillingPro cardView.setVisibility(View.VISIBLE); } output.setText(DecodeWrittenMorseManager.getDecodedString(input.getText().toString())); + closeKeyboard(); } catch (Exception e){ e.printStackTrace(); } diff --git a/app/src/main/res/layout-large-land/fragment_main.xml b/app/src/main/res/layout-large-land/fragment_main.xml index d28e1df..00e537b 100644 --- a/app/src/main/res/layout-large-land/fragment_main.xml +++ b/app/src/main/res/layout-large-land/fragment_main.xml @@ -70,8 +70,7 @@ android:scrollbars="vertical" android:minLines="5" android:singleLine="false" - android:background="@color/cardview_light_background" - android:textCursorDrawable="@color/colorPrimary"/> + android:background="@color/cardview_light_background"/> + android:minLines="5"> + android:background="@color/cardview_light_background"/> + android:minLines="5">