mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-25 10:28:22 +01:00
Add a BottomAppBar to navigate to subscriptions and multireddits.
This commit is contained in:
parent
ee02d63345
commit
5097919a36
@ -45,6 +45,7 @@ import com.bumptech.glide.RequestManager;
|
|||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
|
import com.google.android.material.bottomappbar.BottomAppBar;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
|
|
||||||
@ -162,6 +163,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
TabLayout tabLayout;
|
TabLayout tabLayout;
|
||||||
@BindView(R.id.fab_main_activity)
|
@BindView(R.id.fab_main_activity)
|
||||||
FloatingActionButton fab;
|
FloatingActionButton fab;
|
||||||
|
@BindView(R.id.bottom_navigation_main_activity)
|
||||||
|
BottomAppBar bottomNavigationView;
|
||||||
|
@BindView(R.id.subscriptions_bottom_app_bar_main_activity)
|
||||||
|
TextView subscriptionsBottomAppBar;
|
||||||
|
@BindView(R.id.multi_reddit_bottom_app_bar_main_activity)
|
||||||
|
TextView multiRedditBottomAppBar;
|
||||||
AccountViewModel accountViewModel;
|
AccountViewModel accountViewModel;
|
||||||
@Inject
|
@Inject
|
||||||
@Named("oauth")
|
@Named("oauth")
|
||||||
@ -353,20 +360,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
mNewAccountName = null;
|
mNewAccountName = null;
|
||||||
if (newAccount == null) {
|
if (newAccount == null) {
|
||||||
mNullAccessToken = true;
|
mNullAccessToken = true;
|
||||||
|
|
||||||
if (mMenu != null) {
|
|
||||||
mMenu.findItem(R.id.action_subscriptions_main_activity).setVisible(false);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
mAccessToken = newAccount.getAccessToken();
|
mAccessToken = newAccount.getAccessToken();
|
||||||
mAccountName = newAccount.getUsername();
|
mAccountName = newAccount.getUsername();
|
||||||
mProfileImageUrl = newAccount.getProfileImageUrl();
|
mProfileImageUrl = newAccount.getProfileImageUrl();
|
||||||
mBannerImageUrl = newAccount.getBannerImageUrl();
|
mBannerImageUrl = newAccount.getBannerImageUrl();
|
||||||
mKarma = newAccount.getKarma();
|
mKarma = newAccount.getKarma();
|
||||||
|
|
||||||
if (mMenu != null) {
|
|
||||||
mMenu.findItem(R.id.action_subscriptions_main_activity).setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableNotification) {
|
if (enableNotification) {
|
||||||
@ -395,10 +394,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
mBannerImageUrl = account.getBannerImageUrl();
|
mBannerImageUrl = account.getBannerImageUrl();
|
||||||
mKarma = account.getKarma();
|
mKarma = account.getKarma();
|
||||||
|
|
||||||
if (mMenu != null) {
|
|
||||||
mMenu.findItem(R.id.action_subscriptions_main_activity).setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enableNotification) {
|
if (enableNotification) {
|
||||||
Constraints constraints = new Constraints.Builder()
|
Constraints constraints = new Constraints.Builder()
|
||||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||||
@ -421,20 +416,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
} else {
|
} else {
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
mNullAccessToken = true;
|
mNullAccessToken = true;
|
||||||
|
|
||||||
if (mMenu != null) {
|
|
||||||
mMenu.findItem(R.id.action_subscriptions_main_activity).setVisible(false);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
mAccessToken = account.getAccessToken();
|
mAccessToken = account.getAccessToken();
|
||||||
mAccountName = account.getUsername();
|
mAccountName = account.getUsername();
|
||||||
mProfileImageUrl = account.getProfileImageUrl();
|
mProfileImageUrl = account.getProfileImageUrl();
|
||||||
mBannerImageUrl = account.getBannerImageUrl();
|
mBannerImageUrl = account.getBannerImageUrl();
|
||||||
mKarma = account.getKarma();
|
mKarma = account.getKarma();
|
||||||
|
|
||||||
if (mMenu != null) {
|
|
||||||
mMenu.findItem(R.id.action_subscriptions_main_activity).setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableNotification) {
|
if (enableNotification) {
|
||||||
@ -464,6 +451,21 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mAccessToken == null) {
|
||||||
|
bottomNavigationView.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
bottomNavigationView.setVisibility(View.VISIBLE);
|
||||||
|
subscriptionsBottomAppBar.setOnClickListener(view -> {
|
||||||
|
Intent intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
});
|
||||||
|
|
||||||
|
multiRedditBottomAppBar.setOnClickListener(view -> {
|
||||||
|
Intent intent = new Intent(MainActivity.this, MultiRedditListingActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||||
viewPager.setAdapter(sectionsPagerAdapter);
|
viewPager.setAdapter(sectionsPagerAdapter);
|
||||||
viewPager.setOffscreenPageLimit(3);
|
viewPager.setOffscreenPageLimit(3);
|
||||||
@ -783,13 +785,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
getMenuInflater().inflate(R.menu.main_activity, menu);
|
getMenuInflater().inflate(R.menu.main_activity, menu);
|
||||||
mMenu = menu;
|
mMenu = menu;
|
||||||
MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_main_activity);
|
MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_main_activity);
|
||||||
MenuItem subscriptionsItem = mMenu.findItem(R.id.action_subscriptions_main_activity);
|
|
||||||
|
|
||||||
if (mAccessToken != null) {
|
|
||||||
subscriptionsItem.setVisible(true);
|
|
||||||
} else {
|
|
||||||
subscriptionsItem.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isInLazyMode) {
|
if (isInLazyMode) {
|
||||||
lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
|
lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
|
||||||
@ -807,12 +802,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.action_subscriptions_main_activity:
|
|
||||||
/*Intent subscriptionsIntent = new Intent(this, SubscribedThingListingActivity.class);
|
|
||||||
startActivity(subscriptionsIntent);*/
|
|
||||||
Intent multiIntent = new Intent(this, MultiRedditListingActivity.class);
|
|
||||||
startActivity(multiIntent);
|
|
||||||
return true;
|
|
||||||
case R.id.action_sort_main_activity:
|
case R.id.action_sort_main_activity:
|
||||||
if (viewPager.getCurrentItem() == 1 || viewPager.getCurrentItem() == 2) {
|
if (viewPager.getCurrentItem() == 1 || viewPager.getCurrentItem() == 2) {
|
||||||
popularAndAllSortTypeBottomSheetFragment.show(getSupportFragmentManager(), popularAndAllSortTypeBottomSheetFragment.getTag());
|
popularAndAllSortTypeBottomSheetFragment.show(getSupportFragmentManager(), popularAndAllSortTypeBottomSheetFragment.getTag());
|
||||||
@ -935,11 +924,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void postScrollUp() {
|
public void postScrollUp() {
|
||||||
|
bottomNavigationView.performShow();
|
||||||
fab.show();
|
fab.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postScrollDown() {
|
public void postScrollDown() {
|
||||||
fab.hide();
|
fab.hide();
|
||||||
|
bottomNavigationView.performHide();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 138 B |
Binary file not shown.
Before Width: | Height: | Size: 92 B |
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M18,13h-5v5c0,0.55 -0.45,1 -1,1s-1,-0.45 -1,-1v-5H6c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1h5V6c0,-0.55 0.45,-1 1,-1s1,0.45 1,1v5h5c0.55,0 1,0.45 1,1s-0.45,1 -1,1z"/>
|
||||||
|
</vector>
|
Binary file not shown.
Before Width: | Height: | Size: 97 B |
Binary file not shown.
Before Width: | Height: | Size: 97 B |
Binary file not shown.
Before Width: | Height: | Size: 102 B |
9
app/src/main/res/drawable/ic_add_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_add_24dp.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M18,13h-5v5c0,0.55 -0.45,1 -1,1s-1,-0.45 -1,-1v-5H6c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1h5V6c0,-0.55 0.45,-1 1,-1s1,0.45 1,1v5h5c0.55,0 1,0.45 1,1s-0.45,1 -1,1z"/>
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/ic_add_bottom_app_bar_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_add_bottom_app_bar_24dp.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#8A000000"
|
||||||
|
android:pathData="M18,13h-5v5c0,0.55 -0.45,1 -1,1s-1,-0.45 -1,-1v-5H6c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1h5V6c0,-0.55 0.45,-1 1,-1s1,0.45 1,1v5h5c0.55,0 1,0.45 1,1s-0.45,1 -1,1z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#8A000000"
|
||||||
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM16.59,7.58L10,14.17l-2.59,-2.58L6,13l4,4 8,-8z"/>
|
||||||
|
</vector>
|
@ -132,6 +132,6 @@
|
|||||||
android:layout_margin="@dimen/fab_margin"
|
android:layout_margin="@dimen/fab_margin"
|
||||||
app:backgroundTint="@color/backgroundColorPrimary"
|
app:backgroundTint="@color/backgroundColorPrimary"
|
||||||
app:tint="@android:color/white"
|
app:tint="@android:color/white"
|
||||||
app:srcCompat="@drawable/baseline_add_white_24" />
|
app:srcCompat="@drawable/ic_add_24dp" />
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
@ -56,14 +56,63 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
|
|
||||||
|
<com.google.android.material.bottomappbar.BottomAppBar
|
||||||
|
android:id="@+id/bottom_navigation_main_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:gravity="center"
|
||||||
|
app:backgroundTint="?attr/backgroundColor"
|
||||||
|
app:layout_anchorGravity="start"
|
||||||
|
app:fabAnimationMode="scale"
|
||||||
|
app:fabAlignmentMode="center">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:weightSum="3"
|
||||||
|
android:paddingStart="0dp"
|
||||||
|
android:paddingEnd="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/subscriptions_bottom_app_bar_main_activity"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:drawableTop="@drawable/ic_outline_check_circle_outline_bottom_app_bar_24dp"
|
||||||
|
android:text="@string/subscriptions"
|
||||||
|
android:textColor="@color/defaultTextColor"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@android:color/transparent"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/multi_reddit_bottom_app_bar_main_activity"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:drawableTop="@drawable/ic_outline_check_circle_outline_bottom_app_bar_24dp"
|
||||||
|
android:text="@string/multi_reddit_listing_activity"
|
||||||
|
android:textColor="@color/defaultTextColor"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</com.google.android.material.bottomappbar.BottomAppBar>
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/fab_main_activity"
|
android:id="@+id/fab_main_activity"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom|end"
|
|
||||||
android:layout_margin="@dimen/fab_margin"
|
android:layout_margin="@dimen/fab_margin"
|
||||||
app:backgroundTint="@color/backgroundColorPrimary"
|
app:backgroundTint="?attr/backgroundColor"
|
||||||
app:tint="@android:color/white"
|
app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp"
|
||||||
app:srcCompat="@drawable/baseline_add_white_24" />
|
app:tint="@null"
|
||||||
|
app:layout_anchor="@id/bottom_navigation_main_activity" />
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:src="@drawable/baseline_add_white_24"
|
android:src="@drawable/ic_add_24dp"
|
||||||
android:tint="@color/colorPrimaryDarkDayNightTheme"
|
android:tint="@color/colorPrimaryDarkDayNightTheme"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:src="@drawable/baseline_add_white_24"
|
android:src="@drawable/ic_add_24dp"
|
||||||
android:tint="@color/colorPrimaryDarkDayNightTheme"
|
android:tint="@color/colorPrimaryDarkDayNightTheme"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
@ -3,43 +3,36 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:application="ml.docilealligator.infinityforreddit.Activity.MainActivity">
|
tools:application="ml.docilealligator.infinityforreddit.Activity.MainActivity">
|
||||||
<item
|
|
||||||
android:id="@+id/action_subscriptions_main_activity"
|
|
||||||
android:orderInCategory="1"
|
|
||||||
android:title="@string/action_subscriptions"
|
|
||||||
android:icon="@drawable/ic_outline_check_circle_outline_white_24px"
|
|
||||||
app:showAsAction="ifRoom"
|
|
||||||
android:visible="false"/>
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_search_main_activity"
|
android:id="@+id/action_search_main_activity"
|
||||||
android:orderInCategory="2"
|
android:orderInCategory="1"
|
||||||
android:title="@string/action_search"
|
android:title="@string/action_search"
|
||||||
android:icon="@drawable/ic_search_white_24dp"
|
android:icon="@drawable/ic_search_white_24dp"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_sort_main_activity"
|
android:id="@+id/action_sort_main_activity"
|
||||||
android:orderInCategory="3"
|
android:orderInCategory="2"
|
||||||
android:title="@string/action_sort"
|
android:title="@string/action_sort"
|
||||||
android:icon="@drawable/ic_outline_sort_24px"
|
android:icon="@drawable/ic_outline_sort_24px"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_refresh_main_activity"
|
android:id="@+id/action_refresh_main_activity"
|
||||||
android:orderInCategory="4"
|
android:orderInCategory="3"
|
||||||
android:title="@string/action_refresh"
|
android:title="@string/action_refresh"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_lazy_mode_main_activity"
|
android:id="@+id/action_lazy_mode_main_activity"
|
||||||
android:orderInCategory="5"
|
android:orderInCategory="4"
|
||||||
android:title="@string/action_start_lazy_mode"
|
android:title="@string/action_start_lazy_mode"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_change_post_layout_main_activity"
|
android:id="@+id/action_change_post_layout_main_activity"
|
||||||
android:orderInCategory="6"
|
android:orderInCategory="5"
|
||||||
android:title="@string/action_change_post_layout"
|
android:title="@string/action_change_post_layout"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
Loading…
Reference in New Issue
Block a user