List of usage examples for android.text TextWatcher TextWatcher
TextWatcher
From source file:com.hxqc.mall.usedcar.activity.SellCarActivity.java
private void initView() { mToolbar = (Toolbar) findViewById(R.id.toolbar); mToolbar.setTitleTextColor(Color.WHITE); mToolbar.setTitle(getResources().getString(R.string.activity_sellcar)); mToolbar.setNavigationIcon(R.drawable.ic_back); setSupportActionBar(mToolbar);/*from w ww .j a v a 2s . co m*/ mDrawerLayoutView = (UsedCarDrawer) findViewById(R.id.drawer_layout); mRightView = (FrameLayout) findViewById(R.id.right); mBrandView = (SellCarBrand) findViewById(R.id.item_brand); mColorView = (SellCarColor) findViewById(R.id.item_color); mLocationView = (SellCarItem) findViewById(R.id.item_location); mLevelView = (SellCarItem) findViewById(R.id.item_level); mGearboxView = (SellCarItem) findViewById(R.id.item_gearbox); mDisplacementView = (SellCarEditText) findViewById(R.id.item_displacement); mNewCarPriceView = (SellCarEditText) findViewById(R.id.item_new_car_price); mMileView = (SellCarEditText) findViewById(R.id.item_mile); mPlateNumView = (NewPlateNumberLayout) findViewById(R.id.item_plate_num); mPlateNumView.setScrollView((ScrollView) findViewById(R.id.scroll_view)); mPlateNumView.setNextView(mNewCarPriceView); mPlateNumView.setPlateNumber("", false); mPlateNumView.getCityEditText().addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { mPlateNumView.getNumberEditText().clearValidators(); if (s.length() == 0) { mPlateNumView.getNumberEditText().addValidator( new UsedCarPlateNumberValidator("?", "[A-Z_0-9]{5}$")); } else if (s.length() == 1) { mPlateNumView.getNumberEditText() .addValidator(new UsedCarPlateNumberValidator3("?", "")); mPlateNumView.initKeyboard(com.hxqc.mall.core.R.xml.licence_new_letter); } else if (s.length() == 2) { mPlateNumView.getNumberEditText().addValidator( new UsedCarPlateNumberValidator2("?", "[A-Z_0-9]{5}$")); mPlateNumView.jumpNumKerboard(); } } }); mOnCardView = (SellCarItemChooseDate) findViewById(R.id.item_on_card); mPriceView = (SellCarEditText) findViewById(R.id.item_price); mContactView = (SellCarEditText) findViewById(R.id.item_contact); mMobileView = (SellCarEditText) findViewById(R.id.item_mobile); mLookLocationView = (SellCarItem) findViewById(R.id.item_look_location); mReadmeView = (SellCarReadme) findViewById(R.id.item_readme); mGridView = (GridViewNoSlide) findViewById(R.id.grid_view); mIDPhotoView = (LinearLayout) findViewById(R.id.ll_id_photo); mTextIDPhotoView = (RelativeLayout) findViewById(R.id.rl_id_photo); mDrivingView = (ImageView) findViewById(R.id.iv_driving_license); mRegistrationView = (ImageView) findViewById(R.id.iv_registration); mInvoiceView = (ImageView) findViewById(R.id.iv_invoice); mDrivingDeleteView = (ImageView) findViewById(R.id.iv_driving_license_delete); mRegistrationDeleteView = (ImageView) findViewById(R.id.iv_registration_delete); mInvoiceDeleteView = (ImageView) findViewById(R.id.iv_invoice_delete); mTvIDPhotoView = (TextView) findViewById(R.id.tv_id_photo); mArrowView = (ImageView) findViewById(R.id.iv_arrow); mSubmitView = (Button) findViewById(R.id.submit); mInspectionView = (SellCarItemChooseDate) findViewById(R.id.item_inspection); mStrongView = (SellCarItemChooseDate) findViewById(R.id.item_strong); mCommercialView = (SellCarItemChooseDate) findViewById(R.id.item_commercial); mWarrantyView = (SellCarItemChooseDate) findViewById(R.id.item_warranty); mDeleteViews = new ImageView[] { mDrivingDeleteView, mRegistrationDeleteView, mInvoiceDeleteView }; mLicenseViews = new ImageView[] { mDrivingView, mRegistrationView, mInvoiceView }; mChooseFragment = new ChooseFragment(); mLookCarFragment = new LookCarFragment(); mLocationFragment = new LookCarFragment(); mChooseGearboxFragment = new ChooseGearboxFragment(); mChooseLevelFragment = new ChooseLevelFragment(); mSellCarAddFragment = new SellCarAddFragment(addBrand, addSeries, addModel); mBrandView.setOnSellCarBrandClickListener(this); mLocationFragment.setChooseAreaListener(this); mLookCarFragment.setChooseAreaListener(this); mChooseFragment.setListener(this); mReadmeView.setOnClickListener(this); mChooseGearboxFragment.setListener(this); mChooseLevelFragment.setListener(this); mLookLocationView.setSellCarItemListener(this); mLocationView.setSellCarItemListener(this); mColorView.setSellCarItemListener(this); mTextIDPhotoView.setOnClickListener(this); mDrivingView.setOnClickListener(this); mRegistrationView.setOnClickListener(this); mInvoiceView.setOnClickListener(this); mDrivingDeleteView.setOnClickListener(this); mRegistrationDeleteView.setOnClickListener(this); mInvoiceDeleteView.setOnClickListener(this); mSellCarAddFragment.setOnConfirmListener(this); mGridView.setOnItemClickListener(this); mSubmitView.setOnClickListener(this); mGearboxView.setSellCarItemListener(this); mLevelView.setSellCarItemListener(this); initRight(mChooseFragment); if (UserInfoHelper.getInstance().isLogin(this)) { mMobileView.getInputView().setText(UserInfoHelper.getInstance().getPhoneNumber(this)); mMobileView.getInputView().setEnabled(false); UserInfoHelper.getInstance().getUserInfo(this, new UserInfoHelper.UserInfoAction() { @Override public void showUserInfo(User meData) { if (meData != null && !TextUtils.isEmpty(meData.fullname)) { mContactView.getInputView().setText(meData.fullname); } } @Override public void onFinish() { } }, false); } mVWholeEditManager.addEditView(new EditTextValidatorView[] { mBrandView.getBrandView(), mColorView.getChooseResultView(), mLevelView.getChooseResultView(), mGearboxView.getChooseResultView(), mDisplacementView.getInputView(), mLocationView.getChooseResultView(), mMileView.getInputView(), mOnCardView.getChooseResultView(), mPlateNumView.getNumberEditText(), mPriceView.getInputView(), mContactView.getInputView(), mMobileView.getInputView(), mLookLocationView.getChooseResultView() }); }
From source file:com.gsma.rcs.ri.messaging.OneToOneTalkView.java
private void initialize() throws RcsGenericException, RcsServiceNotAvailableException { mCtx = this;//from w ww . ja v a 2 s . c o m /* Set send button listener */ Button sendBtn = (Button) findViewById(R.id.send_button); sendBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { sendText(); } }); mHandler = new Handler(); mClearUndeliveredChat = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Set<String> msgIds = SingleChatIntentService.getUndelivered(mCtx, mContact); if (!msgIds.isEmpty()) { try { if (LogUtils.isActive) { Log.d(LOGTAG, "Clear delivery expiration for IDs=" + msgIds); } mChatService.clearMessageDeliveryExpiration(msgIds); } catch (RcsServiceException e) { showException(e); } finally { mClearUndeliveredAlertDialog = null; } } } }; mUndeliveredCancelListener = new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mClearUndeliveredAlertDialog = null; } }; mClearUndeliveredFt = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { Set<String> transferIds = FileTransferIntentService.getUndelivered(mCtx, mContact); if (!transferIds.isEmpty()) { if (LogUtils.isActive) { Log.d(LOGTAG, "Clear delivery expiration for IDs=" + transferIds); } mFileTransferService.clearFileTransferDeliveryExpiration(transferIds); mClearUndeliveredAlertDialog = null; } } catch (RcsServiceException e) { showException(e); } finally { mClearUndeliveredAlertDialog = null; } } }; mChatListener = new OneToOneChatListener() { /* Callback called when an Is-composing event has been received */ @Override public void onComposingEvent(ContactId contact, boolean status) { /* Discard event if not for current contact */ if (!contact.equals(mContact)) { return; } if (LogUtils.isActive) { Log.d(LOGTAG, "onComposingEvent contact=" + contact + " status=" + status); } displayComposingEvent(contact, status); } @Override public void onMessageStatusChanged(ContactId contact, String mimeType, String msgId, ChatLog.Message.Content.Status status, ChatLog.Message.Content.ReasonCode reasonCode) { if (LogUtils.isActive) { Log.d(LOGTAG, "onMessageStatusChanged contact=" + contact + " mime-type=" + mimeType + " msgId=" + msgId + " status=" + status); } } @Override public void onMessagesDeleted(ContactId contact, Set<String> msgIds) { if (LogUtils.isActive) { Log.d(LOGTAG, "onMessagesDeleted contact=" + contact + " for IDs=" + msgIds); } } }; mFileTransferListener = new OneToOneFileTransferListener() { @Override public void onStateChanged(ContactId contact, String transferId, FileTransfer.State state, FileTransfer.ReasonCode reasonCode) { if (!contact.equals(mContact)) { return; } if (LogUtils.isActive) { Log.d(LOGTAG, "onStateChanged contact=" + contact + " transferId=" + transferId + " state=" + state + " reason=" + reasonCode); } if (FileTransfer.State.TRANSFERRED == state) { try { FileTransfer fileTransfer = mFileTransferService.getFileTransfer(transferId); if (fileTransfer == null) { return; } if (Utils.isAudioType(fileTransfer.getMimeType()) && FileTransfer.Disposition.RENDER == fileTransfer.getDisposition()) { Utils.playAudio(OneToOneTalkView.this, fileTransfer.getFile()); mFileTransferService.markFileTransferAsRead(transferId); } } catch (RcsPersistentStorageException | RcsServiceNotAvailableException | RcsGenericException e) { showException(e); } } } @Override public void onProgressUpdate(ContactId contact, String transferId, long currentSize, long totalSize) { } @Override public void onDeleted(ContactId contact, Set<String> transferIds) { } }; mChatService = getChatApi(); mCapabilityService = getCapabilityApi(); mFileTransferService = getFileTransferApi(); HistoryUriBuilder uriBuilder = new HistoryUriBuilder(HistoryLog.CONTENT_URI); uriBuilder.appendProvider(ChatLog.Message.HISTORYLOG_MEMBER_ID); uriBuilder.appendProvider(FileTransferLog.HISTORYLOG_MEMBER_ID); mUriHistoryProvider = uriBuilder.build(); mComposeText = (EditText) findViewById(R.id.userText); ChatServiceConfiguration configuration = mChatService.getConfiguration(); // Set max label length int maxMsgLength = configuration.getOneToOneChatMessageMaxLength(); if (maxMsgLength > 0) { /* Set the message composer max length */ InputFilter[] filterArray = new InputFilter[1]; filterArray[0] = new InputFilter.LengthFilter(maxMsgLength); mComposeText.setFilters(filterArray); } IsComposingManager.INotifyComposing iNotifyComposing = new IsComposingManager.INotifyComposing() { public void setTypingStatus(boolean isTyping) { try { if (mChat == null) { return; } mChat.setComposingStatus(isTyping); if (LogUtils.isActive) { Boolean _isTyping = isTyping; Log.d(LOGTAG, "sendIsComposingEvent ".concat(_isTyping.toString())); } } catch (RcsGenericException e) { showException(e); } } }; /* Instantiate the composing manager */ mComposingManager = new IsComposingManager(configuration.getIsComposingTimeout(), iNotifyComposing); mComposeText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // Check if the text is not null. // we do not wish to consider putting the edit text back to null // (like when sending message), is having activity if (!TextUtils.isEmpty(s)) { // Warn the composing manager that we have some activity if (mComposingManager != null) { mComposingManager.hasActivity(); } } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); /* Initialize the adapter. */ mAdapter = new TalkCursorAdapter(this, true, mChatService, mFileTransferService); /* Associate the list adapter with the ListView. */ ListView listView = (ListView) findViewById(android.R.id.list); listView.setDivider(null); listView.setAdapter(mAdapter); registerForContextMenu(listView); }
From source file:com.aidigame.hisun.imengstar.huanxin.ChatActivity.java
/** * initView/* w w w. ja v a 2 s .co m*/ */ protected void initView() { micImage = (ImageView) findViewById(R.id.mic_image); recordingContainer = findViewById(R.id.recording_container); recordingHint = (TextView) findViewById(R.id.recording_hint); listView = (ListView) findViewById(R.id.list); mEditTextContent = (PasteEditText) findViewById(R.id.et_sendmessage); buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard); edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout); buttonSetModeVoice = findViewById(R.id.btn_set_mode_voice); buttonSend = findViewById(R.id.btn_send); buttonPressToSpeak = findViewById(R.id.btn_press_to_speak); expressionViewpager = (ViewPager) findViewById(R.id.vPager); emojiIconContainer = (LinearLayout) findViewById(R.id.ll_face_container); btnContainer = (LinearLayout) findViewById(R.id.ll_btn_container); locationImgview = (ImageView) findViewById(R.id.btn_location); iv_emoticons_normal = (ImageView) findViewById(R.id.iv_emoticons_normal); iv_emoticons_checked = (ImageView) findViewById(R.id.iv_emoticons_checked); loadmorePB = (ProgressBar) findViewById(R.id.pb_load_more); btnMore = (Button) findViewById(R.id.btn_more); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); more = findViewById(R.id.more); edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); // ?, micImages = new Drawable[] { getResources().getDrawable(R.drawable.record_animate_01), getResources().getDrawable(R.drawable.record_animate_02), getResources().getDrawable(R.drawable.record_animate_03), getResources().getDrawable(R.drawable.record_animate_04), getResources().getDrawable(R.drawable.record_animate_05), getResources().getDrawable(R.drawable.record_animate_06), getResources().getDrawable(R.drawable.record_animate_07), getResources().getDrawable(R.drawable.record_animate_08), getResources().getDrawable(R.drawable.record_animate_09), getResources().getDrawable(R.drawable.record_animate_10), getResources().getDrawable(R.drawable.record_animate_11), getResources().getDrawable(R.drawable.record_animate_12), getResources().getDrawable(R.drawable.record_animate_13), getResources().getDrawable(R.drawable.record_animate_14), }; // list reslist = getExpressionRes(44); // ?viewpager List<View> views = new ArrayList<View>(); View gv1 = getGridChildView(1); View gv2 = getGridChildView(2); View gv3 = getGridChildView(3); views.add(gv1); views.add(gv2); views.add(gv3); expressionViewpager.setAdapter(new ExpressionPagerAdapter(views)); edittext_layout.requestFocus(); voiceRecorder = new VoiceRecorder(micImageHandler); buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen()); mEditTextContent.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); } else { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); } } }); mEditTextContent.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); } }); // ? mEditTextContent.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!TextUtils.isEmpty(s)) { btnMore.setVisibility(View.GONE); buttonSend.setVisibility(View.VISIBLE); } else { btnMore.setVisibility(View.VISIBLE); buttonSend.setVisibility(View.GONE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); }
From source file:com.owncloud.android.authentication.AuthenticatorActivity.java
/** * {@inheritDoc}/*from w w w.j a v a 2 s . co m*/ * * IMPORTANT ENTRY POINT 1: activity is shown to the user */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.account_setup); mAuthMessage = (TextView) findViewById(R.id.auth_message); mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput); mHostUrlInput.setText(getString(R.string.server_url)); // valid although // R.string.server_url // is an empty // string mUsernameInput = (EditText) findViewById(R.id.account_username); mPasswordInput = (EditText) findViewById(R.id.account_password); mPasswordInput2 = (EditText) findViewById(R.id.account_password2); mOAuthAuthEndpointText = (TextView) findViewById(R.id.oAuthEntryPoint_1); mOAuthTokenEndpointText = (TextView) findViewById(R.id.oAuthEntryPoint_2); mOAuth2Check = (CheckBox) findViewById(R.id.oauth_onOff_check); mOkButton = findViewById(R.id.buttonOK); mAuthStatusLayout = (TextView) findViewById(R.id.auth_status_text); // / set Host Url Input Enabled mHostUrlInputEnabled = getResources().getBoolean(R.bool.show_server_url_input); locationSpinner = (Spinner) findViewById(R.id.spinner1); // / complete label for 'register account' button Button b = (Button) findViewById(R.id.account_register); if (b != null) { b.setText(String.format(getString(R.string.auth_register), getString(R.string.app_name))); } // / initialization mAccountMgr = AccountManager.get(this); mNewCapturedUriFromOAuth2Redirection = null; mAction = getIntent().getByteExtra(EXTRA_ACTION, ACTION_CREATE); mAccount = null; mHostBaseUrl = ""; location = " ";//locationSpinner.getSelectedItem(); locationSpinner.setOnItemSelectedListener(this); boolean refreshButtonEnabled = false; // URL input configuration applied if (!mHostUrlInputEnabled) { findViewById(R.id.hostUrlFrame).setVisibility(View.GONE); mRefreshButton = findViewById(R.id.centeredRefreshButton); } else { mRefreshButton = findViewById(R.id.embeddedRefreshButton); } if (savedInstanceState == null) { mResumed = false; // / connection state and info mAuthMessageVisibility = View.GONE; mServerStatusText = mServerStatusIcon = 0; mServerIsValid = false; mServerIsChecked = false; mIsSslConn = false; mAuthStatusText = mAuthStatusIcon = 0; // / retrieve extras from intent mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT); if (mAccount != null) { String ocVersion = mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION); Log.d("!!!!!!!!!!!!!!!!!!!!!!!!! ", mAccount.name); if (ocVersion != null) { mDiscoveredVersion = new OwnCloudVersion(ocVersion); } mHostBaseUrl = normalizeUrl( mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL)); mHostUrlInput.setText(mHostBaseUrl); String userName = mAccount.name.substring(0, mAccount.name.lastIndexOf('@')); Log.d("!!!!!!!!!!!!!!!!!!!!!!!!!4234 ", userName); mUsernameInput.setText(userName); } initAuthorizationMethod(); // checks intent and setup.xml to // determine mCurrentAuthorizationMethod mJustCreated = true; if (mAction == ACTION_UPDATE_TOKEN || !mHostUrlInputEnabled) { checkOcServer(); } } else { mResumed = true; // / connection state and info mAuthMessageVisibility = savedInstanceState.getInt(KEY_AUTH_MESSAGE_VISIBILITY); mAuthMessageText = savedInstanceState.getString(KEY_AUTH_MESSAGE_TEXT); mServerIsValid = savedInstanceState.getBoolean(KEY_SERVER_VALID); mServerIsChecked = savedInstanceState.getBoolean(KEY_SERVER_CHECKED); mServerStatusText = savedInstanceState.getInt(KEY_SERVER_STATUS_TEXT); mServerStatusIcon = savedInstanceState.getInt(KEY_SERVER_STATUS_ICON); mIsSslConn = savedInstanceState.getBoolean(KEY_IS_SSL_CONN); mAuthStatusText = savedInstanceState.getInt(KEY_AUTH_STATUS_TEXT); mAuthStatusIcon = savedInstanceState.getInt(KEY_AUTH_STATUS_ICON); if (savedInstanceState.getBoolean(KEY_PASSWORD_VISIBLE, false)) { showPassword(); } // / server data String ocVersion = savedInstanceState.getString(KEY_OC_VERSION); if (ocVersion != null) { mDiscoveredVersion = new OwnCloudVersion(ocVersion); } mHostBaseUrl = savedInstanceState.getString(KEY_HOST_URL_TEXT); // account data, if updating mAccount = savedInstanceState.getParcelable(KEY_ACCOUNT); // Log.d("////////////////// ",mAccount.name); mAuthTokenType = savedInstanceState.getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE); if (mAuthTokenType == null) { mAuthTokenType = AccountAuthenticator.AUTH_TOKEN_TYPE_PASSWORD; } // check if server check was interrupted by a configuration change if (savedInstanceState.getBoolean(KEY_SERVER_CHECK_IN_PROGRESS, false)) { checkOcServer(); } // refresh button enabled refreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED); } if (mAuthMessageVisibility == View.VISIBLE) { showAuthMessage(mAuthMessageText); } else { hideAuthMessage(); } adaptViewAccordingToAuthenticationMethod(); showServerStatus(); showAuthStatus(); if (mAction == ACTION_UPDATE_TOKEN) { // / lock things that should not change mHostUrlInput.setEnabled(false); mHostUrlInput.setFocusable(false); mUsernameInput.setEnabled(false); mUsernameInput.setFocusable(false); mOAuth2Check.setVisibility(View.GONE); } // if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled) // showRefreshButton(); if (mServerIsChecked && !mServerIsValid && refreshButtonEnabled) showRefreshButton(); mOkButton.setEnabled(mServerIsValid); // state not automatically // recovered in configuration // changes if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType) || !AUTH_OPTIONAL.equals(getString(R.string.auth_method_oauth2))) { mOAuth2Check.setVisibility(View.GONE); } mPasswordInput.setText(""); // clean password to avoid social hacking // (disadvantage: password in removed if the // device is turned aside) // / bind view elements to listeners and other friends mHostUrlInput.setOnFocusChangeListener(this); mHostUrlInput.setImeOptions(EditorInfo.IME_ACTION_NEXT); mHostUrlInput.setOnEditorActionListener(this); mHostUrlInput.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (!mHostBaseUrl.equals(normalizeUrl(mHostUrlInput.getText().toString()))) { mOkButton.setEnabled(false); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!mResumed) { mAuthStatusIcon = 0; mAuthStatusText = 0; showAuthStatus(); } mResumed = false; } }); mPasswordInput.setOnFocusChangeListener(this); mPasswordInput.setImeOptions(EditorInfo.IME_ACTION_DONE); mPasswordInput.setOnEditorActionListener(this); mPasswordInput.setOnTouchListener(new RightDrawableOnTouchListener() { @Override public boolean onDrawableTouch(final MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { AuthenticatorActivity.this.onViewPasswordClick(); } return true; } }); findViewById(R.id.scroll).setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType) && mHostUrlInput.hasFocus()) { checkOcServer(); } } return false; } }); }
From source file:com.ericsun.duom.Framework.Activity.BaseActivity.java
public void setPricePoint(final EditText editText) { editText.addTextChangedListener(new TextWatcher() { @Override/*from www. j a v a2 s . c o m*/ public void onTextChanged(CharSequence s, int start, int before, int count) { if (s.toString().contains(".")) { if (s.length() - 1 - s.toString().indexOf(".") > 2) { s = s.toString().subSequence(0, s.toString().indexOf(".") + 3); editText.setText(s); editText.setSelection(s.length()); } } if (s.toString().trim().substring(0).equals(".")) { s = ""; } if (s.toString().startsWith("0") && s.toString().trim().length() > 1) { if (!s.toString().substring(1, 2).equals(".")) { editText.setText(s.subSequence(0, 1)); editText.setSelection(1); return; } } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable editable) { // TODO Auto-generated method stub } }); }
From source file:com.keylesspalace.tusky.activity.ComposeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_compose); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from www . java 2 s .c om ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(null); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); Drawable closeIcon = AppCompatResources.getDrawable(this, R.drawable.ic_close_24dp); ThemeUtils.setDrawableTint(this, closeIcon, R.attr.compose_close_button_tint); actionBar.setHomeAsUpIndicator(closeIcon); } SharedPreferences preferences = getSharedPreferences(getString(R.string.preferences_file_key), Context.MODE_PRIVATE); floatingBtn = (Button) findViewById(R.id.floating_btn); pickBtn = (ImageButton) findViewById(R.id.compose_photo_pick); nsfwBtn = (Button) findViewById(R.id.action_toggle_nsfw); ImageButton visibilityBtn = (ImageButton) findViewById(R.id.action_toggle_visibility); floatingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { sendStatus(); } }); pickBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onMediaPick(); } }); nsfwBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleNsfw(); } }); visibilityBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showComposeOptions(); } }); String startingVisibility; boolean startingHideText; ArrayList<SavedQueuedMedia> savedMediaQueued = null; if (savedInstanceState != null) { showMarkSensitive = savedInstanceState.getBoolean("showMarkSensitive"); startingVisibility = savedInstanceState.getString("statusVisibility"); statusMarkSensitive = savedInstanceState.getBoolean("statusMarkSensitive"); startingHideText = savedInstanceState.getBoolean("statusHideText"); // Keep these until everything needed to put them in the queue is finished initializing. savedMediaQueued = savedInstanceState.getParcelableArrayList("savedMediaQueued"); // These are for restoring an in-progress commit content operation. InputContentInfoCompat previousInputContentInfo = InputContentInfoCompat .wrap(savedInstanceState.getParcelable("commitContentInputContentInfo")); int previousFlags = savedInstanceState.getInt("commitContentFlags"); if (previousInputContentInfo != null) { onCommitContentInternal(previousInputContentInfo, previousFlags); } } else { showMarkSensitive = false; startingVisibility = preferences.getString("rememberedVisibility", "public"); statusMarkSensitive = false; startingHideText = false; } updateNsfwButtonColor(); Intent intent = getIntent(); String[] mentionedUsernames = null; inReplyToId = null; if (intent != null) { inReplyToId = intent.getStringExtra("in_reply_to_id"); String replyVisibility = intent.getStringExtra("reply_visibility"); if (replyVisibility != null && startingVisibility != null) { // Lowest possible visibility setting in response if (startingVisibility.equals("private") || replyVisibility.equals("private")) { startingVisibility = "private"; } else if (startingVisibility.equals("unlisted") || replyVisibility.equals("unlisted")) { startingVisibility = "unlisted"; } else { startingVisibility = replyVisibility; } } mentionedUsernames = intent.getStringArrayExtra("mentioned_usernames"); } /* Only after the starting visibility is determined and the send button is initialised can * the status visibility be set. */ setStatusVisibility(startingVisibility); textEditor = createEditText(null); // new String[] { "image/gif", "image/webp" } final int mentionColour = ThemeUtils.getColor(this, R.attr.compose_mention_color); if (savedInstanceState != null) { restoreTextEditorState(savedInstanceState.getParcelable("textEditorState")); highlightSpans(textEditor.getText(), mentionColour); } RelativeLayout editArea = (RelativeLayout) findViewById(R.id.compose_edit_area); /* Adding this at index zero because it implicitly gives it the lowest input priority. So, * when media previews are added in front of the editor, they can receive click events * without the text editor stealing the events from behind them. */ editArea.addView(textEditor, 0); contentWarningEditor = (EditText) findViewById(R.id.field_content_warning); final TextView charactersLeft = (TextView) findViewById(R.id.characters_left); textEditor.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { int left = STATUS_CHARACTER_LIMIT - s.length() - contentWarningEditor.length(); charactersLeft.setText(String.format(Locale.getDefault(), "%d", left)); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable editable) { highlightSpans(editable, mentionColour); } }); if (mentionedUsernames != null) { StringBuilder builder = new StringBuilder(); for (String name : mentionedUsernames) { builder.append('@'); builder.append(name); builder.append(' '); } textEditor.setText(builder); textEditor.setSelection(textEditor.length()); } mediaPreviewBar = (LinearLayout) findViewById(R.id.compose_media_preview_bar); mediaQueued = new ArrayList<>(); waitForMediaLatch = new CountUpDownLatch(); contentWarningBar = findViewById(R.id.compose_content_warning_bar); contentWarningEditor.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { int left = STATUS_CHARACTER_LIMIT - s.length() - textEditor.length(); charactersLeft.setText(String.format(Locale.getDefault(), "%d", left)); } @Override public void afterTextChanged(Editable s) { } }); showContentWarning(startingHideText); statusAlreadyInFlight = false; // These can only be added after everything affected by the media queue is initialized. if (savedMediaQueued != null) { for (SavedQueuedMedia item : savedMediaQueued) { addMediaToQueue(item.type, item.preview, item.uri, item.mediaSize); } } }
From source file:com.irccloud.android.activity.MainActivity.java
@SuppressLint("NewApi") @SuppressWarnings({ "deprecation", "unchecked" }) @Override// www .j a v a 2 s .co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); suggestionsTimer = new Timer("suggestions-timer"); countdownTimer = new Timer("messsage-countdown-timer"); IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(screenReceiver, filter); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); if (cloud != null) { setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, 0xFFF2F7FC)); cloud.recycle(); } } setContentView(R.layout.activity_message); try { setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); } catch (Throwable t) { } suggestionsAdapter = new SuggestionsAdapter(); progressBar = (ProgressBar) findViewById(R.id.progress); errorMsg = (TextView) findViewById(R.id.errorMsg); buffersListView = findViewById(R.id.BuffersList); messageContainer = (LinearLayout) findViewById(R.id.messageContainer); drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); redColor = getResources().getColor(R.color.highlight_red); blueColor = getResources().getColor(R.color.dark_blue); messageTxt = (ActionEditText) findViewById(R.id.messageTxt); messageTxt.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (sendBtn.isEnabled() && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED && event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER && messageTxt.getText() != null && messageTxt.getText().length() > 0) { sendBtn.setEnabled(false); new SendTask().execute((Void) null); } else if (keyCode == KeyEvent.KEYCODE_TAB) { if (event.getAction() == KeyEvent.ACTION_DOWN) nextSuggestion(); return true; } return false; } }); messageTxt.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (drawerLayout != null && v == messageTxt && hasFocus) { drawerLayout.closeDrawers(); update_suggestions(false); } else if (!hasFocus) { runOnUiThread(new Runnable() { @Override public void run() { suggestionsContainer.setVisibility(View.INVISIBLE); } }); } } }); messageTxt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (drawerLayout != null) { drawerLayout.closeDrawers(); } } }); messageTxt.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (sendBtn.isEnabled() && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED && actionId == EditorInfo.IME_ACTION_SEND && messageTxt.getText() != null && messageTxt.getText().length() > 0) { sendBtn.setEnabled(false); new SendTask().execute((Void) null); } return true; } }); textWatcher = new TextWatcher() { public void afterTextChanged(Editable s) { Object[] spans = s.getSpans(0, s.length(), Object.class); for (Object o : spans) { if (((s.getSpanFlags(o) & Spanned.SPAN_COMPOSING) != Spanned.SPAN_COMPOSING) && (o.getClass() == StyleSpan.class || o.getClass() == ForegroundColorSpan.class || o.getClass() == BackgroundColorSpan.class || o.getClass() == UnderlineSpan.class || o.getClass() == URLSpan.class)) { s.removeSpan(o); } } if (s.length() > 0 && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED) { sendBtn.setEnabled(true); if (Build.VERSION.SDK_INT >= 11) sendBtn.setAlpha(1); } else { sendBtn.setEnabled(false); if (Build.VERSION.SDK_INT >= 11) sendBtn.setAlpha(0.5f); } String text = s.toString(); if (text.endsWith("\t")) { //Workaround for Swype text = text.substring(0, text.length() - 1); messageTxt.setText(text); nextSuggestion(); } else if (suggestionsContainer != null && suggestionsContainer.getVisibility() == View.VISIBLE) { runOnUiThread(new Runnable() { @Override public void run() { update_suggestions(false); } }); } else { if (suggestionsTimer != null) { if (suggestionsTimerTask != null) suggestionsTimerTask.cancel(); suggestionsTimerTask = new TimerTask() { @Override public void run() { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); update_suggestions(false); } }; suggestionsTimer.schedule(suggestionsTimerTask, 250); } } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }; messageTxt.addTextChangedListener(textWatcher); sendBtn = findViewById(R.id.sendBtn); sendBtn.setFocusable(false); sendBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED) new SendTask().execute((Void) null); } }); photoBtn = findViewById(R.id.photoBtn); if (photoBtn != null) { photoBtn.setFocusable(false); photoBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { insertPhoto(); } }); } userListView = findViewById(R.id.usersListFragment); View v = getLayoutInflater().inflate(R.layout.actionbar_messageview, null); v.findViewById(R.id.actionTitleArea).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { show_topic_popup(); } }); if (drawerLayout != null) { if (findViewById(R.id.usersListFragment2) == null) { upDrawable = new DrawerArrowDrawable(this); greyColor = upDrawable.getColor(); ((Toolbar) findViewById(R.id.toolbar)).setNavigationIcon(upDrawable); ((Toolbar) findViewById(R.id.toolbar)).setNavigationContentDescription("Show navigation drawer"); drawerLayout.setDrawerListener(mDrawerListener); if (refreshUpIndicatorTask != null) refreshUpIndicatorTask.cancel(true); refreshUpIndicatorTask = new RefreshUpIndicatorTask(); refreshUpIndicatorTask.execute((Void) null); } } messageTxt.setDrawerLayout(drawerLayout); title = (TextView) v.findViewById(R.id.title); subtitle = (TextView) v.findViewById(R.id.subtitle); key = (ImageView) v.findViewById(R.id.key); getSupportActionBar().setCustomView(v); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); if (savedInstanceState != null && savedInstanceState.containsKey("cid")) { server = ServersDataSource.getInstance().getServer(savedInstanceState.getInt("cid")); buffer = BuffersDataSource.getInstance().getBuffer(savedInstanceState.getInt("bid")); backStack = (ArrayList<Integer>) savedInstanceState.getSerializable("backStack"); } if (savedInstanceState != null && savedInstanceState.containsKey("imagecaptureuri")) imageCaptureURI = Uri.parse(savedInstanceState.getString("imagecaptureuri")); else imageCaptureURI = null; ConfigInstance config = (ConfigInstance) getLastCustomNonConfigurationInstance(); if (config != null) { imgurTask = config.imgurUploadTask; fileUploadTask = config.fileUploadTask; } drawerLayout.setScrimColor(0); drawerLayout.closeDrawers(); getSupportActionBar().setElevation(0); }
From source file:com.huofu.RestaurantOS.ui.splash.activate.java
/** * ?/* w w w . ja v a2s . co m*/ */ public void widgetConfigure() { buttonActivate.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (authDialog == null) { authDialog = new Dialog(activate.this, R.style.PauseDialog); } if (ttv.getParent() != null) { ttv = new TitanicTextView(ctxt); } String key = etActivteCode.getText().toString(); if (key.length() >= 16) { CommonUtils.LogWuwei(tag, "key is " + key); CommonUtils.sendMsg("?", activate.SHOW_LOADING_TEXT, mUiHandler); activate(ctxt, key); } else { CommonUtils.sendMsg("????", activate.SHOW_ERROR_MESSAGE, mUiHandler); } } }); InputFilter filter = new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { // TODO Auto-generated method stub for (int i = start; i < end; i++) { //???'-' if (!Character.isLetter(source.charAt(i)) && source.charAt(i) != '-') { return ""; } } return null; } }; InputFilter filterLength = new InputFilter.LengthFilter(19); etActivteCode.setCursorVisible(false); etActivteCode.setFilters(new InputFilter[] { filter, filterLength }); etActivteCode.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub etActivteCode.setCursorVisible(true); etActivteCode.removeTextChangedListener(this);// ? etActivteCode.setText(s.toString().toUpperCase());// ? etActivteCode.setSelection(s.toString().length());// ?? etActivteCode.addTextChangedListener(this);// ? String licensePlateNumber = etActivteCode.getText().toString().trim(); if (s.length() == 19) { InputMethodUtils.HideKeyboard(etActivteCode); } } }); etActivteCode.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_DEL) { CommonUtils.LogWuwei(tag, "delete"); etActivteCode.setCursorVisible(false); } return false; } }); rl_activate_qrscan_ready.setVisibility(View.INVISIBLE); OnClickListener oclGetQrCode = new OnClickListener() { @Override public void onClick(View v) { flagInQrcodeDialog = true; CommonUtils.sendMsg("??", SHOW_LOADING_TEXT, mUiHandler); if (LocalDataDeal.readFromLocalPublicKey(ctxt) == null || LocalDataDeal.readFromLocalPublicKey(ctxt).equals("")) { ApisManager.GetPublicKey(new ApiCallback() { @Override public void success(Object object) { sendUIMessage(HIDE_LOADING, ""); try { org.json.JSONObject obj = new org.json.JSONObject((String) object); String public_key = obj.getString("public_key"); LocalDataDeal.writeToLocalPublicKey(public_key, ctxt);//key?base64? } catch (Exception e) { } CommonUtils.sendMsg("", GET_QRCODE, mUiHandler); } @Override public void error(BaseApi.ApiResponse response) { sendUIMessage(HIDE_LOADING, ""); sendUIMessage(SHOW_ERROR_MESSAGE, response.error_message); } }); } else { CommonUtils.sendMsg("", GET_QRCODE, mUiHandler); } rl_activate_input.setVisibility(View.INVISIBLE); rl_activate_qrscan_ready.setVisibility(View.VISIBLE); imageViewQrcode.setVisibility(View.INVISIBLE); rl_activate_qrscan_ready .startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big)); textviewScanStauts.setTextColor(Color.parseColor("#898989")); textviewScanStauts.setText(R.string.activateByQrCodeTips); rl_activate_qrscan_ready .startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_left_in)); rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_right_out)); } }; buttonSwitchQrScan.setOnClickListener(oclGetQrCode); findViewById(R.id.rl_switch_activate_qrcode_way).setOnClickListener(oclGetQrCode); buttonSwitchInputCode.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub flagInQrcodeDialog = false; flagWaitingCmd = false; rl_activate_qrscan_ready.setVisibility(View.INVISIBLE); rl_activate_input.setVisibility(View.VISIBLE); rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big)); stopQrScanTimer(); rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_right_in)); rl_activate_qrscan_ready .startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_left_out)); } }); findViewById(R.id.rl_switch_activate_keyboard_way).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub flagInQrcodeDialog = false; flagWaitingCmd = false; rl_activate_qrscan_ready.setVisibility(View.INVISIBLE); rl_activate_input.setVisibility(View.VISIBLE); rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big)); stopQrScanTimer(); } }); PackageManager manager; PackageInfo info = null; manager = this.getPackageManager(); String versionName = null; try { info = manager.getPackageInfo(this.getPackageName(), 0); versionName = info.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } ((TextView) findViewById(R.id.tv_app_version)) .setText(getResources().getString(R.string.app_name) + " V" + versionName); LocalDataDeal.writeToLocalVersion(versionName, ctxt); LocalDataDeal.writeToLocalVersionCode(info.versionCode, ctxt); ftpServiceStart(); }
From source file:com.brewcrewfoo.performance.fragments.MemSettings.java
public void ProcEditDialog(final String key, String title, String msg, String path, Boolean type) { Resources res = getActivity().getResources(); final String cancel = res.getString(R.string.cancel); final String ok = res.getString(R.string.ps_volt_save); LayoutInflater factory = LayoutInflater.from(getActivity()); final View alphaDialog = factory.inflate(R.layout.sh_dialog, null); final String namespath = path; settingText = (EditText) alphaDialog.findViewById(R.id.shText); settingText.setText(mPreferences.getString(key, "")); settingText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override/*from w ww .jav a 2s . c om*/ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { return true; } }); settingText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); new AlertDialog.Builder(getActivity()).setTitle(title).setMessage(msg).setView(alphaDialog) .setNegativeButton(cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { /* nothing */ } }).setPositiveButton(ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final SharedPreferences.Editor editor = mPreferences.edit(); editor.putString(key, settingText.getText().toString()).commit(); new CMDProcessor().su.runWaitFor("busybox echo " + mPreferences.getString(key, Helpers.readOneLine(namespath)) + " > " + namespath); } }).create().show(); }
From source file:sjizl.com.ChatActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (CommonUtilities.isInternetAvailable(getApplicationContext())) //returns true if internet available {/*from ww w .java 2 s . co m*/ SharedPreferences sp = getApplicationContext().getSharedPreferences("loginSaved", Context.MODE_PRIVATE); pid = sp.getString("pid", null); naam = sp.getString("naam", null); username = sp.getString("username", null); password = sp.getString("password", null); foto = sp.getString("foto", null); foto_num = sp.getString("foto_num", null); Bundle bundle = getIntent().getExtras(); pid_user = bundle.getString("pid_user"); user = bundle.getString("user"); user_foto_num = bundle.getString("user_foto_num"); user_foto = bundle.getString("user_foto"); // Toast.makeText(getApplicationContext(), "pid_user"+pid_user, Toast.LENGTH_SHORT).show(); if (user.equalsIgnoreCase(naam.toString())) { Toast.makeText(getApplicationContext(), "You can't message yourself!", Toast.LENGTH_SHORT).show(); finish(); } AbsListViewBaseActivity.imageLoader.init(ImageLoaderConfiguration.createDefault(getBaseContext())); //registerReceiver(mHandleMessageReceiver2, new IntentFilter(DISPLAY_MESSAGE_ACTION)); setContentView(R.layout.activity_chat); imageLoader.loadImage("https://www.sjizl.com/fotos/" + user_foto_num + "/thumbs/" + user_foto + "", new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { d1 = new BitmapDrawable(getResources(), loadedImage); } }); imageLoader.loadImage("https://www.sjizl.com/fotos/" + foto_num + "/thumbs/" + foto + "", new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { d2 = new BitmapDrawable(getResources(), loadedImage); } }); smilbtn = (ImageView) findViewById(R.id.smilbtn); listView = (ListView) findViewById(android.R.id.list); underlayout = (LinearLayout) findViewById(R.id.underlayout); smiles_layout = (LinearLayout) findViewById(R.id.smiles); textView1_bgtext = (TextView) findViewById(R.id.textView1_bgtext); textView1_bgtext.setText(user); imageView2_dashboard = (ImageView) findViewById(R.id.imageView2_dashboard); imageView1_logo = (ImageView) findViewById(R.id.imageView1_logo); imageView_bericht = (ImageView) findViewById(R.id.imageView_bericht); textView2_under_title = (TextView) findViewById(R.id.textView2_under_title); right_lin = (LinearLayout) findViewById(R.id.right_lin); left_lin1 = (LinearLayout) findViewById(R.id.left_lin1); left_lin3 = (LinearLayout) findViewById(R.id.left_lin3); left_lin4 = (LinearLayout) findViewById(R.id.left_lin4); middle_lin = (LinearLayout) findViewById(R.id.middle_lin); smile_lin = (LinearLayout) findViewById(R.id.smile_lin); ber_lin = (LinearLayout) findViewById(R.id.ber_lin); progressBar_hole = (ProgressBar) findViewById(R.id.progressBar_hole); progressBar_hole.setVisibility(View.INVISIBLE); imageLoader.displayImage("http://sjizl.com/fotos/" + user_foto_num + "/thumbs/" + user_foto, imageView2_dashboard, options); new UpdateChat().execute(); mNewMessage = (EditText) findViewById(R.id.newmsg); ber_lin = (LinearLayout) findViewById(R.id.ber_lin); photosend = (ImageView) findViewById(R.id.photosend); /* if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { imageLoader.loadImage("http://sjizl.com/fotos/"+user_foto_num+"/thumbs/"+user_foto, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { super.onLoadingComplete(imageUri, view, loadedImage); Bitmap LoadedImage2 = loadedImage; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { if(loadedImage!=null){ LoadedImage2 = CommonUtilities.fastblur16(loadedImage, 4,getApplicationContext()); } } if (Build.VERSION.SDK_INT >= 16) { listView.setBackground(new BitmapDrawable(getApplicationContext().getResources(), LoadedImage2)); } else { listView.setBackgroundDrawable(new BitmapDrawable(LoadedImage2)); } } } ); } */ final ImageView left_button; left_button = (ImageView) findViewById(R.id.imageView1_back); CommonUtilities u = new CommonUtilities(); u.setHeaderConrols(getApplicationContext(), this, right_lin, left_lin3, left_lin4, left_lin1, left_button); listView.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { mScrollState = scrollState; } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); listView.setLongClickable(true); registerForContextMenu(listView); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); viewPager_smiles = new ViewPager(this); viewPager_smiles.setId(0x1000); LayoutParams layoutParams555 = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); layoutParams555.width = LayoutParams.MATCH_PARENT; layoutParams555.height = (metrics.heightPixels / 2); viewPager_smiles.setLayoutParams(layoutParams555); TabsPagerAdapter mAdapter = new TabsPagerAdapter(getSupportFragmentManager(), mNewMessage); viewPager_smiles.setAdapter(mAdapter); LayoutInflater inflater = null; viewPager_smiles.setVisibility(View.VISIBLE); smiles_layout.addView(viewPager_smiles); smiles_layout.setVisibility(View.GONE); left_lin4.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { Intent profile = new Intent(getApplicationContext(), ProfileActivityMain.class); profile.putExtra("user", user); profile.putExtra("user_foto", user_foto); profile.putExtra("user_foto_num", user_foto_num); profile.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(profile); } return false; } }); middle_lin.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { Intent profile = new Intent(getApplicationContext(), ProfileActivityMain.class); profile.putExtra("user", user); profile.putExtra("user_foto", user_foto); profile.putExtra("user_foto_num", user_foto_num); profile.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(profile); } return false; } }); smile_lin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { opensmiles(); } }); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent dashboard = new Intent(getApplicationContext(), ProfileActivityMain.class); dashboard.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); dashboard.putExtra("user", ArrChatLines.get(position).getNaam()); dashboard.putExtra("user_foto", foto); dashboard.putExtra("user_foto_num", foto_num); startActivity(dashboard); } }); mNewMessage.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { v.setFocusable(true); v.setFocusableInTouchMode(true); smiles_layout.setVisibility(View.GONE); smilbtn.setImageResource(R.drawable.emoji_btn_normal); return false; } return false; } }); TextWatcher textWatcher = new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { //after text changed } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { if (ArrChatLines.get(0).getblocked_profile().equals("1")) { } else if (ArrChatLines.get(0).getblocked_profile2().equals("1")) { } else { CommonUtilities.startandsendwebsock( "" + pid_user + " " + naam + " " + pid + " is typing to you ..."); } } @Override public void afterTextChanged(Editable s) { /* AsyncHttpClient.getDefaultInstance().websocket("ws://sjizl.com:9300", "my-protocol", new WebSocketConnectCallback() { @Override public void onCompleted(Exception ex, WebSocket webSocket) { if (ex != null) { ex.printStackTrace(); return; } webSocket.send(""+pid_user+" "+naam+" "+pid+" is typing to you ..."); webSocket.close(); } }); */ } }; photosend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (ArrChatLines.get(0).getblocked_profile().equals("1")) { } else if (ArrChatLines.get(0).getblocked_profile2().equals("1")) { } else { openGallery(SELECT_FILE1); } } }); mNewMessage.addTextChangedListener(textWatcher); ber_lin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { SpannableStringBuilder spanStr = (SpannableStringBuilder) mNewMessage.getText(); Spanned cs = (Spanned) mNewMessage.getText(); String a = Html.toHtml(spanStr); String text = mNewMessage.getText().toString(); mNewMessage.setText(""); mNewMessage.requestFocus(); mybmp2 = "http://sjizl.com/fotos/" + foto_num + "/thumbs/" + foto; if (text.length() < 1) { } else { addItem(foto, foto_num, "0", naam, text.toString(), "http://sjizl.com/fotos/" + foto_num + "/thumbs/" + foto, "", a); } } }); hideSoftKeyboard(); } else { Intent dashboard = new Intent(getApplicationContext(), NoInternetActivity.class); dashboard.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(dashboard); finish(); } mNewMessage.clearFocus(); listView.requestFocus(); final String wsuri = "ws://sjizl.com:9300"; WebSocketConnection mConnection8 = new WebSocketConnection(); if (mConnection8.isConnected()) { mConnection8.reconnect(); } else { try { mConnection8.connect(wsuri, new WebSocketConnectionHandler() { @Override public void onOpen() { Log.d("TAG", "Status: Connected to " + wsuri); } @Override public void onTextMessage(String payload) { if (payload.contains("message send")) { String[] parts = payload.split(" "); String zender = parts[0]; String send_from = parts[1]; String send_name = parts[2]; String send_foto = parts[3]; String send_foto_num = parts[4]; String send_xxx = parts[5]; // Toast.makeText(getApplication(), "" + "\n zender: "+zender+"" + "\n pid_user: "+pid_user+"" +"\n pid: "+pid+"" + // "\n send_from: "+send_from, // Toast.LENGTH_LONG).show(); if (zender.equalsIgnoreCase(pid) || zender.equalsIgnoreCase(pid_user)) { if (send_from.equalsIgnoreCase(pid_user) || send_from.equalsIgnoreCase(pid)) { //Toast.makeText(getApplication(), "uu", Toast.LENGTH_LONG).show(); new UpdateChat().execute(); } } } else if (payload.contains("is typing to you")) { String[] parts = payload.split(" "); String part1 = parts[0]; // 004 is_typing_name = parts[1]; // 034556 if (is_typing_name.equalsIgnoreCase(user)) { if (ArrChatLines.size() > 0) { oldvalue = ArrChatLines.get(0).getLaatstOnline(); } else { oldvalue = textView2_under_title.getText().toString(); } Timer t = new Timer(false); t.schedule(new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { public void run() { textView2_under_title.setText("typing ..."); } }); } }, 2); Timer t2 = new Timer(false); t2.schedule(new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { public void run() { textView2_under_title.setText(oldvalue); } }); } }, 2000); } } Log.d("TAG", "Got echo: " + payload); } @Override public void onClose(int code, String reason) { Log.d("TAG", "Connection lost."); } }); } catch (WebSocketException e) { Log.d("TAG", e.toString()); } } }