diff --git a/src/conversations/java/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/conversations/java/eu/siacs/conversations/ui/ManageAccountActivity.java
index 22e208b90..aab32220d 100644
--- a/src/conversations/java/eu/siacs/conversations/ui/ManageAccountActivity.java
+++ b/src/conversations/java/eu/siacs/conversations/ui/ManageAccountActivity.java
@@ -1,5 +1,7 @@
package eu.siacs.conversations.ui;
+import static android.view.View.VISIBLE;
+
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.os.Bundle;
@@ -40,6 +42,9 @@ import eu.siacs.conversations.xmpp.XmppConnection;
import static eu.siacs.conversations.utils.PermissionUtils.allGranted;
import static eu.siacs.conversations.utils.PermissionUtils.writeGranted;
+import com.google.android.material.bottomnavigation.BottomNavigationView;
+import com.google.android.material.navigation.NavigationBarView;
+
public class ManageAccountActivity extends XmppActivity implements OnAccountUpdate, KeyChainAliasCallback, XmppConnectionService.OnAccountCreated, AccountAdapter.OnTglAccountState {
private final String STATE_SELECTED_ACCOUNT = "selected_account";
@@ -68,9 +73,10 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
accountList.addAll(xmppConnectionService.getAccounts());
}
ActionBar actionBar = getSupportActionBar();
+ boolean showNavBar = findViewById(R.id.bottom_navigation).getVisibility() == VISIBLE;
if (actionBar != null) {
- actionBar.setHomeButtonEnabled(this.accountList.size() > 0);
- actionBar.setDisplayHomeAsUpEnabled(this.accountList.size() > 0);
+ actionBar.setHomeButtonEnabled(this.accountList.size() > 0 && !showNavBar);
+ actionBar.setDisplayHomeAsUpEnabled(this.accountList.size() > 0 && !showNavBar);
}
invalidateOptionsMenu();
mAccountAdapter.notifyDataSetChanged();
@@ -100,6 +106,30 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
accountListView.setAdapter(this.mAccountAdapter);
accountListView.setOnItemClickListener((arg0, view, position, arg3) -> switchToAccount(accountList.get(position)));
registerForContextMenu(accountListView);
+
+ BottomNavigationView bottomNavigationView=findViewById(R.id.bottom_navigation);
+ bottomNavigationView.setOnItemSelectedListener(item -> {
+
+ switch (item.getItemId()) {
+ case R.id.chats -> {
+ startActivity(new Intent(getApplicationContext(), ConversationsActivity.class));
+ overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
+ return true;
+ }
+ case R.id.contactslist -> {
+ Intent i = new Intent(getApplicationContext(), StartConversationActivity.class);
+ i.putExtra("show_nav_bar", true);
+ startActivity(i);
+ overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
+ return true;
+ }
+ case R.id.manageaccounts -> {
+ return true;
+ }
+ default ->
+ throw new IllegalStateException("Unexpected value: " + item.getItemId());
+ }
+ });
}
@Override
@@ -109,6 +139,15 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
if (this.mTheme != theme) {
recreate();
}
+
+ BottomNavigationView bottomNavigationView=findViewById(R.id.bottom_navigation);
+ bottomNavigationView.setSelectedItemId(R.id.manageaccounts);
+
+ if (getBooleanPreference("show_nav_bar", R.bool.show_nav_bar) && getIntent().getBooleanExtra("show_nav_bar", false)) {
+ bottomNavigationView.setVisibility(VISIBLE);
+ } else {
+ bottomNavigationView.setVisibility(View.GONE);
+ }
}
@Override
@@ -147,6 +186,18 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
menu.setHeaderTitle(this.selectedAccount.getJid().asBareJid().toEscapedString());
}
+ @Override
+ public void onBackPressed() {
+ if (findViewById(R.id.bottom_navigation).getVisibility() == VISIBLE) {
+ Intent intent = new Intent(this, ConversationsActivity.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
+ startActivity(intent);
+ overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
+ }
+
+ super.onBackPressed();
+ }
+
@Override
void onBackendConnected() {
if (selectedAccountJid != null) {
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index d426ddecc..0b24f9439 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -1418,6 +1418,14 @@ public class ConversationFragment extends XmppFragment
menuTogglePinned.setTitle(R.string.add_to_favorites);
}
}
+
+ Fragment secondaryFragment = activity.getFragmentManager().findFragmentById(R.id.secondary_fragment);
+ if (secondaryFragment instanceof ConversationFragment) {
+ activity.showNavigationBar();
+ } else {
+ activity.hideNavigationBar();
+ }
+
super.onCreateOptionsMenu(menu, menuInflater);
}
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java
index 1836ed157..b225d8404 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java
@@ -31,6 +31,7 @@ package eu.siacs.conversations.ui;
import static eu.siacs.conversations.ui.ConversationFragment.REQUEST_DECRYPT_PGP;
+import static eu.siacs.conversations.utils.AccountUtils.MANAGE_ACCOUNT_ACTIVITY;
import android.Manifest;
import android.annotation.SuppressLint;
@@ -61,6 +62,9 @@ import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityCompat;
import androidx.databinding.DataBindingUtil;
+import com.google.android.material.bottomnavigation.BottomNavigationView;
+import com.google.android.material.navigation.NavigationBarView;
+
import org.openintents.openpgp.util.OpenPgpApi;
import java.util.Arrays;
@@ -397,6 +401,33 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
pendingViewIntent.push(intent);
setIntent(createLauncherIntent(this));
}
+
+ BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
+ bottomNavigationView.setOnItemSelectedListener(item -> {
+
+ switch (item.getItemId()) {
+ case R.id.chats -> {
+ return true;
+ }
+ case R.id.contactslist -> {
+ Intent i = new Intent(getApplicationContext(), StartConversationActivity.class);
+ i.putExtra("show_nav_bar", true);
+ startActivity(i);
+
+ overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
+ return true;
+ }
+ case R.id.manageaccounts -> {
+ Intent i = new Intent(getApplicationContext(), MANAGE_ACCOUNT_ACTIVITY);
+ i.putExtra("show_nav_bar", true);
+ startActivity(i);
+ overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
+ return true;
+ }
+ default ->
+ throw new IllegalStateException("Unexpected value: " + item.getItemId());
+ }
+ });
}
@Override
@@ -432,6 +463,24 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
}
}
+ public boolean navigationBarVisible() {
+ return findViewById(R.id.bottom_navigation).getVisibility() == View.VISIBLE;
+ }
+
+ public boolean showNavigationBar() {
+ if (!getBooleanPreference("show_nav_bar", R.bool.show_nav_bar)) {
+ findViewById(R.id.bottom_navigation).setVisibility(View.GONE);
+ return false;
+ }
+
+ findViewById(R.id.bottom_navigation).setVisibility(View.VISIBLE);
+ return true;
+ }
+
+ public void hideNavigationBar() {
+ findViewById(R.id.bottom_navigation).setVisibility(View.GONE);
+ }
+
@Nullable
public View getFragmentHostView() {
if (binding.secondaryFragment != null) {
@@ -611,6 +660,9 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
this.mSkipBackgroundBinding = false;
}
mRedirectInProcess.set(false);
+
+ BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
+ bottomNavigationView.setSelectedItemId(R.id.chats);
}
@Override
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java
index c36f839e0..69b01888a 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java
@@ -422,6 +422,21 @@ public class ConversationsOverviewFragment extends XmppFragment {
}
}
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ super.onPrepareOptionsMenu(menu);
+
+ boolean navBarVisible = activity instanceof ConversationsActivity && ((ConversationsActivity) activity).navigationBarVisible();
+ MenuItem manageAccount = menu.findItem(R.id.action_account);
+ MenuItem manageAccounts = menu.findItem(R.id.action_accounts);
+ if (navBarVisible) {
+ manageAccount.setVisible(false);
+ manageAccounts.setVisible(false);
+ } else {
+ AccountUtils.showHideMenuItems(menu);
+ }
+ }
+
@Override
public void onStart() {
super.onStart();
@@ -429,6 +444,16 @@ public class ConversationsOverviewFragment extends XmppFragment {
if (activity.xmppConnectionService != null) {
refresh();
}
+
+ if (activity instanceof ConversationsActivity) {
+ boolean showed = ((ConversationsActivity) activity).showNavigationBar();
+
+ if (showed) {
+ this.binding.fab.setVisibility(View.GONE);
+ } else {
+ this.binding.fab.setVisibility(View.VISIBLE);
+ }
+ }
}
@Override
diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
index f119dfb76..4a1439e84 100644
--- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
@@ -1,5 +1,9 @@
package eu.siacs.conversations.ui;
+import static android.view.View.VISIBLE;
+
+import static eu.siacs.conversations.utils.AccountUtils.MANAGE_ACCOUNT_ACTIVITY;
+
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Dialog;
@@ -63,6 +67,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
+import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.textfield.TextInputLayout;
import com.leinardi.android.speeddial.SpeedDialActionItem;
import com.leinardi.android.speeddial.SpeedDialView;
@@ -374,6 +379,30 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
}
return false;
});
+
+ BottomNavigationView bottomNavigationView=findViewById(R.id.bottom_navigation);
+ bottomNavigationView.setOnItemSelectedListener(item -> {
+
+ switch (item.getItemId()) {
+ case R.id.chats -> {
+ startActivity(new Intent(getApplicationContext(), ConversationsActivity.class));
+ overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
+ return true;
+ }
+ case R.id.contactslist -> {
+ return true;
+ }
+ case R.id.manageaccounts -> {
+ Intent i = new Intent(getApplicationContext(), MANAGE_ACCOUNT_ACTIVITY);
+ i.putExtra("show_nav_bar", true);
+ startActivity(i);
+ overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
+ return true;
+ }
+ default ->
+ throw new IllegalStateException("Unexpected value: " + item.getItemId());
+ }
+ });
}
private void inflateFab(final SpeedDialView speedDialView, final @MenuRes int menuRes) {
@@ -430,6 +459,15 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
}
mConferenceAdapter.refreshSettings();
mContactsAdapter.refreshSettings();
+
+ BottomNavigationView bottomNavigationView=findViewById(R.id.bottom_navigation);
+ bottomNavigationView.setSelectedItemId(R.id.contactslist);
+
+ if (getBooleanPreference("show_nav_bar", R.bool.show_nav_bar) && getIntent().getBooleanExtra("show_nav_bar", false)) {
+ bottomNavigationView.setVisibility(VISIBLE);
+ } else {
+ bottomNavigationView.setVisibility(View.GONE);
+ }
}
@Override
@@ -769,6 +807,22 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
return super.onCreateOptionsMenu(menu);
}
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ boolean res = super.onPrepareOptionsMenu(menu);
+ boolean navBarVisible = binding.bottomNavigation.getVisibility() == VISIBLE;
+ MenuItem manageAccount = menu.findItem(R.id.action_account);
+ MenuItem manageAccounts = menu.findItem(R.id.action_accounts);
+ if (navBarVisible) {
+ manageAccount.setVisible(false);
+ manageAccounts.setVisible(false);
+ } else {
+ AccountUtils.showHideMenuItems(menu);
+ }
+
+ return res;
+ }
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (MenuDoubleTabUtil.shouldIgnoreTap()) {
@@ -916,8 +970,9 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
return;
}
boolean openConversations = !createdByViewIntent && !xmppConnectionService.isConversationsListEmpty(null);
- actionBar.setDisplayHomeAsUpEnabled(openConversations);
- actionBar.setDisplayHomeAsUpEnabled(openConversations);
+ boolean showNavBar = binding.bottomNavigation.getVisibility() == VISIBLE;
+ actionBar.setDisplayHomeAsUpEnabled(openConversations && !showNavBar);
+ actionBar.setDisplayHomeAsUpEnabled(openConversations && !showNavBar);
}
@@ -1149,6 +1204,9 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
Intent intent = new Intent(this, ConversationsActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
+ if (binding.bottomNavigation.getVisibility() == VISIBLE) {
+ overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
+ }
}
finish();
}
diff --git a/src/main/res/animator/fade_in.xml b/src/main/res/animator/fade_in.xml
new file mode 100644
index 000000000..8307c7835
--- /dev/null
+++ b/src/main/res/animator/fade_in.xml
@@ -0,0 +1,8 @@
+
+