diff --git a/app/build.gradle b/app/build.gradle index 566df8e7..fcda7ec4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/src/main/assets/release_notes/notes.json b/app/src/main/assets/release_notes/notes.json index 2d2d1bba..b1e4195b 100644 --- a/app/src/main/assets/release_notes/notes.json +++ b/app/src/main/assets/release_notes/notes.json @@ -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", diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index cffdb745..331add50 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -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 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; diff --git a/app/src/main/java/app/fedilab/android/activities/MediaActivity.java b/app/src/main/java/app/fedilab/android/activities/MediaActivity.java index a93697f6..66dcb5b9 100644 --- a/app/src/main/java/app/fedilab/android/activities/MediaActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/MediaActivity.java @@ -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); diff --git a/app/src/main/java/app/fedilab/android/helper/CustomEmoji.java b/app/src/main/java/app/fedilab/android/helper/CustomEmoji.java index f121afc1..f7689766 100644 --- a/app/src/main/java/app/fedilab/android/helper/CustomEmoji.java +++ b/app/src/main/java/app/fedilab/android/helper/CustomEmoji.java @@ -94,28 +94,29 @@ public class CustomEmoji extends ReplacementSpan { @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition 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); } } }); diff --git a/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java b/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java index 6c94cf29..42bfc8f4 100644 --- a/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java @@ -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; } } } diff --git a/app/src/main/java/app/fedilab/android/helper/TranslateHelper.java b/app/src/main/java/app/fedilab/android/helper/TranslateHelper.java index 2edbb8ac..2876feea 100644 --- a/app/src/main/java/app/fedilab/android/helper/TranslateHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/TranslateHelper.java @@ -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()); diff --git a/app/src/main/java/app/fedilab/android/imageeditor/EditImageActivity.java b/app/src/main/java/app/fedilab/android/imageeditor/EditImageActivity.java index 65c5545e..f0d5ea6b 100644 --- a/app/src/main/java/app/fedilab/android/imageeditor/EditImageActivity.java +++ b/app/src/main/java/app/fedilab/android/imageeditor/EditImageActivity.java @@ -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) { diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java index 75f794be..332bb58e 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java @@ -390,12 +390,14 @@ public class ComposeAdapter extends RecyclerView.Adapter 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 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); diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java index f0be81cc..be9a5c3d 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java @@ -1201,7 +1201,7 @@ public class StatusAdapter extends RecyclerView.Adapter 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 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 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 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 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); diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/login/FragmentLoginMain.java b/app/src/main/java/app/fedilab/android/ui/fragment/login/FragmentLoginMain.java index f4b41ef9..8b4be76d 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/login/FragmentLoginMain.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/login/FragmentLoginMain.java @@ -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://")) { diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentSettingsCategories.java b/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentSettingsCategories.java index 36d5b60e..eb11a00b 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentSettingsCategories.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentSettingsCategories.java @@ -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; }); } diff --git a/mytransl/src/main/java/com/github/stom79/mytransl/translate/Helper.java b/mytransl/src/main/java/com/github/stom79/mytransl/translate/Helper.java index 2b27c86b..5376d3cf 100644 --- a/mytransl/src/main/java/com/github/stom79/mytransl/translate/Helper.java +++ b/mytransl/src/main/java/com/github/stom79/mytransl/translate/Helper.java @@ -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"}; diff --git a/src/fdroid/fastlane/metadata/android/en/changelogs/456.txt b/src/fdroid/fastlane/metadata/android/en/changelogs/456.txt new file mode 100644 index 00000000..4ac4f10f --- /dev/null +++ b/src/fdroid/fastlane/metadata/android/en/changelogs/456.txt @@ -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 \ No newline at end of file diff --git a/src/fdroid/fastlane/metadata/android/pt/changelogs/390.txt b/src/fdroid/fastlane/metadata/android/pt/changelogs/390.txt new file mode 100644 index 00000000..e5ce13b8 --- /dev/null +++ b/src/fdroid/fastlane/metadata/android/pt/changelogs/390.txt @@ -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 diff --git a/src/fdroid/fastlane/metadata/android/pt/changelogs/393.txt b/src/fdroid/fastlane/metadata/android/pt/changelogs/393.txt new file mode 100644 index 00000000..88a074ca --- /dev/null +++ b/src/fdroid/fastlane/metadata/android/pt/changelogs/393.txt @@ -0,0 +1,3 @@ +- Algumas correcções de bugs + +- Melhorar as linhas de tempo fixadas diff --git a/src/fdroid/fastlane/metadata/android/pt/changelogs/394.txt b/src/fdroid/fastlane/metadata/android/pt/changelogs/394.txt new file mode 100644 index 00000000..a833e934 --- /dev/null +++ b/src/fdroid/fastlane/metadata/android/pt/changelogs/394.txt @@ -0,0 +1 @@ +‐ Correcção de crashes para algumas instâncias do pleroma