Java Code Examples for org.telegram.ui.ActionBar.ActionBar

The following examples show how to use org.telegram.ui.ActionBar.ActionBar. These examples are extracted from open source projects. 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
@Override
protected ActionBar createActionBar(Context context)
{
    ActionBar actionBar = new ActionBar(context)
    {
        @Override
        public boolean onTouchEvent(MotionEvent event)
        {
            return super.onTouchEvent(event);
        }
    };

    actionBar.setItemsBackgroundColor(AvatarDrawable.getButtonColorForId(user_id != 0 || ChatObject.isChannel(chat_id, currentAccount) && !currentChat.megagroup ? 5 : chat_id), false);
    actionBar.setItemsColor(Theme.getColor(Theme.key_actionBarDefaultIcon), false);
    actionBar.setItemsColor(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon), true);
    actionBar.setBackButtonDrawable(new BackDrawable(false));
    actionBar.setCastShadows(false);
    actionBar.setAddToContainer(false);
    actionBar.setOccupyStatusBar(Build.VERSION.SDK_INT >= 21 && !AndroidUtilities.isTablet());
    return actionBar;
}
 
Example 2
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int totalHeight = MeasureSpec.getSize(heightMeasureSpec);
    if (totalHeight == 0) {
        totalHeight = AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
    }
    if (currentType == 0) {
        ArrayList<TLRPC.RecentMeUrl> arrayList = MessagesController.getInstance(currentAccount).hintDialogs;
        if (!arrayList.isEmpty()) {
            totalHeight -= AndroidUtilities.dp(72) * arrayList.size() + arrayList.size() - 1 + AndroidUtilities.dp(12 + 38);
        }
        super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.EXACTLY));
    } else {
        super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.AT_MOST));
    }
}
 
Example 3
private static int getSideCoord(boolean isX, int side, float p, int sideSize) {
    int total;
    if (isX) {
        total = AndroidUtilities.displaySize.x - sideSize;
    } else {
        total = AndroidUtilities.displaySize.y - sideSize - ActionBar.getCurrentActionBarHeight();
    }
    int result;
    if (side == 0) {
        result = AndroidUtilities.dp(10);
    } else if (side == 1) {
        result = total - AndroidUtilities.dp(10);
    } else {
        result = Math.round((total - AndroidUtilities.dp(20)) * p) + AndroidUtilities.dp(10);
    }
    if (!isX) {
        result += ActionBar.getCurrentActionBarHeight();
    }
    return result;
}
 
Example 4
private static int getSideCoord(boolean isX, int side, float p, int sideSize) {
    int total;
    if (isX) {
        total = AndroidUtilities.displaySize.x - sideSize;
    } else {
        total = AndroidUtilities.displaySize.y - sideSize - ActionBar.getCurrentActionBarHeight();
    }
    int result;
    if (side == 0) {
        result = AndroidUtilities.dp(10);
    } else if (side == 1) {
        result = total - AndroidUtilities.dp(10);
    } else {
        result = Math.round((total - AndroidUtilities.dp(20)) * p) + AndroidUtilities.dp(10);
    }
    if (!isX) {
        result += ActionBar.getCurrentActionBarHeight();
    }
    return result;
}
 
Example 5
Source Project: Telegram   Source File: ProfileGalleryView.java    License: GNU General Public License v2.0 6 votes vote down vote up
public ProfileGalleryView(Context context, long dialogId, ActionBar parentActionBar, RecyclerListView parentListView, ProfileActivity.AvatarImageView parentAvatarImageView, int parentClassGuid, Callback callback) {
    super(context);
    setVisibility(View.GONE);
    setOverScrollMode(View.OVER_SCROLL_NEVER);
    setOffscreenPageLimit(2);

    this.dialogId = dialogId;
    this.parentListView = parentListView;
    this.parentClassGuid = parentClassGuid;
    setAdapter(adapter = new ViewPagerAdapter(context, parentAvatarImageView, parentActionBar));
    this.touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    this.callback = callback;

    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.dialogPhotosLoaded);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.fileDidLoad);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.FileLoadProgressChanged);
    MessagesController.getInstance(currentAccount).loadDialogPhotos((int) dialogId, 80, 0, true, parentClassGuid);
}
 
Example 6
@Override
protected ActionBar createActionBar(Context context)
{
    ActionBar actionBar = new ActionBar(context)
    {
        @Override
        public boolean onTouchEvent(MotionEvent event)
        {
            return super.onTouchEvent(event);
        }
    };

    actionBar.setItemsBackgroundColor(AvatarDrawable.getButtonColorForId(user_id != 0 || ChatObject.isChannel(chat_id, currentAccount) && !currentChat.megagroup ? 5 : chat_id), false);
    actionBar.setItemsColor(Theme.getColor(Theme.key_actionBarDefaultIcon), false);
    actionBar.setItemsColor(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon), true);
    actionBar.setBackButtonDrawable(new BackDrawable(false));
    actionBar.setCastShadows(false);
    actionBar.setAddToContainer(false);
    actionBar.setOccupyStatusBar(Build.VERSION.SDK_INT >= 21 && !AndroidUtilities.isTablet());
    return actionBar;
}
 
Example 7
Source Project: Telegram   Source File: PipVideoView.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static int getSideCoord(boolean isX, int side, float p, int sideSize) {
    int total;
    if (isX) {
        total = AndroidUtilities.displaySize.x - sideSize;
    } else {
        total = AndroidUtilities.displaySize.y - sideSize - ActionBar.getCurrentActionBarHeight();
    }
    int result;
    if (side == 0) {
        result = AndroidUtilities.dp(10);
    } else if (side == 1) {
        result = total - AndroidUtilities.dp(10);
    } else {
        result = Math.round((total - AndroidUtilities.dp(20)) * p) + AndroidUtilities.dp(10);
    }
    if (!isX) {
        result += ActionBar.getCurrentActionBarHeight();
    }
    return result;
}
 
Example 8
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int totalHeight = MeasureSpec.getSize(heightMeasureSpec);
    if (totalHeight == 0) {
        totalHeight = AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
    }
    if (currentType == 0) {
        ArrayList<TLRPC.RecentMeUrl> arrayList = MessagesController.getInstance(currentAccount).hintDialogs;
        if (!arrayList.isEmpty()) {
            totalHeight -= AndroidUtilities.dp(72) * arrayList.size() + arrayList.size() - 1 + AndroidUtilities.dp(12 + 38);
        }
        super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.EXACTLY));
    } else {
        super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.AT_MOST));
    }
}
 
Example 9
private static int getSideCoord(boolean isX, int side, float p, int sideSize) {
    int total;
    if (isX) {
        total = AndroidUtilities.displaySize.x - sideSize;
    } else {
        total = AndroidUtilities.displaySize.y - sideSize - ActionBar.getCurrentActionBarHeight();
    }
    int result;
    if (side == 0) {
        result = AndroidUtilities.dp(10);
    } else if (side == 1) {
        result = total - AndroidUtilities.dp(10);
    } else {
        result = Math.round((total - AndroidUtilities.dp(20)) * p) + AndroidUtilities.dp(10);
    }
    if (!isX) {
        result += ActionBar.getCurrentActionBarHeight();
    }
    return result;
}
 
Example 10
private static int getSideCoord(boolean isX, int side, float p, int sideSize) {
    int total;
    if (isX) {
        total = AndroidUtilities.displaySize.x - sideSize;
    } else {
        total = AndroidUtilities.displaySize.y - sideSize - ActionBar.getCurrentActionBarHeight();
    }
    int result;
    if (side == 0) {
        result = AndroidUtilities.dp(10);
    } else if (side == 1) {
        result = total - AndroidUtilities.dp(10);
    } else {
        result = Math.round((total - AndroidUtilities.dp(20)) * p) + AndroidUtilities.dp(10);
    }
    if (!isX) {
        result += ActionBar.getCurrentActionBarHeight();
    }
    return result;
}
 
Example 11
private static int getSideCoord(boolean isX, int side, float p, int sideSize) {
    int total;
    if (isX) {
        total = AndroidUtilities.displaySize.x - sideSize;
    } else {
        total = AndroidUtilities.displaySize.y - sideSize - ActionBar.getCurrentActionBarHeight();
    }
    int result;
    if (side == 0) {
        result = AndroidUtilities.dp(10);
    } else if (side == 1) {
        result = total - AndroidUtilities.dp(10);
    } else {
        result = Math.round((total - AndroidUtilities.dp(20)) * p) + AndroidUtilities.dp(10);
    }
    if (!isX) {
        result += ActionBar.getCurrentActionBarHeight();
    }
    return result;
}
 
Example 12
public HintInnerCell(Context context) {
    super(context);

    int top = (int) ((ActionBar.getCurrentActionBarHeight() + (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0)) / AndroidUtilities.density) - 44;

    imageView = new ImageView(context);
    imageView.setBackgroundDrawable(Theme.createCircleDrawable(AndroidUtilities.dp(74), Theme.getColor(Theme.key_chats_archiveBackground)));
    imageView.setImageDrawable(new ShareLocationDrawable(context, 2));
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    addView(imageView, LayoutHelper.createFrame(74, 74, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, top + 27, 0, 0));

    titleTextView = new TextView(context);
    titleTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 24);
    titleTextView.setGravity(Gravity.CENTER);
    titleTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("PeopleNearby", R.string.PeopleNearby)));
    addView(titleTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 52, top + 120, 52, 27));

    messageTextView = new TextView(context);
    messageTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
    messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    messageTextView.setGravity(Gravity.CENTER);
    messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("PeopleNearbyInfo2", R.string.PeopleNearbyInfo2)));
    addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 40, top + 161, 40, 27));
}
 
Example 13
Source Project: Telegram   Source File: ThemeEditorView.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static int getSideCoord(boolean isX, int side, float p, int sideSize) {
    int total;
    if (isX) {
        total = AndroidUtilities.displaySize.x - sideSize;
    } else {
        total = AndroidUtilities.displaySize.y - sideSize - ActionBar.getCurrentActionBarHeight();
    }
    int result;
    if (side == 0) {
        result = AndroidUtilities.dp(10);
    } else if (side == 1) {
        result = total - AndroidUtilities.dp(10);
    } else {
        result = Math.round((total - AndroidUtilities.dp(20)) * p) + AndroidUtilities.dp(10);
    }
    if (!isX) {
        result += ActionBar.getCurrentActionBarHeight();
    }
    return result;
}
 
Example 14
public HintInnerCell(Context context) {
    super(context);

    int top = (int) ((ActionBar.getCurrentActionBarHeight() + (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0)) / AndroidUtilities.density) - 44;

    imageView = new ImageView(context);
    imageView.setBackgroundDrawable(Theme.createCircleDrawable(AndroidUtilities.dp(74), Theme.getColor(Theme.key_chats_archiveBackground)));
    imageView.setImageDrawable(new ShareLocationDrawable(context, 2));
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    addView(imageView, LayoutHelper.createFrame(74, 74, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, top + 27, 0, 0));

    titleTextView = new TextView(context);
    titleTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 24);
    titleTextView.setGravity(Gravity.CENTER);
    titleTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("PeopleNearby", R.string.PeopleNearby)));
    addView(titleTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 52, top + 120, 52, 27));

    messageTextView = new TextView(context);
    messageTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
    messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    messageTextView.setGravity(Gravity.CENTER);
    messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("PeopleNearbyInfo2", R.string.PeopleNearbyInfo2)));
    addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 40, top + 161, 40, 27));
}
 
Example 15
Source Project: Telegram   Source File: DialogsEmptyCell.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int totalHeight;
    if (getParent() instanceof View) {
        View view = (View) getParent();
        totalHeight = view.getMeasuredHeight();
        if (view.getPaddingTop() != 0 && Build.VERSION.SDK_INT >= 21) {
            totalHeight -= AndroidUtilities.statusBarHeight;
        }
    } else {
        totalHeight = MeasureSpec.getSize(heightMeasureSpec);
    }
    if (totalHeight == 0) {
        totalHeight = AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
    }
    if (currentType == 0 || currentType == 2 || currentType == 3) {
        ArrayList<TLRPC.RecentMeUrl> arrayList = MessagesController.getInstance(currentAccount).hintDialogs;
        if (!arrayList.isEmpty()) {
            totalHeight -= AndroidUtilities.dp(72) * arrayList.size() + arrayList.size() - 1 + AndroidUtilities.dp(12 + 38);
        }
        super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.EXACTLY));
    } else {
        super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(166), MeasureSpec.EXACTLY));
    }
}
 
Example 16
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int totalHeight;
    if (getParent() instanceof View) {
        View view = (View) getParent();
        totalHeight = view.getMeasuredHeight();
        if (view.getPaddingTop() != 0 && Build.VERSION.SDK_INT >= 21) {
            totalHeight -= AndroidUtilities.statusBarHeight;
        }
    } else {
        totalHeight = MeasureSpec.getSize(heightMeasureSpec);
    }
    if (totalHeight == 0) {
        totalHeight = AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
    }
    if (currentType == 0 || currentType == 2 || currentType == 3) {
        ArrayList<TLRPC.RecentMeUrl> arrayList = MessagesController.getInstance(currentAccount).hintDialogs;
        if (!arrayList.isEmpty()) {
            totalHeight -= AndroidUtilities.dp(72) * arrayList.size() + arrayList.size() - 1 + AndroidUtilities.dp(12 + 38);
        }
        super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.EXACTLY));
    } else {
        super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(166), MeasureSpec.EXACTLY));
    }
}
 
Example 17
Source Project: Telegram-FOSS   Source File: PipVideoView.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static int getSideCoord(boolean isX, int side, float p, int sideSize) {
    int total;
    if (isX) {
        total = AndroidUtilities.displaySize.x - sideSize;
    } else {
        total = AndroidUtilities.displaySize.y - sideSize - ActionBar.getCurrentActionBarHeight();
    }
    int result;
    if (side == 0) {
        result = AndroidUtilities.dp(10);
    } else if (side == 1) {
        result = total - AndroidUtilities.dp(10);
    } else {
        result = Math.round((total - AndroidUtilities.dp(20)) * p) + AndroidUtilities.dp(10);
    }
    if (!isX) {
        result += ActionBar.getCurrentActionBarHeight();
    }
    return result;
}
 
Example 18
private static int getSideCoord(boolean isX, int side, float p, int sideSize) {
    int total;
    if (isX) {
        total = AndroidUtilities.displaySize.x - sideSize;
    } else {
        total = AndroidUtilities.displaySize.y - sideSize - ActionBar.getCurrentActionBarHeight();
    }
    int result;
    if (side == 0) {
        result = AndroidUtilities.dp(10);
    } else if (side == 1) {
        result = total - AndroidUtilities.dp(10);
    } else {
        result = Math.round((total - AndroidUtilities.dp(20)) * p) + AndroidUtilities.dp(10);
    }
    if (!isX) {
        result += ActionBar.getCurrentActionBarHeight();
    }
    return result;
}
 
Example 19
public ProfileGalleryView(Context context, long dialogId, ActionBar parentActionBar, RecyclerListView parentListView, ProfileActivity.AvatarImageView parentAvatarImageView, int parentClassGuid, Callback callback) {
    super(context);
    setVisibility(View.GONE);
    setOverScrollMode(View.OVER_SCROLL_NEVER);
    setOffscreenPageLimit(2);

    this.dialogId = dialogId;
    this.parentListView = parentListView;
    this.parentClassGuid = parentClassGuid;
    setAdapter(adapter = new ViewPagerAdapter(context, parentAvatarImageView, parentActionBar));
    this.touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    this.callback = callback;

    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.dialogPhotosLoaded);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.fileDidLoad);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.FileLoadProgressChanged);
    MessagesController.getInstance(currentAccount).loadDialogPhotos((int) dialogId, 80, 0, true, parentClassGuid);
}
 
Example 20
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 21
@Override
public View createView(Context context) {
    actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == done_button) {
                views[currentViewNum].onNextPressed();
            } else if (id == -1) {
                finishFragment();
            }
        }
    });

    ActionBarMenu menu = actionBar.createMenu();
    doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

    fragmentView = new ScrollView(context);
    ScrollView scrollView = (ScrollView) fragmentView;
    scrollView.setFillViewport(true);

    FrameLayout frameLayout = new FrameLayout(context);
    scrollView.addView(frameLayout, LayoutHelper.createScroll(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT));

    views[0] = new PhoneView(context);
    views[1] = new LoginActivitySmsView(context, 1);
    views[2] = new LoginActivitySmsView(context, 2);
    views[3] = new LoginActivitySmsView(context, 3);
    views[4] = new LoginActivitySmsView(context, 4);

    for (int a = 0; a < views.length; a++) {
        views[a].setVisibility(a == 0 ? View.VISIBLE : View.GONE);
        frameLayout.addView(views[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, a == 0 ? LayoutHelper.WRAP_CONTENT : LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, AndroidUtilities.isTablet() ? 26 : 18, 30, AndroidUtilities.isTablet() ? 26 : 18, 0));
    }

    actionBar.setTitle(views[0].getHeaderName());

    return fragmentView;
}
 
Example 22
@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 23
private void needLayout() {
    FrameLayout.LayoutParams layoutParams;
    int newTop = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight();
    if (listView != null) {
        layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
        if (layoutParams.topMargin != newTop) {
            layoutParams.topMargin = newTop;
            listView.setLayoutParams(layoutParams);
            extraHeightView.setTranslationY(newTop);
        }
    }

    if (avatarImage != null) {
        float diff = extraHeight / (float) AndroidUtilities.dp(88);
        extraHeightView.setScaleY(diff);
        shadowView.setTranslationY(newTop + extraHeight);

        avatarImage.setScaleX((42 + 18 * diff) / 42.0f);
        avatarImage.setScaleY((42 + 18 * diff) / 42.0f);
        float avatarY = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() / 2.0f * (1.0f + diff) - 21 * AndroidUtilities.density + 27 * AndroidUtilities.density * diff;
        avatarImage.setTranslationX(-AndroidUtilities.dp(47) * diff);
        avatarImage.setTranslationY((float) Math.ceil(avatarY));
        nameTextView.setTranslationX(-21 * AndroidUtilities.density * diff);
        nameTextView.setTranslationY((float) Math.floor(avatarY) - (float) Math.ceil(AndroidUtilities.density) + (float) Math.floor(7 * AndroidUtilities.density * diff));
        nameTextView.setScaleX(1.0f + 0.12f * diff);
        nameTextView.setScaleY(1.0f + 0.12f * diff);
    }
}
 
Example 24
private void fixLayout() {
    if (avatarContainer != null) {
        avatarContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                if (avatarContainer != null) {
                    avatarContainer.getViewTreeObserver().removeOnPreDrawListener(this);
                }
                int padding = (ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(48)) / 2;
                avatarContainer.setPadding(avatarContainer.getPaddingLeft(), padding, avatarContainer.getPaddingRight(), padding);
                return true;
            }
        });
    }
    if (messageContainer != null) {
        messageContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                messageContainer.getViewTreeObserver().removeOnPreDrawListener(this);
                if (!checkTransitionAnimation() && !startedMoving) {
                    ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) messageContainer.getLayoutParams();
                    layoutParams.topMargin = ActionBar.getCurrentActionBarHeight();
                    layoutParams.bottomMargin = AndroidUtilities.dp(48);
                    layoutParams.width = ViewGroup.MarginLayoutParams.MATCH_PARENT;
                    layoutParams.height = ViewGroup.MarginLayoutParams.MATCH_PARENT;
                    messageContainer.setLayoutParams(layoutParams);
                    applyViewsLayoutParams(0);
                }
                return true;
            }
        });
    }
}
 
Example 25
private void fixLayout() {
    if (avatarContainer != null) {
        avatarContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                if (avatarContainer != null) {
                    avatarContainer.getViewTreeObserver().removeOnPreDrawListener(this);
                }
                int padding = (ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(48)) / 2;
                avatarContainer.setPadding(avatarContainer.getPaddingLeft(), padding, avatarContainer.getPaddingRight(), padding);
                return true;
            }
        });
    }
    if (messageContainer != null) {
        messageContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                messageContainer.getViewTreeObserver().removeOnPreDrawListener(this);
                if (!checkTransitionAnimation() && !startedMoving) {
                    ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) messageContainer.getLayoutParams();
                    layoutParams.topMargin = ActionBar.getCurrentActionBarHeight();
                    layoutParams.bottomMargin = AndroidUtilities.dp(48);
                    layoutParams.width = ViewGroup.MarginLayoutParams.MATCH_PARENT;
                    layoutParams.height = ViewGroup.MarginLayoutParams.MATCH_PARENT;
                    messageContainer.setLayoutParams(layoutParams);
                    applyViewsLayoutParams(0);
                }
                return true;
            }
        });
    }
}
 
Example 26
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    int actionBarHeight = ActionBar.getCurrentActionBarHeight();
    int viewTop = (actionBarHeight - AndroidUtilities.dp(42)) / 2 + (Build.VERSION.SDK_INT >= 21 && occupyStatusBar ? AndroidUtilities.statusBarHeight : 0);
    avatarImageView.layout(AndroidUtilities.dp(8), viewTop, AndroidUtilities.dp(42 + 8), viewTop + AndroidUtilities.dp(42));
    if (subtitleTextView.getVisibility() == VISIBLE) {
        titleTextView.layout(AndroidUtilities.dp(8 + 54), viewTop + AndroidUtilities.dp(1.3f), AndroidUtilities.dp(8 + 54) + titleTextView.getMeasuredWidth(), viewTop + titleTextView.getTextHeight() + AndroidUtilities.dp(1.3f));
    } else {
        titleTextView.layout(AndroidUtilities.dp(8 + 54), viewTop + AndroidUtilities.dp(11), AndroidUtilities.dp(8 + 54) + titleTextView.getMeasuredWidth(), viewTop + titleTextView.getTextHeight() + AndroidUtilities.dp(11));
    }
    if (timeItem != null) {
        timeItem.layout(AndroidUtilities.dp(8 + 16), viewTop + AndroidUtilities.dp(15), AndroidUtilities.dp(8 + 16 + 34), viewTop + AndroidUtilities.dp(15 + 34));
    }
    subtitleTextView.layout(AndroidUtilities.dp(8 + 54), viewTop + AndroidUtilities.dp(24), AndroidUtilities.dp(8 + 54) + subtitleTextView.getMeasuredWidth(), viewTop + subtitleTextView.getTextHeight() + AndroidUtilities.dp(24));
}
 
Example 27
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);

    setMeasuredDimension(width, height);

    float bitmapW;
    float bitmapH;
    int fullHeight = AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight();
    int maxHeight = fullHeight - AndroidUtilities.dp(48);
    if (bitmapToEdit != null) {
        bitmapW = isSidewardOrientation() ? bitmapToEdit.getHeight() : bitmapToEdit.getWidth();
        bitmapH = isSidewardOrientation() ? bitmapToEdit.getWidth() : bitmapToEdit.getHeight();
    } else {
        bitmapW = width;
        bitmapH = height - ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(48);
    }

    float renderWidth = width;
    float renderHeight = (float) Math.floor(renderWidth * bitmapH / bitmapW);
    if (renderHeight > maxHeight) {
        renderHeight = maxHeight;
        renderWidth = (float) Math.floor(renderHeight * bitmapW / bitmapH);
    }

    renderView.measure(MeasureSpec.makeMeasureSpec((int) renderWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) renderHeight, MeasureSpec.EXACTLY));
    entitiesView.measure(MeasureSpec.makeMeasureSpec((int) paintingSize.width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) paintingSize.height, MeasureSpec.EXACTLY));
    dimView.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST));
    selectionContainerView.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.EXACTLY));
    colorPicker.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.EXACTLY));
    toolsView.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY));
    if (stickersView != null) {
        stickersView.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.y, MeasureSpec.EXACTLY));
    }
}
 
Example 28
@Override
public View createView(Context context) {
    actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR);
    actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR, false);
    actionBar.setTitleColor(0xffffffff);
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("CropImage", R.string.CropImage));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                if (delegate != null && !doneButtonPressed) {
                    Bitmap bitmap = view.getBitmap();
                    if (bitmap == imageToCrop) {
                        sameBitmap = true;
                    }
                    delegate.didFinishEdit(bitmap);
                    doneButtonPressed = true;
                }
                finishFragment();
            }
        }
    });

    ActionBarMenu menu = actionBar.createMenu();
    menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

    fragmentView = view = new PhotoCropView(context);
    ((PhotoCropView) fragmentView).freeform = getArguments().getBoolean("freeform", false);
    fragmentView.setLayoutParams(new FrameLayout.LayoutParams(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    return fragmentView;
}
 
Example 29
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 30
@Override
public View createView(Context context) {
    actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == done_button) {
                views[currentViewNum].onNextPressed();
            } else if (id == -1) {
                finishFragment();
            }
        }
    });

    ActionBarMenu menu = actionBar.createMenu();
    doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

    fragmentView = new ScrollView(context);
    ScrollView scrollView = (ScrollView) fragmentView;
    scrollView.setFillViewport(true);

    FrameLayout frameLayout = new FrameLayout(context);
    scrollView.addView(frameLayout, LayoutHelper.createScroll(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT));

    views[0] = new PhoneView(context);
    views[1] = new LoginActivitySmsView(context, 1);
    views[2] = new LoginActivitySmsView(context, 2);
    views[3] = new LoginActivitySmsView(context, 3);
    views[4] = new LoginActivitySmsView(context, 4);

    for (int a = 0; a < views.length; a++) {
        views[a].setVisibility(a == 0 ? View.VISIBLE : View.GONE);
        frameLayout.addView(views[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, a == 0 ? LayoutHelper.WRAP_CONTENT : LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, AndroidUtilities.isTablet() ? 26 : 18, 30, AndroidUtilities.isTablet() ? 26 : 18, 0));
    }

    actionBar.setTitle(views[0].getHeaderName());

    return fragmentView;
}