-
Notifications
You must be signed in to change notification settings - Fork 399
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
4f6fb5e
e8f5a5e
50f67e1
58d3520
60aac0b
51ea81f
9c92c97
bea3197
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
|
@@ -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; | ||
|
||
|
@@ -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){ | ||
|
@@ -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); | ||
|
||
((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); | ||
|
@@ -100,7 +179,6 @@ protected RecyclerView.Adapter getAdapter(){ | |
} | ||
return adapter; | ||
} | ||
|
||
@Override | ||
public boolean wantsLightNavigationBar(){ | ||
return true; | ||
|
@@ -195,7 +273,6 @@ public ChannelViewHolder(){ | |
|
||
itemView.setOutlineProvider(roundedCornersOutline); | ||
itemView.setClipToOutline(true); | ||
itemView.setElevation(V.dp(2)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? |
||
itemView.setOnClickListener(this); | ||
} | ||
|
||
|
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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you change this at all? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
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> |
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space indents :'(