diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java index 41e1ba6d7..10dd2b17d 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java @@ -106,6 +106,7 @@ import fr.gouv.etalab.mastodon.client.HttpsConnection; import fr.gouv.etalab.mastodon.fragments.DisplayAccountsFragment; import fr.gouv.etalab.mastodon.fragments.DisplayBookmarksFragment; import fr.gouv.etalab.mastodon.fragments.DisplayDraftsFragment; +import fr.gouv.etalab.mastodon.fragments.DisplayFavoritesPeertubeFragment; import fr.gouv.etalab.mastodon.fragments.DisplayFiltersFragment; import fr.gouv.etalab.mastodon.fragments.DisplayFollowRequestSentFragment; import fr.gouv.etalab.mastodon.fragments.DisplayHowToFragment; @@ -1830,7 +1831,7 @@ public abstract class BaseMainActivity extends BaseActivity toolbarTitle.setVisibility(View.VISIBLE); delete_instance.setVisibility(View.GONE); appBar.setExpanded(true); - if (id != R.id.nav_drafts && id != R.id.nav_bookmarks ) { + if (id != R.id.nav_drafts && id != R.id.nav_bookmarks && id != R.id.nav_peertube ) { delete_all.hide(); }else{ delete_all.show(); @@ -1901,6 +1902,12 @@ public abstract class BaseMainActivity extends BaseActivity fragmentManager.beginTransaction() .replace(R.id.main_app_container, displayBookmarksFragment, fragmentTag).commit(); toot.hide(); + }else if (id == R.id.nav_peertube) { + DisplayFavoritesPeertubeFragment displayFavoritesPeertubeFragment = new DisplayFavoritesPeertubeFragment(); + fragmentTag = "BOOKMARKS_PEERTUBE"; + fragmentManager.beginTransaction() + .replace(R.id.main_app_container, displayFavoritesPeertubeFragment, fragmentTag).commit(); + toot.hide(); }else if( id == R.id.nav_follow_request){ toot.hide(); DisplayFollowRequestSentFragment followRequestSentFragment = new DisplayFollowRequestSentFragment(); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeActivity.java index 5f3f01cbe..8c6da2d7c 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeActivity.java @@ -21,6 +21,8 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; +import android.database.sqlite.SQLiteDatabase; +import android.graphics.drawable.Drawable; import android.media.MediaPlayer; import android.net.Uri; import android.os.AsyncTask; @@ -66,6 +68,8 @@ import fr.gouv.etalab.mastodon.drawers.StatusListAdapter; import fr.gouv.etalab.mastodon.helper.FullScreenMediaController; import fr.gouv.etalab.mastodon.helper.Helper; import fr.gouv.etalab.mastodon.interfaces.OnRetrievePeertubeInterface; +import fr.gouv.etalab.mastodon.sqlite.PeertubeFavoritesDAO; +import fr.gouv.etalab.mastodon.sqlite.Sqlite; import static fr.gouv.etalab.mastodon.helper.Helper.EXTERNAL_STORAGE_REQUEST_CODE; import static fr.gouv.etalab.mastodon.helper.Helper.manageDownloads; @@ -82,7 +86,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube private FullScreenMediaController.fullscreen fullscreen; private VideoView videoView; private RelativeLayout loader; - private TextView peertube_view_count, peertube_like_count, peertube_dislike_count, peertube_share, peertube_download, peertube_description, peertube_title; + private TextView peertube_view_count, peertube_bookmark, peertube_like_count, peertube_dislike_count, peertube_share, peertube_download, peertube_description, peertube_title; private ScrollView peertube_information_container; private MediaPlayer mediaPlayer; private FullScreenMediaController fullScreenMediaController; @@ -112,6 +116,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube setContentView(R.layout.activity_peertube); loader = findViewById(R.id.loader); peertube_view_count = findViewById(R.id.peertube_view_count); + peertube_bookmark = findViewById(R.id.peertube_bookmark); peertube_like_count = findViewById(R.id.peertube_like_count); peertube_dislike_count = findViewById(R.id.peertube_dislike_count); peertube_share = findViewById(R.id.peertube_share); @@ -283,6 +288,34 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube } } }); + SQLiteDatabase db = Sqlite.getInstance(PeertubeActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); + List peertubes = new PeertubeFavoritesDAO(PeertubeActivity.this, db).getSinglePeertube(peertube); + + Drawable img; + + if( peertubes == null || peertubes.size() == 0) + img = ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_bookmark_peertube_border); + else + img = ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_bookmark_peertube); + peertube_bookmark.setCompoundDrawablesWithIntrinsicBounds(null, img, null, null); + + peertube_bookmark.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + List peertubes = new PeertubeFavoritesDAO(PeertubeActivity.this, db).getSinglePeertube(peertube); + if( peertubes == null || peertubes.size() == 0){ + new PeertubeFavoritesDAO(PeertubeActivity.this, db).insert(peertube); + Toast.makeText(PeertubeActivity.this,R.string.bookmark_add_peertube, Toast.LENGTH_SHORT).show(); + }else{ + new PeertubeFavoritesDAO(PeertubeActivity.this, db).remove(peertube); + Toast.makeText(PeertubeActivity.this,R.string.bookmark_remove_peertube, Toast.LENGTH_SHORT).show(); + } + if( peertubes != null && peertubes.size() > 0) //Was initially in cache + peertube_bookmark.setCompoundDrawablesWithIntrinsicBounds( null, ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_bookmark_peertube_border), null ,null); + else + peertube_bookmark.setCompoundDrawablesWithIntrinsicBounds( null, ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_bookmark_peertube), null ,null); + } + }); peertube_share.setOnClickListener(new View.OnClickListener() { @Override diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java index 4c8ff65e0..71bb8a75c 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java @@ -30,6 +30,7 @@ import fr.gouv.etalab.mastodon.helper.FilterToots; import fr.gouv.etalab.mastodon.helper.Helper; import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface; import fr.gouv.etalab.mastodon.sqlite.InstancesDAO; +import fr.gouv.etalab.mastodon.sqlite.PeertubeFavoritesDAO; import fr.gouv.etalab.mastodon.sqlite.Sqlite; import fr.gouv.etalab.mastodon.sqlite.StatusCacheDAO; @@ -68,6 +69,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask { CONTEXT, TAG, CACHE_BOOKMARKS, + CACHE_BOOKMARKS_PEERTUBE, CACHE_STATUS, REMOTE_INSTANCE } @@ -179,6 +181,12 @@ public class RetrieveFeedsAsyncTask extends AsyncTask { List statuses = new StatusCacheDAO(contextReference.get(), db).getAllStatus(StatusCacheDAO.BOOKMARK_CACHE); apiResponse.setStatuses(statuses); break; + case CACHE_BOOKMARKS_PEERTUBE: + apiResponse = new APIResponse(); + db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); + List peertubes = new PeertubeFavoritesDAO(contextReference.get(), db).getAllPeertube(); + apiResponse.setPeertubes(peertubes); + break; case CACHE_STATUS: apiResponse = new APIResponse(); db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java index 45fcff057..cea593711 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java @@ -616,7 +616,6 @@ public class API { try { HttpsConnection httpsConnection = new HttpsConnection(context); String response = httpsConnection.get("https://"+instance+"/api/v1/videos", 60, params, null); - Helper.largeLog(response); JSONArray jsonArray = new JSONObject(response).getJSONArray("data"); peertubes = parsePeertube(instance, jsonArray); } catch (HttpsConnection.HttpsConnectionException e) { @@ -2386,10 +2385,11 @@ public class API { * @param resobj JSONObject * @return Peertube */ - private static Peertube parsePeertube(Context context, String instance, JSONObject resobj){ + public static Peertube parsePeertube(Context context, String instance, JSONObject resobj){ Peertube peertube = new Peertube(); try { peertube.setId(resobj.get("id").toString()); + peertube.setCache(resobj); peertube.setUuid(resobj.get("uuid").toString()); peertube.setName(resobj.get("name").toString()); peertube.setDescription(resobj.get("description").toString()); @@ -2425,6 +2425,7 @@ public class API { peertube.setId(resobj.get("id").toString()); peertube.setUuid(resobj.get("uuid").toString()); peertube.setName(resobj.get("name").toString()); + peertube.setCache(resobj); peertube.setInstance(instance); peertube.setHost(resobj.getJSONObject("account").get("host").toString()); peertube.setDescription(resobj.get("description").toString()); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Peertube.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Peertube.java index 0febba666..80ae76581 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Peertube.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Peertube.java @@ -14,6 +14,8 @@ * see . */ package fr.gouv.etalab.mastodon.client.Entities; +import org.json.JSONObject; + import java.util.Date; import java.util.List; @@ -40,7 +42,7 @@ public class Peertube { private Account account; private List resolution; private boolean commentsEnabled; - + private JSONObject cache; public Peertube() { } @@ -207,4 +209,12 @@ public class Peertube { public void setCommentsEnabled(boolean commentsEnabled) { this.commentsEnabled = commentsEnabled; } + + public JSONObject getCache() { + return cache; + } + + public void setCache(JSONObject cache) { + this.cache = cache; + } } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayFavoritesPeertubeFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayFavoritesPeertubeFragment.java new file mode 100644 index 000000000..fa127db17 --- /dev/null +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayFavoritesPeertubeFragment.java @@ -0,0 +1,148 @@ +package fr.gouv.etalab.mastodon.fragments; +/* Copyright 2017 Thomas Schneider + * + * This file is a part of Mastalab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Mastalab; if not, + * see . */ + +import android.content.Context; +import android.content.DialogInterface; +import android.database.sqlite.SQLiteDatabase; +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.design.widget.FloatingActionButton; +import android.support.v4.app.Fragment; +import android.support.v7.app.AlertDialog; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.RelativeLayout; + +import java.util.ArrayList; +import java.util.List; + +import fr.gouv.etalab.mastodon.R; +import fr.gouv.etalab.mastodon.activities.MainActivity; +import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask; +import fr.gouv.etalab.mastodon.client.APIResponse; +import fr.gouv.etalab.mastodon.client.Entities.Peertube; +import fr.gouv.etalab.mastodon.drawers.PeertubeAdapter; +import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface; +import fr.gouv.etalab.mastodon.sqlite.PeertubeFavoritesDAO; +import fr.gouv.etalab.mastodon.sqlite.Sqlite; +import fr.gouv.etalab.mastodon.sqlite.StatusCacheDAO; + + +/** + * Created by Thomas on 21/10/2018. + * Fragment to display bookmarks for Peertube + */ +public class DisplayFavoritesPeertubeFragment extends Fragment implements OnRetrieveFeedsInterface { + + + private Context context; + private List peertubes; + private PeertubeAdapter peertubeAdapter; + private RelativeLayout textviewNoAction; + private RelativeLayout mainLoader; + private RecyclerView lv_status; + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + + View rootView = inflater.inflate(R.layout.fragment_peertube_favourites, container, false); + context = getContext(); + + lv_status = rootView.findViewById(R.id.lv_status); + + mainLoader = rootView.findViewById(R.id.loader); + textviewNoAction = rootView.findViewById(R.id.no_action); + mainLoader.setVisibility(View.VISIBLE); + return rootView; + } + + + @Override + public void onCreate(Bundle saveInstance) + { + super.onCreate(saveInstance); + } + + + @Override + public void onAttach(Context context) { + super.onAttach(context); + this.context = context; + } + + @Override + public void onResume() { + super.onResume(); + new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS_PEERTUBE, null, DisplayFavoritesPeertubeFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } + + @Override + public void onRetrieveFeeds(APIResponse apiResponse) { + + final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); + mainLoader.setVisibility(View.GONE); + FloatingActionButton delete_all = null; + try { + delete_all = ((MainActivity) context).findViewById(R.id.delete_all); + }catch (Exception ignored){} + peertubes = apiResponse.getPeertubes(); + if( peertubes != null && peertubes.size() > 0) { + LinearLayoutManager mLayoutManager = new LinearLayoutManager(context); + peertubeAdapter = new PeertubeAdapter(context, peertubes.get(0).getInstance(), this.peertubes); + lv_status.setAdapter(peertubeAdapter); + lv_status.setLayoutManager(mLayoutManager); + textviewNoAction.setVisibility(View.GONE); + lv_status.setVisibility(View.VISIBLE); + }else { + textviewNoAction.setVisibility(View.VISIBLE); + lv_status.setVisibility(View.GONE); + } + + if( delete_all != null) + delete_all.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + AlertDialog.Builder builder = new AlertDialog.Builder(context); + builder.setTitle(R.string.delete_all); + builder.setIcon(android.R.drawable.ic_dialog_alert) + .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogConfirm, int which) { + new PeertubeFavoritesDAO(context, db).removeAll(); + peertubes = new ArrayList<>(); + peertubes.clear(); + peertubeAdapter = new PeertubeAdapter(context,null, peertubes); + lv_status.setAdapter(peertubeAdapter); + peertubeAdapter.notifyDataSetChanged(); + textviewNoAction.setVisibility(View.VISIBLE); + dialogConfirm.dismiss(); + } + }) + .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogConfirm, int which) { + dialogConfirm.dismiss(); + } + }) + .show(); + } + }); + } +} diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/sqlite/PeertubeFavoritesDAO.java b/app/src/main/java/fr/gouv/etalab/mastodon/sqlite/PeertubeFavoritesDAO.java new file mode 100644 index 000000000..aed3ac684 --- /dev/null +++ b/app/src/main/java/fr/gouv/etalab/mastodon/sqlite/PeertubeFavoritesDAO.java @@ -0,0 +1,146 @@ +package fr.gouv.etalab.mastodon.sqlite; +/* Copyright 2018 Thomas Schneider + * + * This file is a part of Mastalab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Mastalab; if not, + * see . */ + +import android.content.ContentValues; +import android.content.Context; +import android.content.SharedPreferences; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import fr.gouv.etalab.mastodon.client.API; +import fr.gouv.etalab.mastodon.client.Entities.Peertube; +import fr.gouv.etalab.mastodon.helper.Helper; + + +/** + * Created by Thomas on 21/10/2018. + * Manage Peertube favorites + */ +public class PeertubeFavoritesDAO { + + private SQLiteDatabase db; + public Context context; + + public PeertubeFavoritesDAO(Context context, SQLiteDatabase db) { + //Creation of the DB with tables + this.context = context; + this.db = db; + } + + + //------- INSERTIONS ------- + /** + * Insert a status in database + * @param peertube Peertube + * @return boolean + */ + public long insert(Peertube peertube) { + ContentValues values = new ContentValues(); + values.put(Sqlite.COL_UUID, peertube.getUuid()); + values.put(Sqlite.COL_INSTANCE, peertube.getInstance()); + values.put(Sqlite.COL_DATE, Helper.dateToString(new Date())); + values.put(Sqlite.COL_CACHE, peertube.getCache().toString()); + //Inserts cached peertube + long last_id; + try{ + last_id = db.insert(Sqlite.TABLE_PEERTUBE_FAVOURITES, null, values); + }catch (Exception e) { + last_id = -1; + } + return last_id; + } + //------- REMOVE ------- + + /*** + * Remove stored status + * @return int + */ + public int remove(Peertube peertube){ + return db.delete(Sqlite.TABLE_PEERTUBE_FAVOURITES, Sqlite.COL_UUID + " = \""+ peertube.getUuid() +"\" AND " + Sqlite.COL_INSTANCE + " = \"" + peertube.getInstance() + "\"", null); + } + + /*** + * Remove stored status + * @return int + */ + public int removeAll(){ + return db.delete(Sqlite.TABLE_PEERTUBE_FAVOURITES, null, null); + } + + + + //------- GETTERS ------- + + /** + * Returns all cached Peertube + * @return stored peertube List + */ + public List getAllPeertube(){ + SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + try { + Cursor c = db.query(Sqlite.TABLE_PEERTUBE_FAVOURITES, null, null, null, null, null, Sqlite.COL_DATE+ " DESC"); + return cursorToListPeertube(c); + } catch (Exception e) { + return null; + } + } + + /** + * Returns a cached Peertube + * @return stored peertube List + */ + public List getSinglePeertube(Peertube peertube){ + SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + try { + Cursor c = db.query(Sqlite.TABLE_PEERTUBE_FAVOURITES, null, Sqlite.COL_UUID + " = \""+ peertube.getUuid() +"\" AND " + Sqlite.COL_INSTANCE + " = \"" + peertube.getInstance() + "\"", null, null, null, Sqlite.COL_DATE+ " DESC"); + return cursorToListPeertube(c); + } catch (Exception e) { + return null; + } + } + + /*** + * Method to hydrate cached statuses from database + * @param c Cursor + * @return List + */ + private List cursorToListPeertube(Cursor c){ + //No element found + if (c.getCount() == 0) + return null; + List peertubes = new ArrayList<>(); + while (c.moveToNext() ) { + //Restore cached status + try { + Peertube peertube = API.parsePeertube(context, c.getString(c.getColumnIndex(Sqlite.COL_INSTANCE)), new JSONObject(c.getString(c.getColumnIndex(Sqlite.COL_CACHE)))); + peertubes.add(peertube); + } catch (JSONException e) { + e.printStackTrace(); + } + } + //Close the cursor + c.close(); + //Peertubes list is returned + return peertubes; + } +} diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/sqlite/Sqlite.java b/app/src/main/java/fr/gouv/etalab/mastodon/sqlite/Sqlite.java index 970c4c32f..19e79fdee 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/sqlite/Sqlite.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/sqlite/Sqlite.java @@ -26,7 +26,7 @@ import android.database.sqlite.SQLiteOpenHelper; public class Sqlite extends SQLiteOpenHelper { - public static final int DB_VERSION = 14; + public static final int DB_VERSION = 15; public static final String DB_NAME = "mastodon_etalab_db"; public static SQLiteDatabase db; private static Sqlite sInstance; @@ -52,6 +52,9 @@ public class Sqlite extends SQLiteOpenHelper { //Table for instance names static final String TABLE_INSTANCES = "INSTANCES"; + //Table for peertube favorites + static final String TABLE_PEERTUBE_FAVOURITES = "PEERTUBE_FAVOURITES"; + static final String COL_USER_ID = "USER_ID"; static final String COL_USERNAME = "USERNAME"; static final String COL_ACCT = "ACCT"; @@ -166,6 +169,18 @@ public class Sqlite extends SQLiteOpenHelper { + COL_INSTANCE + " TEXT NOT NULL, " + COL_USER_ID + " TEXT NOT NULL, " + COL_INSTANCE_TYPE + " TEXT, " + COL_DATE_CREATION + " TEXT NOT NULL)"; + static final String COL_UUID = "UUID"; + static final String COL_CACHE = "CACHE"; + static final String COL_DATE = "DATE"; + + private final String CREATE_TABLE_PEERTUBE_FAVOURITES = "CREATE TABLE " + + TABLE_PEERTUBE_FAVOURITES + "(" + + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + + COL_UUID + " TEXT NOT NULL, " + + COL_INSTANCE + " TEXT NOT NULL, " + + COL_CACHE + " TEXT NOT NULL, " + + COL_DATE + " TEXT NOT NULL)"; + public Sqlite(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) { super(context, name, factory, version); } @@ -189,6 +204,7 @@ public class Sqlite extends SQLiteOpenHelper { db.execSQL(CREATE_TABLE_STATUSES_CACHE); db.execSQL(CREATE_UNIQUE_CACHE_INDEX); db.execSQL(CREATE_TABLE_INSTANCES); + db.execSQL(CREATE_TABLE_PEERTUBE_FAVOURITES); } @Override @@ -228,6 +244,8 @@ public class Sqlite extends SQLiteOpenHelper { db.execSQL("ALTER TABLE " + TABLE_USER_ACCOUNT + " ADD COLUMN "+ COL_EMOJIS + " TEXT"); case 13: db.execSQL("ALTER TABLE " + TABLE_INSTANCES + " ADD COLUMN "+ COL_INSTANCE_TYPE + " TEXT"); + case 14: + db.execSQL(CREATE_TABLE_PEERTUBE_FAVOURITES); default: break; } diff --git a/app/src/main/res/drawable-anydpi/ic_bookmark_peertube.xml b/app/src/main/res/drawable-anydpi/ic_bookmark_peertube.xml new file mode 100644 index 000000000..b8c26706c --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_bookmark_peertube.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-anydpi/ic_bookmark_peertube_border.xml b/app/src/main/res/drawable-anydpi/ic_bookmark_peertube_border.xml new file mode 100644 index 000000000..1348ada67 --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_bookmark_peertube_border.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-hdpi/ic_favorite_peertube_full.png b/app/src/main/res/drawable-hdpi/ic_favorite_peertube_full.png new file mode 100644 index 000000000..e996c6b2c Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_favorite_peertube_full.png differ diff --git a/app/src/main/res/drawable-ldpi/ic_favorite_peertube_full.png b/app/src/main/res/drawable-ldpi/ic_favorite_peertube_full.png new file mode 100644 index 000000000..0b61dca88 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/ic_favorite_peertube_full.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_favorite_peertube_full.png b/app/src/main/res/drawable-mdpi/ic_favorite_peertube_full.png new file mode 100644 index 000000000..a37c2f292 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_favorite_peertube_full.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_favorite_peertube_full.png b/app/src/main/res/drawable-xhdpi/ic_favorite_peertube_full.png new file mode 100644 index 000000000..c433b2f8c Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_favorite_peertube_full.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_favorite_peertube_full.png b/app/src/main/res/drawable-xxhdpi/ic_favorite_peertube_full.png new file mode 100644 index 000000000..5e479fd8c Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_favorite_peertube_full.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_favorite_peertube_full.png b/app/src/main/res/drawable-xxxhdpi/ic_favorite_peertube_full.png new file mode 100644 index 000000000..4e91d72b0 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_favorite_peertube_full.png differ diff --git a/app/src/main/res/layout/activity_peertube.xml b/app/src/main/res/layout/activity_peertube.xml index e087e7700..d92a53755 100644 --- a/app/src/main/res/layout/activity_peertube.xml +++ b/app/src/main/res/layout/activity_peertube.xml @@ -121,6 +121,20 @@ android:text="0" android:layout_height="wrap_content" tools:ignore="HardcodedText" /> + + + + + + + + + + + + + + diff --git a/app/src/main/res/menu/activity_main_drawer.xml b/app/src/main/res/menu/activity_main_drawer.xml index eb138aa40..494d67d58 100644 --- a/app/src/main/res/menu/activity_main_drawer.xml +++ b/app/src/main/res/menu/activity_main_drawer.xml @@ -31,6 +31,10 @@ android:id="@+id/nav_bookmarks" android:icon="@drawable/ic_bookmark" android:title="@string/bookmarks" /> + Add an instance Comments are not enabled on this video! Pick up a resolution + Peertube favourites + The video has been added to bookmarks! + The video has been removed from bookmarks! + There is no Peertube videos in your favourites! Never