From dd64bf2af712e7b8cb07dd967bb14e10d1b93181 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Thu, 26 Oct 2017 15:16:35 +0200 Subject: [PATCH] make title contain current tab --- .../java/org/schabi/newpipe/MainActivity.java | 1 - .../newpipe/fragments/BlankFragment.java | 19 +++++++++++++++++++ .../newpipe/fragments/MainFragment.java | 1 - .../list/channel/ChannelFragment.java | 2 +- .../fragments/list/kiosk/KioskFragment.java | 17 ++++++++++++++++- .../subscription/SubscriptionFragment.java | 16 ++++++++++++++++ 6 files changed, 52 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 3ff55cb76..03b856d31 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -181,7 +181,6 @@ public class MainActivity extends AppCompatActivity implements HistoryListener { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { - actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayHomeAsUpEnabled(false); } return true; diff --git a/app/src/main/java/org/schabi/newpipe/fragments/BlankFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/BlankFragment.java index e9e50dd69..e81645202 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/BlankFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/BlankFragment.java @@ -2,6 +2,7 @@ package org.schabi.newpipe.fragments; import android.os.Bundle; import android.support.annotation.Nullable; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -13,6 +14,24 @@ public class BlankFragment extends BaseFragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { + if(activity != null && activity.getSupportActionBar() != null) { + activity.getSupportActionBar() + .setTitle("NewPipe"); + } return inflater.inflate(R.layout.fragment_blank, container, false); } + + @Override + public void setUserVisibleHint(boolean isVisibleToUser) { + super.setUserVisibleHint(isVisibleToUser); + if(isVisibleToUser) { + if(activity != null && activity.getSupportActionBar() != null) { + activity.getSupportActionBar() + .setTitle("NewPipe"); + } + // leave this inline. Will make it harder for copy cats. + // If you are a Copy cat FUCK YOU. + // I WILL FIND YOU, AND I WILL ... + } + } } 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 42f52431e..190361f0e 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java @@ -117,7 +117,6 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte ActionBar supportActionBar = activity.getSupportActionBar(); if (supportActionBar != null) { - supportActionBar.setDisplayShowTitleEnabled(false); supportActionBar.setDisplayHomeAsUpEnabled(false); } } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index daa1b62ed..f98f8c36a 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -33,6 +33,7 @@ import org.schabi.newpipe.fragments.subscription.SubscriptionService; import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.util.AnimationUtils; import org.schabi.newpipe.util.ExtractorHelper; +import org.schabi.newpipe.util.KioskTranslator; import org.schabi.newpipe.util.Localization; import java.util.List; @@ -125,7 +126,6 @@ public class ChannelFragment extends BaseListInfoFragment { ActionBar supportActionBar = activity.getSupportActionBar(); if(useAsFrontPage) { supportActionBar.setDisplayHomeAsUpEnabled(false); - //supportActionBar.setDisplayShowTitleEnabled(false); } else { inflater.inflate(R.menu.menu_channel, menu); diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/kiosk/KioskFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/kiosk/KioskFragment.java index b1387b1ad..a9d1cda76 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/kiosk/KioskFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/kiosk/KioskFragment.java @@ -53,6 +53,9 @@ import static org.schabi.newpipe.util.AnimationUtils.animateView; public class KioskFragment extends BaseListInfoFragment { + private String kioskId = ""; + + /*////////////////////////////////////////////////////////////////////////// // Views //////////////////////////////////////////////////////////////////////////*/ @@ -76,6 +79,7 @@ public class KioskFragment extends BaseListInfoFragment { instance.setInitialData(serviceId, kioskTypeUrlIdHandler.getUrl(kioskId), kioskId); + instance.kioskId = kioskId; return instance; } @@ -83,6 +87,18 @@ public class KioskFragment extends BaseListInfoFragment { // LifeCycle //////////////////////////////////////////////////////////////////////////*/ + @Override + public void setUserVisibleHint(boolean isVisibleToUser) { + super.setUserVisibleHint(isVisibleToUser); + if(useAsFrontPage && isVisibleToUser) { + try { + activity.getSupportActionBar().setTitle(KioskTranslator.getTranslatedKioskName(kioskId, getActivity())); + } catch (Exception e) { + onError(e); + } + } + } + @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_kiosk, container, false); @@ -97,7 +113,6 @@ public class KioskFragment extends BaseListInfoFragment { super.onCreateOptionsMenu(menu, inflater); ActionBar supportActionBar = activity.getSupportActionBar(); if (supportActionBar != null && useAsFrontPage) { - //supportActionBar.setDisplayShowTitleEnabled(false); supportActionBar.setDisplayHomeAsUpEnabled(false); } } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/subscription/SubscriptionFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/subscription/SubscriptionFragment.java index afb2f078e..c4dfbc50d 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/subscription/SubscriptionFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/subscription/SubscriptionFragment.java @@ -7,6 +7,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -19,6 +20,7 @@ import org.schabi.newpipe.fragments.BaseStateFragment; import org.schabi.newpipe.info_list.InfoItemBuilder; import org.schabi.newpipe.info_list.InfoListAdapter; import org.schabi.newpipe.report.UserAction; +import org.schabi.newpipe.util.KioskTranslator; import org.schabi.newpipe.util.NavigationHelper; import java.util.ArrayList; @@ -52,6 +54,17 @@ public class SubscriptionFragment extends BaseStateFragment