mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-24 09:00:31 +00:00
app language now changes time formatting (3hrs ago), was system language b4
This commit is contained in:
parent
ed9a3517c6
commit
b32935a1b0
@ -99,7 +99,7 @@ public class App extends Application {
|
|||||||
NewPipe.init(getDownloader(),
|
NewPipe.init(getDownloader(),
|
||||||
Localization.getPreferredLocalization(this),
|
Localization.getPreferredLocalization(this),
|
||||||
Localization.getPreferredContentCountry(this));
|
Localization.getPreferredContentCountry(this));
|
||||||
Localization.init();
|
Localization.init(getApplicationContext());
|
||||||
|
|
||||||
StateSaver.init(this);
|
StateSaver.init(this);
|
||||||
initNotificationChannel();
|
initNotificationChannel();
|
||||||
|
@ -66,6 +66,7 @@ import org.schabi.newpipe.fragments.list.search.SearchFragment;
|
|||||||
import org.schabi.newpipe.report.ErrorActivity;
|
import org.schabi.newpipe.report.ErrorActivity;
|
||||||
import org.schabi.newpipe.util.Constants;
|
import org.schabi.newpipe.util.Constants;
|
||||||
import org.schabi.newpipe.util.KioskTranslator;
|
import org.schabi.newpipe.util.KioskTranslator;
|
||||||
|
import org.schabi.newpipe.util.Localization;
|
||||||
import org.schabi.newpipe.util.NavigationHelper;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
import org.schabi.newpipe.util.PeertubeHelper;
|
import org.schabi.newpipe.util.PeertubeHelper;
|
||||||
import org.schabi.newpipe.util.PermissionHelper;
|
import org.schabi.newpipe.util.PermissionHelper;
|
||||||
@ -78,7 +79,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.schabi.newpipe.util.Localization.changeAppLanguage;
|
import static org.schabi.newpipe.util.Localization.changeAppLanguage;
|
||||||
import static org.schabi.newpipe.util.Localization.getAppLanguage;
|
import static org.schabi.newpipe.util.Localization.getAppLocale;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
private static final String TAG = "MainActivity";
|
private static final String TAG = "MainActivity";
|
||||||
@ -117,7 +118,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this));
|
ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this));
|
||||||
|
|
||||||
changeAppLanguage(getAppLanguage(getApplicationContext()), getResources());
|
changeAppLanguage(getAppLocale(getApplicationContext()), getResources());
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
@ -422,7 +423,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
changeAppLanguage(getAppLanguage(getApplicationContext()), getResources());
|
changeAppLanguage(getAppLocale(getApplicationContext()), getResources());
|
||||||
|
Localization.init(getApplicationContext()); //change the date format to match the selected language on resume
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
// close drawer on return, and don't show animation, so its looks like the drawer isn't open
|
// close drawer on return, and don't show animation, so its looks like the drawer isn't open
|
||||||
|
@ -26,7 +26,7 @@ import org.schabi.newpipe.util.NavigationHelper;
|
|||||||
import org.schabi.newpipe.util.ThemeHelper;
|
import org.schabi.newpipe.util.ThemeHelper;
|
||||||
|
|
||||||
import static org.schabi.newpipe.util.Localization.changeAppLanguage;
|
import static org.schabi.newpipe.util.Localization.changeAppLanguage;
|
||||||
import static org.schabi.newpipe.util.Localization.getAppLanguage;
|
import static org.schabi.newpipe.util.Localization.getAppLocale;
|
||||||
|
|
||||||
public class AboutActivity extends AppCompatActivity {
|
public class AboutActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ public class AboutActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
changeAppLanguage(getAppLanguage(getApplicationContext()), getResources());
|
changeAppLanguage(getAppLocale(getApplicationContext()), getResources());
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
ThemeHelper.setTheme(this);
|
ThemeHelper.setTheme(this);
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import us.shandian.giga.service.DownloadManagerService;
|
|||||||
import us.shandian.giga.ui.fragment.MissionsFragment;
|
import us.shandian.giga.ui.fragment.MissionsFragment;
|
||||||
|
|
||||||
import static org.schabi.newpipe.util.Localization.changeAppLanguage;
|
import static org.schabi.newpipe.util.Localization.changeAppLanguage;
|
||||||
import static org.schabi.newpipe.util.Localization.getAppLanguage;
|
import static org.schabi.newpipe.util.Localization.getAppLocale;
|
||||||
|
|
||||||
public class DownloadActivity extends AppCompatActivity {
|
public class DownloadActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ public class DownloadActivity extends AppCompatActivity {
|
|||||||
i.setClass(this, DownloadManagerService.class);
|
i.setClass(this, DownloadManagerService.class);
|
||||||
startService(i);
|
startService(i);
|
||||||
|
|
||||||
changeAppLanguage(getAppLanguage(getApplicationContext()), getResources());
|
changeAppLanguage(getAppLocale(getApplicationContext()), getResources());
|
||||||
ThemeHelper.setTheme(this);
|
ThemeHelper.setTheme(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_downloader);
|
setContentView(R.layout.activity_downloader);
|
||||||
|
@ -15,7 +15,7 @@ import org.schabi.newpipe.R;
|
|||||||
import org.schabi.newpipe.util.ThemeHelper;
|
import org.schabi.newpipe.util.ThemeHelper;
|
||||||
|
|
||||||
import static org.schabi.newpipe.util.Localization.changeAppLanguage;
|
import static org.schabi.newpipe.util.Localization.changeAppLanguage;
|
||||||
import static org.schabi.newpipe.util.Localization.getAppLanguage;
|
import static org.schabi.newpipe.util.Localization.getAppLocale;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -47,7 +47,7 @@ public class SettingsActivity extends AppCompatActivity implements BasePreferenc
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceBundle) {
|
protected void onCreate(Bundle savedInstanceBundle) {
|
||||||
setTheme(ThemeHelper.getSettingsThemeStyle(this));
|
setTheme(ThemeHelper.getSettingsThemeStyle(this));
|
||||||
changeAppLanguage(getAppLanguage(getApplicationContext()), getResources());
|
changeAppLanguage(getAppLocale(getApplicationContext()), getResources());
|
||||||
super.onCreate(savedInstanceBundle);
|
super.onCreate(savedInstanceBundle);
|
||||||
setContentView(R.layout.settings_layout);
|
setContentView(R.layout.settings_layout);
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import android.content.res.Resources;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.PluralsRes;
|
import androidx.annotation.PluralsRes;
|
||||||
@ -54,8 +53,8 @@ public class Localization {
|
|||||||
private Localization() {
|
private Localization() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
public static void init(Context context) {
|
||||||
initPrettyTime();
|
initPrettyTime(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -203,17 +202,17 @@ public class Localization {
|
|||||||
// Pretty Time
|
// Pretty Time
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
private static void initPrettyTime() {
|
private static void initPrettyTime(Context context) {
|
||||||
prettyTime = new PrettyTime(Locale.getDefault());
|
prettyTime = new PrettyTime(getAppLocale(context));
|
||||||
// Do not use decades as YouTube doesn't either.
|
// Do not use decades as YouTube doesn't either.
|
||||||
prettyTime.removeUnit(Decade.class);
|
prettyTime.removeUnit(Decade.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PrettyTime getPrettyTime() {
|
private static PrettyTime getPrettyTime() {
|
||||||
// If pretty time's Locale is different, init again with the new one.
|
// If pretty time's Locale is different, init again with the new one.
|
||||||
if (!prettyTime.getLocale().equals(Locale.getDefault())) {
|
// if (!prettyTime.getLocale().equals(Locale.getDefault())) {
|
||||||
initPrettyTime();
|
// initPrettyTime();
|
||||||
}
|
// }
|
||||||
return prettyTime;
|
return prettyTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +227,7 @@ public class Localization {
|
|||||||
res.updateConfiguration(conf, dm);
|
res.updateConfiguration(conf, dm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Locale getAppLanguage(Context context) {
|
public static Locale getAppLocale(Context context) {
|
||||||
SharedPreferences prefs = androidx.preference.PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = androidx.preference.PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
String lang = prefs.getString("newpipes_language_key", "en");
|
String lang = prefs.getString("newpipes_language_key", "en");
|
||||||
Locale loc;
|
Locale loc;
|
||||||
|
Loading…
Reference in New Issue
Block a user