List of usage examples for android.content Context INPUT_METHOD_SERVICE
String INPUT_METHOD_SERVICE
To view the source code for android.content Context INPUT_METHOD_SERVICE.
Click Source Link
From source file:cn.count.easydrive366.DriverLicenseEditActivity.java
private void save() { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(((EditText) findViewById(R.id.edt_driverlicense_name)).getWindowToken(), 0); if (!this.isOnline()) { this.showMessage(this.getResources().getString(R.string.no_network), null); return;/*from w ww.j av a2 s. co m*/ } String name = ((EditText) findViewById(R.id.edt_driverlicense_name)).getText().toString().trim(); String id = ((EditText) findViewById(R.id.edt_driverlicense_number)).getText().toString().trim() .toUpperCase(); if (name.equals("")) { this.showMessage(this.getResources().getString(R.string.name_is_empty), null); return; } if (id.equals("") || id.length() != 18 || !personIdValidation(id)) { this.showMessage(this.getResources().getString(R.string.id_is_wrong), null); return; } String url = String.format("api/add_driver_license?user_id=%d&name=%s&license_id=%s&type=%s&init_date=%s", AppSettings.userid, ((EditText) findViewById(R.id.edt_driverlicense_name)).getText().toString().toUpperCase(), ((EditText) findViewById(R.id.edt_driverlicense_number)).getText().toString().toUpperCase(), ((TextView) findViewById(R.id.edt_driverlicense_car_type)).getText(), ((TextView) findViewById(R.id.edt_driverlicense_init_date)).getText()); this.get(url, 2, this.getResources().getString(R.string.app_uploading)); }
From source file:info.xuluan.podcast.SearchActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.search_activity); setTitle(getResources().getString(R.string.title_channels)); mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mStrings); setListAdapter(mAdapter);// www.ja v a 2 s . c om getListView().setOnCreateContextMenuListener(this); mEditText = (EditText) findViewById(R.id.keywords); mEditText.addTextChangedListener(this); startInit(); Button next = (Button) findViewById(R.id.ButtonNext); next.setEnabled(false); next.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String str = "&start=" + mStart; String url = getUrl(); if (url != null) { start_search(url + str); } } }); ImageButton start = (ImageButton) findViewById(R.id.ButtonStart); start.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { InputMethodManager m = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); m.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS); m.hideSoftInputFromInputMethod(mEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); String str = "&start=" + mStart; String url = getUrl(); if (url != null) { start_search(url + str); } } }); TabsHelper.setChannelTabClickListeners(this, R.id.channel_bar_search_button); }
From source file:com.facebook.android.GraphExplorer.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mHandler = new Handler(); setContentView(R.layout.graph_explorer); url = BASE_GRAPH_URL; // Base URL mInputId = (EditText) findViewById(R.id.inputId); mOutput = (TextView) findViewById(R.id.output); mSubmitButton = (Button) findViewById(R.id.submitButton); mViewURLButton = (Button) findViewById(R.id.viewURLButton); mGetPermissionsButton = (Button) findViewById(R.id.accessTokenButton); mFieldsConnectionsButton = (Button) findViewById(R.id.fieldsAndConnectionsButton); mBackParentButton = (Button) findViewById(R.id.backParentButton); mScrollView = (ScrollView) findViewById(R.id.ScrollView01); mTextDeleteButton = (Button) findViewById(R.id.textDeleteButton); mMeButton = (Button) findViewById(R.id.meButton); if (Utility.mFacebook.isSessionValid()) { mMeButton.setVisibility(View.VISIBLE); }//from ww w . ja v a2s. c o m params = new Bundle(); mSubmitButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(mInputId.getWindowToken(), 0); // Prepare the URL to be shown on 'View URL' click action. This // is not used by the SDK url = BASE_GRAPH_URL; // Base URL /* * Source Tag: graph_explorer */ rootString = mInputId.getText().toString(); if (!TextUtils.isEmpty(rootString)) { dialog = ProgressDialog.show(GraphExplorer.this, "", getString(R.string.please_wait), true, true); params.putString("metadata", "1"); Utility.mAsyncRunner.request(rootString, params, new graphApiRequestListener()); url += "/" + rootString; // Relative Path provided by you } } }); mViewURLButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setText(url); Linkify.addLinks(mOutput, Linkify.WEB_URLS); } }); mGetPermissionsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (Utility.mFacebook.isSessionValid()) { dialog = ProgressDialog.show(GraphExplorer.this, "", getString(R.string.fetching_current_permissions), true, true); Bundle params = new Bundle(); params.putString("access_token", Utility.mFacebook.getAccessToken()); Utility.mAsyncRunner.request("me/permissions", params, new permissionsRequestListener()); } else { new PermissionsDialog(GraphExplorer.this).show(); } } }); mFieldsConnectionsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (metadataObject == null) { makeToast("No fields, connections availalbe for this object."); } else { new FieldsConnectionsDialog(GraphExplorer.this, metadataObject).show(); } } }); mTextDeleteButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { url = BASE_GRAPH_URL; // Base URL mParentObjectId = ""; mInputId.setText(""); params.clear(); metadataObject = null; setText(""); mBackParentButton.setVisibility(View.INVISIBLE); } }); mMeButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mInputId.setText("me"); mSubmitButton.performClick(); } }); mBackParentButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mInputId.setText(mParentObjectId); mParentObjectId = ""; mSubmitButton.performClick(); } }); }
From source file:cn.count.easydrive366.CarRegistrationEditActivity.java
private void save() { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(((EditText) findViewById(R.id.edt_carregistration_plate_no)).getWindowToken(), 0);/*from w w w. j a v a2s . co m*/ if (!this.isOnline()) { this.showMessage(this.getResources().getString(R.string.no_network), null); return; } String url = String.format( "api/add_car_registration?user_id=%d&car_id=%s&engine_no=%s&vin=%s&init_date=%s&owner_name=%s&owner_license=%s", AppSettings.userid, ((EditText) findViewById(R.id.edt_carregistration_plate_no)).getText().toString().toUpperCase(), ((EditText) findViewById(R.id.edt_carregistration_engine_no)).getText().toString().toUpperCase(), ((EditText) findViewById(R.id.edt_carregistration_vin)).getText().toString().toUpperCase(), ((TextView) findViewById(R.id.edt_carregistration_registration_date)).getText(), ((EditText) findViewById(R.id.edt_carregistration_owner_name)).getText().toString().toUpperCase(), ((EditText) findViewById(R.id.edt_carregistration_owner_license)).getText().toString() .toUpperCase()); this.get(url, 2, this.getResources().getString(R.string.app_uploading)); }
From source file:org.cocos2dx.lib.TextInputWraper.java
private Boolean isFullScreenEdit() { InputMethodManager imm = (InputMethodManager) mMainView.getTextField().getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); return imm.isFullscreenMode(); }
From source file:net.olejon.mdapp.Icd10ChapterActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Intent/*from w ww . j av a2s .co m*/ final Intent intent = getIntent(); mChapterId = intent.getLongExtra("chapter", 0); // Input manager mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Layout setContentView(R.layout.activity_icd10_chapter); // Toolbar mToolbar = (Toolbar) findViewById(R.id.icd10_chapter_toolbar); mToolbar.setTitle(""); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbarSearchLayout = (LinearLayout) findViewById(R.id.icd10_chapter_toolbar_search_layout); mToolbarSearchEditText = (EditText) findViewById(R.id.icd10_chapter_toolbar_search); ImageButton imageButton = (ImageButton) findViewById(R.id.icd10_chapter_toolbar_clear_search); imageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mToolbarSearchEditText.setText(""); } }); // Progress bar mProgressBar = (ProgressBar) findViewById(R.id.icd10_chapter_toolbar_progressbar); mFloatingActionButton = (FloatingActionButton) findViewById(R.id.icd10_chapter_fab); mFloatingActionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mToolbarSearchLayout.setVisibility(View.VISIBLE); mToolbarSearchEditText.requestFocus(); mInputMethodManager.showSoftInput(mToolbarSearchEditText, 0); } }); // List mListView = (ListView) findViewById(R.id.icd10_chapter_list); mListViewEmpty = findViewById(R.id.icd10_chapter_list_empty); // Get data GetDataTask getDataTask = new GetDataTask(); getDataTask.execute(); }
From source file:edu.rit.csh.androidwebnews.DisplayThreadsActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getSupportMenuInflater().inflate(R.menu.displaythreads_menu, menu); // Get the SearchView and set the searchable configuration final SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() { public boolean onQueryTextChange(String newText) { return true; }/*from ww w.j av a 2 s . c o m*/ public boolean onQueryTextSubmit(String query) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0); Intent intent = new Intent(DisplayThreadsActivity.this, SearchResultsActivity.class); HashMap<String, String> params = new HashMap<String, String>(); params.put("keywords", query); intent.putExtra("params", params); startActivity(intent); return true; } }; searchView.setOnQueryTextListener(queryTextListener); return super.onCreateOptionsMenu(menu); }
From source file:com.netpace.expressit.activity.UploadImageStoryActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_upload_image_story); getSupportActionBar().setTitle("retake"); getSupportActionBar().setDisplayShowHomeEnabled(false); Intent intent = getIntent();/*from w w w. j a va 2s . c o m*/ img_filePath = intent.getStringExtra(IMAGE_PATH); widthAfter = intent.getIntExtra(IMAGE_WIDTH, 0); heightAfter = intent.getIntExtra(IMAGE_HEIGHT, 0); isGalleryPhoto = intent.getBooleanExtra("isGalleryPhoto", false); imageViewThumbnail = (ImageView) findViewById(R.id.imageViewThumb); imageViewThumbnail.setImageURI(Uri.parse(img_filePath)); titleTextView = (TypefaceEditText) findViewById(R.id.story_title_txt_field); button_saveLater = (Button) findViewById(R.id.shareButton); button_saveLater.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isValidate()) { // close the keyboard. InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(titleTextView.getWindowToken(), 0); getMediaKeyFromRemoteServer(); } } }); }
From source file:com.liferay.alerts.activity.ComposeActivity.java
protected void showKeyboard() { final InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); Runnable runnable = new Runnable() { @Override/* www .j a v a 2 s . co m*/ public void run() { manager.showSoftInput(_edit, InputMethodManager.SHOW_IMPLICIT); } }; int delay = getResources().getInteger(R.integer.compose_show_keyboard_delay); Handler handler = new Handler(); handler.postDelayed(runnable, delay); _edit.setKeyboardHideListener(new KeyboardHideListener() { @Override public void onHide() { finish(); } }); }
From source file:com.aware.ui.ESM_UI.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // getActivity().getWindow().setType(WindowManager.LayoutParams.TYPE_PRIORITY_PHONE); // getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); // getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); builder = new AlertDialog.Builder(getActivity()); inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); TAG = Aware.getSetting(getActivity().getApplicationContext(), Aware_Preferences.DEBUG_TAG).length() > 0 ? Aware.getSetting(getActivity().getApplicationContext(), Aware_Preferences.DEBUG_TAG) : TAG;//from w w w . j a v a2 s. c o m Cursor visible_esm = getActivity().getContentResolver().query(ESM_Data.CONTENT_URI, null, ESM_Data.STATUS + "=" + ESM.STATUS_NEW, null, ESM_Data.TIMESTAMP + " ASC LIMIT 1"); if (visible_esm != null && visible_esm.moveToFirst()) { esm_id = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data._ID)); //Fixed: set the esm as not new anymore, to avoid displaying the same ESM twice due to changes in orientation ContentValues update_state = new ContentValues(); update_state.put(ESM_Data.STATUS, ESM.STATUS_VISIBLE); getActivity().getContentResolver().update(ESM_Data.CONTENT_URI, update_state, ESM_Data._ID + "=" + esm_id, null); esm_type = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.TYPE)); expires_seconds = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.EXPIRATION_THREASHOLD)); builder.setTitle(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.TITLE))); View ui = null; switch (esm_type) { case ESM.TYPE_ESM_TEXT: ui = inflater.inflate(R.layout.esm_text, null); break; case ESM.TYPE_ESM_RADIO: ui = inflater.inflate(R.layout.esm_radio, null); break; case ESM.TYPE_ESM_CHECKBOX: ui = inflater.inflate(R.layout.esm_checkbox, null); break; case ESM.TYPE_ESM_LIKERT: ui = inflater.inflate(R.layout.esm_likert, null); break; case ESM.TYPE_ESM_QUICK_ANSWERS: ui = inflater.inflate(R.layout.esm_quick, null); break; } final View layout = ui; builder.setView(layout); current_dialog = builder.create(); sContext = current_dialog.getContext(); TextView esm_instructions = (TextView) layout.findViewById(R.id.esm_instructions); esm_instructions.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.INSTRUCTIONS))); switch (esm_type) { case ESM.TYPE_ESM_TEXT: final EditText feedback = (EditText) layout.findViewById(R.id.esm_feedback); Button cancel_text = (Button) layout.findViewById(R.id.esm_cancel); cancel_text.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { inputManager.hideSoftInputFromWindow(feedback.getWindowToken(), 0); current_dialog.cancel(); } }); Button submit_text = (Button) layout.findViewById(R.id.esm_submit); submit_text.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit_text.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { inputManager.hideSoftInputFromWindow(feedback.getWindowToken(), 0); if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); rowData.put(ESM_Data.ANSWER, feedback.getText().toString()); rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); break; case ESM.TYPE_ESM_RADIO: try { final RadioGroup radioOptions = (RadioGroup) layout.findViewById(R.id.esm_radio); final JSONArray radios = new JSONArray( visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.RADIOS))); for (int i = 0; i < radios.length(); i++) { final RadioButton radioOption = new RadioButton(getActivity()); radioOption.setId(i); radioOption.setText(radios.getString(i)); radioOptions.addView(radioOption); if (radios.getString(i).equals("Other")) { radioOption.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog editOther = new Dialog(getActivity()); editOther.setTitle("Can you be more specific, please?"); editOther.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); editOther.getWindow().setGravity(Gravity.TOP); editOther.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout editor = new LinearLayout(getActivity()); editor.setOrientation(LinearLayout.VERTICAL); editOther.setContentView(editor); editOther.show(); final EditText otherText = new EditText(getActivity()); editor.addView(otherText); Button confirm = new Button(getActivity()); confirm.setText("OK"); confirm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (otherText.length() > 0) radioOption.setText(otherText.getText()); inputManager.hideSoftInputFromWindow(otherText.getWindowToken(), 0); editOther.dismiss(); } }); editor.addView(confirm); } }); } } Button cancel_radio = (Button) layout.findViewById(R.id.esm_cancel); cancel_radio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { current_dialog.cancel(); } }); Button submit_radio = (Button) layout.findViewById(R.id.esm_submit); submit_radio.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit_radio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); RadioGroup radioOptions = (RadioGroup) layout.findViewById(R.id.esm_radio); if (radioOptions.getCheckedRadioButtonId() != -1) { RadioButton selected = (RadioButton) radioOptions .getChildAt(radioOptions.getCheckedRadioButtonId()); rowData.put(ESM_Data.ANSWER, selected.getText().toString()); } rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); } catch (JSONException e) { e.printStackTrace(); } break; case ESM.TYPE_ESM_CHECKBOX: try { final LinearLayout checkboxes = (LinearLayout) layout.findViewById(R.id.esm_checkboxes); final JSONArray checks = new JSONArray( visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.CHECKBOXES))); for (int i = 0; i < checks.length(); i++) { final CheckBox checked = new CheckBox(getActivity()); checked.setText(checks.getString(i)); checked.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (buttonView.getText().equals("Other")) { checked.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog editOther = new Dialog(getActivity()); editOther.setTitle("Can you be more specific, please?"); editOther.getWindow() .setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); editOther.getWindow().setGravity(Gravity.TOP); editOther.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout editor = new LinearLayout(getActivity()); editor.setOrientation(LinearLayout.VERTICAL); editOther.setContentView(editor); editOther.show(); final EditText otherText = new EditText(getActivity()); editor.addView(otherText); Button confirm = new Button(getActivity()); confirm.setText("OK"); confirm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (otherText.length() > 0) { inputManager.hideSoftInputFromWindow( otherText.getWindowToken(), 0); selected_options .remove(buttonView.getText().toString()); checked.setText(otherText.getText()); selected_options.add(otherText.getText().toString()); } editOther.dismiss(); } }); editor.addView(confirm); } }); } else { selected_options.add(buttonView.getText().toString()); } } else { selected_options.remove(buttonView.getText().toString()); } } }); checkboxes.addView(checked); } Button cancel_checkbox = (Button) layout.findViewById(R.id.esm_cancel); cancel_checkbox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { current_dialog.cancel(); } }); Button submit_checkbox = (Button) layout.findViewById(R.id.esm_submit); submit_checkbox.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit_checkbox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); if (selected_options.size() > 0) { rowData.put(ESM_Data.ANSWER, selected_options.toString()); } rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); } catch (JSONException e) { e.printStackTrace(); } break; case ESM.TYPE_ESM_LIKERT: final RatingBar ratingBar = (RatingBar) layout.findViewById(R.id.esm_likert); ratingBar.setMax(visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX))); ratingBar.setStepSize( (float) visible_esm.getDouble(visible_esm.getColumnIndex(ESM_Data.LIKERT_STEP))); ratingBar.setNumStars(visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX))); TextView min_label = (TextView) layout.findViewById(R.id.esm_min); min_label.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.LIKERT_MIN_LABEL))); TextView max_label = (TextView) layout.findViewById(R.id.esm_max); max_label.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX_LABEL))); Button cancel = (Button) layout.findViewById(R.id.esm_cancel); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { current_dialog.cancel(); } }); Button submit = (Button) layout.findViewById(R.id.esm_submit); submit.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); rowData.put(ESM_Data.ANSWER, ratingBar.getRating()); rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); break; case ESM.TYPE_ESM_QUICK_ANSWERS: try { final JSONArray answers = new JSONArray( visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.QUICK_ANSWERS))); final LinearLayout answersHolder = (LinearLayout) layout.findViewById(R.id.esm_answers); //If we have more than 3 possibilities, better that the UI is vertical for UX if (answers.length() > 3) { answersHolder.setOrientation(LinearLayout.VERTICAL); } for (int i = 0; i < answers.length(); i++) { final Button answer = new Button(getActivity()); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f); answer.setLayoutParams(params); answer.setText(answers.getString(i)); answer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); rowData.put(ESM_Data.ANSWER, (String) answer.getText()); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); answersHolder.addView(answer); } } catch (JSONException e) { e.printStackTrace(); } break; } } if (visible_esm != null && !visible_esm.isClosed()) visible_esm.close(); //Start dialog visibility threshold if (expires_seconds > 0) { expire_monitor = new ESMExpireMonitor(System.currentTimeMillis(), expires_seconds, esm_id); expire_monitor.execute(); } //Fixed: doesn't dismiss the dialog if touched outside or ghost touches current_dialog.setCanceledOnTouchOutside(false); return current_dialog; }