--- a/app/src/main/java/com/codesys/forge/MainActivity.java +++ b/app/src/main/java/com/codesys/forge/MainActivity.java @@ -21,6 +21,7 @@ import android.net.Uri; import android.os.Build; import android.util.Log; +import android.view.Menu; import android.view.MenuItem; import android.view.KeyEvent; import android.os.Bundle; @@ -161,6 +162,7 @@ currentURL = Url; myWebView.loadUrl(Url); RemoveNotification(); + UpdateBottomNavigation(); PassCookiesToService(); } @@ -212,6 +214,7 @@ } myWebView.loadUrl(currentURL); RemoveNotification(); + UpdateBottomNavigation(); } private void CreateNotificationChannel() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { @@ -238,6 +241,23 @@ } NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); notificationManager.cancel(id); + } + + private void UpdateBottomNavigation() { + Menu menuNav = bottomnav.getMenu(); + MenuItem menuItem = null; + + if (currentURL.contains("forge/community-feed")) { + menuItem = (MenuItem) menuNav.findItem(R.id.community); + } + else if (currentURL.contains("forge/news")) { + menuItem = (MenuItem) menuNav.findItem(R.id.news); + } + else if (currentURL.contains("forge/talk")) { + menuItem = (MenuItem) menuNav.findItem(R.id.talk); + } + if (menuItem != null) + menuItem.setChecked(true); } private void CreateNotification(int id) { @@ -283,6 +303,11 @@ String myUseragent; String url = this.getIntent().getStringExtra("url"); + if (url != null) + { + currentURL = url; + } + super.onCreate(savedInstanceState); // start long polling service