Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Release

See merge request sschueller/peertube!58
  • Loading branch information
sschueller committed Jan 9, 2022
2 parents 55a9acc + 04db4ce commit eb3b1eb
Show file tree
Hide file tree
Showing 16 changed files with 821 additions and 345 deletions.
105 changes: 55 additions & 50 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,78 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="net.schueller.peertube">
xmlns:tools="http://schemas.android.com/tools"
package="net.schueller.peertube">
<!-- required to play video in background via notification -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!-- connect to peertube server -->
<uses-permission android:name="android.permission.INTERNET" /> <!-- required for torrent downloading -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> <!-- connect to peertube server -->
<uses-permission android:name="android.permission.INTERNET"/> <!-- required for torrent downloading -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
android:name=".application.AppApplication"
android:allowBackup="true"
android:fullBackupContent="@xml/backup_descriptor"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
android:name=".application.AppApplication"
android:allowBackup="true"
android:fullBackupContent="@xml/backup_descriptor"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">

<!-- Server Address Book -->
<activity
android:name=".activity.ServerAddressBookActivity"
android:label="@string/title_activity_server_address_book"
android:theme="@style/AppTheme.NoActionBar" /> <!-- Video Lists -->
android:name=".activity.ServerAddressBookActivity"
android:label="@string/title_activity_server_address_book"
android:theme="@style/AppTheme.NoActionBar"/> <!-- Video Lists -->
<activity
android:name=".activity.VideoListActivity"
android:launchMode="singleTop"
android:theme="@style/AppTheme.NoActionBar"
android:exported="true">
android:name=".activity.VideoListActivity"
android:launchMode="singleTop"
android:theme="@style/AppTheme.NoActionBar"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEARCH" />
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.SEARCH"/>

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity> <!-- Video Player -->
<activity
android:name=".activity.VideoPlayActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"
android:label="@string/title_activity_video_play"
android:launchMode="singleInstance"
android:supportsPictureInPicture="true"
android:theme="@style/AppTheme.NoActionBar" /> <!-- Settings -->
android:name=".activity.VideoPlayActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"
android:label="@string/title_activity_video_play"
android:launchMode="singleInstance"
android:supportsPictureInPicture="true"
android:theme="@style/AppTheme.NoActionBar"/>
<!-- Playlist -->
<activity android:name=".activity.PlaylistActivity"
android:label="Playlist"
android:theme="@style/AppTheme.NoActionBar"/>
<!-- Settings -->
<activity
android:name=".activity.SettingsActivity"
android:label="@string/title_activity_settings"
android:theme="@style/AppTheme.NoActionBar" /> <!-- Server Selection -->
android:name=".activity.SettingsActivity"
android:label="@string/title_activity_settings"
android:theme="@style/AppTheme.NoActionBar"/> <!-- Server Selection -->
<activity
android:name=".activity.SearchServerActivity"
android:label="@string/title_activity_select_server"
android:theme="@style/AppTheme.NoActionBar" /> <!-- Me -->
android:name=".activity.SearchServerActivity"
android:label="@string/title_activity_select_server"
android:theme="@style/AppTheme.NoActionBar"/> <!-- Me -->
<activity
android:name=".activity.MeActivity"
android:label="@string/title_activity_me"
android:theme="@style/AppTheme.NoActionBar" /> <!-- Account -->
android:name=".activity.MeActivity"
android:label="@string/title_activity_me"
android:theme="@style/AppTheme.NoActionBar"/> <!-- Account -->
<activity
android:name=".activity.AccountActivity"
android:label="@string/title_activity_account"
android:theme="@style/AppTheme.NoActionBar" /> <!-- Content provider for search suggestions -->
android:name=".activity.AccountActivity"
android:label="@string/title_activity_account"
android:theme="@style/AppTheme.NoActionBar"/> <!-- Content provider for search suggestions -->
<provider
android:name=".provider.SearchSuggestionsProvider"
android:authorities="net.schueller.peertube.provider.SearchSuggestionsProvider"
android:enabled="true"
android:exported="false" />
android:name=".provider.SearchSuggestionsProvider"
android:authorities="net.schueller.peertube.provider.SearchSuggestionsProvider"
android:enabled="true"
android:exported="false"/>

<service android:name=".service.VideoPlayerService" />
<service android:name=".service.VideoPlayerService"/>

<receiver android:name="androidx.media.session.MediaButtonReceiver"
android:exported="true">
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
<action android:name="android.intent.action.MEDIA_BUTTON"/>
</intent-filter>
</receiver>

Expand Down
23 changes: 12 additions & 11 deletions app/src/main/java/net/schueller/peertube/activity/MeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import com.squareup.picasso.Picasso;
import net.schueller.peertube.R;
import net.schueller.peertube.helper.APIUrlHelper;
import net.schueller.peertube.helper.ErrorHelper;
Expand All @@ -36,18 +38,12 @@
import net.schueller.peertube.network.GetUserService;
import net.schueller.peertube.network.RetrofitInstance;
import net.schueller.peertube.network.Session;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;

import com.squareup.picasso.Picasso;

import java.util.Objects;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

import java.util.Objects;

import static net.schueller.peertube.application.AppApplication.getContext;

public class MeActivity extends CommonActivity {
Expand Down Expand Up @@ -85,11 +81,16 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_baseline_close_24);

LinearLayout account = findViewById(R.id.a_me_account_line);
LinearLayout playlist = findViewById(R.id.a_me_playlist);
LinearLayout settings = findViewById(R.id.a_me_settings);
LinearLayout help = findViewById(R.id.a_me_helpnfeedback);

TextView logout = findViewById(R.id.a_me_logout);

playlist.setOnClickListener(view -> {
Intent playlistActivity = new Intent(getContext(), PlaylistActivity.class);
startActivity(playlistActivity);
});

settings.setOnClickListener(view -> {
Intent settingsActivity = new Intent(getContext(), SettingsActivity.class);
Expand Down Expand Up @@ -124,7 +125,7 @@ private void getUserData() {

call.enqueue(new Callback<Me>() {

LinearLayout account = findViewById(R.id.a_me_account_line);
final LinearLayout account = findViewById(R.id.a_me_account_line);

@Override
public void onResponse(@NonNull Call<Me> call, @NonNull Response<Me> response) {
Expand Down Expand Up @@ -162,7 +163,7 @@ public void onResponse(@NonNull Call<Me> call, @NonNull Response<Me> response) {

@Override
public void onFailure(@NonNull Call<Me> call, @NonNull Throwable t) {
ErrorHelper.showToastFromCommunicationError( MeActivity.this, t );
ErrorHelper.showToastFromCommunicationError(MeActivity.this, t);
account.setVisibility(View.GONE);
}
});
Expand Down
103 changes: 103 additions & 0 deletions app/src/main/java/net/schueller/peertube/activity/PlaylistActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Copyright (C) 2020 Stefan Schüller <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.schueller.peertube.activity

import android.app.AlertDialog
import android.content.DialogInterface
import android.content.Intent
import android.os.Bundle
import androidx.activity.viewModels
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.RecyclerView
import net.schueller.peertube.R
import net.schueller.peertube.adapter.MultiViewRecyclerViewHolder
import net.schueller.peertube.adapter.PlaylistAdapter
import net.schueller.peertube.database.Video
import net.schueller.peertube.database.VideoViewModel
import net.schueller.peertube.databinding.ActivityPlaylistBinding

class PlaylistActivity : CommonActivity() {

private val TAG = "PlaylistAct"

private val mVideoViewModel: VideoViewModel by viewModels()

private lateinit var mBinding: ActivityPlaylistBinding

override fun onSupportNavigateUp(): Boolean {
finish() // close this activity as oppose to navigating up
return false
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mBinding = ActivityPlaylistBinding.inflate(layoutInflater)
setContentView(mBinding.root)

// Setting toolbar as the ActionBar with setSupportActionBar() call
setSupportActionBar(mBinding.toolBarServerAddressBook)
supportActionBar?.apply {
setDisplayHomeAsUpEnabled(true)
setHomeAsUpIndicator(R.drawable.ic_baseline_close_24)
}

showServers()
}

private fun onVideoClick(video: Video) {
val intent = Intent(this, VideoPlayActivity::class.java)
intent.putExtra(MultiViewRecyclerViewHolder.EXTRA_VIDEOID, video.videoUUID)
startActivity(intent)
}

private fun showServers() {
val adapter = PlaylistAdapter(mutableListOf(), { onVideoClick(it) }).also {
mBinding.serverListRecyclerview.adapter = it
}

// Delete items on swipe
val helper = ItemTouchHelper(
object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT) {
override fun onMove(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean {
return false
}

override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
AlertDialog.Builder(this@PlaylistActivity)
.setTitle(getString(R.string.remove_video))
.setMessage(getString(R.string.remove_video_warning_message))
.setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
val position = viewHolder.bindingAdapterPosition
val video = adapter.getVideoAtPosition(position)
// Delete the video
mVideoViewModel.delete(video)
}
.setNegativeButton(android.R.string.cancel) { _: DialogInterface?, _: Int -> adapter.notifyItemChanged(viewHolder.bindingAdapterPosition) }
.setIcon(android.R.drawable.ic_dialog_alert)
.show()
}
})
helper.attachToRecyclerView(mBinding.serverListRecyclerview)

// Update the cached copy of the words in the adapter.
mVideoViewModel.allVideos.observe(this, { videos: List<Video> ->
adapter.setVideos(videos)
})
}

companion object
}
Loading

0 comments on commit eb3b1eb

Please sign in to comment.