Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrollbar accent color bugfix [#570] #608

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void onNothingSelected(AdapterView<?> adapterView) {}
contentView.findViewById(R.id.rl_bottom_sheet_title).setBackgroundColor(theme.getPrimaryColor());
exploreModePanel.setBackgroundColor(theme.getPrimaryColor());
contentView.findViewById(R.id.ll_select_folder).setBackgroundColor(theme.getCardBackgroundColor());
theme.setColorScrollBarDrawable(ContextCompat.getDrawable(dialog.getContext(), R.drawable.ic_scrollbar));
// theme.setColorScrollBarDrawable(ContextCompat.getDrawable(dialog.getContext(), R.drawable.ic_scrollbar));
mRecyclerView.setBackgroundColor(theme.getBackgroundColor());

fabDone = contentView.findViewById(R.id.fab_bottomsheet_done);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
unbinder = ButterKnife.bind(this);

initUi();
pickMode = getIntent().getBooleanExtra(ARGS_PICK_MODE, false);

Expand Down Expand Up @@ -372,7 +371,7 @@ public void updateUiElements() {
mainLayout.setBackgroundColor(getBackgroundColor());

// setScrollViewColor(navigationDrawerView);
setAllScrollbarsColor();
// setAllScrollbarsColor();

navigationDrawerView.setTheme(getPrimaryColor(), getBackgroundColor(), getTextColor(), getIconColor());

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package org.horaapps.leafpic.adapters;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.support.annotation.ColorInt;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import com.orhanobut.hawk.Hawk;
import org.horaapps.leafpic.R;


/**
* This class is used to create a recyclerview that has a scrollbar that matches the color of the chosen accent color.
* The need for this class arises because the native method of setting a recyclerview scrollbar color is set to a drawable,
* that doesn't have a dynamic way to change colors.
*
* Edited by Bharadwaj Giridhar on April 9,2020
**/

public class CustomRecyclerView extends RecyclerView {

private int scrollBarColor = Hawk.get(getResources().getString(R.string.preference_accent_color));

public CustomRecyclerView(Context context) {
super(context);
}

public CustomRecyclerView(Context context, AttributeSet attrs) {
super(context, attrs);
}

public CustomRecyclerView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}

public void setScrollBarColor(@ColorInt int scrollBarColor) {
this.scrollBarColor = scrollBarColor;
}

/**
* Called by Android {@link android.view.View#onDrawScrollBars(Canvas)}
**/
protected void onDrawHorizontalScrollBar(Canvas canvas, Drawable scrollBar, int l, int t, int r, int b) {
scrollBar.setColorFilter(scrollBarColor, PorterDuff.Mode.SRC_ATOP);
scrollBar.setBounds(l, t, r, b);
scrollBar.draw(canvas);
}

/**
* Called by Android {@link android.view.View#onDrawScrollBars(Canvas)}
**/
protected void onDrawVerticalScrollBar(Canvas canvas, Drawable scrollBar, int l, int t, int r, int b) {
scrollBar.setColorFilter(scrollBarColor, PorterDuff.Mode.SRC_ATOP);
scrollBar.setBounds(l, t, r, b);
scrollBar.draw(canvas);
}
}
5 changes: 2 additions & 3 deletions app/src/main/res/layout/activity_black_white_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@

</android.support.v7.widget.CardView>

<android.support.v7.widget.RecyclerView
<org.horaapps.leafpic.adapters.CustomRecyclerView
android:id="@+id/excluded_albums"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:scrollbarThumbVertical="@drawable/ic_scrollbar" />
android:scrollbars="vertical"/>

</LinearLayout>
</RelativeLayout>
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/layout/fragment_albums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
<org.horaapps.leafpic.adapters.CustomRecyclerView
android:id="@+id/albums"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:clipToPadding="false"
android:scrollbars="vertical"
android:scrollbarThumbVertical="@drawable/ic_scrollbar" />
android:scrollbars="vertical" />

</android.support.v4.widget.SwipeRefreshLayout>
6 changes: 3 additions & 3 deletions app/src/main/res/layout/fragment_rv_media.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
<org.horaapps.leafpic.adapters.CustomRecyclerView
android:id="@+id/media"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:clipToPadding="false"
android:scrollbars="vertical"
android:scrollbarThumbVertical="@drawable/ic_scrollbar" />
android:scrollbars="vertical"/>

</android.support.v4.widget.SwipeRefreshLayout>
3 changes: 1 addition & 2 deletions app/src/main/res/layout/fragment_timeline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
<org.horaapps.leafpic.adapters.CustomRecyclerView
android:id="@+id/timeline_items"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/timeline_decorator_spacing"
android:paddingLeft="@dimen/timeline_decorator_spacing"
android:paddingRight="@dimen/timeline_decorator_spacing"
android:paddingTop="@dimen/timeline_decorator_spacing"
android:scrollbarThumbVertical="@drawable/ic_scrollbar"
android:scrollbars="vertical" />

</android.support.v4.widget.SwipeRefreshLayout>
5 changes: 2 additions & 3 deletions app/src/main/res/layout/select_folder_bottom_sheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,12 @@

<!-- ITEMS RECYCLE VIEW -->

<android.support.v7.widget.RecyclerView
<org.horaapps.leafpic.adapters.CustomRecyclerView
android:id="@+id/folders"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="400dp"
android:scrollbars="vertical"
android:scrollbarThumbVertical="@drawable/ic_scrollbar" />
android:scrollbars="vertical"/>

</LinearLayout>

Expand Down