Merge remote-tracking branch 'GitHub/develop' into develop
This commit is contained in:
commit
a4be7d8869
Binary file not shown.
After Width: | Height: | Size: 114 KiB |
Binary file not shown.
After Width: | Height: | Size: 95 KiB |
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
@ -244,6 +245,12 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere
|
|||
ImageButton moreButton = findViewById(R.id.moreButton);
|
||||
ImageButton videoOptions = findViewById(R.id.exo_more);
|
||||
|
||||
//Playback speed buttons
|
||||
Button speed05 = findViewById(R.id.speed05);
|
||||
Button speed10 = findViewById(R.id.speed10);
|
||||
Button speed15 = findViewById(R.id.speed15);
|
||||
Button speed20 = findViewById(R.id.speed20);
|
||||
|
||||
Video video = response.body();
|
||||
|
||||
mService.setCurrentVideo(video);
|
||||
|
@ -299,6 +306,41 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere
|
|||
|
||||
mService.setCurrentStreamUrl(video.getFiles().get(0).getFileUrl());
|
||||
|
||||
//Playback speed controls
|
||||
speed05.setOnClickListener(view -> {
|
||||
mService.setPlayBackSpeed(0.5f);
|
||||
speed05.setTextColor(getResources().getColor(R.color.primaryColorRed));
|
||||
|
||||
speed10.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
|
||||
speed15.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
|
||||
speed20.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
|
||||
|
||||
});
|
||||
speed10.setOnClickListener(view -> {
|
||||
mService.setPlayBackSpeed(1.0f);
|
||||
speed10.setTextColor(getResources().getColor(R.color.primaryColorRed));
|
||||
|
||||
speed05.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
|
||||
speed15.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
|
||||
speed20.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
|
||||
});
|
||||
speed15.setOnClickListener(view -> {
|
||||
mService.setPlayBackSpeed(1.5f);
|
||||
speed15.setTextColor(getResources().getColor(R.color.primaryColorRed));
|
||||
|
||||
speed05.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
|
||||
speed10.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
|
||||
speed20.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
|
||||
});
|
||||
speed20.setOnClickListener(view -> {
|
||||
mService.setPlayBackSpeed(2.0f);
|
||||
speed20.setTextColor(getResources().getColor(R.color.primaryColorRed));
|
||||
|
||||
speed05.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
|
||||
speed10.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
|
||||
speed15.setTextColor(getResources().getColor(R.color.secondaryTextColorRed));
|
||||
});
|
||||
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
if (sharedPref.getBoolean("pref_torrent_player", false)) {
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -109,6 +109,51 @@
|
|||
android:layout_marginEnd="12dp"
|
||||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Body1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/playback_speed_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/description"
|
||||
android:text="Playback Speed"
|
||||
android:layout_marginTop="16dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/speed05"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/playback_speed_label"
|
||||
android:text="0.5x"
|
||||
android:textAllCaps="false"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/speed10"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/playback_speed_label"
|
||||
android:layout_toRightOf="@id/speed05"
|
||||
android:text="1.0x"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@color/primaryColorRed"
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/speed15"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/playback_speed_label"
|
||||
android:layout_toRightOf="@id/speed10"
|
||||
android:text="1.5x"
|
||||
android:textAllCaps="false"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/speed20"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/playback_speed_label"
|
||||
android:layout_toRightOf="@id/speed15"
|
||||
android:text="2.0x"
|
||||
android:textAllCaps="false"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
android:title="@string/pref_title_app_theme"
|
||||
android:summary="@string/pref_description_app_theme"
|
||||
android:key="pref_theme"
|
||||
android:defaultValue="1"
|
||||
android:defaultValue="AppTheme.ORANGE"
|
||||
android:entries="@array/themeArray"
|
||||
android:entryValues="@array/themeValues" />
|
||||
|
||||
|
|
Loading…
Reference in New Issue