mirror of
https://github.com/MaintainTeam/LastPipeBender.git
synced 2025-03-01 05:48:22 +03:00
make the headings to change font
This commit is contained in:
parent
eb9f300e60
commit
bca9fa7b7f
49 changed files with 301 additions and 20 deletions
|
@ -11,6 +11,10 @@ plugins {
|
|||
id "org.sonarqube" version "4.0.0.2929"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
android {
|
||||
compileSdk 34
|
||||
namespace 'org.schabi.newpipe'
|
||||
|
@ -103,6 +107,10 @@ android {
|
|||
'META-INF/COPYRIGHT']
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
aidl true
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
|
@ -197,9 +205,9 @@ dependencies {
|
|||
// Or you can use a commit you pushed to GitHub by just replacing TeamNewPipe with your GitHub
|
||||
// name and the commit hash with the commit hash of the (pushed) commit you want to test
|
||||
// This works thanks to JitPack: https://jitpack.io/
|
||||
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
|
||||
implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.24.2'
|
||||
implementation 'com.github.TeamNewPipe:NoNonsense-FilePicker:5.0.0'
|
||||
implementation 'com.github.teamnewpipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
|
||||
implementation 'com.github.teamnewpipe:NewPipeExtractor:v0.24.2'
|
||||
implementation 'com.github.teamnewpipe:NoNonsense-FilePicker:5.0.0'
|
||||
|
||||
/** Checkstyle **/
|
||||
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
|
||||
|
@ -237,6 +245,10 @@ dependencies {
|
|||
implementation "frankiesardo:icepick:${icepickVersion}"
|
||||
kapt "frankiesardo:icepick-processor:${icepickVersion}"
|
||||
|
||||
// changing fonts
|
||||
implementation 'com.github.MarcinOrlowski:fonty:3.1.5'
|
||||
|
||||
|
||||
// HTML parser
|
||||
implementation "org.jsoup:jsoup:1.17.2"
|
||||
|
||||
|
|
BIN
app/src/main/assets/fonts/ARIALN.TTF
Normal file
BIN
app/src/main/assets/fonts/ARIALN.TTF
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/ARIALNB.TTF
Normal file
BIN
app/src/main/assets/fonts/ARIALNB.TTF
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/ARIALNBI.TTF
Normal file
BIN
app/src/main/assets/fonts/ARIALNBI.TTF
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/ARIALNI.TTF
Normal file
BIN
app/src/main/assets/fonts/ARIALNI.TTF
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/Algerian.TTF
Normal file
BIN
app/src/main/assets/fonts/Algerian.TTF
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/BELL.TTF
Normal file
BIN
app/src/main/assets/fonts/BELL.TTF
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/BELLB.TTF
Normal file
BIN
app/src/main/assets/fonts/BELLB.TTF
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/BELLI.TTF
Normal file
BIN
app/src/main/assets/fonts/BELLI.TTF
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/BROADW.TTF
Normal file
BIN
app/src/main/assets/fonts/BROADW.TTF
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/arial.ttf
Normal file
BIN
app/src/main/assets/fonts/arial.ttf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/arialbd.ttf
Normal file
BIN
app/src/main/assets/fonts/arialbd.ttf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/arialbi.ttf
Normal file
BIN
app/src/main/assets/fonts/arialbi.ttf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/ariali.ttf
Normal file
BIN
app/src/main/assets/fonts/ariali.ttf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/ariblk.ttf
Normal file
BIN
app/src/main/assets/fonts/ariblk.ttf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/calibri.ttf
Normal file
BIN
app/src/main/assets/fonts/calibri.ttf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/calibrib.ttf
Normal file
BIN
app/src/main/assets/fonts/calibrib.ttf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/calibrii.ttf
Normal file
BIN
app/src/main/assets/fonts/calibrii.ttf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/calibril.ttf
Normal file
BIN
app/src/main/assets/fonts/calibril.ttf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/calibrili.ttf
Normal file
BIN
app/src/main/assets/fonts/calibrili.ttf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/calibriz.ttf
Normal file
BIN
app/src/main/assets/fonts/calibriz.ttf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/times.ttf
Normal file
BIN
app/src/main/assets/fonts/times.ttf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/timesbd.ttf
Normal file
BIN
app/src/main/assets/fonts/timesbd.ttf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/timesbi.ttf
Normal file
BIN
app/src/main/assets/fonts/timesbi.ttf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/timesi.ttf
Normal file
BIN
app/src/main/assets/fonts/timesi.ttf
Normal file
Binary file not shown.
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.schabi.newpipe;
|
||||
|
||||
import static org.schabi.newpipe.extractor.NewPipe.getPreferredFont;
|
||||
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
|
@ -57,6 +58,7 @@ import androidx.fragment.app.FragmentManager;
|
|||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.marcinorlowski.fonty.Fonty;
|
||||
|
||||
import org.schabi.newpipe.databinding.ActivityMainBinding;
|
||||
import org.schabi.newpipe.databinding.DrawerHeaderBinding;
|
||||
|
@ -130,6 +132,9 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
// Apply the preferred font globally
|
||||
final String preferredFont = getPreferredFont(this);
|
||||
setUpFont(preferredFont);
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onCreate() called with: "
|
||||
+ "savedInstanceState = [" + savedInstanceState + "]");
|
||||
|
@ -174,6 +179,9 @@ public class MainActivity extends AppCompatActivity {
|
|||
&& ReleaseVersionUtil.INSTANCE.isReleaseApk()) {
|
||||
UpdateSettingsFragment.askForConsentToUpdateChecks(this);
|
||||
}
|
||||
if (preferredFont != "default_font_name") {
|
||||
Fonty.setFonts(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -190,6 +198,45 @@ public class MainActivity extends AppCompatActivity {
|
|||
NewVersionWorker.enqueueNewVersionCheckingWork(app, false);
|
||||
}
|
||||
}
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
|
||||
public void setUpFont(final String preferredFont) {
|
||||
switch (preferredFont) {
|
||||
case "Arial":
|
||||
Fonty.context(this)
|
||||
.normalTypeface("arial.ttf")
|
||||
.build();
|
||||
break;
|
||||
case "Broadway":
|
||||
Fonty.context(this)
|
||||
.normalTypeface("BROADW.TTF")
|
||||
.build();
|
||||
break;
|
||||
case "Algerian":
|
||||
Fonty.context(this)
|
||||
.normalTypeface("Algerian.TTF")
|
||||
.build();
|
||||
break;
|
||||
case "Bell TM":
|
||||
Fonty.context(this)
|
||||
.normalTypeface("BELL.TTF")
|
||||
.build();
|
||||
break;
|
||||
case "Calibri":
|
||||
Fonty.context(this)
|
||||
.normalTypeface("calibri.ttf")
|
||||
.build();
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setupDrawer() throws ExtractionException {
|
||||
addDrawerMenuForCurrentService();
|
||||
|
|
|
@ -41,6 +41,8 @@ import androidx.lifecycle.Lifecycle;
|
|||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.marcinorlowski.fonty.Fonty;
|
||||
|
||||
import org.schabi.newpipe.database.stream.model.StreamEntity;
|
||||
import org.schabi.newpipe.databinding.ListRadioIconItemBinding;
|
||||
import org.schabi.newpipe.databinding.SingleChoiceDialogViewBinding;
|
||||
|
@ -128,6 +130,7 @@ public class RouterActivity extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
final String preferredFont = getPreferredFont(this);
|
||||
ThemeHelper.setDayNightMode(this);
|
||||
setTheme(ThemeHelper.isLightThemeSelected(this)
|
||||
? R.style.RouterActivityThemeLight : R.style.RouterActivityThemeDark);
|
||||
|
@ -183,7 +186,17 @@ public class RouterActivity extends AppCompatActivity {
|
|||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
if (preferredFont != "default_font_name") {
|
||||
Fonty.setFonts(this);
|
||||
}
|
||||
}
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.schabi.newpipe.download;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -10,6 +12,7 @@ import android.view.ViewTreeObserver;
|
|||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.databinding.ActivityDownloaderBinding;
|
||||
|
@ -22,6 +25,8 @@ import us.shandian.giga.ui.fragment.MissionsFragment;
|
|||
|
||||
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
||||
|
||||
import com.marcinorlowski.fonty.Fonty;
|
||||
|
||||
public class DownloadActivity extends AppCompatActivity {
|
||||
|
||||
private static final String MISSIONS_FRAGMENT_TAG = "fragment_tag";
|
||||
|
@ -63,6 +68,10 @@ public class DownloadActivity extends AppCompatActivity {
|
|||
if (DeviceUtils.isTv(this)) {
|
||||
FocusOverlayView.setupFocusObserver(this);
|
||||
}
|
||||
final String preferredFont = getPreferredFont(this);
|
||||
if (preferredFont != "default_font_name") {
|
||||
Fonty.setFonts(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFragments() {
|
||||
|
@ -73,6 +82,12 @@ public class DownloadActivity extends AppCompatActivity {
|
|||
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
||||
.commit();
|
||||
}
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
@ -16,8 +17,10 @@ import androidx.appcompat.app.ActionBar;
|
|||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.IntentCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.grack.nanojson.JsonWriter;
|
||||
import com.marcinorlowski.fonty.Fonty;
|
||||
|
||||
import org.schabi.newpipe.BuildConfig;
|
||||
import org.schabi.newpipe.R;
|
||||
|
@ -83,6 +86,8 @@ public class ErrorActivity extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
final String preferredFont = getPreferredFont(this);
|
||||
|
||||
assureCorrectAppLanguage(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
@ -127,6 +132,9 @@ public class ErrorActivity extends AppCompatActivity {
|
|||
for (final String e : errorInfo.getStackTraces()) {
|
||||
Log.e(TAG, e);
|
||||
}
|
||||
if (preferredFont != "default_font_name") {
|
||||
Fonty.setFonts(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -150,6 +158,13 @@ public class ErrorActivity extends AppCompatActivity {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void openPrivacyPolicyDialog(final Context context, final String action) {
|
||||
new AlertDialog.Builder(context)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.schabi.newpipe.error;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
@ -20,6 +21,8 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||
import androidx.core.app.NavUtils;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.marcinorlowski.fonty.Fonty;
|
||||
|
||||
import org.schabi.newpipe.DownloaderImpl;
|
||||
import org.schabi.newpipe.MainActivity;
|
||||
import org.schabi.newpipe.R;
|
||||
|
@ -68,6 +71,7 @@ public class ReCaptchaActivity extends AppCompatActivity {
|
|||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
final String preferredFont = getPreferredFont(this);
|
||||
ThemeHelper.setTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
@ -109,6 +113,10 @@ public class ReCaptchaActivity extends AppCompatActivity {
|
|||
CookieManager.getInstance().removeAllCookies(null);
|
||||
|
||||
recaptchaBinding.reCaptchaWebView.loadUrl(url);
|
||||
|
||||
if (preferredFont != "default_font_name") {
|
||||
Fonty.setFonts(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -129,6 +137,12 @@ public class ReCaptchaActivity extends AppCompatActivity {
|
|||
public void onBackPressed() {
|
||||
saveCookiesAndFinish();
|
||||
}
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package org.schabi.newpipe.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.schabi.newpipe.BaseFragment;
|
||||
import org.schabi.newpipe.R;
|
||||
|
@ -20,7 +23,11 @@ public class EmptyFragment extends BaseFragment {
|
|||
emptyFragment.setArguments(bundle);
|
||||
return emptyFragment;
|
||||
}
|
||||
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container,
|
||||
final Bundle savedInstanceState) {
|
||||
|
|
|
@ -91,7 +91,11 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
|||
mainTabsPositionKey = getString(R.string.main_tabs_position_key);
|
||||
mainTabsPositionBottom = prefs.getBoolean(mainTabsPositionKey, false);
|
||||
}
|
||||
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
@Override
|
||||
public View onCreateView(@NonNull final LayoutInflater inflater,
|
||||
@Nullable final ViewGroup container,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.schabi.newpipe.fragments.list.kiosk;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
|
@ -10,6 +12,7 @@ import android.view.ViewGroup;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.error.ErrorInfo;
|
||||
|
@ -100,7 +103,11 @@ public class KioskFragment extends BaseListInfoFragment<StreamInfoItem, KioskInf
|
|||
name = kioskTranslatedName;
|
||||
contentCountry = Localization.getPreferredContentCountry(requireContext());
|
||||
}
|
||||
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
|
|
@ -6,6 +6,7 @@ import static org.schabi.newpipe.ktx.ViewUtils.animateHideRecyclerViewAllowingSc
|
|||
import static org.schabi.newpipe.util.ServiceHelper.getServiceById;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
@ -19,9 +20,11 @@ import android.view.ViewGroup;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.google.android.material.shape.CornerFamily;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
import com.marcinorlowski.fonty.Fonty;
|
||||
|
||||
import org.reactivestreams.Subscriber;
|
||||
import org.reactivestreams.Subscription;
|
||||
|
@ -98,7 +101,11 @@ public class PlaylistFragment extends BaseListInfoFragment<StreamInfoItem, Playl
|
|||
instance.setInitialData(serviceId, url, name);
|
||||
return instance;
|
||||
}
|
||||
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
public PlaylistFragment() {
|
||||
super(UserAction.REQUESTED_PLAYLIST);
|
||||
}
|
||||
|
@ -120,7 +127,12 @@ public class PlaylistFragment extends BaseListInfoFragment<StreamInfoItem, Playl
|
|||
public View onCreateView(@NonNull final LayoutInflater inflater,
|
||||
@Nullable final ViewGroup container,
|
||||
@Nullable final Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_playlist, container, false);
|
||||
final View view = inflater.inflate(R.layout.fragment_playlist, container, false);
|
||||
final String preferredFont = getPreferredFont(view.getContext());
|
||||
if (preferredFont != "default_font_name") {
|
||||
Fonty.setFonts((ViewGroup) view);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -124,7 +124,11 @@ class FeedFragment : BaseStateFragment<FeedState>() {
|
|||
PreferenceManager.getDefaultSharedPreferences(activity)
|
||||
.registerOnSharedPreferenceChangeListener(onSettingsChangeListener)
|
||||
}
|
||||
|
||||
// fun getPreferredFont(context: Context?): String? {
|
||||
// val preferences = PreferenceManager
|
||||
// .getDefaultSharedPreferences(context!!)
|
||||
// return preferences.getString("preferred_font", "default_font_name")
|
||||
// }
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_feed, container, false)
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import static org.schabi.newpipe.ktx.ViewUtils.animate;
|
|||
import static org.schabi.newpipe.util.ThemeHelper.shouldUseGridLayout;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.text.InputType;
|
||||
|
@ -22,6 +23,7 @@ import android.widget.Toast;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.viewbinding.ViewBinding;
|
||||
|
@ -125,7 +127,11 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
|||
isLoadingComplete = new AtomicBoolean();
|
||||
debounceSaver = new DebounceSaver(this);
|
||||
}
|
||||
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
@Override
|
||||
public View onCreateView(@NonNull final LayoutInflater inflater,
|
||||
@Nullable final ViewGroup container,
|
||||
|
|
|
@ -5,8 +5,10 @@ import static org.schabi.newpipe.player.helper.PlayerHelper.formatSpeed;
|
|||
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.provider.Settings;
|
||||
|
@ -21,11 +23,13 @@ import android.widget.SeekBar;
|
|||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.exoplayer2.PlaybackParameters;
|
||||
import com.marcinorlowski.fonty.Fonty;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.databinding.ActivityPlayerQueueControlBinding;
|
||||
|
@ -84,6 +88,7 @@ public final class PlayQueueActivity extends AppCompatActivity
|
|||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
final String preferredFont = getPreferredFont(this);
|
||||
assureCorrectAppLanguage(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this));
|
||||
|
@ -99,6 +104,9 @@ public final class PlayQueueActivity extends AppCompatActivity
|
|||
|
||||
serviceConnection = getServiceConnection();
|
||||
bind();
|
||||
if (preferredFont != "default_font_name") {
|
||||
Fonty.setFonts(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -126,6 +134,12 @@ public final class PlayQueueActivity extends AppCompatActivity
|
|||
}
|
||||
return super.onPrepareOptionsMenu(m);
|
||||
}
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package org.schabi.newpipe.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.schabi.newpipe.DownloaderImpl;
|
||||
import org.schabi.newpipe.R;
|
||||
|
@ -22,6 +24,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
private String youtubeRestrictedModeEnabledKey;
|
||||
|
||||
private Localization initialSelectedLocalization;
|
||||
private String initialSelectedFont;
|
||||
private ContentCountry initialSelectedContentCountry;
|
||||
private String initialLanguage;
|
||||
|
||||
|
@ -36,7 +39,8 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
initialSelectedContentCountry = org.schabi.newpipe.util.Localization
|
||||
.getPreferredContentCountry(requireContext());
|
||||
initialLanguage = defaultPreferences.getString(getString(R.string.app_language_key), "en");
|
||||
|
||||
initialSelectedFont = defaultPreferences
|
||||
.getString(getString(R.string.app_font_key), "Default");
|
||||
final Preference imageQualityPreference = requirePreference(R.string.image_quality_key);
|
||||
imageQualityPreference.setOnPreferenceChangeListener(
|
||||
(preference, newValue) -> {
|
||||
|
@ -78,7 +82,8 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
.getPreferredContentCountry(requireContext());
|
||||
final String selectedLanguage =
|
||||
defaultPreferences.getString(getString(R.string.app_language_key), "en");
|
||||
|
||||
final String selectedFont =
|
||||
defaultPreferences.getString(getString(R.string.app_font_key), "Arial");
|
||||
if (!selectedLocalization.equals(initialSelectedLocalization)
|
||||
|| !selectedContentCountry.equals(initialSelectedContentCountry)
|
||||
|| !selectedLanguage.equals(initialLanguage)) {
|
||||
|
@ -86,6 +91,15 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
Toast.LENGTH_LONG).show();
|
||||
|
||||
NewPipe.setupLocalization(selectedLocalization, selectedContentCountry);
|
||||
} else if ((!selectedFont.equals(initialSelectedFont))) {
|
||||
Toast.makeText(requireContext(), R.string.font_changes_requires_app_restart,
|
||||
Toast.LENGTH_LONG).show();
|
||||
NewPipe.setupFont(selectedFont);
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(requireContext());
|
||||
final SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putString("preferred_font", selectedFont);
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package org.schabi.newpipe.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.schabi.newpipe.DownloaderImpl;
|
||||
import org.schabi.newpipe.R;
|
||||
|
@ -55,7 +57,11 @@ public class HistorySettingsFragment extends BasePreferenceFragment {
|
|||
clearCookiePref.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(final Preference preference) {
|
||||
if (preference.getKey().equals(cacheWipeKey)) {
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package org.schabi.newpipe.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.schabi.newpipe.MainActivity;
|
||||
import org.schabi.newpipe.R;
|
||||
|
@ -58,7 +61,11 @@ public class MainSettingsFragment extends BasePreferenceFragment {
|
|||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
// Unlink activity so that we don't get memory problems
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.schabi.newpipe.settings;
|
|||
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
@ -20,8 +21,10 @@ import androidx.fragment.app.Fragment;
|
|||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.jakewharton.rxbinding4.widget.RxTextView;
|
||||
import com.marcinorlowski.fonty.Fonty;
|
||||
|
||||
import org.schabi.newpipe.MainActivity;
|
||||
import org.schabi.newpipe.R;
|
||||
|
@ -89,6 +92,7 @@ public class SettingsActivity extends AppCompatActivity implements
|
|||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceBundle) {
|
||||
|
||||
setTheme(ThemeHelper.getSettingsThemeStyle(this));
|
||||
assureCorrectAppLanguage(this);
|
||||
|
||||
|
@ -120,6 +124,10 @@ public class SettingsActivity extends AppCompatActivity implements
|
|||
if (DeviceUtils.isTv(this)) {
|
||||
FocusOverlayView.setupFocusObserver(this);
|
||||
}
|
||||
final String preferredFont = getPreferredFont(this);
|
||||
if (preferredFont != "default_font_name") {
|
||||
Fonty.setFonts(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -257,6 +265,12 @@ public class SettingsActivity extends AppCompatActivity implements
|
|||
}
|
||||
searchFragment.setSearcher(searcher);
|
||||
}
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ensures that the search shows the correct/available search results.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.schabi.newpipe.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
|
@ -14,9 +15,11 @@ import android.widget.Toast;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.loader.content.Loader;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.SortedList;
|
||||
|
||||
import com.marcinorlowski.fonty.Fonty;
|
||||
import com.nononsenseapps.filepicker.AbstractFilePickerFragment;
|
||||
import com.nononsenseapps.filepicker.FilePickerFragment;
|
||||
|
||||
|
@ -36,12 +39,17 @@ public class FilePickerActivityHelper extends com.nononsenseapps.filepicker.File
|
|||
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
final String preferredFont = getPreferredFont(this);
|
||||
if (ThemeHelper.isLightThemeSelected(this)) {
|
||||
this.setTheme(R.style.FilePickerThemeLight);
|
||||
} else {
|
||||
this.setTheme(R.style.FilePickerThemeDark);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (preferredFont != "default_font_name") {
|
||||
Fonty.setFonts(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,6 +62,13 @@ public class FilePickerActivityHelper extends com.nononsenseapps.filepicker.File
|
|||
currentFragment.goUp();
|
||||
}
|
||||
}
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected AbstractFilePickerFragment<File> getFragment(@Nullable final String startPath,
|
||||
|
|
|
@ -129,6 +129,7 @@ public class DownloadManagerService extends Service {
|
|||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
||||
super.onCreate();
|
||||
|
||||
if (DEBUG) {
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
package us.shandian.giga.ui.common;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.marcinorlowski.fonty.Fonty;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
|
||||
|
@ -12,13 +17,24 @@ public abstract class ToolbarActivity extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
final String preferredFont = getPreferredFont(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(getLayoutResource());
|
||||
|
||||
mToolbar = this.findViewById(R.id.toolbar);
|
||||
|
||||
setSupportActionBar(mToolbar);
|
||||
|
||||
if (preferredFont != "default_font_name") {
|
||||
Fonty.setFonts(this);
|
||||
}
|
||||
}
|
||||
public String getPreferredFont(final Context context) {
|
||||
final SharedPreferences preferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return preferences.getString("preferred_font", "default_font_name");
|
||||
}
|
||||
|
||||
|
||||
protected abstract int getLayoutResource();
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../layout/list_stream_item.xml
|
|
@ -354,6 +354,8 @@
|
|||
|
||||
<string name="app_language_key">app_language_key</string>
|
||||
|
||||
<string name="app_font_key">app_font_key</string>
|
||||
|
||||
<string name="feed_update_threshold_key">feed_update_threshold_key</string>
|
||||
<string name="feed_update_threshold_default_value">300</string>
|
||||
<string name="feed_show_watched_items_key">feed_show_played_items</string>
|
||||
|
@ -1343,6 +1345,29 @@
|
|||
<item>正體中文</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
|
||||
<!--The next two arrays are set to change the app font-->
|
||||
<string-array name="app_font_code">
|
||||
<item>@string/default_localization_key</item>
|
||||
<item>Calibri</item>
|
||||
<item>Algerian</item>
|
||||
<item>Broadway</item>
|
||||
<item>Arial</item>
|
||||
<item>Bell MT</item>
|
||||
<item>Time New Roman</item>
|
||||
</string-array>
|
||||
<string-array name="app_font_name">
|
||||
<item>@string/systems_font</item>
|
||||
<item>Calibri</item>
|
||||
<item>Algerian</item>
|
||||
<item>Broadway</item>
|
||||
<item>Arial</item>
|
||||
<item>Bell MT</item>
|
||||
<item>Time New Roman</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<!-- Limit mobile data usage -->
|
||||
<string name="limit_mobile_data_usage_key">limit_mobile_data_usage</string>
|
||||
<string name="limit_data_usage_none_key">limit_data_usage_none</string>
|
||||
|
|
|
@ -411,6 +411,7 @@
|
|||
<string name="import_settings">Do you want to also import settings?</string>
|
||||
<string name="error_unable_to_load_comments">Could not load comments</string>
|
||||
<string name="localization_changes_requires_app_restart">The language will change once the app is restarted</string>
|
||||
<string name="font_changes_requires_app_restart">The font will change once the app is restarted</string>
|
||||
<!-- Kiosk Names -->
|
||||
<string name="trending">Trending</string>
|
||||
<string name="top_50">Top 50</string>
|
||||
|
@ -658,6 +659,9 @@
|
|||
<string name="choose_instance_prompt">Choose an instance</string>
|
||||
<string name="app_language_title">App language</string>
|
||||
<string name="systems_language">System default</string>
|
||||
<string name="systems_font">System default</string>
|
||||
<string name="app_font_title">App font</string>
|
||||
|
||||
<string name="remove_watched">Remove watched</string>
|
||||
<string name="remove_watched_popup_title">Remove watched videos?</string>
|
||||
<string name="remove_duplicates">Remove duplicates</string>
|
||||
|
|
|
@ -33,6 +33,16 @@
|
|||
app:iconSpaceReserved="false"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="@string/default_localization_key"
|
||||
android:entries="@array/app_font_name"
|
||||
android:entryValues="@array/app_font_code"
|
||||
android:key="@string/app_font_key"
|
||||
android:title="@string/app_font_title"
|
||||
app:singleLineTitle="false"
|
||||
app:iconSpaceReserved="false"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<PreferenceScreen
|
||||
android:fragment="org.schabi.newpipe.settings.tabs.ChooseTabsFragment"
|
||||
android:key="@string/main_page_content_key"
|
||||
|
|
|
@ -4,8 +4,8 @@ include ':app'
|
|||
// We assume, that NewPipe and NewPipe Extractor have the same parent directory.
|
||||
// If this is not the case, please change the path in includeBuild().
|
||||
|
||||
//includeBuild('../NewPipeExtractor') {
|
||||
// dependencySubstitution {
|
||||
// substitute module('com.github.TeamNewPipe:NewPipeExtractor') using project(':extractor')
|
||||
// }
|
||||
//}
|
||||
includeBuild('../NewPipeExtractor') {
|
||||
dependencySubstitution {
|
||||
substitute module('com.github.teamnewpipe:NewPipeExtractor') using project(':extractor')
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue