diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java index de711f9ac..761b50d85 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java @@ -4,6 +4,7 @@ import android.content.Intent; import android.view.MenuItem; import org.schabi.newpipe.R; +import org.schabi.newpipe.util.PermissionHelper; import static org.schabi.newpipe.player.BackgroundPlayer.ACTION_CLOSE; @@ -48,6 +49,12 @@ public final class BackgroundPlayerActivity extends ServicePlayerActivity { @Override public boolean onPlayerOptionSelected(MenuItem item) { if (item.getItemId() == R.id.action_switch_popup) { + + if (!PermissionHelper.isPopupEnabled(this)) { + PermissionHelper.showPopupEnablementToast(this); + return true; + } + this.player.setRecovery(); getApplicationContext().sendBroadcast(getPlayerShutdownIntent()); getApplicationContext().startService(getSwitchIntent(PopupVideoPlayer.class)); diff --git a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java index 2ec0dc14f..8081dcad7 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -25,7 +25,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.res.Configuration; -import android.content.res.Resources; import android.graphics.Color; import android.media.AudioManager; import android.os.Build; @@ -65,8 +64,6 @@ import org.schabi.newpipe.util.PermissionHelper; import org.schabi.newpipe.util.PopupMenuIconHacker; import org.schabi.newpipe.util.ThemeHelper; -import java.lang.reflect.Field; -import java.lang.reflect.Method; import java.util.List; import static org.schabi.newpipe.util.AnimationUtils.animateView; @@ -400,9 +397,8 @@ public final class MainVideoPlayer extends Activity { if (DEBUG) Log.d(TAG, "onFullScreenButtonClicked() called"); if (simpleExoPlayer == null) return; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M - && !PermissionHelper.checkSystemAlertWindowPermission(MainVideoPlayer.this)) { - Toast.makeText(MainVideoPlayer.this, R.string.msg_popup_permission, Toast.LENGTH_LONG).show(); + if (!PermissionHelper.isPopupEnabled(context)) { + PermissionHelper.showPopupEnablementToast(context); return; } diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index 58c117017..4165dc087 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -183,7 +183,7 @@ public abstract class ServicePlayerActivity extends AppCompatActivity this.player.getPlaybackSpeed(), this.player.getPlaybackPitch(), null - ); + ).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } //////////////////////////////////////////////////////////////////////////// // Service Connection diff --git a/app/src/main/java/org/schabi/newpipe/settings/SettingsActivity.java b/app/src/main/java/org/schabi/newpipe/settings/SettingsActivity.java index 7f91a7ca1..7d6f8d633 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SettingsActivity.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SettingsActivity.java @@ -43,7 +43,8 @@ public class SettingsActivity extends AppCompatActivity implements BasePreferenc @Override protected void onCreate(Bundle savedInstanceBundle) { - ThemeHelper.setTheme(this); + setTheme(ThemeHelper.getSettingsThemeStyle(this)); + super.onCreate(savedInstanceBundle); setContentView(R.layout.settings_layout); diff --git a/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java b/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java index b078ac0c8..b2a20c491 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java @@ -49,6 +49,21 @@ public class ThemeHelper { return PreferenceManager.getDefaultSharedPreferences(context).getString(themeKey, defaultTheme); } + @StyleRes + public static int getSettingsThemeStyle(Context context) { + String lightTheme = context.getResources().getString(R.string.light_theme_key); + String darkTheme = context.getResources().getString(R.string.dark_theme_key); + String blackTheme = context.getResources().getString(R.string.black_theme_key); + + String selectedTheme = getSelectedTheme(context); + + if (selectedTheme.equals(lightTheme)) return R.style.LightSettingsTheme; + else if (selectedTheme.equals(blackTheme)) return R.style.BlackSettingsTheme; + else if (selectedTheme.equals(darkTheme)) return R.style.DarkSettingsTheme; + // Fallback + else return R.style.DarkSettingsTheme; + } + /** * Get a resource id from a resource styled according to the the context's theme. */ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 694e4900f..1b9d102bf 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -6,6 +6,7 @@ #e53935 #d32f2f #000000 + #e53935 #32000000 #48868686 #2a868686 @@ -20,6 +21,7 @@ #CD322E #BC211D #FFFFFF + #ff5252 #0affffff #48ffffff #2affffff @@ -31,6 +33,7 @@ #000 + @color/dark_settings_accent_color #1effffff #23454545 diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index b9c1d9f9c..a71e01743 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -90,6 +90,20 @@ @color/black_contrast_background_color + + + + + + + +