Make navbar transparent in the MainUI
Signed-off-by: Joey <joey@lineageos.org>
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 802b116..10d095a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -30,6 +30,7 @@
<activity
android:name=".ui.MainActivity"
+ android:theme="@style/AppTheme.TranslucentNav"
android:excludeFromRecents="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
diff --git a/app/src/main/java/org/lineageos/backgrounds/adapters/WallsAdapter.java b/app/src/main/java/org/lineageos/backgrounds/adapters/WallsAdapter.java
index a4d0b6d..95669d2 100644
--- a/app/src/main/java/org/lineageos/backgrounds/adapters/WallsAdapter.java
+++ b/app/src/main/java/org/lineageos/backgrounds/adapters/WallsAdapter.java
@@ -60,8 +60,14 @@
@Override
public void onBindViewHolder(final @NonNull WallpaperHolder holder, final int position) {
+ /*
+ * + 2 is for the last 2 items of the list as the one
+ * before the last might happen to end "below" the real
+ * last one
+ */
+ final boolean isLast = position + 2 == mData.size();
final WallpaperBundle bundle = mData.get(position);
- holder.bind(bundle);
+ holder.bind(bundle, isLast);
}
@Override
diff --git a/app/src/main/java/org/lineageos/backgrounds/holders/UserHolder.java b/app/src/main/java/org/lineageos/backgrounds/holders/UserHolder.java
index 86d906e..e5e8fb3 100644
--- a/app/src/main/java/org/lineageos/backgrounds/holders/UserHolder.java
+++ b/app/src/main/java/org/lineageos/backgrounds/holders/UserHolder.java
@@ -30,8 +30,9 @@
}
@Override
- public void bind(@NonNull final WallpaperBundle bundle) {
- super.bind(bundle);
+ public void bind(@NonNull final WallpaperBundle bundle,
+ final boolean isLast) {
+ super.bind(bundle, isLast);
itemView.setOnClickListener(v -> callback.onWallpaperSelected(previewView, null));
}
diff --git a/app/src/main/java/org/lineageos/backgrounds/holders/WallpaperHolder.java b/app/src/main/java/org/lineageos/backgrounds/holders/WallpaperHolder.java
index feb86e2..8666c0d 100644
--- a/app/src/main/java/org/lineageos/backgrounds/holders/WallpaperHolder.java
+++ b/app/src/main/java/org/lineageos/backgrounds/holders/WallpaperHolder.java
@@ -26,6 +26,7 @@
import org.lineageos.backgrounds.R;
import org.lineageos.backgrounds.bundle.WallpaperBundle;
import org.lineageos.backgrounds.ui.SelectionInterface;
+import org.lineageos.backgrounds.util.UiUtils;
public class WallpaperHolder extends RecyclerView.ViewHolder {
@NonNull
@@ -39,7 +40,8 @@
this.callback = callback;
}
- public void bind(@NonNull WallpaperBundle bundle) {
+ public void bind(@NonNull final WallpaperBundle bundle,
+ final boolean isLast) {
previewView = itemView.findViewById(R.id.item_wallpaper_preview);
TextView nameView = itemView.findViewById(R.id.item_wallpaper_name);
@@ -55,5 +57,9 @@
nameView.setText(name);
itemView.setOnClickListener((v) -> callback.onWallpaperSelected(previewView, bundle));
+
+ // Update margins
+ UiUtils.setMarginForListItem(itemView.getResources(), itemView,
+ R.dimen.item_margin_vertical, isLast);
}
}
diff --git a/app/src/main/java/org/lineageos/backgrounds/ui/MainActivity.java b/app/src/main/java/org/lineageos/backgrounds/ui/MainActivity.java
index f2f44ed..e3032e9 100644
--- a/app/src/main/java/org/lineageos/backgrounds/ui/MainActivity.java
+++ b/app/src/main/java/org/lineageos/backgrounds/ui/MainActivity.java
@@ -38,6 +38,7 @@
import org.lineageos.backgrounds.bundle.WallpaperType;
import org.lineageos.backgrounds.factory.UserWallpaperFactory;
import org.lineageos.backgrounds.task.FetchDataTask;
+import org.lineageos.backgrounds.util.UiUtils;
import java.util.List;
@@ -104,6 +105,8 @@
}
private void setupRecyclerView() {
+ //UiUtils.addSystemUiPadding(getResources(), mContentRecyclerView);
+
mAdapter = new WallsAdapter(this);
int numOfColumns = getResources().getInteger(R.integer.main_list_columns);
diff --git a/app/src/main/java/org/lineageos/backgrounds/util/UiUtils.java b/app/src/main/java/org/lineageos/backgrounds/util/UiUtils.java
index b4212f9..7114abd 100644
--- a/app/src/main/java/org/lineageos/backgrounds/util/UiUtils.java
+++ b/app/src/main/java/org/lineageos/backgrounds/util/UiUtils.java
@@ -15,13 +15,18 @@
*/
package org.lineageos.backgrounds.util;
+import android.content.res.Resources;
import android.os.Build;
import android.view.View;
+import android.view.ViewGroup;
import android.view.Window;
import androidx.annotation.ColorInt;
+import androidx.annotation.DimenRes;
import androidx.annotation.NonNull;
+import org.lineageos.backgrounds.R;
+
public final class UiUtils {
private UiUtils() {
@@ -47,4 +52,26 @@
window.getDecorView().setSystemUiVisibility(flags);
}
+
+ public static void setMarginForListItem(@NonNull final Resources resources,
+ @NonNull final View view,
+ @DimenRes final int baseRes,
+ final boolean addNavBarMargin) {
+ final ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams)
+ view.getLayoutParams();
+
+ params.bottomMargin = resources.getDimensionPixelSize(baseRes);
+
+ // Increase for eventual navBar
+ if (addNavBarMargin) {
+ final int navBarSizeId = resources.getIdentifier("navigation_bar_height",
+ "dimen", "android");
+ if (navBarSizeId > 0) {
+ final int navBarSize = resources.getDimensionPixelSize(navBarSizeId);
+ params.bottomMargin += navBarSize;
+ }
+ }
+
+ view.setLayoutParams(params);
+ }
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 9c7ba72..f42bc8a 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -14,6 +14,7 @@
limitations under the License.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -38,7 +39,10 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/main_recyclerview"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="@dimen/main_list_margin_left"
+ android:layout_marginTop="24dp"
android:paddingHorizontal="4dp"
- android:visibility="gone" />
+ android:visibility="gone"
+ tools:ignore="RtlHardcoded" />
</merge>
diff --git a/app/src/main/res/layout/item_wallpaper.xml b/app/src/main/res/layout/item_wallpaper.xml
index 95a9bac..2347586 100644
--- a/app/src/main/res/layout/item_wallpaper.xml
+++ b/app/src/main/res/layout/item_wallpaper.xml
@@ -17,8 +17,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginHorizontal="4dp"
- android:layout_marginVertical="8dp"
+ android:layout_marginHorizontal="@dimen/item_margin_horizontal"
+ android:layout_marginVertical="@dimen/item_margin_vertical"
android:background="@drawable/bg_wallpaper_item"
android:clickable="true"
android:elevation="4dp"
diff --git a/app/src/main/res/values-land/dimens.xml b/app/src/main/res/values-land/dimens.xml
new file mode 100644
index 0000000..ca1b186
--- /dev/null
+++ b/app/src/main/res/values-land/dimens.xml
@@ -0,0 +1,18 @@
+<!--
+ Copyright (C) 2019 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<resources>
+ <dimen name="main_list_margin_left">48dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values-sw600dp-land/dimens.xml b/app/src/main/res/values-sw600dp-land/dimens.xml
new file mode 100644
index 0000000..cd1f74b
--- /dev/null
+++ b/app/src/main/res/values-sw600dp-land/dimens.xml
@@ -0,0 +1,18 @@
+<!--
+ Copyright (C) 2019 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<resources>
+ <dimen name="main_list_margin_left">0dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values-sw600dp/dimens.xml b/app/src/main/res/values-sw600dp/dimens.xml
new file mode 100644
index 0000000..cd1f74b
--- /dev/null
+++ b/app/src/main/res/values-sw600dp/dimens.xml
@@ -0,0 +1,18 @@
+<!--
+ Copyright (C) 2019 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<resources>
+ <dimen name="main_list_margin_left">0dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..dff5e2c
--- /dev/null
+++ b/app/src/main/res/values/dimens.xml
@@ -0,0 +1,21 @@
+<!--
+ Copyright (C) 2019 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<resources>
+ <dimen name="item_margin_vertical">8dp</dimen>
+ <dimen name="item_margin_horizontal">4dp</dimen>
+
+ <dimen name="main_list_margin_left">0dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 603a450..8d83e9d 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -20,13 +20,16 @@
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="isLightTheme">@bool/isLight</item>
- <item name="android:navigationBarColor">@color/navigationBar_color</item>
- <item name="android:navigationBarDividerColor">@color/navigationBar_divider</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:windowLightStatusBar">@bool/isLight</item>
<item name="android:windowLightNavigationBar">@bool/isLight</item>
</style>
+ <style name="AppTheme.TranslucentNav">
+ <item name="android:windowTranslucentNavigation">true</item>
+ <item name="android:windowTranslucentStatus">false</item>
+ </style>
+
<style name="AppTheme.ApplyButton">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">match_parent</item>