org.telegram.ui.ActionBar.ActionBar Java Examples

The following examples show how to use org.telegram.ui.ActionBar.ActionBar. 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: PipVideoView.java    From Telegram-FOSS with 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 #2
Source File: ThemeEditorView.java    From Telegram with 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 #3
Source File: PeopleNearbyActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
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 #4
Source File: ThemeEditorView.java    From TelePlus-Android with 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 #5
Source File: PipRoundVideoView.java    From TelePlus-Android with 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 #6
Source File: PipVideoView.java    From TelePlus-Android with 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 #7
Source File: PeopleNearbyActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
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 #8
Source File: DialogsEmptyCell.java    From Telegram with 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 #9
Source File: DialogsEmptyCell.java    From Telegram-FOSS with 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 #10
Source File: ProfileGalleryView.java    From Telegram with 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 #11
Source File: DialogsEmptyCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@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 #12
Source File: ThemeEditorView.java    From TelePlus-Android with 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 #13
Source File: PipVideoView.java    From TelePlus-Android with 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
Source File: ProfileActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@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 #15
Source File: PipRoundVideoView.java    From Telegram-FOSS with 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 #16
Source File: ProfileGalleryView.java    From Telegram-FOSS with 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 #17
Source File: ProfileActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@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 #18
Source File: PipVideoView.java    From Telegram with 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 #19
Source File: DialogsEmptyCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@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 #20
Source File: FiltersSetupActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("Filters", R.string.Filters));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));

    listView = new RecyclerListView(context);
    ((DefaultItemAnimator) listView.getItemAnimator()).setDelayAnimations(false);
    listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    listView.setVerticalScrollBarEnabled(false);
    itemTouchHelper = new ItemTouchHelper(new TouchHelperCallback());
    itemTouchHelper.attachToRecyclerView(listView);
    frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    listView.setAdapter(adapter = new ListAdapter(context));
    listView.setOnItemClickListener((view, position, x, y) -> {
        if (position >= filtersStartRow && position < filtersEndRow) {
            presentFragment(new FilterCreateActivity(getMessagesController().dialogFilters.get(position - filtersStartRow)));
        } else if (position == createFilterRow) {
            presentFragment(new FilterCreateActivity());
        }
    });

    return fragmentView;
}
 
Example #21
Source File: PhotoCropActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@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.setItemsColor(0xffffffff, false);
    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 #22
Source File: QuickRepliesSettingsActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@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 #23
Source File: ProfileGalleryView.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public ViewPagerAdapter(Context context, ProfileActivity.AvatarImageView parentAvatarImageView, ActionBar parentActionBar) {
    this.context = context;
    this.parentAvatarImageView = parentAvatarImageView;
    this.parentActionBar = parentActionBar;
    placeholderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    placeholderPaint.setColor(Color.BLACK);
}
 
Example #24
Source File: ChatAttachAlertLocationLayout.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void fixLayoutInternal(final boolean resume) {
    int viewHeight = getMeasuredHeight();
    if (viewHeight == 0 || mapView == null) {
        return;
    }
    int height = ActionBar.getCurrentActionBarHeight();
    overScrollHeight = AndroidUtilities.dp(189);
    mapHeight = Math.max(overScrollHeight, Math.min(AndroidUtilities.dp(310), AndroidUtilities.displaySize.y - AndroidUtilities.dp(66) - height));

    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
    layoutParams.topMargin = height;
    listView.setLayoutParams(layoutParams);
    layoutParams = (FrameLayout.LayoutParams) mapViewClip.getLayoutParams();
    layoutParams.topMargin = height;
    layoutParams.height = mapHeight;
    mapViewClip.setLayoutParams(layoutParams);

    layoutParams = (FrameLayout.LayoutParams) searchListView.getLayoutParams();
    layoutParams.topMargin = height;
    searchListView.setLayoutParams(layoutParams);

    adapter.setOverScrollHeight(overScrollHeight);
    layoutParams = (FrameLayout.LayoutParams) mapView.getLayoutParams();
    if (layoutParams != null) {
        layoutParams.height = mapHeight + AndroidUtilities.dp(10);
        mapView.setLayoutParams(layoutParams);
    }
    if (overlayView != null) {
        layoutParams = (FrameLayout.LayoutParams) overlayView.getLayoutParams();
        if (layoutParams != null) {
            layoutParams.height = mapHeight + AndroidUtilities.dp(10);
            overlayView.setLayoutParams(layoutParams);
        }
    }
    adapter.notifyDataSetChanged();
    updateClipView();
}
 
Example #25
Source File: PhonebookShareActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
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 #26
Source File: QuickRepliesSettingsActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@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 #27
Source File: ChatAvatarContainer.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@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 #28
Source File: ChatAvatarContainer.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@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 #29
Source File: PopupNotificationActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
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 #30
Source File: PhotoPickerActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
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));
    }
}