|
5 | 5 | import java.util.Arrays; |
6 | 6 | import java.util.HashMap; |
7 | 7 | import java.util.List; |
8 | | -import java.util.Locale; |
9 | 8 | import java.util.concurrent.Callable; |
10 | 9 | import java.util.ArrayList; |
11 | | -import java.util.concurrent.TimeUnit; |
12 | 10 |
|
13 | 11 | import android.animation.Animator; |
14 | 12 | import android.annotation.SuppressLint; |
|
58 | 56 | import android.text.TextUtils; |
59 | 57 | import android.text.TextWatcher; |
60 | 58 | import android.util.Log; |
| 59 | +import android.util.TypedValue; |
61 | 60 | import android.view.Gravity; |
62 | 61 | import android.view.Menu; |
63 | 62 | import android.view.MenuItem; |
@@ -168,6 +167,8 @@ public class ZulipActivity extends BaseActivity implements |
168 | 167 | private AsyncGetEvents event_poll; |
169 | 168 | private Handler statusUpdateHandler; |
170 | 169 | private Runnable statusUpdateRunnable; |
| 170 | + |
| 171 | + private int mToolbarHeightInPx; |
171 | 172 | private MessageListFragment narrowedList; |
172 | 173 | private MessageListFragment homeList; |
173 | 174 | private AutoCompleteTextView streamActv; |
@@ -2057,14 +2058,17 @@ public void onNewMessages(Message[] messages) { |
2057 | 2058 | } |
2058 | 2059 |
|
2059 | 2060 | Snackbar snackbar; |
2060 | | - |
| 2061 | + CoordinatorLayout.LayoutParams snackBarParams; |
2061 | 2062 | private void setupSnackBar() { |
2062 | 2063 | final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout); |
2063 | 2064 | snackbar = Snackbar.make(coordinatorLayout, "", Snackbar.LENGTH_LONG); |
2064 | 2065 | View v = snackbar.getView(); |
2065 | | - CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) v.getLayoutParams(); |
2066 | | - params.gravity = Gravity.TOP; |
2067 | | - v.setLayoutParams(params); |
| 2066 | + snackBarParams = (CoordinatorLayout.LayoutParams) v.getLayoutParams(); |
| 2067 | + snackBarParams.gravity = Gravity.TOP; |
| 2068 | + v.setLayoutParams(snackBarParams); |
| 2069 | + TypedValue tv = new TypedValue(); |
| 2070 | + if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) |
| 2071 | + mToolbarHeightInPx = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); |
2068 | 2072 | } |
2069 | 2073 |
|
2070 | 2074 | NarrowFilter narrowFilter; |
@@ -2112,6 +2116,11 @@ public void onClick(View view) { |
2112 | 2116 | } |
2113 | 2117 | }); |
2114 | 2118 | } |
| 2119 | + if (appBarLayout.getVisibility() == View.GONE) { |
| 2120 | + snackBarParams.setMargins(0, 0, 0, 0); |
| 2121 | + } else { |
| 2122 | + snackBarParams.setMargins(0, mToolbarHeightInPx, 0, 0); |
| 2123 | + } |
2115 | 2124 | snackbar.show(); |
2116 | 2125 | } |
2117 | 2126 |
|
|
0 commit comments