diff options
author | Thomas <tschneider.ac@gmail.com> | 2023-01-24 15:03:02 +0100 |
---|---|---|
committer | Thomas <tschneider.ac@gmail.com> | 2023-01-24 15:03:02 +0100 |
commit | 77fbebf4a71bb1f7bb7f11abcd68ae6d137559f6 (patch) | |
tree | 223a411431b7e98dbc12b3448231af98e8945ece | |
parent | c09a7a3c2b977af40b0c5ac1bfd2e4a2d779cd26 (diff) |
improvements
28 files changed, 209 insertions, 90 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index be9a9a630..ecdc571e2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -358,7 +358,9 @@ <activity android:name=".peertube.activities.PeertubeMainActivity" android:configChanges="keyboardHidden|orientation|screenSize" /> - + <activity + android:name=".peertube.activities.PeertubeMainActivity" + android:configChanges="keyboardHidden|orientation|screenSize" /> <activity android:name=".peertube.activities.PeertubeActivity" android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index c2fdc3e70..57be860ba 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -17,6 +17,7 @@ package app.fedilab.android; import static app.fedilab.android.BaseMainActivity.status.DISCONNECTED; import static app.fedilab.android.BaseMainActivity.status.UNKNOWN; import static app.fedilab.android.mastodon.helper.CacheHelper.deleteDir; +import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_SOFTWARE; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN; import static app.fedilab.android.mastodon.helper.Helper.TAG; import static app.fedilab.android.mastodon.helper.Helper.displayReleaseNotesIfNeeded; @@ -108,7 +109,6 @@ import java.util.regex.Pattern; import app.fedilab.android.activities.AboutActivity; import app.fedilab.android.activities.LoginActivity; import app.fedilab.android.activities.MainActivity; -import app.fedilab.android.activities.PeertubeBaseMainActivity; import app.fedilab.android.databinding.ActivityMainBinding; import app.fedilab.android.databinding.NavHeaderMainBinding; import app.fedilab.android.mastodon.activities.ActionActivity; @@ -170,6 +170,7 @@ import app.fedilab.android.mastodon.viewmodel.mastodon.InstancesVM; import app.fedilab.android.mastodon.viewmodel.mastodon.SearchVM; import app.fedilab.android.mastodon.viewmodel.mastodon.TimelinesVM; import app.fedilab.android.mastodon.viewmodel.mastodon.TopBarVM; +import app.fedilab.android.peertube.activities.PeertubeMainActivity; import es.dmoral.toasty.Toasty; import okhttp3.Call; import okhttp3.Callback; @@ -328,6 +329,13 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt } else { BaseMainActivity.currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null); } + String software = sharedpreferences.getString(PREF_USER_SOFTWARE, null); + Log.v(TAG, "software: " + software); + if (software != null && software.equalsIgnoreCase("peertube")) { + startActivity(new Intent(this, PeertubeMainActivity.class)); + finish(); + return; + } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { ActivityResultLauncher<String> permissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> { @@ -346,17 +354,11 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null); } currentAccount = new Account(BaseMainActivity.this).getConnectedAccount(); - Log.v(TAG, "currentToken! " + currentToken); - Log.v(TAG, "currentAccount! " + currentAccount); - if (currentAccount != null && currentAccount.api == Account.API.PEERTUBE) { - startActivity(new Intent(this, PeertubeBaseMainActivity.class)); - finish(); - } } catch (DBException e) { e.printStackTrace(); } //If the attached account is null, the app will fetch remote instance to get up-to-date values - if (currentAccount != null && currentAccount.mastodon_account == null) { + if (currentAccount != null && currentAccount.mastodon_account == null && currentAccount.peertube_account == null) { OkHttpClient okHttpClient = new OkHttpClient.Builder() .readTimeout(60, TimeUnit.SECONDS) .connectTimeout(60, TimeUnit.SECONDS) @@ -383,11 +385,22 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt } Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> { - if (currentAccount == null || currentAccount.mastodon_account == null) { + if (currentAccount == null || (currentAccount.mastodon_account == null && currentAccount.peertube_account == null)) { //It is not, the user is redirected to the login page - Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class); - startActivity(myIntent); - finish(); + if (currentAccount != null) { + try { + Helper.removeAccount(BaseMainActivity.this); + } catch (DBException e) { + Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class); + startActivity(myIntent); + finish(); + e.printStackTrace(); + } + } else { + Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class); + startActivity(myIntent); + finish(); + } return; } bottomMenu = new BottomMenu(BaseMainActivity.this).hydrate(currentAccount, binding.bottomNavView); @@ -654,13 +667,25 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt if (currentSubmenu == null) { continue; } - final MenuItem item = currentSubmenu.add("@" + account.mastodon_account.acct); - item.setIcon(R.drawable.ic_person); + String acct = ""; + String url = ""; boolean disableGif = sharedpreferences.getBoolean(getString(R.string.SET_DISABLE_GIF), false); - String url = !disableGif ? account.mastodon_account.avatar : account.mastodon_account.avatar_static; - if (url != null && url.startsWith("/")) { - url = "https://" + account.instance + account.mastodon_account.avatar; + if (account.mastodon_account != null) { + acct = account.mastodon_account.acct; + url = !disableGif ? account.mastodon_account.avatar : account.mastodon_account.avatar_static; + if (url != null && url.startsWith("/")) { + url = "https://" + account.instance + account.mastodon_account.avatar; + } + } else if (account.peertube_account != null) { + acct = account.peertube_account.getAcct(); + url = account.peertube_account.getAvatar().getPath(); + if (url != null && url.startsWith("/")) { + url = "https://" + account.instance + account.peertube_account.getAvatar().getPath(); + } } + + final MenuItem item = currentSubmenu.add("@" + acct); + item.setIcon(R.drawable.ic_person); if (!this.isDestroyed() && !this.isFinishing() && url != null) { if (url.contains(".gif")) { Glide.with(BaseMainActivity.this) @@ -706,6 +731,8 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt api = account.api; SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(PREF_USER_TOKEN, account.token); + editor.putString(PREF_USER_SOFTWARE, account.software); + Log.v(TAG, "put 2: " + account.software); editor.commit(); //The user is now aut //The user is now authenticated, it will be redirected to MainActivity @@ -908,9 +935,11 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt e.printStackTrace(); } } - MutedAccounts mutedAccounts = new MutedAccounts(BaseMainActivity.this).getMutedAccount(currentAccount); - if (mutedAccounts != null && mutedAccounts.accounts != null) { - filteredAccounts = mutedAccounts.accounts; + if (currentAccount != null) { + MutedAccounts mutedAccounts = new MutedAccounts(BaseMainActivity.this).getMutedAccount(currentAccount); + if (mutedAccounts != null && mutedAccounts.accounts != null) { + filteredAccounts = mutedAccounts.accounts; + } } //Delete cache older than 7 days new StatusCache(BaseMainActivity.this).deleteForAllAccountAfter7Days(); @@ -930,12 +959,19 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt headerMainBinding.otherAccount1.setVisibility(View.VISIBLE); headerMainBinding.otherAccount1.setOnClickListener(v -> { headerMenuOpen = false; - Toasty.info(BaseMainActivity.this, getString(R.string.toast_account_changed, "@" + accounts.get(0).mastodon_account.acct + "@" + accounts.get(0).instance), Toasty.LENGTH_LONG).show(); + String account = ""; + if (accounts.get(0).mastodon_account != null) { + account = "@" + accounts.get(0).mastodon_account.acct + "@" + accounts.get(0).instance; + } else if (accounts.get(0).peertube_account != null) { + account = "@" + accounts.get(0).peertube_account.getAcct() + "@" + accounts.get(0).instance; + } + Toasty.info(BaseMainActivity.this, getString(R.string.toast_account_changed, account), Toasty.LENGTH_LONG).show(); BaseMainActivity.currentToken = accounts.get(0).token; BaseMainActivity.currentUserID = accounts.get(0).user_id; api = accounts.get(0).api; SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(PREF_USER_TOKEN, accounts.get(0).token); + editor.putString(PREF_USER_SOFTWARE, accounts.get(0).software); editor.commit(); //The user is now aut //The user is now authenticated, it will be redirected to MainActivity @@ -948,12 +984,19 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt headerMainBinding.otherAccount2.setVisibility(View.VISIBLE); headerMainBinding.otherAccount2.setOnClickListener(v -> { headerMenuOpen = false; - Toasty.info(BaseMainActivity.this, getString(R.string.toast_account_changed, "@" + accounts.get(1).mastodon_account.acct + "@" + accounts.get(1).instance), Toasty.LENGTH_LONG).show(); + String account = ""; + if (accounts.get(1).mastodon_account != null) { + account = "@" + accounts.get(1).mastodon_account.acct + "@" + accounts.get(1).instance; + } else if (accounts.get(1).peertube_account != null) { + account = "@" + accounts.get(1).peertube_account.getAcct() + "@" + accounts.get(1).instance; + } + Toasty.info(BaseMainActivity.this, getString(R.string.toast_account_changed, account), Toasty.LENGTH_LONG).show(); BaseMainActivity.currentToken = accounts.get(1).token; BaseMainActivity.currentUserID = accounts.get(1).user_id; api = accounts.get(1).api; SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(PREF_USER_TOKEN, accounts.get(1).token); + editor.putString(PREF_USER_SOFTWARE, accounts.get(1).software); editor.commit(); //The user is now aut //The user is now authenticated, it will be redirected to MainActivity @@ -1034,6 +1077,8 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt api = account.api; SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(PREF_USER_TOKEN, account.token); + editor.putString(PREF_USER_SOFTWARE, account.software); + Log.v(TAG, "put 3: " + account.software); editor.commit(); Intent mainActivity = new Intent(this, MainActivity.class); mainActivity.putExtra(Helper.INTENT_ACTION, Helper.OPEN_NOTIFICATION); diff --git a/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/Account.java b/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/Account.java index 085125edf..7b310b4d3 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/Account.java +++ b/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/Account.java @@ -526,12 +526,19 @@ public class Account extends BaseAccount implements Serializable { case "PLEROMA": api = API.PLEROMA; break; + case "PEERTUBE": + api = API.PEERTUBE; + break; default: api = API.UNKNOWN; break; } account.api = api; - account.mastodon_account = restoreAccountFromString(c.getString(c.getColumnIndexOrThrow(Sqlite.COL_ACCOUNT))); + if (api != API.PEERTUBE) { + account.mastodon_account = restoreAccountFromString(c.getString(c.getColumnIndexOrThrow(Sqlite.COL_ACCOUNT))); + } else { + account.peertube_account = restorePeertubeAccountFromString(c.getString(c.getColumnIndexOrThrow(Sqlite.COL_ACCOUNT))); + } return account; } diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java index aeacb46bb..284be1648 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java @@ -58,6 +58,7 @@ import android.provider.MediaStore; import android.provider.OpenableColumns; import android.text.TextUtils; import android.util.DisplayMetrics; +import android.util.Log; import android.util.TypedValue; import android.view.Menu; import android.view.MenuItem; @@ -298,6 +299,7 @@ public class Helper { public static final String PREF_USER_TOKEN = "PREF_USER_TOKEN"; public static final String PREF_USER_ID = "PREF_USER_ID"; public static final String PREF_USER_INSTANCE = "PREF_USER_INSTANCE"; + public static final String PREF_USER_SOFTWARE = "PREF_USER_SOFTWARE"; public static final String PREF_IS_MODERATOR = "PREF_IS_MODERATOR"; public static final String PREF_IS_ADMINISTRATOR = "PREF_IS_ADMINISTRATOR"; public static final String PREF_MESSAGE_URL = "PREF_MESSAGE_URL"; @@ -922,6 +924,7 @@ public class Helper { if (newAccount == null) { editor.putString(PREF_USER_TOKEN, null); editor.putString(PREF_USER_INSTANCE, null); + // editor.putString(PREF_USER_SOFTWARE, null); editor.putString(PREF_USER_ID, null); editor.commit(); Intent loginActivity = new Intent(activity, LoginActivity.class); @@ -930,6 +933,8 @@ public class Helper { } else { currentAccount = newAccount; editor.putString(PREF_USER_TOKEN, newAccount.token); + editor.putString(PREF_USER_SOFTWARE, newAccount.software); + Log.v(TAG, "put 4: " + newAccount.software); editor.putString(PREF_USER_INSTANCE, newAccount.instance); editor.putString(PREF_USER_ID, newAccount.user_id); BaseMainActivity.currentUserID = newAccount.user_id; @@ -1073,7 +1078,16 @@ public class Helper { public static void loadPP(Activity activity, ImageView view, BaseAccount account, boolean crop) { SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity); boolean disableGif = sharedpreferences.getBoolean(activity.getString(R.string.SET_DISABLE_GIF), false); - String targetedUrl = disableGif ? account.mastodon_account.avatar_static : account.mastodon_account.avatar; + String targetedUrl = ""; + if (account.mastodon_account != null) { + targetedUrl = disableGif ? account.mastodon_account.avatar_static : account.mastodon_account.avatar; + } else if (account.peertube_account != null) { + targetedUrl = account.peertube_account.getAvatar().getPath(); + if (targetedUrl != null && targetedUrl.startsWith("/")) { + targetedUrl = "https://" + account.instance + account.peertube_account.getAvatar().getPath(); + } + } + if (targetedUrl != null && Helper.isValidContextForGlide(activity)) { if (disableGif || (!targetedUrl.endsWith(".gif"))) { try { diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java index bfda3bd81..54e7aef99 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java @@ -28,7 +28,9 @@ import static app.fedilab.android.mastodon.activities.ContextActivity.expand; import static app.fedilab.android.mastodon.helper.Helper.ARG_TIMELINE_REFRESH_ALL; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE; +import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_SOFTWARE; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN; +import static app.fedilab.android.mastodon.helper.Helper.TAG; import android.annotation.SuppressLint; import android.app.Activity; @@ -49,6 +51,7 @@ import android.os.Looper; import android.text.Html; import android.text.SpannableString; import android.text.TextUtils; +import android.util.Log; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -1995,6 +1998,8 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> currentAccount = account; SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(PREF_USER_TOKEN, account.token); + editor.putString(PREF_USER_SOFTWARE, account.software); + Log.v(TAG, "put 5: " + account.software); editor.putString(PREF_USER_INSTANCE, account.instance); editor.putString(PREF_USER_ID, account.user_id); editor.commit(); @@ -2020,6 +2025,8 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> currentAccount = account; SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(PREF_USER_TOKEN, account.token); + editor.putString(PREF_USER_SOFTWARE, account.software); + Log.v(TAG, "put 6: " + account.software); editor.putString(PREF_USER_INSTANCE, account.instance); editor.putString(PREF_USER_ID, account.user_id); editor.commit(); diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/AccountActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/AccountActivity.java index ee6bc5da0..dbb3ff861 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/AccountActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/AccountActivity.java @@ -36,6 +36,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; +import androidx.preference.PreferenceManager; import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; @@ -79,7 +80,7 @@ public class AccountActivity extends BaseBarActivity { Spanned.SPAN_INCLUSIVE_EXCLUSIVE); - SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); + SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(AccountActivity.this); String token = sharedpreferences.getString(PREF_USER_TOKEN, null); BaseAccount baseAccount = null; diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/LoginActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/LoginActivity.java index 9ccf5608e..5f07ad06e 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/LoginActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/LoginActivity.java @@ -14,7 +14,6 @@ package app.fedilab.android.peertube.activities; * You should have received a copy of the GNU General Public License along with TubeLab; if not, * see <http://www.gnu.org/licenses>. */ -import static app.fedilab.android.mastodon.helper.Helper.TAG; import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.updateCredential; import android.annotation.SuppressLint; @@ -25,7 +24,6 @@ import android.text.SpannableString; import android.text.Spanned; import android.text.style.ForegroundColorSpan; import android.text.style.UnderlineSpan; -import android.util.Log; import android.util.Patterns; import android.view.MenuItem; import android.view.View; @@ -33,6 +31,8 @@ import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; +import androidx.preference.PreferenceManager; + import java.net.MalformedURLException; import java.net.URL; @@ -163,9 +163,7 @@ public class LoginActivity extends BaseBarActivity { } client_id = oauth.getClient_id(); client_secret = oauth.getClient_secret(); - Log.v(TAG, "client_id: " + client_id); - Log.v(TAG, "client_secret: " + client_secret); - SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); + SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(LoginActivity.this); SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(Helper.CLIENT_ID, client_id); editor.putString(Helper.CLIENT_SECRET, client_secret); @@ -182,9 +180,7 @@ public class LoginActivity extends BaseBarActivity { oauthParams.setPassword(binding.loginPasswd.getText().toString()); } try { - Log.v(TAG, "token: GET"); Token token = new RetrofitPeertubeAPI(LoginActivity.this, finalInstance, null).manageToken(oauthParams); - Log.v(TAG, ">token: " + token); proceedLogin(token, finalInstance); } catch (final Exception e) { oauthParams.setUsername(binding.loginUid.getText().toString().toLowerCase().trim()); diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/MyAccountActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/MyAccountActivity.java index 11ffd307f..550311788 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/MyAccountActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/MyAccountActivity.java @@ -19,7 +19,6 @@ import static app.fedilab.android.peertube.worker.WorkHelper.NOTIFICATION_WORKER import android.Manifest; import android.app.Activity; -import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; @@ -38,6 +37,7 @@ import androidx.appcompat.widget.SwitchCompat; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import androidx.documentfile.provider.DocumentFile; +import androidx.preference.PreferenceManager; import androidx.work.WorkManager; import com.bumptech.glide.Glide; @@ -102,7 +102,7 @@ public class MyAccountActivity extends BaseBarActivity { android.R.layout.simple_spinner_dropdown_item, refresh_array); binding.refreshTime.setAdapter(refreshArray); - SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(MyAccountActivity.this); int interval = sharedpreferences.getInt(Helper.NOTIFICATION_INTERVAL, 60); binding.refreshTime.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java index f236ef904..c46736d0a 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java @@ -80,6 +80,7 @@ import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import androidx.lifecycle.ViewModelProvider; +import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -213,7 +214,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis setContentView(binding.getRoot()); videoOrientationType = videoOrientation.LANDSCAPE; max_id = "0"; - SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); + SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeActivity.this); String token = sharedpreferences.getString(PREF_USER_TOKEN, null); if (Helper.canMakeAction(PeertubeActivity.this) && !sepiaSearch) { BaseAccount account = null; @@ -954,7 +955,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis }); fetchComments(); - SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); + SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeActivity.this); setTitle(peertube.getName()); binding.peertubeDescription.setText(peertube.getDescription()); @@ -1148,7 +1149,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis if (subtitles != null) { subtitlesStr = subtitles.toString(); } - SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); + SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeActivity.this); int video_cache = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB); ProgressiveMediaSource videoSource = null; HlsMediaSource hlsMediaSource = null; @@ -1242,7 +1243,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis return; } - SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); + SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeActivity.this); |