|
@ -5,6 +5,8 @@ import android.content.SharedPreferences; |
|
|
import android.net.Uri; |
|
|
import android.net.Uri; |
|
|
import android.os.Build; |
|
|
import android.os.Build; |
|
|
import android.os.Bundle; |
|
|
import android.os.Bundle; |
|
|
|
|
|
import android.view.ViewGroup; |
|
|
|
|
|
import android.widget.LinearLayout; |
|
|
import android.widget.Toast; |
|
|
import android.widget.Toast; |
|
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatDelegate; |
|
|
import androidx.appcompat.app.AppCompatDelegate; |
|
@ -55,6 +57,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF |
|
|
private SectionsPagerAdapter sectionsPagerAdapter; |
|
|
private SectionsPagerAdapter sectionsPagerAdapter; |
|
|
private ViewPager viewPager; |
|
|
private ViewPager viewPager; |
|
|
private TabLayout tabLayout; |
|
|
private TabLayout tabLayout; |
|
|
|
|
|
private boolean displayCompactTabs; |
|
|
|
|
|
|
|
|
//Fix for vector drawables on android <21
|
|
|
//Fix for vector drawables on android <21
|
|
|
static { |
|
|
static { |
|
@ -82,9 +85,15 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF |
|
|
return; //Avoid executing the code below
|
|
|
return; //Avoid executing the code below
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
toolbar = findViewById(R.id.toolbar); |
|
|
displayCompactTabs = BaseApplication.getInstance().isDisplayCompactTabsEnabled(); |
|
|
toolbar.setTitle(""); |
|
|
|
|
|
setSupportActionBar(toolbar); |
|
|
if (displayCompactTabs) { |
|
|
|
|
|
toolbar = findViewById(R.id.toolbar); |
|
|
|
|
|
ViewGroup.LayoutParams currentParams = toolbar.getLayoutParams(); |
|
|
|
|
|
toolbar.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, currentParams.height)); |
|
|
|
|
|
toolbar.setTitle(""); |
|
|
|
|
|
setSupportActionBar(toolbar); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//Initialize drawer
|
|
|
//Initialize drawer
|
|
|
createDrawer(); |
|
|
createDrawer(); |
|
@ -108,8 +117,8 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF |
|
|
if ((preferredTab != 3 && preferredTab != 4) || sessionManager.isLoggedIn()) |
|
|
if ((preferredTab != 3 && preferredTab != 4) || sessionManager.isLoggedIn()) |
|
|
tabLayout.getTabAt(preferredTab).select(); |
|
|
tabLayout.getTabAt(preferredTab).select(); |
|
|
|
|
|
|
|
|
for (int i = 0; i < tabLayout.getTabCount(); i++) |
|
|
if (!displayCompactTabs) |
|
|
updateTabIcon(i); |
|
|
updateTabIcons(); |
|
|
|
|
|
|
|
|
setMainActivity(this); |
|
|
setMainActivity(this); |
|
|
} |
|
|
} |
|
@ -189,7 +198,8 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF |
|
|
fragmentList.add(fragment); |
|
|
fragmentList.add(fragment); |
|
|
fragmentTitleList.add(title); |
|
|
fragmentTitleList.add(title); |
|
|
notifyDataSetChanged(); |
|
|
notifyDataSetChanged(); |
|
|
updateTabIcon(fragmentList.size() - 1); |
|
|
if (!displayCompactTabs) |
|
|
|
|
|
updateTabIcon(fragmentList.size() - 1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void removeFragment(int position) { |
|
|
void removeFragment(int position) { |
|
@ -234,6 +244,10 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF |
|
|
tabLayout.getTabAt(2).setIcon(getResources().getDrawable(R.drawable.ic_fiber_new_white_24dp)); |
|
|
tabLayout.getTabAt(2).setIcon(getResources().getDrawable(R.drawable.ic_fiber_new_white_24dp)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void updateTabIcons() { |
|
|
|
|
|
for (int i = 0; i < tabLayout.getTabCount(); i++) |
|
|
|
|
|
updateTabIcon(i); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public void updateTabs() { |
|
|
public void updateTabs() { |
|
|
if (!sessionManager.isLoggedIn() && sectionsPagerAdapter.getCount() == 3) |
|
|
if (!sessionManager.isLoggedIn() && sectionsPagerAdapter.getCount() == 3) |
|
@ -241,8 +255,8 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF |
|
|
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"); |
|
|
|
|
|
|
|
|
for (int i = 0; i < tabLayout.getTabCount(); i++) |
|
|
if (!displayCompactTabs) |
|
|
updateTabIcon(i); |
|
|
updateTabIcons(); |
|
|
} |
|
|
} |
|
|
//-------------------------------FragmentPagerAdapter END-------------------------------------------
|
|
|
//-------------------------------FragmentPagerAdapter END-------------------------------------------
|
|
|
|
|
|
|
|
|