Browse Source

shoutbox fixes: remove when guest, update color changes in names

pull/61/merge
Thodoris1999 6 years ago
parent
commit
e3fa8a5e18
  1. 9
      app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java
  2. 1
      app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java
  3. 2
      app/src/main/res/layout/activity_main.xml
  4. 9
      app/src/main/res/menu/bottom_navigation_basic.xml
  5. 11
      app/src/main/res/menu/bottom_navigation_logged_in.xml
  6. 10
      app/src/main/res/xml/app_preferences.xml

9
app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java

@ -4,6 +4,8 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.widget.Toast; import android.widget.Toast;
import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.bottomnavigation.BottomNavigationView;
@ -86,6 +88,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
initialFragmentTransaction.commit(); initialFragmentTransaction.commit();
bottomNavigation = findViewById(R.id.main_bottom_navigation); bottomNavigation = findViewById(R.id.main_bottom_navigation);
if (sessionManager.isLoggedIn()) bottomNavigation.inflateMenu(R.menu.bottom_navigation_logged_in);
bottomNavigation.setOnNavigationItemSelectedListener(menuItem -> { bottomNavigation.setOnNavigationItemSelectedListener(menuItem -> {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
switch (menuItem.getItemId()) { switch (menuItem.getItemId()) {
@ -236,6 +239,12 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
sectionsPagerAdapter.removeFragment(2); sectionsPagerAdapter.removeFragment(2);
else if (sessionManager.isLoggedIn() && sectionsPagerAdapter.getCount() == 2) else if (sessionManager.isLoggedIn() && sectionsPagerAdapter.getCount() == 2)
sectionsPagerAdapter.addFragment(UnreadFragment.newInstance(3), "UNREAD"); sectionsPagerAdapter.addFragment(UnreadFragment.newInstance(3), "UNREAD");
if (!sessionManager.isLoggedIn() && bottomNavigation.getMenu().size() > 2) {
bottomNavigation.getMenu().removeItem(R.id.action_shoutbox);
bottomNavigation.getMenu().removeItem(R.id.action_unread);
} else if (sessionManager.isLoggedIn() && bottomNavigation.getMenu().size() < 4) {
bottomNavigation.inflateMenu(R.menu.bottom_navigation_logged_in);
}
} }
//-------------------------------FragmentPagerAdapter END------------------------------------------- //-------------------------------FragmentPagerAdapter END-------------------------------------------

1
app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java

@ -57,6 +57,7 @@ public class ShoutAdapter extends CustomRecyclerView.Adapter<ShoutAdapter.ShoutV
Shout currentShout = shouts[position]; Shout currentShout = shouts[position];
holder.author.setText(currentShout.getShouter()); holder.author.setText(currentShout.getShouter());
if (currentShout.isMemberOfTheMonth()) holder.author.setTextColor(context.getResources().getColor(R.color.member_of_the_month)); if (currentShout.isMemberOfTheMonth()) holder.author.setTextColor(context.getResources().getColor(R.color.member_of_the_month));
else holder.author.setTextColor(context.getResources().getColor(R.color.accent));
holder.author.setOnClickListener(view -> { holder.author.setOnClickListener(view -> {
Intent intent = new Intent(context, ProfileActivity.class); Intent intent = new Intent(context, ProfileActivity.class);
Bundle extras = new Bundle(); Bundle extras = new Bundle();

2
app/src/main/res/layout/activity_main.xml

@ -30,6 +30,6 @@
android:background="@color/primary" android:background="@color/primary"
app:itemIconTint="@color/bottom_navigation_selector" app:itemIconTint="@color/bottom_navigation_selector"
app:itemTextColor="@color/bottom_navigation_selector" app:itemTextColor="@color/bottom_navigation_selector"
app:menu="@menu/bottom_navigation" app:menu="@menu/bottom_navigation_basic"
app:labelVisibilityMode="labeled"/> app:labelVisibilityMode="labeled"/>
</RelativeLayout> </RelativeLayout>

9
app/src/main/res/menu/bottom_navigation.xml → app/src/main/res/menu/bottom_navigation_basic.xml

@ -9,13 +9,4 @@
android:id="@+id/action_forum" android:id="@+id/action_forum"
android:icon="@drawable/ic_forum_white_24dp" android:icon="@drawable/ic_forum_white_24dp"
android:title="@string/forum" /> android:title="@string/forum" />
<item
android:id="@+id/action_unread"
android:icon="@drawable/ic_fiber_new_white_24dp"
android:title="@string/unread" />
<item
android:id="@+id/action_shoutbox"
android:icon="@drawable/ic_announcement"
android:title="@string/shoutbox" />
</menu> </menu>

11
app/src/main/res/menu/bottom_navigation_logged_in.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_unread"
android:icon="@drawable/ic_fiber_new_white_24dp"
android:title="@string/unread" />
<item
android:id="@+id/action_shoutbox"
android:icon="@drawable/ic_announcement"
android:title="@string/shoutbox" />
</menu>

10
app/src/main/res/xml/app_preferences.xml

@ -3,7 +3,7 @@
<androidx.preference.PreferenceCategory android:title="@string/pref_category_app"> <androidx.preference.PreferenceCategory android:title="@string/pref_category_app">
<android.support.v7.preference.ListPreference <ListPreference
android:defaultValue="0" android:defaultValue="0"
android:dialogTitle="@string/pref_app_main_default_tab_dialog_title" android:dialogTitle="@string/pref_app_main_default_tab_dialog_title"
android:entries="@array/pref_app_main_default_tab_entries" android:entries="@array/pref_app_main_default_tab_entries"
@ -22,12 +22,12 @@
android:summary="@string/pref_summary_notifications_enable" android:summary="@string/pref_summary_notifications_enable"
android:title="@string/pref_title_notifications_enable" />--> android:title="@string/pref_title_notifications_enable" />-->
<android.support.v7.preference.SwitchPreferenceCompat <androidx.preference.SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"
android:key="pref_notification_vibration_enable_key" android:key="pref_notification_vibration_enable_key"
android:title="@string/pref_title_notification_vibration_enable" /> android:title="@string/pref_title_notification_vibration_enable" />
<android.support.v7.preference.SwitchPreferenceCompat <androidx.preference.SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"
android:key="pref_notification_led_enable_key" android:key="pref_notification_led_enable_key"
android:summary="@string/pref_summary_notification_led_enable" android:summary="@string/pref_summary_notification_led_enable"
@ -44,7 +44,7 @@
android:key="pref_category_posting_key" android:key="pref_category_posting_key"
android:title="@string/pref_category_posting"> android:title="@string/pref_category_posting">
<android.support.v7.preference.SwitchPreferenceCompat <androidx.preference.SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"
android:key="pref_posting_app_signature_enable_key" android:key="pref_posting_app_signature_enable_key"
android:summary="@string/pref_summary_posting_app_signature_enable" android:summary="@string/pref_summary_posting_app_signature_enable"
@ -56,7 +56,7 @@
android:key="pref_category_uploading_key" android:key="pref_category_uploading_key"
android:title="@string/pref_category_uploading"> android:title="@string/pref_category_uploading">
<android.support.v7.preference.SwitchPreferenceCompat <androidx.preference.SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"
android:key="pref_uploading_app_signature_enable_key" android:key="pref_uploading_app_signature_enable_key"
android:summary="@string/pref_summary_uploading_app_signature_enable" android:summary="@string/pref_summary_uploading_app_signature_enable"

Loading…
Cancel
Save