Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature UI improvements #147

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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 @@ -6,7 +6,7 @@

import me.grishka.houseclub.api.model.Channel;

class DataProvider {
public class DataProvider {
private static Channel channelCache = null;

@Nullable
Expand All @@ -15,6 +15,10 @@ public static Channel getChannel(String id) {
return Objects.equals(channelCache.channel, id) ? channelCache : null;
}

public static Channel getCachedChannel(){
return channelCache;
}

public static void saveChannel(Channel channel) {
channelCache = channel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ public void leaveChannel(){
uiHandler.removeCallbacks(pinger);
pubnub.unsubscribeAll();
pubnub.destroy();
uiHandler.post(() -> {
for(ChannelEventListener l:listeners)
l.onSelfLeft();
});
}

public void leaveCurrentChannel(){
Expand Down Expand Up @@ -422,6 +426,7 @@ public interface ChannelEventListener{
void onChannelUpdated(Channel channel);
void onSpeakingUsersChanged(List<Integer> ids);
void onChannelEnded();
void onSelfLeft();
}

private class RtcEngineEventHandler extends IRtcEngineEventHandler{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package me.grishka.houseclub.fragments;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Outline;
Expand All @@ -20,7 +18,6 @@
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

Expand All @@ -33,16 +30,20 @@
import me.grishka.appkit.imageloader.ImageLoaderViewHolder;
import me.grishka.appkit.utils.BindableViewHolder;
import me.grishka.appkit.utils.V;
import me.grishka.houseclub.DataProvider;
import me.grishka.houseclub.MainActivity;
import me.grishka.houseclub.R;
import me.grishka.houseclub.VoiceService;
import me.grishka.houseclub.api.ClubhouseSession;
import me.grishka.houseclub.api.methods.GetChannels;
import me.grishka.houseclub.api.model.Channel;
import me.grishka.houseclub.api.model.ChannelUser;

public class HomeFragment extends BaseRecyclerFragment<Channel>{

private ChannelAdapter adapter;
private View returnView;

private ViewOutlineProvider roundedCornersOutline=new ViewOutlineProvider(){
@Override
public void getOutline(View view, Outline outline){
Expand Down Expand Up @@ -84,8 +85,86 @@ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull R
}
});
getToolbar().setElevation(0);

// add Return to "channel" bar to bottom of toolbar
LayoutInflater inflater = LayoutInflater.from(getActivity());
View returnBar = inflater.inflate(R.layout.return_row_bar, null);
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space indents :'(


((ViewGroup) getView()).addView(returnBar, 1, layoutParams);
returnBar.setOnClickListener((it) -> {
Channel channel = DataProvider.getCachedChannel();
if (channel != null)
((MainActivity) getActivity()).joinChannel(channel);
});
returnView = getView().findViewById(R.id.return_container);
VoiceService.addListener(channelEventListener);
}

private final VoiceService.ChannelEventListener channelEventListener = new VoiceService.ChannelEventListener() {
@Override
public void onUserMuteChanged(int id, boolean muted) {
}

@Override
public void onUserJoined(ChannelUser user) {
}

@Override
public void onUserLeft(int id) {
}

@Override
public void onCanSpeak(String inviterName, int inviterID) {
}

@Override
public void onChannelUpdated(Channel channel) {
checkReturnBar();
}

@Override
public void onSpeakingUsersChanged(List<Integer> ids) {
}

@Override
public void onChannelEnded() {
hideReturnBar();
}

@Override
public void onSelfLeft() {
hideReturnBar();
}

};

private void hideReturnBar() {
if (returnView != null) {
returnView.setVisibility(View.GONE);
}
}

private void checkReturnBar() {
try {
Channel channel = DataProvider.getCachedChannel();
if (returnView != null) {
if (channel != null) {
TextView title = returnView.findViewById(R.id.return_title);
if (title != null) {
String channelNameShortened = channel.topic.substring(0, Math.min(channel.topic.length(), 16));
if (channelNameShortened.length() < channel.topic.length())
channelNameShortened += "...";
title.setText(getString(R.string.return_to_channel, channelNameShortened));
}
returnView.setVisibility(View.VISIBLE);
} else returnView.setVisibility(View.GONE);
}
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void onConfigurationChanged(Configuration newConfig){
super.onConfigurationChanged(newConfig);
Expand All @@ -100,7 +179,6 @@ protected RecyclerView.Adapter getAdapter(){
}
return adapter;
}

@Override
public boolean wantsLightNavigationBar(){
return true;
Expand Down Expand Up @@ -195,7 +273,6 @@ public ChannelViewHolder(){

itemView.setOutlineProvider(roundedCornersOutline);
itemView.setClipToOutline(true);
itemView.setElevation(V.dp(2));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

itemView.setOnClickListener(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ public void onChannelEnded(){
Nav.finish(this);
}

@Override
public void onSelfLeft() { }

private class UserListAdapter extends RecyclerView.Adapter<UserViewHolder> implements ImageLoaderRecyclerAdapter{

private List<ChannelUser> users;
Expand Down
32 changes: 32 additions & 0 deletions Houseclub/src/main/res/drawable/background_channel_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<ripple android:color="?android:attr/colorControlHighlight">
<item>
<shape android:id="@android:id/mask">
<solid android:color="#fff" />

<padding
android:bottom="0dp"
android:left="8dp"
android:right="8dp"
android:top="0dp" />
<corners
android:radius="25dp" />
</shape>
</item>
</ripple>
</item>
<item>
<shape android:id="@android:id/mask">
<solid android:color="#aaa" />
<padding
android:bottom="0dp"
android:left="8dp"
android:right="8dp"
android:top="0dp" />
<corners android:radius="25dp" />
</shape>
</item>

</transition>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change this at all?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit wasn't related to the "return bar" feature. The idea was to make channel item more rounded towards official UI.

32 changes: 32 additions & 0 deletions Houseclub/src/main/res/drawable/button_blue_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<ripple android:color="?android:attr/colorControlHighlight">
<item>
<shape android:id="@android:id/mask">
<solid android:color="@color/blue" />

<padding
android:bottom="0dp"
android:left="8dp"
android:right="8dp"
android:top="0dp" />
<corners
android:radius="28dp" />
</shape>
</item>
</ripple>
</item>
<item>
<shape android:id="@android:id/mask">
<solid android:color="#494E57" />
<padding
android:bottom="0dp"
android:left="8dp"
android:right="8dp"
android:top="0dp" />
<corners android:radius="28dp" />
</shape>
</item>

</transition>
3 changes: 1 addition & 2 deletions Houseclub/src/main/res/layout/channel_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:padding="16dp"
android:background="#FFF"
android:foreground="?android:selectableItemBackground">
android:background="@drawable/background_channel_item">

<TextView
android:id="@+id/topic"
Expand Down
27 changes: 27 additions & 0 deletions Houseclub/src/main/res/layout/return_row_bar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/return_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#e2e2e2"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:orientation="vertical"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:visibility="gone"
tools:visibility="visible">

<TextView
android:id="@+id/return_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:gravity="center"
android:text="Return to channel" />

</LinearLayout>
1 change: 1 addition & 0 deletions Houseclub/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@
<string name="event_expired">This event has already ended</string>
<string name="log_in_to_activate">Please log in again to activate your account.</string>
<string name="ok">OK</string>
<string name="return_to_channel">Return to %1$s</string>
</resources>
2 changes: 2 additions & 0 deletions Houseclub/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<item name="android:colorAccent">@color/blue</item>
<item name="android:stateListAnimator">@null</item>
<item name="android:textAllCaps">false</item>
<item name="android:minHeight">38dp</item>
<item name="android:background">@drawable/button_blue_background</item>
</style>

<style name="Widget.Button.Grey" parent="android:Widget.Material.Button">
Expand Down