Mercurial > 510Connectbot
diff src/com/five_ten_sg/connectbot/util/StringPickerDialog.java @ 308:42b15aaa7ac7 ganymed
merge
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 30 Jul 2014 14:21:50 -0700 |
parents | 071eccdff8ea |
children |
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/util/StringPickerDialog.java Wed Jul 30 13:38:04 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/util/StringPickerDialog.java Wed Jul 30 14:21:50 2014 -0700 @@ -38,7 +38,7 @@ * Dialog for choosing accented characters related to a base character. */ public class StringPickerDialog extends Dialog - implements OnItemClickListener, OnClickListener { + implements OnItemClickListener, OnClickListener { private View mView; private Editable mText; private String []mOptions; @@ -52,10 +52,9 @@ * the sense of <code>insert</code>) into <code>text</code>. */ public StringPickerDialog(Context context, View view, - Editable text, String []options, - boolean insert) { + Editable text, String []options, + boolean insert) { //super(context, com.android.internal.R.style.Theme_Panel); - //Resources res = Resources.getSystem(); //int id = res.getIdentifier("Theme_Panel", "style", "android"); //int id = android.R.style.Theme_Panel; @@ -70,18 +69,14 @@ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - WindowManager.LayoutParams params = getWindow().getAttributes(); params.token = mView.getApplicationWindowToken(); params.type = params.TYPE_APPLICATION_ATTACHED_DIALOG; params.flags = params.flags | Window.FEATURE_NO_TITLE; - setContentView(R.layout.string_picker); - GridView grid = (GridView) findViewById(R.id.stringPicker); grid.setAdapter(new OptionsAdapter(getContext())); grid.setOnItemClickListener(this); - mCancelButton = (Button) findViewById(R.id.cancel); mCancelButton.setOnClickListener(this); } @@ -96,9 +91,11 @@ private void replaceCharacterAndClose(CharSequence replace) { int selEnd = Selection.getSelectionEnd(mText); + if (mInsert || selEnd == 0) { mText.insert(selEnd, replace); - } else { + } + else { mText.replace(selEnd - 1, selEnd, replace); } @@ -111,7 +108,8 @@ public void onClick(View v) { if (v == mCancelButton) { dismiss(); - } else if (v instanceof Button) { + } + else if (v instanceof Button) { CharSequence result = ((Button) v).getText(); replaceCharacterAndClose(result); } @@ -125,7 +123,7 @@ public View getView(int position, View convertView, ViewGroup parent) { Button b = (Button) - mInflater.inflate(R.layout.string_picker_button, null); + mInflater.inflate(R.layout.string_picker_button, null); b.setText(mOptions[position]); b.setOnClickListener(StringPickerDialog.this); return b;