forked from mirror/monocles_chat_clean
update fork #128
20 changed files with 194 additions and 126 deletions
Replace Accounts with Calls in bottom navigation bar
commit
9b49e58a1d
|
|
@ -1,31 +1,73 @@
|
|||
|
||||
package eu.siacs.conversations.ui;
|
||||
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.databinding.ActivityCallsBinding;
|
||||
|
||||
public class CallsActivity extends AppCompatActivity {
|
||||
public class CallsActivity extends XmppActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ActivityCallsBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_calls);
|
||||
Activities.setStatusAndNavigationBarColors(this, findViewById(android.R.id.content));
|
||||
setSupportActionBar(binding.toolbar);
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
configureActionBar(getSupportActionBar());
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragment_container, new CallsFragment())
|
||||
.commit();
|
||||
}
|
||||
|
||||
|
||||
// Bottom Navigation Setup
|
||||
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
|
||||
bottomNavigationView.setBackgroundColor(Color.TRANSPARENT);
|
||||
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.stories -> {
|
||||
Intent i = new Intent(getApplicationContext(), StoriesActivity.class);
|
||||
i.putExtra("show_nav_bar", true);
|
||||
startActivity(i);
|
||||
overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
|
||||
return true;
|
||||
}
|
||||
case R.id.calls -> {
|
||||
return true;
|
||||
}
|
||||
default ->
|
||||
throw new IllegalStateException("Unexpected value: " + item.getItemId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -33,4 +75,74 @@ public class CallsActivity extends AppCompatActivity {
|
|||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
BottomNavigationView bottomNavigationView=findViewById(R.id.bottom_navigation);
|
||||
bottomNavigationView.setSelectedItemId(R.id.calls);
|
||||
|
||||
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
|
||||
protected void onBackendConnected() {
|
||||
refreshUiReal();
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
protected void refreshUiReal() {
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
|
||||
// Show badge for unread message in bottom nav
|
||||
int unreadCount = xmppConnectionService.unreadCount();
|
||||
BottomNavigationView bottomnav = findViewById(R.id.bottom_navigation);
|
||||
var bottomBadge = bottomnav.getOrCreateBadge(R.id.chats);
|
||||
bottomBadge.setNumber(unreadCount);
|
||||
bottomBadge.setVisible(unreadCount > 0);
|
||||
bottomBadge.setHorizontalOffset(20);
|
||||
|
||||
// Show badge for new stories in bottom nav
|
||||
long lastRead = getPreferences().getLong("last_read_story_timestamp", 0);
|
||||
boolean hasNewStories = xmppConnectionService.getStories().stream().anyMatch(s -> s.getPublished() > lastRead);
|
||||
var storiesBadge = bottomnav.getOrCreateBadge(R.id.stories);
|
||||
storiesBadge.setVisible(hasNewStories);
|
||||
|
||||
boolean showNavBar = bottomnav.getVisibility() == VISIBLE;
|
||||
if (actionBar != null) {
|
||||
actionBar.setHomeButtonEnabled(!showNavBar);
|
||||
actionBar.setDisplayHomeAsUpEnabled(!showNavBar);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.activity_stories, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.action_settings) {
|
||||
startActivity(new Intent(this, eu.siacs.conversations.ui.activity.SettingsActivity.class));
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1149,8 +1149,8 @@ public class ConversationsActivity extends XmppActivity
|
|||
overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
|
||||
return true;
|
||||
}
|
||||
case R.id.manageaccounts -> {
|
||||
Intent i = new Intent(getApplicationContext(), MANAGE_ACCOUNT_ACTIVITY);
|
||||
case R.id.calls -> {
|
||||
Intent i = new Intent(getApplicationContext(), CallsActivity.class);
|
||||
i.putExtra("show_nav_bar", true);
|
||||
startActivity(i);
|
||||
overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
|
||||
|
|
|
|||
|
|
@ -483,13 +483,9 @@ public class ConversationsOverviewFragment extends XmppFragment {
|
|||
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);
|
||||
MenuItem stories = menu.findItem(R.id.action_stories);
|
||||
MenuItem calls = menu.findItem(R.id.action_calls);
|
||||
if (navBarVisible) {
|
||||
manageAccount.setVisible(false);
|
||||
manageAccounts.setVisible(false);
|
||||
stories.setVisible(false);
|
||||
calls.setVisible(false);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -459,8 +459,8 @@ public class StartConversationActivity extends XmppActivity
|
|||
overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
|
||||
return true;
|
||||
}
|
||||
case R.id.manageaccounts -> {
|
||||
Intent i = new Intent(getApplicationContext(), MANAGE_ACCOUNT_ACTIVITY);
|
||||
case R.id.calls -> {
|
||||
Intent i = new Intent(getApplicationContext(), CallsActivity.class);
|
||||
i.putExtra("show_nav_bar", true);
|
||||
startActivity(i);
|
||||
overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
|
||||
|
|
|
|||
|
|
@ -87,8 +87,8 @@ public class StoriesActivity extends XmppActivity implements XmppConnectionServi
|
|||
case R.id.stories -> {
|
||||
return true;
|
||||
}
|
||||
case R.id.manageaccounts -> {
|
||||
Intent i = new Intent(getApplicationContext(), MANAGE_ACCOUNT_ACTIVITY);
|
||||
case R.id.calls -> {
|
||||
Intent i = new Intent(getApplicationContext(), CallsActivity.class);
|
||||
i.putExtra("show_nav_bar", true);
|
||||
startActivity(i);
|
||||
overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
|
||||
|
|
|
|||
5
src/main/res/drawable/calls_selected_black_24dp.xml
Normal file
5
src/main/res/drawable/calls_selected_black_24dp.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M20.01,15.38c-1.23,0 -2.42,-0.2 -3.53,-0.56 -0.35,-0.12 -0.74,-0.03 -1.01,0.24l-1.57,1.97c-2.83,-1.35 -5.48,-3.9 -6.89,-6.83l1.95,-1.66c0.27,-0.28 0.35,-0.67 0.24,-1.02 -0.37,-1.11 -0.56,-2.3 -0.56,-3.53 0,-0.54 -0.45,-0.99 -0.99,-0.99H4.19C3.65,3 3,3.24 3,3.99 3,13.28 10.73,21 20.01,21c0.71,0 0.99,-0.63 0.99,-1.18v-3.45c0,-0.54 -0.45,-0.99 -0.99,-0.99z"/>
|
||||
|
||||
</vector>
|
||||
5
src/main/res/drawable/calls_selected_white_24dp.xml
Normal file
5
src/main/res/drawable/calls_selected_white_24dp.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M20.01,15.38c-1.23,0 -2.42,-0.2 -3.53,-0.56 -0.35,-0.12 -0.74,-0.03 -1.01,0.24l-1.57,1.97c-2.83,-1.35 -5.48,-3.9 -6.89,-6.83l1.95,-1.66c0.27,-0.28 0.35,-0.67 0.24,-1.02 -0.37,-1.11 -0.56,-2.3 -0.56,-3.53 0,-0.54 -0.45,-0.99 -0.99,-0.99H4.19C3.65,3 3,3.24 3,3.99 3,13.28 10.73,21 20.01,21c0.71,0 0.99,-0.63 0.99,-1.18v-3.45c0,-0.54 -0.45,-0.99 -0.99,-0.99z"/>
|
||||
|
||||
</vector>
|
||||
5
src/main/res/drawable/calls_unselected_black_24dp.xml
Normal file
5
src/main/res/drawable/calls_unselected_black_24dp.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M6.54,5c0.06,0.89 0.21,1.76 0.45,2.59l-1.2,1.2c-0.41,-1.2 -0.67,-2.47 -0.76,-3.79h1.51m9.86,12.02c0.85,0.24 1.72,0.39 2.6,0.45v1.49c-1.32,-0.09 -2.59,-0.35 -3.8,-0.75l1.2,-1.19M7.5,3H4c-0.55,0 -1,0.45 -1,1 0,9.39 7.61,17 17,17 0.55,0 1,-0.45 1,-1v-3.49c0,-0.55 -0.45,-1 -1,-1 -1.24,0 -2.45,-0.2 -3.57,-0.57 -0.1,-0.04 -0.21,-0.05 -0.31,-0.05 -0.26,0 -0.51,0.1 -0.71,0.29l-2.2,2.2c-2.83,-1.45 -5.15,-3.76 -6.59,-6.59l2.2,-2.2c0.28,-0.28 0.36,-0.67 0.25,-1.02C8.7,6.45 8.5,5.25 8.5,4c0,-0.55 -0.45,-1 -1,-1z"/>
|
||||
|
||||
</vector>
|
||||
5
src/main/res/drawable/calls_unselected_white_24dp.xml
Normal file
5
src/main/res/drawable/calls_unselected_white_24dp.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M6.54,5c0.06,0.89 0.21,1.76 0.45,2.59l-1.2,1.2c-0.41,-1.2 -0.67,-2.47 -0.76,-3.79h1.51m9.86,12.02c0.85,0.24 1.72,0.39 2.6,0.45v1.49c-1.32,-0.09 -2.59,-0.35 -3.8,-0.75l1.2,-1.19M7.5,3H4c-0.55,0 -1,0.45 -1,1 0,9.39 7.61,17 17,17 0.55,0 1,-0.45 1,-1v-3.49c0,-0.55 -0.45,-1 -1,-1 -1.24,0 -2.45,-0.2 -3.57,-0.57 -0.1,-0.04 -0.21,-0.05 -0.31,-0.05 -0.26,0 -0.51,0.1 -0.71,0.29l-2.2,2.2c-2.83,-1.45 -5.15,-3.76 -6.59,-6.59l2.2,-2.2c0.28,-0.28 0.36,-0.67 0.25,-1.02C8.7,6.45 8.5,5.25 8.5,4c0,-0.55 -0.45,-1 -1,-1z"/>
|
||||
|
||||
</vector>
|
||||
|
|
@ -1,8 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@id/bottom_navigation">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
@ -26,4 +37,14 @@
|
|||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottom_navigation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/nav_bar_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="?colorSurfaceContainerLowest"
|
||||
app:labelVisibilityMode="labeled"
|
||||
app:menu="@menu/bottom_navigation_menu_calls" />
|
||||
</RelativeLayout>
|
||||
</layout>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_above="@id/bottom_navigation"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
|
|
@ -85,16 +84,6 @@
|
|||
android:src="@drawable/ic_settings_24dp"
|
||||
app:shapeAppearance="@style/ShapeAppearanceOverlay.Photo" />
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottom_navigation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/nav_bar_height"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="?colorSurfaceContainerLowest"
|
||||
app:labelVisibilityMode="labeled"
|
||||
app:menu="@menu/bottom_navigation_menu_accounts" />
|
||||
</RelativeLayout>
|
||||
</layout>
|
||||
|
|
|
|||
9
src/main/res/menu/activity_calls.xml
Normal file
9
src/main/res/menu/activity_calls.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_settings"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
android:icon="?attr/ic_stories_unselected"
|
||||
android:title="@string/stories"/>
|
||||
<item
|
||||
android:id="@+id/manageaccounts"
|
||||
android:icon="?attr/ic_accounts_selected"
|
||||
android:title="@string/accounts"/>
|
||||
android:id="@+id/calls"
|
||||
android:icon="?attr/ic_calls_selected"
|
||||
android:title="@string/calls"/>
|
||||
</menu>
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
android:icon="?attr/ic_stories_unselected"
|
||||
android:title="@string/stories"/>
|
||||
<item
|
||||
android:id="@+id/manageaccounts"
|
||||
android:icon="?attr/ic_account"
|
||||
android:title="@string/accounts"/>
|
||||
android:id="@+id/calls"
|
||||
android:icon="?attr/ic_calls_unselected"
|
||||
android:title="@string/calls"/>
|
||||
</menu>
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
android:icon="?attr/ic_stories_unselected"
|
||||
android:title="@string/stories"/>
|
||||
<item
|
||||
android:id="@+id/manageaccounts"
|
||||
android:icon="?attr/ic_account"
|
||||
android:title="@string/accounts"/>
|
||||
android:id="@+id/calls"
|
||||
android:icon="?attr/ic_calls_unselected"
|
||||
android:title="@string/calls"/>
|
||||
</menu>
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
android:icon="?attr/ic_stories_selected"
|
||||
android:title="@string/stories"/>
|
||||
<item
|
||||
android:id="@+id/manageaccounts"
|
||||
android:icon="?attr/ic_account"
|
||||
android:title="@string/accounts"/>
|
||||
android:id="@+id/calls"
|
||||
android:icon="?attr/ic_calls_unselected"
|
||||
android:title="@string/calls"/>
|
||||
</menu>
|
||||
|
|
@ -32,8 +32,8 @@
|
|||
|
||||
<item name="ic_chat_unselected" type="reference">@drawable/outline_chat_white_24</item>
|
||||
<item name="ic_chat_selected" type="reference">@drawable/chat_selected_white_24</item>
|
||||
<item name="ic_account" type="reference">@drawable/ic_account_white_24dp</item>
|
||||
<item name="ic_accounts_selected" type="reference">@drawable/accounts_selected_white_24</item>
|
||||
<item name="ic_calls_unselected" type="reference">@drawable/calls_unselected_white_24dp</item>
|
||||
<item name="ic_calls_selected" type="reference">@drawable/calls_selected_white_24dp</item>
|
||||
<item name="ic_group_unselected" type="reference">@drawable/outline_group_white_24</item>
|
||||
<item name="ic_group_selected" type="reference">@drawable/ic_group_selected_white_24</item>
|
||||
<item name="ic_stories_unselected" type="reference">@drawable/stories_unselected_white_24</item>
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@
|
|||
|
||||
<item name="ic_chat_unselected" type="reference">@drawable/outline_chat_black_24</item>
|
||||
<item name="ic_chat_selected" type="reference">@drawable/chat_selected_black_24</item>
|
||||
<item name="ic_account" type="reference">@drawable/ic_account_black_24dp</item>
|
||||
<item name="ic_accounts_selected" type="reference">@drawable/accounts_selected_black_24</item>
|
||||
<item name="ic_calls_unselected" type="reference">@drawable/calls_unselected_black_24dp</item>
|
||||
<item name="ic_calls_selected" type="reference">@drawable/calls_selected_black_24dp</item>
|
||||
<item name="ic_group_unselected" type="reference">@drawable/outline_group_black_24dp</item>
|
||||
<item name="ic_group_selected" type="reference">@drawable/ic_group_selected_black_24</item>
|
||||
<item name="ic_stories_unselected" type="reference">@drawable/stories_unselected_black_24</item>
|
||||
|
|
|
|||
|
|
@ -49,8 +49,6 @@ 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;
|
||||
|
||||
public class ManageAccountActivity extends XmppActivity implements XmppConnectionService.OnConversationUpdate, OnAccountUpdate, KeyChainAliasCallback, XmppConnectionService.OnAccountCreated, AccountAdapter.OnTglAccountState {
|
||||
|
||||
private final String STATE_SELECTED_ACCOUNT = "selected_account";
|
||||
|
|
@ -87,24 +85,9 @@ public class ManageAccountActivity extends XmppActivity implements XmppConnectio
|
|||
}
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
|
||||
// Show badge for unread message in bottom nav
|
||||
int unreadCount = xmppConnectionService.unreadCount();
|
||||
BottomNavigationView bottomnav = findViewById(R.id.bottom_navigation);
|
||||
var bottomBadge = bottomnav.getOrCreateBadge(R.id.chats);
|
||||
bottomBadge.setNumber(unreadCount);
|
||||
bottomBadge.setVisible(unreadCount > 0);
|
||||
bottomBadge.setHorizontalOffset(20);
|
||||
|
||||
// Show badge for new stories in bottom nav
|
||||
long lastRead = getPreferences().getLong("last_read_story_timestamp", 0);
|
||||
boolean hasNewStories = xmppConnectionService.getStories().stream().anyMatch(s -> s.getPublished() > lastRead);
|
||||
var storiesBadge = bottomnav.getOrCreateBadge(R.id.stories);
|
||||
storiesBadge.setVisible(hasNewStories);
|
||||
|
||||
boolean showNavBar = bottomnav.getVisibility() == VISIBLE;
|
||||
if (actionBar != null) {
|
||||
actionBar.setHomeButtonEnabled(!this.accountList.isEmpty() && !showNavBar);
|
||||
actionBar.setDisplayHomeAsUpEnabled(!this.accountList.isEmpty() && !showNavBar);
|
||||
actionBar.setHomeButtonEnabled(!this.accountList.isEmpty());
|
||||
actionBar.setDisplayHomeAsUpEnabled(!this.accountList.isEmpty());
|
||||
}
|
||||
invalidateOptionsMenu();
|
||||
mAccountAdapter.notifyDataSetChanged();
|
||||
|
|
@ -218,69 +201,7 @@ public class ManageAccountActivity extends XmppActivity implements XmppConnectio
|
|||
});
|
||||
|
||||
accountListView.setAdapter(this.mAccountAdapter);
|
||||
|
||||
// Bottom Navigation Setup (unchanged) ...
|
||||
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
|
||||
// ... (rest of bottom nav logic)
|
||||
bottomNavigationView.setBackgroundColor(Color.TRANSPARENT);
|
||||
bottomNavigationView.setOnItemSelectedListener(item -> {
|
||||
// ... existing switch case ...
|
||||
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.stories -> {
|
||||
Intent i = new Intent(getApplicationContext(), StoriesActivity.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
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
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
|
||||
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
|
||||
public void onSaveInstanceState(final Bundle savedInstanceState) {
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<attr name="icon_chat" format="reference" />
|
||||
<attr name="ic_chat_unselected" format="reference" />
|
||||
<attr name="ic_chat_selected" format="reference" />
|
||||
<attr name="ic_account" format="reference" />
|
||||
<attr name="ic_accounts_selected" format="reference" />
|
||||
<attr name="ic_calls_unselected" format="reference" />
|
||||
<attr name="ic_calls_selected" format="reference" />
|
||||
<attr name="ic_group_unselected" format="reference" />
|
||||
<attr name="ic_group_selected" format="reference" />
|
||||
<attr name="ic_stories_unselected" format="reference" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue