forked from mirrors/Fedilab
working
This commit is contained in:
parent
7b071eb9eb
commit
e87a347354
29 changed files with 367 additions and 175 deletions
|
@ -68,6 +68,7 @@ android {
|
|||
'src/main/res/layouts/mastodon',
|
||||
'src/main/res/layouts/peertube',
|
||||
'src/main/res/layouts',
|
||||
'src/main/layout',
|
||||
'src/main/res/drawables/mastodon',
|
||||
'src/main/res/drawables/peertube',
|
||||
'src/main/res/drawables',
|
||||
|
|
|
@ -107,7 +107,7 @@ public abstract class PeertubeBaseMainActivity extends AppCompatActivity impleme
|
|||
assert b != null;
|
||||
int state = b.getInt("state_asked", -1);
|
||||
int displayed = b.getInt("displayed", -1);
|
||||
castedTube = b.getParcelable("castedTube");
|
||||
castedTube = (VideoData.Video) b.getSerializable("castedTube");
|
||||
|
||||
if (state == 1) {
|
||||
discoverCast();
|
||||
|
|
20
app/src/main/assets/categories.json
Normal file
20
app/src/main/assets/categories.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"1": "Music",
|
||||
"2": "Films",
|
||||
"3": "Vehicles",
|
||||
"4": "Art",
|
||||
"5": "Sports",
|
||||
"6": "Travels",
|
||||
"7": "Gaming",
|
||||
"8": "People",
|
||||
"9": "Comedy",
|
||||
"10": "Entertainment",
|
||||
"11": "News & Politics",
|
||||
"12": "How To",
|
||||
"13": "Education",
|
||||
"14": "Activism",
|
||||
"15": "Science & Technology",
|
||||
"16": "Animals",
|
||||
"17": "Kids",
|
||||
"18": "Food"
|
||||
}
|
199
app/src/main/assets/languages.json
Normal file
199
app/src/main/assets/languages.json
Normal file
|
@ -0,0 +1,199 @@
|
|||
{
|
||||
"aa": "Afar",
|
||||
"ab": "Abkhazian",
|
||||
"af": "Afrikaans",
|
||||
"ak": "Akan",
|
||||
"am": "Amharic",
|
||||
"ar": "Arabic",
|
||||
"an": "Aragonese",
|
||||
"ase": "American Sign Language",
|
||||
"as": "Assamese",
|
||||
"av": "Avaric",
|
||||
"avk": "Kotava",
|
||||
"ay": "Aymara",
|
||||
"az": "Azerbaijani",
|
||||
"ba": "Bashkir",
|
||||
"bm": "Bambara",
|
||||
"be": "Belarusian",
|
||||
"bn": "Bengali",
|
||||
"bfi": "British Sign Language",
|
||||
"bi": "Bislama",
|
||||
"bo": "Tibetan",
|
||||
"bs": "Bosnian",
|
||||
"br": "Breton",
|
||||
"bg": "Bulgarian",
|
||||
"bzs": "Brazilian Sign Language",
|
||||
"ca": "Catalan",
|
||||
"cs": "Czech",
|
||||
"ch": "Chamorro",
|
||||
"ce": "Chechen",
|
||||
"cv": "Chuvash",
|
||||
"kw": "Cornish",
|
||||
"co": "Corsican",
|
||||
"cr": "Cree",
|
||||
"cse": "Czech Sign Language",
|
||||
"csl": "Chinese Sign Language",
|
||||
"cy": "Welsh",
|
||||
"da": "Danish",
|
||||
"de": "German",
|
||||
"dv": "Dhivehi",
|
||||
"dsl": "Danish Sign Language",
|
||||
"dz": "Dzongkha",
|
||||
"el": "Greek",
|
||||
"en": "English",
|
||||
"eo": "Esperanto",
|
||||
"et": "Estonian",
|
||||
"eu": "Basque",
|
||||
"ee": "Ewe",
|
||||
"fo": "Faroese",
|
||||
"fa": "Persian",
|
||||
"fj": "Fijian",
|
||||
"fi": "Finnish",
|
||||
"fr": "French",
|
||||
"fy": "Western Frisian",
|
||||
"fsl": "French Sign Language",
|
||||
"ff": "Fulah",
|
||||
"gd": "Scottish Gaelic",
|
||||
"ga": "Irish",
|
||||
"gl": "Galician",
|
||||
"gv": "Manx",
|
||||
"gn": "Guarani",
|
||||
"gsg": "German Sign Language",
|
||||
"gu": "Gujarati",
|
||||
"ht": "Haitian",
|
||||
"ha": "Hausa",
|
||||
"sh": "Serbo-Croatian",
|
||||
"he": "Hebrew",
|
||||
"hz": "Herero",
|
||||
"hi": "Hindi",
|
||||
"ho": "Hiri Motu",
|
||||
"hr": "Croatian",
|
||||
"hu": "Hungarian",
|
||||
"hy": "Armenian",
|
||||
"ig": "Igbo",
|
||||
"ii": "Sichuan Yi",
|
||||
"iu": "Inuktitut",
|
||||
"id": "Indonesian",
|
||||
"ik": "Inupiaq",
|
||||
"is": "Icelandic",
|
||||
"it": "Italian",
|
||||
"jv": "Javanese",
|
||||
"jbo": "Lojban",
|
||||
"ja": "Japanese",
|
||||
"jsl": "Japanese Sign Language",
|
||||
"kab": "Kabyle",
|
||||
"kl": "Kalaallisut",
|
||||
"kn": "Kannada",
|
||||
"ks": "Kashmiri",
|
||||
"ka": "Georgian",
|
||||
"kr": "Kanuri",
|
||||
"kk": "Kazakh",
|
||||
"km": "Khmer",
|
||||
"ki": "Kikuyu",
|
||||
"rw": "Kinyarwanda",
|
||||
"ky": "Kirghiz",
|
||||
"kv": "Komi",
|
||||
"kg": "Kongo",
|
||||
"ko": "Korean",
|
||||
"kj": "Kuanyama",
|
||||
"ku": "Kurdish",
|
||||
"lo": "Lao",
|
||||
"la": "Latin",
|
||||
"lv": "Latvian",
|
||||
"li": "Limburgan",
|
||||
"ln": "Lingala",
|
||||
"lt": "Lithuanian",
|
||||
"lb": "Luxembourgish",
|
||||
"lu": "Luba-Katanga",
|
||||
"lg": "Ganda",
|
||||
"mh": "Marshallese",
|
||||
"ml": "Malayalam",
|
||||
"mr": "Marathi",
|
||||
"mk": "Macedonian",
|
||||
"mg": "Malagasy",
|
||||
"mt": "Maltese",
|
||||
"mn": "Mongolian",
|
||||
"mi": "Maori",
|
||||
"ms": "Malay (macrolanguage)",
|
||||
"my": "Burmese",
|
||||
"na": "Nauru",
|
||||
"nv": "Navajo",
|
||||
"nr": "South Ndebele",
|
||||
"nd": "North Ndebele",
|
||||
"ng": "Ndonga",
|
||||
"ne": "Nepali (macrolanguage)",
|
||||
"nl": "Dutch",
|
||||
"nn": "Norwegian Nynorsk",
|
||||
"nb": "Norwegian Bokmål",
|
||||
"no": "Norwegian",
|
||||
"ny": "Nyanja",
|
||||
"oc": "Occitan",
|
||||
"oj": "Ojibwa",
|
||||
"or": "Oriya (macrolanguage)",
|
||||
"om": "Oromo",
|
||||
"os": "Ossetian",
|
||||
"pa": "Panjabi",
|
||||
"pks": "Pakistan Sign Language",
|
||||
"pl": "Polish",
|
||||
"pt": "Portuguese",
|
||||
"ps": "Pushto",
|
||||
"qu": "Quechua",
|
||||
"rm": "Romansh",
|
||||
"ro": "Romanian",
|
||||
"rsl": "Russian Sign Language",
|
||||
"rn": "Rundi",
|
||||
"ru": "Russian",
|
||||
"sg": "Sango",
|
||||
"sdl": "Saudi Arabian Sign Language",
|
||||
"sfs": "South African Sign Language",
|
||||
"si": "Sinhala",
|
||||
"sk": "Slovak",
|
||||
"sl": "Slovenian",
|
||||
"se": "Northern Sami",
|
||||
"sm": "Samoan",
|
||||
"sn": "Shona",
|
||||
"sd": "Sindhi",
|
||||
"so": "Somali",
|
||||
"st": "Southern Sotho",
|
||||
"es": "Spanish",
|
||||
"sq": "Albanian",
|
||||
"sc": "Sardinian",
|
||||
"sr": "Serbian",
|
||||
"ss": "Swati",
|
||||
"su": "Sundanese",
|
||||
"sw": "Swahili (macrolanguage)",
|
||||
"sv": "Swedish",
|
||||
"swl": "Swedish Sign Language",
|
||||
"ty": "Tahitian",
|
||||
"ta": "Tamil",
|
||||
"tt": "Tatar",
|
||||
"te": "Telugu",
|
||||
"tg": "Tajik",
|
||||
"tl": "Tagalog",
|
||||
"th": "Thai",
|
||||
"ti": "Tigrinya",
|
||||
"tlh": "Klingon",
|
||||
"to": "Tonga (Tonga Islands)",
|
||||
"tn": "Tswana",
|
||||
"ts": "Tsonga",
|
||||
"tk": "Turkmen",
|
||||
"tr": "Turkish",
|
||||
"tw": "Twi",
|
||||
"ug": "Uighur",
|
||||
"uk": "Ukrainian",
|
||||
"ur": "Urdu",
|
||||
"uz": "Uzbek",
|
||||
"ve": "Venda",
|
||||
"vi": "Vietnamese",
|
||||
"wa": "Walloon",
|
||||
"wo": "Wolof",
|
||||
"xh": "Xhosa",
|
||||
"yi": "Yiddish",
|
||||
"yo": "Yoruba",
|
||||
"za": "Zhuang",
|
||||
"zh": "Chinese",
|
||||
"zu": "Zulu",
|
||||
"zxx": "No linguistic content",
|
||||
"zh-Hans": "Simplified Chinese",
|
||||
"zh-Hant": "Traditional Chinese"
|
||||
}
|
|
@ -17,9 +17,10 @@ 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_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 static app.fedilab.android.mastodon.helper.Helper.displayReleaseNotesIfNeeded;
|
||||
import static app.fedilab.android.mastodon.ui.drawer.StatusAdapter.sendAction;
|
||||
|
||||
|
@ -43,7 +44,6 @@ import android.provider.BaseColumns;
|
|||
import android.text.Editable;
|
||||
import android.text.Html;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.util.Patterns;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
|
@ -330,7 +330,6 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
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();
|
||||
|
@ -725,14 +724,22 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
item.setOnMenuItemClickListener(item1 -> {
|
||||
if (!this.isFinishing()) {
|
||||
headerMenuOpen = false;
|
||||
Toasty.info(BaseMainActivity.this, getString(R.string.toast_account_changed, "@" + account.mastodon_account.acct + "@" + account.instance), Toasty.LENGTH_LONG).show();
|
||||
String acctForAccount = "";
|
||||
if (account.mastodon_account != null) {
|
||||
acctForAccount = "@" + account.mastodon_account.username + "@" + account.instance;
|
||||
} else if (account.peertube_account != null) {
|
||||
acctForAccount = "@" + account.peertube_account.getUsername() + "@" + account.instance;
|
||||
}
|
||||
Toasty.info(BaseMainActivity.this, getString(R.string.toast_account_changed, acctForAccount), Toasty.LENGTH_LONG).show();
|
||||
BaseMainActivity.currentToken = account.token;
|
||||
BaseMainActivity.currentUserID = account.user_id;
|
||||
BaseMainActivity.currentInstance = account.instance;
|
||||
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.putString(PREF_USER_INSTANCE, account.instance);
|
||||
editor.putString(PREF_USER_ID, account.user_id);
|
||||
editor.commit();
|
||||
//The user is now aut
|
||||
//The user is now authenticated, it will be redirected to MainActivity
|
||||
|
@ -968,9 +975,12 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
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;
|
||||
BaseMainActivity.currentInstance = accounts.get(0).instance;
|
||||
api = accounts.get(0).api;
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_USER_ID, accounts.get(0).user_id);
|
||||
editor.putString(PREF_USER_TOKEN, accounts.get(0).token);
|
||||
editor.putString(PREF_USER_INSTANCE, accounts.get(0).instance);
|
||||
editor.putString(PREF_USER_SOFTWARE, accounts.get(0).software);
|
||||
editor.commit();
|
||||
//The user is now aut
|
||||
|
@ -993,10 +1003,13 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
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;
|
||||
BaseMainActivity.currentInstance = accounts.get(1).instance;
|
||||
api = accounts.get(1).api;
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_USER_ID, accounts.get(1).user_id);
|
||||
editor.putString(PREF_USER_TOKEN, accounts.get(1).token);
|
||||
editor.putString(PREF_USER_SOFTWARE, accounts.get(1).software);
|
||||
editor.putString(PREF_USER_INSTANCE, accounts.get(1).instance);
|
||||
editor.commit();
|
||||
//The user is now aut
|
||||
//The user is now authenticated, it will be redirected to MainActivity
|
||||
|
@ -1061,7 +1074,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
String userIdIntent, instanceIntent, urlOfMessage;
|
||||
if (extras != null && extras.containsKey(Helper.INTENT_ACTION)) {
|
||||
userIdIntent = extras.getString(Helper.PREF_USER_ID); //Id of the account in the intent
|
||||
instanceIntent = extras.getString(Helper.PREF_INSTANCE);
|
||||
instanceIntent = extras.getString(Helper.PREF_USER_INSTANCE);
|
||||
urlOfMessage = extras.getString(Helper.PREF_MESSAGE_URL);
|
||||
if (extras.getInt(Helper.INTENT_ACTION) == Helper.NOTIFICATION_INTENT) {
|
||||
if (userIdIntent != null && instanceIntent != null && userIdIntent.equals(currentUserID) && instanceIntent.equals(currentInstance)) {
|
||||
|
@ -1078,7 +1091,6 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
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);
|
||||
|
|
|
@ -58,7 +58,6 @@ 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;
|
||||
|
@ -303,7 +302,6 @@ public class Helper {
|
|||
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";
|
||||
public static final String PREF_INSTANCE = "PREF_INSTANCE";
|
||||
|
||||
|
||||
public static final String SET_SECURITY_PROVIDER = "SET_SECURITY_PROVIDER";
|
||||
|
@ -915,10 +913,12 @@ public class Helper {
|
|||
|
||||
OauthVM oauthVM = new ViewModelProvider((ViewModelStoreOwner) activity).get(OauthVM.class);
|
||||
|
||||
//Revoke the token
|
||||
oauthVM.revokeToken(currentAccount.instance, currentAccount.token, currentAccount.client_id, currentAccount.client_secret);
|
||||
//Log out the current user
|
||||
accountDB.removeUser(currentAccount);
|
||||
if (currentAccount != null) {
|
||||
//Revoke the token
|
||||
oauthVM.revokeToken(currentAccount.instance, currentAccount.token, currentAccount.client_id, currentAccount.client_secret);
|
||||
//Log out the current user
|
||||
accountDB.removeUser(currentAccount);
|
||||
}
|
||||
BaseAccount newAccount = accountDB.getLastUsedAccount();
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
if (newAccount == null) {
|
||||
|
@ -934,7 +934,6 @@ public class Helper {
|
|||
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;
|
||||
|
|
|
@ -372,7 +372,7 @@ public class NotificationsHelper {
|
|||
intent.putExtra(Helper.PREF_USER_ID, account.user_id);
|
||||
if (targeted_account != null)
|
||||
intent.putExtra(Helper.INTENT_TARGETED_ACCOUNT, targeted_account);
|
||||
intent.putExtra(Helper.PREF_INSTANCE, account.instance);
|
||||
intent.putExtra(Helper.PREF_USER_INSTANCE, account.instance);
|
||||
notificationUrl = notification.account.avatar;
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
final String finalNotificationUrl = notificationUrl;
|
||||
|
|
|
@ -30,7 +30,6 @@ 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;
|
||||
|
@ -51,7 +50,6 @@ 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;
|
||||
|
@ -1999,7 +1997,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
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();
|
||||
|
@ -2026,7 +2023,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
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();
|
||||
|
|
|
@ -124,7 +124,7 @@ public class AccountActivity extends BaseBarActivity {
|
|||
|
||||
|
||||
TabLayout.Tab notificationTab = binding.accountTabLayout.newTab();
|
||||
if (Helper.isLoggedIn(AccountActivity.this)) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
if (badgeCount > 0) {
|
||||
binding.accountTabLayout.addTab(notificationTab.setText(getString(R.string.title_notifications) + " (" + badgeCount + ")"));
|
||||
} else {
|
||||
|
|
|
@ -21,7 +21,6 @@ import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType
|
|||
import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.REPLY;
|
||||
import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT;
|
||||
import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.REPORT_VIDEO;
|
||||
import static app.fedilab.android.peertube.helper.Helper.canMakeAction;
|
||||
import static app.fedilab.android.peertube.helper.Helper.getAttColor;
|
||||
import static app.fedilab.android.peertube.helper.Helper.isLoggedIn;
|
||||
import static app.fedilab.android.peertube.helper.Helper.loadAvatar;
|
||||
|
@ -216,7 +215,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
max_id = "0";
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeActivity.this);
|
||||
String token = sharedpreferences.getString(PREF_USER_TOKEN, null);
|
||||
if (Helper.canMakeAction(PeertubeActivity.this) && !sepiaSearch) {
|
||||
if (Helper.isLoggedIn() && !sepiaSearch) {
|
||||
BaseAccount account = null;
|
||||
try {
|
||||
account = new app.fedilab.android.mastodon.client.entities.app.Account(PeertubeActivity.this).getAccountByToken(token);
|
||||
|
@ -264,17 +263,13 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
videoUuid = b.getString("video_uuid", null);
|
||||
isMyVideo = b.getBoolean("isMyVideo", false);
|
||||
sepiaSearch = b.getBoolean("sepia_search", false);
|
||||
peertube = b.getParcelable("video");
|
||||
peertube = (VideoData.Video) b.getSerializable("video");
|
||||
}
|
||||
|
||||
|
||||
willPlayFromIntent = manageIntentUrl(intent);
|
||||
|
||||
if (Helper.isLoggedInType(PeertubeActivity.this) == PeertubeMainActivity.TypeOfConnection.REMOTE_ACCOUNT) {
|
||||
binding.peertubeLikeCount.setVisibility(View.GONE);
|
||||
binding.peertubeDislikeCount.setVisibility(View.GONE);
|
||||
binding.peertubePlaylist.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (Helper.isLoggedIn()) {
|
||||
binding.peertubePlaylist.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
@ -289,7 +284,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
}
|
||||
}
|
||||
});
|
||||
if (!Helper.canMakeAction(PeertubeActivity.this) || sepiaSearch) {
|
||||
if (!Helper.isLoggedIn() || sepiaSearch) {
|
||||
binding.writeCommentContainer.setVisibility(View.GONE);
|
||||
}
|
||||
playInMinimized = sharedpreferences.getBoolean(getString(R.string.set_video_minimize_choice), true);
|
||||
|
@ -385,7 +380,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
}
|
||||
}
|
||||
});
|
||||
if (!willPlayFromIntent && peertube != null && sepiaSearch && peertube.getEmbedUrl() != null && Helper.isLoggedIn(PeertubeActivity.this)) {
|
||||
if (!willPlayFromIntent && peertube != null && sepiaSearch && peertube.getEmbedUrl() != null && Helper.isLoggedIn()) {
|
||||
SearchVM viewModelSearch = new ViewModelProvider(PeertubeActivity.this).get(SearchVM.class);
|
||||
viewModelSearch.getVideos("0", peertube.getUuid()).observe(PeertubeActivity.this, this::manageVIewVideos);
|
||||
} else {
|
||||
|
@ -397,7 +392,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
openFullscreenDialog();
|
||||
}
|
||||
binding.postCommentButton.setOnClickListener(v -> {
|
||||
if (canMakeAction(PeertubeActivity.this) && !sepiaSearch) {
|
||||
if (Helper.isLoggedIn() && !sepiaSearch) {
|
||||
openPostComment(null, 0);
|
||||
} else {
|
||||
if (sepiaSearch) {
|
||||
|
@ -862,7 +857,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
PlaylistsVM viewModel = new ViewModelProvider(this).get(PlaylistsVM.class);
|
||||
viewModel.videoExists(videoIds).observe(this, this::manageVIewPlaylist);
|
||||
|
||||
if (!Helper.canMakeAction(PeertubeActivity.this) || sepiaSearch) {
|
||||
if (!Helper.isLoggedIn() || sepiaSearch) {
|
||||
binding.writeCommentContainer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
@ -985,7 +980,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
|
||||
|
||||
binding.peertubeLikeCount.setOnClickListener(v -> {
|
||||
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
|
||||
if (isLoggedIn() && !sepiaSearch) {
|
||||
String newState = peertube.getMyRating().equals("like") ? "none" : "like";
|
||||
PostActionsVM viewModelLike = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
|
||||
viewModelLike.post(RATEVIDEO, peertube.getId(), newState).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(RATEVIDEO, 0, apiResponse1));
|
||||
|
@ -1010,7 +1005,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
}
|
||||
});
|
||||
binding.peertubeDislikeCount.setOnClickListener(v -> {
|
||||
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
|
||||
if (isLoggedIn() && !sepiaSearch) {
|
||||
String newState = peertube.getMyRating().equals("dislike") ? "none" : "dislike";
|
||||
PostActionsVM viewModelLike = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
|
||||
viewModelLike.post(RATEVIDEO, peertube.getId(), newState).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(RATEVIDEO, 0, apiResponse1));
|
||||
|
@ -1210,14 +1205,14 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
|
||||
private void fetchComments() {
|
||||
if (peertube.isCommentsEnabled()) {
|
||||
if (Helper.canMakeAction(PeertubeActivity.this)) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
binding.postCommentButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
binding.postCommentButton.setVisibility(View.GONE);
|
||||
}
|
||||
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
||||
commentViewModel.getThread(sepiaSearch ? peertubeInstance : null, videoUuid, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
|
||||
if (Helper.canMakeAction(PeertubeActivity.this) && !sepiaSearch) {
|
||||
if (Helper.isLoggedIn() && !sepiaSearch) {
|
||||
binding.writeCommentContainer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
binding.peertubeComments.setVisibility(View.VISIBLE);
|
||||
|
@ -1698,7 +1693,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(getString(R.string.set_autoplay_next_video_choice), item.getId() == 1);
|
||||
editor.apply();
|
||||
if (Helper.isLoggedIn(PeertubeActivity.this)) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
new Thread(() -> {
|
||||
UserSettings userSettings = new UserSettings();
|
||||
userSettings.setAutoPlayNextVideo(item.getId() == 1);
|
||||
|
@ -1772,11 +1767,11 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
|
||||
|
||||
private void sendComment(Comment comment, int position) {
|
||||
if (canMakeAction(PeertubeActivity.this) && !sepiaSearch) {
|
||||
if (Helper.isLoggedIn() && !sepiaSearch) {
|
||||
if (comment == null) {
|
||||
String commentStr = binding.addCommentWrite.getText() != null ? binding.addCommentWrite.getText().toString() : "";
|
||||
if (commentStr.trim().length() > 0) {
|
||||
if (Helper.isLoggedIn(PeertubeActivity.this)) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
|
||||
viewModelComment.comment(ADD_COMMENT, peertube.getId(), null, commentStr).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(ADD_COMMENT, 0, apiResponse1));
|
||||
}
|
||||
|
@ -1785,7 +1780,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
} else {
|
||||
String commentView = binding.addCommentWrite.getText() != null ? binding.addCommentWrite.getText().toString() : "";
|
||||
if (commentView.trim().length() > 0) {
|
||||
if (Helper.isLoggedIn(PeertubeActivity.this)) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
|
||||
viewModelComment.comment(REPLY, peertube.getId(), comment.getId(), commentView).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(REPLY, position, apiResponse1));
|
||||
}
|
||||
|
@ -2143,7 +2138,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
private void updateHistory(long position) {
|
||||
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) {
|
||||
if (Helper.isLoggedIn() && peertube != null && storeInHistory) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
RetrofitPeertubeAPI api = new RetrofitPeertubeAPI(PeertubeActivity.this);
|
||||
|
|
|
@ -14,12 +14,12 @@ package app.fedilab.android.peertube.activities;
|
|||
* 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.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_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 static app.fedilab.android.peertube.helper.Helper.peertubeInformation;
|
||||
import static app.fedilab.android.peertube.helper.SwitchAccountHelper.switchDialog;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
|
@ -30,7 +30,6 @@ 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;
|
||||
|
@ -87,7 +86,6 @@ import app.fedilab.android.peertube.fragment.DisplayVideosFragment;
|
|||
import app.fedilab.android.peertube.helper.Helper;
|
||||
import app.fedilab.android.peertube.helper.HelperAcadInstance;
|
||||
import app.fedilab.android.peertube.helper.HelperInstance;
|
||||
import app.fedilab.android.peertube.helper.SwitchAccountHelper;
|
||||
import app.fedilab.android.peertube.services.RetrieveInfoService;
|
||||
import app.fedilab.android.peertube.sqlite.StoredInstanceDAO;
|
||||
import app.fedilab.android.peertube.viewmodel.TimelineVM;
|
||||
|
@ -102,11 +100,12 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
public static int PICK_INSTANCE_SURF = 5642;
|
||||
public static UserMe userMe;
|
||||
public static InstanceData.InstanceConfig instanceConfig;
|
||||
public static TypeOfConnection typeOfConnection;
|
||||
public static TypeOfConnection typeOfConnection = TypeOfConnection.NORMAL;
|
||||
public static int badgeCount;
|
||||
private DisplayVideosFragment recentFragment, locaFragment, trendingFragment, subscriptionFragment, mostLikedFragment;
|
||||
private DisplayOverviewFragment overviewFragment;
|
||||
private ActivityMainPeertubeBinding binding;
|
||||
|
||||
private final BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
|
||||
= item -> {
|
||||
int itemId = item.getItemId();
|
||||
|
@ -155,7 +154,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
WellKnownNodeinfo.NodeInfo instanceNodeInfo = new RetrofitPeertubeAPI(activity, newInstance, null).getNodeInfo();
|
||||
if (instanceNodeInfo.getSoftware() != null && instanceNodeInfo.getSoftware().getName().trim().toLowerCase().compareTo("peertube") == 0) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_INSTANCE, newInstance);
|
||||
editor.putString(PREF_USER_INSTANCE, newInstance);
|
||||
editor.commit();
|
||||
if (storeInDb) {
|
||||
newInstance = newInstance.trim().toLowerCase();
|
||||
|
@ -219,7 +218,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
typeOfConnection = TypeOfConnection.UNKNOWN;
|
||||
|
||||
badgeCount = 0;
|
||||
|
||||
binding.navView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
|
||||
|
@ -227,7 +226,6 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
}
|
||||
|
||||
recentFragment = new DisplayVideosFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(Helper.TIMELINE_TYPE, TimelineVM.TimelineType.RECENT);
|
||||
|
@ -254,7 +252,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
mostLikedFragment.setArguments(bundle);
|
||||
|
||||
overviewFragment = new DisplayOverviewFragment();
|
||||
if (!Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
if (!Helper.isLoggedIn()) {
|
||||
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
||||
binding.viewpager.setAdapter(mPagerAdapter);
|
||||
} else {
|
||||
|
@ -263,8 +261,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
invalidateOptionsMenu();
|
||||
}).start();
|
||||
}
|
||||
Log.v(TAG, "logged: " + Helper.isLoggedIn(PeertubeMainActivity.this));
|
||||
if (Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
binding.viewpager.setOffscreenPageLimit(5);
|
||||
} else {
|
||||
binding.viewpager.setOffscreenPageLimit(4);
|
||||
|
@ -303,7 +300,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
|
||||
setTitleCustom(R.string.title_discover);
|
||||
|
||||
if (Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
binding.navView.inflateMenu(R.menu.bottom_nav_menu_connected_peertube);
|
||||
refreshToken();
|
||||
|
||||
|
@ -327,8 +324,8 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
|
||||
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeMainActivity.this);
|
||||
int search_cast = sharedpreferences.getInt(getString(R.string.set_cast_choice), 0);
|
||||
if (search_cast == 1) {
|
||||
boolean search_cast = sharedpreferences.getBoolean(getString(R.string.set_cast_choice), false);
|
||||
if (search_cast) {
|
||||
super.discoverCast();
|
||||
}
|
||||
|
||||
|
@ -363,7 +360,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeMainActivity.this);
|
||||
String tokenStr = Helper.getToken(PeertubeMainActivity.this);
|
||||
String instance = HelperInstance.getLiveInstance(PeertubeMainActivity.this);
|
||||
String instanceShar = sharedpreferences.getString(PREF_INSTANCE, null);
|
||||
String instanceShar = sharedpreferences.getString(PREF_USER_INSTANCE, null);
|
||||
String userIdShar = sharedpreferences.getString(PREF_USER_ID, null);
|
||||
BaseAccount account = null;
|
||||
try {
|
||||
|
@ -372,6 +369,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
e.printStackTrace();
|
||||
}
|
||||
if (account == null) {
|
||||
|
||||
try {
|
||||
account = new Account(PeertubeMainActivity.this).getUniqAccount(userIdShar, instanceShar);
|
||||
} catch (DBException e) {
|
||||
|
@ -395,7 +393,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
runOnUiThread(() -> {
|
||||
//To avoid a token issue with subscriptions, adding fragment is done when the token is refreshed.
|
||||
new Handler().post(() -> {
|
||||
if (Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
||||
binding.viewpager.setAdapter(mPagerAdapter);
|
||||
}
|
||||
|
@ -412,7 +410,6 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
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();
|
||||
|
@ -421,7 +418,11 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
BaseAccount finalAccount1 = account;
|
||||
runOnUiThread(() -> {
|
||||
app.fedilab.android.mastodon.helper.Helper.loadPP(this, binding.profilePicture, finalAccount1);
|
||||
binding.profilePicture.setOnClickListener(v -> switchDialog(PeertubeMainActivity.this, false));
|
||||
});
|
||||
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());
|
||||
|
@ -526,20 +527,9 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
TooltipCompat.setTooltipText(accountItem.getActionView(), getText(R.string.account));
|
||||
|
||||
switch (typeOfConnection) {
|
||||
case UNKNOWN:
|
||||
accountItem.setVisible(false);
|
||||
uploadItem.setVisible(false);
|
||||
myVideosItem.setVisible(false);
|
||||
playslistItem.setVisible(false);
|
||||
historyItem.setVisible(false);
|
||||
settingsItem.setVisible(false);
|
||||
mostLikedItem.setVisible(false);
|
||||
incognitoItem.setVisible(false);
|
||||
break;
|
||||
case REMOTE_ACCOUNT:
|
||||
case NORMAL:
|
||||
accountItem.setVisible(true);
|
||||
if (Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
uploadItem.setVisible(true);
|
||||
myVideosItem.setVisible(true);
|
||||
playslistItem.setVisible(true);
|
||||
|
@ -600,9 +590,9 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
} else if (item.getItemId() == R.id.action_account) {
|
||||
Intent intent;
|
||||
if (typeOfConnection == TypeOfConnection.SURFING) {
|
||||
SwitchAccountHelper.switchDialog(PeertubeMainActivity.this, false);
|
||||
switchDialog(PeertubeMainActivity.this, false);
|
||||
} else {
|
||||
if (Helper.canMakeAction(PeertubeMainActivity.this)) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
intent = new Intent(PeertubeMainActivity.this, AccountActivity.class);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
|
||||
|
@ -706,7 +696,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
alt_bld.setSingleChoiceItems(academiesKey, position, (dialog, item) -> {
|
||||
String newInstance = academiesValue[item];
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_INSTANCE, newInstance);
|
||||
editor.putString(PREF_USER_INSTANCE, newInstance);
|
||||
editor.commit();
|
||||
dialog.dismiss();
|
||||
recreate();
|
||||
|
@ -724,7 +714,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
if (data != null && data.getData() != null) {
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(PeertubeMainActivity.this);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_INSTANCE, String.valueOf(data.getData()));
|
||||
editor.putString(PREF_USER_INSTANCE, String.valueOf(data.getData()));
|
||||
editor.commit();
|
||||
recreate();
|
||||
}
|
||||
|
@ -732,10 +722,8 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
}
|
||||
|
||||
public enum TypeOfConnection {
|
||||
UNKNOWN,
|
||||
NORMAL,
|
||||
SURFING,
|
||||
REMOTE_ACCOUNT,
|
||||
SURFING
|
||||
}
|
||||
|
||||
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
@ -747,7 +735,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
@NotNull
|
||||
@Override
|
||||
public Fragment getItem(final int position) {
|
||||
if (Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
return locaFragment;
|
||||
|
@ -777,7 +765,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
|
|||
|
||||
@Override
|
||||
public int getCount() {
|
||||
if (Helper.isLoggedIn(PeertubeMainActivity.this)) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
return 5;
|
||||
} else {
|
||||
return 4;
|
||||
|
|
|
@ -45,7 +45,7 @@ public class PlaylistsActivity extends BaseBarActivity {
|
|||
PlaylistData.Playlist playlist;
|
||||
Bundle b = getIntent().getExtras();
|
||||
if (b != null) {
|
||||
playlist = b.getParcelable("playlist");
|
||||
playlist = (PlaylistData.Playlist) b.getSerializable("playlist");
|
||||
if (playlist == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public class ShowAccountActivity extends BaseBarActivity {
|
|||
account_dn = findViewById(R.id.account_dn);
|
||||
account_pp.setBackgroundResource(R.drawable.account_pp_border);
|
||||
if (b != null) {
|
||||
account = b.getParcelable("account");
|
||||
account = (AccountData.PeertubeAccount) b.getSerializable("account");
|
||||
accountAcct = b.getString("accountAcct");
|
||||
} else {
|
||||
Toasty.error(ShowAccountActivity.this, getString(R.string.toast_error_loading_account), Toast.LENGTH_LONG).show();
|
||||
|
@ -104,7 +104,7 @@ public class ShowAccountActivity extends BaseBarActivity {
|
|||
@Override
|
||||
public boolean onCreateOptionsMenu(@NotNull Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.main_account_peertube, menu);
|
||||
if (!Helper.isLoggedIn(ShowAccountActivity.this)) {
|
||||
if (!Helper.isLoggedIn()) {
|
||||
menu.findItem(R.id.action_mute).setVisible(false);
|
||||
}
|
||||
menu.findItem(R.id.action_display_account).setVisible(false);
|
||||
|
|
|
@ -95,7 +95,7 @@ public class ShowChannelActivity extends BaseBarActivity {
|
|||
binding.accountFollow.setEnabled(false);
|
||||
binding.accountPp.setBackgroundResource(R.drawable.account_pp_border);
|
||||
if (b != null) {
|
||||
channel = b.getParcelable("channel");
|
||||
channel = (Channel) b.getSerializable("channel");
|
||||
channelAcct = b.getString("channelId");
|
||||
sepiaSearch = b.getBoolean("sepia_search", false);
|
||||
peertubeInstance = b.getString("peertube_instance", null);
|
||||
|
@ -118,7 +118,7 @@ public class ShowChannelActivity extends BaseBarActivity {
|
|||
@Override
|
||||
public boolean onCreateOptionsMenu(@NotNull Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.main_account_peertube, menu);
|
||||
if (!Helper.isLoggedIn(ShowChannelActivity.this) || sepiaSearch) {
|
||||
if (!Helper.isLoggedIn() || sepiaSearch) {
|
||||
menu.findItem(R.id.action_mute).setVisible(false);
|
||||
}
|
||||
return true;
|
||||
|
@ -176,7 +176,7 @@ public class ShowChannelActivity extends BaseBarActivity {
|
|||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(ShowChannelActivity.this);
|
||||
|
||||
String accountIdRelation = channel.getAcct();
|
||||
if (isLoggedIn(ShowChannelActivity.this)) {
|
||||
if (isLoggedIn()) {
|
||||
RelationshipVM viewModel = new ViewModelProvider(ShowChannelActivity.this).get(RelationshipVM.class);
|
||||
List<String> uids = new ArrayList<>();
|
||||
uids.add(accountIdRelation);
|
||||
|
|
|
@ -14,11 +14,10 @@ package app.fedilab.android.peertube.client;
|
|||
* 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.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_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.app.Activity;
|
||||
import android.content.Context;
|
||||
|
@ -28,7 +27,6 @@ import android.database.sqlite.SQLiteDatabase;
|
|||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.webkit.URLUtil;
|
||||
|
||||
|
@ -185,13 +183,11 @@ public class RetrofitPeertubeAPI {
|
|||
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_INSTANCE, host);
|
||||
editor.putString(PREF_USER_TOKEN, token);
|
||||
editor.putString(PREF_USER_SOFTWARE, account.software);
|
||||
Log.v(TAG, "put 8: " + account.software);
|
||||
editor.apply();
|
||||
editor.commit();
|
||||
|
||||
Log.v(TAG, "PREF_USER_SOFTWARE: " + account.software);
|
||||
try {
|
||||
new Account(activity).insertOrUpdate(account);
|
||||
} catch (DBException e) {
|
||||
|
@ -249,14 +245,12 @@ 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) {
|
||||
refreshTokenCall = peertubeService.refreshToken(oauthParams.getClient_id(), oauthParams.getClient_secret(), oauthParams.getRefresh_token(), oauthParams.getGrant_type());
|
||||
}
|
||||
if (refreshTokenCall != null) {
|
||||
Log.v(TAG, "request: " + refreshTokenCall.request());
|
||||
try {
|
||||
Response<Token> response = refreshTokenCall.execute();
|
||||
if (response.isSuccessful()) {
|
||||
|
@ -274,7 +268,6 @@ public class RetrofitPeertubeAPI {
|
|||
} else {
|
||||
Error error = new Error();
|
||||
error.setStatusCode(response.code());
|
||||
Log.v(TAG, "err: " + response.errorBody().string());
|
||||
if (response.errorBody() != null) {
|
||||
error.setError(response.errorBody().string());
|
||||
} else {
|
||||
|
|
|
@ -16,7 +16,7 @@ package app.fedilab.android.peertube.drawer;
|
|||
|
||||
|
||||
import static androidx.core.text.HtmlCompat.FROM_HTML_MODE_LEGACY;
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_INSTANCE;
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
|
@ -130,7 +130,7 @@ public class AboutInstanceAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
holder.binding.instanceContainer.setOnClickListener(v -> {
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_INSTANCE, aboutInstance.getHost());
|
||||
editor.putString(PREF_USER_INSTANCE, aboutInstance.getHost());
|
||||
editor.commit();
|
||||
Helper.logoutNoRemoval((Activity) context);
|
||||
});
|
||||
|
|
|
@ -14,8 +14,8 @@ package app.fedilab.android.peertube.drawer;
|
|||
* 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.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_INSTANCE;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
|
@ -140,7 +140,7 @@ public class ChannelListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String channeIdOwner = channel.getOwnerAccount().getId();
|
||||
String channeInstanceOwner = channel.getOwnerAccount().getHost();
|
||||
String instanceShar = sharedpreferences.getString(PREF_INSTANCE, null);
|
||||
String instanceShar = sharedpreferences.getString(PREF_USER_INSTANCE, null);
|
||||
String userIdShar = sharedpreferences.getString(PREF_USER_ID, null);
|
||||
if (channeIdOwner != null && channeInstanceOwner != null && instanceShar != null && userIdShar != null) {
|
||||
return channeIdOwner.compareTo(userIdShar) == 0 && channeInstanceOwner.compareTo(instanceShar) == 0;
|
||||
|
|
|
@ -152,7 +152,7 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||
if (!isVideoOwner) {
|
||||
popup.getMenu().findItem(R.id.action_remove_comments).setVisible(false);
|
||||
}
|
||||
if (!Helper.isLoggedIn(context)) {
|
||||
if (!Helper.isLoggedIn()) {
|
||||
popup.getMenu().findItem(R.id.action_mute).setVisible(false);
|
||||
popup.getMenu().findItem(R.id.action_remove_comments).setVisible(false);
|
||||
popup.getMenu().findItem(R.id.action_delete).setVisible(false);
|
||||
|
@ -295,7 +295,7 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||
holder.binding.postReplyButton.setVisibility(View.GONE);
|
||||
}
|
||||
holder.binding.postReplyButton.setOnClickListener(v -> {
|
||||
if (Helper.canMakeAction(context) && !sepiaSearch) {
|
||||
if (Helper.isLoggedIn() && !sepiaSearch) {
|
||||
((PeertubeActivity) context).openPostComment(comment, i);
|
||||
} else {
|
||||
if (sepiaSearch) {
|
||||
|
@ -306,7 +306,7 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||
}
|
||||
|
||||
});
|
||||
if (Helper.canMakeAction(context) && !sepiaSearch) {
|
||||
if (Helper.isLoggedIn() && !sepiaSearch) {
|
||||
holder.binding.replyButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.binding.replyButton.setVisibility(View.GONE);
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.util.List;
|
|||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.mastodon.client.entities.app.BaseAccount;
|
||||
import app.fedilab.android.mastodon.helper.MastodonHelper;
|
||||
import app.fedilab.android.peertube.helper.Helper;
|
||||
|
||||
|
||||
|
@ -76,10 +77,18 @@ public class OwnAccountsAdapter extends ArrayAdapter<BaseAccount> {
|
|||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
String acct = "";
|
||||
if (account.peertube_account != null) {
|
||||
acct = account.peertube_account.getUsername() + "@" + account.instance;
|
||||
Helper.loadAvatar(holder.account_pp.getContext(), account.peertube_account, holder.account_pp);
|
||||
} else if (account.mastodon_account != null) {
|
||||
acct = account.mastodon_account.username + "@" + account.instance;
|
||||
MastodonHelper.loadPPMastodon(holder.account_pp, account.mastodon_account);
|
||||
}
|
||||
|
||||
holder.account_un.setText(String.format("@%s", account.peertube_account.getAcct()));
|
||||
holder.account_un.setText(String.format("@%s", acct));
|
||||
//Profile picture
|
||||
Helper.loadAvatar(holder.account_pp.getContext(), account.peertube_account, holder.account_pp);
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter
|
|||
}
|
||||
}
|
||||
|
||||
if (Helper.isLoggedIn(context)) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
List<String> uids = new ArrayList<>();
|
||||
for (VideoData.Video video : apiResponse.getPeertubes()) {
|
||||
uids.add(video.getChannel().getName() + "@" + video.getChannel().getHost());
|
||||
|
|
|
@ -85,7 +85,7 @@ public class DisplaySepiaSearchFragment extends Fragment implements AccountsHori
|
|||
context = getContext();
|
||||
Bundle bundle = this.getArguments();
|
||||
if (bundle != null) {
|
||||
sepiaSearchVideo = bundle.getParcelable("sepiaSearchVideo");
|
||||
sepiaSearchVideo = (SepiaSearch) bundle.getSerializable("sepiaSearchVideo");
|
||||
}
|
||||
flag_loading = true;
|
||||
firstLoad = true;
|
||||
|
|
|
@ -381,7 +381,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||
flag_loading = false;
|
||||
firstLoad = false;
|
||||
|
||||
if (Helper.isLoggedIn(context)) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
List<String> uids = new ArrayList<>();
|
||||
for (VideoData.Video video : apiResponse.getPeertubes()) {
|
||||
if (video != null) {
|
||||
|
|
|
@ -140,7 +140,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
|||
if (set_video_sensitive_choice != null) {
|
||||
editor.putString(getString(R.string.set_video_sensitive_choice), set_video_sensitive_choice.getValue());
|
||||
editor.apply();
|
||||
if (Helper.isLoggedIn(getActivity())) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
new Thread(() -> {
|
||||
UserSettings userSettings = new UserSettings();
|
||||
userSettings.setNsfwPolicy(set_video_sensitive_choice.getValue());
|
||||
|
@ -190,7 +190,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
|||
SwitchPreference set_autoplay_choice = findPreference(getString(R.string.set_autoplay_choice));
|
||||
assert set_autoplay_choice != null;
|
||||
editor.putBoolean(getString(R.string.set_autoplay_choice), set_autoplay_choice.isChecked());
|
||||
if (Helper.isLoggedIn(getActivity())) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
new Thread(() -> {
|
||||
UserSettings userSettings = new UserSettings();
|
||||
userSettings.setAutoPlayVideo(set_autoplay_choice.isChecked());
|
||||
|
@ -212,7 +212,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
|||
SwitchPreference set_autoplay_next_video_choice = findPreference(getString(R.string.set_autoplay_next_video_choice));
|
||||
assert set_autoplay_next_video_choice != null;
|
||||
editor.putBoolean(getString(R.string.set_autoplay_next_video_choice), set_autoplay_next_video_choice.isChecked());
|
||||
if (Helper.isLoggedIn(getActivity())) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
new Thread(() -> {
|
||||
UserSettings userSettings = new UserSettings();
|
||||
userSettings.setAutoPlayNextVideo(set_autoplay_next_video_choice.isChecked());
|
||||
|
@ -240,7 +240,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
|||
if (key.compareTo(getString(R.string.set_cast_choice)) == 0) {
|
||||
SwitchPreference set_cast_choice = findPreference(getString(R.string.set_cast_choice));
|
||||
assert set_cast_choice != null;
|
||||
editor.putInt(getString(R.string.set_cast_choice), set_cast_choice.isChecked() ? 1 : 0);
|
||||
editor.putBoolean(getString(R.string.set_cast_choice), set_cast_choice.isChecked());
|
||||
Intent intentBC = new Intent(Helper.RECEIVE_CAST_SETTINGS);
|
||||
Bundle b = new Bundle();
|
||||
b.putInt("state_asked", set_cast_choice.isChecked() ? 1 : 0);
|
||||
|
@ -251,7 +251,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
|||
MultiSelectListPreference set_video_language_choice = findPreference(getString(R.string.set_video_language_choice));
|
||||
assert set_video_language_choice != null;
|
||||
editor.putStringSet(getString(R.string.set_video_language_choice), set_video_language_choice.getValues());
|
||||
if (Helper.isLoggedIn(getActivity())) {
|
||||
if (Helper.isLoggedIn()) {
|
||||
new Thread(() -> {
|
||||
UserSettings userSettings = new UserSettings();
|
||||
Set<String> language_choiceValues = set_video_language_choice.getValues();
|
||||
|
@ -286,7 +286,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
|||
startActivity(new Intent(requireActivity(), MyAccountActivity.class));
|
||||
return false;
|
||||
});
|
||||
if (!Helper.isLoggedIn(getActivity()) || userMe == null) {
|
||||
if (!Helper.isLoggedIn() || userMe == null) {
|
||||
my_account.setVisible(false);
|
||||
} else {
|
||||
my_account.setTitle(userMe.getUsername());
|
||||
|
@ -425,10 +425,10 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
|||
set_video_in_list_choice.setChecked(videosInList);
|
||||
|
||||
//****** Allow Chromecast *******
|
||||
int cast = sharedpref.getInt(getString(R.string.set_cast_choice), 0);
|
||||
boolean cast = sharedpref.getBoolean(getString(R.string.set_cast_choice), false);
|
||||
SwitchPreference set_cast_choice = findPreference(getString(R.string.set_cast_choice));
|
||||
assert set_cast_choice != null;
|
||||
set_cast_choice.setChecked(cast == 1);
|
||||
set_cast_choice.setChecked(cast);
|
||||
|
||||
//****** Language filter *********
|
||||
LinkedHashMap<String, String> languages = new LinkedHashMap<>(Helper.peertubeInformation.getLanguages());
|
||||
|
|
|
@ -15,9 +15,10 @@ package app.fedilab.android.peertube.helper;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import static android.content.Context.DOWNLOAD_SERVICE;
|
||||
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_INSTANCE;
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN;
|
||||
import static app.fedilab.android.peertube.activities.PeertubeMainActivity.typeOfConnection;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
|
@ -569,7 +570,7 @@ public class Helper {
|
|||
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_INSTANCE, null);
|
||||
// editor.putString(PREF_USER_SOFTWARE, null);
|
||||
editor.apply();
|
||||
Intent loginActivity = new Intent(activity, PeertubeMainActivity.class);
|
||||
|
@ -595,49 +596,16 @@ public class Helper {
|
|||
/**
|
||||
* Returns boolean depending if the user is authenticated
|
||||
*
|
||||
* @param context Context
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isLoggedIn(Context context) {
|
||||
return isLoggedInType(context) == PeertubeMainActivity.TypeOfConnection.NORMAL;
|
||||
public static boolean isLoggedIn() {
|
||||
return typeOfConnection == PeertubeMainActivity.TypeOfConnection.NORMAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Some actions like following writing comment can be performed with remote accounts
|
||||
*
|
||||
* @param context Context
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean canMakeAction(Context context) {
|
||||
return (isLoggedInType(context) == PeertubeMainActivity.TypeOfConnection.NORMAL || isLoggedInType(context) == PeertubeMainActivity.TypeOfConnection.REMOTE_ACCOUNT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns boolean depending if the user is authenticated
|
||||
*
|
||||
* @param context Context
|
||||
* @return PeertubeMainActivity.TypeOfConnection
|
||||
*/
|
||||
public static PeertubeMainActivity.TypeOfConnection isLoggedInType(Context context) {
|
||||
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) {
|
||||
return PeertubeMainActivity.TypeOfConnection.NORMAL;
|
||||
} else if (prefKeyOauthTokenT != null) {
|
||||
return PeertubeMainActivity.TypeOfConnection.REMOTE_ACCOUNT;
|
||||
} else {
|
||||
return PeertubeMainActivity.TypeOfConnection.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getToken(Context context) {
|
||||
if (isLoggedInType(context) == PeertubeMainActivity.TypeOfConnection.NORMAL) {
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return sharedpreferences.getString(PREF_USER_TOKEN, null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return sharedpreferences.getString(PREF_USER_TOKEN, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -662,14 +630,14 @@ public class Helper {
|
|||
public static boolean isOwner(Context context, AccountData.PeertubeAccount account) {
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String userId = sharedpreferences.getString(PREF_USER_ID, "");
|
||||
String instance = sharedpreferences.getString(PREF_INSTANCE, "");
|
||||
String instance = sharedpreferences.getString(PREF_USER_INSTANCE, "");
|
||||
return account.getUserId().compareTo(userId) == 0 && account.getHost().compareTo(instance) == 0;
|
||||
}
|
||||
|
||||
public static boolean isVideoOwner(Context context, VideoData.Video video) {
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String userId = sharedpreferences.getString(PREF_USER_ID, null);
|
||||
String instance = sharedpreferences.getString(PREF_INSTANCE, null);
|
||||
String instance = sharedpreferences.getString(PREF_USER_INSTANCE, null);
|
||||
if (video == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ package app.fedilab.android.peertube.helper;
|
|||
* 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.mastodon.helper.Helper.PREF_INSTANCE;
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -33,7 +33,7 @@ public class HelperInstance {
|
|||
*/
|
||||
public static String getLiveInstance(Context context) {
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return sharedpreferences.getString(PREF_INSTANCE, null);
|
||||
return sharedpreferences.getString(PREF_USER_INSTANCE, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,24 +14,22 @@ package app.fedilab.android.peertube.helper;
|
|||
* 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.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_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.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;
|
||||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.mastodon.client.entities.app.Account;
|
||||
import app.fedilab.android.mastodon.client.entities.app.BaseAccount;
|
||||
import app.fedilab.android.mastodon.exception.DBException;
|
||||
|
@ -65,12 +63,11 @@ public class SwitchAccountHelper {
|
|||
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_INSTANCE, account.instance);
|
||||
editor.putString(PREF_USER_ID, account.user_id);
|
||||
editor.apply();
|
||||
editor.commit();
|
||||
dialog.dismiss();
|
||||
Intent intent = new Intent(activity, BaseMainActivity.class);
|
||||
Intent intent = new Intent(activity, MainActivity.class);
|
||||
activity.startActivity(intent);
|
||||
activity.finish();
|
||||
});
|
||||
|
|
|
@ -123,7 +123,7 @@ public class TimelineVM extends AndroidViewModel {
|
|||
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext, instance, null);
|
||||
}
|
||||
APIResponse apiResponse = retrofitPeertubeAPI.getVideos(videoId, myVideo, finalCanUseToken);
|
||||
if (Helper.isLoggedIn(_mContext) && instance == null) {
|
||||
if (Helper.isLoggedIn() && instance == null) {
|
||||
if (apiResponse.getPeertubes() != null && apiResponse.getPeertubes().size() > 0 && apiResponse.getPeertubes().get(0) != null) {
|
||||
APIResponse response = new RetrofitPeertubeAPI(_mContext).getRating(videoId);
|
||||
if (response != null)
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tabLayout"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="?actionBarSize"
|
||||
android:layout_weight="1"
|
||||
|
|
|
@ -38,15 +38,29 @@
|
|||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?colorPrimary"
|
||||
android:fitsSystemWindows="true"
|
||||
app:layout_scrollFlags="scroll|enterAlways">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toolbar_title"
|
||||
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/profile_picture"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_gravity="center"
|
||||
android:contentDescription="@string/select_accounts" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toolbar_title"
|
||||
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue