forked from mirrors/Fedilab
improvements
This commit is contained in:
parent
c09a7a3c2b
commit
77fbebf4a7
28 changed files with 209 additions and 90 deletions
|
@ -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"
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
String nsfwAction = sharedpreferences.getString(getString(R.string.set_video_sensitive_choice), Helper.BLUR);
|
||||
if (promptNSFW && peertube != null && peertube.isNsfw() && (nsfwAction.compareTo(Helper.BLUR) == 0 || nsfwAction.compareTo(Helper.DO_NOT_LIST) == 0)) {
|
||||
AlertDialog alertDialog;
|
||||
|
@ -1346,7 +1347,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
final IntentFilter theFilter = new IntentFilter();
|
||||
theFilter.addAction(Intent.ACTION_SCREEN_ON);
|
||||
theFilter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeActivity.this);
|
||||
mPowerKeyReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
@ -1597,7 +1598,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
break;
|
||||
case AUTONEXT:
|
||||
binding.subMenuTitle.setText(R.string.set_autoplay_next_video_settings);
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeActivity.this);
|
||||
boolean autoplayNextVideo = sharedpreferences.getBoolean(getString(R.string.set_autoplay_next_video_choice), true);
|
||||
items.add(new MenuItemView(0, getString(R.string.no), !autoplayNextVideo));
|
||||
items.add(new MenuItemView(1, getString(R.string.yes), autoplayNextVideo));
|
||||
|
@ -1693,7 +1694,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
);
|
||||
break;
|
||||
case AUTONEXT:
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeActivity.this);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(getString(R.string.set_autoplay_next_video_choice), item.getId() == 1);
|
||||
editor.apply();
|
||||
|
@ -2141,7 +2142,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
}
|
||||
|
||||
private void updateHistory(long position) {
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeActivity.this);
|
||||
boolean storeInHistory = sharedpreferences.getBoolean(getString(R.string.set_store_in_history), true);
|
||||
if (Helper.isLoggedIn(PeertubeActivity.this) && peertube != null && storeInHistory) {
|
||||
new Thread(() -> {
|
||||
|
@ -2176,7 +2177,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
|
||||
@Override
|
||||
public void onMediaItemTransition(MediaItem mediaItem, int reason) {
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeActivity.this);
|
||||
boolean autoplayNextVideo = sharedpreferences.getBoolean(getString(R.string.set_autoplay_next_video_choice), true);
|
||||
if (reason == MEDIA_ITEM_TRANSITION_REASON_AUTO) {
|
||||
player.removeMediaItems(0, player.getMediaItemCount());
|
||||
|
|
|
@ -37,6 +37,7 @@ import androidx.appcompat.app.AlertDialog;
|
|||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
|
@ -91,7 +92,7 @@ public class PeertubeEditUploadActivity extends BaseBarActivity {
|
|||
View view = binding.getRoot();
|
||||
setContentView(view);
|
||||
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeEditUploadActivity.this);
|
||||
|
||||
Bundle b = getIntent().getExtras();
|
||||
|
||||
|
|
|
@ -16,11 +16,13 @@ package app.fedilab.android.peertube.activities;
|
|||
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_INSTANCE;
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID;
|
||||
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.peertube.helper.Helper.peertubeInformation;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
@ -28,6 +30,7 @@ import android.net.Uri;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -44,6 +47,7 @@ import androidx.appcompat.widget.TooltipCompat;
|
|||
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;
|
||||
|
||||
|
@ -127,7 +131,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public static void showRadioButtonDialogFullInstances(Activity activity, boolean storeInDb) {
|
||||
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
AlertDialog.Builder alt_bld = new AlertDialog.Builder(activity);
|
||||
alt_bld.setTitle(R.string.instance_choice);
|
||||
String instance = HelperInstance.getLiveInstance(activity);
|
||||
|
@ -259,6 +263,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
invalidateOptionsMenu();
|
||||
}).start();
|
||||
}
|
||||
Log.v(TAG, "logged: " + Helper.isLoggedIn(PeertubeMainActivity.this));
|
||||
if (Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
binding.viewpager.setOffscreenPageLimit(5);
|
||||
} else {
|
||||
|
@ -321,7 +326,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
}
|
||||
|
||||
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeMainActivity.this);
|
||||
int search_cast = sharedpreferences.getInt(getString(R.string.set_cast_choice), 0);
|
||||
if (search_cast == 1) {
|
||||
super.discoverCast();
|
||||
|
@ -355,10 +360,9 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
|
||||
private void refreshToken() {
|
||||
new Thread(() -> {
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeMainActivity.this);
|
||||
String tokenStr = Helper.getToken(PeertubeMainActivity.this);
|
||||
String instance = HelperInstance.getLiveInstance(PeertubeMainActivity.this);
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String instanceShar = sharedpreferences.getString(PREF_INSTANCE, null);
|
||||
String userIdShar = sharedpreferences.getString(PREF_USER_ID, null);
|
||||
BaseAccount account = null;
|
||||
|
@ -387,6 +391,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
if (token == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
runOnUiThread(() -> {
|
||||
//To avoid a token issue with subscriptions, adding fragment is done when the token is refreshed.
|
||||
new Handler().post(() -> {
|
||||
|
@ -398,6 +403,17 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
});
|
||||
|
||||
userMe = new RetrofitPeertubeAPI(PeertubeMainActivity.this, instance, token.getAccess_token()).verifyCredentials();
|
||||
account.token = token.getAccess_token();
|
||||
account.refresh_token = token.getRefresh_token();
|
||||
account.peertube_account = userMe.getAccount();
|
||||
account.software = Account.API.PEERTUBE.name();
|
||||
account.user_id = userMe.getAccount().getUserId();
|
||||
account.instance = userMe.getAccount().getHost();
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_USER_TOKEN, token.getAccess_token());
|
||||
editor.putString(PREF_USER_SOFTWARE, account.software);
|
||||
Log.v(TAG, "put 7: " + account.software);
|
||||
editor.apply();
|
||||
if (userMe != null && userMe.getAccount() != null) {
|
||||
account.peertube_account = userMe.getAccount();
|
||||
try {
|
||||
|
@ -405,7 +421,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
|
||||
editor.putString(PREF_USER_ID, account.user_id);
|
||||
editor.putBoolean(getString(R.string.set_autoplay_choice), userMe.isAutoPlayVideo());
|
||||
editor.putBoolean(getString(R.string.set_store_in_history), userMe.isVideosHistoryEnabled());
|
||||
|
@ -531,7 +547,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
settingsItem.setVisible(false);
|
||||
mostLikedItem.setVisible(true);
|
||||
incognitoItem.setVisible(true);
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeMainActivity.this);
|
||||
boolean checked = sharedpreferences.getBoolean(getString(R.string.set_store_in_history), true);
|
||||
incognitoItem.setChecked(checked);
|
||||
} else {
|
||||
|
@ -634,7 +650,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
startActivity(intent);
|
||||
} else if (item.getItemId() == R.id.action_incognito) {
|
||||
item.setChecked(!item.isChecked());
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeMainActivity.this);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(getString(R.string.set_store_in_history), item.isChecked());
|
||||
editor.apply();
|
||||
|
@ -673,7 +689,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
|
||||
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
|
||||
alt_bld.setTitle(R.string.instance_choice);
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeMainActivity.this);
|
||||
String acad = HelperInstance.getLiveInstance(PeertubeMainActivity.this);
|
||||
int i = 0;
|
||||
List<AcadInstances> acadInstances = AcadInstances.getInstances();
|
||||
|
@ -708,7 +724,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == PICK_INSTANCE && resultCode == Activity.RESULT_OK) {
|
||||
if (data != null && data.getData() != null) {
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeMainActivity.this);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_INSTANCE, String.valueOf(data.getData()));
|
||||
editor.commit();
|
||||
|
|
|
@ -17,7 +17,6 @@ package app.fedilab.android.peertube.activities;
|
|||
import static app.fedilab.android.peertube.activities.PeertubeActivity.hideKeyboard;
|
||||
import static app.fedilab.android.peertube.helper.Helper.peertubeInformation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
|
@ -27,6 +26,7 @@ import android.widget.ArrayAdapter;
|
|||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.mancj.materialsearchbar.MaterialSearchBar;
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class SepiaSearchActivity extends BaseBarActivity {
|
|||
|
||||
sepiaSearchVideo = new SepiaSearch();
|
||||
sepiaSearchChannel = new SepiaSearch();
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(SepiaSearchActivity.this);
|
||||
sepiaSearchVideo.setCount(String.valueOf(sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE)));
|
||||
sepiaSearchVideo.setDurationMin(0);
|
||||
sepiaSearchVideo.setDurationMax(9999999);
|
||||
|
|
|
@ -46,6 +46,7 @@ import androidx.fragment.app.Fragment;
|
|||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
|
@ -172,7 +173,7 @@ public class ShowChannelActivity extends BaseBarActivity {
|
|||
}
|
||||
|
||||
private void manageChannel() {
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(ShowChannelActivity.this);
|
||||
|
||||
String accountIdRelation = channel.getAcct();
|
||||
if (isLoggedIn(ShowChannelActivity.this)) {
|
||||
|
|
|
@ -16,6 +16,7 @@ package app.fedilab.android.peertube.client;
|
|||
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_INSTANCE;
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID;
|
||||
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;
|
||||
|
||||
|
@ -32,6 +33,7 @@ import android.webkit.MimeTypeMap;
|
|||
import android.webkit.URLUtil;
|
||||
|
||||
import androidx.documentfile.provider.DocumentFile;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.json.JSONException;
|
||||
|
@ -52,6 +54,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.mastodon.client.entities.app.Account;
|
||||
import app.fedilab.android.mastodon.exception.DBException;
|
||||
|
@ -121,7 +124,7 @@ public class RetrofitPeertubeAPI {
|
|||
_context = context;
|
||||
instance = HelperInstance.getLiveInstance(context);
|
||||
finalUrl = "https://" + HelperInstance.getLiveInstance(context) + "/api/v1/";
|
||||
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(_context);
|
||||
count = String.valueOf(sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE));
|
||||
String currentSensitive = sharedpreferences.getString(_context.getString(R.string.set_video_sensitive_choice), Helper.BLUR);
|
||||
if (currentSensitive.compareTo(Helper.DO_NOT_LIST) == 0) {
|
||||
|
@ -138,7 +141,7 @@ public class RetrofitPeertubeAPI {
|
|||
this.instance = instance;
|
||||
this.token = token;
|
||||
finalUrl = "https://" + instance + "/api/v1/";
|
||||
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(_context);
|
||||
count = String.valueOf(sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE));
|
||||
String currentSensitive = sharedpreferences.getString(_context.getString(R.string.set_video_sensitive_choice), Helper.BLUR);
|
||||
if (currentSensitive.compareTo(Helper.DO_NOT_LIST) == 0) {
|
||||
|
@ -158,7 +161,7 @@ public class RetrofitPeertubeAPI {
|
|||
String instance = host;
|
||||
try {
|
||||
UserMe userMe = new RetrofitPeertubeAPI(activity, instance, token).verifyCredentials();
|
||||
Log.v(TAG, "userMe: " + userMe);
|
||||
|
||||
peertubeAccount = userMe.getAccount();
|
||||
} catch (Error error) {
|
||||
Error.displayError(activity, error);
|
||||
|
@ -170,7 +173,7 @@ public class RetrofitPeertubeAPI {
|
|||
instance = URLDecoder.decode(instance, "utf-8");
|
||||
} catch (UnsupportedEncodingException ignored) {
|
||||
}
|
||||
SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
account.token = token;
|
||||
account.client_id = client_id;
|
||||
account.client_secret = client_secret;
|
||||
|
@ -179,12 +182,16 @@ public class RetrofitPeertubeAPI {
|
|||
account.api = Account.API.PEERTUBE;
|
||||
account.software = Account.API.PEERTUBE.name();
|
||||
account.peertube_account = peertubeAccount;
|
||||
account.user_id = peertubeAccount.getId();
|
||||
account.user_id = peertubeAccount.getUserId();
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_USER_ID, account.user_id);
|
||||
editor.putString(PREF_INSTANCE, host);
|
||||
editor.putString(PREF_USER_TOKEN, token);
|
||||
editor.putString(PREF_USER_SOFTWARE, account.software);
|
||||
Log.v(TAG, "put 8: " + account.software);
|
||||
editor.apply();
|
||||
|
||||
Log.v(TAG, "PREF_USER_SOFTWARE: " + account.software);
|
||||
try {
|
||||
new Account(activity).insertOrUpdate(account);
|
||||
} catch (DBException e) {
|
||||
|
@ -215,7 +222,7 @@ public class RetrofitPeertubeAPI {
|
|||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.client(okHttpClient)
|
||||
.build();
|
||||
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(_context);
|
||||
if (token == null) {
|
||||
token = Helper.getToken(_context);
|
||||
}
|
||||
|
@ -242,6 +249,7 @@ public class RetrofitPeertubeAPI {
|
|||
public Token manageToken(OauthParams oauthParams) throws Error {
|
||||
PeertubeService peertubeService = init();
|
||||
Call<Token> refreshTokenCall = null;
|
||||
Log.v(TAG, "oauthParams.getGrant_type(): " + oauthParams.getGrant_type());
|
||||
if (oauthParams.getGrant_type().compareTo("password") == 0) {
|
||||
refreshTokenCall = peertubeService.createToken(oauthParams.getClient_id(), oauthParams.getClient_secret(), oauthParams.getGrant_type(), oauthParams.getUsername(), oauthParams.getPassword());
|
||||
} else if (oauthParams.getGrant_type().compareTo("refresh_token") == 0) {
|
||||
|
@ -254,11 +262,12 @@ public class RetrofitPeertubeAPI {
|
|||
if (response.isSuccessful()) {
|
||||
Token tokenReply = response.body();
|
||||
if (oauthParams.getGrant_type().compareTo("refresh_token") == 0 && tokenReply != null) {
|
||||
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(_context);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_USER_TOKEN, tokenReply.getAccess_token());
|
||||
editor.apply();
|
||||
SQLiteDatabase db = Sqlite.getInstance(_context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
BaseMainActivity.currentToken = tokenReply.getAccess_token();
|
||||
new Account(_context).updatePeertubeToken(tokenReply);
|
||||
}
|
||||
return tokenReply;
|
||||
|
|
|
@ -18,6 +18,8 @@ package app.fedilab.android.peertube.client.data;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -133,7 +135,7 @@ public class VideoData implements Serializable {
|
|||
}
|
||||
|
||||
public String getFileUrl(String resolution, Context context) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
int mode = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL);
|
||||
List<File> files = getAllFile(context);
|
||||
if (files != null && files.size() > 0) {
|
||||
|
|
|
@ -37,6 +37,7 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -127,7 +128,7 @@ public class AboutInstanceAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
|
||||
holder.binding.aboutInstanceName.setText(aboutInstance.getName());
|
||||
holder.binding.instanceContainer.setOnClickListener(v -> {
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_INSTANCE, aboutInstance.getHost());
|
||||
editor.commit();
|
||||
|
|
|
@ -34,6 +34,7 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -136,7 +137,7 @@ public class ChannelListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||
|
||||
|
||||
private boolean isMyChannel(Channel channel) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String channeIdOwner = channel.getOwnerAccount().getId();
|
||||
String channeInstanceOwner = channel.getOwnerAccount().getHost();
|
||||
String instanceShar = sharedpreferences.getString(PREF_INSTANCE, null);
|
||||
|
|
|
@ -40,6 +40,7 @@ import androidx.appcompat.widget.PopupMenu;
|
|||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.lifecycle.ViewModelStoreOwner;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
@ -118,7 +119,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
if (video == null) {
|
||||
return;
|
||||
}
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
boolean videoInList = sharedpreferences.getBoolean(context.getString(R.string.set_video_in_list_choice), false);
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
@ -90,7 +91,7 @@ public class DisplaySepiaSearchFragment extends Fragment implements AccountsHori
|
|||
firstLoad = true;
|
||||
|
||||
assert context != null;
|
||||
sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
|
||||
binding.loader.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -33,6 +33,7 @@ import androidx.fragment.app.Fragment;
|
|||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.multidex.BuildConfig;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
@ -307,7 +308,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||
if (max_id_accounts == null) {
|
||||
max_id_accounts = "0";
|
||||
}
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
//max_id_accounts needs to work like an offset
|
||||
int tootPerPage = sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE);
|
||||
max_id_accounts = String.valueOf(Integer.parseInt(max_id_accounts) + tootPerPage);
|
||||
|
@ -339,7 +340,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||
if (max_id == null)
|
||||
max_id = "0";
|
||||
//max_id needs to work like an offset
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
int videoPerPage = sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE);
|
||||
max_id = String.valueOf(Integer.parseInt(max_id) + videoPerPage);
|
||||
if (apiResponse.getPeertubes() == null && apiResponse.getVideoPlaylist() == null) {
|
||||
|
|
|
@ -3,7 +3,6 @@ package app.fedilab.android.peertube.fragment;
|
|||
|
||||
import static app.fedilab.android.peertube.activities.PeertubeMainActivity.userMe;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
|
@ -22,6 +21,7 @@ import androidx.preference.ListPreference;
|
|||
import androidx.preference.MultiSelectListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SeekBarPreference;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
@ -93,7 +93,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
|||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
|
||||
requireActivity();
|
||||
SharedPreferences sharedpreferences = requireActivity().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
|
||||
if (key.compareTo(getString(R.string.set_video_mode_choice)) == 0) {
|
||||
|
@ -328,7 +328,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
|||
|
||||
|
||||
//****** App theme *******
|
||||
final SharedPreferences sharedpref = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
final SharedPreferences sharedpref = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||
ListPreference SET_THEME_BASE = findPreference(getString(R.string.SET_THEME_BASE));
|
||||
if (SET_THEME_BASE != null) {
|
||||
SET_THEME_BASE.getContext().setTheme(app.fedilab.android.mastodon.helper.Helper.dialogStyle());
|
||||
|
|
|
@ -15,7 +15,6 @@ package app.fedilab.android.peertube.helper;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import static android.content.Context.DOWNLOAD_SERVICE;
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_INSTANCE;
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID;
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN;
|
||||
|
@ -52,6 +51,7 @@ import android.widget.Toast;
|
|||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.avatarfirst.avatargenlib.AvatarGenerator;
|
||||
import com.bumptech.glide.Glide;
|
||||
|
@ -455,7 +455,7 @@ public class Helper {
|
|||
} else {
|
||||
webView = rootView.findViewById(webviewId);
|
||||
}
|
||||
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
webView.getSettings().setUseWideViewPort(true);
|
||||
|
@ -563,13 +563,14 @@ public class Helper {
|
|||
* @param activity Activity
|
||||
*/
|
||||
public static void logoutNoRemoval(Activity activity) {
|
||||
SharedPreferences sharedpreferences = activity.getSharedPreferences(APP_PREFS, MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_USER_TOKEN, null);
|
||||
editor.putString(CLIENT_ID, null);
|
||||
editor.putString(CLIENT_SECRET, null);
|
||||
editor.putString(PREF_USER_ID, null);
|
||||
editor.putString(PREF_INSTANCE, null);
|
||||
// editor.putString(PREF_USER_SOFTWARE, null);
|
||||
editor.apply();
|
||||
Intent loginActivity = new Intent(activity, PeertubeMainActivity.class);
|
||||
activity.startActivity(loginActivity);
|
||||
|
@ -618,7 +619,7 @@ public class Helper {
|
|||
* @return PeertubeMainActivity.TypeOfConnection
|
||||
*/
|
||||
public static PeertubeMainActivity.TypeOfConnection isLoggedInType(Context context) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String prefKeyOauthTokenT = sharedpreferences.getString(PREF_USER_TOKEN, null);
|
||||
String prefSoftware = sharedpreferences.getString(PREF_SOFTWARE, null);
|
||||
if (prefKeyOauthTokenT != null && prefSoftware == null) {
|
||||
|
@ -632,7 +633,7 @@ public class Helper {
|
|||
|
||||
public static String getToken(Context context) {
|
||||
if (isLoggedInType(context) == PeertubeMainActivity.TypeOfConnection.NORMAL) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return sharedpreferences.getString(PREF_USER_TOKEN, null);
|
||||
} else {
|
||||
return null;
|
||||
|
@ -659,14 +660,14 @@ public class Helper {
|
|||
|
||||
|
||||
public static boolean isOwner(Context context, AccountData.PeertubeAccount account) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String userId = sharedpreferences.getString(PREF_USER_ID, "");
|
||||
String instance = sharedpreferences.getString(PREF_INSTANCE, "");
|
||||
return account.getUserId().compareTo(userId) == 0 && account.getHost().compareTo(instance) == 0;
|
||||
}
|
||||
|
||||
public static boolean isVideoOwner(Context context, VideoData.Video video) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String userId = sharedpreferences.getString(PREF_USER_ID, null);
|
||||
String instance = sharedpreferences.getString(PREF_INSTANCE, null);
|
||||
if (video == null) {
|
||||
|
@ -696,7 +697,7 @@ public class Helper {
|
|||
if (files == null || files.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
int video_quality = sharedpreferences.getInt(Helper.SET_QUALITY_MODE, Helper.QUALITY_HIGH);
|
||||
if (video_quality == QUALITY_HIGH) {
|
||||
return files.get(0);
|
||||
|
|
|
@ -19,6 +19,8 @@ import static app.fedilab.android.mastodon.helper.Helper.PREF_INSTANCE;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
|
||||
public class HelperInstance {
|
||||
|
||||
|
@ -30,7 +32,7 @@ public class HelperInstance {
|
|||
* @return String domain instance
|
||||
*/
|
||||
public static String getLiveInstance(Context context) {
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return sharedpreferences.getString(PREF_INSTANCE, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,16 +14,19 @@ package app.fedilab.android.peertube.helper;
|
|||
* 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 android.content.Context.MODE_PRIVATE;
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_INSTANCE;
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID;
|
||||
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.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -58,9 +61,11 @@ public class SwitchAccountHelper {
|
|||
}
|
||||
builderSingle.setAdapter(accountsListAdapter, (dialog, which) -> {
|
||||
final BaseAccount account = accountArray[which];
|
||||
SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_USER_TOKEN, account.token);
|
||||
editor.putString(PREF_USER_SOFTWARE, account.software);
|
||||
Log.v(TAG, "put 1: " + account.software);
|
||||
editor.putString(PREF_INSTANCE, account.instance);
|
||||
editor.putString(PREF_USER_ID, account.user_id);
|
||||
editor.apply();
|
||||
|
|
|
@ -18,6 +18,8 @@ import android.annotation.SuppressLint;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import net.gotev.uploadservice.data.UploadInfo;
|
||||
import net.gotev.uploadservice.network.ServerResponse;
|
||||
import net.gotev.uploadservice.observer.request.RequestObserverDelegate;
|
||||
|
@ -55,7 +57,7 @@ public class GlobalUploadObserver implements RequestObserverDelegate {
|
|||
|
||||
if (response.has("video")) {
|
||||
String videoUuid = response.getJSONObject("video").getString("uuid");
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.VIDEO_ID, videoUuid);
|
||||
editor.commit();
|
||||
|
|
|
@ -22,13 +22,14 @@ import android.content.SharedPreferences;
|
|||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.peertube.client.data.InstanceData;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.sqlite.Sqlite;
|
||||
|
||||
|
@ -89,7 +90,7 @@ public class StoredInstanceDAO {
|
|||
return true;
|
||||
}
|
||||
ContentValues values = new ContentValues();
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String userId = sharedpreferences.getString(PREF_USER_ID, null);
|
||||
String instance = HelperInstance.getLiveInstance(context);
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import android.text.Html;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.work.ForegroundInfo;
|
||||
import androidx.work.Worker;
|
||||
import androidx.work.WorkerParameters;
|
||||
|
@ -90,7 +91,7 @@ public class NotificationsWorker extends Worker {
|
|||
@SuppressWarnings({"SwitchStatementWithoutDefaultBranch", "DuplicateBranchesInSwitch"})
|
||||
private void fetchNotification() {
|
||||
List<BaseAccount> accounts = new Account(getApplicationContext()).getPeertubeAccounts();
|
||||
SharedPreferences sharedpreferences = getApplicationContext().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
for (BaseAccount account : accounts) {
|
||||
RetrofitPeertubeAPI retrofitPeertubeAPI = new RetrofitPeertubeAPI(getApplicationContext(), account.instance, account.token);
|
||||
|
|
Loading…
Reference in a new issue