aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java22
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java21
-rw-r--r--app/src/main/res/values/strings.xml10
6 files changed, 70 insertions, 10 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
index 2b990071..78939b83 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
@@ -5,9 +5,11 @@ import android.app.Application;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
+import android.graphics.Typeface;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.view.WindowManager;
+import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -26,6 +28,7 @@ import org.greenrobot.eventbus.Subscribe;
import javax.inject.Inject;
import javax.inject.Named;
+import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.LockScreenActivity;
import ml.docilealligator.infinityforreddit.broadcastreceivers.NetworkWifiStatusReceiver;
import ml.docilealligator.infinityforreddit.broadcastreceivers.WallpaperChangeReceiver;
@@ -42,6 +45,9 @@ public class Infinity extends Application implements LifecycleObserver {
private long appLockTimeout;
private boolean canStartLockScreenActivity = false;
private boolean isSecureMode;
+ private Typeface typeface;
+ private Typeface titleTypeface;
+ private Typeface contentTypeface;
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
@@ -63,8 +69,24 @@ public class Infinity extends Application implements LifecycleObserver {
appLockTimeout = Long.parseLong(mSecuritySharedPreferences.getString(SharedPreferencesUtils.APP_LOCK_TIMEOUT, "600000"));
isSecureMode = mSecuritySharedPreferences.getBoolean(SharedPreferencesUtils.SECURE_MODE, false);
+ try {
+ typeface = Typeface.createFromFile(getCacheDir() + "/opensans.ttf");
+ titleTypeface = Typeface.createFromFile(getCacheDir() + "/opensans.ttf");
+ contentTypeface = Typeface.createFromFile(getCacheDir() + "/opensans.ttf");
+ } catch (RuntimeException e) {
+ e.printStackTrace();
+ Toast.makeText(this, "Some font files do not exist", Toast.LENGTH_SHORT).show();
+ }
+
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
+ public void onActivityPreCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
+ if (activity instanceof BaseActivity) {
+ ((BaseActivity) activity).setCustomFont(typeface, titleTypeface, contentTypeface);
+ }
+ }
+
+ @Override
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle bundle) {
if (isSecureMode) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
index ad840efa..9890d538 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
@@ -11,6 +11,7 @@ import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
+import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
@@ -59,6 +60,9 @@ public abstract class BaseActivity extends AppCompatActivity {
private int systemVisibilityToolbarExpanded = 0;
private int systemVisibilityToolbarCollapsed = 0;
private CustomThemeWrapper customThemeWrapper;
+ public Typeface typeface;
+ public Typeface titleTypeface;
+ public Typeface contentTypeface;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -367,4 +371,10 @@ public abstract class BaseActivity extends AppCompatActivity {
}
} catch (NoSuchFieldException | IllegalAccessException ignore) {}
}
+
+ public void setCustomFont(Typeface typeface, Typeface titleTypeface, Typeface contentTypeface) {
+ this.typeface = typeface;
+ this.titleTypeface = titleTypeface;
+ this.contentTypeface = contentTypeface;
+ }
} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java
index d9248652..106b717a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java
@@ -182,7 +182,7 @@ public class EditProfileActivity extends BaseActivity {
@Override
public void failed(String message) {
Toast.makeText(EditProfileActivity.this,
- getString(R.string.message_remove_banner_failed_fmt, message),
+ getString(R.string.message_remove_banner_failed, message),
Toast.LENGTH_SHORT).show();
}
}))
@@ -224,7 +224,7 @@ public class EditProfileActivity extends BaseActivity {
@Override
public void failed(String message) {
Toast.makeText(EditProfileActivity.this,
- getString(R.string.message_remove_avatar_failed_fmt, message),
+ getString(R.string.message_remove_avatar_failed, message),
Toast.LENGTH_SHORT).show();
}
}))
@@ -305,7 +305,7 @@ public class EditProfileActivity extends BaseActivity {
if (event.isSuccess) {
Toast.makeText(this, R.string.message_change_avatar_success, Toast.LENGTH_SHORT).show();
} else {
- String message = getString(R.string.message_change_avatar_failed_fmt, event.errorMessage);
+ String message = getString(R.string.message_change_avatar_failed, event.errorMessage);
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
}
@@ -315,7 +315,7 @@ public class EditProfileActivity extends BaseActivity {
if (event.isSuccess) {
Toast.makeText(this, R.string.message_change_banner_success, Toast.LENGTH_SHORT).show();
} else {
- String message = getString(R.string.message_change_banner_failed_fmt, event.errorMessage);
+ String message = getString(R.string.message_change_banner_failed, event.errorMessage);
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
}
@@ -325,7 +325,7 @@ public class EditProfileActivity extends BaseActivity {
if (event.isSuccess) {
Toast.makeText(this, R.string.message_save_profile_success, Toast.LENGTH_SHORT).show();
} else {
- String message = getString(R.string.message_save_profile_failed_fmt, event.errorMessage);
+ String message = getString(R.string.message_save_profile_failed, event.errorMessage);
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
index 11a9dc13..44c284b5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -25,6 +25,7 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
@@ -354,6 +355,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
applyTabLayoutTheme(tabLayout);
bottomAppBar.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor()));
applyFABTheme(fab);
+ for (int i = 0; i < toolbar.getChildCount(); i++) {
+ View view = toolbar.getChildAt(i);
+ if (view instanceof TextView) {
+ ((TextView) view).setTypeface(typeface);
+ }
+ }
}
private void initializeNotificationAndBindView(boolean doNotInitializeNotificationIfNoNewAccount) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index f69b8378..e326c11d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -75,6 +75,7 @@ import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStra
import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.StreamableVideo;
import ml.docilealligator.infinityforreddit.VoteThing;
+import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.activities.ViewImageOrGifActivity;
@@ -2103,6 +2104,26 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else {
itemView.setBackgroundTintList(ColorStateList.valueOf(mCardViewBackgroundColor));
}
+
+ if (((BaseActivity) mActivity).typeface != null) {
+ subredditTextView.setTypeface(((BaseActivity) mActivity).typeface);
+ userTextView.setTypeface(((BaseActivity) mActivity).typeface);
+ postTimeTextView.setTypeface(((BaseActivity) mActivity).typeface);
+ typeTextView.setTypeface(((BaseActivity) mActivity).typeface);
+ spoilerTextView.setTypeface(((BaseActivity) mActivity).typeface);
+ nsfwTextView.setTypeface(((BaseActivity) mActivity).typeface);
+ flairTextView.setTypeface(((BaseActivity) mActivity).typeface);
+ awardsTextView.setTypeface(((BaseActivity) mActivity).typeface);
+ scoreTextView.setTypeface(((BaseActivity) mActivity).typeface);
+ commentsCountTextView.setTypeface(((BaseActivity) mActivity).typeface);
+ }
+ if (((BaseActivity) mActivity).titleTypeface != null) {
+ titleTextView.setTypeface(((BaseActivity) mActivity).titleTypeface);
+ }
+ if (((BaseActivity) mActivity).contentTypeface != null) {
+
+ }
+
subredditTextView.setTextColor(mSubredditColor);
userTextView.setTextColor(mUsernameColor);
postTimeTextView.setTextColor(mSecondaryTextColor);
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index cf7ea58e..11f1d66d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1235,14 +1235,14 @@
<string name="about_you_text">About You</string>
<string name="about_you_hint">A little description of yourself</string>
<string name="message_remove_avatar_success">Remove avatar successfully</string>
- <string name="message_remove_avatar_failed_fmt">Failed to remove avatar %s</string>
+ <string name="message_remove_avatar_failed">Failed to remove avatar %s</string>
<string name="message_remove_banner_success">Remove banner successfully</string>
- <string name="message_remove_banner_failed_fmt">Failed to remove banner %s</string>
+ <string name="message_remove_banner_failed">Failed to remove banner %s</string>
<string name="message_change_avatar_success">Change avatar successfully</string>
- <string name="message_change_avatar_failed_fmt">Failed to change avatar %s</string>
+ <string name="message_change_avatar_failed">Failed to change avatar %s</string>
<string name="message_change_banner_success">Changing banner successfully</string>
- <string name="message_change_banner_failed_fmt">Failed to change banner %s</string>
+ <string name="message_change_banner_failed">Failed to change banner %s</string>
<string name="message_save_profile_success">Save profile successfully</string>
- <string name="message_save_profile_failed_fmt">Failed to save profile %s</string>
+ <string name="message_save_profile_failed">Failed to save profile %s</string>
</resources>