diff --git a/Screenshot1.png b/Screenshot1.png
new file mode 100644
index 0000000..a962100
Binary files /dev/null and b/Screenshot1.png differ
diff --git a/Screenshot2.jpg b/Screenshot2.jpg
new file mode 100644
index 0000000..841a96b
Binary files /dev/null and b/Screenshot2.jpg differ
diff --git a/app/build.gradle b/app/build.gradle
index 6be087c..233ead1 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -6,8 +6,8 @@ android {
applicationId "net.schueller.peertube"
minSdkVersion 21
targetSdkVersion 28
- versionCode 1012
- versionName "1.0.12"
+ versionCode 1013
+ versionName "1.0.13"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
diff --git a/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java b/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java
index eabde7c..0cb0211 100644
--- a/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java
+++ b/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java
@@ -23,6 +23,8 @@ import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY;
public class SettingsActivity extends AppCompatPreferenceActivity {
+ private static String previousThemeColorValue = "";
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
@@ -33,6 +35,21 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
return super.onOptionsItemSelected(item);
}
+ private static String getSelectedColor(Context context, String colorId){
+
+ String res = "Color not found";
+ String [ ] themeArray = context.getResources().getStringArray(R.array.themeValues);
+ String [ ] colorArray = context.getResources().getStringArray(R.array.themeArray);
+
+ for (int i = 0 ; i < themeArray.length ; i++){
+ if (themeArray[i].equals(colorId)){
+ res = colorArray[i];
+ break;
+ }
+ }
+ return res;
+ }
+
/**
* A preference value change listener that updates the preference's summary
* to reflect its new value.
@@ -45,6 +62,19 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
Toast.makeText(preference.getContext(), R.string.invalid_url, Toast.LENGTH_LONG).show();
return false;
}
+ // Check if Theme color has change & Provide selected color
+ else if (preference.getKey().equals("pref_theme")) {
+
+ stringValue = getSelectedColor(preference.getContext(), stringValue);
+
+ if (!previousThemeColorValue.equals("") && !previousThemeColorValue.equals(stringValue)) {
+ Toast.makeText(preference.getContext(), R.string.pref_description_app_theme, Toast.LENGTH_LONG).show();
+ }
+
+ previousThemeColorValue = stringValue;
+ preference.setSummary(stringValue);
+ return true;
+ }
preference.setSummary(stringValue);
@@ -96,7 +126,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
setupActionBar();
getFragmentManager().beginTransaction().replace(android.R.id.content, new GeneralPreferenceFragment()).commit();
-
}
/**
@@ -153,6 +182,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
// updated to reflect the new value, per the Android Design
// guidelines.
bindPreferenceSummaryToValue(findPreference("pref_api_base"));
+ bindPreferenceSummaryToValue(findPreference("pref_theme"));
}
@Override
diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java
index e43af9d..fa781a2 100644
--- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java
+++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java
@@ -20,6 +20,7 @@ import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
+import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ProgressBar;
@@ -39,6 +40,7 @@ import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoRendererEventListener;
import com.squareup.picasso.Picasso;
import net.schueller.peertube.R;
+import net.schueller.peertube.fragment.VideoOptionsFragment;
import net.schueller.peertube.helper.APIUrlHelper;
import net.schueller.peertube.helper.MetaDataHelper;
import net.schueller.peertube.intents.Intents;
@@ -241,6 +243,8 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere
TextView videoMeta = findViewById(R.id.videoMeta);
ImageView avatarView = findViewById(R.id.avatar);
ImageButton moreButton = findViewById(R.id.moreButton);
+ ImageButton videoOptions = findViewById(R.id.exo_more);
+
Video video = response.body();
@@ -287,8 +291,18 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere
popup.show();
});
+ // video player options
+ videoOptions.setOnClickListener(v -> {
+
+ VideoOptionsFragment videoOptionsFragment =
+ VideoOptionsFragment.newInstance(mService);
+ videoOptionsFragment.show(getSupportFragmentManager(),
+ "video_options_fragment");
+ });
+
mService.setCurrentStreamUrl(video.getFiles().get(0).getFileUrl());
+
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
if (sharedPref.getBoolean("pref_torrent_player", false)) {
diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java
new file mode 100644
index 0000000..d2a9cf9
--- /dev/null
+++ b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java
@@ -0,0 +1,51 @@
+package net.schueller.peertube.fragment;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
+
+import net.schueller.peertube.R;
+import net.schueller.peertube.service.VideoPlayerService;
+
+import androidx.annotation.Nullable;
+
+public class VideoOptionsFragment extends BottomSheetDialogFragment {
+
+ private static VideoPlayerService videoPlayerService;
+
+ public static VideoOptionsFragment newInstance(VideoPlayerService mService) {
+ videoPlayerService = mService;
+ return new VideoOptionsFragment();
+ }
+
+ @Nullable
+ @Override
+ public View onCreateView(LayoutInflater inflater,
+ @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
+
+ View view = inflater.inflate(R.layout.bottom_sheet_video_options_fragment, container,
+ false);
+
+ // get the views and attach the listener
+
+ //Playback speed buttons
+ TextView speed05 = view.findViewById(R.id.video_speed05);
+ TextView speed10 = view.findViewById(R.id.video_speed10);
+ TextView speed15 = view.findViewById(R.id.video_speed15);
+ TextView speed20 = view.findViewById(R.id.video_speed20);
+
+ //Playback speed controls
+ speed05.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(0.5f));
+ speed10.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(1.0f));
+ speed15.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(1.5f));
+ speed20.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(2.0f));
+
+ return view;
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java
index 3b9611e..063bde0 100644
--- a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java
+++ b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java
@@ -16,6 +16,7 @@ import androidx.annotation.Nullable;
import android.util.Log;
import com.google.android.exoplayer2.ExoPlayerFactory;
+import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
@@ -123,8 +124,14 @@ public class VideoPlayerService extends Service {
currentStreamUrl = streamUrl;
}
- public void playVideo()
- {
+ //Playback speed control
+ public void setPlayBackSpeed(float speed) {
+
+ Log.v("VideoPlayerService", "setPlayBackSpeed...");
+ player.setPlaybackParameters(new PlaybackParameters(speed));
+ }
+
+ public void playVideo() {
Context context = this;
Log.v("VideoPlayerService", "playVideo...");
@@ -143,6 +150,9 @@ public class VideoPlayerService extends Service {
// Auto play
player.setPlayWhenReady(true);
+ //reset playback speed
+ this.setPlayBackSpeed(1.0f);
+
playerNotificationManager = PlayerNotificationManager.createWithNotificationChannel(
context, PLAYBACK_CHANNEL_ID, R.string.playback_channel_name,
PLAYBACK_NOTIFICATION_ID,
diff --git a/app/src/main/res/layout/activity_video_play.xml b/app/src/main/res/layout/activity_video_play.xml
index 4416157..6e38fce 100644
--- a/app/src/main/res/layout/activity_video_play.xml
+++ b/app/src/main/res/layout/activity_video_play.xml
@@ -17,6 +17,7 @@
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="250dp"
+ android:background="@color/videoBackgroundColor"
app:layout_constraintDimensionRatio="H,3:1"
app:layout_constraintEnd_toEndOf="parent"
@@ -108,9 +109,10 @@
android:layout_marginEnd="12dp"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Body1" />
+
-
+
diff --git a/app/src/main/res/layout/bottom_sheet_video_options_fragment.xml b/app/src/main/res/layout/bottom_sheet_video_options_fragment.xml
new file mode 100644
index 0000000..c016aca
--- /dev/null
+++ b/app/src/main/res/layout/bottom_sheet_video_options_fragment.xml
@@ -0,0 +1,65 @@
+