Skip to content

Commit

Permalink
Fix Customize Reactions shadow.
Browse files Browse the repository at this point in the history
  • Loading branch information
cody-signal authored Jun 29, 2021
1 parent 6e7022a commit e3870f5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -56,6 +58,7 @@ public final class ReactWithAnyEmojiBottomSheetDialogFragment extends BottomShee
private static final String ARG_MESSAGE_ID = "arg_message_id";
private static final String ARG_IS_MMS = "arg_is_mms";
private static final String ARG_START_PAGE = "arg_start_page";
private static final String ARG_SHADOWS = "arg_shadows";
private static final String ARG_RECENT_KEY = "arg_recent_key";
private static final String ARG_EDIT = "arg_edit";

Expand Down Expand Up @@ -102,6 +105,7 @@ public static DialogFragment createForEditReactions() {
args.putLong(ARG_MESSAGE_ID, -1);
args.putBoolean(ARG_IS_MMS, false);
args.putInt(ARG_START_PAGE, -1);
args.putBoolean(ARG_SHADOWS, false);
args.putString(ARG_RECENT_KEY, REACTION_STORAGE_KEY);
fragment.setArguments(args);

Expand Down Expand Up @@ -151,6 +155,14 @@ public void onStateChanged(@NonNull View bottomSheet, int newState) {
public void onSlide(@NonNull View bottomSheet, float slideOffset) { }
});

boolean shadows = requireArguments().getBoolean(ARG_SHADOWS, true);
if (!shadows) {
Window window = dialog.getWindow();
if (window != null) {
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
}
}

return dialog;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package org.thoughtcrime.securesms.reactions.edit

import android.os.Bundle
import android.view.View
import androidx.core.content.ContextCompat
import org.thoughtcrime.securesms.PassphraseRequiredActivity
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme
import org.thoughtcrime.securesms.util.DynamicTheme
import org.thoughtcrime.securesms.util.WindowUtil

class EditReactionsActivity : PassphraseRequiredActivity() {

Expand All @@ -13,6 +17,10 @@ class EditReactionsActivity : PassphraseRequiredActivity() {
super.onCreate(savedInstanceState, ready)
theme.onCreate(this)

@Suppress("DEPRECATION")
findViewById<View>(android.R.id.content).systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
WindowUtil.setStatusBarColor(window, ContextCompat.getColor(this, R.color.transparent))

if (savedInstanceState == null) {
supportFragmentManager.beginTransaction()
.replace(android.R.id.content, EditReactionsFragment())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package org.thoughtcrime.securesms.reactions.edit

import android.animation.ObjectAnimator
import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import androidx.appcompat.widget.Toolbar
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.view.ViewCompat
import androidx.lifecycle.ViewModelProviders
import androidx.transition.ChangeBounds
import androidx.transition.Transition
Expand Down Expand Up @@ -44,6 +46,7 @@ class EditReactionsFragment : LoggingFragment(R.layout.edit_reactions_fragment),
toolbar.setNavigationOnClickListener {
requireActivity().onBackPressed()
}
configureToolbar()

reactionViews = listOf(
view.findViewById(R.id.reaction_1),
Expand Down Expand Up @@ -86,6 +89,23 @@ class EditReactionsFragment : LoggingFragment(R.layout.edit_reactions_fragment),
view.setOnClickListener { viewModel.setSelection(EditReactionsViewModel.NO_SELECTION) }
}

private fun configureToolbar() {
if (Build.VERSION.SDK_INT == 19) {
updateToolbarTopMargin(ViewUtil.getStatusBarHeight(toolbar))
} else {
ViewCompat.setOnApplyWindowInsetsListener(toolbar) { _, insets ->
updateToolbarTopMargin(insets.systemWindowInsetTop)
insets
}
}
}

private fun updateToolbarTopMargin(topMargin: Int) {
val layoutParams = toolbar.layoutParams as ConstraintLayout.LayoutParams
layoutParams.topMargin = topMargin
toolbar.layoutParams = layoutParams
}

private fun select(emojiImageView: EmojiImageView) {
val set = ConstraintSet()
set.clone(scrubber)
Expand Down

0 comments on commit e3870f5

Please sign in to comment.