diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4044781..416dd53 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -12,7 +13,8 @@ diff --git a/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java b/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java index f6a8c0a..f4ec908 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java @@ -1,15 +1,18 @@ package app.fedilab.fedilabtube; +import android.os.AsyncTask; import android.os.Bundle; -import com.google.android.material.bottomnavigation.BottomNavigationView; - import androidx.appcompat.app.AppCompatActivity; import androidx.navigation.NavController; import androidx.navigation.Navigation; import androidx.navigation.ui.AppBarConfiguration; import androidx.navigation.ui.NavigationUI; +import com.google.android.material.bottomnavigation.BottomNavigationView; + +import app.fedilab.fedilabtube.asynctasks.RetrievePeertubeInformationAsyncTask; + public class MainActivity extends AppCompatActivity { @Override @@ -17,10 +20,16 @@ public class MainActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); BottomNavigationView navView = findViewById(R.id.nav_view); + + try { + new RetrievePeertubeInformationAsyncTask(MainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } catch (Exception ignored) { + } + // Passing each menu ID as a set of Ids because each // menu should be considered as top level destinations. AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder( - R.id.navigation_home, R.id.navigation_recently_added, R.id.navigation_most_liked, R.id.navigation_trending, R.id.navigation_discover) + R.id.navigation_discover, R.id.navigation_trending, R.id.navigation_most_liked, R.id.navigation_recently_added, R.id.navigation_home) .build(); NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment); NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration); diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java index e55e387..7b41582 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; @@ -17,7 +16,6 @@ import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.text.Html; -import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; @@ -35,7 +33,6 @@ import android.widget.ScrollView; import android.widget.TextView; import android.widget.Toast; -import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.AppCompatImageView; import androidx.appcompat.widget.PopupMenu; @@ -64,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; @@ -96,6 +92,7 @@ import es.dmoral.toasty.Toasty; import static app.fedilab.fedilabtube.asynctasks.ManagePlaylistsAsyncTask.action.GET_PLAYLIST; import static app.fedilab.fedilabtube.asynctasks.ManagePlaylistsAsyncTask.action.GET_PLAYLIST_FOR_VIDEO; import static app.fedilab.fedilabtube.helper.Helper.changeDrawableColor; +import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn; public class PeertubeActivity extends AppCompatActivity implements OnRetrievePeertubeInterface, OnPostActionInterface, OnPlaylistActionInterface { @@ -107,7 +104,6 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee private TextView peertube_view_count, peertube_playlist, peertube_bookmark, peertube_like_count, peertube_dislike_count, peertube_share, peertube_download, peertube_description, peertube_title; private ScrollView peertube_information_container; private Peertube peertube; - private TextView toolbar_title; private PlayerView playerView; private SimpleExoPlayer player; private boolean fullScreenMode; @@ -158,29 +154,11 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee add_comment_write = findViewById(R.id.add_comment_write); peertube_playlist = findViewById(R.id.peertube_playlist); send = findViewById(R.id.send); - add_comment_read.setOnClickListener(v -> { - 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()); - }); peertube_playlist.setVisibility(View.VISIBLE); peertube_bookmark.setVisibility(View.GONE); - send.setOnClickListener(v -> { - 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(); - } - }); SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); @@ -189,22 +167,12 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee Helper.loadGiF(PeertubeActivity.this, account, my_pp); Bundle b = getIntent().getExtras(); if (b != null) { - peertubeInstance = b.getString("peertube_instance", null); + peertubeInstance = b.getString("peertube_instance", Helper.getLiveInstance(PeertubeActivity.this)); videoId = b.getString("video_id", null); } + if (getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); - assert inflater != null; - View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(PeertubeActivity.this), false); - actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); - ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close); - toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title); - toolbar_close.setOnClickListener(v -> finish()); - } mode = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_DIRECT); @@ -346,6 +314,84 @@ 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); + + 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(); + } + }); + + 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 -> { if (playlists != null && peertube.getId() != null) { @@ -406,8 +452,7 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee write_comment_container.setVisibility(View.GONE); } SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); - - toolbar_title.setText(peertube.getName()); + setTitle(peertube.getName()); peertube_description.setText(peertube.getDescription()); peertube_title.setText(peertube.getName()); peertube_dislike_count.setText(String.valueOf(peertube.getDislike())); @@ -419,17 +464,26 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee initResolution(); peertube_like_count.setOnClickListener(v -> { - 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(); + 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 { + Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show(); + } }); peertube_dislike_count.setOnClickListener(v -> { - 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(); + 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 { + Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show(); + } }); + try { HttpsURLConnection.setDefaultSSLSocketFactory(new TLSSocketFactory(instance)); } catch (KeyManagementException | NoSuchAlgorithmException e) { diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeEditUploadActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeEditUploadActivity.java index 4cb3b51..43b259b 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeEditUploadActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeEditUploadActivity.java @@ -1,7 +1,6 @@ package app.fedilab.fedilabtube; - import android.content.Intent; import android.content.SharedPreferences; import android.os.AsyncTask; diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeUploadActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeUploadActivity.java index 9e18f38..82cce0a 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeUploadActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeUploadActivity.java @@ -48,7 +48,6 @@ import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; - import java.util.List; import java.util.Map; import java.util.UUID; diff --git a/app/src/main/java/app/fedilab/fedilabtube/WebviewActivity.java b/app/src/main/java/app/fedilab/fedilabtube/WebviewActivity.java index 7f9150b..f6bc725 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/WebviewActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/WebviewActivity.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube; diff --git a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/ManagePlaylistsAsyncTask.java b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/ManagePlaylistsAsyncTask.java index c907c07..3db6c32 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/ManagePlaylistsAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/ManagePlaylistsAsyncTask.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.asynctasks; import android.content.Context; @@ -7,6 +6,7 @@ import android.database.sqlite.SQLiteDatabase; import android.os.AsyncTask; import java.lang.ref.WeakReference; +import java.util.ArrayList; import app.fedilab.fedilabtube.client.APIResponse; import app.fedilab.fedilabtube.client.PeertubeAPI; @@ -45,7 +45,11 @@ public class ManagePlaylistsAsyncTask extends AsyncTask { String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(contextReference.get())); SQLiteDatabase db = Sqlite.getInstance(contextReference.get().getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); Account account = new AccountDAO(contextReference.get(), db).getUniqAccount(userId, instance); - if (apiAction == action.GET_PLAYLIST) { + if (account == null) { + statusCode = 403; + apiResponse = new APIResponse(); + apiResponse.setPlaylists(new ArrayList<>()); + } else if (apiAction == action.GET_PLAYLIST) { apiResponse = new PeertubeAPI(contextReference.get()).getPlayists(account.getUsername()); } else if (apiAction == action.GET_LIST_VIDEOS) { apiResponse = new PeertubeAPI(contextReference.get()).getPlaylistVideos(playlist.getId(), max_id, null); diff --git a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/PostActionAsyncTask.java b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/PostActionAsyncTask.java index ae295c3..f1245db 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/PostActionAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/PostActionAsyncTask.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/PostPeertubeAsyncTask.java b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/PostPeertubeAsyncTask.java index 3333650..93d81c9 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/PostPeertubeAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/PostPeertubeAsyncTask.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 40ffea6..59057e2 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveFeedsAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrieveFeedsAsyncTask.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.asynctasks; import android.content.Context; @@ -102,6 +101,14 @@ public class RetrieveFeedsAsyncTask extends AsyncTask { peertubeAPI = new PeertubeAPI(this.contextReference.get()); apiResponse = peertubeAPI.getLocalTL(max_id); break; + case PPUBLIC: + peertubeAPI = new PeertubeAPI(this.contextReference.get()); + apiResponse = peertubeAPI.getPublicTL(max_id); + break; + case PMOSTLIKED: + peertubeAPI = new PeertubeAPI(this.contextReference.get()); + apiResponse = peertubeAPI.getLikedTL(max_id); + break; } return null; diff --git a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeChannelsAsyncTask.java b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeChannelsAsyncTask.java index f8a0f84..acf944c 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeChannelsAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeChannelsAsyncTask.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/RetrievePeertubeInformationAsyncTask.java b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeInformationAsyncTask.java index 4731d1f..aee3de2 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeInformationAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeInformationAsyncTask.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/RetrievePeertubeNotificationsAsyncTask.java b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeNotificationsAsyncTask.java index 08ac8df..7939ae2 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeNotificationsAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeNotificationsAsyncTask.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/RetrievePeertubeSearchAsyncTask.java b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeSearchAsyncTask.java index adbb2e6..97190ac 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeSearchAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeSearchAsyncTask.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/RetrievePeertubeSingleAsyncTask.java b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeSingleAsyncTask.java index cbe9957..2a2d0de 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeSingleAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeSingleAsyncTask.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/RetrievePeertubeSingleCommentsAsyncTask.java b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeSingleCommentsAsyncTask.java index 5d75b11..4167f2f 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeSingleCommentsAsyncTask.java +++ b/app/src/main/java/app/fedilab/fedilabtube/asynctasks/RetrievePeertubeSingleCommentsAsyncTask.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/APIResponse.java b/app/src/main/java/app/fedilab/fedilabtube/client/APIResponse.java index 22553b0..e44b0af 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/APIResponse.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/APIResponse.java @@ -1,16 +1,14 @@ package app.fedilab.fedilabtube.client; - - import java.util.List; import app.fedilab.fedilabtube.client.entities.Account; +import app.fedilab.fedilabtube.client.entities.Error; import app.fedilab.fedilabtube.client.entities.Instance; import app.fedilab.fedilabtube.client.entities.Peertube; import app.fedilab.fedilabtube.client.entities.PeertubeNotification; import app.fedilab.fedilabtube.client.entities.Playlist; -import app.fedilab.fedilabtube.client.entities.Error; import app.fedilab.fedilabtube.client.entities.Status; public class APIResponse { @@ -69,7 +67,6 @@ public class APIResponse { } - public List getPeertubes() { return peertubes; } @@ -79,7 +76,6 @@ public class APIResponse { } - public List getPeertubeNotifications() { return peertubeNotifications; } @@ -89,7 +85,6 @@ public class APIResponse { } - public List getPlaylists() { return playlists; } diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/HttpsConnection.java b/app/src/main/java/app/fedilab/fedilabtube/client/HttpsConnection.java index 2fc14a0..4ce4940 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/HttpsConnection.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/HttpsConnection.java @@ -7,7 +7,6 @@ import android.os.Build; import android.text.Html; import android.text.SpannableString; - import com.google.gson.JsonObject; import net.gotev.uploadservice.MultipartUploadRequest; @@ -47,9 +46,9 @@ import java.util.regex.Pattern; import javax.net.ssl.HttpsURLConnection; import app.fedilab.fedilabtube.R; +import app.fedilab.fedilabtube.client.entities.Error; import app.fedilab.fedilabtube.helper.FileNameCleaner; import app.fedilab.fedilabtube.helper.Helper; -import app.fedilab.fedilabtube.client.entities.Error; import app.fedilab.fedilabtube.interfaces.OnDownloadInterface; public class HttpsConnection { @@ -567,7 +566,7 @@ public class HttpsConnection { try { httpsURLConnection.getInputStream().close(); } catch (Exception ignored) { - } + } return null; } diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java b/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java index 8620c7a..c8d9089 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java @@ -28,10 +28,10 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; - import app.fedilab.fedilabtube.R; import app.fedilab.fedilabtube.client.entities.Account; import app.fedilab.fedilabtube.client.entities.AccountCreation; +import app.fedilab.fedilabtube.client.entities.Error; import app.fedilab.fedilabtube.client.entities.Instance; import app.fedilab.fedilabtube.client.entities.InstanceNodeInfo; import app.fedilab.fedilabtube.client.entities.InstanceReg; @@ -49,8 +49,6 @@ import app.fedilab.fedilabtube.helper.Helper; import app.fedilab.fedilabtube.sqlite.AccountDAO; import app.fedilab.fedilabtube.sqlite.Sqlite; -import app.fedilab.fedilabtube.client.entities.Error; - /** * Created by Thomas on 02/01/2019. * Manage Calls to the Peertube REST API @@ -69,34 +67,12 @@ public class PeertubeAPI { private Error APIError; - public enum StatusAction { - FOLLOW, - UNFOLLOW, - RATEVIDEO, - PEERTUBECOMMENT, - PEERTUBEREPLY, - PEERTUBEDELETECOMMENT, - PEERTUBEDELETEVIDEO, - } - public PeertubeAPI(Context context) { this.context = context; SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); tootPerPage = Helper.VIDEOS_PER_PAGE; - if (Helper.getLiveInstance(context) != null) - this.instance = Helper.getLiveInstance(context); - else { - SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); - String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); - String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(context)); - Account account = new AccountDAO(context, db).getUniqAccount(userId, instance); - if (account == null) { - apiResponse = new APIResponse(); - APIError = new Error(); - return; - } - this.instance = account.getInstance().trim(); - } + Helper.getLiveInstance(context); + this.instance = Helper.getLiveInstance(context); this.prefKeyOauthTokenT = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null); apiResponse = new APIResponse(); APIError = null; @@ -391,7 +367,6 @@ public class PeertubeAPI { return peertube; } - /** * Parse json response for emoji * @@ -481,6 +456,90 @@ public class PeertubeAPI { return account; } + /** + * Parse json response for peertube comments + * + * @param resobj JSONObject + * @return Peertube + */ + private static List parseSinglePeertubeComments(Context context, String instance, JSONObject resobj) { + List statuses = new ArrayList<>(); + try { + JSONArray jsonArray = resobj.getJSONArray("data"); + int i = 0; + while (i < jsonArray.length()) { + Status status = new Status(); + JSONObject comment = jsonArray.getJSONObject(i); + status.setId(comment.get("id").toString()); + status.setUri(comment.get("url").toString()); + status.setUrl(comment.get("url").toString()); + status.setSensitive(false); + status.setContent(comment.get("text").toString()); + status.setIn_reply_to_id(comment.get("inReplyToCommentId").toString()); + status.setAccount(parseAccountResponsePeertube(instance, comment.getJSONObject("account"))); + status.setCreated_at(Helper.mstStringToDate(comment.get("createdAt").toString())); + status.setVisibility("public"); + SpannableString spannableString; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) + spannableString = new SpannableString(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY)); + else + spannableString = new SpannableString(Html.fromHtml(status.getContent())); + status.setContentSpan(new SpannableString(spannableString)); + i++; + statuses.add(status); + } + } catch (JSONException | ParseException e) { + e.printStackTrace(); + } + return statuses; + } + + /** + * Parse json response an unique peertube account + * + * @param resobj JSONObject + * @return Account + */ + private static Account parseAccountResponsePeertube(String instance, JSONObject resobj) { + Account account = new Account(); + try { + account.setId(resobj.get("id").toString()); + account.setUsername(resobj.get("name").toString()); + account.setAcct(resobj.get("name").toString() + "@" + resobj.get("host").toString()); + account.setDisplay_name(resobj.get("displayName").toString()); + account.setHost(resobj.get("host").toString()); + if (resobj.has("createdAt")) + account.setCreated_at(Helper.mstStringToDate(resobj.get("createdAt").toString())); + else + account.setCreated_at(new Date()); + + if (resobj.has("followersCount")) + account.setFollowers_count(resobj.getInt("followersCount")); + else + account.setFollowers_count(0); + if (resobj.has("followingCount")) + account.setFollowing_count(resobj.getInt("followingCount")); + else + account.setFollowing_count(0); + account.setStatuses_count(0); + if (resobj.has("description")) + account.setNote(resobj.get("description").toString()); + else + account.setNote(""); + account.setUrl(resobj.get("url").toString()); + account.setSocial("PEERTUBE"); + if (resobj.has("avatar") && !resobj.get("avatar").toString().equals("null")) { + account.setAvatar("https://" + instance + resobj.getJSONObject("avatar").get("path")); + account.setAvatar_static("https://" + instance + resobj.getJSONObject("avatar").get("path")); + } else + account.setAvatar(null); + account.setAvatar_static(resobj.get("avatar").toString()); + } catch (JSONException ignored) { + } catch (ParseException e) { + e.printStackTrace(); + } + return account; + } /*** * Get info on the current Instance *synchronously* @@ -712,8 +771,6 @@ public class PeertubeAPI { return account; } - - public InstanceNodeInfo displayNodeInfo(String domain) { String response; @@ -1185,6 +1242,21 @@ public class PeertubeAPI { } } + /** + * Retrieves most likded videos *synchronously* + * + * @param max_id String id max + * @return APIResponse + */ + public APIResponse getLikedTL(String max_id) { + try { + return getTL("/videos/", "-likes", null, max_id, null, null); + } catch (HttpsConnection.HttpsConnectionException e) { + setError(e.getStatusCode(), e); + return apiResponse; + } + } + /** * Retrieves trending videos *synchronously* * @@ -1216,7 +1288,7 @@ public class PeertubeAPI { } /** - * Retrieves trending videos *synchronously* + * Retrieves local videos *synchronously* * * @param max_id String id max * @return APIResponse @@ -1230,6 +1302,20 @@ public class PeertubeAPI { } } + /** + * Retrieves public videos *synchronously* + * + * @param max_id String id max + * @return APIResponse + */ + public APIResponse getPublicTL(String max_id) { + try { + return getTL("/videos/", "-publishedAt", null, max_id, null, null); + } catch (HttpsConnection.HttpsConnectionException e) { + setError(e.getStatusCode(), e); + return apiResponse; + } + } /** * Retrieves home timeline for the account *synchronously* @@ -1357,7 +1443,6 @@ public class PeertubeAPI { return apiResponse; } - /** * Retrieves rating of user on a video *synchronously* * @@ -1482,7 +1567,6 @@ public class PeertubeAPI { return actionCode; } - /** * Video is in play lists * @@ -1636,7 +1720,6 @@ public class PeertubeAPI { return apiResponse; } - /** * Retrieves Peertube videos from an instance *synchronously* * @@ -1658,93 +1741,6 @@ public class PeertubeAPI { return apiResponse; } - - /** - * Parse json response for peertube comments - * - * @param resobj JSONObject - * @return Peertube - */ - private static List parseSinglePeertubeComments(Context context, String instance, JSONObject resobj) { - List statuses = new ArrayList<>(); - try { - JSONArray jsonArray = resobj.getJSONArray("data"); - int i = 0; - while (i < jsonArray.length()) { - Status status = new Status(); - JSONObject comment = jsonArray.getJSONObject(i); - status.setId(comment.get("id").toString()); - status.setUri(comment.get("url").toString()); - status.setUrl(comment.get("url").toString()); - status.setSensitive(false); - status.setContent(comment.get("text").toString()); - status.setIn_reply_to_id(comment.get("inReplyToCommentId").toString()); - status.setAccount(parseAccountResponsePeertube(instance, comment.getJSONObject("account"))); - status.setCreated_at(Helper.mstStringToDate(comment.get("createdAt").toString())); - status.setVisibility("public"); - SpannableString spannableString; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) - spannableString = new SpannableString(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY)); - else - spannableString = new SpannableString(Html.fromHtml(status.getContent())); - status.setContentSpan(new SpannableString(spannableString)); - i++; - statuses.add(status); - } - } catch (JSONException | ParseException e) { - e.printStackTrace(); - } - return statuses; - } - - - /** - * Parse json response an unique peertube account - * - * @param resobj JSONObject - * @return Account - */ - private static Account parseAccountResponsePeertube(String instance, JSONObject resobj) { - Account account = new Account(); - try { - account.setId(resobj.get("id").toString()); - account.setUsername(resobj.get("name").toString()); - account.setAcct(resobj.get("name").toString() + "@" + resobj.get("host").toString()); - account.setDisplay_name(resobj.get("displayName").toString()); - account.setHost(resobj.get("host").toString()); - if (resobj.has("createdAt")) - account.setCreated_at(Helper.mstStringToDate(resobj.get("createdAt").toString())); - else - account.setCreated_at(new Date()); - - if (resobj.has("followersCount")) - account.setFollowers_count(resobj.getInt("followersCount")); - else - account.setFollowers_count(0); - if (resobj.has("followingCount")) - account.setFollowing_count(resobj.getInt("followingCount")); - else - account.setFollowing_count(0); - account.setStatuses_count(0); - if (resobj.has("description")) - account.setNote(resobj.get("description").toString()); - else - account.setNote(""); - account.setUrl(resobj.get("url").toString()); - account.setSocial("PEERTUBE"); - if (resobj.has("avatar") && !resobj.get("avatar").toString().equals("null")) { - account.setAvatar("https://" + instance + resobj.getJSONObject("avatar").get("path")); - account.setAvatar_static("https://" + instance + resobj.getJSONObject("avatar").get("path")); - } else - account.setAvatar(null); - account.setAvatar_static(resobj.get("avatar").toString()); - } catch (JSONException ignored) { - } catch (ParseException e) { - e.printStackTrace(); - } - return account; - } - /** * Retrieves peertube search *synchronously* * @@ -1778,7 +1774,6 @@ public class PeertubeAPI { return apiResponse; } - /** * Parse json response for peertube notifications * @@ -1932,7 +1927,6 @@ public class PeertubeAPI { return accounts; } - /** * Set the error message * @@ -1968,14 +1962,23 @@ public class PeertubeAPI { apiResponse.setError(APIError); } - public Error getError() { return APIError; } - private String getAbsoluteUrl(String action) { return Helper.instanceWithProtocol(context) + "/api/v1" + action; } + + public enum StatusAction { + FOLLOW, + UNFOLLOW, + RATEVIDEO, + PEERTUBECOMMENT, + PEERTUBEREPLY, + PEERTUBEDELETECOMMENT, + PEERTUBEDELETEVIDEO, + } + } diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Account.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Account.java index b25b9f8..bde6c0e 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Account.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Account.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.client.entities; @@ -7,13 +6,11 @@ import android.os.Parcelable; import android.text.SpannableString; import android.text.TextUtils; - import org.jetbrains.annotations.NotNull; import java.util.Date; - public class Account implements Parcelable { public static final Creator CREATOR = new Creator() { @@ -512,8 +509,6 @@ public class Account implements Parcelable { } - - @NotNull public String toString() { return this.getAcct() + " - " + this.getUrl(); diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Error.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Error.java index 71a092a..750da1d 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Error.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Error.java @@ -1,8 +1,6 @@ - package app.fedilab.fedilabtube.client.entities; - public class Error { private String error = null; diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Instance.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Instance.java index 5087307..6311df1 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Instance.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Instance.java @@ -1,10 +1,8 @@ - package app.fedilab.fedilabtube.client.entities; import java.util.HashMap; - public class Instance { private String uri; diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/InstanceNodeInfo.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/InstanceNodeInfo.java index ed6c15e..abac9e2 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/entities/InstanceNodeInfo.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/InstanceNodeInfo.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.client.entities; diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/InstanceReg.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/InstanceReg.java index c395e92..2a5d6a7 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/entities/InstanceReg.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/InstanceReg.java @@ -1,7 +1,6 @@ package app.fedilab.fedilabtube.client.entities; - public class InstanceReg { private String domain; diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Mention.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Mention.java index 47dd10b..86aa742 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Mention.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Mention.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.client.entities; import android.os.Parcel; diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeAccountNotification.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeAccountNotification.java index 98fd6ab..3282a98 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeAccountNotification.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeAccountNotification.java @@ -1,8 +1,6 @@ - package app.fedilab.fedilabtube.client.entities; - public class PeertubeAccountNotification { private String id; diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeActorFollow.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeActorFollow.java index 19381d8..2e8bc0a 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeActorFollow.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeActorFollow.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.client.entities; diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeComment.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeComment.java index 27d4840..293602b 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeComment.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeComment.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.client.entities; diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeNotification.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeNotification.java index 0031705..9e8ed6d 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeNotification.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeNotification.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.client.entities; diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeVideoNotification.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeVideoNotification.java index bff8ab4..a7b5fe8 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeVideoNotification.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/PeertubeVideoNotification.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.client.entities; diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Playlist.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Playlist.java index e05ed00..303414d 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Playlist.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Playlist.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.client.entities; import android.os.Parcel; diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Status.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Status.java index 882c258..ec635e3 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Status.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Status.java @@ -22,7 +22,6 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; - import java.lang.ref.WeakReference; import java.net.URI; import java.net.URISyntaxException; @@ -42,8 +41,6 @@ import app.fedilab.fedilabtube.helper.CustomQuoteSpan; import app.fedilab.fedilabtube.helper.Helper; - - @SuppressWarnings("unused") public class Status implements Parcelable { @@ -82,10 +79,6 @@ public class Status implements Parcelable { private String conversationId; private String contentType; - public void setContent(String content) { - this.content = content; - } - public Status() { } @@ -117,12 +110,10 @@ public class Status implements Parcelable { this.contentType = in.readString(); } - public static void fillSpan(WeakReference contextWeakReference, Status status) { Status.transform(contextWeakReference, status); } - private static void transform(WeakReference contextWeakReference, Status status) { Context context = contextWeakReference.get(); if (status == null) @@ -390,7 +381,6 @@ public class Status implements Parcelable { return SpannableString.valueOf(spannableStringT); } - private static void replaceQuoteSpans(Context context, Spannable spannable) { QuoteSpan[] quoteSpans = spannable.getSpans(0, spannable.length(), QuoteSpan.class); for (QuoteSpan quoteSpan : quoteSpans) { @@ -488,7 +478,9 @@ public class Status implements Parcelable { return content; } - + public void setContent(String content) { + this.content = content; + } public Date getCreated_at() { return created_at; @@ -568,7 +560,6 @@ public class Status implements Parcelable { } - public String getLanguage() { return language; } @@ -587,8 +578,6 @@ public class Status implements Parcelable { } - - @Override public boolean equals(Object otherStatus) { return otherStatus != null && (otherStatus == this || otherStatus instanceof Status && this.getId().equals(((Status) otherStatus).getId())); @@ -627,7 +616,6 @@ public class Status implements Parcelable { } - public String getConversationId() { return conversationId; } @@ -637,7 +625,6 @@ public class Status implements Parcelable { } - @Override public int describeContents() { return 0; diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Tag.java b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Tag.java index 12c6cee..5525834 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/entities/Tag.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/entities/Tag.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.client.entities; import android.os.Parcel; @@ -30,7 +29,6 @@ public class Tag implements Parcelable { } - public String getName() { return name; } diff --git a/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java b/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java index 3c2d20c..2a6249f 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java +++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java @@ -1,7 +1,6 @@ package app.fedilab.fedilabtube.drawer; - import android.content.Context; import android.content.Intent; import android.os.Bundle; @@ -18,12 +17,8 @@ import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import java.util.List; -import java.util.Objects; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import app.fedilab.fedilabtube.PeertubeActivity; -import app.fedilab.fedilabtube.PeertubeEditUploadActivity; import app.fedilab.fedilabtube.R; import app.fedilab.fedilabtube.client.APIResponse; import app.fedilab.fedilabtube.client.entities.Account; @@ -91,7 +86,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter { - Intent intent = new Intent(context, PeertubeEditUploadActivity.class); + Intent intent = new Intent(context, PeertubeActivity.class); Bundle b = new Bundle(); b.putString("video_id", peertube.getUuid()); intent.putExtras(b); @@ -100,16 +95,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter { Intent intent = new Intent(context, PeertubeActivity.class); Bundle b = new Bundle(); - String instance = Helper.getLiveInstance(context); - String finalUrl = "https://" + instance + peertube.getEmbedPath(); - Pattern link = Pattern.compile("(https?://[\\da-z.-]+\\.[a-z.]{2,10})/videos/embed/(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})$"); - Matcher matcherLink = link.matcher(finalUrl); - if (matcherLink.find()) { - String url = matcherLink.group(1) + "/videos/watch/" + matcherLink.group(2); - b.putString("peertubeLinkToFetch", url); - b.putString("peertube_instance", Objects.requireNonNull(matcherLink.group(1)).replace("https://", "").replace("http://", "")); - b.putString("video_id", matcherLink.group(2)); - } + b.putString("video_id", peertube.getUuid()); intent.putExtras(b); context.startActivity(intent); }); diff --git a/app/src/main/java/app/fedilab/fedilabtube/drawer/StatusListAdapter.java b/app/src/main/java/app/fedilab/fedilabtube/drawer/StatusListAdapter.java index b8f9278..0a936a5 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/drawer/StatusListAdapter.java +++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/StatusListAdapter.java @@ -23,6 +23,7 @@ import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; + import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -42,11 +43,9 @@ import es.dmoral.toasty.Toasty; import static android.content.Context.MODE_PRIVATE; - public class StatusListAdapter extends RecyclerView.Adapter implements OnPostActionInterface { - private Context context; private List statuses; 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 d054826..185fa9e 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayStatusFragment.java +++ b/app/src/main/java/app/fedilab/fedilabtube/fragment/DisplayStatusFragment.java @@ -14,16 +14,18 @@ import android.view.inputmethod.InputMethodManager; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; + import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + import org.jetbrains.annotations.NotNull; + import java.util.ArrayList; import java.util.List; - import app.fedilab.fedilabtube.R; import app.fedilab.fedilabtube.asynctasks.RetrieveFeedsAsyncTask; import app.fedilab.fedilabtube.asynctasks.RetrievePeertubeSearchAsyncTask; @@ -117,7 +119,6 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, context != null ? Helper.getLiveInstance(context) : null); - peertubeAdapater = new PeertubeAdapter(this.peertubes); lv_status.setAdapter(peertubeAdapater); mLayoutManager = new LinearLayoutManager(context); @@ -278,7 +279,6 @@ public class DisplayStatusFragment extends Fragment implements OnPostActionInter } - public void scrollToTop() { if (mLayoutManager != null) { mLayoutManager.scrollToPositionWithOffset(0, 0); 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 1294a3c..53526d2 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/helper/Helper.java +++ b/app/src/main/java/app/fedilab/fedilabtube/helper/Helper.java @@ -57,6 +57,67 @@ import static android.content.Context.DOWNLOAD_SERVICE; public class Helper { + public static final int RELOAD_MYVIDEOS = 10; + public static final String SET_VIDEO_MODE = "set_video_mode"; + public static final int VIDEO_MODE_TORRENT = 0; + public static final int VIDEO_MODE_WEBVIEW = 1; + public static final int VIDEO_MODE_DIRECT = 2; + public static final String SET_SHARE_DETAILS = "set_share_details"; + public static final int DEFAULT_VIDEO_CACHE_MB = 100; + public static final String TAG = "mastodon_etalab"; + public static final String CLIENT_NAME_VALUE = "Fedilab"; + public static final String OAUTH_SCOPES = "read write follow"; + public static final String OAUTH_SCOPES_ADMIN = "read write follow admin:read admin:write admin"; + public static final String OAUTH_SCOPES_PEERTUBE = "user"; + public static final String PREF_KEY_OAUTH_TOKEN = "oauth_token"; + public static final Pattern urlPattern = Pattern.compile( + "(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,10}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))", + + Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); + public static final Pattern hashtagPattern = Pattern.compile("(#[\\w_A-zÀ-ÿ]+)"); + public static final String SET_ALLOW_STREAM = "set_allow_stream"; + public static final String SET_CUSTOM_USER_AGENT = "set_custom_user_agent"; + public static final String SET_VIDEO_CACHE = "set_video_cache"; + public static final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0"; + //Proxy + public static final String SET_PROXY_ENABLED = "set_proxy_enabled"; + public static final String SET_PROXY_TYPE = "set_proxy_type"; + public static final String SET_PROXY_HOST = "set_proxy_host"; + public static final String SET_PROXY_PORT = "set_proxy_port"; + public static final String SET_PROXY_LOGIN = "set_proxy_login"; + public static final String SET_PROXY_PASSWORD = "set_proxy_password"; + public static final String INTENT_ACTION = "intent_action"; + public static final String PREF_KEY_ID = "userID"; + public static final String PREF_IS_MODERATOR = "is_moderator"; + public static final String PREF_IS_ADMINISTRATOR = "is_administrator"; + public static final String PREF_INSTANCE = "instance"; + public static final String REDIRECT_CONTENT = "urn:ietf:wg:oauth:2.0:oob"; + public static final String REDIRECT_CONTENT_WEB = "mastalab://backtomastalab"; + public static final int EXTERNAL_STORAGE_REQUEST_CODE = 84; + public static final String SET_VIDEOS_PER_PAGE = "set_videos_per_page"; + public static final String VIDEO_ID = "video_id_update"; + public static final String CLIENT_NAME = "client_name"; + public static final String APP_PREFS = "app_prefs"; + public static final String ID = "id"; + public static final String CLIENT_ID = "client_id"; + public static final String CLIENT_SECRET = "client_secret"; + public static final String REDIRECT_URI = "redirect_uri"; + public static final String REDIRECT_URIS = "redirect_uris"; + public static final String RESPONSE_TYPE = "response_type"; + public static final String SCOPE = "scope"; + public static final String SCOPES = "scopes"; + public static final String WEBSITE = "website"; + public static final String SHOW_ACCOUNT_BOOSTS = "show_account_boosts"; + public static final String SHOW_ACCOUNT_REPLIES = "show_account_replies"; + public static final String WEBSITE_VALUE = "https://fedilab.app"; + public static final String SHOW_BATTERY_SAVER_MESSAGE = "show_battery_saver_message"; + public static final String LAST_NOTIFICATION_MAX_ID = "last_notification_max_id"; + public static final int VIDEOS_PER_PAGE = 40; + public static final String SET_VIDEO_NSFW = "set_video_nsfw"; + public static final String SET_EMBEDDED_BROWSER = "set_embedded_browser"; + public static final String SET_CUSTOM_TABS = "set_custom_tabs"; + public static final String SET_DISPLAY_CONFIRM = "set_display_confirm"; + public static final String INTENT_ADD_UPLOADED_MEDIA = "intent_add_uploaded_media"; //List of available academies public static List academies = new ArrayList<>(Arrays.asList( "ac-aix-marseille.fr", @@ -91,83 +152,14 @@ public class Helper { "ac-versailles.fr" )); - - public static final int RELOAD_MYVIDEOS = 10; - - - public static final String SET_VIDEO_MODE = "set_video_mode"; - public static final int VIDEO_MODE_TORRENT = 0; - public static final int VIDEO_MODE_WEBVIEW = 1; - public static final int VIDEO_MODE_DIRECT = 2; - - public static final String SET_SHARE_DETAILS = "set_share_details"; - public static final int DEFAULT_VIDEO_CACHE_MB = 100; - - public static final String TAG = "mastodon_etalab"; - public static final String CLIENT_NAME_VALUE = "Fedilab"; - public static final String OAUTH_SCOPES = "read write follow"; - public static final String OAUTH_SCOPES_ADMIN = "read write follow admin:read admin:write admin"; - public static final String OAUTH_SCOPES_PEERTUBE = "user"; - public static final String PREF_KEY_OAUTH_TOKEN = "oauth_token"; - - public static final Pattern urlPattern = Pattern.compile( - "(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,10}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))", - - Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); - public static final Pattern hashtagPattern = Pattern.compile("(#[\\w_A-zÀ-ÿ]+)"); - public static final String SET_ALLOW_STREAM = "set_allow_stream"; - public static final String SET_CUSTOM_USER_AGENT = "set_custom_user_agent"; - public static final String SET_VIDEO_CACHE = "set_video_cache"; - public static final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0"; - //Proxy - public static final String SET_PROXY_ENABLED = "set_proxy_enabled"; - public static final String SET_PROXY_TYPE = "set_proxy_type"; - public static final String SET_PROXY_HOST = "set_proxy_host"; - public static final String SET_PROXY_PORT = "set_proxy_port"; - public static final String SET_PROXY_LOGIN = "set_proxy_login"; - public static final String SET_PROXY_PASSWORD = "set_proxy_password"; - - public static final String INTENT_ACTION = "intent_action"; - - public static final String PREF_KEY_ID = "userID"; - public static final String PREF_IS_MODERATOR = "is_moderator"; - public static final String PREF_IS_ADMINISTRATOR = "is_administrator"; - public static final String PREF_INSTANCE = "instance"; - public static final String REDIRECT_CONTENT = "urn:ietf:wg:oauth:2.0:oob"; - public static final String REDIRECT_CONTENT_WEB = "mastalab://backtomastalab"; - public static final int EXTERNAL_STORAGE_REQUEST_CODE = 84; - public static final String SET_VIDEOS_PER_PAGE = "set_videos_per_page"; - - public static final String VIDEO_ID = "video_id_update"; - public static final String CLIENT_NAME = "client_name"; - public static final String APP_PREFS = "app_prefs"; - public static final String ID = "id"; - public static final String CLIENT_ID = "client_id"; - public static final String CLIENT_SECRET = "client_secret"; - public static final String REDIRECT_URI = "redirect_uri"; - public static final String REDIRECT_URIS = "redirect_uris"; - public static final String RESPONSE_TYPE = "response_type"; - public static final String SCOPE = "scope"; - public static final String SCOPES = "scopes"; - public static final String WEBSITE = "website"; - public static final String SHOW_ACCOUNT_BOOSTS = "show_account_boosts"; - public static final String SHOW_ACCOUNT_REPLIES = "show_account_replies"; - public static final String WEBSITE_VALUE = "https://fedilab.app"; - public static final String SHOW_BATTERY_SAVER_MESSAGE = "show_battery_saver_message"; - public static final String LAST_NOTIFICATION_MAX_ID = "last_notification_max_id"; - public static final int VIDEOS_PER_PAGE = 40; - public static final String SET_VIDEO_NSFW = "set_video_nsfw"; - public static final String SET_EMBEDDED_BROWSER = "set_embedded_browser"; - public static final String SET_CUSTOM_TABS = "set_custom_tabs"; - public static final String SET_DISPLAY_CONFIRM = "set_display_confirm"; - public static final String INTENT_ADD_UPLOADED_MEDIA = "intent_add_uploaded_media"; /** * Returns the peertube URL depending of the academic domain name + * * @param acad String academic domain name * @return String the peertube URL */ private static String getPeertubeUrl(String acad) { - return "tube-"+acad.replaceAll("ac-|\\.fr","")+".beta.education.fr"; + return "tube-" + acad.replaceAll("ac-|\\.fr", "") + ".beta.education.fr"; } @@ -179,13 +171,13 @@ public class Helper { */ public static String getLiveInstance(Context context) { final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); - String acad = sharedpreferences.getString(Helper.PREF_INSTANCE, "ac-lyon.fr"); + String acad = sharedpreferences.getString(Helper.PREF_INSTANCE, "ac-lyon.fr"); return getPeertubeUrl(acad); } public static String instanceWithProtocol(Context context) { - return "https://"+getLiveInstance(context); + return "https://" + getLiveInstance(context); } /** @@ -344,6 +336,16 @@ public class Helper { public static void loadGiF(final Context context, Account account, final ImageView imageView) { + + + if (account == null) { + Glide.with(imageView.getContext()) + .asDrawable() + .load(R.drawable.missing_peertube) + .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10))) + .into(imageView); + return; + } String url = account.getAvatar(); if (url != null && url.startsWith("/")) { url = Helper.getLiveInstance(context) + url; @@ -371,7 +373,6 @@ public class Helper { } - /** * Manage URLs to open (built-in or external app) * @@ -528,4 +529,18 @@ public class Helper { DrawableCompat.setTint(mDrawable, color); return mDrawable; } + + + /** + * Returns boolean depending if the user is authenticated + * + * @param context Context + * @return boolean + */ + public static boolean isLoggedIn(Context context) { + SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + String prefKeyOauthTokenT = sharedpreferences.getString(PREF_KEY_OAUTH_TOKEN, null); + return (prefKeyOauthTokenT != null); + } + } diff --git a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnActionInterface.java b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnActionInterface.java index 6ee1b60..489139f 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnActionInterface.java +++ b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnActionInterface.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.interfaces; diff --git a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnDownloadInterface.java b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnDownloadInterface.java index 9df0fca..6fbe27c 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnDownloadInterface.java +++ b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnDownloadInterface.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.interfaces; diff --git a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnPlaylistActionInterface.java b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnPlaylistActionInterface.java index b047224..dd67a23 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnPlaylistActionInterface.java +++ b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnPlaylistActionInterface.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.interfaces; diff --git a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnPostActionInterface.java b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnPostActionInterface.java index abb678b..46f873e 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnPostActionInterface.java +++ b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnPostActionInterface.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.interfaces; diff --git a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrieveFeedsInterface.java b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrieveFeedsInterface.java index c3cb4a0..e48c8c9 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrieveFeedsInterface.java +++ b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrieveFeedsInterface.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.interfaces; diff --git a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrievePeertubeInterface.java b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrievePeertubeInterface.java index 67e6398..3dc01d9 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrievePeertubeInterface.java +++ b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrievePeertubeInterface.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.interfaces; diff --git a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrievePeertubeNotificationsInterface.java b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrievePeertubeNotificationsInterface.java index c970254..79684fb 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrievePeertubeNotificationsInterface.java +++ b/app/src/main/java/app/fedilab/fedilabtube/interfaces/OnRetrievePeertubeNotificationsInterface.java @@ -1,4 +1,3 @@ - package app.fedilab.fedilabtube.interfaces; diff --git a/app/src/main/java/app/fedilab/fedilabtube/services/PeertubeUploadReceiver.java b/app/src/main/java/app/fedilab/fedilabtube/services/PeertubeUploadReceiver.java index 717c01f..923f852 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/services/PeertubeUploadReceiver.java +++ b/app/src/main/java/app/fedilab/fedilabtube/services/PeertubeUploadReceiver.java @@ -4,7 +4,6 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; - import androidx.localbroadcastmanager.content.LocalBroadcastManager; import net.gotev.uploadservice.ServerResponse; diff --git a/app/src/main/java/app/fedilab/fedilabtube/sqlite/AccountDAO.java b/app/src/main/java/app/fedilab/fedilabtube/sqlite/AccountDAO.java index 068bfd2..f3dfbb7 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/sqlite/AccountDAO.java +++ b/app/src/main/java/app/fedilab/fedilabtube/sqlite/AccountDAO.java @@ -13,7 +13,6 @@ import app.fedilab.fedilabtube.client.entities.Account; import app.fedilab.fedilabtube.helper.Helper; - public class AccountDAO { public Context context; @@ -224,7 +223,6 @@ public class AccountDAO { } - /** * Returns an Account by token * diff --git a/app/src/main/java/app/fedilab/fedilabtube/sqlite/PeertubeFavoritesDAO.java b/app/src/main/java/app/fedilab/fedilabtube/sqlite/PeertubeFavoritesDAO.java index f227155..111251e 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/sqlite/PeertubeFavoritesDAO.java +++ b/app/src/main/java/app/fedilab/fedilabtube/sqlite/PeertubeFavoritesDAO.java @@ -116,7 +116,7 @@ public class PeertubeFavoritesDAO { while (c.moveToNext()) { //Restore cached status try { - Peertube peertube = PeertubeAPI.parsePeertube( new JSONObject(c.getString(c.getColumnIndex(Sqlite.COL_CACHE)))); + Peertube peertube = PeertubeAPI.parsePeertube(new JSONObject(c.getString(c.getColumnIndex(Sqlite.COL_CACHE)))); peertubes.add(peertube); } catch (JSONException e) { e.printStackTrace(); diff --git a/app/src/main/java/app/fedilab/fedilabtube/sqlite/Sqlite.java b/app/src/main/java/app/fedilab/fedilabtube/sqlite/Sqlite.java index 7d01328..24a899f 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/sqlite/Sqlite.java +++ b/app/src/main/java/app/fedilab/fedilabtube/sqlite/Sqlite.java @@ -40,8 +40,12 @@ public class Sqlite extends SQLiteOpenHelper { static final String COL_UPDATED_AT = "UPDATED_AT"; static final String COL_PRIVACY = "PRIVACY"; static final String COL_SENSITIVE = "SENSITIVE"; - - + //Table for peertube favorites + static final String TABLE_PEERTUBE_FAVOURITES = "PEERTUBE_FAVOURITES"; + static final String COL_ID = "ID"; + static final String COL_UUID = "UUID"; + static final String COL_CACHE = "CACHE"; + static final String COL_DATE = "DATE"; private static final String CREATE_TABLE_USER_ACCOUNT = "CREATE TABLE " + TABLE_USER_ACCOUNT + " (" + COL_USER_ID + " TEXT, " + COL_USERNAME + " TEXT NOT NULL, " + COL_ACCT + " TEXT NOT NULL, " + COL_DISPLAYED_NAME + " TEXT NOT NULL, " + COL_LOCKED + " INTEGER NOT NULL, " @@ -56,15 +60,8 @@ public class Sqlite extends SQLiteOpenHelper { + COL_PRIVACY + " TEXT, " + COL_SENSITIVE + " INTEGER DEFAULT 0, " + COL_INSTANCE + " TEXT NOT NULL, " + COL_OAUTHTOKEN + " TEXT NOT NULL, " + COL_CREATED_AT + " TEXT NOT NULL)"; - - - //Table for peertube favorites - static final String TABLE_PEERTUBE_FAVOURITES = "PEERTUBE_FAVOURITES"; - static final String COL_ID = "ID"; - static final String COL_UUID = "UUID"; - static final String COL_CACHE = "CACHE"; - static final String COL_DATE = "DATE"; - + public static SQLiteDatabase db; + private static Sqlite sInstance; private final String CREATE_TABLE_PEERTUBE_FAVOURITES = "CREATE TABLE " + TABLE_PEERTUBE_FAVOURITES + "(" + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " @@ -73,9 +70,6 @@ public class Sqlite extends SQLiteOpenHelper { + COL_CACHE + " TEXT NOT NULL, " + COL_DATE + " TEXT NOT NULL)"; - public static SQLiteDatabase db; - private static Sqlite sInstance; - public Sqlite(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) { super(context, name, factory, version); diff --git a/app/src/main/java/app/fedilab/fedilabtube/webview/CustomWebview.java b/app/src/main/java/app/fedilab/fedilabtube/webview/CustomWebview.java index d5d2d54..359ffad 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/webview/CustomWebview.java +++ b/app/src/main/java/app/fedilab/fedilabtube/webview/CustomWebview.java @@ -9,8 +9,6 @@ import android.util.AttributeSet; import android.webkit.WebView; - - public class CustomWebview extends WebView { diff --git a/app/src/main/java/app/fedilab/fedilabtube/webview/MastalabWebViewClient.java b/app/src/main/java/app/fedilab/fedilabtube/webview/MastalabWebViewClient.java index daae8af..6f0184e 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/webview/MastalabWebViewClient.java +++ b/app/src/main/java/app/fedilab/fedilabtube/webview/MastalabWebViewClient.java @@ -17,7 +17,6 @@ import androidx.appcompat.app.AppCompatActivity; import app.fedilab.fedilabtube.R; - public class MastalabWebViewClient extends WebViewClient { private Activity activity; diff --git a/app/src/main/res/drawable/ic_baseline_add_circle_outline_24.xml b/app/src/main/res/drawable/ic_baseline_add_circle_outline_24.xml index a1c721d..fe178cb 100644 --- a/app/src/main/res/drawable/ic_baseline_add_circle_outline_24.xml +++ b/app/src/main/res/drawable/ic_baseline_add_circle_outline_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_bookmark_24.xml b/app/src/main/res/drawable/ic_baseline_bookmark_24.xml index 7e480e2..78ef499 100644 --- a/app/src/main/res/drawable/ic_baseline_bookmark_24.xml +++ b/app/src/main/res/drawable/ic_baseline_bookmark_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_bookmark_border_24.xml b/app/src/main/res/drawable/ic_baseline_bookmark_border_24.xml index 61dc4cf..56ae1c5 100644 --- a/app/src/main/res/drawable/ic_baseline_bookmark_border_24.xml +++ b/app/src/main/res/drawable/ic_baseline_bookmark_border_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_check_24.xml b/app/src/main/res/drawable/ic_baseline_check_24.xml index 0432fa6..219e80e 100644 --- a/app/src/main/res/drawable/ic_baseline_check_24.xml +++ b/app/src/main/res/drawable/ic_baseline_check_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_close_24.xml b/app/src/main/res/drawable/ic_baseline_close_24.xml index 16d6d37..d5d2297 100644 --- a/app/src/main/res/drawable/ic_baseline_close_24.xml +++ b/app/src/main/res/drawable/ic_baseline_close_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_cloud_upload_24.xml b/app/src/main/res/drawable/ic_baseline_cloud_upload_24.xml index 2896516..006b014 100644 --- a/app/src/main/res/drawable/ic_baseline_cloud_upload_24.xml +++ b/app/src/main/res/drawable/ic_baseline_cloud_upload_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_fullscreen_24.xml b/app/src/main/res/drawable/ic_baseline_fullscreen_24.xml index 804cebc..2956b49 100644 --- a/app/src/main/res/drawable/ic_baseline_fullscreen_24.xml +++ b/app/src/main/res/drawable/ic_baseline_fullscreen_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_fullscreen_exit_24.xml b/app/src/main/res/drawable/ic_baseline_fullscreen_exit_24.xml index 1efbe0a..f2e60af 100644 --- a/app/src/main/res/drawable/ic_baseline_fullscreen_exit_24.xml +++ b/app/src/main/res/drawable/ic_baseline_fullscreen_exit_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_list_24.xml b/app/src/main/res/drawable/ic_baseline_list_24.xml index b0e68e0..d49db2e 100644 --- a/app/src/main/res/drawable/ic_baseline_list_24.xml +++ b/app/src/main/res/drawable/ic_baseline_list_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_open_with_24.xml b/app/src/main/res/drawable/ic_baseline_open_with_24.xml index 6f602a3..d69524e 100644 --- a/app/src/main/res/drawable/ic_baseline_open_with_24.xml +++ b/app/src/main/res/drawable/ic_baseline_open_with_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_public_24.xml b/app/src/main/res/drawable/ic_baseline_public_24.xml index 19fb425..2c9d4e3 100644 --- a/app/src/main/res/drawable/ic_baseline_public_24.xml +++ b/app/src/main/res/drawable/ic_baseline_public_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_send_24.xml b/app/src/main/res/drawable/ic_baseline_send_24.xml index fe37f93..d1e2e1c 100644 --- a/app/src/main/res/drawable/ic_baseline_send_24.xml +++ b/app/src/main/res/drawable/ic_baseline_send_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_share_24.xml b/app/src/main/res/drawable/ic_baseline_share_24.xml index 2f13bb3..59b0e84 100644 --- a/app/src/main/res/drawable/ic_baseline_share_24.xml +++ b/app/src/main/res/drawable/ic_baseline_share_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_thumb_down_alt_24.xml b/app/src/main/res/drawable/ic_baseline_thumb_down_alt_24.xml index ccd0921..59866b7 100644 --- a/app/src/main/res/drawable/ic_baseline_thumb_down_alt_24.xml +++ b/app/src/main/res/drawable/ic_baseline_thumb_down_alt_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_thumb_up_24.xml b/app/src/main/res/drawable/ic_baseline_thumb_up_24.xml index 6a39a39..146f85c 100644 --- a/app/src/main/res/drawable/ic_baseline_thumb_up_24.xml +++ b/app/src/main/res/drawable/ic_baseline_thumb_up_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_thumb_up_alt_24.xml b/app/src/main/res/drawable/ic_baseline_thumb_up_alt_24.xml index 11d7f2f..bd108b0 100644 --- a/app/src/main/res/drawable/ic_baseline_thumb_up_alt_24.xml +++ b/app/src/main/res/drawable/ic_baseline_thumb_up_alt_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_trending_up_24.xml b/app/src/main/res/drawable/ic_baseline_trending_up_24.xml index 16b24de..973f2aa 100644 --- a/app/src/main/res/drawable/ic_baseline_trending_up_24.xml +++ b/app/src/main/res/drawable/ic_baseline_trending_up_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_baseline_visibility_24.xml b/app/src/main/res/drawable/ic_baseline_visibility_24.xml index a3e222a..cc9f66f 100644 --- a/app/src/main/res/drawable/ic_baseline_visibility_24.xml +++ b/app/src/main/res/drawable/ic_baseline_visibility_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_outline_account_circle_24.xml b/app/src/main/res/drawable/ic_outline_account_circle_24.xml index f63eaa3..a21075c 100644 --- a/app/src/main/res/drawable/ic_outline_account_circle_24.xml +++ b/app/src/main/res/drawable/ic_outline_account_circle_24.xml @@ -1,10 +1,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 86c8df6..270e70b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -3,8 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/container" android:layout_width="match_parent" - android:layout_height="match_parent" - android:paddingTop="?attr/actionBarSize"> + android:layout_height="match_parent"> diff --git a/app/src/main/res/layout/drawer_status_compact.xml b/app/src/main/res/layout/drawer_status_compact.xml index e9782a0..80d8b9b 100644 --- a/app/src/main/res/layout/drawer_status_compact.xml +++ b/app/src/main/res/layout/drawer_status_compact.xml @@ -1,91 +1,100 @@ + android:divider="?android:dividerHorizontal" + android:orientation="vertical" + android:paddingTop="10dp" + android:showDividers="end"> + + android:baselineAligned="false" + android:orientation="horizontal"> + + + + android:layout_height="wrap_content" + android:layout_marginStart="-2dp" + android:layout_marginTop="-2dp" + android:drawablePadding="2dp" + android:maxLines="1" + android:textStyle="bold" /> + android:layout_height="wrap_content" + android:orientation="horizontal"> + - + android:textStyle="bold" /> + + + + android:maxLines="1" + android:textSize="12sp" /> + + android:orientation="vertical"> + + android:layout_height="wrap_content" + android:textIsSelectable="true" /> diff --git a/app/src/main/res/layout/fragment_dashboard.xml b/app/src/main/res/layout/fragment_dashboard.xml index c3be25a..549b512 100644 --- a/app/src/main/res/layout/fragment_dashboard.xml +++ b/app/src/main/res/layout/fragment_dashboard.xml @@ -13,11 +13,11 @@ android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" + android:gravity="center_horizontal" android:textAlignment="center" android:textSize="20sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" - android:gravity="center_horizontal" /> + app:layout_constraintTop_toTopOf="parent" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_video.xml b/app/src/main/res/layout/fragment_video.xml index 156fd08..0effe1b 100644 --- a/app/src/main/res/layout/fragment_video.xml +++ b/app/src/main/res/layout/fragment_video.xml @@ -57,7 +57,7 @@ android:layout_height="wrap_content" android:indeterminate="true" /> - + - - \ No newline at end of file diff --git a/app/src/main/res/layout/simple_bar.xml b/app/src/main/res/layout/simple_bar.xml index dd7775b..75cdc90 100644 --- a/app/src/main/res/layout/simple_bar.xml +++ b/app/src/main/res/layout/simple_bar.xml @@ -23,8 +23,7 @@ android:layout_marginEnd="10dp" android:contentDescription="@string/close" android:gravity="center_vertical" - android:src="@drawable/ic_baseline_close_24" - /> + android:src="@drawable/ic_baseline_close_24" /> - - - - + android:id="@+id/navigation_discover" + android:icon="@drawable/ic_baseline_public_24" + android:title="@string/title_discover" /> + android:id="@+id/navigation_most_liked" + android:icon="@drawable/ic_baseline_thumb_up_24" + android:title="@string/title_most_liked" /> + + + + + + \ No newline at end of file diff --git a/app/src/main/res/navigation/mobile_navigation.xml b/app/src/main/res/navigation/mobile_navigation.xml index 5919081..559a9b4 100644 --- a/app/src/main/res/navigation/mobile_navigation.xml +++ b/app/src/main/res/navigation/mobile_navigation.xml @@ -3,28 +3,30 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/mobile_navigation" - app:startDestination="@id/navigation_home"> + app:startDestination="@id/navigation_discover"> + - - - - + android:defaultValue="POVERVIEW" + app:argType=".asynctasks.RetrieveFeedsAsyncTask$Type" /> + + + + + + android:defaultValue="PMOSTLIKED" + app:argType=".asynctasks.RetrieveFeedsAsyncTask$Type" /> + + android:defaultValue="PRECENTLYADDED" + app:argType=".asynctasks.RetrieveFeedsAsyncTask$Type" /> + + android:defaultValue="PLOCAL" + app:argType=".asynctasks.RetrieveFeedsAsyncTask$Type" /> + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 338a363..9523889 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,8 +1,8 @@ - #6200EE - #3700B3 - #03DAC5 + #512DA8 + #4527A0 + #9C27B0 #2b90d9 #F44336 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9c6c1bc..0cad826 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -93,4 +93,5 @@ Mode pour les vidéos Afficher les vidéos sensibles Vous n\'avez aucune liste de lecture. Cliquez sur l\'icône « + » pour en ajouter une + Vous devez être connecté.e pour effectuer cette action ! \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index fac9291..8b1bcff 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,4 +1,6 @@ + +