Fixes scrollbars, updates libraries

parent b9b138e5
Pipeline #242 passed with stages
in 14 minutes and 48 seconds
......@@ -110,7 +110,7 @@ android {
}
dependencies {
implementation(kotlin("stdlib", "1.2.50"))
implementation(kotlin("stdlib", "1.2.51"))
// App Compat
withVersion("27.1.1") {
......@@ -166,7 +166,6 @@ dependencies {
// UI
implementation("me.zhanghai.android.materialprogressbar", "library", "1.4.2")
implementation("com.simplecityapps", "recyclerview-fastscroll", "1.0.18")
withVersion("0.9.6.0") {
implementation("com.afollestad.material-dialogs", "core", version)
implementation("com.afollestad.material-dialogs", "commons", version)
......
......@@ -161,7 +161,7 @@
},
{
"name": "Kotlin Standard Library",
"version": "1.2.50",
"version": "1.2.51",
"license": {
"short_name": "Apache-2.0",
"full_name": "Apache License"
......
......@@ -29,7 +29,6 @@ import android.widget.ImageView
import android.widget.TextView
import butterknife.BindView
import butterknife.ButterKnife
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
import de.kuschku.libquassel.protocol.BufferId
import de.kuschku.libquassel.protocol.Buffer_Activity
import de.kuschku.libquassel.protocol.NetworkId
......@@ -39,6 +38,7 @@ import de.kuschku.quasseldroid.R
import de.kuschku.quasseldroid.settings.MessageSettings
import de.kuschku.quasseldroid.util.helper.*
import de.kuschku.quasseldroid.util.lists.ListAdapter
import de.kuschku.quasseldroid.util.ui.fastscroll.views.FastScrollRecyclerView
import de.kuschku.quasseldroid.viewmodel.data.BufferListItem
import de.kuschku.quasseldroid.viewmodel.data.BufferProps
import de.kuschku.quasseldroid.viewmodel.data.BufferState
......
......@@ -29,7 +29,6 @@ import android.widget.ImageView
import android.widget.TextView
import butterknife.BindView
import butterknife.ButterKnife
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
import de.kuschku.libquassel.util.helpers.nullIf
import de.kuschku.quasseldroid.R
import de.kuschku.quasseldroid.settings.MessageSettings
......@@ -37,6 +36,7 @@ import de.kuschku.quasseldroid.util.helper.letIf
import de.kuschku.quasseldroid.util.helper.loadAvatars
import de.kuschku.quasseldroid.util.helper.visibleIf
import de.kuschku.quasseldroid.util.ui.SpanFormatter
import de.kuschku.quasseldroid.util.ui.fastscroll.views.FastScrollRecyclerView
import de.kuschku.quasseldroid.viewmodel.data.IrcUserItem
class NickListAdapter(
......
......@@ -227,7 +227,7 @@ class AboutFragment : DaggerFragment() {
),
Library(
name = "Kotlin Standard Library",
version = "1.2.50",
version = "1.2.51",
license = apache2,
url = "https://kotlinlang.org/"
),
......
......@@ -29,7 +29,7 @@ interface MatrixApi {
@GET("/_matrix/client/r0/profile/{name}/avatar_url")
fun avatarUrl(@Path("name") name: String): Call<MatrixAvatarResponse>
@GET("/_matrix/media/r0/thumbnail/{server}/{id}/?width=32&height=32&method=crop")
@GET("/_matrix/media/r0/thumbnail/{server}/{id}/?width={width}&height={height}&method={method]")
fun avatarThumbnail(
@Path("server") server: String,
@Path("id") id: String,
......
......@@ -25,8 +25,8 @@ import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.support.v4.view.ViewCompat
import android.util.AttributeSet
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
import de.kuschku.quasseldroid.R
import de.kuschku.quasseldroid.util.ui.fastscroll.views.FastScrollRecyclerView
class DrawerRecyclerView @JvmOverloads constructor(
context: Context,
......
package de.kuschku.quasseldroid.util.ui.fastscroll.interfaces;
public interface OnFastScrollStateChangeListener {
/**
* Called when fast scrolling begins
*/
void onFastScrollStart();
/**
* Called when fast scrolling ends
*/
void onFastScrollStop();
}
/*
* Copyright (c) 2016 Tim Malseed
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.kuschku.quasseldroid.util.ui.fastscroll.utils;
import android.annotation.TargetApi;
import android.content.res.Resources;
import android.os.Build;
import android.util.TypedValue;
import android.view.View;
public class Utils {
/**
* Converts dp to px
*
* @param res Resources
* @param dp the value in dp
* @return int
*/
public static int toPixels(Resources res, float dp) {
return (int) (dp * res.getDisplayMetrics().density);
}
/**
* Converts sp to px
*
* @param res Resources
* @param sp the value in sp
* @return int
*/
public static int toScreenPixels(Resources res, float sp) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, res.getDisplayMetrics());
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static boolean isRtl(Resources res) {
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) &&
(res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
}
}
/*
* Copyright (c) 2016 Tim Malseed
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.kuschku.quasseldroid.util.ui.fastscroll.views;
import android.animation.ObjectAnimator;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.support.annotation.Keep;
import android.text.TextUtils;
import de.kuschku.quasseldroid.util.ui.fastscroll.utils.Utils;
public class FastScrollPopup {
private FastScrollRecyclerView mRecyclerView;
private Resources mRes;
private int mBackgroundSize;
private int mCornerRadius;
private Path mBackgroundPath = new Path();
private RectF mBackgroundRect = new RectF();
private Paint mBackgroundPaint;
private int mBackgroundColor = 0xff000000;
private Rect mInvalidateRect = new Rect();
private Rect mTmpRect = new Rect();
// The absolute bounds of the fast scroller bg
private Rect mBgBounds = new Rect();
private String mSectionName;
private Paint mTextPaint;
private Rect mTextBounds = new Rect();
private float mAlpha = 1;
private ObjectAnimator mAlphaAnimator;
private boolean mVisible;
@FastScroller.FastScrollerPopupPosition
private int mPosition;
FastScrollPopup(Resources resources, FastScrollRecyclerView recyclerView) {
mRes = resources;
mRecyclerView = recyclerView;
mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTextPaint.setAlpha(0);
setTextSize(Utils.toScreenPixels(mRes, 44));
setBackgroundSize(Utils.toPixels(mRes, 88));
}
public void setBgColor(int color) {
mBackgroundColor = color;
mBackgroundPaint.setColor(color);
mRecyclerView.invalidate(mBgBounds);
}
public void setTextColor(int color) {
mTextPaint.setColor(color);
mRecyclerView.invalidate(mBgBounds);
}
public void setTextSize(int size) {
mTextPaint.setTextSize(size);
mRecyclerView.invalidate(mBgBounds);
}
public void setBackgroundSize(int size) {
mBackgroundSize = size;
mCornerRadius = mBackgroundSize / 2;
mRecyclerView.invalidate(mBgBounds);
}
public void setTypeface(Typeface typeface) {
mTextPaint.setTypeface(typeface);
mRecyclerView.invalidate(mBgBounds);
}
/**
* Animates the visibility of the fast scroller popup.
*/
public void animateVisibility(boolean visible) {
if (mVisible != visible) {
mVisible = visible;
if (mAlphaAnimator != null) {
mAlphaAnimator.cancel();
}
mAlphaAnimator = ObjectAnimator.ofFloat(this, "alpha", visible ? 1f : 0f);
mAlphaAnimator.setDuration(visible ? 200 : 150);
mAlphaAnimator.start();
}
}
@Keep
public float getAlpha() {
return mAlpha;
}
// Setter/getter for the popup alpha for animations
@Keep
public void setAlpha(float alpha) {
mAlpha = alpha;
mRecyclerView.invalidate(mBgBounds);
}
@FastScroller.FastScrollerPopupPosition
public int getPopupPosition() {
return mPosition;
}
public void setPopupPosition(@FastScroller.FastScrollerPopupPosition int position) {
mPosition = position;
}
private float[] createRadii() {
if (mPosition == FastScroller.FastScrollerPopupPosition.CENTER) {
return new float[]{mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius};
}
if (Utils.isRtl(mRes)) {
return new float[]{mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, 0, 0};
} else {
return new float[]{mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, 0, 0, mCornerRadius, mCornerRadius};
}
}
public void draw(Canvas canvas) {
if (isVisible()) {
// Draw the fast scroller popup
int restoreCount = canvas.save();
canvas.translate(mBgBounds.left, mBgBounds.top);
mTmpRect.set(mBgBounds);
mTmpRect.offsetTo(0, 0);
mBackgroundPath.reset();
mBackgroundRect.set(mTmpRect);
float[] radii = createRadii();
mBackgroundPath.addRoundRect(mBackgroundRect, radii, Path.Direction.CW);
mBackgroundPaint.setAlpha((int) (Color.alpha(mBackgroundColor) * mAlpha));
mTextPaint.setAlpha((int) (mAlpha * 255));
canvas.drawPath(mBackgroundPath, mBackgroundPaint);
canvas.drawText(mSectionName, (mBgBounds.width() - mTextBounds.width()) / 2,
mBgBounds.height() - (mBgBounds.height() - mTextBounds.height()) / 2,
mTextPaint);
canvas.restoreToCount(restoreCount);
}
}
public void setSectionName(String sectionName) {
if (!sectionName.equals(mSectionName)) {
mSectionName = sectionName;
mTextPaint.getTextBounds(sectionName, 0, sectionName.length(), mTextBounds);
// Update the width to use measureText since that is more accurate
mTextBounds.right = (int) (mTextBounds.left + mTextPaint.measureText(sectionName));
}
}
/**
* Updates the bounds for the fast scroller.
*
* @return the invalidation rect for this update.
*/
public Rect updateFastScrollerBounds(FastScrollRecyclerView recyclerView, int thumbOffsetY) {
mInvalidateRect.set(mBgBounds);
mBgBounds.top += recyclerView.getPaddingTop();
mBgBounds.left += recyclerView.getPaddingLeft();
mBgBounds.right -= recyclerView.getPaddingRight();
mBgBounds.bottom -= recyclerView.getPaddingBottom();
if (isVisible()) {
// Calculate the dimensions and position of the fast scroller popup
int edgePadding = recyclerView.getScrollBarWidth();
int bgPadding = Math.round((mBackgroundSize - mTextBounds.height()) / 10) * 5;
int bgHeight = mBackgroundSize;
int bgWidth = Math.max(mBackgroundSize, mTextBounds.width() + (2 * bgPadding));
if (mPosition == FastScroller.FastScrollerPopupPosition.CENTER) {
mBgBounds.left = (recyclerView.getWidth() - bgWidth) / 2;
mBgBounds.right = mBgBounds.left + bgWidth;
mBgBounds.top = (recyclerView.getHeight() - bgHeight) / 2;
} else {
if (Utils.isRtl(mRes)) {
mBgBounds.left = (2 * recyclerView.getScrollBarWidth());
mBgBounds.right = mBgBounds.left + bgWidth;
} else {
mBgBounds.right = recyclerView.getWidth() - (2 * recyclerView.getScrollBarWidth());
mBgBounds.left = mBgBounds.right - bgWidth;
}
mBgBounds.top = recyclerView.getPaddingTop() + thumbOffsetY - bgHeight + recyclerView.getScrollBarThumbHeight() / 2;
mBgBounds.top = Math.max(edgePadding + recyclerView.getPaddingTop(), Math.min(mBgBounds.top, recyclerView.getHeight() - edgePadding - bgHeight - recyclerView.getPaddingBottom()));
}
mBgBounds.bottom = mBgBounds.top + bgHeight;
} else {
mBgBounds.setEmpty();
}
// Combine the old and new fast scroller bounds to create the full invalidate rect
mInvalidateRect.union(mBgBounds);
return mInvalidateRect;
}
public boolean isVisible() {
return (mAlpha > 0f) && (!TextUtils.isEmpty(mSectionName));
}
}
......@@ -49,7 +49,7 @@
</android.support.design.widget.AppBarLayout>
<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
<de.kuschku.quasseldroid.util.ui.fastscroll.views.FastScrollRecyclerView
android:id="@+id/chatList"
style="@style/Widget.FastScroller"
android:layout_width="match_parent"
......
......@@ -88,4 +88,52 @@
<!-- InsetLayouts -->
<attr name="insetBackground" format="color|reference" />
<!-- DrawerRecyclerView -->
<declare-styleable name="DrawerRecyclerView">
<attr name="insetBackground" />
</declare-styleable>
<!-- ShadowView -->
<declare-styleable name="ShadowView">
<attr name="android:gravity" />
</declare-styleable>
<!-- RingtonePreference -->
<declare-styleable name="RingtonePreference">
<!-- Which ringtone type(s) to show in the picker. -->
<attr name="ringtoneType">
<!-- Ringtones. -->
<flag name="ringtone" value="1" />
<!-- Notification sounds. -->
<flag name="notification" value="2" />
<!-- Alarm sounds. -->
<flag name="alarm" value="4" />
<!-- All available ringtone sounds. -->
<flag name="all" value="7" />
</attr>
<!-- Whether to show an item for a default sound. -->
<attr name="showDefault" format="boolean" />
<!-- Whether to show an item for 'Silent'. -->
<attr name="showSilent" format="boolean" />
</declare-styleable>
<!-- FastScroll RecyclerView -->
<declare-styleable name="FastScrollRecyclerView">
<attr name="fastScrollThumbColor" format="reference|color" />
<attr name="fastScrollThumbInactiveColor" format="reference|color" />
<attr name="fastScrollTrackColor" format="reference|color" />
<attr name="fastScrollPopupBgColor" format="reference|color" />
<attr name="fastScrollPopupTextColor" format="reference|color" />
<attr name="fastScrollPopupTextSize" format="reference|dimension" />
<attr name="fastScrollPopupBackgroundSize" format="reference|dimension" />
<attr name="fastScrollPopupPosition" format="enum">
<enum name="adjacent" value="0" />
<enum name="center" value="1" />
</attr>
<attr name="fastScrollAutoHide" format="reference|boolean" />
<attr name="fastScrollAutoHideDelay" format="reference|integer" />
<attr name="fastScrollEnableThumbInactiveColor" format="reference|boolean" />
<attr name="fastScrollThumbEnabled" format="reference|boolean" />
</declare-styleable>
</resources>
......@@ -335,33 +335,4 @@
<style name="Widget.NavigationDrawerLayout" parent="">
<item name="insetBackground">#4000</item>
</style>
<!-- DrawerRecyclerView -->
<declare-styleable name="DrawerRecyclerView">
<attr name="insetBackground" />
</declare-styleable>
<!-- ShadowView -->
<declare-styleable name="ShadowView">
<attr name="android:gravity" />
</declare-styleable>
<!-- RingtonePreference -->
<declare-styleable name="RingtonePreference">
<!-- Which ringtone type(s) to show in the picker. -->
<attr name="ringtoneType">
<!-- Ringtones. -->
<flag name="ringtone" value="1" />
<!-- Notification sounds. -->
<flag name="notification" value="2" />
<!-- Alarm sounds. -->
<flag name="alarm" value="4" />
<!-- All available ringtone sounds. -->
<flag name="all" value="7" />
</attr>
<!-- Whether to show an item for a default sound. -->
<attr name="showDefault" format="boolean" />
<!-- Whether to show an item for 'Silent'. -->
<attr name="showSilent" format="boolean" />
</declare-styleable>
</resources>
......@@ -24,7 +24,7 @@ buildscript {
}
dependencies {
classpath("com.android.tools.build:gradle:3.1.3")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.50")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.51")
}
}
......
......@@ -29,7 +29,7 @@ plugins {
}
dependencies {
implementation(kotlin("stdlib", "1.2.50"))
implementation(kotlin("stdlib", "1.2.51"))
withVersion("27.1.1") {
implementation("com.android.support", "support-annotations", version)
......
......@@ -27,7 +27,7 @@ plugins {
}
dependencies {
implementation(kotlin("stdlib", "1.2.50"))
implementation(kotlin("stdlib", "1.2.51"))
withVersion("27.1.1") {
implementation("com.android.support", "support-annotations", version)
......
......@@ -45,7 +45,7 @@ android {
}
dependencies {
implementation(kotlin("stdlib", "1.2.50"))
implementation(kotlin("stdlib", "1.2.51"))
implementation("com.google.code.gson", "gson", "2.8.2")
}
......@@ -52,7 +52,7 @@ android {
}
dependencies {
implementation(kotlin("stdlib", "1.2.50"))
implementation(kotlin("stdlib", "1.2.51"))
// App Compat
withVersion("27.1.1") {
......
......@@ -45,7 +45,7 @@ android {
}
dependencies {
implementation(kotlin("stdlib", "1.2.50"))
implementation(kotlin("stdlib", "1.2.51"))
// App Compat
withVersion("27.1.1") {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment