Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Feat(android): add "slash" on inputbar #997

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,15 @@ public void onAttachPressed() {
}
}

@Override
public void onSlashPressed() {
if (findInputBar().getText() == "/") {
findInputBar().setText("", true);
} else {
findInputBar().setText("/", true);
}
}

@Override
public void onAvatarClick(int uid) {
ActorSDKLauncher.startProfileActivity(getActivity(), uid);
Expand Down Expand Up @@ -474,6 +483,7 @@ private void hideQuote() {
findInputBar().setDisableOnEmptyText(true);
findInputBar().setAudioEnabled(true);
findInputBar().setAttachEnabled(true);
findInputBar().setSlashEnabled(true);
}

private void showQuote(String text, boolean isQuote) {
Expand All @@ -482,5 +492,6 @@ private void showQuote(String text, boolean isQuote) {
findInputBar().setDisableOnEmptyText(false);
findInputBar().setAudioEnabled(false);
findInputBar().setAttachEnabled(false);
findInputBar().setSlashEnabled(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ public interface InputBarCallback {
void onStickerSent(Sticker sticker);

void onAttachPressed();

void onSlashPressed();
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class InputBarFragment extends BaseFragment implements MessagesDefaultFra

private boolean isAudioEnabled = true;
private boolean isAttachEnabled = true;
private boolean isSlashEnabled = true;
private boolean isDisableOnEmptyText = true;

//
Expand All @@ -72,6 +73,7 @@ public class InputBarFragment extends BaseFragment implements MessagesDefaultFra
protected BarEditText messageEditText;
protected TintImageView sendButton;
protected ImageButton attachButton;
protected ImageButton slashButton;
protected String lastWord = "";

//
Expand Down Expand Up @@ -194,6 +196,15 @@ public void afterTextChanged(Editable editable) {
});


//
// Slash Button
//
slashButton = (ImageButton) res.findViewById(R.id.ib_slash);
slashButton.setOnClickListener(v -> {
onSlashButtonClicked();
});


//
// Emoji keyboard
//
Expand Down Expand Up @@ -366,6 +377,16 @@ public void setAttachEnabled(boolean attachEnabled) {
checkSendButton();
}

public boolean isSlashEnabled() {
return isSlashEnabled;
}

public void setSlashEnabled(boolean slashEnabled) {
isSlashEnabled = slashEnabled;
hideAudio(true);
checkSendButton();
}

public boolean isDisableOnEmptyText() {
return isDisableOnEmptyText;
}
Expand Down Expand Up @@ -397,6 +418,13 @@ protected void onAttachButtonClicked() {
}
}

protected void onSlashButtonClicked() {
Fragment parent = getParentFragment();
if (parent instanceof InputBarCallback) {
((InputBarCallback) parent).onSlashPressed();
}
}

protected void onBeforeTextChanged(CharSequence s, int start, int count, int after) {
Fragment parent = getParentFragment();
if (parent instanceof InputBarCallback) {
Expand Down Expand Up @@ -475,6 +503,7 @@ protected void checkSendButton(boolean hasText) {
} else {
zoomOutView(attachButton);
}
zoomOutView(slashButton);
zoomInView(sendButton);
zoomOutView(audioButton);
} else {
Expand All @@ -485,6 +514,11 @@ protected void checkSendButton(boolean hasText) {
} else {
zoomOutView(attachButton);
}
if (isSlashEnabled) {
zoomInView(slashButton);
} else {
zoomOutView(slashButton);
}
if (isAudioEnabled) {
zoomInView(audioButton);
zoomOutView(sendButton);
Expand All @@ -510,6 +544,7 @@ protected void showAudio() {
isAudioVisible = true;

hideView(attachButton);
hideView(slashButton);
hideView(messageEditText);
hideView(emojiButton);

Expand Down Expand Up @@ -552,6 +587,7 @@ protected void hideAudio(boolean cancel) {
isAudioVisible = false;

showView(attachButton);
showView(slashButton);
showView(messageEditText);
showView(emojiButton);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,13 @@ public void onDestroyView() {

private void expandMentions(final BottomSheetListView list, final int oldRowsCount, final int newRowsCount) {
list.post(() -> {
if (newRowsCount == oldRowsCount) {
return;
}

// I dont understand for what it.
// But when its not comment, not work first time typing "/", only next.
//
//if (newRowsCount == oldRowsCount) {
// return;
//}

list.setMinHeight(newRowsCount == 0 ? 0 : newRowsCount == 1 ? Screen.dp(48) + 1 : newRowsCount == 2 ? Screen.dp(96) + 2 : Screen.dp(122));
list.setVisibility(View.VISIBLE);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<bitmap android:src="@drawable/conv_slash"/>
</item>
<item>
<bitmap android:src="@drawable/conv_slash"/>
</item>
</selector>
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,28 @@
android:textCursorDrawable="@null"
android:textSize="16sp" />

<FrameLayout
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="right|bottom"
android:layout_marginRight="111dp">

<ImageButton
android:id="@+id/ib_slash"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/selector_flat"
android:padding="7dp"
android:src="@drawable/button_slash" />

<View
android:id="@+id/slashAnchor"
android:layout_width="56dp"
android:layout_height="0dp"
android:layout_gravity="top"
android:layout_marginTop="46dp" />
</FrameLayout>

<FrameLayout
android:layout_width="56dp"
android:layout_height="56dp"
Expand Down