From af187550c59233c0cda424ed805875ac4e279411 Mon Sep 17 00:00:00 2001 From: Somethingweirdhere Date: Thu, 14 Jun 2018 01:55:55 +0200 Subject: [PATCH] Nav drawer now moves behind the status bar and the colors also work correctly. --- .../java/org/schabi/newpipe/MainActivity.java | 13 +++++++ .../newpipe/fragments/MainFragment.java | 2 ++ .../main/res/values-v21/styles_services.xml | 34 +++++++++++++++++++ app/src/main/res/values/colors_services.xml | 12 ++++--- app/src/main/res/values/styles_services.xml | 10 +++--- 5 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 app/src/main/res/values-v21/styles_services.xml diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 21b701e7e..5167e5670 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -23,14 +23,19 @@ package org.schabi.newpipe; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; +import android.content.res.Resources; +import android.graphics.Color; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.preference.PreferenceManager; +import android.support.annotation.ColorInt; import android.support.annotation.NonNull; import android.support.design.widget.NavigationView; import android.support.v4.app.Fragment; +import android.support.v4.content.ContextCompat; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBar; @@ -38,11 +43,14 @@ import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; +import android.util.TypedValue; import android.view.Gravity; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; +import android.view.Window; +import android.view.WindowManager; import android.widget.Button; import android.widget.ImageButton; import android.widget.TextView; @@ -86,6 +94,11 @@ public class MainActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + Window w = getWindow(); + w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + } + if (getSupportFragmentManager() != null && getSupportFragmentManager().getBackStackEntryCount() == 0) { initFragments(); } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java index e796396f1..b7783edce 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java @@ -2,6 +2,7 @@ package org.schabi.newpipe.fragments; import android.content.Context; import android.content.SharedPreferences; +import android.graphics.Color; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -92,6 +93,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); prefs.registerOnSharedPreferenceChangeListener(listener); + return inflater.inflate(R.layout.fragment_main, container, false); } diff --git a/app/src/main/res/values-v21/styles_services.xml b/app/src/main/res/values-v21/styles_services.xml new file mode 100644 index 000000000..e3d6c24e2 --- /dev/null +++ b/app/src/main/res/values-v21/styles_services.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors_services.xml b/app/src/main/res/values/colors_services.xml index 36a292453..761b721d0 100644 --- a/app/src/main/res/values/colors_services.xml +++ b/app/src/main/res/values/colors_services.xml @@ -2,20 +2,24 @@ #e53935 - #d32f2f + #992722 #000000 + #ff4336 #CD322E - #BC211D + #992722 #FFFFFF + #ff4336 #f57c00 - #ef6c00 + #995700 #000000 + #ff9100 #f57c00 - #ef6c00 + #995700 #FFFFFF + #ff9100 \ No newline at end of file diff --git a/app/src/main/res/values/styles_services.xml b/app/src/main/res/values/styles_services.xml index 6ed8c29e9..7ca9dacde 100644 --- a/app/src/main/res/values/styles_services.xml +++ b/app/src/main/res/values/styles_services.xml @@ -1,12 +1,14 @@ - - +