gradle update, bug fix

This commit is contained in:
nuclearfog 2024-03-15 18:28:06 +01:00
parent ae44dedca0
commit 4de094bdcc
No known key found for this signature in database
GPG Key ID: 43E45B82006BC9D5
7 changed files with 86 additions and 48 deletions

View File

@ -55,9 +55,9 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'androidx.media3:media3-exoplayer:1.2.1'
implementation 'androidx.media3:media3-ui:1.2.1'
implementation 'androidx.media3:media3-datasource-okhttp:1.2.1'
implementation 'androidx.media3:media3-exoplayer:1.3.0'
implementation 'androidx.media3:media3-ui:1.3.0'
implementation 'androidx.media3:media3-datasource-okhttp:1.3.0'
implementation 'androidx.viewpager2:viewpager2:1.0.0'
//noinspection GradleDependency
implementation 'com.squareup.okhttp3:okhttp:4.12.0'

View File

@ -73,10 +73,21 @@ public class TextEmojiLoader extends AsyncExecutor<TextEmojiLoader.Param, TextEm
final long id;
final int size;
/**
* @param emojis array of emojis
* @param spannable spannable string containing emoji tags
* @param size icon size of the emoji picture
*/
public Param(Emoji[] emojis, Spannable spannable, int size) {
this(0L, emojis, spannable, size);
}
/**
* @param id ID used to identify task (used if multiple tasks are running at the samt time)
* @param emojis array of emojis
* @param spannable spannable string containing emoji tags
* @param size icon size of the emoji picture
*/
public Param(long id, Emoji[] emojis, Spannable spannable, int size) {
this.emojis = emojis;
this.spannable = spannable;
@ -95,6 +106,11 @@ public class TextEmojiLoader extends AsyncExecutor<TextEmojiLoader.Param, TextEm
public final Spannable spannable;
public final long id;
/**
* @param id ID of the task
* @param spannable spannable string containing emoji tags
* @param images a map containing emoji tags and images
*/
Result(long id, Spannable spannable, @Nullable Map<String, Bitmap> images) {
this.images = images;
this.spannable = spannable;

View File

@ -652,6 +652,8 @@ public class ProfileActivity extends AppCompatActivity implements OnClickListene
follower.setVisibility(View.VISIBLE);
user_createdAt.setVisibility(View.VISIBLE);
screenName.setText(user.getScreenname());
// set user join date
user_createdAt.setText(SimpleDateFormat.getDateInstance().format(user.getTimestamp()));
// set status count
if (user.getStatusCount() >= 0) {
tabSelector.setLabel(0, StringUtils.NUMBER_FORMAT.format(user.getStatusCount()));
@ -665,22 +667,28 @@ public class ProfileActivity extends AppCompatActivity implements OnClickListene
tabSelector.setLabel(1, "");
}
// set username and emojis
if (!user.getUsername().trim().isEmpty() && user.getEmojis().length > 0) {
if (!user.getUsername().trim().isEmpty()) {
Spannable usernameSpan = new SpannableString(user.getUsername());
usernameSpan = EmojiUtils.removeTags(usernameSpan);
username.setText(usernameSpan);
} else {
username.setText(user.getUsername());
}
// set user join date
user_createdAt.setText(SimpleDateFormat.getDateInstance().format(user.getTimestamp()));
// set user description
if (!user.getDescription().isEmpty()) {
Spannable descriptionSpan = Tagger.makeTextWithLinks(user.getDescription(), settings.getHighlightColor(), this);
if (user.getEmojis().length > 0) {
descriptionSpan = EmojiUtils.removeTags(descriptionSpan);
if (settings.imagesEnabled() && user.getEmojis().length > 0) {
TextEmojiLoader.Param param = new TextEmojiLoader.Param(user.getEmojis(), usernameSpan, getResources().getDimensionPixelSize(R.dimen.profile_icon_size));
emojiLoader.execute(param, usernameUpdate);
username.setText(EmojiUtils.removeTags(usernameSpan));
} else {
username.setText(usernameSpan);
}
} else {
username.setText("");
}
// set user description
if (!user.getDescription().trim().isEmpty()) {
Spannable descriptionSpan = Tagger.makeTextWithLinks(user.getDescription(), settings.getHighlightColor(), this);
if (settings.imagesEnabled() && user.getEmojis().length > 0) {
TextEmojiLoader.Param param = new TextEmojiLoader.Param(user.getEmojis(), descriptionSpan, getResources().getDimensionPixelSize(R.dimen.profile_icon_size));
emojiLoader.execute(param, userDescriptionUpdate);
description.setText(EmojiUtils.removeTags(descriptionSpan));
} else {
description.setText(descriptionSpan);
}
description.setText(descriptionSpan);
description.setVisibility(View.VISIBLE);
} else {
description.setVisibility(View.GONE);
@ -746,19 +754,6 @@ public class ProfileActivity extends AppCompatActivity implements OnClickListene
} else {
profileImage.setImageDrawable(placeholder);
}
// initialize emoji loading for username/description
if (settings.imagesEnabled() && user.getEmojis().length > 0) {
if (!user.getUsername().isEmpty()) {
SpannableString usernameSpan = new SpannableString(user.getUsername());
TextEmojiLoader.Param param = new TextEmojiLoader.Param(user.getEmojis(), usernameSpan, getResources().getDimensionPixelSize(R.dimen.profile_icon_size));
emojiLoader.execute(param, usernameUpdate);
}
if (!user.getDescription().trim().isEmpty()) {
Spannable descriptionSpan = new SpannableString(user.getDescription());
TextEmojiLoader.Param param = new TextEmojiLoader.Param(user.getEmojis(), descriptionSpan, getResources().getDimensionPixelSize(R.dimen.profile_icon_size));
emojiLoader.execute(param, userDescriptionUpdate);
}
}
}
/**

View File

@ -2,6 +2,7 @@ package org.nuclearfog.twidda.ui.adapter.recyclerview.holder;
import android.graphics.Color;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
@ -31,7 +32,7 @@ import java.util.Random;
*
* @author nuclearfog
*/
public class FieldHolder extends ViewHolder implements AsyncCallback<TextEmojiLoader.Result> {
public class FieldHolder extends ViewHolder {
private static final Random RND = new Random();
@ -42,6 +43,9 @@ public class FieldHolder extends ViewHolder implements AsyncCallback<TextEmojiLo
private GlobalSettings settings;
private OnTagClickListener listener;
private AsyncCallback<TextEmojiLoader.Result> resultValue = this::onValueResult;
private AsyncCallback<TextEmojiLoader.Result> resultKey = this::onKeyResult;
private long tagId = RND.nextLong();
/**
@ -64,9 +68,20 @@ public class FieldHolder extends ViewHolder implements AsyncCallback<TextEmojiLo
AppStyles.setTheme(container, Color.TRANSPARENT);
}
/**
* set emojis of the key text
*/
private void onKeyResult(@NonNull TextEmojiLoader.Result result) {
if (result.id == tagId) {
Spannable spannable = EmojiUtils.addEmojis(key.getContext(), result.spannable, result.images);
key.setText(spannable);
}
}
@Override
public void onResult(@NonNull TextEmojiLoader.Result result) {
/**
* set emojis of the value text
*/
private void onValueResult(@NonNull TextEmojiLoader.Result result) {
if (result.id == tagId) {
Spannable spannable = EmojiUtils.addEmojis(value.getContext(), result.spannable, result.images);
value.setText(spannable);
@ -77,7 +92,7 @@ public class FieldHolder extends ViewHolder implements AsyncCallback<TextEmojiLo
* set view content
*/
public void setContent(Field field, Emoji[] emojis) {
key.setText(field.getKey());
Spannable keySpan = new SpannableString(field.getKey());
Spannable valueSpan = Tagger.makeTextWithLinks(field.getValue(), settings.getHighlightColor(), listener);
if (field.getTimestamp() != 0L) {
verified.setVisibility(View.VISIBLE);
@ -87,12 +102,18 @@ public class FieldHolder extends ViewHolder implements AsyncCallback<TextEmojiLo
verified.setVisibility(View.GONE);
time.setVisibility(View.GONE);
}
if (emojis.length > 0) {
if (emojis.length > 0 && settings.imagesEnabled()) {
// set emojis of the value field
TextEmojiLoader.Param param = new TextEmojiLoader.Param(tagId, emojis, valueSpan, value.getResources().getDimensionPixelSize(R.dimen.item_field_emoji_size));
emojiLoader.execute(param, this);
emojiLoader.execute(param, resultValue);
value.setText(EmojiUtils.removeTags(valueSpan));
// set emojis of the key field
param = new TextEmojiLoader.Param(tagId, emojis, keySpan, value.getResources().getDimensionPixelSize(R.dimen.item_field_emoji_size));
emojiLoader.execute(param, resultKey);
key.setText(EmojiUtils.removeTags(keySpan));
} else {
value.setText(valueSpan);
key.setText(keySpan);
}
}
}

Binary file not shown.

View File

@ -3,5 +3,6 @@ distributionPath=wrapper/dists
distributionSha256Sum=9d926787066a081739e8200858338b4a69e837c3a821a33aca9db09dd4a41026
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

29
gradlew vendored
View File

@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@ -133,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \