diff options
author | Thomas <tschneider.ac@gmail.com> | 2022-12-18 15:43:47 +0100 |
---|---|---|
committer | Thomas <tschneider.ac@gmail.com> | 2022-12-18 15:43:47 +0100 |
commit | 8e3b146a77aa54efdc20fdc6c43ff679480c887b (patch) | |
tree | 0c58dfd963bb968330d72c0e8466d24ed0a03d5a | |
parent | 376daf7c6307a35c338c774c68b94d271ab4e6e9 (diff) | |
parent | a63f1a93000cb0dd1c81b1173d53ca58669c07c4 (diff) |
Merge branch 'develop'3.12.0
44 files changed, 666 insertions, 236 deletions
diff --git a/app/build.gradle b/app/build.gradle index 4182bde72..773416633 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,8 @@ android { defaultConfig { minSdk 21 targetSdk 32 - versionCode 449 - versionName "3.11.3" + versionCode 450 + versionName "3.12.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } flavorDimensions "default" diff --git a/app/src/main/assets/release_notes/notes.json b/app/src/main/assets/release_notes/notes.json index b72d5facc..a98bff249 100644 --- a/app/src/main/assets/release_notes/notes.json +++ b/app/src/main/assets/release_notes/notes.json @@ -1,5 +1,10 @@ [ { + "version": "3.12.0", + "code": "450", + "note": "Added:\n- Full data import/export feature\n- Android 13 themed icon support\n\nFixed:\n- Fix a regression with filters\n- Fix dark solarized theme\n- Fix hide link previews for CW\n- Fix status bar color for all themes\n- Fix language in compose \"...\"\n- Fix add all home muted accounts from lists\n- Fix top notification badges" + }, + { "version": "3.11.3", "code": "449", "note": "Added:\n- Add more targeted languages in picker for translations\n- Add account name in push notifications\n\nFixed:\n- Fix a crash when changing language\n- Fix counter colors\n- Fix default link color\n- Fix a crash when clicking on mentions" diff --git a/app/src/main/java/app/fedilab/android/activities/BaseActivity.java b/app/src/main/java/app/fedilab/android/activities/BaseActivity.java index e7ba4af89..2f2b870f8 100644 --- a/app/src/main/java/app/fedilab/android/activities/BaseActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/BaseActivity.java @@ -19,11 +19,8 @@ import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; -import android.graphics.Color; import android.os.Build; import android.os.Bundle; -import android.view.Window; -import android.view.WindowManager; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; @@ -84,9 +81,6 @@ public class BaseActivity extends AppCompatActivity { break; case "BLACK": setTheme(R.style.BlackAppTheme); - Window window = getWindow(); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(Color.BLACK); currentThemeId = R.style.BlackAppTheme; break; case "DRACULA": @@ -121,9 +115,6 @@ public class BaseActivity extends AppCompatActivity { case "BLACK": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); setTheme(R.style.BlackAppTheme); - Window window = getWindow(); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(Color.BLACK); currentThemeId = R.style.BlackAppTheme; break; case "DRACULA": diff --git a/app/src/main/java/app/fedilab/android/activities/BaseBarActivity.java b/app/src/main/java/app/fedilab/android/activities/BaseBarActivity.java index 2776d2ec2..e8f0111e4 100644 --- a/app/src/main/java/app/fedilab/android/activities/BaseBarActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/BaseBarActivity.java @@ -19,11 +19,8 @@ import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; -import android.graphics.Color; import android.os.Build; import android.os.Bundle; -import android.view.Window; -import android.view.WindowManager; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; @@ -76,9 +73,6 @@ public class BaseBarActivity extends AppCompatActivity { setTheme(R.style.SolarizedAppThemeBar); break; case "BLACK": - Window window = getWindow(); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(Color.BLACK); setTheme(R.style.BlackAppThemeBar); break; case "DRACULA": @@ -108,9 +102,6 @@ public class BaseBarActivity extends AppCompatActivity { break; case "BLACK": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); - Window window = getWindow(); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(Color.BLACK); setTheme(R.style.BlackAppThemeBar); break; case "DRACULA": diff --git a/app/src/main/java/app/fedilab/android/activities/BaseTransparentActivity.java b/app/src/main/java/app/fedilab/android/activities/BaseTransparentActivity.java index 0f2668649..77f2df730 100644 --- a/app/src/main/java/app/fedilab/android/activities/BaseTransparentActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/BaseTransparentActivity.java @@ -19,11 +19,8 @@ import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; -import android.graphics.Color; import android.os.Build; import android.os.Bundle; -import android.view.Window; -import android.view.WindowManager; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; @@ -76,9 +73,6 @@ public class BaseTransparentActivity extends AppCompatActivity { setTheme(R.style.TransparentSolarized); break; case "BLACK": - Window window = getWindow(); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(Color.BLACK); setTheme(R.style.TransparentBlack); break; case "DRACULA": @@ -108,9 +102,6 @@ public class BaseTransparentActivity extends AppCompatActivity { break; case "BLACK": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); - Window window = getWindow(); - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - window.setStatusBarColor(Color.BLACK); setTheme(R.style.TransparentBlack); break; case "DRACULA": diff --git a/app/src/main/java/app/fedilab/android/activities/LoginActivity.java b/app/src/main/java/app/fedilab/android/activities/LoginActivity.java index 4b91601b3..0262a8366 100644 --- a/app/src/main/java/app/fedilab/android/activities/LoginActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/LoginActivity.java @@ -54,9 +54,9 @@ public class LoginActivity extends BaseActivity { public static Account.API apiLogin; public static String currentInstanceLogin, client_idLogin, client_secretLogin, softwareLogin; - private final int PICK_IMPORT = 5557; public static boolean requestedAdmin; + @SuppressLint("ApplySharedPref") public void proceedLogin(Activity activity, Account account) { new Thread(() -> { @@ -154,6 +154,8 @@ public class LoginActivity extends BaseActivity { //The activity handles a redirect URI, it will extract token code and will proceed to authentication //That happens when the user wants to use an external browser manageItent(getIntent()); + + } @@ -176,7 +178,6 @@ public class LoginActivity extends BaseActivity { // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); - if (id == R.id.action_proxy) { Intent intent = new Intent(LoginActivity.this, ProxyActivity.class); startActivity(intent); @@ -188,20 +189,5 @@ public class LoginActivity extends BaseActivity { return super.onOptionsItemSelected(item); } - @Override - protected void onActivityResult(int requestCode, int resultCode, - Intent data) { - super.onActivityResult(requestCode, resultCode, data); - if (requestCode == PICK_IMPORT && resultCode == RESULT_OK) { - if (data == null || data.getData() == null) { - Toasty.error(LoginActivity.this, getString(R.string.toot_select_file_error), Toast.LENGTH_LONG).show(); - return; - } - // String filename = Helper.getFilePathFromURI(LoginActivity.this, data.getData()); - // Sqlite.importDB(LoginActivity.this, filename); - } else { - Toasty.error(LoginActivity.this, getString(R.string.toot_select_file_error), Toast.LENGTH_LONG).show(); - } - } }
\ No newline at end of file diff --git a/app/src/main/java/app/fedilab/android/activities/MastodonListActivity.java b/app/src/main/java/app/fedilab/android/activities/MastodonListActivity.java index 0d6219316..1ab34d21c 100644 --- a/app/src/main/java/app/fedilab/android/activities/MastodonListActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/MastodonListActivity.java @@ -150,9 +150,7 @@ public class MastodonListActivity extends BaseBarActivity implements MastodonLis timelinesVM.getAccountsInList(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, mastodonList.id, null, null, 0) .observe(MastodonListActivity.this, accounts -> { if (accounts != null && accounts.size() > 0) { - for (Account account : accounts) { - accountsVM.muteHome(MainActivity.currentAccount, account); - } + accountsVM.muteAccountsHome(MainActivity.currentAccount, accounts); } }); dialog.dismiss(); diff --git a/app/src/main/java/app/fedilab/android/client/entities/app/MutedAccounts.java b/app/src/main/java/app/fedilab/android/client/entities/app/MutedAccounts.java index a1d3b2194..520804e2f 100644 --- a/app/src/main/java/app/fedilab/android/client/entities/app/MutedAccounts.java +++ b/app/src/main/java/app/fedilab/android/client/entities/app/MutedAccounts.java @@ -68,6 +68,7 @@ public class MutedAccounts implements Serializable { try { return gson.toJson(accounts); } catch (Exception e) { + e.printStackTrace(); return null; } } diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java index 3b9855918..fe70d4fed 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -312,7 +312,7 @@ public class Helper { public static final String INTENT_SEND_MODIFIED_IMAGE = "INTENT_SEND_MODIFIED_IMAGE"; public static final String INTENT_COMPOSE_ERROR_MESSAGE = "INTENT_COMPOSE_ERROR_MESSAGE"; public static final String TEMP_MEDIA_DIRECTORY = "TEMP_MEDIA_DIRECTORY"; - + public static final String TEMP_EXPORT_DATA = "TEMP_EXPORT_DATA"; public static final int EXTERNAL_STORAGE_REQUEST_CODE = 84; public static final int EXTERNAL_STORAGE_REQUEST_CODE_MEDIA_SAVE = 85; @@ -1276,6 +1276,50 @@ public class Helper { }).start(); } + + public static void createFileFromUri(Context context, Uri uri, OnFileCopied callBack) { + new Thread(() -> { + InputStream selectedFileInputStream; + File file = null; + try { + String uriFullPath = uri.getPath(); + String[] uriFullPathStr = uriFullPath.split(":"); + String fullPath = uriFullPath; + if (uriFullPathStr.length > 1) { + fullPath = uriFullPathStr[1]; + } + final String fileName = Helper.dateFileToString(context, new Date()) + ".zip"; + selectedFileInputStream = context.getContentResolver().openInputStream(uri); + if (selectedFileInputStream != null) { + final File certCacheDir = new File(context.getCacheDir(), TEMP_EXPORT_DATA); + boolean isCertCacheDirExists = certCacheDir.exists(); + if (!isCertCacheDirExists) { + isCertCacheDirExists = certCacheDir.mkdirs(); + } + if (isCertCacheDirExists) { + String filePath = certCacheDir.getAbsolutePath() + "/" + fileName; + file = new File(filePath); + OutputStream selectedFileOutPutStream = new FileOutputStream(filePath); + byte[] buffer = new byte[1024]; + int length; + while ((length = selectedFileInputStream.read(buffer)) > 0) { + selectedFileOutPutStream.write(buffer, 0, length); + } + selectedFileOutPutStream.flush(); + selectedFileOutPutStream.close(); + } + selectedFileInputStream.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + Handler mainHandler = new Handler(Looper.getMainLooper()); + File finalFile = file; + Runnable myRunnable = () -> callBack.onFileCopied(finalFile); + mainHandler.post(myRunnable); + }).start(); + } + public static void createAttachmentFromPAth(String path, OnAttachmentCopied callBack) { new Thread(() -> { Attachment attachment = new Attachment(); @@ -1954,6 +1998,10 @@ public class Helper { void onAttachmentCopied(Attachment attachment); } + public interface OnFileCopied { + void onFileCopied(File file); + } + public static void addMutedAccount(app.fedilab.android.client.entities.api.Account target) { if (MainActivity.filteredAccounts == null) { MainActivity.filteredAccounts = new ArrayList<>(); diff --git a/app/src/main/java/app/fedilab/android/helper/SettingsStorage.java b/app/src/main/java/app/fedilab/android/helper/SettingsStorage.java deleted file mode 100644 index 86a74a236..000000000 --- a/app/src/main/java/app/fedilab/android/helper/SettingsStorage.java +++ /dev/null @@ -1,134 +0,0 @@ -package app.fedilab.android.helper; -/* Copyright 2022 Thomas Schneider - * - * This file is a part of Fedilab - * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU General Public License as published by the Free Software Foundation; either version 3 of the - * License, or (at your option) any later version. - * - * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. - * - * You should have received a copy of the GNU General Public License along with Fedilab; if not, - * see <http://www.gnu.org/licenses>. */ - -import static app.fedilab.android.BaseMainActivity.currentAccount; -import static app.fedilab.android.helper.LogoHelper.getMainLogo; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.graphics.BitmapFactory; -import android.net.Uri; -import android.os.Environment; - -import androidx.preference.PreferenceManager; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.util.Date; -import java.util.Map; - -import app.fedilab.android.R; - - -//From https://stackoverflow.com/a/10864463 - -public class SettingsStorage { - - - public static boolean saveSharedPreferencesToFile(Context context) { - boolean res = false; - ObjectOutputStream output = null; - String fileName = "Fedilab_settings_export_" + Helper.dateFileToString(context, new Date()) + ".txt"; - String filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(); - String fullPath = filePath + "/" + fileName; - File dst = new File(fullPath); - try { - output = new ObjectOutputStream(new FileOutputStream(dst)); - SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); - output.writeObject(sharedpreferences.getAll()); - res = true; - String message = context.getString(R.string.data_export_settings_success); - Intent intentOpen = new Intent(); - intentOpen.setAction(android.content.Intent.ACTION_VIEW); - Uri uri = Uri.parse("file://" + fullPath); - intentOpen.setDataAndType(uri, "text/txt"); - String title = context.getString(R.string.data_export_settings); - Helper.notify_user(context, currentAccount, intentOpen, BitmapFactory.decodeResource(context.getResources(), - getMainLogo(context)), Helper.NotifType.BACKUP, title, message); - } catch (IOException e) { - e.printStackTrace(); - } finally { - try { - if (output != null) { - output.flush(); - output.close(); - } - } catch (IOException ex) { - ex.printStackTrace(); - } - } - return res; - } - - @SuppressLint("ApplySharedPref") - @SuppressWarnings({"unchecked", "UnnecessaryUnboxing"}) - public static boolean loadSharedPreferencesFromFile(Context context, Uri srcUri) { - boolean res = false; - ObjectInputStream input = null; - try { - input = new ObjectInputStream(context.getContentResolver().openInputStream(srcUri)); - SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); - SharedPreferences.Editor prefEdit = sharedpreferences.edit(); - prefEdit.clear(); - Map<String, ?> entries = (Map<String, ?>) input.readObject(); - for (Map.Entry<String, ?> entry : entries.entrySet()) { - Object v = entry.getValue(); - String key = entry.getKey(); - //We skip some values - if (key.compareTo(Helper.PREF_USER_ID) == 0) { - continue; - } - if (key.compareTo(Helper.PREF_INSTANCE) == 0) { - continue; - } - if (key.compareTo(Helper.PREF_USER_INSTANCE) == 0) { - continue; - } - if (key.compareTo(Helper.PREF_USER_TOKEN) == 0) { - continue; - } - if (v instanceof Boolean) - prefEdit.putBoolean(key, ((Boolean) v).booleanValue()); - else if (v instanceof Float) - prefEdit.putFloat(key, ((Float) v).floatValue()); - else if (v instanceof Integer) - prefEdit.putInt(key, ((Integer) v).intValue()); - else if (v instanceof Long) - prefEdit.putLong(key, ((Long) v).longValue()); - else if (v instanceof String) - prefEdit.putString(key, ((String) v)); - } - prefEdit.commit(); - res = true; - } catch (IOException | ClassNotFoundException e) { - e.printStackTrace(); - } finally { - try { - if (input != null) { - input.close(); - } - } catch (IOException ex) { - ex.printStackTrace(); - } - } - return res; - } -} 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 589528a8c..4ad014c17 100644 --- a/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java @@ -137,8 +137,6 @@ public class TimelineHelper { if (m.find()) { status.filteredByApp = filter; continue; - } else { - status.filteredByApp = null; } if (status.spoiler_text != null) { String spoilerText; @@ -149,8 +147,6 @@ public class TimelineHelper { Matcher ms = p.matcher(spoilerText); if (ms.find()) { status.filteredByApp = filter; - } else { - status.filteredByApp = null; } } } @@ -160,9 +156,6 @@ public class TimelineHelper { if (filterTimeLineType == Timeline.TimeLineEnum.HOME) { if (filteredAccounts != null && filteredAccounts.size() > 0) { for (Status status : statuses) { - if (status.filteredByApp != null) { - continue; - } for (Account account : filteredAccounts) { if (account.acct.equals(status.account.acct) || (status.reblog != null && account.acct.equals(status.reblog.account.acct))) { Filter filterCustom = new Filter(); diff --git a/app/src/main/java/app/fedilab/android/helper/ZipHelper.java b/app/src/main/java/app/fedilab/android/helper/ZipHelper.java new file mode 100644 index 000000000..e9873b941 --- /dev/null +++ b/app/src/main/java/app/fedilab/android/helper/ZipHelper.java @@ -0,0 +1,294 @@ +package app.fedilab.android.helper; +/* Copyright 2022 Thomas Schneider + * + * This file is a part of Fedilab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Fedilab; if not, + * see <http://www.gnu.org/licenses>. */ + + +import static app.fedilab.android.BaseMainActivity.currentAccount; +import static app.fedilab.android.helper.LogoHelper.getMainLogo; +import static app.fedilab.android.sqlite.Sqlite.DB_NAME; +import static app.fedilab.android.sqlite.Sqlite.db; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.BitmapFactory; +import android |