app language: refactoring
renamed NewPipe's language into App language, and same for all the concerning thing (keys, comments…) we now call assureCorrectAppLanguage(CONTEXT) in activities needing it instead of changeAppLanguage(getAppLocale(CONTEXT), RESOURCES) changeAppLanguage becomes private.
This commit is contained in:
parent
156a2eb4ff
commit
edc9d47da7
14 changed files with 43 additions and 52 deletions
|
|
@ -58,9 +58,7 @@ 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;
|
||||
|
||||
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
||||
|
||||
/**
|
||||
* Base players joining the common properties
|
||||
|
|
@ -117,7 +115,7 @@ public final class BackgroundPlayer extends Service {
|
|||
notificationManager = ((NotificationManager) getSystemService(NOTIFICATION_SERVICE));
|
||||
lockManager = new LockManager(this);
|
||||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
changeAppLanguage(getAppLocale(getApplicationContext()), getResources());
|
||||
assureCorrectAppLanguage(this);
|
||||
ThemeHelper.setTheme(this);
|
||||
basePlayerImpl = new BasePlayerImpl(this);
|
||||
basePlayerImpl.setup();
|
||||
|
|
|
|||
|
|
@ -95,8 +95,7 @@ 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.Localization.assureCorrectAppLanguage;
|
||||
import static org.schabi.newpipe.util.StateSaver.KEY_SAVED_STATE;
|
||||
|
||||
/**
|
||||
|
|
@ -127,7 +126,7 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
changeAppLanguage(getAppLocale(getApplicationContext()), getResources());
|
||||
assureCorrectAppLanguage(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
if (DEBUG) Log.d(TAG, "onCreate() called with: savedInstanceState = [" + savedInstanceState + "]");
|
||||
defaultPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
|
@ -195,7 +194,7 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||
@Override
|
||||
protected void onResume() {
|
||||
if (DEBUG) Log.d(TAG, "onResume() called");
|
||||
changeAppLanguage(getAppLocale(getApplicationContext()), getResources());
|
||||
assureCorrectAppLanguage(this);
|
||||
super.onResume();
|
||||
|
||||
if (globalScreenOrientationLocked()) {
|
||||
|
|
@ -226,7 +225,7 @@ public final class MainVideoPlayer extends AppCompatActivity
|
|||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
changeAppLanguage(getAppLocale(getApplicationContext()), getResources());
|
||||
assureCorrectAppLanguage(this);
|
||||
|
||||
if (playerImpl.isSomePopupMenuVisible()) {
|
||||
playerImpl.getQualityPopupMenu().dismiss();
|
||||
|
|
|
|||
|
|
@ -80,8 +80,7 @@ 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;
|
||||
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
||||
|
||||
/**
|
||||
* Service Popup Player implementing VideoPlayer
|
||||
|
|
@ -144,7 +143,7 @@ public final class PopupVideoPlayer extends Service {
|
|||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
changeAppLanguage(getAppLocale(getApplicationContext()), getResources());
|
||||
assureCorrectAppLanguage(this);
|
||||
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||
notificationManager = ((NotificationManager) getSystemService(NOTIFICATION_SERVICE));
|
||||
|
||||
|
|
@ -172,7 +171,7 @@ public final class PopupVideoPlayer extends Service {
|
|||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
changeAppLanguage(getAppLocale(getApplicationContext()), getResources());
|
||||
assureCorrectAppLanguage(this);
|
||||
if (DEBUG) Log.d(TAG, "onConfigurationChanged() called with: newConfig = [" + newConfig + "]");
|
||||
updateScreenSize();
|
||||
updatePopupSize(popupLayoutParams.width, -1);
|
||||
|
|
|
|||
|
|
@ -46,8 +46,7 @@ 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;
|
||||
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
||||
|
||||
public abstract class ServicePlayerActivity extends AppCompatActivity
|
||||
implements PlayerEventListener, SeekBar.OnSeekBarChangeListener,
|
||||
|
|
@ -118,7 +117,7 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
changeAppLanguage(getAppLocale(getApplicationContext()), getResources());
|
||||
assureCorrectAppLanguage(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
ThemeHelper.setTheme(this);
|
||||
setContentView(R.layout.activity_player_queue_control);
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@ import org.schabi.newpipe.R;
|
|||
import org.schabi.newpipe.util.SliderStrategy;
|
||||
|
||||
import static org.schabi.newpipe.player.BasePlayer.DEBUG;
|
||||
import static org.schabi.newpipe.util.Localization.changeAppLanguage;
|
||||
import static org.schabi.newpipe.util.Localization.getAppLocale;
|
||||
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
||||
|
||||
public class PlaybackParameterDialog extends DialogFragment {
|
||||
@NonNull private static final String TAG = "PlaybackParameterDialog";
|
||||
|
|
@ -110,7 +109,7 @@ public class PlaybackParameterDialog extends DialogFragment {
|
|||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
changeAppLanguage(getAppLocale(getContext()), getResources());
|
||||
assureCorrectAppLanguage(getContext());
|
||||
super.onCreate(savedInstanceState);
|
||||
if (savedInstanceState != null) {
|
||||
initialTempo = savedInstanceState.getDouble(INITIAL_TEMPO_KEY, DEFAULT_TEMPO);
|
||||
|
|
@ -140,7 +139,7 @@ public class PlaybackParameterDialog extends DialogFragment {
|
|||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
changeAppLanguage(getAppLocale(getContext()), getResources());
|
||||
assureCorrectAppLanguage(getContext());
|
||||
final View view = View.inflate(getContext(), R.layout.dialog_playback_parameter, null);
|
||||
setupControlViews(view);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue