2017-09-03 06:04:18 +00:00
|
|
|
package org.schabi.newpipe.settings;
|
|
|
|
|
2020-01-25 17:00:49 +00:00
|
|
|
import android.content.SharedPreferences;
|
2020-02-17 09:10:15 +00:00
|
|
|
import android.content.res.Resources;
|
2020-01-25 17:00:49 +00:00
|
|
|
import android.os.Build;
|
2017-09-03 06:04:18 +00:00
|
|
|
import android.os.Bundle;
|
2020-01-25 17:00:49 +00:00
|
|
|
import android.provider.Settings;
|
|
|
|
|
|
|
|
import androidx.annotation.Nullable;
|
Multiple localization fixes
With the extractor PR, fixes title & description shown in the wrong language.
Fixed views / spectators counts possibly in the wrong language
Fixed live spectators not showing full count on detail page
Fixed LIVE shown on players, it shows translated instead
Fixed Videos string in search / three dots not available in Weblate
(because it was videos, but there already was a plural string named videos, in Weblate)
Subscriber count is always giving the short count.
We can't get exact number since this YouTube update: https://support.google.com/youtube/thread/6543166
But only short count (B, M, k), so showing full number, eg for 1.9M: 1,900,000, is wrong because the number could be 1,923,490 or 1,897,789…
Added a « sytem default » option to content language and country language selector.
It's the one selected by default (not en-GB anymore then), and correspond to the
language of the system / country of the system
By system I mean phone, tablet, TV…
Fixed russian showing - before time ago (eg 19hrs ago)
This is a workaround fix, I opened an issue on prettytime library repo.
Fixed russian plurals:
other was used instead of many for videos and subscribers
Fixed seek_duration english only
2020-02-14 17:19:35 +00:00
|
|
|
import androidx.preference.ListPreference;
|
2020-01-25 17:00:49 +00:00
|
|
|
|
|
|
|
import com.google.android.material.snackbar.Snackbar;
|
2017-09-03 06:04:18 +00:00
|
|
|
|
2020-02-29 10:23:21 +00:00
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
2017-09-03 06:04:18 +00:00
|
|
|
import org.schabi.newpipe.R;
|
2020-01-25 17:00:49 +00:00
|
|
|
import org.schabi.newpipe.util.PermissionHelper;
|
2017-09-03 06:04:18 +00:00
|
|
|
|
|
|
|
public class VideoAudioSettingsFragment extends BasePreferenceFragment {
|
2020-01-25 17:00:49 +00:00
|
|
|
|
|
|
|
private SharedPreferences.OnSharedPreferenceChangeListener listener;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
2020-02-15 15:29:46 +00:00
|
|
|
//initializing R.array.seek_duration_description to display the translation of seconds
|
2020-02-17 09:10:15 +00:00
|
|
|
Resources res = getResources();
|
|
|
|
String[] durationsValues = res.getStringArray(R.array.seek_duration_value);
|
|
|
|
String[] durationsDescriptions = res.getStringArray(R.array.seek_duration_description);
|
2020-02-29 10:23:21 +00:00
|
|
|
List<String> durationsValResult = new LinkedList<>();
|
|
|
|
List<String> durationsDesResult = new LinkedList<>();
|
Multiple localization fixes
With the extractor PR, fixes title & description shown in the wrong language.
Fixed views / spectators counts possibly in the wrong language
Fixed live spectators not showing full count on detail page
Fixed LIVE shown on players, it shows translated instead
Fixed Videos string in search / three dots not available in Weblate
(because it was videos, but there already was a plural string named videos, in Weblate)
Subscriber count is always giving the short count.
We can't get exact number since this YouTube update: https://support.google.com/youtube/thread/6543166
But only short count (B, M, k), so showing full number, eg for 1.9M: 1,900,000, is wrong because the number could be 1,923,490 or 1,897,789…
Added a « sytem default » option to content language and country language selector.
It's the one selected by default (not en-GB anymore then), and correspond to the
language of the system / country of the system
By system I mean phone, tablet, TV…
Fixed russian showing - before time ago (eg 19hrs ago)
This is a workaround fix, I opened an issue on prettytime library repo.
Fixed russian plurals:
other was used instead of many for videos and subscribers
Fixed seek_duration english only
2020-02-14 17:19:35 +00:00
|
|
|
int currentDurationValue;
|
2020-02-29 10:23:21 +00:00
|
|
|
final boolean inexactSeek = getPreferenceManager().getSharedPreferences()
|
|
|
|
.getBoolean(res.getString(R.string.use_inexact_seek_key), false);
|
|
|
|
|
Multiple localization fixes
With the extractor PR, fixes title & description shown in the wrong language.
Fixed views / spectators counts possibly in the wrong language
Fixed live spectators not showing full count on detail page
Fixed LIVE shown on players, it shows translated instead
Fixed Videos string in search / three dots not available in Weblate
(because it was videos, but there already was a plural string named videos, in Weblate)
Subscriber count is always giving the short count.
We can't get exact number since this YouTube update: https://support.google.com/youtube/thread/6543166
But only short count (B, M, k), so showing full number, eg for 1.9M: 1,900,000, is wrong because the number could be 1,923,490 or 1,897,789…
Added a « sytem default » option to content language and country language selector.
It's the one selected by default (not en-GB anymore then), and correspond to the
language of the system / country of the system
By system I mean phone, tablet, TV…
Fixed russian showing - before time ago (eg 19hrs ago)
This is a workaround fix, I opened an issue on prettytime library repo.
Fixed russian plurals:
other was used instead of many for videos and subscribers
Fixed seek_duration english only
2020-02-14 17:19:35 +00:00
|
|
|
for (int i = 0; i < durationsDescriptions.length; i++) {
|
|
|
|
currentDurationValue = Integer.parseInt(durationsValues[i]) / 1000;
|
2020-02-29 10:23:21 +00:00
|
|
|
if (inexactSeek && currentDurationValue % 10 != 5) {
|
|
|
|
try {
|
|
|
|
durationsValResult.add(durationsValues[i]);
|
|
|
|
durationsDesResult.add(String.format(
|
2020-02-17 09:10:15 +00:00
|
|
|
res.getQuantityString(R.plurals.dynamic_seek_duration_description, currentDurationValue),
|
2020-02-29 10:23:21 +00:00
|
|
|
currentDurationValue));
|
|
|
|
} catch (Resources.NotFoundException ignored) {
|
|
|
|
//if this happens, the translation is missing, and the english string will be displayed instead
|
|
|
|
}
|
2020-02-17 09:10:15 +00:00
|
|
|
}
|
Multiple localization fixes
With the extractor PR, fixes title & description shown in the wrong language.
Fixed views / spectators counts possibly in the wrong language
Fixed live spectators not showing full count on detail page
Fixed LIVE shown on players, it shows translated instead
Fixed Videos string in search / three dots not available in Weblate
(because it was videos, but there already was a plural string named videos, in Weblate)
Subscriber count is always giving the short count.
We can't get exact number since this YouTube update: https://support.google.com/youtube/thread/6543166
But only short count (B, M, k), so showing full number, eg for 1.9M: 1,900,000, is wrong because the number could be 1,923,490 or 1,897,789…
Added a « sytem default » option to content language and country language selector.
It's the one selected by default (not en-GB anymore then), and correspond to the
language of the system / country of the system
By system I mean phone, tablet, TV…
Fixed russian showing - before time ago (eg 19hrs ago)
This is a workaround fix, I opened an issue on prettytime library repo.
Fixed russian plurals:
other was used instead of many for videos and subscribers
Fixed seek_duration english only
2020-02-14 17:19:35 +00:00
|
|
|
}
|
|
|
|
ListPreference durations = (ListPreference) findPreference(getString(R.string.seek_duration_key));
|
2020-02-29 10:23:21 +00:00
|
|
|
durations.setEntryValues(durationsValResult.toArray(new CharSequence[0]));
|
|
|
|
durations.setEntries(durationsDesResult.toArray(new CharSequence[0]));
|
Multiple localization fixes
With the extractor PR, fixes title & description shown in the wrong language.
Fixed views / spectators counts possibly in the wrong language
Fixed live spectators not showing full count on detail page
Fixed LIVE shown on players, it shows translated instead
Fixed Videos string in search / three dots not available in Weblate
(because it was videos, but there already was a plural string named videos, in Weblate)
Subscriber count is always giving the short count.
We can't get exact number since this YouTube update: https://support.google.com/youtube/thread/6543166
But only short count (B, M, k), so showing full number, eg for 1.9M: 1,900,000, is wrong because the number could be 1,923,490 or 1,897,789…
Added a « sytem default » option to content language and country language selector.
It's the one selected by default (not en-GB anymore then), and correspond to the
language of the system / country of the system
By system I mean phone, tablet, TV…
Fixed russian showing - before time ago (eg 19hrs ago)
This is a workaround fix, I opened an issue on prettytime library repo.
Fixed russian plurals:
other was used instead of many for videos and subscribers
Fixed seek_duration english only
2020-02-14 17:19:35 +00:00
|
|
|
|
2020-02-01 12:41:03 +00:00
|
|
|
listener = (sharedPreferences, s) -> {
|
|
|
|
|
|
|
|
// on M and above, if user chooses to minimise to popup player on exit and the app doesn't have
|
|
|
|
// display over other apps permission, show a snackbar to let the user give permission
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
|
|
|
|
s.equals(getString(R.string.minimize_on_exit_key))) {
|
|
|
|
|
|
|
|
String newSetting = sharedPreferences.getString(s, null);
|
|
|
|
if (newSetting != null
|
|
|
|
&& newSetting.equals(getString(R.string.minimize_on_exit_popup_key))
|
|
|
|
&& !Settings.canDrawOverlays(getContext())) {
|
|
|
|
|
|
|
|
Snackbar.make(getListView(), R.string.permission_display_over_apps, Snackbar.LENGTH_INDEFINITE)
|
|
|
|
.setAction(R.string.settings,
|
|
|
|
view -> PermissionHelper.checkSystemAlertWindowPermission(getContext()))
|
|
|
|
.show();
|
|
|
|
|
2020-01-25 17:00:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-09-03 06:04:18 +00:00
|
|
|
@Override
|
|
|
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
|
|
|
addPreferencesFromResource(R.xml.video_audio_settings);
|
|
|
|
}
|
2020-01-25 17:00:49 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume() {
|
|
|
|
super.onResume();
|
|
|
|
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(listener);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPause() {
|
|
|
|
super.onPause();
|
|
|
|
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(listener);
|
|
|
|
}
|
2017-09-03 06:04:18 +00:00
|
|
|
}
|