mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 22:57:29 +00:00
make isNavRootInCurrentTabs consistent, show/hide explore
This commit is contained in:
parent
1774ce8af0
commit
23611df3fe
@ -906,9 +906,9 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
|
|||||||
return currentTabs;
|
return currentTabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNavRootInCurrentTabs(@IdRes final int navRootId) {
|
// public boolean isNavRootInCurrentTabs(@IdRes final int navRootId) {
|
||||||
return showBottomViewDestinations.stream().anyMatch(id -> id == navRootId);
|
// return showBottomViewDestinations.stream().anyMatch(id -> id == navRootId);
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void setNavBarDMUnreadCountBadge(final int unseenCount) {
|
private void setNavBarDMUnreadCountBadge(final int unseenCount) {
|
||||||
final BadgeDrawable badge = binding.bottomNavView.getOrCreateBadge(R.id.direct_messages_nav_graph);
|
final BadgeDrawable badge = binding.bottomNavView.getOrCreateBadge(R.id.direct_messages_nav_graph);
|
||||||
|
@ -580,7 +580,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
disableDm = !fragmentActivity.isNavRootInCurrentTabs(R.id.directMessagesInboxFragment);
|
disableDm = !Utils.isNavRootInCurrentTabs("direct_messages_nav_graph");
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
final ProfileFragmentArgs fragmentArgs = ProfileFragmentArgs.fromBundle(getArguments());
|
final ProfileFragmentArgs fragmentArgs = ProfileFragmentArgs.fromBundle(getArguments());
|
||||||
username = fragmentArgs.getUsername();
|
username = fragmentArgs.getUsername();
|
||||||
|
@ -39,6 +39,7 @@ import awais.instagrabber.utils.Constants;
|
|||||||
import awais.instagrabber.utils.CookieUtils;
|
import awais.instagrabber.utils.CookieUtils;
|
||||||
import awais.instagrabber.utils.FlavorTown;
|
import awais.instagrabber.utils.FlavorTown;
|
||||||
import awais.instagrabber.utils.TextUtils;
|
import awais.instagrabber.utils.TextUtils;
|
||||||
|
import awais.instagrabber.utils.Utils;
|
||||||
import awais.instagrabber.webservices.ServiceCallback;
|
import awais.instagrabber.webservices.ServiceCallback;
|
||||||
import awais.instagrabber.webservices.UserService;
|
import awais.instagrabber.webservices.UserService;
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ public class MorePreferencesFragment extends BasePreferencesFragment {
|
|||||||
final MainActivity activity = (MainActivity) getActivity();
|
final MainActivity activity = (MainActivity) getActivity();
|
||||||
// screen.addPreference(new MoreHeaderPreference(getContext()));
|
// screen.addPreference(new MoreHeaderPreference(getContext()));
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
|
final Resources resources = context.getResources();
|
||||||
if (context == null) return;
|
if (context == null) return;
|
||||||
accountRepository = AccountRepository.getInstance(AccountDataSource.getInstance(context));
|
accountRepository = AccountRepository.getInstance(AccountDataSource.getInstance(context));
|
||||||
final PreferenceCategory accountCategory = new PreferenceCategory(context);
|
final PreferenceCategory accountCategory = new PreferenceCategory(context);
|
||||||
@ -138,8 +140,10 @@ public class MorePreferencesFragment extends BasePreferencesFragment {
|
|||||||
final NavController navController = NavHostFragment.findNavController(this);
|
final NavController navController = NavHostFragment.findNavController(this);
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
boolean showActivity = true;
|
boolean showActivity = true;
|
||||||
|
boolean showExplore = false;
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
showActivity = !activity.isNavRootInCurrentTabs(R.id.notificationsViewer);
|
showActivity = !Utils.isNavRootInCurrentTabs("notification_viewer_nav_graph");
|
||||||
|
showExplore = !Utils.isNavRootInCurrentTabs("discover_nav_graph");
|
||||||
}
|
}
|
||||||
if (showActivity) {
|
if (showActivity) {
|
||||||
screen.addPreference(getPreference(R.string.action_notif, R.drawable.ic_not_liked, preference -> {
|
screen.addPreference(getPreference(R.string.action_notif, R.drawable.ic_not_liked, preference -> {
|
||||||
@ -150,6 +154,15 @@ public class MorePreferencesFragment extends BasePreferencesFragment {
|
|||||||
return true;
|
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 -> {
|
screen.addPreference(getPreference(R.string.action_ayml, R.drawable.ic_suggested_users, preference -> {
|
||||||
if (isSafeToNavigate(navController)) {
|
if (isSafeToNavigate(navController)) {
|
||||||
final NavDirections navDirections = MorePreferencesFragmentDirections.actionGlobalNotificationsViewerFragment("ayml");
|
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
|
// Check if favorites has been added as a tab. And if so, do not add in this list
|
||||||
boolean showFavorites = true;
|
boolean showFavorites = true;
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
showFavorites = !activity.isNavRootInCurrentTabs(R.id.favoritesFragment);
|
showFavorites = !Utils.isNavRootInCurrentTabs("favorites_nav_graph");
|
||||||
}
|
}
|
||||||
if (showFavorites) {
|
if (showFavorites) {
|
||||||
screen.addPreference(getPreference(R.string.title_favorites, R.drawable.ic_star_24, preference -> {
|
screen.addPreference(getPreference(R.string.title_favorites, R.drawable.ic_star_24, preference -> {
|
||||||
|
@ -31,6 +31,7 @@ import android.webkit.MimeTypeMap;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes;
|
import androidx.annotation.DrawableRes;
|
||||||
|
import androidx.annotation.IdRes;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
@ -80,6 +81,7 @@ public final class Utils {
|
|||||||
private static int actionBarHeight;
|
private static int actionBarHeight;
|
||||||
public static Handler applicationHandler;
|
public static Handler applicationHandler;
|
||||||
public static String cacheDir;
|
public static String cacheDir;
|
||||||
|
public static String tabOrderString;
|
||||||
private static int defaultStatusBarColor;
|
private static int defaultStatusBarColor;
|
||||||
|
|
||||||
public static int convertDpToPx(final float dp) {
|
public static int convertDpToPx(final float dp) {
|
||||||
@ -468,7 +470,7 @@ public final class Utils {
|
|||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private static List<String> getCurrentOrderOfGraphNamesFromPref(@NonNull final String[] navGraphNames) {
|
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);
|
final List<String> navGraphNameList = Arrays.asList(navGraphNames);
|
||||||
if (TextUtils.isEmpty(tabOrderString)) {
|
if (TextUtils.isEmpty(tabOrderString)) {
|
||||||
// Use top 5 entries for default list
|
// Use top 5 entries for default list
|
||||||
@ -485,4 +487,8 @@ public final class Utils {
|
|||||||
}
|
}
|
||||||
return orderGraphNames;
|
return orderGraphNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isNavRootInCurrentTabs(final String navRootString) {
|
||||||
|
return tabOrderString.contains(navRootString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
<include app:graph="@navigation/likes_nav_graph" />
|
<include app:graph="@navigation/likes_nav_graph" />
|
||||||
<include app:graph="@navigation/notification_viewer_nav_graph" />
|
<include app:graph="@navigation/notification_viewer_nav_graph" />
|
||||||
<include app:graph="@navigation/story_list_nav_graph" />
|
<include app:graph="@navigation/story_list_nav_graph" />
|
||||||
|
<include app:graph="@navigation/discover_nav_graph" />
|
||||||
|
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_global_profileFragment"
|
android:id="@+id/action_global_profileFragment"
|
||||||
|
Loading…
Reference in New Issue
Block a user