Merge branch 'theZacAttacks-account_header_image_click_opens_account'
This commit is contained in:
commit
3db2eede07
|
@ -49,6 +49,7 @@ import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
|
||||||
import com.mikepenz.materialdrawer.model.ProfileDrawerItem;
|
import com.mikepenz.materialdrawer.model.ProfileDrawerItem;
|
||||||
import com.mikepenz.materialdrawer.model.SecondaryDrawerItem;
|
import com.mikepenz.materialdrawer.model.SecondaryDrawerItem;
|
||||||
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
|
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
|
||||||
|
import com.mikepenz.materialdrawer.model.interfaces.IProfile;
|
||||||
import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader;
|
import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader;
|
||||||
import com.mikepenz.materialdrawer.util.DrawerImageLoader;
|
import com.mikepenz.materialdrawer.util.DrawerImageLoader;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
|
@ -77,6 +78,8 @@ public class MainActivity extends BaseActivity {
|
||||||
@BindView(R.id.tab_layout) TabLayout tabLayout;
|
@BindView(R.id.tab_layout) TabLayout tabLayout;
|
||||||
@BindView(R.id.pager) ViewPager viewPager;
|
@BindView(R.id.pager) ViewPager viewPager;
|
||||||
|
|
||||||
|
static FloatingActionButton composeBtn;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -176,6 +179,8 @@ public class MainActivity extends BaseActivity {
|
||||||
|
|
||||||
// Setup push notifications
|
// Setup push notifications
|
||||||
if (arePushNotificationsEnabled()) enablePushNotifications();
|
if (arePushNotificationsEnabled()) enablePushNotifications();
|
||||||
|
|
||||||
|
composeBtn = floatingBtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -208,6 +213,23 @@ public class MainActivity extends BaseActivity {
|
||||||
.withActivity(this)
|
.withActivity(this)
|
||||||
.withSelectionListEnabledForSingleProfile(false)
|
.withSelectionListEnabledForSingleProfile(false)
|
||||||
.withDividerBelowHeader(false)
|
.withDividerBelowHeader(false)
|
||||||
|
.withOnAccountHeaderProfileImageListener(new AccountHeader.OnAccountHeaderProfileImageListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onProfileImageClick(View view, IProfile profile, boolean current) {
|
||||||
|
if (current && loggedInAccountId != null) {
|
||||||
|
Intent intent = new Intent(MainActivity.this, AccountActivity.class);
|
||||||
|
intent.putExtra("id", loggedInAccountId);
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onProfileImageLongClick(View view, IProfile profile, boolean current) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
.withCompactStyle(true)
|
.withCompactStyle(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,12 @@
|
||||||
package com.keylesspalace.tusky;
|
package com.keylesspalace.tusky;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.design.widget.TabLayout;
|
import android.support.design.widget.TabLayout;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.widget.DividerItemDecoration;
|
import android.support.v7.widget.DividerItemDecoration;
|
||||||
|
@ -85,7 +88,7 @@ public class TimelineFragment extends SFragment implements
|
||||||
hashtagOrId = arguments.getString("hashtag_or_id");
|
hashtagOrId = arguments.getString("hashtag_or_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
View rootView = inflater.inflate(R.layout.fragment_timeline, container, false);
|
final View rootView = inflater.inflate(R.layout.fragment_timeline, container, false);
|
||||||
|
|
||||||
// Setup the SwipeRefreshLayout.
|
// Setup the SwipeRefreshLayout.
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
|
@ -103,6 +106,20 @@ public class TimelineFragment extends SFragment implements
|
||||||
divider.setDrawable(drawable);
|
divider.setDrawable(drawable);
|
||||||
recyclerView.addItemDecoration(divider);
|
recyclerView.addItemDecoration(divider);
|
||||||
scrollListener = new EndlessOnScrollListener(layoutManager) {
|
scrollListener = new EndlessOnScrollListener(layoutManager) {
|
||||||
|
@Override
|
||||||
|
public void onScrolled(RecyclerView view, int dx, int dy) {
|
||||||
|
super.onScrolled(view, dx, dy);
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
|
|
||||||
|
if (dy > 0 && prefs.getBoolean("fabHide", false) && MainActivity.composeBtn.isShown()) {
|
||||||
|
MainActivity.composeBtn.hide(); // hides the button if we're scrolling down
|
||||||
|
} else if (dy < 0 && prefs.getBoolean("fabHide", false) && !MainActivity.composeBtn.isShown()) {
|
||||||
|
MainActivity.composeBtn.show(); // shows it if we are scrolling up
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
|
public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
|
||||||
TimelineAdapter adapter = (TimelineAdapter) view.getAdapter();
|
TimelineAdapter adapter = (TimelineAdapter) view.getAdapter();
|
||||||
|
|
|
@ -9,6 +9,11 @@
|
||||||
android:title="@string/pref_title_light_theme"
|
android:title="@string/pref_title_light_theme"
|
||||||
android:defaultValue="false" />
|
android:defaultValue="false" />
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="fabHide"
|
||||||
|
android:title="Hide FAB while scrolling"
|
||||||
|
android:defaultValue="false" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/pref_title_browser_settings">
|
<PreferenceCategory android:title="@string/pref_title_browser_settings">
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
|
Loading…
Reference in New Issue