Merge branch 'develop'

This commit is contained in:
Thomas 2022-12-28 18:01:57 +01:00
commit 5766bfce32
18 changed files with 124 additions and 50 deletions

View file

@ -13,8 +13,8 @@ android {
defaultConfig {
minSdk 21
targetSdk 33
versionCode 455
versionName "3.13.1"
versionCode 456
versionName "3.13.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
flavorDimensions "default"
@ -109,7 +109,7 @@ dependencies {
implementation("com.vanniktech:android-image-cropper:4.3.3")
annotationProcessor "com.github.bumptech.glide:compiler:4.12.0"
implementation 'jp.wasabeef:glide-transformations:4.3.0'
implementation 'com.github.penfeizhou.android.animation:glide-plugin:2.24.0'
implementation 'com.github.penfeizhou.android.animation:glide-plugin:2.23.0'
implementation 'com.google.android.exoplayer:exoplayer:2.18.1'
implementation "androidx.viewpager2:viewpager2:1.0.0"
implementation 'com.github.piasy:rxandroidaudio:1.7.0'

View file

@ -1,4 +1,9 @@
[
{
"version": "3.13.2",
"code": "456",
"note": "Changed:\n- Hidden media smaller with preview images\n\nFixed:\n- Issue with Media for Android 11+\n- Crash when not setting a translation key\n- Fix DeepL for API pro\n- Crash when visiting a profile with a lot of media\n- Home muted accounts not working without filters\n- Animated custom emoji not displayed"
},
{
"version": "3.13.1",
"code": "455",

View file

@ -21,6 +21,7 @@ import static app.fedilab.android.helper.Helper.PREF_USER_TOKEN;
import static app.fedilab.android.helper.Helper.displayReleaseNotesIfNeeded;
import static app.fedilab.android.ui.drawer.StatusAdapter.sendAction;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
@ -51,12 +52,15 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.SearchView;
import androidx.core.app.ActivityCompat;
import androidx.core.app.ActivityOptionsCompat;
import androidx.core.view.GravityCompat;
import androidx.fragment.app.Fragment;
@ -290,6 +294,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
};
private NetworkStateReceiver networkStateReceiver;
private boolean headerMenuOpen;
private static final int REQUEST_CODE = 5415;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -304,6 +309,15 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
} else {
BaseMainActivity.currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
ActivityResultLauncher<String> permissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> {
if (!isGranted) {
ActivityCompat.requestPermissions(BaseMainActivity.this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, REQUEST_CODE);
}
});
permissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS);
}
filteredAccounts = new ArrayList<>();
mamageNewIntent(getIntent());
filterFetched = false;

View file

@ -243,8 +243,17 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
int position = binding.mediaViewpager.getCurrentItem();
Attachment attachment = attachments.get(position);
if (Build.VERSION.SDK_INT >= 23) {
if (ContextCompat.checkSelfPermission(MediaActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(MediaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE_MEDIA_SAVE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
if (ContextCompat.checkSelfPermission(MediaActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(MediaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE_MEDIA_SAVE);
} else {
if (attachment.type.compareTo("image") == 0) {
MediaHelper.manageMove(MediaActivity.this, attachment.url, false);
} else {
MediaHelper.manageDownloadsNoPopup(MediaActivity.this, attachment.url);
downloadID = -1;
}
}
} else {
if (attachment.type.compareTo("image") == 0) {
MediaHelper.manageMove(MediaActivity.this, attachment.url, false);

View file

@ -94,28 +94,29 @@ public class CustomEmoji extends ReplacementSpan {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
View view = viewWeakReference.get();
if (animate && resource instanceof Animatable) {
Drawable.Callback callback = resource.getCallback();
Drawable.Callback drawableCallBack = resource.getCallback();
resource.setCallback(new Drawable.Callback() {
@Override
public void invalidateDrawable(@NonNull Drawable drawable) {
if (callback != null) {
callback.invalidateDrawable(drawable);
if (drawableCallBack != null) {
drawableCallBack.invalidateDrawable(drawable);
}
view.invalidate();
}
@Override
public void scheduleDrawable(@NonNull Drawable drawable, @NonNull Runnable runnable, long l) {
if (callback != null) {
callback.scheduleDrawable(drawable, runnable, l);
if (drawableCallBack != null) {
drawableCallBack.scheduleDrawable(drawable, runnable, l);
}
}
@Override
public void unscheduleDrawable(@NonNull Drawable drawable, @NonNull Runnable runnable) {
if (callback != null) {
callback.unscheduleDrawable(drawable, runnable);
if (drawableCallBack != null) {
drawableCallBack.unscheduleDrawable(drawable, runnable);
}
}
});

View file

@ -156,7 +156,8 @@ public class TimelineHelper {
}
}
}
}
if (statuses != null && statuses.size() > 0) {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
boolean groupReblogs = sharedpreferences.getBoolean(context.getString(R.string.SET_GROUP_REBLOGS), true);
if (filterTimeLineType == Timeline.TimeLineEnum.HOME) {
@ -172,6 +173,7 @@ public class TimelineHelper {
filterCustom.title = "Fedilab";
filterCustom.context = contextCustom;
statuses.get(i).filteredByApp = filterCustom;
break;
}
}
}

View file

@ -58,7 +58,9 @@ public class TranslateHelper {
String translatorVersion = sharedpreferences.getString(context.getString(R.string.SET_TRANSLATOR_VERSION), "PRO");
params.setPro(translatorVersion.equals("PRO"));
String apikey = sharedpreferences.getString(context.getString(R.string.SET_TRANSLATOR_API_KEY), null);
myTransL.setDeeplAPIKey(apikey.trim());
if (apikey != null) {
myTransL.setDeeplAPIKey(apikey.trim());
}
}
String translate = sharedpreferences.getString(context.getString(R.string.SET_LIVE_TRANSLATE), MyTransL.getLocale());

View file

@ -8,6 +8,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.MotionEvent;
@ -252,7 +253,7 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList
}
private void saveImage() {
if (requestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
if (requestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) || Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
showLoading(getString(R.string.saving));
File file = new File(path);
try {
@ -263,13 +264,16 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList
.setClearViewsEnabled(true)
.setTransparencyEnabled(true)
.build();
if (ContextCompat.checkSelfPermission(EditImageActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(EditImageActivity.this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
STORE_REQUEST);
return;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
if (ContextCompat.checkSelfPermission(EditImageActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(EditImageActivity.this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
STORE_REQUEST);
return;
}
}
mPhotoEditor.saveAsFile(file.getAbsolutePath(), saveSettings, new PhotoEditor.OnSaveListener() {
@Override
public void onSuccess(@NonNull String imagePath) {

View file

@ -390,12 +390,14 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
* @param position - int position of the media in the message
*/
private void pickupMedia(ComposeActivity.mediaType type, int position) {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions((Activity) context,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
return;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions((Activity) context,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
return;
}
}
Intent intent;
intent = new Intent(Intent.ACTION_GET_CONTENT);

View file

@ -78,11 +78,9 @@ public class ImageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
holder.binding.media.setOnClickListener(v -> {
Intent mediaIntent = new Intent(context, MediaActivity.class);
Bundle b = new Bundle();
b.putInt(Helper.ARG_MEDIA_POSITION, position + 1);
b.putInt(Helper.ARG_MEDIA_POSITION, 1);
ArrayList<Attachment> attachmentsTmp = new ArrayList<>();
for (Status status1 : statuses) {
attachmentsTmp.add(status1.art_attachment);
}
attachmentsTmp.add(status.art_attachment);
b.putSerializable(Helper.ARG_STATUS, status);
b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(attachmentsTmp));
mediaIntent.putExtras(b);

View file

@ -1201,7 +1201,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
boolean singleMedia = statusToDeal.media_attachments.size() == 1;
for (Attachment attachment : statusToDeal.media_attachments) {
LayoutMediaBinding layoutMediaBinding = LayoutMediaBinding.inflate(LayoutInflater.from(context));
if (fullAttachement) {
if (fullAttachement && !statusToDeal.sensitive) {
float ratio = 1.0f;
float mediaH = -1.0f;
@ -1240,13 +1240,13 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
loadAndAddAttachment(context, layoutMediaBinding, holder, adapter, mediaPosition, -1.f, -1.f, -1.f, statusToDeal, attachment, singleMedia);
}
mediaPosition++;
if (fullAttachement || singleMedia) {
if ((fullAttachement && !statusToDeal.sensitive) || singleMedia) {
holder.binding.mediaContainer.addView(layoutMediaBinding.getRoot());
} else {
holder.binding.attachmentsList.addView(layoutMediaBinding.getRoot());
}
}
if (!fullAttachement && !singleMedia) {
if ((!fullAttachement || statusToDeal.sensitive) && !singleMedia) {
holder.binding.mediaContainer.setVisibility(View.GONE);
holder.binding.attachmentsListContainer.setVisibility(View.VISIBLE);
} else {
@ -2018,7 +2018,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
boolean expand_media = sharedpreferences.getBoolean(context.getString(R.string.SET_EXPAND_MEDIA), false);
LinearLayout.LayoutParams lp;
if (fullAttachement && mediaH > 0) {
if (fullAttachement && mediaH > 0 && !statusToDeal.sensitive) {
lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, (int) (mediaH * ratio));
layoutMediaBinding.media.setScaleType(ImageView.ScaleType.FIT_CENTER);
} else {
@ -2040,7 +2040,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
focusY = statusToDeal.media_attachments.get(0).meta.focus.y;
}
layoutMediaBinding.count.setVisibility(View.VISIBLE);
if (!fullAttachement && !singleImage) {
if ((!fullAttachement || statusToDeal.sensitive) && !singleImage) {
layoutMediaBinding.count.setText(String.format(Locale.getDefault(), "%d/%d", mediaPosition, statusToDeal.media_attachments.size()));
}
String finalUrl;
@ -2132,7 +2132,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
});
if (fullAttachement || singleImage) {
if (!statusToDeal.sensitive && (fullAttachement || singleImage)) {
layoutMediaBinding.getRoot().setPadding(0, 0, 0, 10);
} else {
layoutMediaBinding.getRoot().setPadding(0, 0, 10, 0);

View file

@ -27,6 +27,7 @@ import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
@ -86,16 +87,7 @@ public class FragmentLoginMain extends Fragment {
permissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> {
if (isGranted) {
Intent openFileIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
openFileIntent.addCategory(Intent.CATEGORY_OPENABLE);
openFileIntent.setType("application/zip");
String[] mimeTypes = new String[]{"application/zip"};
openFileIntent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
//noinspection deprecation
startActivityForResult(
Intent.createChooser(
openFileIntent,
getString(R.string.load_settings)), PICK_IMPORT);
proceed();
} else {
ActivityCompat.requestPermissions(requireActivity(), new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_CODE);
}
@ -233,13 +225,30 @@ public class FragmentLoginMain extends Fragment {
}
});
} else if (itemId == R.id.action_import_data) {
permissionLauncher.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
permissionLauncher.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE);
} else {
proceed();
}
}
return false;
});
popupMenu.show();
}
private void proceed() {
Intent openFileIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
openFileIntent.addCategory(Intent.CATEGORY_OPENABLE);
openFileIntent.setType("application/zip");
String[] mimeTypes = new String[]{"application/zip"};
openFileIntent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
//noinspection deprecation
startActivityForResult(
Intent.createChooser(
openFileIntent,
getString(R.string.load_settings)), PICK_IMPORT);
}
private void retrievesClientId(String instance) {
String oldInstance = instance;
if (!instance.startsWith("http://") && !instance.startsWith("https://")) {

View file

@ -18,6 +18,7 @@ import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.webkit.URLUtil;
import android.widget.Toast;
@ -135,7 +136,15 @@ public class FragmentSettingsCategories extends PreferenceFragmentCompat {
Preference pref_export_settings = findPreference(getString(R.string.pref_export_settings));
if (pref_export_settings != null) {
pref_export_settings.setOnPreferenceClickListener(preference -> {
permissionLauncher.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
permissionLauncher.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE);
} else {
try {
ZipHelper.exportData(requireActivity());
} catch (IOException e) {
e.printStackTrace();
}
}
return false;
});
}

View file

@ -28,7 +28,7 @@ public class Helper {
private static final String YANDEX_BASE_URL = "https://translate.yandex.net/api/v1.5/tr.json/translate?";
private static final String DEEPL_BASE_URL = "https://free.deepl.com/v2/translate?";
private static final String DEEPL_BASE_URL = "https://api.deepl.com/v2/translate?";
private static final String DEEPL_BASE_FREE_URL = "https://api-free.deepl.com/v2/translate?";
private static final String SYSTRAN_BASE_URL = "https://api-platform.systran.net/translation/text/translate?";
private static final String[] deeplAvailableLang = {"EN", "DE", "FR", "ES", "IT", "NL", "PL"};

View file

@ -0,0 +1,10 @@
Changed:
- Hidden media smaller with preview images
Fixed:
- Issue with Media for Android 11+
- Crash when not setting a translation key
- Fix DeepL for API pro
- Crash when visiting a profile with a lot of media
- Home muted accounts not working without filters
- Animated custom emoji not displayed

View file

@ -0,0 +1,5 @@
Nova versão do Fedilab com nova funcionalidade.
- Agora é possível compor threads
- Vê o thread completo ao responder
- Suporte de cache
- Novo design

View file

@ -0,0 +1,3 @@
- Algumas correcções de bugs
- Melhorar as linhas de tempo fixadas

View file

@ -0,0 +1 @@
Correcção de crashes para algumas instâncias do pleroma