From 8f46432391578b6602cea69ef344817857f75a7e Mon Sep 17 00:00:00 2001 From: bopol Date: Fri, 10 Jan 2020 15:50:15 +0100 Subject: [PATCH] fixed some activities where the wrong languages would be set --- app/src/main/java/org/schabi/newpipe/MainActivity.java | 1 - .../java/org/schabi/newpipe/about/AboutActivity.java | 1 + .../java/org/schabi/newpipe/player/BackgroundPlayer.java | 4 +++- .../java/org/schabi/newpipe/player/MainVideoPlayer.java | 9 +++++++-- .../java/org/schabi/newpipe/player/PopupVideoPlayer.java | 3 +++ .../org/schabi/newpipe/player/ServicePlayerActivity.java | 3 +++ .../java/org/schabi/newpipe/report/ErrorActivity.java | 4 ++++ .../main/java/org/schabi/newpipe/util/Localization.java | 4 ---- 8 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index d48db1035..c5aedb85b 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -119,7 +119,6 @@ public class MainActivity extends AppCompatActivity { ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this)); changeAppLanguage(getAppLocale(getApplicationContext()), getResources()); - super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); diff --git a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java index 795feceb0..c8c62bbe7 100644 --- a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java +++ b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java @@ -68,6 +68,7 @@ public class AboutActivity extends AppCompatActivity { changeAppLanguage(getAppLocale(getApplicationContext()), getResources()); super.onCreate(savedInstanceState); ThemeHelper.setTheme(this); + this.setTitle(getString(R.string.title_activity_about)); setContentView(R.layout.activity_about); diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java index 76da7da36..c74882161 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java @@ -58,6 +58,8 @@ import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.ThemeHelper; import static org.schabi.newpipe.player.helper.PlayerHelper.getTimeString; +import static org.schabi.newpipe.util.Localization.changeAppLanguage; +import static org.schabi.newpipe.util.Localization.getAppLocale; /** @@ -115,7 +117,7 @@ public final class BackgroundPlayer extends Service { notificationManager = ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)); lockManager = new LockManager(this); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); - + changeAppLanguage(getAppLocale(getApplicationContext()), getResources()); ThemeHelper.setTheme(this); basePlayerImpl = new BasePlayerImpl(this); basePlayerImpl.setup(); 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 7a3e60c66..284d10b42 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -93,6 +93,8 @@ import static org.schabi.newpipe.util.AnimationUtils.Type.SCALE_AND_ALPHA; import static org.schabi.newpipe.util.AnimationUtils.Type.SLIDE_AND_ALPHA; import static org.schabi.newpipe.util.AnimationUtils.animateRotation; import static org.schabi.newpipe.util.AnimationUtils.animateView; +import static org.schabi.newpipe.util.Localization.changeAppLanguage; +import static org.schabi.newpipe.util.Localization.getAppLocale; import static org.schabi.newpipe.util.StateSaver.KEY_SAVED_STATE; /** @@ -123,6 +125,7 @@ public final class MainVideoPlayer extends AppCompatActivity @Override protected void onCreate(@Nullable Bundle savedInstanceState) { + changeAppLanguage(getAppLocale(getApplicationContext()), getResources()); super.onCreate(savedInstanceState); if (DEBUG) Log.d(TAG, "onCreate() called with: savedInstanceState = [" + savedInstanceState + "]"); defaultPreferences = PreferenceManager.getDefaultSharedPreferences(this); @@ -190,6 +193,7 @@ public final class MainVideoPlayer extends AppCompatActivity @Override protected void onResume() { if (DEBUG) Log.d(TAG, "onResume() called"); + changeAppLanguage(getAppLocale(getApplicationContext()), getResources()); super.onResume(); if (globalScreenOrientationLocked()) { @@ -220,6 +224,7 @@ public final class MainVideoPlayer extends AppCompatActivity @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); + changeAppLanguage(getAppLocale(getApplicationContext()), getResources()); if (playerImpl.isSomePopupMenuVisible()) { playerImpl.getQualityPopupMenu().dismiss(); @@ -364,8 +369,8 @@ public final class MainVideoPlayer extends AppCompatActivity } private boolean globalScreenOrientationLocked() { - // 1: Screen orientation changes using acelerometer - // 0: Screen orientatino is locked + // 1: Screen orientation changes using accelerometer + // 0: Screen orientation is locked return !(android.provider.Settings.System.getInt(getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0) == 1); } diff --git a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java index 969c47990..b173448d0 100644 --- a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java @@ -80,6 +80,8 @@ import static org.schabi.newpipe.player.BasePlayer.STATE_PLAYING; import static org.schabi.newpipe.player.VideoPlayer.DEFAULT_CONTROLS_DURATION; import static org.schabi.newpipe.player.VideoPlayer.DEFAULT_CONTROLS_HIDE_TIME; import static org.schabi.newpipe.util.AnimationUtils.animateView; +import static org.schabi.newpipe.util.Localization.changeAppLanguage; +import static org.schabi.newpipe.util.Localization.getAppLocale; /** * Service Popup Player implementing VideoPlayer @@ -142,6 +144,7 @@ public final class PopupVideoPlayer extends Service { @Override public void onCreate() { + changeAppLanguage(getAppLocale(getApplicationContext()), getResources()); windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); notificationManager = ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)); 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 2207808ac..d5ee59a7e 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -46,6 +46,8 @@ import java.util.List; import static org.schabi.newpipe.player.helper.PlayerHelper.formatPitch; import static org.schabi.newpipe.player.helper.PlayerHelper.formatSpeed; +import static org.schabi.newpipe.util.Localization.changeAppLanguage; +import static org.schabi.newpipe.util.Localization.getAppLocale; public abstract class ServicePlayerActivity extends AppCompatActivity implements PlayerEventListener, SeekBar.OnSeekBarChangeListener, @@ -116,6 +118,7 @@ public abstract class ServicePlayerActivity extends AppCompatActivity @Override protected void onCreate(Bundle savedInstanceState) { + changeAppLanguage(getAppLocale(getApplicationContext()), getResources()); super.onCreate(savedInstanceState); ThemeHelper.setTheme(this); setContentView(R.layout.activity_player_queue_control); diff --git a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java index e7a6319e3..05dfe33ca 100644 --- a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java @@ -46,6 +46,9 @@ import java.util.List; import java.util.TimeZone; import java.util.Vector; +import static org.schabi.newpipe.util.Localization.changeAppLanguage; +import static org.schabi.newpipe.util.Localization.getAppLocale; + /* * Created by Christian Schabesberger on 24.10.15. * @@ -171,6 +174,7 @@ public class ErrorActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { + changeAppLanguage(getAppLocale(getApplicationContext()), getResources()); super.onCreate(savedInstanceState); ThemeHelper.setTheme(this); setContentView(R.layout.activity_error); diff --git a/app/src/main/java/org/schabi/newpipe/util/Localization.java b/app/src/main/java/org/schabi/newpipe/util/Localization.java index 695a73295..3f555fcfd 100644 --- a/app/src/main/java/org/schabi/newpipe/util/Localization.java +++ b/app/src/main/java/org/schabi/newpipe/util/Localization.java @@ -209,10 +209,6 @@ public class Localization { } private static PrettyTime getPrettyTime() { - // If pretty time's Locale is different, init again with the new one. -// if (!prettyTime.getLocale().equals(Locale.getDefault())) { -// initPrettyTime(); -// } return prettyTime; }