Java Code Examples for org.telegram.ui.Components.LayoutHelper#MATCH_PARENT

The following examples show how to use org.telegram.ui.Components.LayoutHelper#MATCH_PARENT . 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: ActionBarLayout.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void init(ArrayList<BaseFragment> stack)
{
    fragmentsStack = stack;
    containerViewBack = new LinearLayoutContainer(parentActivity);
    addView(containerViewBack);
    LayoutParams layoutParams = (LayoutParams) containerViewBack.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    containerViewBack.setLayoutParams(layoutParams);

    containerView = new LinearLayoutContainer(parentActivity);
    addView(containerView);
    layoutParams = (LayoutParams) containerView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    containerView.setLayoutParams(layoutParams);

    for (BaseFragment fragment : fragmentsStack)
    {
        fragment.setParentLayout(this);
    }
}
 
Example 2
Source File: ActionBarLayout.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void init(ArrayList<BaseFragment> stack)
{
    fragmentsStack = stack;
    containerViewBack = new LinearLayoutContainer(parentActivity);
    addView(containerViewBack);
    LayoutParams layoutParams = (LayoutParams) containerViewBack.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    containerViewBack.setLayoutParams(layoutParams);

    containerView = new LinearLayoutContainer(parentActivity);
    addView(containerView);
    layoutParams = (LayoutParams) containerView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    containerView.setLayoutParams(layoutParams);

    for (BaseFragment fragment : fragmentsStack)
    {
        fragment.setParentLayout(this);
    }
}
 
Example 3
Source File: ActionBarLayout.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void init(ArrayList<BaseFragment> stack) {
    fragmentsStack = stack;
    containerViewBack = new LayoutContainer(parentActivity);
    addView(containerViewBack);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) containerViewBack.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    containerViewBack.setLayoutParams(layoutParams);

    containerView = new LayoutContainer(parentActivity);
    addView(containerView);
    layoutParams = (FrameLayout.LayoutParams) containerView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    containerView.setLayoutParams(layoutParams);

    for (BaseFragment fragment : fragmentsStack) {
        fragment.setParentLayout(this);
    }
}
 
Example 4
Source File: ActionBarLayout.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void init(ArrayList<BaseFragment> stack) {
    fragmentsStack = stack;
    containerViewBack = new LayoutContainer(parentActivity);
    addView(containerViewBack);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) containerViewBack.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    containerViewBack.setLayoutParams(layoutParams);

    containerView = new LayoutContainer(parentActivity);
    addView(containerView);
    layoutParams = (FrameLayout.LayoutParams) containerView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    containerView.setLayoutParams(layoutParams);

    for (BaseFragment fragment : fragmentsStack) {
        fragment.setParentLayout(this);
    }
}
 
Example 5
Source File: ExternalActionActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
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 6
Source File: ExternalActionActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
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 7
Source File: ExternalActionActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
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 8
Source File: ActionBarMenuItem.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public ActionBarMenuSubItem addSubItem(int id, int icon, CharSequence text) {
    createPopupLayout();

    ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getContext());
    cell.setTextAndIcon(text, icon);
    cell.setMinimumWidth(AndroidUtilities.dp(196));
    cell.setTag(id);
    popupLayout.addView(cell);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) cell.getLayoutParams();
    if (LocaleController.isRTL) {
        layoutParams.gravity = Gravity.RIGHT;
    }
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(48);
    cell.setLayoutParams(layoutParams);
    cell.setOnClickListener(view -> {
        if (popupWindow != null && popupWindow.isShowing()) {
            if (processedPopupClick) {
                return;
            }
            processedPopupClick = true;
            popupWindow.dismiss(allowCloseAnimation);
        }
        if (parentMenu != null) {
            parentMenu.onItemClick((Integer) view.getTag());
        } else if (delegate != null) {
            delegate.onItemClick((Integer) view.getTag());
        }
    });
    return cell;
}
 
Example 9
Source File: ExternalActionActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
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 10
Source File: ActionBarMenuItem.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public ActionBarMenuSubItem addSubItem(int id, int icon, CharSequence text) {
    createPopupLayout();

    ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getContext());
    cell.setTextAndIcon(text, icon);
    cell.setMinimumWidth(AndroidUtilities.dp(196));
    cell.setTag(id);
    popupLayout.addView(cell);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) cell.getLayoutParams();
    if (LocaleController.isRTL) {
        layoutParams.gravity = Gravity.RIGHT;
    }
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(48);
    cell.setLayoutParams(layoutParams);
    cell.setOnClickListener(view -> {
        if (popupWindow != null && popupWindow.isShowing()) {
            if (processedPopupClick) {
                return;
            }
            processedPopupClick = true;
            popupWindow.dismiss(allowCloseAnimation);
        }
        if (parentMenu != null) {
            parentMenu.onItemClick((Integer) view.getTag());
        } else if (delegate != null) {
            delegate.onItemClick((Integer) view.getTag());
        }
    });
    return cell;
}
 
Example 11
Source File: ActionBarMenuItem.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public TextView addSubItem(int id, CharSequence text)
{
    createPopupLayout();
    TextView textView = new TextView(getContext());
    textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
    textView.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    if (!LocaleController.isRTL)
    {
        textView.setGravity(Gravity.CENTER_VERTICAL);
    }
    else
    {
        textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    }
    textView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setMinWidth(AndroidUtilities.dp(196));
    textView.setTag(id);
    textView.setText(text);
    popupLayout.addView(textView);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams();
    if (LocaleController.isRTL)
    {
        layoutParams.gravity = Gravity.RIGHT;
    }
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(48);
    textView.setLayoutParams(layoutParams);

    textView.setOnClickListener(view ->
    {
        if (popupWindow != null && popupWindow.isShowing())
        {
            if (processedPopupClick)
            {
                return;
            }
            processedPopupClick = true;
            popupWindow.dismiss(allowCloseAnimation);
        }
        if (parentMenu != null)
        {
            parentMenu.onItemClick((Integer) view.getTag());
        }
        else if (delegate != null)
        {
            delegate.onItemClick((Integer) view.getTag());
        }
    });
    return textView;
}
 
Example 12
Source File: ActionBarMenuItem.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public TextView addSubItem(int id, CharSequence text)
{
    createPopupLayout();
    TextView textView = new TextView(getContext());
    textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
    textView.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    if (!LocaleController.isRTL)
    {
        textView.setGravity(Gravity.CENTER_VERTICAL);
    }
    else
    {
        textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    }
    textView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setMinWidth(AndroidUtilities.dp(196));
    textView.setTag(id);
    textView.setText(text);
    popupLayout.addView(textView);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams();
    if (LocaleController.isRTL)
    {
        layoutParams.gravity = Gravity.RIGHT;
    }
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(48);
    textView.setLayoutParams(layoutParams);

    textView.setOnClickListener(view ->
    {
        if (popupWindow != null && popupWindow.isShowing())
        {
            if (processedPopupClick)
            {
                return;
            }
            processedPopupClick = true;
            popupWindow.dismiss(allowCloseAnimation);
        }
        if (parentMenu != null)
        {
            parentMenu.onItemClick((Integer) view.getTag());
        }
        else if (delegate != null)
        {
            delegate.onItemClick((Integer) view.getTag());
        }
    });
    return textView;
}
 
Example 13
Source File: ActionBarMenuItem.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public TextView addSubItem(int id, CharSequence text) {
    createPopupLayout();
    TextView textView = new TextView(getContext());
    textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
    textView.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    if (!LocaleController.isRTL) {
        textView.setGravity(Gravity.CENTER_VERTICAL);
    } else {
        textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    }
    textView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setMinWidth(AndroidUtilities.dp(196));
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setTag(id);
    textView.setText(text);
    popupLayout.addView(textView);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams();
    if (LocaleController.isRTL) {
        layoutParams.gravity = Gravity.RIGHT;
    }
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(48);
    textView.setLayoutParams(layoutParams);

    textView.setOnClickListener(view -> {
        if (popupWindow != null && popupWindow.isShowing()) {
            if (processedPopupClick) {
                return;
            }
            processedPopupClick = true;
            if (!allowCloseAnimation) {
                popupWindow.setAnimationStyle(R.style.PopupAnimation);
            }
            popupWindow.dismiss(allowCloseAnimation);
        }
        if (parentMenu != null) {
            parentMenu.onItemClick((Integer) view.getTag());
        } else if (delegate != null) {
            delegate.onItemClick((Integer) view.getTag());
        }
    });
    return textView;
}
 
Example 14
Source File: ActionBarMenuItem.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public TextView addSubItem(int id, CharSequence text) {
    createPopupLayout();
    TextView textView = new TextView(getContext());
    textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
    textView.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    if (!LocaleController.isRTL) {
        textView.setGravity(Gravity.CENTER_VERTICAL);
    } else {
        textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    }
    textView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setMinWidth(AndroidUtilities.dp(196));
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setTag(id);
    textView.setText(text);
    popupLayout.addView(textView);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams();
    if (LocaleController.isRTL) {
        layoutParams.gravity = Gravity.RIGHT;
    }
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(48);
    textView.setLayoutParams(layoutParams);

    textView.setOnClickListener(view -> {
        if (popupWindow != null && popupWindow.isShowing()) {
            if (processedPopupClick) {
                return;
            }
            processedPopupClick = true;
            if (!allowCloseAnimation) {
                popupWindow.setAnimationStyle(R.style.PopupAnimation);
            }
            popupWindow.dismiss(allowCloseAnimation);
        }
        if (parentMenu != null) {
            parentMenu.onItemClick((Integer) view.getTag());
        } else if (delegate != null) {
            delegate.onItemClick((Integer) view.getTag());
        }
    });
    return textView;
}