summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas <tschneider.ac@gmail.com>2023-01-23 18:06:25 +0100
committerThomas <tschneider.ac@gmail.com>2023-01-23 18:06:25 +0100
commitc09a7a3c2b977af40b0c5ac1bfd2e4a2d779cd26 (patch)
tree3d32b40fb616e839fa1327880c6e9e2b1ec68248
parent1b429a31a2ce29016200ba4d5da82f69b25dea94 (diff)
improvements
-rw-r--r--app/src/main/java/app/fedilab/android/BaseMainActivity.java376
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/client/entities/app/Account.java3
-rw-r--r--app/src/main/java/app/fedilab/android/peertube/activities/LoginActivity.java3
-rw-r--r--app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java62
-rw-r--r--app/src/main/java/app/fedilab/android/peertube/activities/WebviewActivity.java4
-rw-r--r--app/src/main/java/app/fedilab/android/peertube/client/RetrofitPeertubeAPI.java16
-rw-r--r--app/src/main/java/app/fedilab/android/peertube/helper/Helper.java10
-rw-r--r--app/src/main/java/app/fedilab/android/peertube/webview/CustomWebview.java53
-rw-r--r--app/src/main/java/app/fedilab/android/peertube/webview/MastalabWebChromeClient.java4
-rw-r--r--app/src/main/java/app/fedilab/android/peertube/webview/ProxyHelper.java9
-rw-r--r--app/src/main/res/layouts/peertube/layout/activity_peertube.xml6
-rw-r--r--app/src/main/res/layouts/peertube/layout/activity_webview_peertube.xml2
12 files changed, 256 insertions, 292 deletions
diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java
index 9230ae23d..c2fdc3e70 100644
--- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java
+++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java
@@ -18,6 +18,7 @@ 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_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;
@@ -41,6 +42,7 @@ 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;
@@ -335,8 +337,195 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
});
permissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS);
}
+ NavHeaderMainBinding headerMainBinding = NavHeaderMainBinding.inflate(getLayoutInflater());
+ currentAccount = null;
+ //Update account details
+ new Thread(() -> {
+ try {
+ if (currentToken == null) {
+ 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) {
+ OkHttpClient okHttpClient = new OkHttpClient.Builder()
+ .readTimeout(60, TimeUnit.SECONDS)
+ .connectTimeout(60, TimeUnit.SECONDS)
+ .callTimeout(60, TimeUnit.SECONDS)
+ .proxy(Helper.getProxy(getApplication().getApplicationContext()))
+ .build();
+ Retrofit retrofit = new Retrofit.Builder()
+ .baseUrl("https://" + MainActivity.currentInstance + "/api/v1/")
+ .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
+ .client(okHttpClient)
+ .build();
+ MastodonAccountsService mastodonAccountsService = retrofit.create(MastodonAccountsService.class);
+ retrofit2.Call<app.fedilab.android.mastodon.client.entities.api.Account> accountCall = mastodonAccountsService.verify_credentials(MainActivity.currentToken);
+ if (accountCall != null) {
+ try {
+ retrofit2.Response<app.fedilab.android.mastodon.client.entities.api.Account> accountResponse = accountCall.execute();
+ if (accountResponse.isSuccessful()) {
+ currentAccount.mastodon_account = accountResponse.body();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ Runnable myRunnable = () -> {
+ if (currentAccount == null || currentAccount.mastodon_account == null) {
+ //It is not, the user is redirected to the login page
+ Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
+ startActivity(myIntent);
+ finish();
+ return;
+ }
+ bottomMenu = new BottomMenu(BaseMainActivity.this).hydrate(currentAccount, binding.bottomNavView);
+ if (currentAccount.mastodon_account.locked) {
+ binding.navView.getMenu().findItem(R.id.nav_follow_requests).setVisible(true);
+ }
+ if (currentAccount.admin) {
+ binding.navView.getMenu().findItem(R.id.nav_administration).setVisible(true);
+ }
+ if (bottomMenu != null) {
+ //ManageClick on bottom menu items
+ if (binding.bottomNavView.findViewById(R.id.nav_home) != null) {
+ binding.bottomNavView.findViewById(R.id.nav_home).setOnLongClickListener(view -> {
+ int position = BottomMenu.getPosition(bottomMenu, R.id.nav_home);
+ if (position >= 0) {
+ manageFilters(position);
+ }
+ return false;
+ });
+ }
+ if (binding.bottomNavView.findViewById(R.id.nav_local) != null) {
+ binding.bottomNavView.findViewById(R.id.nav_local).setOnLongClickListener(view -> {
+ int position = BottomMenu.getPosition(bottomMenu, R.id.nav_local);
+ if (position >= 0) {
+ manageFilters(position);
+ }
+ return false;
+ });
+ }
+ if (binding.bottomNavView.findViewById(R.id.nav_public) != null) {
+ binding.bottomNavView.findViewById(R.id.nav_public).setOnLongClickListener(view -> {
+ int position = BottomMenu.getPosition(bottomMenu, R.id.nav_public);
+ if (position >= 0) {
+ manageFilters(position);
+ }
+ return false;
+ });
+ }
+ binding.bottomNavView.setOnItemSelectedListener(item -> {
+ int itemId = item.getItemId();
+ int position = BottomMenu.getPosition(bottomMenu, itemId);
+ if (position >= 0) {
+ if (binding.viewPager.getCurrentItem() == position) {
+ scrollToTop();
+ binding.bottomNavView.removeBadge(itemId);
+ } else {
+ binding.viewPager.setCurrentItem(position, false);
+ }
+ }
+ return true;
+ });
+ }
+
+ currentInstance = currentAccount.instance;
+ currentUserID = currentAccount.user_id;
+
+ show_boosts = sharedpreferences.getBoolean(getString(R.string.SET_SHOW_BOOSTS) + currentUserID + currentInstance, true);
+ show_replies = sharedpreferences.getBoolean(getString(R.string.SET_SHOW_REPLIES) + currentUserID + currentInstance, true);
+ show_dms = sharedpreferences.getBoolean(getString(R.string.SET_SHOW_DMS) + currentUserID + currentInstance, true);
+ regex_home = sharedpreferences.getString(getString(R.string.SET_FILTER_REGEX_HOME) + currentUserID + currentInstance, null);
+ regex_local = sharedpreferences.getString(getString(R.string.SET_FILTER_REGEX_LOCAL) + currentUserID + currentInstance, null);
+ regex_public = sharedpreferences.getString(getString(R.string.SET_FILTER_REGEX_PUBLIC) + currentUserID + currentInstance, null);
+ show_art_nsfw = sharedpreferences.getBoolean(getString(R.string.SET_ART_WITH_NSFW) + currentUserID + currentInstance, false);
+
+ binding.profilePicture.setOnClickListener(v -> binding.drawerLayout.openDrawer(GravityCompat.START));
+ Helper.loadPP(BaseMainActivity.this, binding.profilePicture, currentAccount);
+ headerMainBinding.accountAcc.setText(String.format("%s@%s", currentAccount.mastodon_account.username, currentAccount.instance));
+ if (currentAccount.mastodon_account.display_name == null || currentAccount.mastodon_account.display_name.isEmpty()) {
+ currentAccount.mastodon_account.display_name = currentAccount.mastodon_account.acct;
+ }
+ if (!isFinishing()) {
+ headerMainBinding.accountName.setText(
+ currentAccount.mastodon_account.getSpanDisplayName(BaseMainActivity.this,
+ new WeakReference<>(headerMainBinding.accountName)),
+ TextView.BufferType.SPANNABLE);
+ }
+ float scale = sharedpreferences.getFloat(getString(R.string.SET_FONT_SCALE), 1.1f);
+ headerMainBinding.accountName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
+ headerMainBinding.accountAcc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
+ Helper.loadPP(BaseMainActivity.this, headerMainBinding.accountProfilePicture, currentAccount, false);
+ MastodonHelper.loadProfileMediaMastodon(BaseMainActivity.this, headerMainBinding.backgroundImage, currentAccount.mastodon_account, MastodonHelper.MediaAccountType.HEADER);
+ headerMainBinding.backgroundImage.setAlpha(0.5f);
+ /*
+ * Some general data are loaded when the app starts such;
+ * - Pinned timelines (in app feature)
+ * - Instance info (for limits)
+ * - Emoji for picker
+ * - Filters for timelines
+
+ */
+
+ //Update pinned timelines
+ new ViewModelProvider(BaseMainActivity.this).get(TopBarVM.class).getDBPinned()
+ .observe(this, pinned -> {
+ this.pinned = pinned;
+ //Initialize the slug of the first fragment
+ //First it's taken from db (last stored values)
+ PinnedTimelineHelper.redrawTopBarPinned(BaseMainActivity.this, binding, pinned, bottomMenu, null);
+ //Fetch remote lists for the authenticated account and update them
+ new ViewModelProvider(BaseMainActivity.this).get(TimelinesVM.class).getLists(currentInstance, currentToken)
+ .observe(this, mastodonLists ->
+ PinnedTimelineHelper.redrawTopBarPinned(BaseMainActivity.this, binding, pinned, bottomMenu, mastodonLists)
+ );
+ });
+ //Update emoji in db for the current instance
+ new ViewModelProvider(BaseMainActivity.this).get(InstancesVM.class).getEmoji(currentInstance);
+ //Retrieve instance info
+ new ViewModelProvider(BaseMainActivity.this).get(InstancesVM.class).getInstance(currentInstance)
+ .observe(BaseMainActivity.this, instance -> {
+ instanceInfo = instance.info;
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putString(getString(R.string.INSTANCE_INFO) + MainActivity.currentInstance, Instance.serialize(instanceInfo));
+ editor.apply();
+ });
+ //Retrieve filters
+ new ViewModelProvider(BaseMainActivity.this).get(FiltersVM.class).getFilters(currentInstance, currentToken)
+ .observe(BaseMainActivity.this, filters -> mainFilters = filters);
+ new ViewModelProvider(BaseMainActivity.this).get(AccountsVM.class).getConnectedAccount(currentInstance, currentToken)
+ .observe(BaseMainActivity.this, mastodonAccount -> {
+ //Initialize static var
+ if (mastodonAccount != null && currentAccount != null) {
+ currentAccount.mastodon_account = mastodonAccount;
+ displayReleaseNotesIfNeeded(BaseMainActivity.this, false);
+ new Thread(() -> {
+ try {
+ //Update account in db
+ new Account(BaseMainActivity.this).insertOrUpdate(currentAccount);
+ } catch (DBException e) {
+ e.printStackTrace();
+ }
+ }).start();
+ }
+ });
+ };
+ mainHandler.post(myRunnable);
+ }).start();
filteredAccounts = new ArrayList<>();
mamageNewIntent(getIntent());
filterFetched = false;
@@ -363,7 +552,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
.setOpenableLayout(binding.drawerLayout)
.build();
- NavHeaderMainBinding headerMainBinding = NavHeaderMainBinding.inflate(getLayoutInflater());
+
binding.navView.addHeaderView(headerMainBinding.getRoot());
binding.navView.setNavigationItemSelectedListener(menuItem -> {
int id = menuItem.getItemId();
@@ -593,192 +782,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
});
popup.show();
});
- currentAccount = null;
- //Update account details
- new Thread(() -> {
- try {
- if (currentToken == null) {
- currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null);
- }
- currentAccount = new Account(BaseMainActivity.this).getConnectedAccount();
- if (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) {
- OkHttpClient okHttpClient = new OkHttpClient.Builder()
- .readTimeout(60, TimeUnit.SECONDS)
- .connectTimeout(60, TimeUnit.SECONDS)
- .callTimeout(60, TimeUnit.SECONDS)
- .proxy(Helper.getProxy(getApplication().getApplicationContext()))
- .build();
- Retrofit retrofit = new Retrofit.Builder()
- .baseUrl("https://" + MainActivity.currentInstance + "/api/v1/")
- .addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))
- .client(okHttpClient)
- .build();
- MastodonAccountsService mastodonAccountsService = retrofit.create(MastodonAccountsService.class);
- retrofit2.Call<app.fedilab.android.mastodon.client.entities.api.Account> accountCall = mastodonAccountsService.verify_credentials(MainActivity.currentToken);
- if (accountCall != null) {
- try {
- retrofit2.Response<app.fedilab.android.mastodon.client.entities.api.Account> accountResponse = accountCall.execute();
- if (accountResponse.isSuccessful()) {
- currentAccount.mastodon_account = accountResponse.body();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- Handler mainHandler = new Handler(Looper.getMainLooper());
- Runnable myRunnable = () -> {
- if (currentAccount == null || currentAccount.mastodon_account == null) {
- //It is not, the user is redirected to the login page
- Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
- startActivity(myIntent);
- finish();
- return;
- }
- bottomMenu = new BottomMenu(BaseMainActivity.this).hydrate(currentAccount, binding.bottomNavView);
- if (currentAccount.mastodon_account.locked) {
- binding.navView.getMenu().findItem(R.id.nav_follow_requests).setVisible(true);
- }
- if (currentAccount.admin) {
- binding.navView.getMenu().findItem(R.id.nav_administration).setVisible(true);
- }
- if (bottomMenu != null) {
- //ManageClick on bottom menu items
- if (binding.bottomNavView.findViewById(R.id.nav_home) != null) {
- binding.bottomNavView.findViewById(R.id.nav_home).setOnLongClickListener(view -> {
- int position = BottomMenu.getPosition(bottomMenu, R.id.nav_home);
- if (position >= 0) {
- manageFilters(position);
- }
- return false;
- });
- }
- if (binding.bottomNavView.findViewById(R.id.nav_local) != null) {
- binding.bottomNavView.findViewById(R.id.nav_local).setOnLongClickListener(view -> {
- int position = BottomMenu.getPosition(bottomMenu, R.id.nav_local);
- if (position >= 0) {
- manageFilters(position);
- }
- return false;
- });
- }
- if (binding.bottomNavView.findViewById(R.id.nav_public) != null) {
- binding.bottomNavView.findViewById(R.id.nav_public).setOnLongClickListener(view -> {
- int position = BottomMenu.getPosition(bottomMenu, R.id.nav_public);
- if (position >= 0) {
- manageFilters(position);
- }
- return false;
- });
- }
- binding.bottomNavView.setOnItemSelectedListener(item -> {
- int itemId = item.getItemId();
- int position = BottomMenu.getPosition(bottomMenu, itemId);
- if (position >= 0) {
- if (binding.viewPager.getCurrentItem() == position) {
- scrollToTop();
- binding.bottomNavView.removeBadge(itemId);
- } else {
- binding.viewPager.setCurrentItem(position, false);
- }
- }
- return true;
- });
- }
-
- currentInstance = currentAccount.instance;
- currentUserID = currentAccount.user_id;
-
- show_boosts = sharedpreferences.getBoolean(getString(R.string.SET_SHOW_BOOSTS) + currentUserID + currentInstance, true);
- show_replies = sharedpreferences.getBoolean(getString(R.string.SET_SHOW_REPLIES) + currentUserID + currentInstance, true);
- show_dms = sharedpreferences.getBoolean(getString(R.string.SET_SHOW_DMS) + currentUserID + currentInstance, true);
- regex_home = sharedpreferences.getString(getString(R.string.SET_FILTER_REGEX_HOME) + currentUserID + currentInstance, null);
- regex_local = sharedpreferences.getString(getString(R.string.SET_FILTER_REGEX_LOCAL) + currentUserID + currentInstance, null);
- regex_public = sharedpreferences.getString(getString(R.string.SET_FILTER_REGEX_PUBLIC) + currentUserID + currentInstance, null);
- show_art_nsfw = sharedpreferences.getBoolean(getString(R.string.SET_ART_WITH_NSFW) + currentUserID + currentInstance, false);
-
- binding.profilePicture.setOnClickListener(v -> binding.drawerLayout.openDrawer(GravityCompat.START));
- Helper.loadPP(BaseMainActivity.this, binding.profilePicture, currentAccount);
- headerMainBinding.accountAcc.setText(String.format("%s@%s", currentAccount.mastodon_account.username, currentAccount.instance));
- if (currentAccount.mastodon_account.display_name == null || currentAccount.mastodon_account.display_name.isEmpty()) {
- currentAccount.mastodon_account.display_name = currentAccount.mastodon_account.acct;
- }
- if (!isFinishing()) {
- headerMainBinding.accountName.setText(
- currentAccount.mastodon_account.getSpanDisplayName(BaseMainActivity.this,
- new WeakReference<>(headerMainBinding.accountName)),
- TextView.BufferType.SPANNABLE);
- }
- float scale = sharedpreferences.getFloat(getString(R.string.SET_FONT_SCALE), 1.1f);
- headerMainBinding.accountName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
- headerMainBinding.accountAcc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale);
- Helper.loadPP(BaseMainActivity.this, headerMainBinding.accountProfilePicture, currentAccount, false);
- MastodonHelper.loadProfileMediaMastodon(BaseMainActivity.this, headerMainBinding.backgroundImage, currentAccount.mastodon_account, MastodonHelper.MediaAccountType.HEADER);
- headerMainBinding.backgroundImage.setAlpha(0.5f);
- /*
- * Some general data are loaded when the app starts such;
- * - Pinned timelines (in app feature)
- * - Instance info (for limits)
- * - Emoji for picker
- * - Filters for timelines
-
- */
-
- //Update pinned timelines
- new ViewModelProvider(BaseMainActivity.this).get(TopBarVM.class).getDBPinned()
- .observe(this, pinned -> {
- this.pinned = pinned;
- //Initialize the slug of the first fragment
- //First it's taken from db (last stored values)
- PinnedTimelineHelper.redrawTopBarPinned(BaseMainActivity.this, binding, pinned, bottomMenu, null);
- //Fetch remote lists for the authenticated account and update them
- new ViewModelProvider(BaseMainActivity.this).get(TimelinesVM.class).getLists(currentInstance, currentToken)
- .observe(this, mastodonLists ->
- PinnedTimelineHelper.redrawTopBarPinned(BaseMainActivity.this, binding, pinned, bottomMenu, mastodonLists)
- );
- });
-
- //Update emoji in db for the current instance
- new ViewModelProvider(BaseMainActivity.this).get(InstancesVM.class).getEmoji(currentInstance);
- //Retrieve instance info
- new ViewModelProvider(BaseMainActivity.this).get(InstancesVM.class).getInstance(currentInstance)
- .observe(BaseMainActivity.this, instance -> {
- instanceInfo = instance.info;
- SharedPreferences.Editor editor = sharedpreferences.edit();
- editor.putString(getString(R.string.INSTANCE_INFO) + MainActivity.currentInstance, Instance.serialize(instanceInfo));
- editor.apply();
- });
- //Retrieve filters
- new ViewModelProvider(BaseMainActivity.this).get(FiltersVM.class).getFilters(currentInstance, currentToken)
- .observe(BaseMainActivity.this, filters -> mainFilters = filters);
- new ViewModelProvider(BaseMainActivity.this).get(AccountsVM.class).getConnectedAccount(currentInstance, currentToken)
- .observe(BaseMainActivity.this, mastodonAccount -> {
- //Initialize static var
- if (mastodonAccount != null && currentAccount != null) {
- currentAccount.mastodon_account = mastodonAccount;
- displayReleaseNotesIfNeeded(BaseMainActivity.this, false);
- new Thread(() -> {
- try {
- //Update account in db
- new Account(BaseMainActivity.this).insertOrUpdate(currentAccount);
- } catch (DBException e) {
- e.printStackTrace();
- }
- }).start();
- }
- });
- };
- mainHandler.post(myRunnable);
- }).start();
//Toolbar search
binding.toolbarSearch.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
diff --git a/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/Account.java b/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/Account.java
index f6387b263..085125edf 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/Account.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/client/entities/app/Account.java
@@ -263,8 +263,9 @@ public class Account extends BaseAccount implements Serializable {
if (token.getRefresh_token() != null) {
values.put(Sqlite.COL_REFRESH_TOKEN, token.getRefresh_token());
}
- if (token.getAccess_token() != null)
+ if (token.getAccess_token() != null) {
values.put(Sqlite.COL_TOKEN, token.getAccess_token());
+ }
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
String userId = sharedpreferences.getString(Helper.PREF_USER_ID, null);
String instance = HelperInstance.getLiveInstance(context);
diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/LoginActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/LoginActivity.java
index 62506e1ed..9ccf5608e 100644
--- a/app/src/main/java/app/fedilab/android/peertube/activities/LoginActivity.java
+++ b/app/src/main/java/app/fedilab/android/peertube/activities/LoginActivity.java
@@ -182,8 +182,9 @@ 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);
+ Log.v(TAG, ">token: " + token);
proceedLogin(token, finalInstance);
} catch (final Exception e) {
oauthParams.setUsername(binding.loginUid.getText().toString().toLowerCase().trim());
diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java
index 05cbbf326..f236ef904 100644
--- a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java
+++ b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java
@@ -63,6 +63,7 @@ import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.view.inputmethod.InputMethodManager;
+import android.webkit.WebView;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
@@ -155,7 +156,6 @@ import app.fedilab.android.peertube.viewmodel.PlaylistsVM;
import app.fedilab.android.peertube.viewmodel.PostActionsVM;
import app.fedilab.android.peertube.viewmodel.SearchVM;
import app.fedilab.android.peertube.viewmodel.TimelineVM;
-import app.fedilab.android.peertube.webview.CustomWebview;
import app.fedilab.android.peertube.webview.MastalabWebChromeClient;
import app.fedilab.android.peertube.webview.MastalabWebViewClient;
import es.dmoral.toasty.Toasty;
@@ -209,6 +209,8 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ binding = ActivityPeertubeBinding.inflate(getLayoutInflater());
+ setContentView(binding.getRoot());
videoOrientationType = videoOrientation.LANDSCAPE;
max_id = "0";
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
@@ -306,7 +308,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
binding.webviewVideo.setVisibility(View.VISIBLE);
binding.mediaVideo.setVisibility(View.GONE);
binding.doubleTapPlayerView.setVisibility(View.GONE);
- CustomWebview webview_video = Helper.initializeWebview(PeertubeActivity.this, R.id.webview_video, null);
+ WebView webview_video = Helper.initializeWebview(PeertubeActivity.this, R.id.webview_video, null);
MastalabWebChromeClient mastalabWebChromeClient = new MastalabWebChromeClient(PeertubeActivity.this, webview_video, binding.mainMediaFrame, binding.videoLayout);
mastalabWebChromeClient.setOnToggledFullscreen(fullscreen -> {
@@ -1940,35 +1942,45 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
private void initControllerButtons() {
PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller);
+ if (controlView == null) {
+ return;
+ }
fullScreenIcon = controlView.findViewById(R.id.exo_fullscreen_icon);
View fullScreenButton = controlView.findViewById(R.id.exo_fullscreen_button);
- fullScreenButton.setOnClickListener(v -> {
- if (!fullScreenMode) {
- openFullscreenDialog();
- } else {
- closeFullscreenDialog();
- setRequestedOrientationCustom(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- }
- });
-
+ if (fullScreenButton != null) {
+ fullScreenButton.setOnClickListener(v -> {
+ if (!fullScreenMode) {
+ openFullscreenDialog();
+ } else {
+ closeFullscreenDialog();
+ setRequestedOrientationCustom(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ }
+ });
+ }
ImageButton playButton = controlView.findViewById(R.id.exo_play);
- playButton.setOnClickListener(v -> {
- if (autoFullscreen && !fullScreenMode) {
- openFullscreenDialog();
- }
- player.setPlayWhenReady(true);
- });
+ if (playButton != null) {
+ playButton.setOnClickListener(v -> {
+ if (autoFullscreen && !fullScreenMode) {
+ openFullscreenDialog();
+ }
+ player.setPlayWhenReady(true);
+ });
+ }
View exo_next = controlView.findViewById(R.id.exo_next);
- exo_next.setOnClickListener(v -> playNextVideo());
+ if (exo_next != null) {
+ exo_next.setOnClickListener(v -> playNextVideo());
+ }
View exoSettings = controlView.findViewById(R.id.exo_settings);
- exoSettings.setOnClickListener(v -> {
- if (binding.videoParams.getVisibility() == View.VISIBLE) {
- closeMainMenuOptions();
- } else {
- openMainMenuOptions();
- }
- });
+ if (exoSettings != null) {
+ exoSettings.setOnClickListener(v -> {
+ if (binding.videoParams.getVisibility() == View.VISIBLE) {
+ closeMainMenuOptions();
+ } else {
+ openMainMenuOptions();
+ }
+ });
+ }
}
diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/WebviewActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/WebviewActivity.java
index 2c002801c..c008e33e2 100644
--- a/app/src/main/java/app/fedilab/android/peertube/activities/WebviewActivity.java
+++ b/app/src/main/java/app/fedilab/android/peertube/activities/WebviewActivity.java
@@ -26,6 +26,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
+import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.Toast;
@@ -37,7 +38,6 @@ import org.jetbrains.annotations.NotNull;
import app.fedilab.android.R;
import app.fedilab.android.mastodon.activities.BaseBarActivity;
import app.fedilab.android.peertube.helper.Helper;
-import app.fedilab.android.peertube.webview.CustomWebview;
import app.fedilab.android.peertube.webview.MastalabWebChromeClient;
import app.fedilab.android.peertube.webview.MastalabWebViewClient;
import es.dmoral.toasty.Toasty;
@@ -47,7 +47,7 @@ public class WebviewActivity extends BaseBarActivity {
private String url;
private boolean peertubeLink;
- private CustomWebview webView;
+ private WebView webView;
@SuppressLint("SetJavaScriptEnabled")
diff --git a/app/src/main/java/app/fedilab/android/peertube/client/RetrofitPeertubeAPI.java b/app/src/main/java/app/fedilab/android/peertube/client/RetrofitPeertubeAPI.java
index 82658f4c0..18a6edf6b 100644
--- a/app/src/main/java/app/fedilab/android/peertube/client/RetrofitPeertubeAPI.java
+++ b/app/src/main/java/app/fedilab/android/peertube/client/RetrofitPeertubeAPI.java
@@ -177,19 +177,19 @@ public class RetrofitPeertubeAPI {
account.refresh_token = refresh_token;
account.instance = instance;
account.api = Account.API.PEERTUBE;
+ account.software = Account.API.PEERTUBE.name();
account.peertube_account = peertubeAccount;
- SQLiteDatabase db = Sqlite.getInstance(activity.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
- boolean userExists = false;
+ account.user_id = peertubeAccount.getId();
+ 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.apply();
try {
- SharedPreferences.Editor editor = sharedpreferences.edit();
- editor.putString(PREF_USER_ID, account.user_id);
- editor.putString(PREF_INSTANCE, host);
- editor.apply();
new Account(activity).insertOrUpdate(account);
} catch (DBException e) {
e.printStackTrace();
}
-
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -&g