From 9dca09b1d39b85d729187e53cc9900346b23f676 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 27 Jun 2020 19:08:52 +0200 Subject: [PATCH] Display account --- app/build.gradle | 1 + .../app/fedilab/fedilabtube/MainActivity.java | 6 +- .../fedilab/fedilabtube/PeertubeActivity.java | 156 +++++++-------- .../fedilabtube/ShowAccountActivity.java | 37 +--- .../asynctasks/RetrieveAccountAsyncTask.java | 1 - .../asynctasks/RetrieveAccountsAsyncTask.java | 1 - .../asynctasks/RetrieveFeedsAsyncTask.java | 21 +- .../RetrieveRelationshipAsyncTask.java | 1 - .../fedilabtube/client/entities/Peertube.java | 2 +- .../drawer/AccountsListAdapter.java | 21 +- .../fragment/DisplayStatusFragment.java | 10 +- .../fedilab/fedilabtube/helper/Helper.java | 15 +- .../OnRetrieveFeedsAccountInterface.java | 2 +- .../OnRetrieveRelationshipInterface.java | 1 - .../main/res/layout/activity_show_account.xml | 186 +----------------- 15 files changed, 127 insertions(+), 334 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9d8e175..06ec200 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -59,6 +59,7 @@ dependencies { implementation 'com.google.android.exoplayer:exoplayer:2.10.6' implementation "com.github.mabbas007:TagsEditText:1.0.5" implementation "com.github.bumptech.glide:glide:4.11.0" + annotationProcessor "com.github.bumptech.glide:compiler:4.11.0" implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" implementation 'org.apache.poi:poi:3.16' implementation "net.gotev:uploadservice:3.5.2" diff --git a/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java b/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java index 88078b9..399b28a 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java @@ -1,7 +1,6 @@ package app.fedilab.fedilabtube; import android.content.Context; -import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.AsyncTask; import android.os.Bundle; @@ -23,7 +22,6 @@ import app.fedilab.fedilabtube.asynctasks.RetrievePeertubeInformationAsyncTask; import app.fedilab.fedilabtube.helper.Helper; import static app.fedilab.fedilabtube.helper.Helper.academies; -import static app.fedilab.fedilabtube.helper.Helper.getLiveInstance; public class MainActivity extends AppCompatActivity { @@ -71,8 +69,8 @@ public class MainActivity extends AppCompatActivity { final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); String acad = sharedpreferences.getString(Helper.PREF_INSTANCE, "ac-lyon.fr"); int i = 0; - for(String item: academies){ - if( item.compareTo(acad) == 0) { + for (String item : academies) { + if (item.compareTo(acad) == 0) { break; } i++; diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java index 16f1389..3c977d9 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube; @@ -62,7 +61,6 @@ import java.util.Objects; import javax.net.ssl.HttpsURLConnection; - import app.fedilab.fedilabtube.asynctasks.ManagePlaylistsAsyncTask; import app.fedilab.fedilabtube.asynctasks.PostActionAsyncTask; import app.fedilab.fedilabtube.asynctasks.RetrievePeertubeSingleAsyncTask; @@ -162,7 +160,6 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee peertube_bookmark.setVisibility(View.GONE); - SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(PeertubeActivity.this)); @@ -178,8 +175,6 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee getSupportActionBar().setDisplayHomeAsUpEnabled(true); - - mode = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_DIRECT); if (mode != Helper.VIDEO_MODE_WEBVIEW && mode != Helper.VIDEO_MODE_DIRECT) mode = Helper.VIDEO_MODE_DIRECT; @@ -320,84 +315,83 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee new ManagePlaylistsAsyncTask(PeertubeActivity.this, GET_PLAYLIST_FOR_VIDEO, null, peertube.getId(), null, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + peertube_playlist.setOnClickListener(v -> { + if (isLoggedIn(PeertubeActivity.this)) { + if (playlists != null && peertube.getId() != null) { + PopupMenu popup = new PopupMenu(PeertubeActivity.this, peertube_playlist); - peertube_playlist.setOnClickListener(v -> { - if( isLoggedIn(PeertubeActivity.this) ) { - if (playlists != null && peertube.getId() != null) { - PopupMenu popup = new PopupMenu(PeertubeActivity.this, peertube_playlist); - - for (Playlist playlist : playlists) { - String title = null; - for (String id : playlistForVideo) { - if (playlist.getId().equals(id)) { - title = "✔ " + playlist.getDisplayName(); - break; - } + for (Playlist playlist : playlists) { + String title = null; + for (String id : playlistForVideo) { + if (playlist.getId().equals(id)) { + title = "✔ " + playlist.getDisplayName(); + break; } - if (title == null) { - title = playlist.getDisplayName(); - } - MenuItem item = popup.getMenu().add(0, 0, Menu.NONE, title); - item.setOnMenuItemClickListener(item1 -> { - item1.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); - item1.setActionView(new View(PeertubeActivity.this)); - item1.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { - @Override - public boolean onMenuItemActionExpand(MenuItem item1) { - return false; - } - - @Override - public boolean onMenuItemActionCollapse(MenuItem item1) { - return false; - } - }); - if (playlistForVideo.contains(playlist.getId())) { - item1.setTitle(playlist.getDisplayName()); - new ManagePlaylistsAsyncTask(PeertubeActivity.this, ManagePlaylistsAsyncTask.action.DELETE_VIDEOS, playlist, peertube.getId(), null, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - playlistForVideo.remove(playlist.getId()); - } else { - item1.setTitle("✔ " + playlist.getDisplayName()); - new ManagePlaylistsAsyncTask(PeertubeActivity.this, ManagePlaylistsAsyncTask.action.ADD_VIDEOS, playlist, peertube.getId(), null, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - playlistForVideo.add(playlist.getId()); - } - return false; - }); - popup.show(); } - } - }else { - Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show(); - } - }); + if (title == null) { + title = playlist.getDisplayName(); + } + MenuItem item = popup.getMenu().add(0, 0, Menu.NONE, title); + item.setOnMenuItemClickListener(item1 -> { + item1.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); + item1.setActionView(new View(PeertubeActivity.this)); + item1.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { + @Override + public boolean onMenuItemActionExpand(MenuItem item1) { + return false; + } - add_comment_read.setOnClickListener(v -> { - if( isLoggedIn(PeertubeActivity.this) ) { - add_comment_read.setVisibility(View.GONE); - add_comment_write.setVisibility(View.VISIBLE); - send.setVisibility(View.VISIBLE); - add_comment_write.requestFocus(); - add_comment_write.setSelection(add_comment_write.getText().length()); - }else { - Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show(); - } - - }); - send.setOnClickListener(v -> { - if( isLoggedIn(PeertubeActivity.this) ) { - String comment = add_comment_write.getText().toString(); - if (comment.trim().length() > 0) { - new PostActionAsyncTask(PeertubeActivity.this, PeertubeAPI.StatusAction.PEERTUBECOMMENT, peertube.getId(), null, comment, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - add_comment_write.setText(""); - add_comment_read.setVisibility(View.VISIBLE); - add_comment_write.setVisibility(View.GONE); - send.setVisibility(View.GONE); - add_comment_read.requestFocus(); + @Override + public boolean onMenuItemActionCollapse(MenuItem item1) { + return false; + } + }); + if (playlistForVideo.contains(playlist.getId())) { + item1.setTitle(playlist.getDisplayName()); + new ManagePlaylistsAsyncTask(PeertubeActivity.this, ManagePlaylistsAsyncTask.action.DELETE_VIDEOS, playlist, peertube.getId(), null, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + playlistForVideo.remove(playlist.getId()); + } else { + item1.setTitle("✔ " + playlist.getDisplayName()); + new ManagePlaylistsAsyncTask(PeertubeActivity.this, ManagePlaylistsAsyncTask.action.ADD_VIDEOS, playlist, peertube.getId(), null, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + playlistForVideo.add(playlist.getId()); + } + return false; + }); + popup.show(); } - }else { - Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show(); } - }); + } else { + Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show(); + } + }); + + add_comment_read.setOnClickListener(v -> { + if (isLoggedIn(PeertubeActivity.this)) { + add_comment_read.setVisibility(View.GONE); + add_comment_write.setVisibility(View.VISIBLE); + send.setVisibility(View.VISIBLE); + add_comment_write.requestFocus(); + add_comment_write.setSelection(add_comment_write.getText().length()); + } else { + Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show(); + } + + }); + send.setOnClickListener(v -> { + if (isLoggedIn(PeertubeActivity.this)) { + String comment = add_comment_write.getText().toString(); + if (comment.trim().length() > 0) { + new PostActionAsyncTask(PeertubeActivity.this, PeertubeAPI.StatusAction.PEERTUBECOMMENT, peertube.getId(), null, comment, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + add_comment_write.setText(""); + add_comment_read.setVisibility(View.VISIBLE); + add_comment_write.setVisibility(View.GONE); + send.setVisibility(View.GONE); + add_comment_read.requestFocus(); + } + } else { + Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show(); + } + }); peertube_playlist.setOnClickListener(v -> { @@ -471,22 +465,22 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee initResolution(); peertube_like_count.setOnClickListener(v -> { - if( isLoggedIn(PeertubeActivity.this) ) { + if (isLoggedIn(PeertubeActivity.this)) { String newState = peertube.getMyRating().equals("like") ? "none" : "like"; new PostActionAsyncTask(PeertubeActivity.this, PeertubeAPI.StatusAction.RATEVIDEO, peertube.getId(), null, newState, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); peertube.setMyRating(newState); changeColor(); - }else { + } else { Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show(); } }); peertube_dislike_count.setOnClickListener(v -> { - if( isLoggedIn(PeertubeActivity.this) ) { + if (isLoggedIn(PeertubeActivity.this)) { String newState = peertube.getMyRating().equals("dislike") ? "none" : "dislike"; new PostActionAsyncTask(PeertubeActivity.this, PeertubeAPI.StatusAction.RATEVIDEO, peertube.getId(), null, newState, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); peertube.setMyRating(newState); changeColor(); - }else { + } else { Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show(); } }); diff --git a/app/src/main/java/app/fedilab/fedilabtube/ShowAccountActivity.java b/app/src/main/java/app/fedilab/fedilabtube/ShowAccountActivity.java index a27aa84..a380286 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/ShowAccountActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/ShowAccountActivity.java @@ -3,7 +3,6 @@ package app.fedilab.fedilabtube; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.ColorStateList; -import android.database.sqlite.SQLiteDatabase; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; @@ -42,7 +41,6 @@ import app.fedilab.fedilabtube.client.APIResponse; import app.fedilab.fedilabtube.client.PeertubeAPI; import app.fedilab.fedilabtube.client.entities.Account; import app.fedilab.fedilabtube.client.entities.Error; -import app.fedilab.fedilabtube.client.entities.InstanceNodeInfo; import app.fedilab.fedilabtube.client.entities.Relationship; import app.fedilab.fedilabtube.client.entities.Status; import app.fedilab.fedilabtube.client.entities.StatusDrawerParams; @@ -54,12 +52,11 @@ import app.fedilab.fedilabtube.interfaces.OnPostActionInterface; import app.fedilab.fedilabtube.interfaces.OnRetrieveFeedsAccountInterface; import app.fedilab.fedilabtube.interfaces.OnRetrieveFeedsInterface; import app.fedilab.fedilabtube.interfaces.OnRetrieveRelationshipInterface; -import app.fedilab.fedilabtube.sqlite.AccountDAO; -import app.fedilab.fedilabtube.sqlite.Sqlite; import es.dmoral.toasty.Toasty; import static androidx.core.text.HtmlCompat.FROM_HTML_MODE_LEGACY; import static app.fedilab.fedilabtube.helper.Helper.getLiveInstance; +import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn; public class ShowAccountActivity extends AppCompatActivity implements OnPostActionInterface, OnRetrieveFeedsAccountInterface, OnRetrieveRelationshipInterface, OnRetrieveFeedsInterface { @@ -73,8 +70,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi private TextView account_note; private String userId; private Relationship relationship; - private ImageButton header_edit_profile; - private List pins; private int maxScrollSize; private boolean avatarShown = true; private ImageView account_pp; @@ -85,7 +80,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi private boolean ischannel; private AsyncTask retrieveRelationship; private action doAction; - private PeertubeAPI.StatusAction doActionAccount; @Override protected void onCreate(Bundle savedInstanceState) { @@ -93,10 +87,8 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); setContentView(R.layout.activity_show_account); setTitle(""); - pins = new ArrayList<>(); Bundle b = getIntent().getExtras(); account_follow = findViewById(R.id.account_follow); - header_edit_profile = findViewById(R.id.header_edit_profile); account_follow.setEnabled(false); account_pp = findViewById(R.id.account_pp); account_dn = findViewById(R.id.account_dn); @@ -143,11 +135,13 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); String accountIdRelation = account.getAcct(); - retrieveRelationship = new RetrieveRelationshipAsyncTask(ShowAccountActivity.this, accountIdRelation, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + if (isLoggedIn(ShowAccountActivity.this)) { + retrieveRelationship = new RetrieveRelationshipAsyncTask(ShowAccountActivity.this, accountIdRelation, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } String urlHeader = account.getHeader(); if (urlHeader != null && urlHeader.startsWith("/")) { - urlHeader = "https://"+Helper.getLiveInstance(ShowAccountActivity.this) + account.getHeader(); + urlHeader = "https://" + Helper.getLiveInstance(ShowAccountActivity.this) + account.getHeader(); } if (urlHeader != null && !urlHeader.contains("missing.png")) { ImageView banner_pp = findViewById(R.id.banner_pp); @@ -155,8 +149,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi .load(urlHeader) .into(banner_pp); } - //Peertube account watched by a Mastodon account - //Bot account TextView actionbar_title = findViewById(R.id.show_account_title); if (account.getAcct() != null) @@ -170,12 +162,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi maxScrollSize = appBar.getTotalScrollRange(); - //Timed muted account - String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); - String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null); - final SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); - final Account authenticatedAccount = new AccountDAO(ShowAccountActivity.this, db).getUniqAccount(userId, instance); - appBar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> { LinearLayout toolbarContent = findViewById(R.id.toolbar_content); if (toolbarContent != null) { @@ -293,13 +279,12 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi Helper.loadGiF(ShowAccountActivity.this, account, account_pp); //Follow button String target = account.getAcct(); - String finalTarget = target; account_follow.setOnClickListener(v -> { if (doAction == action.NOTHING) { Toasty.info(ShowAccountActivity.this, getString(R.string.nothing_to_do), Toast.LENGTH_LONG).show(); } else if (doAction == action.FOLLOW) { account_follow.setEnabled(false); - new PostActionAsyncTask(ShowAccountActivity.this, PeertubeAPI.StatusAction.FOLLOW, finalTarget, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + new PostActionAsyncTask(ShowAccountActivity.this, PeertubeAPI.StatusAction.FOLLOW, target, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else if (doAction == action.UNFOLLOW) { boolean confirm_unfollow = sharedpreferences.getBoolean(Helper.SET_UNFOLLOW_VALIDATION, true); if (confirm_unfollow) { @@ -309,13 +294,13 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi unfollowConfirm.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); unfollowConfirm.setPositiveButton(R.string.yes, (dialog, which) -> { account_follow.setEnabled(false); - new PostActionAsyncTask(ShowAccountActivity.this, PeertubeAPI.StatusAction.UNFOLLOW, finalTarget, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + new PostActionAsyncTask(ShowAccountActivity.this, PeertubeAPI.StatusAction.UNFOLLOW, target, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); dialog.dismiss(); }); unfollowConfirm.show(); } else { account_follow.setEnabled(false); - new PostActionAsyncTask(ShowAccountActivity.this, PeertubeAPI.StatusAction.UNFOLLOW, finalTarget, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + new PostActionAsyncTask(ShowAccountActivity.this, PeertubeAPI.StatusAction.UNFOLLOW, target, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } @@ -339,7 +324,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi public void onRetrieveFeeds(APIResponse apiResponse) { if (apiResponse.getError() != null) { Toasty.error(ShowAccountActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); - return; } } @@ -405,7 +389,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi } - @Override public void onDestroy() { super.onDestroy(); @@ -428,7 +411,7 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi } String target = account.getAcct(); //IF action is unfollow or mute, sends an intent to remove statuses - if (statusAction == PeertubeAPI.StatusAction.UNFOLLOW ) { + if (statusAction == PeertubeAPI.StatusAction.UNFOLLOW) { Bundle b = new Bundle(); b.putString("receive_action", targetedId); Intent intentBC = new Intent(Helper.RECEIVE_ACTION); @@ -438,7 +421,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi } - public enum action { FOLLOW, UNFOLLOW, @@ -463,7 +445,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi bundle = new Bundle(); bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.USER); bundle.putString("targetedid", account.getAcct()); - bundle.putBoolean("showReply", false); bundle.putBoolean("ischannel", ischannel); displayStatusFragment.setArguments(bundle); return displayStatusFragment; diff --git a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveAccountAsyncTask.java b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveAccountAsyncTask.java index af4c148..4e9f8de 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveAccountAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveAccountAsyncTask.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.asynctasks; import android.content.Context; diff --git a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveAccountsAsyncTask.java b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveAccountsAsyncTask.java index 60dc62b..a76adf8 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveAccountsAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveAccountsAsyncTask.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.asynctasks; import android.content.Context; diff --git a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveFeedsAsyncTask.java b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveFeedsAsyncTask.java index 59057e2..38d7544 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveFeedsAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveFeedsAsyncTask.java @@ -22,33 +22,24 @@ public class RetrieveFeedsAsyncTask extends AsyncTask { private APIResponse apiResponse; private String max_id; private OnRetrieveFeedsInterface listener; - private String targetedID; - private String tag; - private boolean showMediaOnly = false; - private boolean showPinned = false; - private boolean showReply = false; private WeakReference contextReference; - private String instanceName, remoteInstance, name; - private int timelineId; - private String search; + private String target; - private String social; - public RetrieveFeedsAsyncTask(Context context, Type action, String max_id, OnRetrieveFeedsInterface onRetrieveFeedsInterface) { this.contextReference = new WeakReference<>(context); this.action = action; this.max_id = max_id; this.listener = onRetrieveFeedsInterface; - this.search = null; + this.target = null; } - public RetrieveFeedsAsyncTask(Context context, Type action, String max_id, String search, OnRetrieveFeedsInterface onRetrieveFeedsInterface) { + public RetrieveFeedsAsyncTask(Context context, Type action, String max_id, String target, OnRetrieveFeedsInterface onRetrieveFeedsInterface) { this.contextReference = new WeakReference<>(context); this.action = action; this.max_id = max_id; this.listener = onRetrieveFeedsInterface; - this.search = search; + this.target = target; } @@ -60,7 +51,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask { return null; switch (action) { case USER: - apiResponse = peertubeAPI.getVideos(targetedID, max_id); + apiResponse = peertubeAPI.getVideos(target, max_id); break; case MYVIDEOS: peertubeAPI = new PeertubeAPI(this.contextReference.get()); @@ -72,7 +63,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask { break; case CHANNEL: peertubeAPI = new PeertubeAPI(this.contextReference.get()); - apiResponse = peertubeAPI.getVideosChannel(targetedID, max_id); + apiResponse = peertubeAPI.getVideosChannel(target, max_id); break; case CACHE_BOOKMARKS_PEERTUBE: diff --git a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveRelationshipAsyncTask.java b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveRelationshipAsyncTask.java index 4f2c114..2ae1289 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveRelationshipAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveRelationshipAsyncTask.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.asynctasks; import android.content.Context; diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Peertube.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Peertube.java index 580664a..f1a04ab 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Peertube.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Peertube.java @@ -165,7 +165,7 @@ public class Peertube { resolution = this.getResolution().get(0); if (resolution == null) return null; - if (streamService ) { + if (streamService) { return "https://" + this.host + "/static/streaming-playlists/hls/" + getUuid() + "/" + getUuid() + "-" + resolution + "-fragmented.mp4"; } else { return "https://" + this.host + "/static/webseed/" + getUuid() + "-" + resolution + ".mp4"; diff --git a/app/src/main/java/app/fedilab/fedilabtube/drawer/AccountsListAdapter.java b/app/src/main/java/app/fedilab/fedilabtube/drawer/AccountsListAdapter.java index 52a144b..34b6e74 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/drawer/AccountsListAdapter.java +++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/AccountsListAdapter.java @@ -32,7 +32,6 @@ import app.fedilab.fedilabtube.interfaces.OnPostActionInterface; import es.dmoral.toasty.Toasty; - public class AccountsListAdapter extends RecyclerView.Adapter implements OnPostActionInterface { private List accounts; @@ -95,14 +94,18 @@ public class AccountsListAdapter extends RecyclerView.Adapter { }); - Intent intent = new Intent(context, ShowAccountActivity.class); - Bundle b = new Bundle(); - b.putBoolean("peertubeaccount", true); - b.putBoolean("ischannel", true); - b.putString("targetedid", account.getAcct()); - b.putParcelable("account", account); - intent.putExtras(b); - context.startActivity(intent); + + holder.account_pp.setOnClickListener(v -> { + Intent intent = new Intent(context, ShowAccountActivity.class); + Bundle b = new Bundle(); + b.putBoolean("peertubeaccount", true); + b.putBoolean("ischannel", true); + b.putString("targetedid", account.getAcct()); + b.putParcelable("account", account); + intent.putExtras(b); + context.startActivity(intent); + }); + } @Override diff --git a/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayStatusFragment.java b/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayStatusFragment.java index f4c5162..6d6d352 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayStatusFragment.java +++ b/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayStatusFragment.java @@ -61,6 +61,7 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter private boolean ischannel; private View rootView; private RecyclerView lv_status; + private String targetedId; public DisplayStatusFragment() { } @@ -81,6 +82,7 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter if (bundle != null) { search_peertube = bundle.getString("search_peertube", null); + targetedId = bundle.getString("targetedid", null); ischannel = bundle.getBoolean("ischannel", false); } if (ischannel) { @@ -116,7 +118,7 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter if (context != null) { //Load data depending of the value if (search_peertube == null) { //Not a Peertube search - asyncTask = new RetrieveFeedsAsyncTask(context, type, "0", DisplayStatusFragment.this).execute(); + asyncTask = new RetrieveFeedsAsyncTask(context, type, "0", targetedId, DisplayStatusFragment.this).execute(); } else { asyncTask = new RetrievePeertubeSearchAsyncTask(context, "0", search_peertube, DisplayStatusFragment.this).execute(); } @@ -124,7 +126,7 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter new Handler(Looper.getMainLooper()).postDelayed(() -> { if (context != null) { if (search_peertube == null) { //Not a Peertube search - asyncTask = new RetrieveFeedsAsyncTask(context, type, "0", DisplayStatusFragment.this).execute(); + asyncTask = new RetrieveFeedsAsyncTask(context, type, "0", targetedId, DisplayStatusFragment.this).execute(); } else { asyncTask = new RetrievePeertubeSearchAsyncTask(context, "0", search_peertube, DisplayStatusFragment.this).execute(); } @@ -132,7 +134,7 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter }, 500); } - if( type != POVERVIEW) { + if (type != POVERVIEW) { lv_status.addOnScrollListener(new RecyclerView.OnScrollListener() { public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { @@ -282,7 +284,7 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter max_id = "0"; peertubeAdapater.notifyItemRangeRemoved(0, size); if (search_peertube == null) { //Not a Peertube search - asyncTask = new RetrieveFeedsAsyncTask(context, type, "0", DisplayStatusFragment.this).execute(); + asyncTask = new RetrieveFeedsAsyncTask(context, type, "0", targetedId, DisplayStatusFragment.this).execute(); } else { asyncTask = new RetrievePeertubeSearchAsyncTask(context, "0", search_peertube, DisplayStatusFragment.this).execute(); } diff --git a/app/src/main/java/app/fedilab/fedilabtube/helper/Helper.java b/app/src/main/java/app/fedilab/fedilabtube/helper/Helper.java index 9701a58..d6c3a93 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/helper/Helper.java +++ b/app/src/main/java/app/fedilab/fedilabtube/helper/Helper.java @@ -35,7 +35,6 @@ import com.bumptech.glide.load.resource.bitmap.CenterCrop; import com.bumptech.glide.load.resource.bitmap.RoundedCorners; import com.bumptech.glide.request.RequestOptions; - import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -131,13 +130,13 @@ public class Helper { "ac-dijon.fr", "ac-grenoble.fr", "education.fr", - // "ac-guadeloupe.fr", - // "ac-guyane.fr", - // "ac-reunion.fr", + // "ac-guadeloupe.fr", + // "ac-guyane.fr", + // "ac-reunion.fr", "ac-lille.fr", "ac-limoges.fr", "ac-lyon.fr", - // "ac-martinique.fr", + // "ac-martinique.fr", "ac-mayotte.fr", "ac-montpellier.fr", "ac-nancy.fr", @@ -148,7 +147,7 @@ public class Helper { "ac-poitiers.fr", "outremer.fr", "ac-rennes.fr", - // "ac-spm.fr", + // "ac-spm.fr", "ac-strasbourg.fr", "ac-toulouse.fr", "ac-versailles.fr" @@ -351,7 +350,7 @@ public class Helper { public static void loadGiF(final Context context, Account account, final ImageView imageView) { - if (account == null) { + if (account == null || account.getAvatar() == null || account.getAvatar().compareTo("null") == 0) { Glide.with(imageView.getContext()) .asDrawable() .load(R.drawable.missing_peertube) @@ -360,7 +359,7 @@ public class Helper { return; } String url = account.getAvatar(); - if (url != null && url.startsWith("/")) { + if (url.startsWith("/")) { url = Helper.getLiveInstance(context) + url; } diff --git a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrieveFeedsAccountInterface.java b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrieveFeedsAccountInterface.java index 6719da4..8296756 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrieveFeedsAccountInterface.java +++ b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrieveFeedsAccountInterface.java @@ -1,8 +1,8 @@ - package app.fedilab.fedilabtube.interfaces; import java.util.List; + import app.fedilab.fedilabtube.client.entities.Status; public interface OnRetrieveFeedsAccountInterface { diff --git a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrieveRelationshipInterface.java b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrieveRelationshipInterface.java index 83e73dc..317ade0 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrieveRelationshipInterface.java +++ b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrieveRelationshipInterface.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.interfaces; diff --git a/app/src/main/res/layout/activity_show_account.xml b/app/src/main/res/layout/activity_show_account.xml index 4a4ca1e..6ed631d 100644 --- a/app/src/main/res/layout/activity_show_account.xml +++ b/app/src/main/res/layout/activity_show_account.xml @@ -14,7 +14,6 @@ android:fitsSystemWindows="true"> - + android:textColor="@android:color/white" + android:textSize="16sp" /> + android:textColor="@android:color/white" + android:textSize="14sp" /> @@ -161,6 +160,7 @@ android:layout_marginTop="5dp" android:gravity="center" android:padding="10dp" + android:textColor="@android:color/white" android:textIsSelectable="true" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -394,7 +221,8 @@ android:layout_height="wrap_content" android:animationCache="true" android:orientation="horizontal" - android:visibility="gone"> + android:visibility="gone" + tools:ignore="UseCompoundDrawables">