mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 12:49:02 +00:00
support translucent navbar in mainactivity
This commit is contained in:
parent
158acea5a1
commit
c3ade8b827
16 changed files with 160 additions and 106 deletions
|
|
@ -31,6 +31,7 @@
|
|||
<activity
|
||||
android:name=".ui.activities.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme.NoActionBar.Transparent"
|
||||
android:windowSoftInputMode="stateHidden|adjustPan"
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
|
|
|
|||
|
|
@ -65,13 +65,13 @@ dependencies {
|
|||
apt 'com.google.dagger:dagger-compiler:2.8'
|
||||
provided 'org.glassfish:javax.annotation:10.0-b28'
|
||||
//App Compatibility and Material Design
|
||||
compile('com.mikepenz:materialdrawer:5.3.6@aar') {
|
||||
compile('com.mikepenz:materialdrawer:5.8.3@aar') {
|
||||
transitive = true
|
||||
}
|
||||
compile 'com.android.support:appcompat-v7:25.3.0'
|
||||
compile 'com.android.support:design:25.3.0'
|
||||
compile 'com.android.support:recyclerview-v7:25.3.0'
|
||||
compile 'com.android.support:preference-v14:25.3.0'
|
||||
compile 'com.android.support:appcompat-v7:25.3.1'
|
||||
compile 'com.android.support:design:25.3.1'
|
||||
compile 'com.android.support:recyclerview-v7:25.3.1'
|
||||
compile 'com.android.support:preference-v14:25.3.1'
|
||||
compile 'com.android.support:multidex:1.0.1'
|
||||
|
||||
//QR Code
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 76 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 29 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 99 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 165 KiB |
|
|
@ -1,108 +1,96 @@
|
|||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/overlayFrameLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:elevation="0dp"
|
||||
tools:context=".ui.activities.MainActivity"
|
||||
android:id="@+id/overlayFrameLayout">
|
||||
<android.support.v4.widget.DrawerLayout
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:gravity="center">
|
||||
android:fitsSystemWindows="false">
|
||||
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
android:id="@+id/main_content"
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:elevation="0dp"
|
||||
tools:context=".ui.activities.MainActivity">
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
<android.support.design.widget.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="false">
|
||||
app:titleEnabled="false"
|
||||
app:contentScrim="?attr/colorPrimary"
|
||||
app:expandedTitleMarginEnd="?attr/actionBarSize"
|
||||
app:expandedTitleMarginStart="0dp"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
|
||||
<android.support.design.widget.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
<include
|
||||
android:id="@+id/avatar_with_bars"
|
||||
layout="@layout/avatar_with_bars"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:titleEnabled="false"
|
||||
app:contentScrim="?attr/colorPrimary"
|
||||
app:expandedTitleMarginEnd="?attr/actionBarSize"
|
||||
app:expandedTitleMarginStart="0dp"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
android:layout_marginTop="?attr/actionBarSize"
|
||||
app:layout_collapseMode="parallax" />
|
||||
|
||||
<include
|
||||
android:id="@+id/avatar_with_bars"
|
||||
layout="@layout/avatar_with_bars"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="?attr/actionBarSize"
|
||||
app:layout_collapseMode="parallax" />
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:theme="@style/Toolbar"
|
||||
app:layout_collapseMode="pin"
|
||||
app:popupTheme="@style/Theme.AppCompat.Light" />
|
||||
</android.support.design.widget.CollapsingToolbarLayout>
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/detail_tabs"
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@color/brand_200"
|
||||
android:elevation="0dp"
|
||||
android:fillViewport="false"
|
||||
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
app:layout_anchor="@+id/collapsing_toolbar"
|
||||
app:layout_anchorGravity="bottom"
|
||||
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:theme="@style/Toolbar"
|
||||
app:layout_collapseMode="pin"
|
||||
app:tabGravity="fill"
|
||||
app:tabIndicatorColor="@android:color/white"
|
||||
app:tabMode="fixed" />
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
app:popupTheme="@style/Theme.AppCompat.Light"
|
||||
android:fitsSystemWindows="true"/>
|
||||
</android.support.design.widget.CollapsingToolbarLayout>
|
||||
|
||||
<com.roughike.bottombar.BottomBar
|
||||
android:id="@+id/bottom_navigation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_gravity="bottom|center"
|
||||
android:background="@color/brand_100"
|
||||
app:bb_tabXmlResource="@xml/main_menu_tasks"
|
||||
app:bb_inActiveTabColor="@color/brand_500"
|
||||
app:bb_activeTabColor="@color/white"
|
||||
/>
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/detail_tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@color/brand_200"
|
||||
android:elevation="0dp"
|
||||
android:fillViewport="false"
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/floating_menu_wrapper"
|
||||
app:layout_behavior="com.habitrpg.android.habitica.ui.helpers.FloatingActionMenuBehavior"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="44dp"
|
||||
android:layout_marginRight="8dp"
|
||||
/>
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
app:layout_anchor="@+id/collapsing_toolbar"
|
||||
app:layout_anchorGravity="bottom"
|
||||
|
||||
app:layout_collapseMode="pin"
|
||||
app:tabGravity="fill"
|
||||
app:tabIndicatorColor="@android:color/white"
|
||||
app:tabMode="fixed"
|
||||
android:fitsSystemWindows="true" />
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
</FrameLayout>
|
||||
<com.roughike.bottombar.BottomBar
|
||||
android:id="@+id/bottom_navigation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_gravity="bottom|center"
|
||||
android:background="@color/brand_100"
|
||||
app:bb_tabXmlResource="@xml/main_menu_tasks"
|
||||
app:bb_inActiveTabColor="@color/brand_500"
|
||||
app:bb_activeTabColor="@color/white"
|
||||
app:bb_behavior="underNavbar"
|
||||
/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/floating_menu_wrapper"
|
||||
app:layout_behavior="com.habitrpg.android.habitica.ui.helpers.FloatingActionMenuBehavior"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="44dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:fitsSystemWindows="true"
|
||||
/>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,10 @@
|
|||
android:layout_height="match_parent"
|
||||
android:scrollbarSize="3dp"
|
||||
android:scrollbarThumbVertical="@color/md_grey_500"
|
||||
android:scrollbars="vertical" />
|
||||
android:scrollbars="vertical"
|
||||
android:fitsSystemWindows="true"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="?attr/actionBarSize"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
<FrameLayout
|
||||
android:id="@+id/coordinatorLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
|
@ -16,12 +16,15 @@
|
|||
android:layout_height="match_parent"
|
||||
android:scrollbarSize="3dp"
|
||||
android:scrollbarThumbVertical="@color/md_grey_500"
|
||||
android:scrollbars="vertical" />
|
||||
android:scrollbars="vertical"
|
||||
android:fitsSystemWindows="true"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="?attr/actionBarSize" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/empty_view"
|
||||
style="@style/EmptyView"/>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
</FrameLayout>
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
|
|
|
|||
6
Habitica/res/layout/material_drawer.xml
Normal file
6
Habitica/res/layout/material_drawer.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/material_drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="false" />
|
||||
|
|
@ -14,10 +14,17 @@
|
|||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
<item name="android:windowTranslucentNavigation">true</item>
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="android:windowTranslucentStatus">true</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="windowActionBarOverlay">true</item>
|
||||
</style>
|
||||
<style name="AppTheme.NoActionBar.Transparent">
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
<item name="android:windowTranslucentNavigation">true</item>
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="android:windowTranslucentStatus">true</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
@ -116,6 +116,7 @@
|
|||
<color name="white_75_alpha">#bfffffff</color>
|
||||
<color name="white_50_alpha">#7fffffff</color>
|
||||
<color name="white_15_alpha">#26ffffff</color>
|
||||
<color name="black_10_alpha">#16000000</color>
|
||||
<color name="black_20_alpha">#33000000</color>
|
||||
<color name="light_gray_bg">#F6F4F8</color>
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import android.content.pm.PackageInfo;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.database.sqlite.SQLiteDoneException;
|
||||
import android.databinding.DataBindingUtil;
|
||||
import android.graphics.Bitmap;
|
||||
|
|
@ -18,10 +19,15 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.CoordinatorLayout;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.view.OnApplyWindowInsetsListener;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v4.view.WindowInsetsCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
|
@ -29,6 +35,8 @@ import android.util.Log;
|
|||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
|
|
@ -201,7 +209,7 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
@BindView(R.id.avatar_with_bars)
|
||||
View avatar_with_bars;
|
||||
@BindView(R.id.overlayFrameLayout)
|
||||
FrameLayout overlayFrameLayout;
|
||||
CoordinatorLayout overlayFrameLayout;
|
||||
PushNotificationManager pushNotificationManager;
|
||||
// region UseCases
|
||||
|
||||
|
|
@ -302,9 +310,36 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
drawer.setSelectionAtPosition(1, false);
|
||||
sideAvatarView = new AvatarView(this, true, false, false);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
Window window = getWindow();
|
||||
window.setStatusBarColor(ContextCompat.getColor(this, R.color.black_10_alpha));
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
toolbar.setPadding(0, getStatusBarHeight(), 0, 0);
|
||||
avatar_with_bars.setPadding(0, getStatusBarHeight(), 0, 0);
|
||||
floatingMenuWrapper.setPadding(0, 0, 0, getNavigationBarHeight());
|
||||
}
|
||||
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
public int getStatusBarHeight() {
|
||||
int result = 0;
|
||||
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
result = getResources().getDimensionPixelSize(resourceId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getNavigationBarHeight() {
|
||||
int result = 0;
|
||||
int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
result = getResources().getDimensionPixelSize(resourceId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void injectActivity(AppComponent component) {
|
||||
component.inject(this);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.WindowInsets;
|
||||
|
||||
//http://stackoverflow.com/a/27801394/1315039
|
||||
public class RecyclerViewEmptySupport extends RecyclerView {
|
||||
|
|
@ -37,6 +38,11 @@ public class RecyclerViewEmptySupport extends RecyclerView {
|
|||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
|
||||
return super.onApplyWindowInsets(insets);
|
||||
}
|
||||
|
||||
void checkIfEmpty() {
|
||||
if (emptyView != null && getAdapter() != null) {
|
||||
final boolean emptyViewVisible = getAdapter().getItemCount() == 0;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,8 @@ public class MainDrawerBuilder {
|
|||
|
||||
public static DrawerBuilder CreateDefaultBuilderSettings(final MainActivity activity, SharedPreferences sharedPreferences, Toolbar toolbar, final AccountHeader accountHeader) {
|
||||
DrawerBuilder builder = new DrawerBuilder()
|
||||
.withActivity(activity);
|
||||
.withActivity(activity)
|
||||
.withFullscreen(true);
|
||||
|
||||
if (toolbar != null) {
|
||||
builder.withToolbar(toolbar);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import android.support.v7.widget.RecyclerView;
|
|||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by mikepenz on 03.02.15.
|
||||
*/
|
||||
|
|
@ -75,29 +77,30 @@ public class SectionIconDrawerItem extends AbstractDrawerItem<SectionIconDrawerI
|
|||
}
|
||||
|
||||
@Override
|
||||
public void bindView(ViewHolder viewHolder) {
|
||||
Context ctx = viewHolder.itemView.getContext();
|
||||
public void bindView(ViewHolder holder, List<Object> payloads) {
|
||||
super.bindView(holder, payloads);
|
||||
Context ctx = holder.itemView.getContext();
|
||||
|
||||
//set the identifier from the drawerItem here. It can be used to run tests
|
||||
viewHolder.itemView.setId(hashCode());
|
||||
holder.itemView.setId(hashCode());
|
||||
|
||||
//define this item to be not clickable nor enabled
|
||||
viewHolder.view.setClickable(false);
|
||||
viewHolder.view.setEnabled(false);
|
||||
holder.view.setClickable(false);
|
||||
holder.view.setEnabled(false);
|
||||
|
||||
//define the text color
|
||||
viewHolder.name.setTextColor(ContextCompat.getColor(ctx, R.color.white));
|
||||
holder.name.setTextColor(ContextCompat.getColor(ctx, R.color.white));
|
||||
|
||||
//set the text for the name
|
||||
StringHolder.applyTo(this.getName(), viewHolder.name);
|
||||
StringHolder.applyTo(this.getName(), holder.name);
|
||||
|
||||
//define the typeface for our textViews
|
||||
if (getTypeface() != null) {
|
||||
viewHolder.name.setTypeface(getTypeface());
|
||||
holder.name.setTypeface(getTypeface());
|
||||
}
|
||||
|
||||
//call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required)
|
||||
onPostBindView(this, viewHolder.itemView);
|
||||
onPostBindView(this, holder.itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in a new issue