Java Code Examples for org.telegram.messenger.AndroidUtilities#isTablet()
The following examples show how to use
org.telegram.messenger.AndroidUtilities#isTablet() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExternalActionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public boolean needCloseLastFragment(ActionBarLayout layout) { if (AndroidUtilities.isTablet()) { if (layout == actionBarLayout && layout.fragmentsStack.size() <= 1) { onFinish(); finish(); return false; } else if (layout == layersActionBarLayout && actionBarLayout.fragmentsStack.isEmpty() && layersActionBarLayout.fragmentsStack.size() == 1) { onFinish(); finish(); return false; } } else { if (layout.fragmentsStack.size() <= 1) { onFinish(); finish(); return false; } } return true; }
Example 2
Source File: ExternalActionActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public void fixLayout() { if (!AndroidUtilities.isTablet()) { return; } if (actionBarLayout == null) { return; } actionBarLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { needLayout(); if (actionBarLayout != null) { actionBarLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this); } } }); }
Example 3
Source File: PasscodeView.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { View rootView = getRootView(); int usableViewHeight = rootView.getHeight() - AndroidUtilities.statusBarHeight - AndroidUtilities.getViewInset(rootView); getWindowVisibleDisplayFrame(rect); keyboardHeight = usableViewHeight - (rect.bottom - rect.top); if (SharedConfig.passcodeType == 1 && (AndroidUtilities.isTablet() || getContext().getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE)) { int t = 0; if (passwordFrameLayout.getTag() != null) { t = (Integer) passwordFrameLayout.getTag(); } LayoutParams layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams(); layoutParams.topMargin = t + layoutParams.height - keyboardHeight / 2 - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); passwordFrameLayout.setLayoutParams(layoutParams); } super.onLayout(changed, left, top, right, bottom); }
Example 4
Source File: PhotoPickerAlbumsCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int itemWidth; if (AndroidUtilities.isTablet()) { itemWidth = (AndroidUtilities.dp(490) - ((albumsCount + 1) * AndroidUtilities.dp(4))) / albumsCount; } else { itemWidth = (AndroidUtilities.displaySize.x - ((albumsCount + 1) * AndroidUtilities.dp(4))) / albumsCount; } for (int a = 0; a < albumsCount; a++) { LayoutParams layoutParams = (LayoutParams) albumViews[a].getLayoutParams(); layoutParams.topMargin = AndroidUtilities.dp(4); layoutParams.leftMargin = (itemWidth + AndroidUtilities.dp(4)) * a; layoutParams.width = itemWidth; layoutParams.height = itemWidth; layoutParams.gravity = Gravity.LEFT | Gravity.TOP; albumViews[a].setLayoutParams(layoutParams); } super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(4) + itemWidth, MeasureSpec.EXACTLY)); }
Example 5
Source File: PasscodeView.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { View rootView = getRootView(); int usableViewHeight = rootView.getHeight() - AndroidUtilities.statusBarHeight - AndroidUtilities.getViewInset(rootView); getWindowVisibleDisplayFrame(rect); keyboardHeight = usableViewHeight - (rect.bottom - rect.top); if (SharedConfig.passcodeType == 1 && (AndroidUtilities.isTablet() || getContext().getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE)) { int t = 0; if (passwordFrameLayout.getTag() != null) { t = (Integer) passwordFrameLayout.getTag(); } LayoutParams layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams(); layoutParams.topMargin = t + layoutParams.height - keyboardHeight / 2 - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); passwordFrameLayout.setLayoutParams(layoutParams); } super.onLayout(changed, left, top, right, bottom); }
Example 6
Source File: ChatAttachAlertContactsLayout.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override void onPreMeasure(int availableWidth, int availableHeight) { int padding; if (parentAlert.sizeNotifierFrameLayout.measureKeyboardHeight() > AndroidUtilities.dp(20)) { padding = AndroidUtilities.dp(8); parentAlert.setAllowNestedScroll(false); } else { if (!AndroidUtilities.isTablet() && AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y) { padding = (int) (availableHeight / 3.5f); } else { padding = (availableHeight / 5 * 2); } parentAlert.setAllowNestedScroll(true); } if (listView.getPaddingTop() != padding) { ignoreLayout = true; listView.setPadding(0, padding, 0, 0); ignoreLayout = false; } }
Example 7
Source File: QuickRepliesSettingsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setTitle(LocaleController.getString("VoipQuickReplies", R.string.VoipQuickReplies)); if (AndroidUtilities.isTablet()) { actionBar.setOccupyStatusBar(false); } actionBar.setAllowOverlayTitle(true); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); listAdapter = new ListAdapter(context); fragmentView = new FrameLayout(context); fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray)); FrameLayout frameLayout = (FrameLayout) fragmentView; listView = new RecyclerListView(context); listView.setVerticalScrollBarEnabled(false); listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)); frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); listView.setAdapter(listAdapter); listView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() { @Override public void onItemClick(View view, final int position) { } }); frameLayout.addView(actionBar); return fragmentView; }
Example 8
Source File: DrawerLayoutContainer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void openDrawer(boolean fast) { if (!allowOpenDrawer) { return; } if (AndroidUtilities.isTablet() && parentActionBarLayout != null && parentActionBarLayout.parentActivity != null) { AndroidUtilities.hideKeyboard(parentActionBarLayout.parentActivity.getCurrentFocus()); } cancelCurrentAnimation(); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(this, "drawerPosition", drawerLayout.getMeasuredWidth())); animatorSet.setInterpolator(new DecelerateInterpolator()); if (fast) { animatorSet.setDuration(Math.max((int) (200.0f / drawerLayout.getMeasuredWidth() * (drawerLayout.getMeasuredWidth() - drawerPosition)), 50)); } else { animatorSet.setDuration(300); } animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { onDrawerAnimationEnd(true); } }); animatorSet.start(); currentAnimation = animatorSet; }
Example 9
Source File: PhotoPickerActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void fixLayoutInternal() { if (getParentActivity() == null) { return; } int position = layoutManager.findFirstVisibleItemPosition(); WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE); int rotation = manager.getDefaultDisplay().getRotation(); int columnsCount; if (AndroidUtilities.isTablet()) { columnsCount = 3; } else { if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { columnsCount = 5; } else { columnsCount = 3; } } layoutManager.setSpanCount(columnsCount); if (AndroidUtilities.isTablet()) { itemWidth = (AndroidUtilities.dp(490) - ((columnsCount + 1) * AndroidUtilities.dp(4))) / columnsCount; } else { itemWidth = (AndroidUtilities.displaySize.x - ((columnsCount + 1) * AndroidUtilities.dp(4))) / columnsCount; } listAdapter.notifyDataSetChanged(); layoutManager.scrollToPosition(position); if (selectedAlbum == null) { emptyView.setPadding(0, 0, 0, (int) ((AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight()) * 0.4f)); } }
Example 10
Source File: PhotoCropActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public boolean onFragmentCreate() { swipeBackEnabled = false; if (imageToCrop == null) { String photoPath = getArguments().getString("photoPath"); Uri photoUri = getArguments().getParcelable("photoUri"); if (photoPath == null && photoUri == null) { return false; } if (photoPath != null) { File f = new File(photoPath); if (!f.exists()) { return false; } } int size; if (AndroidUtilities.isTablet()) { size = AndroidUtilities.dp(520); } else { size = Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y); } imageToCrop = ImageLoader.loadBitmap(photoPath, photoUri, size, size, true); if (imageToCrop == null) { return false; } } drawable = new BitmapDrawable(imageToCrop); super.onFragmentCreate(); return true; }
Example 11
Source File: ExternalActionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void needLayout() { if (AndroidUtilities.isTablet()) { RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams) layersActionBarLayout.getLayoutParams(); relativeLayoutParams.leftMargin = (AndroidUtilities.displaySize.x - relativeLayoutParams.width) / 2; int y = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); relativeLayoutParams.topMargin = y + (AndroidUtilities.displaySize.y - relativeLayoutParams.height - y) / 2; layersActionBarLayout.setLayoutParams(relativeLayoutParams); if (!AndroidUtilities.isSmallTablet() || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { int leftWidth = AndroidUtilities.displaySize.x / 100 * 35; if (leftWidth < AndroidUtilities.dp(320)) { leftWidth = AndroidUtilities.dp(320); } relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams(); relativeLayoutParams.width = leftWidth; relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; actionBarLayout.setLayoutParams(relativeLayoutParams); if (AndroidUtilities.isSmallTablet() && actionBarLayout.fragmentsStack.size() == 2) { BaseFragment chatFragment = actionBarLayout.fragmentsStack.get(1); chatFragment.onPause(); actionBarLayout.fragmentsStack.remove(1); actionBarLayout.showLastFragment(); } } else { relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams(); relativeLayoutParams.width = LayoutHelper.MATCH_PARENT; relativeLayoutParams.height = LayoutHelper.MATCH_PARENT; actionBarLayout.setLayoutParams(relativeLayoutParams); } } }
Example 12
Source File: ProfileActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void setPlayProfileAnimation(boolean value) { SharedPreferences preferences = MessagesController.getGlobalMainSettings(); if (!AndroidUtilities.isTablet() && preferences.getBoolean("view_animations", true)) { playProfileAnimation = value; } }
Example 13
Source File: QuickRepliesSettingsActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setTitle(LocaleController.getString("VoipQuickReplies", R.string.VoipQuickReplies)); if (AndroidUtilities.isTablet()) { actionBar.setOccupyStatusBar(false); } actionBar.setAllowOverlayTitle(true); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); listAdapter = new ListAdapter(context); fragmentView = new FrameLayout(context); fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray)); FrameLayout frameLayout = (FrameLayout) fragmentView; listView = new RecyclerListView(context); listView.setVerticalScrollBarEnabled(false); listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)); frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); listView.setAdapter(listAdapter); return fragmentView; }
Example 14
Source File: PaymentInfoCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void setInvoice(TLRPC.TL_messageMediaInvoice invoice, String botname) { nameTextView.setText(invoice.title); detailTextView.setText(invoice.description); detailExTextView.setText(botname); int maxPhotoWidth; if (AndroidUtilities.isTablet()) { maxPhotoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f); } else { maxPhotoWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f); } int width = 640; int height = 360; float scale = width / (float) (maxPhotoWidth - AndroidUtilities.dp(2)); width /= scale; height /= scale; if (invoice.photo != null && invoice.photo.mime_type.startsWith("image/")) { nameTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 9, LocaleController.isRTL ? 123 : 10, 0)); detailTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 33, LocaleController.isRTL ? 123 : 10, 0)); detailExTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 90, LocaleController.isRTL ? 123 : 10, 0)); imageView.setVisibility(VISIBLE); imageView.getImageReceiver().setImage(invoice.photo, null, String.format(Locale.US, "%d_%d", width, height), null, null, null, -1, null, 1); } else { nameTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 9, 17, 0)); detailTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 33, 17, 0)); detailExTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 90, 17, 0)); imageView.setVisibility(GONE); } }
Example 15
Source File: EditTextEmoji.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void openKeyboardInternal() { showPopup(AndroidUtilities.usingHardwareInput || isPaused ? 0 : 2); editText.requestFocus(); AndroidUtilities.showKeyboard(editText); if (isPaused) { showKeyboardOnResume = true; } else if (!AndroidUtilities.usingHardwareInput && !keyboardVisible && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet()) { waitingForKeyboardOpen = true; AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable); AndroidUtilities.runOnUIThread(openKeyboardRunnable, 100); } }
Example 16
Source File: ExternalActionActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override protected void onPause() { super.onPause(); actionBarLayout.onPause(); if (AndroidUtilities.isTablet()) { layersActionBarLayout.onPause(); } ApplicationLoader.externalInterfacePaused = true; onPasscodePause(); if (passcodeView != null) { passcodeView.onPause(); } }
Example 17
Source File: ActionBar.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public static int getCurrentActionBarHeight() { if (AndroidUtilities.isTablet()) { return AndroidUtilities.dp(64); } else if (AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y) { return AndroidUtilities.dp(48); } else { return AndroidUtilities.dp(56); } }
Example 18
Source File: EditTextEmoji.java From Telegram with GNU General Public License v2.0 | 4 votes |
private void showPopup(int show) { if (show == 1) { if (emojiView == null) { createEmojiView(); } emojiView.setVisibility(VISIBLE); emojiViewVisible = true; View currentView = emojiView; if (keyboardHeight <= 0) { if (AndroidUtilities.isTablet()) { keyboardHeight = AndroidUtilities.dp(150); } else { keyboardHeight = MessagesController.getGlobalEmojiSettings().getInt("kbd_height", AndroidUtilities.dp(200)); } } if (keyboardHeightLand <= 0) { if (AndroidUtilities.isTablet()) { keyboardHeightLand = AndroidUtilities.dp(150); } else { keyboardHeightLand = MessagesController.getGlobalEmojiSettings().getInt("kbd_height_land3", AndroidUtilities.dp(200)); } } int currentHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight; FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) currentView.getLayoutParams(); layoutParams.height = currentHeight; currentView.setLayoutParams(layoutParams); if (!AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet()) { AndroidUtilities.hideKeyboard(editText); } if (sizeNotifierLayout != null) { emojiPadding = currentHeight; sizeNotifierLayout.requestLayout(); emojiButton.setImageResource(R.drawable.input_keyboard); onWindowSizeChanged(); } } else { if (emojiButton != null) { if (currentStyle == STYLE_FRAGMENT) { emojiButton.setImageResource(R.drawable.smiles_tab_smiles); } else { emojiButton.setImageResource(R.drawable.input_smile); } } if (emojiView != null) { emojiViewVisible = false; if (AndroidUtilities.usingHardwareInput || AndroidUtilities.isInMultiwindow) { emojiView.setVisibility(GONE); } } if (sizeNotifierLayout != null) { if (show == 0) { emojiPadding = 0; } sizeNotifierLayout.requestLayout(); onWindowSizeChanged(); } } }
Example 19
Source File: DialogsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void updateVisibleRows(int mask) { if (listView == null) return; int count = listView.getChildCount(); for (int a = 0; a < count; a++) { View child = listView.getChildAt(a); if (child instanceof DialogCell) { if (listView.getAdapter() != dialogsSearchAdapter) { DialogCell cell = (DialogCell) child; if ((mask & MessagesController.UPDATE_MASK_NEW_MESSAGE) != 0) { cell.checkCurrentDialogIndex(); if (dialogsType == MessagesController.DialogType.All && AndroidUtilities.isTablet()) { cell.setDialogSelected(cell.getDialogId() == openedDialogId); } } else if ((mask & MessagesController.UPDATE_MASK_SELECT_DIALOG) != 0) { if (dialogsType == MessagesController.DialogType.All && AndroidUtilities.isTablet()) { cell.setDialogSelected(cell.getDialogId() == openedDialogId); } } else { cell.update(mask); } } } else if (child instanceof UserCell) { ((UserCell) child).update(mask); } else if (child instanceof ProfileSearchCell) { ((ProfileSearchCell) child).update(mask); } else if (child instanceof RecyclerListView) { RecyclerListView innerListView = (RecyclerListView) child; int count2 = innerListView.getChildCount(); for (int b = 0; b < count2; b++) { View child2 = innerListView.getChildAt(b); if (child2 instanceof HintDialogCell) { ((HintDialogCell) child2).checkUnreadCounter(mask); } } } } if (updateTabCounters) { updateTabsUnreadCount(); updateTabCounters = false; } }
Example 20
Source File: SettingsActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void setPlayProfileAnimation(boolean value) { SharedPreferences preferences = MessagesController.getGlobalMainSettings(); if (!AndroidUtilities.isTablet() && preferences.getBoolean("view_animations", true)) { playProfileAnimation = value; } }