Skip to content

Commit

Permalink
Collapse title into toolbar on scroll in ManageGroupFragment.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-signal authored and greyson-signal committed May 29, 2020
1 parent 12b1232 commit 090c400
Show file tree
Hide file tree
Showing 4 changed files with 339 additions and 329 deletions.
Expand Up @@ -5,7 +5,6 @@
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;

import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity;
import org.thoughtcrime.securesms.R;
Expand Down Expand Up @@ -39,21 +38,11 @@ protected void onCreate(Bundle savedInstanceState, boolean ready) {
.replace(R.id.container, ManageGroupFragment.newInstance(getIntent().getStringExtra(GROUP_ID)))
.commitNow();
}
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//noinspection ConstantConditions
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

@Override
public void onResume() {
super.onResume();
dynamicTheme.onResume(this);
}

@Override
public boolean onSupportNavigateUp() {
onBackPressed();
return true;
}
}
Expand Up @@ -16,6 +16,7 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.ViewCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
Expand Down Expand Up @@ -62,7 +63,7 @@ public class ManageGroupFragment extends Fragment {
private ManageGroupViewModel viewModel;
private GroupMemberListView groupMemberList;
private View listPending;
private TextView groupTitle;
private Toolbar toolbar;
private TextView memberCountUnderAvatar;
private TextView memberCountAboveList;
private AvatarImageView avatar;
Expand Down Expand Up @@ -119,7 +120,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.group_manage_fragment, container, false);

avatar = view.findViewById(R.id.group_avatar);
groupTitle = view.findViewById(R.id.group_title);
toolbar = view.findViewById(R.id.toolbar);
memberCountUnderAvatar = view.findViewById(R.id.member_count);
memberCountAboveList = view.findViewById(R.id.member_count_2);
groupMemberList = view.findViewById(R.id.group_members);
Expand Down Expand Up @@ -185,7 +186,9 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {

avatar.setFallbackPhotoProvider(fallbackPhotoProvider);

viewModel.getTitle().observe(getViewLifecycleOwner(), groupTitle::setText);
toolbar.setNavigationOnClickListener(v -> requireActivity().finish());

viewModel.getTitle().observe(getViewLifecycleOwner(), toolbar::setTitle);
viewModel.getMemberCountSummary().observe(getViewLifecycleOwner(), memberCountUnderAvatar::setText);
viewModel.getFullMemberCountSummary().observe(getViewLifecycleOwner(), memberCountAboveList::setText);
viewModel.getGroupRecipient().observe(getViewLifecycleOwner(), avatar::setRecipient);
Expand Down
9 changes: 0 additions & 9 deletions app/src/main/res/layout/group_manage_activity.xml
Expand Up @@ -7,15 +7,6 @@
android:orientation="vertical"
tools:context=".groups.ui.managegroup.ManageGroupActivity">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:title=" "
app:titleTextColor="?attr/title_text_color_primary" />

<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
Expand Down

0 comments on commit 090c400

Please sign in to comment.