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:com.tessoft.nearhere.GcmIntentService.java
private void sendNotification(Bundle extras) { String title = extras.getString("title"); String type = extras.getString("type"); String msg = extras.getString("message"); mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(title) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg) .setAutoCancel(true);// w w w. j av a2 s . c om Intent intent = null; boolean isActive = false; // check if background // ActivityManager activityManager = (ActivityManager) this.getSystemService( ACTIVITY_SERVICE ); // List<RunningAppProcessInfo> procInfos = activityManager.getRunningAppProcesses(); // for(int i = 0; i < procInfos.size(); i++) // { // if(procInfos.get(i).processName.equals("com.tessoft.nearhere")) // isActive = true; // } // check if foreground ActivityManager activityManager = (ActivityManager) getApplicationContext() .getSystemService(Context.ACTIVITY_SERVICE); List<RunningTaskInfo> services = activityManager.getRunningTasks(Integer.MAX_VALUE); if (services.get(0).topActivity.getPackageName().toString() .equalsIgnoreCase(getApplicationContext().getPackageName().toString())) { isActive = true; } if (isActive) { intent = new Intent("updateUnreadCount"); intent.putExtra("type", type); if ("message".equals(type)) { intent.putExtra("fromUserID", extras.getString("fromUserID")); Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification); r.play(); Vibrator v = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(500); } else if ("postReply".equals(type)) { intent.putExtra("postID", extras.getString("postID")); Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification); r.play(); Vibrator v = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(500); } getApplicationContext().sendBroadcast(intent); } else { if ("message".equals(type)) { intent = new Intent(this, UserMessageActivity.class); HashMap hash = new HashMap(); hash.put("fromUserID", extras.getString("fromUserID")); hash.put("userID", extras.getString("toUserID")); intent.putExtra("messageInfo", hash); mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI); mBuilder.setVibrate(new long[] { 1000, 1000 }); } else if ("postReply".equals(type)) { intent = new Intent(this, TaxiPostDetailActivity.class); intent.putExtra("postID", extras.getString("postID")); mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI); mBuilder.setVibrate(new long[] { 1000, 1000 }); } else if ("newPostByDistance".equals(type)) { intent = new Intent(this, TaxiPostDetailActivity.class); intent.putExtra("postID", extras.getString("postID")); } else if ("event".equals(type)) { intent = new Intent(this, EventViewerActivity.class); intent.putExtra("eventSeq", extras.getString("eventSeq")); intent.putExtra("pushNo", extras.getString("pushNo")); if ("on".equals(extras.getString("sound"))) mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI); if ("on".equals(extras.getString("vibrate"))) mBuilder.setVibrate(new long[] { 1000, 1000 }); } else if ("eventssl".equals(type)) { intent = new Intent(this, EventViewerActivity.class); intent.putExtra("eventSeq", extras.getString("eventSeq")); intent.putExtra("pushNo", extras.getString("pushNo")); intent.putExtra("ssl", "true"); if ("on".equals(extras.getString("sound"))) mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI); if ("on".equals(extras.getString("vibrate"))) mBuilder.setVibrate(new long[] { 1000, 1000 }); } else { intent = new Intent(this, MainActivity.class); } PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } }
From source file:com.android.yijiang.kzx.widget.betterpickers.calendardatepicker.CalendarDatePickerDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Activity activity = getActivity(); activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); mVibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE); if (savedInstanceState != null) { mCalendar.set(Calendar.YEAR, savedInstanceState.getInt(KEY_SELECTED_YEAR)); mCalendar.set(Calendar.MONTH, savedInstanceState.getInt(KEY_SELECTED_MONTH)); mCalendar.set(Calendar.DAY_OF_MONTH, savedInstanceState.getInt(KEY_SELECTED_DAY)); }/*from ww w .j a v a2 s . c om*/ }
From source file:com.google.cloud.solutions.griddler.android.ui.game.LetterView.java
/** * Handles the animations when a tile is selected and not selected *//* w w w . j a va 2 s . co m*/ public void udateUI() { LetterRenderModel renderModel = gameManager.getBoardRenderModel().getGridLayout().getBoard() .get(letterLocation); if (renderModel.getIsSelected() && !this.isSelected) { isSelected = true; selectedAnimationSet.start(); Vibrator vibrationService = (Vibrator) this.getContext().getSystemService(Context.VIBRATOR_SERVICE); vibrationService.vibrate(10); } else if (this.isSelected && !renderModel.getIsSelected()) { isSelected = false; unselectedAnimationSet.start(); } }
From source file:hide.com.android.datetimepicker.date.DatePickerDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Activity activity = getActivity(); activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); if (Utils.hasVibratePermission(activity)) { mVibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE); }//from w w w . ja v a2s.c o m if (savedInstanceState != null) { mCalendar.set(Calendar.YEAR, savedInstanceState.getInt(KEY_SELECTED_YEAR)); mCalendar.set(Calendar.MONTH, savedInstanceState.getInt(KEY_SELECTED_MONTH)); mCalendar.set(Calendar.DAY_OF_MONTH, savedInstanceState.getInt(KEY_SELECTED_DAY)); } }
From source file:com.emuneee.nctrafficcams.ui.fragments.CameraDetailFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true);// w w w. ja v a 2 s .c om Bundle args = getArguments(); mCamera = args.getParcelable(Constants.BUNDLE_CAMERA); mVibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE); if (savedInstanceState != null) { mCamera = savedInstanceState.getParcelable(Constants.BUNDLE_CAMERA); } }
From source file:org.docrj.smartcard.reader.BatchSelectActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_activity_batch_select); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*w w w . j a va 2s . c o m*/ DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mNavDrawer = new NavDrawer(this, savedInstanceState, R.id.batch_select, drawerLayout, toolbar); ListView listView = (ListView) findViewById(R.id.msg_list); ViewSwitcher switcher = (ViewSwitcher) findViewById(R.id.switcher); mConsole = new Console(this, savedInstanceState, TEST_MODE_BATCH_SELECT, listView, switcher); mNfcManager = new NfcManager(this, this); ApduParser.init(this); // persistent data in shared prefs SharedPreferences ss = getSharedPreferences("prefs", Context.MODE_PRIVATE); mEditor = ss.edit(); // do not clear messages for initial selection mSelectInInit = true; mGrpAdapter = new BatchSelectGroupAdapter(getLayoutInflater()); mGrpSpinner = (Spinner) findViewById(R.id.group); mGrpSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { if (!mSelectInInit) { clearMessages(true); } mSelectInInit = false; mSelectedGrpPos = pos; String groupName = mGrpAdapter.getGroupName(pos); Log.d(TAG, "group: " + groupName); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); // persistent settings and settings listener SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.registerOnSharedPreferenceChangeListener(this); mAutoClear = prefs.getBoolean("pref_auto_clear", true); mShowMsgSeparators = prefs.getBoolean("pref_show_separators", true); String tapFeedback = prefs.getString("pref_tap_feedback", "1"); mTapFeedback = Integer.valueOf(tapFeedback); mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); }
From source file:com.nick.scalpel.core.AutoFoundWirer.java
private void wireFromContext(Context context, AutoFound.Type type, int idRes, Resources.Theme theme, Field field, Object forWho) { Resources resources = context.getResources(); switch (type) { case STRING://w w w . j a v a2 s. c o m setField(field, forWho, resources.getString(idRes)); break; case COLOR: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, resources.getColor(idRes, theme)); } else { //noinspection deprecation setField(field, forWho, resources.getColor(idRes)); } break; case INTEGER: setField(field, forWho, resources.getInteger(idRes)); break; case BOOL: setField(field, forWho, resources.getBoolean(idRes)); break; case STRING_ARRAY: setField(field, forWho, resources.getStringArray(idRes)); break; case INT_ARRAY: setField(field, forWho, resources.getIntArray(idRes)); break; case PM: setField(field, forWho, context.getSystemService(Context.POWER_SERVICE)); break; case ACCOUNT: setField(field, forWho, context.getSystemService(Context.ACCOUNT_SERVICE)); break; case ALARM: setField(field, forWho, context.getSystemService(Context.ALARM_SERVICE)); break; case AM: setField(field, forWho, context.getSystemService(Context.ACTIVITY_SERVICE)); break; case WM: setField(field, forWho, context.getSystemService(Context.WINDOW_SERVICE)); break; case NM: setField(field, forWho, context.getSystemService(Context.NOTIFICATION_SERVICE)); break; case TM: setField(field, forWho, context.getSystemService(Context.TELEPHONY_SERVICE)); break; case TCM: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.TELECOM_SERVICE)); } break; case SP: setField(field, forWho, PreferenceManager.getDefaultSharedPreferences(context)); break; case PKM: setField(field, forWho, context.getPackageManager()); break; case HANDLE: setField(field, forWho, new Handler(Looper.getMainLooper())); break; case ASM: setField(field, forWho, context.getSystemService(Context.ACCESSIBILITY_SERVICE)); break; case CAP: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setField(field, forWho, context.getSystemService(Context.CAPTIONING_SERVICE)); } break; case KGD: setField(field, forWho, context.getSystemService(Context.KEYGUARD_SERVICE)); break; case LOCATION: setField(field, forWho, context.getSystemService(Context.LOCATION_SERVICE)); break; case SEARCH: setField(field, forWho, context.getSystemService(Context.SEARCH_SERVICE)); break; case SENSOR: setField(field, forWho, context.getSystemService(Context.SENSOR_SERVICE)); break; case STORAGE: setField(field, forWho, context.getSystemService(Context.STORAGE_SERVICE)); break; case WALLPAPER: setField(field, forWho, context.getSystemService(Context.WALLPAPER_SERVICE)); break; case VIBRATOR: setField(field, forWho, context.getSystemService(Context.VIBRATOR_SERVICE)); break; case CONNECT: setField(field, forWho, context.getSystemService(Context.CONNECTIVITY_SERVICE)); break; case NETWORK_STATUS: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, context.getSystemService(Context.NETWORK_STATS_SERVICE)); } break; case WIFI: setField(field, forWho, context.getSystemService(Context.WIFI_SERVICE)); break; case AUDIO: setField(field, forWho, context.getSystemService(Context.AUDIO_SERVICE)); break; case FP: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, context.getSystemService(Context.FINGERPRINT_SERVICE)); } break; case MEDIA_ROUTER: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { setField(field, forWho, context.getSystemService(Context.MEDIA_ROUTER_SERVICE)); } break; case SUB: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { setField(field, forWho, context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)); } break; case IME: setField(field, forWho, context.getSystemService(Context.INPUT_METHOD_SERVICE)); break; case CLIP_BOARD: setField(field, forWho, context.getSystemService(Context.CLIPBOARD_SERVICE)); break; case APP_WIDGET: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.APPWIDGET_SERVICE)); } break; case DEVICE_POLICY: setField(field, forWho, context.getSystemService(Context.DEVICE_POLICY_SERVICE)); break; case DOWNLOAD: setField(field, forWho, context.getSystemService(Context.DOWNLOAD_SERVICE)); break; case BATTERY: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.BATTERY_SERVICE)); } break; case NFC: setField(field, forWho, context.getSystemService(Context.NFC_SERVICE)); break; case DISPLAY: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setField(field, forWho, context.getSystemService(Context.DISPLAY_SERVICE)); } break; case USER: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setField(field, forWho, context.getSystemService(Context.USER_SERVICE)); } break; case APP_OPS: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setField(field, forWho, context.getSystemService(Context.APP_OPS_SERVICE)); } break; case BITMAP: setField(field, forWho, BitmapFactory.decodeResource(resources, idRes, null)); break; } }
From source file:es.hol.ecotiffins.view.LoginActivity.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 *//*w ww . j a v a2 s . c o m*/ private void setValidationError(View view, String errorMessage) { //Vibrate device on error ((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).vibrate(50); //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:org.fedorahosted.freeotp.main.ScanDialogFragment.java
@Override public void process(Frame frame) { byte[] i = frame.getImage(); Resolution r = frame.getSize();/* w w w . ja v a 2 s. c o m*/ LuminanceSource ls = new PlanarYUVLuminanceSource(i, r.width, r.height, 0, 0, r.width, r.height, false); try { BinaryBitmap bb = new BinaryBitmap(new HybridBinarizer(ls)); final String uri = new QRCodeReader().decode(bb).getText(); int size = mImage.getWidth(); if (size > mImage.getHeight()) size = mImage.getHeight(); BitMatrix bm = new QRCodeWriter().encode(uri, BarcodeFormat.QR_CODE, size, size); mFotoapparat.stop(); final Bitmap b = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { b.setPixel(x, y, bm.get(x, y) ? Color.BLACK : Color.WHITE); } } Vibrator v = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { v.vibrate(VibrationEffect.createOneShot(250, VibrationEffect.DEFAULT_AMPLITUDE)); } else { v.vibrate(250); } mImage.post(new Runnable() { @Override public void run() { mProgress.setVisibility(View.INVISIBLE); mCamera.animate().setInterpolator(new DecelerateInterpolator()).setDuration(2000).alpha(0.0f) .start(); mImage.setImageBitmap(b); mImage.animate().setInterpolator(new DecelerateInterpolator()).setDuration(2000).alpha(1.0f) .withEndAction(new Runnable() { @Override public void run() { mImage.post(new Runnable() { @Override public void run() { Activity a = (Activity) getActivity(); a.addToken(Uri.parse(uri), true); } }); dismiss(); } }).start(); } }); } catch (NotFoundException | ChecksumException | FormatException | WriterException e) { e.printStackTrace(); } }
From source file:org.telegram.ui.ChannelEditActivity.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. j av a 2 s.c om*/ public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { if (donePressed) { return; } if (nameTextView.length() == 0) { Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE); if (v != null) { v.vibrate(200); } AndroidUtilities.shakeView(nameTextView, 2, 0); return; } donePressed = true; if (avatarUpdater.uploadingAvatar != null) { createAfterUpload = true; progressDialog = new ProgressDialog(getParentActivity()); progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading)); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setCancelable(false); progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { createAfterUpload = false; progressDialog = null; donePressed = false; try { dialog.dismiss(); } catch (Exception e) { FileLog.e("tmessages", e); } } }); progressDialog.show(); return; } if (!currentChat.title.equals(nameTextView.getText().toString())) { MessagesController.getInstance().changeChatTitle(chatId, nameTextView.getText().toString()); } if (info != null && !info.about.equals(descriptionTextView.getText().toString())) { MessagesController.getInstance().updateChannelAbout(chatId, descriptionTextView.getText().toString(), info); } if (signMessages != currentChat.signatures) { currentChat.signatures = true; MessagesController.getInstance().toogleChannelSignatures(chatId, signMessages); } if (uploadedAvatar != null) { MessagesController.getInstance().changeChatAvatar(chatId, uploadedAvatar); } else if (avatar == null && currentChat.photo instanceof TLRPC.TL_chatPhoto) { MessagesController.getInstance().changeChatAvatar(chatId, null); } finishFragment(); } } }); ActionBarMenu menu = actionBar.createMenu(); doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); LinearLayout linearLayout; 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); actionBar.setTitle(LocaleController.getString("ChannelEdit", R.string.ChannelEdit)); 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)); FrameLayout frameLayout = new FrameLayout(context); linearLayout2.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); avatarImage = new BackupImageView(context); avatarImage.setRoundRadius(AndroidUtilities.dp(32)); avatarDrawable.setInfo(5, null, null, false); avatarDrawable.setDrawPhoto(true); frameLayout.addView(avatarImage, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 12)); avatarImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); CharSequence[] items; if (avatar != null) { items = new CharSequence[] { LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto) }; } else { items = new CharSequence[] { LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley) }; } builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (i == 0) { avatarUpdater.openCamera(); } else if (i == 1) { avatarUpdater.openGallery(); } else if (i == 2) { avatar = null; uploadedAvatar = null; avatarImage.setImage(avatar, "50_50", avatarDrawable); } } }); showDialog(builder.create()); } }); nameTextView = new EditText(context); if (currentChat.megagroup) { nameTextView.setHint(LocaleController.getString("GroupName", R.string.GroupName)); } else { nameTextView.setHint(LocaleController.getString("EnterChannelName", R.string.EnterChannelName)); } nameTextView.setMaxLines(4); nameTextView.setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); //nameTextView.setHintTextColor(0xff979797); nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); nameTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); nameTextView.setPadding(0, 0, 0, AndroidUtilities.dp(8)); InputFilter[] inputFilters = new InputFilter[1]; inputFilters[0] = new InputFilter.LengthFilter(100); nameTextView.setFilters(inputFilters); AndroidUtilities.clearCursorDrawable(nameTextView); nameTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); frameLayout.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 16 : 96, 0, LocaleController.isRTL ? 96 : 16, 0)); nameTextView.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) { avatarDrawable.setInfo(5, nameTextView.length() > 0 ? nameTextView.getText().toString() : null, null, false); avatarImage.invalidate(); } }); View lineView = new View(context); lineView.setBackgroundColor(ContextCompat.getColor(context, R.color.card_divider)); linearLayout.addView(lineView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1)); linearLayout2 = new LinearLayout(context); linearLayout2.setOrientation(LinearLayout.VERTICAL); linearLayout2.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); linearLayout2.setElevation(AndroidUtilities.dp(2)); linearLayout.addView(linearLayout2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); descriptionTextView = new EditText(context); descriptionTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); //descriptionTextView.setHintTextColor(0xff979797); descriptionTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); descriptionTextView.setPadding(0, 0, 0, AndroidUtilities.dp(6)); descriptionTextView.setBackgroundDrawable(null); descriptionTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); descriptionTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); descriptionTextView.setImeOptions(EditorInfo.IME_ACTION_DONE); inputFilters = new InputFilter[1]; inputFilters[0] = new InputFilter.LengthFilter(255); descriptionTextView.setFilters(inputFilters); descriptionTextView.setHint(LocaleController.getString("DescriptionOptionalPlaceholder", R.string.DescriptionOptionalPlaceholder)); AndroidUtilities.clearCursorDrawable(descriptionTextView); linearLayout2.addView(descriptionTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 17, 12, 17, 6)); descriptionTextView.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) { doneButton.performClick(); return true; } return false; } }); descriptionTextView.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) { } @Override public void afterTextChanged(Editable editable) { } }); ShadowSectionCell sectionCell = new ShadowSectionCell(context); sectionCell.setSize(20); linearLayout.addView(sectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); if (currentChat.megagroup || !currentChat.megagroup) { frameLayout = new FrameLayout(context); frameLayout.setElevation(AndroidUtilities.dp(2)); frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); typeCell = new TextSettingsCell(context); updateTypeCell(); typeCell.setForeground(R.drawable.list_selector); frameLayout.addView(typeCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); lineView = new View(context); lineView.setBackgroundColor(ContextCompat.getColor(context, R.color.card_divider)); linearLayout.addView(lineView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1)); frameLayout = new FrameLayout(context); frameLayout.setElevation(AndroidUtilities.dp(2)); frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); if (!currentChat.megagroup) { TextCheckCell textCheckCell = new TextCheckCell(context); textCheckCell.setForeground(R.drawable.list_selector); textCheckCell.setTextAndCheck( LocaleController.getString("ChannelSignMessages", R.string.ChannelSignMessages), signMessages, false); frameLayout.addView(textCheckCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); textCheckCell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { signMessages = !signMessages; ((TextCheckCell) v).setChecked(signMessages); } }); TextInfoPrivacyCell infoCell = new TextInfoPrivacyCell(context); //infoCell.setBackgroundResource(R.drawable.greydivider); infoCell.setText( LocaleController.getString("ChannelSignMessagesInfo", R.string.ChannelSignMessagesInfo)); linearLayout.addView(infoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); } else { adminCell = new TextSettingsCell(context); updateAdminCell(); adminCell.setForeground(R.drawable.list_selector); frameLayout.addView(adminCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); adminCell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Bundle args = new Bundle(); args.putInt("chat_id", chatId); args.putInt("type", 1); presentFragment(new ChannelUsersActivity(args)); } }); sectionCell = new ShadowSectionCell(context); sectionCell.setSize(20); linearLayout.addView(sectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); /*if (!currentChat.creator) { sectionCell.setBackgroundResource(R.drawable.greydivider_bottom); }*/ } } if (currentChat.creator) { frameLayout = new FrameLayout(context); frameLayout.setElevation(AndroidUtilities.dp(2)); frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); TextSettingsCell textCell = new TextSettingsCell(context); textCell.setTextColor(0xffed3d39); textCell.setBackgroundResource(R.drawable.list_selector); if (currentChat.megagroup) { textCell.setText(LocaleController.getString("DeleteMega", R.string.DeleteMega), false); } else { textCell.setText(LocaleController.getString("ChannelDelete", R.string.ChannelDelete), false); } frameLayout.addView(textCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); textCell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); if (currentChat.megagroup) { builder.setMessage(LocaleController.getString("MegaDeleteAlert", R.string.MegaDeleteAlert)); } else { builder.setMessage( LocaleController.getString("ChannelDeleteAlert", R.string.ChannelDeleteAlert)); } builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats); if (AndroidUtilities.isTablet()) { NotificationCenter.getInstance().postNotificationName( NotificationCenter.closeChats, -(long) chatId); } else { NotificationCenter.getInstance() .postNotificationName(NotificationCenter.closeChats); } MessagesController.getInstance().deleteUserFromChat(chatId, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), info); finishFragment(); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } }); TextInfoPrivacyCell infoCell = new TextInfoPrivacyCell(context); //infoCell.setBackgroundResource(R.drawable.greydivider_bottom); if (currentChat.megagroup) { infoCell.setText(LocaleController.getString("MegaDeleteInfo", R.string.MegaDeleteInfo)); } else { infoCell.setText(LocaleController.getString("ChannelDeleteInfo", R.string.ChannelDeleteInfo)); } linearLayout.addView(infoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); } nameTextView.setText(currentChat.title); nameTextView.setSelection(nameTextView.length()); if (info != null) { descriptionTextView.setText(info.about); } if (currentChat.photo != null) { avatar = currentChat.photo.photo_small; avatarImage.setImage(avatar, "50_50", avatarDrawable); } else { avatarImage.setImageDrawable(avatarDrawable); } return fragmentView; }