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);
// 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();
}

View file

@ -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"/>
<View
style="@style/Divider"

View file

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

View file

@ -69,8 +69,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"/>
<View
style="@style/Divider"

View file

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