List of usage examples for android.content Context VIBRATOR_SERVICE
String VIBRATOR_SERVICE
To view the source code for android.content Context VIBRATOR_SERVICE.
Click Source Link
From source file:org.telegram.ui.ChannelEditTypeActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override/*w w w.ja v a 2 s. c o m*/ public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { if (donePressed) { return; } if (!isPrivate && ((currentChat.username == null && nameTextView.length() != 0) || (currentChat.username != null && !currentChat.username .equalsIgnoreCase(nameTextView.getText().toString())))) { if (nameTextView.length() != 0 && !lastNameAvailable) { Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE); if (v != null) { v.vibrate(200); } AndroidUtilities.shakeView(checkTextView, 2, 0); return; } } donePressed = true; String oldUserName = currentChat.username != null ? currentChat.username : ""; String newUserName = isPrivate ? "" : nameTextView.getText().toString(); if (!oldUserName.equals(newUserName)) { MessagesController.getInstance().updateChannelUserName(chatId, newUserName); } finishFragment(); } } }); ActionBarMenu menu = actionBar.createMenu(); menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); fragmentView = new ScrollView(context); fragmentView.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background)); ScrollView scrollView = (ScrollView) fragmentView; scrollView.setFillViewport(true); linearLayout = new LinearLayout(context); scrollView.addView(linearLayout, new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); linearLayout.setOrientation(LinearLayout.VERTICAL); if (currentChat.megagroup) { actionBar.setTitle(LocaleController.getString("GroupType", R.string.GroupType)); } else { actionBar.setTitle(LocaleController.getString("ChannelType", R.string.ChannelType)); } LinearLayout linearLayout2 = new LinearLayout(context); linearLayout2.setOrientation(LinearLayout.VERTICAL); linearLayout2.setElevation(AndroidUtilities.dp(2)); linearLayout2.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); linearLayout.addView(linearLayout2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); radioButtonCell1 = new RadioButtonCell(context); radioButtonCell1.setElevation(0); radioButtonCell1.setBackgroundResource(R.drawable.list_selector); if (currentChat.megagroup) { radioButtonCell1.setTextAndValue(LocaleController.getString("MegaPublic", R.string.MegaPublic), LocaleController.getString("MegaPublicInfo", R.string.MegaPublicInfo), !isPrivate, false); } else { radioButtonCell1.setTextAndValue(LocaleController.getString("ChannelPublic", R.string.ChannelPublic), LocaleController.getString("ChannelPublicInfo", R.string.ChannelPublicInfo), !isPrivate, false); } linearLayout2.addView(radioButtonCell1, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); radioButtonCell1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!isPrivate) { return; } isPrivate = false; updatePrivatePublic(); } }); radioButtonCell2 = new RadioButtonCell(context); radioButtonCell2.setElevation(0); radioButtonCell2.setForeground(R.drawable.list_selector); if (currentChat.megagroup) { radioButtonCell2.setTextAndValue(LocaleController.getString("MegaPrivate", R.string.MegaPrivate), LocaleController.getString("MegaPrivateInfo", R.string.MegaPrivateInfo), isPrivate, false); } else { radioButtonCell2.setTextAndValue(LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate), LocaleController.getString("ChannelPrivateInfo", R.string.ChannelPrivateInfo), isPrivate, false); } linearLayout2.addView(radioButtonCell2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); radioButtonCell2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isPrivate) { return; } isPrivate = true; updatePrivatePublic(); } }); sectionCell = new ShadowSectionCell(context); linearLayout.addView(sectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); linkContainer = new LinearLayout(context); linkContainer.setOrientation(LinearLayout.VERTICAL); linkContainer.setElevation(AndroidUtilities.dp(2)); linkContainer.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); linearLayout.addView(linkContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); headerCell = new HeaderCell(context); headerCell.setElevation(0); headerCell.setBackground(null); linkContainer.addView(headerCell); publicContainer = new LinearLayout(context); publicContainer.setOrientation(LinearLayout.HORIZONTAL); linkContainer.addView(publicContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 17, 7, 17, 0)); EditText editText = new EditText(context); editText.setText("telegram.me/"); editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); //editText.setHintTextColor(0xff979797); editText.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); editText.setMaxLines(1); editText.setLines(1); editText.setEnabled(false); editText.setBackgroundDrawable(null); editText.setPadding(0, 0, 0, 0); editText.setSingleLine(true); editText.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); editText.setImeOptions(EditorInfo.IME_ACTION_DONE); publicContainer.addView(editText, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 36)); nameTextView = new EditText(context); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); if (!isPrivate) { nameTextView.setText(currentChat.username); } //nameTextView.setHintTextColor(0xff979797); nameTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); nameTextView.setMaxLines(1); nameTextView.setLines(1); nameTextView.setBackgroundDrawable(null); nameTextView.setPadding(0, 0, 0, 0); nameTextView.setSingleLine(true); nameTextView.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); nameTextView.setImeOptions(EditorInfo.IME_ACTION_DONE); nameTextView.setHint( LocaleController.getString("ChannelUsernamePlaceholder", R.string.ChannelUsernamePlaceholder)); AndroidUtilities.clearCursorDrawable(nameTextView); publicContainer.addView(nameTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36)); nameTextView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { checkUserName(nameTextView.getText().toString()); } @Override public void afterTextChanged(Editable editable) { } }); privateContainer = new TextBlockCell(context); privateContainer.setForeground(R.drawable.list_selector); linkContainer.addView(privateContainer); privateContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (invite == null) { return; } try { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext .getSystemService(Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText("label", invite.link); clipboard.setPrimaryClip(clip); Toast.makeText(getParentActivity(), LocaleController.getString("LinkCopied", R.string.LinkCopied), Toast.LENGTH_SHORT) .show(); } catch (Exception e) { FileLog.e("tmessages", e); } } }); checkTextView = new TextView(context); checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); checkTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); checkTextView.setVisibility(View.GONE); linkContainer.addView(checkTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 17, 3, 17, 7)); typeInfoCell = new TextInfoPrivacyCell(context); //typeInfoCell.setBackgroundResource(R.drawable.greydivider_bottom); linearLayout.addView(typeInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); loadingAdminedCell = new LoadingCell(context); linearLayout.addView(loadingAdminedCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); adminedInfoCell = new TextInfoPrivacyCell(context); //adminedInfoCell.setBackgroundResource(R.drawable.greydivider_bottom); linearLayout.addView(adminedInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); updatePrivatePublic(); return fragmentView; }
From source file:es.hol.ecotiffins.view.RegisterActivity.java
/** * Method is useful to apply error message on TextInputLayouts * * @param view on which error will be shown e.g findViewById(R.id.textInputLayout) * @param errorMessage what you want to display *//*ww w . j av a 2 s . c o m*/ private void setValidationError(View view, String errorMessage) { //Vibrate device on error ((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).vibrate(100); //Here I am handling typecasting so that there is no need to cast before method is called TextInputLayout textInputLayout = (TextInputLayout) view; textInputLayout.setErrorEnabled(true); textInputLayout.setError(errorMessage); }
From source file:net.tjohns.badgescanner.ScanActivity.java
private void scanBadge() { Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(VIBRATION_DURATION); Intent intent = getIntent();/*from w w w . j a va2s . c o m*/ if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(getIntent().getAction())) { Tag rawTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); MifareClassic tag = MifareClassic.get(rawTag); try { // Read from badge NfcConnection tagConnection = new NfcConnection(tag, MifareClassic.KEY_DEFAULT); mBadge = new Badge(); mBadge.readFromTag(tagConnection); tagConnection.close(); } catch (TagLostException e) { // TODO(trevorjohns): Convert to dialog Toast.makeText(this, "Tag lost", Toast.LENGTH_LONG); finish(); } catch (IOException e) { // TODO(trevorjohns): Convert to dialog Toast.makeText(this, "IOExcpetion detected", Toast.LENGTH_LONG); e.printStackTrace(); finish(); } } }
From source file:de.bogutzky.psychophysiocollector.app.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); checkBtEnabled();//from ww w .j ava 2s. com deviceNames = new ArrayList<>(); arrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, deviceNames); setListAdapter(arrayAdapter); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); textViewTimer = (TextView) findViewById(R.id.text_view_timer); textViewTimer.setVisibility(View.INVISIBLE); final SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE); selfReportInterval = sharedPref.getInt("selfReportInterval", 15); selfReportVariance = sharedPref.getInt("selfReportVariance", 30); localeString = this.getResources().getConfiguration().locale.getLanguage().substring(0, 2).toLowerCase(); try { questionnaireFilenames = getAssets().list("questionnaires/" + localeString); } catch (IOException e) { e.printStackTrace(); } questionnaireCount = questionnaireFilenames.length; if (questionnaireCount == 0) { Toast.makeText(this, R.string.no_questionnaires_available, Toast.LENGTH_SHORT).show(); questionnaireFilePath = ""; } else { int questionnaireSpinnerPosition = sharedPref.getInt("questionnaireSpinnerPosition", 0); questionnaireFilePath = "questionnaires/" + localeString + "/" + questionnaireFilenames[questionnaireSpinnerPosition]; } activityName = sharedPref.getString("activityName", ""); participantFirstName = sharedPref.getString("participantFirstName", ""); participantLastName = sharedPref.getString("participantLastName", ""); intervalConfigured = sharedPref.getBoolean("configureInterval", false); getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { final int index = position; AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setCancelable(true); builder.setTitle(getString(R.string.delete)); builder.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { deviceNames.remove(index); getBluetoothAddresses().remove(index); arrayAdapter.notifyDataSetChanged(); if (getBluetoothAddresses().size() == 0) { connectMenuItem.setEnabled(false); } disconnectBioHarness(); disconnectAllShimmerImus(); } }); builder.create().show(); return false; } }); if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.ACCESS_COARSE_LOCATION }, PERMISSIONS_REQUEST); } }
From source file:br.com.imovelhunter.imovelhunterwebmobile.GcmIntentService.java
private void vibrar() { Vibrator rr = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); long milliseconds = 1000; rr.vibrate(milliseconds); }
From source file:org.petero.droidfish.activities.EditBoard.java
private final void initUI() { setContentView(R.layout.editboard);/* www.j av a 2 s . c o m*/ Util.overrideFonts(findViewById(android.R.id.content)); View firstTitleLine = findViewById(R.id.first_title_line); View secondTitleLine = findViewById(R.id.second_title_line); cb = (ChessBoardEdit) findViewById(R.id.eb_chessboard); status = (TextView) findViewById(R.id.eb_status); okButton = (Button) findViewById(R.id.eb_ok); cancelButton = (Button) findViewById(R.id.eb_cancel); TextView whiteTitleText = (TextView) findViewById(R.id.white_clock); whiteTitleText.setVisibility(View.GONE); TextView blackTitleText = (TextView) findViewById(R.id.black_clock); blackTitleText.setVisibility(View.GONE); TextView engineTitleText = (TextView) findViewById(R.id.title_text); engineTitleText.setVisibility(View.GONE); whiteFigText = (TextView) findViewById(R.id.white_pieces); whiteFigText.setTypeface(figNotation); whiteFigText.setSelected(true); whiteFigText.setTextColor(whiteTitleText.getTextColors()); blackFigText = (TextView) findViewById(R.id.black_pieces); blackFigText.setTypeface(figNotation); blackFigText.setSelected(true); blackFigText.setTextColor(blackTitleText.getTextColors()); TextView summaryTitleText = (TextView) findViewById(R.id.title_text_summary); summaryTitleText.setText(R.string.edit_board); TextUtils.TruncateAt where = autoScrollTitle ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END; engineTitleText.setEllipsize(where); whiteFigText.setEllipsize(where); blackFigText.setEllipsize(where); firstTitleLine.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { openOptionsMenu(); } }); secondTitleLine.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { openOptionsMenu(); } }); okButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { sendBackResult(); } }); cancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { setResult(RESULT_CANCELED); finish(); } }); status.setFocusable(false); cb.setFocusable(true); cb.requestFocus(); cb.setClickable(true); cb.setOnTouchListener(new OnTouchListener() { private boolean pending = false; private int sq0 = -1; private Handler handler = new Handler(); private Runnable runnable = new Runnable() { public void run() { pending = false; handler.removeCallbacks(runnable); ((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).vibrate(20); showDialog(EDIT_DIALOG); } }; public boolean onTouch(View v, MotionEvent event) { int action = MotionEventCompat.getActionMasked(event); switch (action) { case MotionEvent.ACTION_DOWN: handler.postDelayed(runnable, ViewConfiguration.getLongPressTimeout()); sq0 = cb.eventToSquare(event); pending = true; break; case MotionEvent.ACTION_UP: if (pending) { pending = false; handler.removeCallbacks(runnable); int sq = cb.eventToSquare(event); if (sq == sq0) { Move m = cb.mousePressed(sq); if (m != null) doMove(m); setEgtbHints(cb.getSelectedSquare()); } } break; case MotionEvent.ACTION_CANCEL: pending = false; handler.removeCallbacks(runnable); break; } return true; } }); cb.setOnTrackballListener(new ChessBoard.OnTrackballListener() { public void onTrackballEvent(MotionEvent event) { Move m = cb.handleTrackballEvent(event); if (m != null) doMove(m); setEgtbHints(cb.getSelectedSquare()); } }); }
From source file:com.marvin.rocklock.RockLockActivity.java
/** Called when the activity is first created. */ @Override// ww w.j a va 2 s. c om public void onCreate(Bundle savedInstanceState) { mSelf = this; sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); mPlayer = new RockLockMusicPlayer(this); super.onCreate(savedInstanceState); requestWindowFeature(android.view.Window.FEATURE_NO_TITLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); setContentView(R.layout.main); mIconDisplay = (ImageView) findViewById(R.id.gestureIcon); mCurrentTrack = (TextView) findViewById(R.id.current_track); mCurrentInfo = (TextView) findViewById(R.id.current_info); mUpcomingText = (TextView) findViewById(R.id.upcoming); mModeText = (TextView) findViewById(R.id.mode_text); mGestureOverlay = (MusicGestureOverlay) findViewById(R.id.gestureLayer); mGestureOverlay.setGestureListener(new PlayerGestureListener(), true); updateDisplayText(null, null, false); mTts = new TextToSpeech(this, new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { mTts.setOnUtteranceCompletedListener(new OnUtteranceCompletedListener() { @Override public void onUtteranceCompleted(String utteranceId) { if (mCurrentUtteranceId != null && mCurrentUtteranceId.equals(utteranceId)) { mPlayer.restoreMusic(); } } }); } }); mTts.addEarcon(TOCK_EARCON, RockLockActivity.class.getPackage().getName(), R.raw.tock_snd); mTts.addEarcon(TICK_EARCON, RockLockActivity.class.getPackage().getName(), R.raw.tick_snd); mVibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mWasStartedByService = getIntent().getBooleanExtra(EXTRA_STARTED_BY_SERVICE, false); mPhoneListener = new RockLockPhoneListener(); final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); tm.listen(mPhoneListener, PhoneStateListener.LISTEN_CALL_STATE); mPausedForCall = false; // Start the service in case it is not already running startService(new Intent(this, ScreenOnHandlerService.class)); // Get notification manager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); loadBookmarks(); // Browsing preference mPrefs = PreferenceManager.getDefaultSharedPreferences(this); mBrowsingPref = mPrefs.getBoolean(getString(R.string.browse_mode), true); }
From source file:com.google.vrtoolkit.cardboard.samples.treasurehunt.MainActivity.java
/** * Sets the view to our CardboardView and initializes the transformation matrices we will use * to render our scene.// ww w.j a v a 2 s . com */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.common_ui); CardboardView cardboardView = (CardboardView) findViewById(R.id.cardboard_view); cardboardView.setRestoreGLStateEnabled(false); cardboardView.setRenderer(this); setCardboardView(cardboardView); modelCube = new float[16]; modelMiniCube = new float[16]; camera = new float[16]; view = new float[16]; modelViewProjection = new float[16]; modelView = new float[16]; modelFloor = new float[16]; // Model first appears directly in front of user. //modelPosition = new float[] {0.0f, 0.0f, -MAX_MODEL_DISTANCE / 0.5f}; modelPosition = new float[] { 0.0f, 0.0f, -WALL_DIST }; headRotation = new float[4]; headView = new float[16]; vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); overlayView = (CardboardOverlayView) findViewById(R.id.overlay); overlayView.show3DToast("Pull the magnet when you find an object."); // Initialize 3D audio engine. cardboardAudioEngine = new CardboardAudioEngine(getAssets(), CardboardAudioEngine.RenderingQuality.HIGH); connectWebSocket(); handPos = new float[3]; }
From source file:com.philliphsu.clock2.alarms.ui.ExpandedAlarmViewHolder.java
@OnClick(R.id.vibrate) void onVibrateToggled() { final boolean checked = mVibrate.isChecked(); if (checked) { Vibrator vibrator = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(300);/*from w w w.j a v a 2 s .c om*/ } final Alarm oldAlarm = getAlarm(); Alarm newAlarm = oldAlarm.toBuilder().vibrates(checked).build(); oldAlarm.copyMutableFieldsTo(newAlarm); persistUpdatedAlarm(newAlarm, false); }
From source file:org.sipdroid.sipua.ui.Receiver.java
public static void onState(int state, String caller) { if (ccCall == null) { ccCall = new Call(); ccConn = new Connection(); ccCall.setConn(ccConn);/* w w w. j av a2 s. c o m*/ ccConn.setCall(ccCall); } if (call_state != state) { if (state != UserAgent.UA_STATE_IDLE) call_end_reason = -1; call_state = state; switch (call_state) { case UserAgent.UA_STATE_INCOMING_CALL: enable_wifi(true); RtpStreamReceiver.good = RtpStreamReceiver.lost = RtpStreamReceiver.loss = RtpStreamReceiver.late = 0; RtpStreamReceiver.speakermode = speakermode(); bluetooth = -1; String text = caller.toString(); if (text.indexOf("<sip:") >= 0 && text.indexOf("@") >= 0) text = text.substring(text.indexOf("<sip:") + 5, text.indexOf("@")); String text2 = caller.toString(); if (text2.indexOf("\"") >= 0) text2 = text2.substring(text2.indexOf("\"") + 1, text2.lastIndexOf("\"")); broadcastCallStateChanged("RINGING", caller); mContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); ccCall.setState(Call.State.INCOMING); ccConn.setUserData(null); ccConn.setAddress(text, text2); ccConn.setIncoming(true); ccConn.date = System.currentTimeMillis(); ccCall.base = 0; AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); int rm = am.getRingerMode(); int vs = am.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER); KeyguardManager mKeyguardManager = (KeyguardManager) mContext .getSystemService(Context.KEYGUARD_SERVICE); if (v == null) v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); if ((pstn_state == null || pstn_state.equals("IDLE")) && PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean( org.sipdroid.sipua.ui.Settings.PREF_AUTO_ON, org.sipdroid.sipua.ui.Settings.DEFAULT_AUTO_ON) && !mKeyguardManager.inKeyguardRestrictedInputMode()) v.vibrate(vibratePattern, 1); else { if ((pstn_state == null || pstn_state.equals("IDLE")) && (rm == AudioManager.RINGER_MODE_VIBRATE || (rm == AudioManager.RINGER_MODE_NORMAL && vs == AudioManager.VIBRATE_SETTING_ON))) v.vibrate(vibratePattern, 1); if (am.getStreamVolume(AudioManager.STREAM_RING) > 0) { String sUriSipRingtone = PreferenceManager.getDefaultSharedPreferences(mContext).getString( org.sipdroid.sipua.ui.Settings.PREF_SIPRINGTONE, Settings.System.DEFAULT_RINGTONE_URI.toString()); if (!TextUtils.isEmpty(sUriSipRingtone)) { oRingtone = RingtoneManager.getRingtone(mContext, Uri.parse(sUriSipRingtone)); if (oRingtone != null) oRingtone.play(); } } } moveTop(); if (wl == null) { PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "Sipdroid.onState"); } wl.acquire(); Checkin.checkin(true); break; case UserAgent.UA_STATE_OUTGOING_CALL: RtpStreamReceiver.good = RtpStreamReceiver.lost = RtpStreamReceiver.loss = RtpStreamReceiver.late = 0; RtpStreamReceiver.speakermode = speakermode(); bluetooth = -1; onText(MISSED_CALL_NOTIFICATION, null, 0, 0); engine(mContext).register(); broadcastCallStateChanged("OFFHOOK", caller); ccCall.setState(Call.State.DIALING); ccConn.setUserData(null); ccConn.setAddress(caller, caller); ccConn.setIncoming(false); ccConn.date = System.currentTimeMillis(); ccCall.base = 0; moveTop(); Checkin.checkin(true); break; case UserAgent.UA_STATE_IDLE: broadcastCallStateChanged("IDLE", null); onText(CALL_NOTIFICATION, null, 0, 0); ccCall.setState(Call.State.DISCONNECTED); if (listener_video != null) listener_video.onHangup(); stopRingtone(); if (wl != null && wl.isHeld()) wl.release(); mContext.startActivity(createIntent(InCallScreen.class)); ccConn.log(ccCall.base); ccConn.date = 0; engine(mContext).listen(); break; case UserAgent.UA_STATE_INCALL: broadcastCallStateChanged("OFFHOOK", null); if (ccCall.base == 0) { ccCall.base = SystemClock.elapsedRealtime(); } progress(); ccCall.setState(Call.State.ACTIVE); stopRingtone(); if (wl != null && wl.isHeld()) wl.release(); mContext.startActivity(createIntent(InCallScreen.class)); break; case UserAgent.UA_STATE_HOLD: onText(CALL_NOTIFICATION, mContext.getString(R.string.card_title_on_hold), android.R.drawable.stat_sys_phone_call_on_hold, ccCall.base); ccCall.setState(Call.State.HOLDING); if (InCallScreen.started && (pstn_state == null || !pstn_state.equals("RINGING"))) mContext.startActivity(createIntent(InCallScreen.class)); break; } pos(true); RtpStreamReceiver.ringback(false); } }