pre lollipop bug fix, proguard cleanup, gradle dependencies update

This commit is contained in:
nuclearfog 2021-12-11 20:14:16 +01:00
parent ac13b1a1b8
commit e3d26960dd
No known key found for this signature in database
GPG Key ID: AA0271FBE406DB98
10 changed files with 65 additions and 53 deletions

View File

@ -22,9 +22,10 @@ android {
buildTypes {
release {
debuggable false
multiDexEnabled false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
proguardFiles 'proguard-rules.pro'
}
debug {
minifyEnabled false
@ -46,12 +47,12 @@ proguardDictionaries {
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'org.twitter4j:twitter4j-core:4.0.7'

View File

@ -1,28 +1,4 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ~/Android/Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in show.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-repackageclasses org.nuclearfog.twidda
# keep these libraries but allow obfuscating
-dontwarn twitter4j.**
@ -42,8 +18,6 @@
-adaptclassstrings org.conscrypt.OpenSSLProvider
-dontwarn javax.annotation.Nullable
-keep,allowobfuscation class javax.annotation.Nullable {*;}
-adaptclassstrings javax.annotation.Nullable
# use dictionaries to create random class/package names
-obfuscationdictionary dict/obfuscation-dictionary.txt

View File

@ -206,8 +206,9 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
muteConfirm = new ConfirmDialog(this, DialogType.PROFILE_MUTE, this);
Intent i = getIntent();
user = (User) i.getSerializableExtra(KEY_PROFILE_DATA);
if (user != null) {
Object o = i.getSerializableExtra(KEY_PROFILE_DATA);
if (o instanceof User) {
user = (User) o;
adapter.setupProfilePage(user.getId());
} else {
long userId = i.getLongExtra(KEY_PROFILE_ID, 0);
@ -644,6 +645,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
Picasso.get().load(bannerLink).error(R.drawable.no_banner).into(bannerImage, this);
} else {
bannerImage.setImageResource(0);
toolbarBackground.setImageResource(0);
}
if (user.hasProfileImage()) {
String imgLink = user.getImageLink();

View File

@ -1,5 +1,7 @@
package org.nuclearfog.twidda.backend.model;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -50,7 +52,7 @@ public class Tweet implements Serializable {
private boolean favorited;
private boolean sensitiveMedia;
private String[] medias = {};
private String[] mediaLinks = {};
private String userMentions = "";
private String locationName = "";
private String locationCoordinates = "";
@ -143,7 +145,7 @@ public class Tweet implements Serializable {
this.time = time;
this.replyID = replyID;
this.embedded = embedded;
this.medias = medias;
this.mediaLinks = medias;
this.mediaType = mediaType;
this.retweeted = retweeted;
this.favorited = favored;
@ -267,7 +269,7 @@ public class Tweet implements Serializable {
* @return medias links array
*/
public String[] getMediaLinks() {
return medias;
return mediaLinks;
}
/**
@ -429,15 +431,23 @@ public class Tweet implements Serializable {
* @param mediaEntities media information
*/
private void getMedia(MediaEntity[] mediaEntities) {
medias = new String[mediaEntities.length];
if (medias.length == 0) {
mediaLinks = new String[mediaEntities.length];
if (mediaLinks.length == 0) {
mediaType = MediaType.NONE;
} else {
switch (mediaEntities[0].getType()) {
case PHOTO:
mediaType = MediaType.IMAGE;
for (int i = 0; i < mediaEntities.length; i++) {
medias[i] = mediaEntities[i].getMediaURLHttps();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
// since twitter dropped TLS 1.1 support,
// https links will not work on pre lollipop devices anymore
for (int i = 0; i < mediaEntities.length; i++) {
mediaLinks[i] = mediaEntities[i].getMediaURL();
}
} else {
for (int i = 0; i < mediaEntities.length; i++) {
mediaLinks[i] = mediaEntities[i].getMediaURLHttps();
}
}
break;
@ -447,14 +457,24 @@ public class Tweet implements Serializable {
if (type.getContentType().equals(MEDIA_VIDEO)) {
// get link with selected video format
// a tweet can only have one video
medias[0] = type.getUrl();
mediaLinks[0] = type.getUrl();
// switching to http since twitter dropped TLS 1.1 support, pre lollipop
// devices don't support https
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP &&
mediaLinks[0].startsWith("https://")) {
mediaLinks[0] = "http://" + mediaLinks[0].substring(8);
}
}
}
break;
case ANGIF:
mediaType = MediaType.GIF;
medias[0] = mediaEntities[0].getVideoVariants()[0].getUrl();
mediaLinks[0] = mediaEntities[0].getVideoVariants()[0].getUrl();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP &&
mediaLinks[0].startsWith("https://")) {
mediaLinks[0] = "http://" + mediaLinks[0].substring(8);
}
break;
default:

View File

@ -1,5 +1,7 @@
package org.nuclearfog.twidda.backend.model;
import android.os.Build;
import androidx.annotation.NonNull;
import java.io.Serializable;
@ -58,14 +60,27 @@ public class User implements Serializable {
this.username = user.getName();
if (user.getScreenName() != null)
this.screenName = '@' + user.getScreenName();
if (user.getOriginalProfileImageURLHttps() != null)
this.profileImg = user.getOriginalProfileImageURLHttps();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
// since twitter dropped TLS 1.1 support,
// https links will not work on pre lollipop devices anymore
if (user.getOriginalProfileImageURL() != null) {
this.profileImg = user.getOriginalProfileImageURL();
}
if (bannerLink != null && bannerLink.length() > 12 && bannerLink.startsWith("https://")) {
bannerImg = "http://" + bannerLink.substring(8, bannerLink.length() - 4);
}
} else {
if (user.getOriginalProfileImageURLHttps() != null) {
this.profileImg = user.getOriginalProfileImageURLHttps();
}
if (bannerLink != null && bannerLink.length() > 4) {
bannerImg = bannerLink.substring(0, bannerLink.length() - 4);
}
}
if (user.getURLEntity().getExpandedURL() != null)
this.link = user.getURLEntity().getExpandedURL();
if (user.getLocation() != null)
this.location = user.getLocation();
if (bannerLink != null && bannerLink.length() > 4)
bannerImg = bannerLink.substring(0, bannerLink.length() - 4);
if (bio != null && !bio.isEmpty()) {
URLEntity[] entities = user.getDescriptionURLEntities();
StringBuilder builder = new StringBuilder(user.getDescription());

View File

@ -7,7 +7,7 @@
<ImageView
android:id="@+id/item_image_preview"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:contentDescription="@string/image_preview" />

View File

@ -18,7 +18,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:enable_move="true"
app:max_zoom_in="10.0"
app:max_zoom_out="0.7" />
app:max_zoom_out="0.5" />
<LinearLayout
android:id="@+id/image_preview_list"

View File

@ -151,7 +151,7 @@
android:layout_marginEnd="@dimen/tweet_textview_margin"
android:fadeScrollbars="false"
android:linksClickable="true"
android:maxLines="@integer/tweet_test_max_lines"
android:maxLines="@integer/tweet_text_max_lines"
android:scrollbars="vertical"
android:textSize="@dimen/tweet_textsize"
app:layout_constraintStart_toStartOf="parent"

View File

@ -36,7 +36,7 @@
<dimen name="tweet_textsize_small">12sp</dimen>
<dimen name="tweet_textsize">18sp</dimen>
<dimen name="tweet_textsize_locale">12sp</dimen>
<integer name="tweet_test_max_lines">6</integer>
<integer name="tweet_text_max_lines">5</integer>
<!--dimens of page_profile.xml-->
<dimen name="profile_toolbar_height">48dp</dimen>

View File

@ -10,9 +10,9 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Fri Mar 12 11:41:58 CET 2021
#Fri Dec 03 17:30:19 CET 2021
org.gradle.configureondemand=false;
org.gradle.jvmargs=-Xmx1536M -Dkotlin.daemon.jvm.options\="-Xmx1536M"
android.enableJetifier=true
android.useAndroidX=true
android.enableR8.fullMode=true
org.gradle.configureondemand=false;
org.gradle.jvmargs=-Xmx1024M -Dkotlin.daemon.jvm.options\="-Xmx1024M"
android.enableR8.fullMode=true