List of usage examples for android.view.inputmethod EditorInfo IME_ACTION_DONE
int IME_ACTION_DONE
To view the source code for android.view.inputmethod EditorInfo IME_ACTION_DONE.
Click Source Link
From source file:group.pals.android.lib.ui.filechooser.FragmentFiles.java
/** * Setup:/*from w ww. j a v a 2 s .c o m*/ * <p/> * <ul> * <li>button Cancel;</li> * <li>text field "save as" filename;</li> * <li>button OK;</li> * </ul> */ private void setupFooter() { /* * By default, view group footer and all its child views are hidden. */ ViewGroup viewGroupFooterContainer = (ViewGroup) getView() .findViewById(R.id.afc_viewgroup_footer_container); ViewGroup viewGroupFooter = (ViewGroup) getView().findViewById(R.id.afc_viewgroup_footer); if (mIsSaveDialog) { viewGroupFooterContainer.setVisibility(View.VISIBLE); viewGroupFooter.setVisibility(View.VISIBLE); mTextSaveas.setVisibility(View.VISIBLE); mTextSaveas.setText(getArguments().getString(FileChooserActivity.EXTRA_DEFAULT_FILENAME)); mTextSaveas.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { Ui.showSoftKeyboard(v, false); mBtnOk.performClick(); return true; } return false; }// onEditorAction() }); mTextSaveas.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { /* * Do nothing. */ }// onTextChanged() @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { /* * Do nothing. */ }// beforeTextChanged() @Override public void afterTextChanged(Editable s) { /* * If the user taps a file, the tag is set to that file's * URI. But if the user types the file name, we remove the * tag. */ mTextSaveas.setTag(null); }// afterTextChanged() }); mBtnOk.setVisibility(View.VISIBLE); mBtnOk.setOnClickListener(mBtnOk_SaveDialog_OnClickListener); mBtnOk.setBackgroundResource(Ui.resolveAttribute(getActivity(), R.attr.afc_selector_button_ok_saveas)); int size = getResources().getDimensionPixelSize(R.dimen.afc_button_ok_saveas_size); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mBtnOk.getLayoutParams(); lp.width = size; lp.height = size; mBtnOk.setLayoutParams(lp); } // this is in save mode else { if (mIsMultiSelection) { viewGroupFooterContainer.setVisibility(View.VISIBLE); viewGroupFooter.setVisibility(View.VISIBLE); ViewGroup.LayoutParams lp = viewGroupFooter.getLayoutParams(); lp.width = ViewGroup.LayoutParams.WRAP_CONTENT; viewGroupFooter.setLayoutParams(lp); mBtnOk.setMinWidth(getResources().getDimensionPixelSize(R.dimen.afc_single_button_min_width)); mBtnOk.setText(android.R.string.ok); mBtnOk.setVisibility(View.VISIBLE); mBtnOk.setOnClickListener(mBtnOk_OpenDialog_OnClickListener); } } // this is in open mode }
From source file:im.neon.activity.VectorRoomActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_vector_room); if (CommonActivityUtils.shouldRestartApp(this)) { Log.e(LOG_TAG, "onCreate : Restart the application."); CommonActivityUtils.restartApp(this); return;/*from w w w . jav a2s . c om*/ } final Intent intent = getIntent(); if (!intent.hasExtra(EXTRA_ROOM_ID)) { Log.e(LOG_TAG, "No room ID extra."); finish(); return; } mSession = MXCActionBarActivity.getSession(this, intent); if (mSession == null) { Log.e(LOG_TAG, "No MXSession."); finish(); return; } String roomId = intent.getStringExtra(EXTRA_ROOM_ID); // ensure that the preview mode is really expected if (!intent.hasExtra(EXTRA_ROOM_PREVIEW_ID)) { sRoomPreviewData = null; Matrix.getInstance(this).clearTmpStoresList(); } if (CommonActivityUtils.isGoingToSplash(this, mSession.getMyUserId(), roomId)) { Log.d(LOG_TAG, "onCreate : Going to splash screen"); return; } //setDragEdge(SwipeBackLayout.DragEdge.LEFT); // bind the widgets of the room header view. The room header view is displayed by // clicking on the title of the action bar mRoomHeaderView = (RelativeLayout) findViewById(R.id.action_bar_header); mActionBarHeaderRoomTopic = (TextView) findViewById(R.id.action_bar_header_room_topic); mActionBarHeaderRoomName = (TextView) findViewById(R.id.action_bar_header_room_title); mActionBarHeaderActiveMembers = (TextView) findViewById(R.id.action_bar_header_room_members); mActionBarHeaderRoomAvatar = (ImageView) mRoomHeaderView.findViewById(R.id.avatar_img); mActionBarHeaderInviteMemberView = mRoomHeaderView.findViewById(R.id.action_bar_header_invite_members); mRoomPreviewLayout = findViewById(R.id.room_preview_info_layout); mVectorPendingCallView = (VectorPendingCallView) findViewById(R.id.room_pending_call_view); mVectorOngoingConferenceCallView = (VectorOngoingConferenceCallView) findViewById( R.id.room_ongoing_conference_call_view); mE2eImageView = (ImageView) findViewById(R.id.room_encrypted_image_view); // hide the header room as soon as the bottom layout (text edit zone) is touched findViewById(R.id.room_bottom_layout).setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { enableActionBarHeader(HIDE_ACTION_BAR_HEADER); return false; } }); // use a toolbar instead of the actionbar // to be able to display an expandable header mToolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.room_toolbar); this.setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // set the default custom action bar layout, // that will be displayed from the custom action bar layout setActionBarDefaultCustomLayout(); mCallId = intent.getStringExtra(EXTRA_START_CALL_ID); mEventId = intent.getStringExtra(EXTRA_EVENT_ID); mDefaultRoomName = intent.getStringExtra(EXTRA_DEFAULT_NAME); mDefaultTopic = intent.getStringExtra(EXTRA_DEFAULT_TOPIC); // the user has tapped on the "View" notification button if ((null != intent.getAction()) && (intent.getAction().startsWith(NotificationUtils.TAP_TO_VIEW_ACTION))) { // remove any pending notifications NotificationManager notificationsManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); notificationsManager.cancelAll(); } Log.d(LOG_TAG, "Displaying " + roomId); mEditText = (EditText) findViewById(R.id.editText_messageBox); // hide the header room as soon as the message input text area is touched mEditText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { enableActionBarHeader(HIDE_ACTION_BAR_HEADER); } }); // IME's DONE button is treated as a send action mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) { int imeActionId = actionId & EditorInfo.IME_MASK_ACTION; if (EditorInfo.IME_ACTION_DONE == imeActionId) { sendTextMessage(); } return false; } }); mSendingMessagesLayout = findViewById(R.id.room_sending_message_layout); mSendImageView = (ImageView) findViewById(R.id.room_send_image_view); mSendButtonLayout = findViewById(R.id.room_send_layout); mSendButtonLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!TextUtils.isEmpty(mEditText.getText())) { sendTextMessage(); } else { // hide the header room enableActionBarHeader(HIDE_ACTION_BAR_HEADER); FragmentManager fm = getSupportFragmentManager(); IconAndTextDialogFragment fragment = (IconAndTextDialogFragment) fm .findFragmentByTag(TAG_FRAGMENT_ATTACHMENTS_DIALOG); if (fragment != null) { fragment.dismissAllowingStateLoss(); } final Integer[] messages = new Integer[] { R.string.option_send_files, R.string.option_take_photo_video, }; final Integer[] icons = new Integer[] { R.drawable.ic_material_file, // R.string.option_send_files R.drawable.ic_material_camera, // R.string.option_take_photo }; fragment = IconAndTextDialogFragment.newInstance(icons, messages, null, ContextCompat.getColor(VectorRoomActivity.this, R.color.vector_text_black_color)); fragment.setOnClickListener(new IconAndTextDialogFragment.OnItemClickListener() { @Override public void onItemClick(IconAndTextDialogFragment dialogFragment, int position) { Integer selectedVal = messages[position]; if (selectedVal == R.string.option_send_files) { VectorRoomActivity.this.launchFileSelectionIntent(); } else if (selectedVal == R.string.option_take_photo_video) { if (CommonActivityUtils.checkPermissions( CommonActivityUtils.REQUEST_CODE_PERMISSION_TAKE_PHOTO, VectorRoomActivity.this)) { launchCamera(); } } } }); fragment.show(fm, TAG_FRAGMENT_ATTACHMENTS_DIALOG); } } }); mEditText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(android.text.Editable s) { if (null != mRoom) { MXLatestChatMessageCache latestChatMessageCache = VectorRoomActivity.this.mLatestChatMessageCache; String textInPlace = latestChatMessageCache.getLatestText(VectorRoomActivity.this, mRoom.getRoomId()); // check if there is really an update // avoid useless updates (initializations..) if (!mIgnoreTextUpdate && !textInPlace.equals(mEditText.getText().toString())) { latestChatMessageCache.updateLatestMessage(VectorRoomActivity.this, mRoom.getRoomId(), mEditText.getText().toString()); handleTypingNotification(mEditText.getText().length() != 0); } manageSendMoreButtons(); refreshCallButtons(); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); mVectorPendingCallView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { IMXCall call = VectorCallViewActivity.getActiveCall(); if (null != call) { final Intent intent = new Intent(VectorRoomActivity.this, VectorCallViewActivity.class); intent.putExtra(VectorCallViewActivity.EXTRA_MATRIX_ID, call.getSession().getCredentials().userId); intent.putExtra(VectorCallViewActivity.EXTRA_CALL_ID, call.getCallId()); VectorRoomActivity.this.runOnUiThread(new Runnable() { @Override public void run() { VectorRoomActivity.this.startActivity(intent); } }); } else { // if the call is no more active, just remove the view mVectorPendingCallView.onCallTerminated(); } } }); mActionBarHeaderInviteMemberView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { launchRoomDetails(VectorRoomDetailsActivity.PEOPLE_TAB_INDEX); } }); // notifications area mNotificationsArea = findViewById(R.id.room_notifications_area); mNotificationIconImageView = (ImageView) mNotificationsArea.findViewById(R.id.room_notification_icon); mNotificationTextView = (TextView) mNotificationsArea.findViewById(R.id.room_notification_message); mCanNotPostTextView = findViewById(R.id.room_cannot_post_textview); // increase the clickable area to open the keyboard. // when there is no text, it is quite small and some user thought the edition was disabled. findViewById(R.id.room_sending_message_layout).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mEditText.requestFocus()) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(mEditText, InputMethodManager.SHOW_IMPLICIT); } } }); mStartCallLayout = findViewById(R.id.room_start_call_layout); mStartCallLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if ((null != mRoom) && mRoom.isEncrypted() && (mRoom.getActiveMembers().size() > 2)) { // display the dialog with the info text AlertDialog.Builder permissionsInfoDialog = new AlertDialog.Builder(VectorRoomActivity.this); Resources resource = getResources(); permissionsInfoDialog .setMessage(resource.getString(R.string.room_no_conference_call_in_encrypted_rooms)); permissionsInfoDialog.setIcon(android.R.drawable.ic_dialog_alert); permissionsInfoDialog.setPositiveButton(resource.getString(R.string.ok), null); permissionsInfoDialog.show(); } else if (isUserAllowedToStartConfCall()) { displayVideoCallIpDialog(); } else { displayConfCallNotAllowed(); } } }); mStopCallLayout = findViewById(R.id.room_end_call_layout); mStopCallLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { IMXCall call = mSession.mCallsManager.getCallWithRoomId(mRoom.getRoomId()); if (null != call) { call.hangup(null); } } }); findViewById(R.id.room_button_margin_right).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // extend the right side of right button // to avoid clicking in the void if (mStopCallLayout.getVisibility() == View.VISIBLE) { mStopCallLayout.performClick(); } else if (mStartCallLayout.getVisibility() == View.VISIBLE) { mStartCallLayout.performClick(); } else if (mSendButtonLayout.getVisibility() == View.VISIBLE) { mSendButtonLayout.performClick(); } } }); mMyUserId = mSession.getCredentials().userId; CommonActivityUtils.resumeEventStream(this); mRoom = mSession.getDataHandler().getRoom(roomId, false); FragmentManager fm = getSupportFragmentManager(); mVectorMessageListFragment = (VectorMessageListFragment) fm .findFragmentByTag(TAG_FRAGMENT_MATRIX_MESSAGE_LIST); if (mVectorMessageListFragment == null) { Log.d(LOG_TAG, "Create VectorMessageListFragment"); // this fragment displays messages and handles all message logic mVectorMessageListFragment = VectorMessageListFragment.newInstance(mMyUserId, roomId, mEventId, (null == sRoomPreviewData) ? null : VectorMessageListFragment.PREVIEW_MODE_READ_ONLY, org.matrix.androidsdk.R.layout.fragment_matrix_message_list_fragment); fm.beginTransaction().add(R.id.anchor_fragment_messages, mVectorMessageListFragment, TAG_FRAGMENT_MATRIX_MESSAGE_LIST).commit(); } else { Log.d(LOG_TAG, "Reuse VectorMessageListFragment"); } mVectorRoomMediasSender = new VectorRoomMediasSender(this, mVectorMessageListFragment, Matrix.getInstance(this).getMediasCache()); mVectorRoomMediasSender.onRestoreInstanceState(savedInstanceState); manageRoomPreview(); addRoomHeaderClickListeners(); // in timeline mode (i.e search in the forward and backward room history) // or in room preview mode // the edition items are not displayed if (!TextUtils.isEmpty(mEventId) || (null != sRoomPreviewData)) { mNotificationsArea.setVisibility(View.GONE); findViewById(R.id.bottom_separator).setVisibility(View.GONE); findViewById(R.id.room_notification_separator).setVisibility(View.GONE); findViewById(R.id.room_notifications_area).setVisibility(View.GONE); View v = findViewById(R.id.room_bottom_layout); ViewGroup.LayoutParams params = v.getLayoutParams(); params.height = 0; v.setLayoutParams(params); } mLatestChatMessageCache = Matrix.getInstance(this).getDefaultLatestChatMessageCache(); // some medias must be sent while opening the chat if (intent.hasExtra(EXTRA_ROOM_INTENT)) { final Intent mediaIntent = intent.getParcelableExtra(EXTRA_ROOM_INTENT); // sanity check if (null != mediaIntent) { mEditText.postDelayed(new Runnable() { @Override public void run() { intent.removeExtra(EXTRA_ROOM_INTENT); sendMediasIntent(mediaIntent); } }, 1000); } } mVectorOngoingConferenceCallView.initRoomInfo(mSession, mRoom); mVectorOngoingConferenceCallView .setCallClickListener(new VectorOngoingConferenceCallView.ICallClickListener() { private void startCall(boolean isVideo) { if (CommonActivityUtils.checkPermissions( isVideo ? CommonActivityUtils.REQUEST_CODE_PERMISSION_VIDEO_IP_CALL : CommonActivityUtils.REQUEST_CODE_PERMISSION_AUDIO_IP_CALL, VectorRoomActivity.this)) { startIpCall(isVideo); } } @Override public void onVoiceCallClick() { startCall(false); } @Override public void onVideoCallClick() { startCall(true); } }); View avatarLayout = findViewById(R.id.room_self_avatar); if (null != avatarLayout) { mAvatarImageView = (ImageView) avatarLayout.findViewById(R.id.avatar_img); } refreshSelfAvatar(); // in case a "Send as" dialog was in progress when the activity was destroyed (life cycle) mVectorRoomMediasSender.resumeResizeMediaAndSend(); // header visibility has launched enableActionBarHeader(intent.getBooleanExtra(EXTRA_EXPAND_ROOM_HEADER, false) ? SHOW_ACTION_BAR_HEADER : HIDE_ACTION_BAR_HEADER); // the both flags are only used once intent.removeExtra(EXTRA_EXPAND_ROOM_HEADER); Log.d(LOG_TAG, "End of create"); }
From source file:com.cypress.cysmart.BLEServiceFragments.SensorHubService.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.sensor_hub, container, false); LinearLayout parent = (LinearLayout) rootView.findViewById(R.id.parent_sensorhub); parent.setOnClickListener(new OnClickListener() { @Override/*from w ww .j av a2 s. c o m*/ public void onClick(View v) { } }); accX = (TextView) rootView.findViewById(R.id.acc_x_value); accY = (TextView) rootView.findViewById(R.id.acc_y_value); accZ = (TextView) rootView.findViewById(R.id.acc_z_value); BAT = (TextView) rootView.findViewById(R.id.bat_value); STEMP = (TextView) rootView.findViewById(R.id.temp_value); mProgressDialog = new ProgressDialog(getActivity()); Spressure = (TextView) rootView.findViewById(R.id.pressure_value); // Locate device button listener Button locateDevice = (Button) rootView.findViewById(R.id.locate_device); locateDevice.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Button btn = (Button) v; String buttonText = btn.getText().toString(); String startText = getResources().getString(R.string.sen_hub_locate); String stopText = getResources().getString(R.string.sen_hub_locate_stop); if (buttonText.equalsIgnoreCase(startText)) { btn.setText(stopText); if (mWriteAlertCharacteristic != null) { byte[] convertedBytes = convertingTobyteArray(IMM_HIGH_ALERT); BluetoothLeService.writeCharacteristicNoresponse(mWriteAlertCharacteristic, convertedBytes); } } else { btn.setText(startText); if (mWriteAlertCharacteristic != null) { byte[] convertedBytes = convertingTobyteArray(IMM_NO_ALERT); BluetoothLeService.writeCharacteristicNoresponse(mWriteAlertCharacteristic, convertedBytes); } } } }); final ImageButton acc_more = (ImageButton) rootView.findViewById(R.id.acc_more); final ImageButton stemp_more = (ImageButton) rootView.findViewById(R.id.stemp_more); final ImageButton spressure_more = (ImageButton) rootView.findViewById(R.id.spressure_more); final LinearLayout acc_layLayout = (LinearLayout) rootView.findViewById(R.id.acc_context_menu); final LinearLayout stemp_layLayout = (LinearLayout) rootView.findViewById(R.id.stemp_context_menu); final LinearLayout spressure_layLayout = (LinearLayout) rootView.findViewById(R.id.spressure_context_menu); // expand listener acc_more.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (acc_layLayout.getVisibility() != View.VISIBLE) { acc_more.setRotation(90); CustomSlideAnimation a = new CustomSlideAnimation(acc_layLayout, CustomSlideAnimation.EXPAND); a.setHeight(height); acc_layLayout.startAnimation(a); acc_scan_interval = (EditText) rootView.findViewById(R.id.acc_sensor_scan_interval); if (ACCSensorScanCharacteristic != null) { acc_scan_interval.setText(ACCSensorScanCharacteristic); } acc_sensortype = (TextView) rootView.findViewById(R.id.acc_sensor_type); if (ACCSensorTypeCharacteristic != null) { acc_sensortype.setText(ACCSensorTypeCharacteristic); } acc_scan_interval.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { int myNum = 0; try { myNum = Integer.parseInt(acc_scan_interval.getText().toString()); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } byte[] convertedBytes = convertingTobyteArray(Integer.toString(myNum)); BluetoothLeService.writeCharacteristicNoresponse(mReadACCSensorScanCharacteristic, convertedBytes); } return false; } }); Spinner spinner_filterconfiguration = (Spinner) rootView .findViewById(R.id.acc_filter_configuration); // Create an ArrayAdapter using the string array and a // default // spinner layout ArrayAdapter<CharSequence> adapter_filterconfiguration = ArrayAdapter.createFromResource( getActivity(), R.array.filter_configuration_alert_array, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices // appears adapter_filterconfiguration .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinner_filterconfiguration.setAdapter(adapter_filterconfiguration); } else { acc_more.setRotation(-90); acc_scan_interval.setText(""); acc_sensortype.setText(""); CustomSlideAnimation a = new CustomSlideAnimation(acc_layLayout, CustomSlideAnimation.COLLAPSE); height = a.getHeight(); acc_layLayout.startAnimation(a); } } }); // expand listener stemp_more.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (stemp_layLayout.getVisibility() != View.VISIBLE) { stemp_more.setRotation(90); CustomSlideAnimation a = new CustomSlideAnimation(stemp_layLayout, CustomSlideAnimation.EXPAND); a.setHeight(height); stemp_layLayout.startAnimation(a); stemp_scan_interval = (EditText) rootView.findViewById(R.id.stemp_sensor_scan_interval); if (STEMPSensorScanCharacteristic != null) { stemp_scan_interval.setText(STEMPSensorScanCharacteristic); } stemp_sensortype = (TextView) rootView.findViewById(R.id.stemp_sensor_type); if (STEMPSensorTypeCharacteristic != null) { stemp_sensortype.setText(STEMPSensorTypeCharacteristic); } stemp_scan_interval.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { int myNum = 0; try { myNum = Integer.parseInt(stemp_scan_interval.getText().toString()); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } byte[] convertedBytes = convertingTobyteArray(Integer.toString(myNum)); BluetoothLeService.writeCharacteristicNoresponse(mReadSTEMPSensorScanCharacteristic, convertedBytes); } return false; } }); } else { stemp_more.setRotation(-90); stemp_scan_interval.setText(""); stemp_sensortype.setText(""); CustomSlideAnimation a = new CustomSlideAnimation(stemp_layLayout, CustomSlideAnimation.COLLAPSE); height = a.getHeight(); stemp_layLayout.startAnimation(a); } } }); // expand listener spressure_more.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (spressure_layLayout.getVisibility() != View.VISIBLE) { spressure_more.setRotation(90); CustomSlideAnimation a = new CustomSlideAnimation(spressure_layLayout, CustomSlideAnimation.EXPAND); a.setHeight(height); spressure_layLayout.startAnimation(a); spressure_scan_interval = (EditText) rootView.findViewById(R.id.spressure_sensor_scan_interval); if (SPRESSURESensorScanCharacteristic != null) { spressure_scan_interval.setText(SPRESSURESensorScanCharacteristic); } spressure_sensortype = (TextView) rootView.findViewById(R.id.spressure_sensor_type); if (SPRESSURESensorTypeCharacteristic != null) { spressure_sensortype.setText(SPRESSURESensorTypeCharacteristic); } spressure_scan_interval.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { int myNum = 0; try { myNum = Integer.parseInt(stemp_scan_interval.getText().toString()); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } byte[] convertedBytes = convertingTobyteArray(Integer.toString(myNum)); BluetoothLeService.writeCharacteristicNoresponse( mReadSPRESSURESensorScanCharacteristic, convertedBytes); } return false; } }); Spinner spinner_filterconfiguration = (Spinner) rootView .findViewById(R.id.spressure_filter_configuration); // Create an ArrayAdapter using the string array and a // default // spinner layout ArrayAdapter<CharSequence> adapter_filterconfiguration = ArrayAdapter.createFromResource( getActivity(), R.array.filter_configuration_alert_array, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices // appears adapter_filterconfiguration .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinner_filterconfiguration.setAdapter(adapter_filterconfiguration); spressure_threshold_value = (EditText) rootView.findViewById(R.id.spressure_threshold); spressure_threshold_value.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { int myNum = 0; try { myNum = Integer.parseInt(spressure_threshold_value.getText().toString()); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } byte[] convertedBytes = convertingTobyteArray(Integer.toString(myNum)); BluetoothLeService.writeCharacteristicNoresponse( mReadSPRESSUREThresholdCharacteristic, convertedBytes); } return false; } }); } else { spressure_more.setRotation(-90); spressure_scan_interval.setText(""); spressure_sensortype.setText(""); spressure_threshold_value.setText(""); CustomSlideAnimation a = new CustomSlideAnimation(spressure_layLayout, CustomSlideAnimation.COLLAPSE); height = a.getHeight(); spressure_layLayout.startAnimation(a); } } }); ImageButton acc_graph = (ImageButton) rootView.findViewById(R.id.acc_graph); setupAccChart(rootView); acc_graph.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mACCGraphLayoutParent.getVisibility() != View.VISIBLE) { mACCGraphLayoutParent.setVisibility(View.VISIBLE); } else { mACCGraphLayoutParent.setVisibility(View.GONE); } } }); ImageButton stemp_graph = (ImageButton) rootView.findViewById(R.id.temp_graph); setupTempGraph(rootView); stemp_graph.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mTemperatureGraphLayoutParent.getVisibility() != View.VISIBLE) { mTemperatureGraphLayoutParent.setVisibility(View.VISIBLE); } else { mTemperatureGraphLayoutParent.setVisibility(View.GONE); } } }); ImageButton spressure_graph = (ImageButton) rootView.findViewById(R.id.pressure_graph); setupPressureGraph(rootView); spressure_graph.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mPressureGraphLayoutParent.getVisibility() != View.VISIBLE) { mPressureGraphLayoutParent.setVisibility(View.VISIBLE); } else { mPressureGraphLayoutParent.setVisibility(View.GONE); } } }); setHasOptionsMenu(true); return rootView; }
From source file:com.landenlabs.all_devtool.PackageFragment.java
@Override public void onClick(View v) { int id = v.getId(); switch (id) { case R.id.pkgLoadBtn: m_pkgLoadBtn.setVisibility(View.GONE); updateList();/*from ww w. ja v a2 s .co m*/ break; case R.id.package_uninstall: if (m_uninstallResId == R.string.package_del_cache) deleteCaches(); else uninstallPackages(); break; case R.id.pkg_plus_minus_toggle: if (m_expand_collapse_toggle.isChecked()) expandAll(); else collapseAll(); break; case R.id.pkg_title: if (TextUtils.isEmpty(m_title.getHint())) { // m_title.setTag(m_title.getText()); m_title.setText(""); m_title.setHint("Filter"); if (m_list.size() > m_beforeFilter.size()) { m_beforeFilter.clear(); m_beforeFilter.addAll(m_list); } m_title.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView edView, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { String filter = edView.getText().toString(); filterPackages(filter); // hideKeyboard InputMethodManager imm = (InputMethodManager) edView.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(edView.getWindowToken(), 0); return true; // consume. } return false; // pass on to other listeners. } }); } break; } }
From source file:im.vector.fragments.VectorRoomDetailsMembersFragment.java
/** * Finalize the fragment initialization. *///from www . j a va2 s . co m private void finalizeInit() { MXMediasCache mxMediasCache = mSession.getMediasCache(); mAddMembersFloatingActionButton = mViewHierarchy.findViewById(R.id.add_participants_create_view); mAddMembersFloatingActionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // pop to the home activity Intent intent = new Intent(getActivity(), VectorRoomInviteMembersActivity.class); intent.putExtra(VectorRoomInviteMembersActivity.EXTRA_MATRIX_ID, mSession.getMyUserId()); intent.putExtra(VectorRoomInviteMembersActivity.EXTRA_ROOM_ID, mRoom.getRoomId()); getActivity().startActivityForResult(intent, INVITE_USER_REQUEST_CODE); } }); // search room members management mPatternToSearchEditText = (EditText) mViewHierarchy.findViewById(R.id.search_value_edit_text); mClearSearchImageView = (ImageView) mViewHierarchy.findViewById(R.id.clear_search_icon_image_view); mSearchNoResultTextView = (TextView) mViewHierarchy.findViewById(R.id.search_no_results_text_view); // add IME search action handler mPatternToSearchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((actionId == EditorInfo.IME_ACTION_SEARCH) || (actionId == EditorInfo.IME_ACTION_GO) || (actionId == EditorInfo.IME_ACTION_DONE)) { String previousPattern = mPatternValue; mPatternValue = mPatternToSearchEditText.getText().toString(); if (TextUtils.isEmpty(mPatternValue.trim())) { // Prevent empty patterns to be launched and restore previous valid pattern to properly manage inter tab switch mPatternValue = previousPattern; } else { refreshRoomMembersList(mPatternValue, REFRESH_NOT_FORCED); } return true; } return false; } }); mClearSearchImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // clear search pattern to restore no filtered room members list mPatternToSearchEditText.setText(""); mPatternValue = null; refreshRoomMembersList(mPatternValue, REFRESH_NOT_FORCED); forceListInExpandingState(); } }); mProgressView = mViewHierarchy.findViewById(R.id.add_participants_progress_view); mParticipantsListView = (ExpandableListView) mViewHierarchy .findViewById(R.id.room_details_members_exp_list_view); mAdapter = new VectorRoomDetailsMembersAdapter(getActivity(), R.layout.adapter_item_vector_add_participants, R.layout.adapter_item_vector_recent_header, mSession, mRoom.getRoomId(), mxMediasCache); mParticipantsListView.setAdapter(mAdapter); // the group indicator is managed in the adapter (group view creation) mParticipantsListView.setGroupIndicator(null); mParticipantsListView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { refreshMemberPresences(); } }); // set all the listener handlers called from the adapter mAdapter.setOnParticipantsListener(new VectorRoomDetailsMembersAdapter.OnParticipantsListener() { @Override public void onClick(final ParticipantAdapterItem participantItem) { Intent memberDetailsIntent = new Intent(getActivity(), VectorMemberDetailsActivity.class); memberDetailsIntent.putExtra(VectorMemberDetailsActivity.EXTRA_ROOM_ID, mRoom.getRoomId()); memberDetailsIntent.putExtra(VectorMemberDetailsActivity.EXTRA_MEMBER_ID, participantItem.mUserId); memberDetailsIntent.putExtra(VectorMemberDetailsActivity.EXTRA_MATRIX_ID, mSession.getCredentials().userId); getActivity().startActivityForResult(memberDetailsIntent, GET_MENTION_REQUEST_CODE); } @Override public void onSelectUserId(String userId) { ArrayList<String> userIds = mAdapter.getSelectedUserIds(); if (0 != userIds.size()) { setActivityTitle(userIds.size() + " " + getActivity().getResources().getString(R.string.room_details_selected)); } else { resetActivityTitle(); } } @Override public void onRemoveClick(final ParticipantAdapterItem participantItem) { String text = getActivity().getString(R.string.room_participants_remove_prompt_msg, participantItem.mDisplayName); // The user is trying to leave with unsaved changes. Warn about that new AlertDialog.Builder(VectorApp.getCurrentActivity()) .setTitle(R.string.room_participants_remove_prompt_title).setMessage(text) .setPositiveButton(R.string.remove, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); getActivity().runOnUiThread(new Runnable() { @Override public void run() { ArrayList<String> userIds = new ArrayList<>(); userIds.add(participantItem.mUserId); kickUsers(userIds, 0); } }); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create().show(); } @Override public void onLeaveClick() { // The user is trying to leave with unsaved changes. Warn about that new AlertDialog.Builder(VectorApp.getCurrentActivity()) .setTitle(R.string.room_participants_leave_prompt_title) .setMessage(getActivity().getString(R.string.room_participants_leave_prompt_msg)) .setPositiveButton(R.string.leave, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); mProgressView.setVisibility(View.VISIBLE); mRoom.leave(new ApiCallback<Void>() { @Override public void onSuccess(Void info) { if (null != getActivity()) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { getActivity().finish(); } }); } } private void onError(final String errorMessage) { if (null != getActivity()) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { mProgressView.setVisibility(View.GONE); Toast.makeText(getActivity(), errorMessage, Toast.LENGTH_SHORT) .show(); } }); } } @Override public void onNetworkError(Exception e) { onError(e.getLocalizedMessage()); } @Override public void onMatrixError(MatrixError e) { onError(e.getLocalizedMessage()); } @Override public void onUnexpectedError(Exception e) { onError(e.getLocalizedMessage()); } }); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create().show(); } @Override public void onGroupCollapsedNotif(int aGroupPosition) { if (null != mIsListViewGroupExpandedMap) { mIsListViewGroupExpandedMap.put(aGroupPosition, CommonActivityUtils.GROUP_IS_COLLAPSED); } } @Override public void onGroupExpandedNotif(int aGroupPosition) { if (null != mIsListViewGroupExpandedMap) { mIsListViewGroupExpandedMap.put(aGroupPosition, CommonActivityUtils.GROUP_IS_EXPANDED); } } }); }
From source file:im.neon.fragments.VectorRoomDetailsMembersFragment.java
/** * Finalize the fragment initialization. */// w ww . j av a 2 s .c o m private void finalizeInit() { MXMediasCache mxMediasCache = mSession.getMediasCache(); mAddMembersFloatingActionButton = mViewHierarchy.findViewById(R.id.add_participants_create_view); mAddMembersFloatingActionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // pop to the home activity Intent intent = new Intent(getActivity(), VectorRoomInviteMembersActivity.class); intent.putExtra(VectorRoomInviteMembersActivity.EXTRA_MATRIX_ID, mSession.getMyUserId()); intent.putExtra(VectorRoomInviteMembersActivity.EXTRA_ROOM_ID, mRoom.getRoomId()); intent.putExtra(VectorRoomInviteMembersActivity.EXTRA_ADD_CONFIRMATION_DIALOG, true); getActivity().startActivityForResult(intent, INVITE_USER_REQUEST_CODE); } }); // search room members management mPatternToSearchEditText = (EditText) mViewHierarchy.findViewById(R.id.search_value_edit_text); mClearSearchImageView = (ImageView) mViewHierarchy.findViewById(R.id.clear_search_icon_image_view); mSearchNoResultTextView = (TextView) mViewHierarchy.findViewById(R.id.search_no_results_text_view); // add IME search action handler mPatternToSearchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((actionId == EditorInfo.IME_ACTION_SEARCH) || (actionId == EditorInfo.IME_ACTION_GO) || (actionId == EditorInfo.IME_ACTION_DONE)) { String previousPattern = mPatternValue; mPatternValue = mPatternToSearchEditText.getText().toString(); if (TextUtils.isEmpty(mPatternValue.trim())) { // Prevent empty patterns to be launched and restore previous valid pattern to properly manage inter tab switch mPatternValue = previousPattern; } else { refreshRoomMembersList(mPatternValue, REFRESH_NOT_FORCED); } return true; } return false; } }); mClearSearchImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // clear search pattern to restore no filtered room members list mPatternToSearchEditText.setText(""); mPatternValue = null; refreshRoomMembersList(mPatternValue, REFRESH_NOT_FORCED); forceListInExpandingState(); } }); mProgressView = mViewHierarchy.findViewById(R.id.add_participants_progress_view); mParticipantsListView = (ExpandableListView) mViewHierarchy .findViewById(R.id.room_details_members_exp_list_view); mAdapter = new VectorRoomDetailsMembersAdapter(getActivity(), R.layout.adapter_item_vector_add_participants, R.layout.adapter_item_vector_recent_header, mSession, mRoom.getRoomId(), mxMediasCache); mParticipantsListView.setAdapter(mAdapter); // the group indicator is managed in the adapter (group view creation) mParticipantsListView.setGroupIndicator(null); mParticipantsListView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { refreshMemberPresences(); } }); // set all the listener handlers called from the adapter mAdapter.setOnParticipantsListener(new VectorRoomDetailsMembersAdapter.OnParticipantsListener() { @Override public void onClick(final ParticipantAdapterItem participantItem) { Intent memberDetailsIntent = new Intent(getActivity(), VectorMemberDetailsActivity.class); memberDetailsIntent.putExtra(VectorMemberDetailsActivity.EXTRA_ROOM_ID, mRoom.getRoomId()); memberDetailsIntent.putExtra(VectorMemberDetailsActivity.EXTRA_MEMBER_ID, participantItem.mUserId); memberDetailsIntent.putExtra(VectorMemberDetailsActivity.EXTRA_MATRIX_ID, mSession.getCredentials().userId); getActivity().startActivityForResult(memberDetailsIntent, GET_MENTION_REQUEST_CODE); } @Override public void onSelectUserId(String userId) { ArrayList<String> userIds = mAdapter.getSelectedUserIds(); if (0 != userIds.size()) { setActivityTitle(userIds.size() + " " + getActivity().getResources().getString(R.string.room_details_selected)); } else { resetActivityTitle(); } } @Override public void onRemoveClick(final ParticipantAdapterItem participantItem) { String text = getActivity().getString(R.string.room_participants_remove_prompt_msg, participantItem.mDisplayName); // The user is trying to leave with unsaved changes. Warn about that new AlertDialog.Builder(VectorApp.getCurrentActivity()).setTitle(R.string.dialog_title_confirmation) .setMessage(text).setPositiveButton(R.string.remove, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); getActivity().runOnUiThread(new Runnable() { @Override public void run() { kickUsers(Arrays.asList(participantItem.mUserId), 0); } }); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create().show(); } @Override public void onLeaveClick() { // The user is trying to leave with unsaved changes. Warn about that new AlertDialog.Builder(VectorApp.getCurrentActivity()) .setTitle(R.string.room_participants_leave_prompt_title) .setMessage(getActivity().getString(R.string.room_participants_leave_prompt_msg)) .setPositiveButton(R.string.leave, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); mProgressView.setVisibility(View.VISIBLE); mRoom.leave(new ApiCallback<Void>() { @Override public void onSuccess(Void info) { if (null != getActivity()) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { getActivity().finish(); } }); } } private void onError(final String errorMessage) { if (null != getActivity()) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { mProgressView.setVisibility(View.GONE); Toast.makeText(getActivity(), errorMessage, Toast.LENGTH_SHORT) .show(); } }); } } @Override public void onNetworkError(Exception e) { onError(e.getLocalizedMessage()); } @Override public void onMatrixError(MatrixError e) { onError(e.getLocalizedMessage()); } @Override public void onUnexpectedError(Exception e) { onError(e.getLocalizedMessage()); } }); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create().show(); } @Override public void onGroupCollapsedNotif(int aGroupPosition) { if (null != mIsListViewGroupExpandedMap) { mIsListViewGroupExpandedMap.put(aGroupPosition, CommonActivityUtils.GROUP_IS_COLLAPSED); } } @Override public void onGroupExpandedNotif(int aGroupPosition) { if (null != mIsListViewGroupExpandedMap) { mIsListViewGroupExpandedMap.put(aGroupPosition, CommonActivityUtils.GROUP_IS_EXPANDED); } } }); }
From source file:com.haibison.android.anhuu.FragmentFiles.java
/** * Setup://from ww w . ja va 2 s . co m * <p/> * <ul> * <li>button Cancel;</li> * <li>text field "save as" filename;</li> * <li>button OK;</li> * </ul> */ private void setupFooter() { /* * By default, view group footer and all its child views are hidden. */ ViewGroup viewGroupFooterContainer = (ViewGroup) getView() .findViewById(R.id.anhuu_f5be488d_viewgroup_footer_container); ViewGroup viewGroupFooter = (ViewGroup) getView().findViewById(R.id.anhuu_f5be488d_viewgroup_footer); if (mIsSaveDialog) { viewGroupFooterContainer.setVisibility(View.VISIBLE); viewGroupFooter.setVisibility(View.VISIBLE); mTextSaveas.setVisibility(View.VISIBLE); mTextSaveas.setText(getArguments().getString(FileChooserActivity.EXTRA_DEFAULT_FILENAME)); mTextSaveas.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { UI.showSoftKeyboard(v, false); mBtnOk.performClick(); return true; } return false; }// onEditorAction() }); mTextSaveas.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { /* * Do nothing. */ }// onTextChanged() @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { /* * Do nothing. */ }// beforeTextChanged() @Override public void afterTextChanged(Editable s) { /* * If the user taps a file, the tag is set to that file's * URI. But if the user types the file name, we remove the * tag. */ mTextSaveas.setTag(null); }// afterTextChanged() }); mBtnOk.setVisibility(View.VISIBLE); mBtnOk.setOnClickListener(mBtnOk_SaveDialog_OnClickListener); mBtnOk.setBackgroundResource( UI.resolveAttribute(getActivity(), R.attr.anhuu_f5be488d_selector_button_ok_saveas)); int size = getResources().getDimensionPixelSize(R.dimen.anhuu_f5be488d_button_ok_saveas_size); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mBtnOk.getLayoutParams(); lp.width = size; lp.height = size; mBtnOk.setLayoutParams(lp); } // this is in save mode else { if (mIsMultiSelection) { viewGroupFooterContainer.setVisibility(View.VISIBLE); viewGroupFooter.setVisibility(View.VISIBLE); ViewGroup.LayoutParams lp = viewGroupFooter.getLayoutParams(); lp.width = ViewGroup.LayoutParams.WRAP_CONTENT; viewGroupFooter.setLayoutParams(lp); mBtnOk.setMinWidth( getResources().getDimensionPixelSize(R.dimen.anhuu_f5be488d_single_button_min_width)); mBtnOk.setText(android.R.string.ok); mBtnOk.setVisibility(View.VISIBLE); mBtnOk.setOnClickListener(mBtnOk_OpenDialog_OnClickListener); } } // this is in open mode }
From source file:org.telegram.ui.TwoStepVerificationActivity.java
private void setPasswordSetState(int state) { if (passwordEditText == null) { return;//from ww w . j a v a 2 s .c o m } passwordSetState = state; if (passwordSetState == 0) { actionBar.setTitle(LocaleController.getString("YourPassword", R.string.YourPassword)); if (currentPassword instanceof TLRPC.TL_account_noPassword) { titleTextView.setText( LocaleController.getString("PleaseEnterFirstPassword", R.string.PleaseEnterFirstPassword)); } else { titleTextView .setText(LocaleController.getString("PleaseEnterPassword", R.string.PleaseEnterPassword)); } passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT); passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance()); bottomTextView.setVisibility(View.INVISIBLE); bottomButton.setVisibility(View.INVISIBLE); } else if (passwordSetState == 1) { actionBar.setTitle(LocaleController.getString("YourPassword", R.string.YourPassword)); titleTextView .setText(LocaleController.getString("PleaseReEnterPassword", R.string.PleaseReEnterPassword)); passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT); passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance()); bottomTextView.setVisibility(View.INVISIBLE); bottomButton.setVisibility(View.INVISIBLE); } else if (passwordSetState == 2) { actionBar.setTitle(LocaleController.getString("PasswordHint", R.string.PasswordHint)); titleTextView.setText(LocaleController.getString("PasswordHintText", R.string.PasswordHintText)); passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT); passwordEditText.setTransformationMethod(null); bottomTextView.setVisibility(View.INVISIBLE); bottomButton.setVisibility(View.INVISIBLE); } else if (passwordSetState == 3) { actionBar.setTitle(LocaleController.getString("RecoveryEmail", R.string.RecoveryEmail)); titleTextView.setText(LocaleController.getString("YourEmail", R.string.YourEmail)); passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); passwordEditText.setTransformationMethod(null); passwordEditText .setInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); bottomTextView.setVisibility(View.VISIBLE); bottomButton.setVisibility(emailOnly ? View.INVISIBLE : View.VISIBLE); } else if (passwordSetState == 4) { actionBar.setTitle(LocaleController.getString("PasswordRecovery", R.string.PasswordRecovery)); titleTextView.setText(LocaleController.getString("PasswordCode", R.string.PasswordCode)); bottomTextView .setText(LocaleController.getString("RestoreEmailSentInfo", R.string.RestoreEmailSentInfo)); bottomButton.setText(LocaleController.formatString("RestoreEmailTrouble", R.string.RestoreEmailTrouble, currentPassword.email_unconfirmed_pattern)); passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); passwordEditText.setTransformationMethod(null); passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE); bottomTextView.setVisibility(View.VISIBLE); bottomButton.setVisibility(View.VISIBLE); } passwordEditText.setText(""); }
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.java
/** * Initialize the {@link AutoCompleteTextView}'s with an {@link ArrayAdapter} * and a listener ({@link AutoCompleteTextWatcher}). The listener gets autocomplete * data from the Google Places API and updates the ArrayAdapter with these. *//*from w w w.j a v a2 s. c o m*/ private void initAutocomplete() { adapter = new ArrayAdapter<String>(this, R.layout.item_list); adapter.setNotifyOnChange(true); acFrom = (AutoCompleteTextView) findViewById(R.id.etGoingFrom); acFrom.setAdapter(adapter); acFrom.addTextChangedListener(new AutoCompleteTextWatcher(this, adapter, acFrom)); acFrom.setThreshold(1); acTo = (AutoCompleteTextView) findViewById(R.id.etGoingTo); acTo.setAdapter(adapter); acTo.addTextChangedListener(new AutoCompleteTextWatcher(this, adapter, acTo)); acTo.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); final Button button = ((Button) findViewById(R.id.btnChooseRoute)); if (actionId == EditorInfo.IME_ACTION_DONE) { if (checkFields() && selectedRoute.getMapPoints().size() > 2 && hasDrawn == true) { button.setEnabled(true); button.setText("Next"); return true; } else if (checkFields() && selectedRoute.getMapPoints().size() == 0) { mapView.getOverlays().clear(); createMap(); button.setEnabled(true); button.setText("Next"); return true; } else if (checkFields() == false && selectedRoute.getMapPoints().size() == 0) { button.setText("Show on map"); button.setEnabled(false); return false; } else { button.setText("Show on map"); button.setEnabled(false); return false; } } return false; } }); }
From source file:com.github.dfa.diaspora_android.activity.MainActivity.java
/** * Handle clicks on the optionsmenu//from w w w. j a v a 2 s.c o m * * @param item item * @return boolean */ @Override public boolean onOptionsItemSelected(MenuItem item) { AppLog.i(this, "onOptionsItemSelected()"); switch (item.getItemId()) { case R.id.action_notifications: { if (appSettings.isExtendedNotificationsActivated()) { return true; } //Otherwise we execute the action of action_notifications_all } case R.id.action_notifications_all: { if (WebHelper.isOnline(MainActivity.this)) { openDiasporaUrl(urls.getNotificationsUrl()); return true; } else { snackbarNoInternet.show(); return false; } } case R.id.action_notifications_also_commented: { if (WebHelper.isOnline(MainActivity.this)) { openDiasporaUrl(urls.getSuburlNotificationsAlsoCommentedUrl()); return true; } else { snackbarNoInternet.show(); return false; } } case R.id.action_notifications_comment_on_post: { if (WebHelper.isOnline(MainActivity.this)) { openDiasporaUrl(urls.getSuburlNotificationsCommentOnPostUrl()); return true; } else { snackbarNoInternet.show(); return false; } } case R.id.action_notifications_liked: { if (WebHelper.isOnline(MainActivity.this)) { openDiasporaUrl(urls.getSuburlNotificationsLikedUrl()); return true; } else { snackbarNoInternet.show(); return false; } } case R.id.action_notifications_mentioned: { if (WebHelper.isOnline(MainActivity.this)) { openDiasporaUrl(urls.getSuburlNotificationsMentionedUrl()); return true; } else { snackbarNoInternet.show(); return false; } } case R.id.action_notifications_reshared: { if (WebHelper.isOnline(MainActivity.this)) { openDiasporaUrl(urls.getSuburlNotificationsResharedUrl()); return true; } else { snackbarNoInternet.show(); return false; } } case R.id.action_notifications_started_sharing: { if (WebHelper.isOnline(MainActivity.this)) { openDiasporaUrl(urls.getSuburlNotificationsStartedSharingUrl()); return true; } else { snackbarNoInternet.show(); return false; } } case R.id.action_conversations: { if (WebHelper.isOnline(MainActivity.this)) { openDiasporaUrl(urls.getConversationsUrl()); return true; } else { snackbarNoInternet.show(); return false; } } case R.id.action_exit: { moveTaskToBack(true); finish(); return true; } case R.id.action_compose: { if (WebHelper.isOnline(MainActivity.this)) { openDiasporaUrl(urls.getNewPostUrl()); } else { snackbarNoInternet.show(); } return true; } case R.id.action_search: { if (WebHelper.isOnline(MainActivity.this)) { final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); @SuppressLint("InflateParams") View layout = getLayoutInflater().inflate(R.layout.ui__dialog_search__people_tags, null, false); final EditText input = (EditText) layout.findViewById(R.id.dialog_search__input); ThemeHelper.updateEditTextColor(input); final DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int which) { String query = input.getText().toString().trim() .replaceAll((which == DialogInterface.BUTTON_NEGATIVE ? "\\*" : "\\#"), ""); if (query.equals("")) { Snackbar.make(fragmentContainer, R.string.search_alert_bypeople_validate_needsomedata, Snackbar.LENGTH_LONG).show(); } else { openDiasporaUrl( which == DialogInterface.BUTTON_NEGATIVE ? urls.getSearchPeopleUrl(query) : urls.getSearchTagsUrl(query)); } getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); imm.hideSoftInputFromWindow(input.getWindowToken(), 0); } }; final AlertDialog dialog = new ThemedAlertDialogBuilder(this, appSettings).setView(layout) .setTitle(R.string.search_alert_title).setCancelable(true) .setPositiveButton(R.string.search_alert_tag, clickListener) .setNegativeButton(R.string.search_alert_people, clickListener).create(); input.setOnEditorActionListener(new TextView.OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { dialog.hide(); clickListener.onClick(null, 0); return true; } return false; } }); // Popup keyboard dialog.show(); input.requestFocus(); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); } else { snackbarNoInternet.show(); } return true; } } return super.onOptionsItemSelected(item); }