1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-12-23 05:16:58 +00:00

make isNavRootInCurrentTabs consistent, show/hide explore

This commit is contained in:
Austin Huang 2021-04-02 12:01:29 -04:00
parent 1774ce8af0
commit 23611df3fe
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
5 changed files with 27 additions and 7 deletions

View File

@ -906,9 +906,9 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
return currentTabs;
}
public boolean isNavRootInCurrentTabs(@IdRes final int navRootId) {
return showBottomViewDestinations.stream().anyMatch(id -> id == navRootId);
}
// public boolean isNavRootInCurrentTabs(@IdRes final int navRootId) {
// return showBottomViewDestinations.stream().anyMatch(id -> id == navRootId);
// }
private void setNavBarDMUnreadCountBadge(final int unseenCount) {
final BadgeDrawable badge = binding.bottomNavView.getOrCreateBadge(R.id.direct_messages_nav_graph);

View File

@ -580,7 +580,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
}
private void init() {
disableDm = !fragmentActivity.isNavRootInCurrentTabs(R.id.directMessagesInboxFragment);
disableDm = !Utils.isNavRootInCurrentTabs("direct_messages_nav_graph");
if (getArguments() != null) {
final ProfileFragmentArgs fragmentArgs = ProfileFragmentArgs.fromBundle(getArguments());
username = fragmentArgs.getUsername();

View File

@ -39,6 +39,7 @@ import awais.instagrabber.utils.Constants;
import awais.instagrabber.utils.CookieUtils;
import awais.instagrabber.utils.FlavorTown;
import awais.instagrabber.utils.TextUtils;
import awais.instagrabber.utils.Utils;
import awais.instagrabber.webservices.ServiceCallback;
import awais.instagrabber.webservices.UserService;
@ -59,6 +60,7 @@ public class MorePreferencesFragment extends BasePreferencesFragment {
final MainActivity activity = (MainActivity) getActivity();
// screen.addPreference(new MoreHeaderPreference(getContext()));
final Context context = getContext();
final Resources resources = context.getResources();
if (context == null) return;
accountRepository = AccountRepository.getInstance(AccountDataSource.getInstance(context));
final PreferenceCategory accountCategory = new PreferenceCategory(context);
@ -138,8 +140,10 @@ public class MorePreferencesFragment extends BasePreferencesFragment {
final NavController navController = NavHostFragment.findNavController(this);
if (isLoggedIn) {
boolean showActivity = true;
boolean showExplore = false;
if (activity != null) {
showActivity = !activity.isNavRootInCurrentTabs(R.id.notificationsViewer);
showActivity = !Utils.isNavRootInCurrentTabs("notification_viewer_nav_graph");
showExplore = !Utils.isNavRootInCurrentTabs("discover_nav_graph");
}
if (showActivity) {
screen.addPreference(getPreference(R.string.action_notif, R.drawable.ic_not_liked, preference -> {
@ -150,6 +154,15 @@ public class MorePreferencesFragment extends BasePreferencesFragment {
return true;
}));
}
if (showExplore) {
screen.addPreference(getPreference(R.string.title_discover, R.drawable.ic_explore_24, preference -> {
if (isSafeToNavigate(navController)) {
navController.navigate(R.id.discover_nav_graph);
}
return true;
}));
}
screen.addPreference(getPreference(R.string.action_ayml, R.drawable.ic_suggested_users, preference -> {
if (isSafeToNavigate(navController)) {
final NavDirections navDirections = MorePreferencesFragmentDirections.actionGlobalNotificationsViewerFragment("ayml");
@ -169,7 +182,7 @@ public class MorePreferencesFragment extends BasePreferencesFragment {
// Check if favorites has been added as a tab. And if so, do not add in this list
boolean showFavorites = true;
if (activity != null) {
showFavorites = !activity.isNavRootInCurrentTabs(R.id.favoritesFragment);
showFavorites = !Utils.isNavRootInCurrentTabs("favorites_nav_graph");
}
if (showFavorites) {
screen.addPreference(getPreference(R.string.title_favorites, R.drawable.ic_star_24, preference -> {

View File

@ -31,6 +31,7 @@ import android.webkit.MimeTypeMap;
import android.widget.Toast;
import androidx.annotation.DrawableRes;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
@ -80,6 +81,7 @@ public final class Utils {
private static int actionBarHeight;
public static Handler applicationHandler;
public static String cacheDir;
public static String tabOrderString;
private static int defaultStatusBarColor;
public static int convertDpToPx(final float dp) {
@ -468,7 +470,7 @@ public final class Utils {
@NonNull
private static List<String> getCurrentOrderOfGraphNamesFromPref(@NonNull final String[] navGraphNames) {
final String tabOrderString = settingsHelper.getString(PreferenceKeys.PREF_TAB_ORDER);
tabOrderString = settingsHelper.getString(PreferenceKeys.PREF_TAB_ORDER);
final List<String> navGraphNameList = Arrays.asList(navGraphNames);
if (TextUtils.isEmpty(tabOrderString)) {
// Use top 5 entries for default list
@ -485,4 +487,8 @@ public final class Utils {
}
return orderGraphNames;
}
public static boolean isNavRootInCurrentTabs(final String navRootString) {
return tabOrderString.contains(navRootString);
}
}

View File

@ -11,6 +11,7 @@
<include app:graph="@navigation/likes_nav_graph" />
<include app:graph="@navigation/notification_viewer_nav_graph" />
<include app:graph="@navigation/story_list_nav_graph" />
<include app:graph="@navigation/discover_nav_graph" />
<action
android:id="@+id/action_global_profileFragment"