diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b8d6b8d1..afaadca0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="5" + android:versionName="0.5" > diff --git a/app/src/main/java/com/termux/api/DialogActivity.java b/app/src/main/java/com/termux/api/DialogActivity.java index 745e1b2f..3a8b7cf4 100644 --- a/app/src/main/java/com/termux/api/DialogActivity.java +++ b/app/src/main/java/com/termux/api/DialogActivity.java @@ -1,7 +1,5 @@ package com.termux.api; -import java.io.PrintWriter; - import android.app.Activity; import android.content.Intent; import android.os.Bundle; @@ -14,71 +12,86 @@ import com.termux.api.util.ResultReturner; import com.termux.api.util.ResultReturner.ResultWriter; +import java.io.PrintWriter; + public class DialogActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - requestWindowFeature(Window.FEATURE_NO_TITLE); - setContentView(R.layout.dialog_textarea_input); - } - @Override - protected void onNewIntent(Intent intent) { - super.onNewIntent(intent); - setIntent(intent); - } + String title = null; + Intent i = getIntent(); + if (i != null) { + title = i.getStringExtra("input_title"); + } - @Override - protected void onResume() { - super.onResume(); + if (title == null) { + requestWindowFeature(Window.FEATURE_NO_TITLE); + } else { + setTitle(title); + } + setContentView(R.layout.dialog_textarea_input); - EditText textInput = (EditText) findViewById(R.id.text_input); + EditText textInput = (EditText) findViewById(R.id.text_input); - String inputHint = getIntent().getStringExtra("input_hint"); - if (inputHint != null) { - textInput.setHint(inputHint); - } + boolean multiLine = getIntent().getBooleanExtra("multiple_lines", false); - String inputType = getIntent().getStringExtra("input_type"); - if ("password".equals(inputType)) { - textInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); - } + String inputHint = getIntent().getStringExtra("input_hint"); + if (inputHint != null) { + textInput.setHint(inputHint); + } + + String inputType = getIntent().getStringExtra("input_type"); + if ("password".equals(inputType)) { + textInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); + } else if (multiLine) { + textInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE); + } else { + textInput.setInputType(InputType.TYPE_CLASS_TEXT); + } findViewById(R.id.cancel_button).setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - ResultReturner.returnData(DialogActivity.this, getIntent(), new ResultWriter() { - @Override - public void writeResult(PrintWriter out) throws Exception { - runOnUiThread(new Runnable() { - @Override - public void run() { - finish(); - } - }); - } - }); - } - }); + @Override + public void onClick(View v) { + ResultReturner.returnData(DialogActivity.this, getIntent(), new ResultWriter() { + @Override + public void writeResult(PrintWriter out) throws Exception { + runOnUiThread(new Runnable() { + @Override + public void run() { + finish(); + } + }); + } + }); + } + }); + + findViewById(R.id.ok_button).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + ResultReturner.returnData(DialogActivity.this, getIntent(), new ResultWriter() { + @Override + public void writeResult(PrintWriter out) throws Exception { + String text = ((EditText) findViewById(R.id.text_input)).getText().toString(); + out.println(text.trim()); + runOnUiThread(new Runnable() { + @Override + public void run() { + finish(); + } + }); + } + }); + } + }); + } - findViewById(R.id.ok_button).setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - ResultReturner.returnData(DialogActivity.this, getIntent(), new ResultWriter() { - @Override - public void writeResult(PrintWriter out) throws Exception { - String text = ((EditText) findViewById(R.id.text_input)).getText().toString(); - out.println(text.trim()); - runOnUiThread(new Runnable() { - @Override - public void run() { - finish(); - } - }); - } - }); - } - }); + @Override + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + setIntent(intent); } + } diff --git a/app/src/main/res/layout/dialog_textarea_input.xml b/app/src/main/res/layout/dialog_textarea_input.xml index 00793744..2d1331c0 100644 --- a/app/src/main/res/layout/dialog_textarea_input.xml +++ b/app/src/main/res/layout/dialog_textarea_input.xml @@ -3,6 +3,8 @@ android:id="@+id/RelativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" + android:padding="16dp" + android:paddingBottom="24dp" android:orientation="vertical" >