Allow to change colors
This commit is contained in:
parent
2a3ddcf0cd
commit
479d6dcf9b
|
@ -124,5 +124,5 @@ dependencies {
|
||||||
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
|
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
|
||||||
implementation 'com.github.smarteist:autoimageslider:1.3.2'
|
implementation 'com.github.smarteist:autoimageslider:1.3.2'
|
||||||
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-2'
|
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-2'
|
||||||
|
implementation 'com.jaredrummler:colorpicker:1.1.0'
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import com.google.android.material.tabs.TabLayout;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import app.fedilab.android.R;
|
import app.fedilab.android.R;
|
||||||
|
import app.fedilab.android.fragments.ColorSettingsFragment;
|
||||||
import app.fedilab.android.fragments.ContentSettingsFragment;
|
import app.fedilab.android.fragments.ContentSettingsFragment;
|
||||||
import app.fedilab.android.helper.Helper;
|
import app.fedilab.android.helper.Helper;
|
||||||
|
|
||||||
|
@ -98,6 +99,7 @@ public class SettingsActivity extends BaseActivity {
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.notifications)));
|
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.notifications)));
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.settings_category_label_interface)));
|
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.settings_category_label_interface)));
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.compose)));
|
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.compose)));
|
||||||
|
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.colors)));
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.hide_menu_items)));
|
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.hide_menu_items)));
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.administration)));
|
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.administration)));
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.languages)));
|
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.languages)));
|
||||||
|
@ -168,12 +170,14 @@ public class SettingsActivity extends BaseActivity {
|
||||||
typeOfSettings = ContentSettingsFragment.type.COMPOSE;
|
typeOfSettings = ContentSettingsFragment.type.COMPOSE;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
return new ColorSettingsFragment();
|
||||||
|
case 5:
|
||||||
typeOfSettings = ContentSettingsFragment.type.MENU;
|
typeOfSettings = ContentSettingsFragment.type.MENU;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 6:
|
||||||
typeOfSettings = ContentSettingsFragment.type.ADMIN;
|
typeOfSettings = ContentSettingsFragment.type.ADMIN;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 7:
|
||||||
typeOfSettings = ContentSettingsFragment.type.LANGUAGE;
|
typeOfSettings = ContentSettingsFragment.type.LANGUAGE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -189,7 +193,7 @@ public class SettingsActivity extends BaseActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return 7;
|
return 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ import android.os.Parcelable;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
|
@ -861,6 +862,19 @@ public class Status implements Parcelable {
|
||||||
spannableStringT.removeSpan(span);
|
spannableStringT.removeSpan(span);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
int l_c = prefs.getInt("theme_link_color", -1);
|
||||||
|
if( l_c == -1) {
|
||||||
|
if (theme == THEME_DARK)
|
||||||
|
l_c = ContextCompat.getColor(context, R.color.dark_link_toot);
|
||||||
|
else if (theme == THEME_BLACK)
|
||||||
|
l_c = ContextCompat.getColor(context, R.color.black_link_toot);
|
||||||
|
else if (theme == THEME_LIGHT)
|
||||||
|
l_c = ContextCompat.getColor(context, R.color.light_link_toot);
|
||||||
|
}
|
||||||
|
final int link_color = l_c;
|
||||||
|
|
||||||
matcher = Helper.twitterPattern.matcher(spannableStringT);
|
matcher = Helper.twitterPattern.matcher(spannableStringT);
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
int matchStart = matcher.start(2);
|
int matchStart = matcher.start(2);
|
||||||
|
@ -888,12 +902,7 @@ public class Status implements Parcelable {
|
||||||
public void updateDrawState(@NonNull TextPaint ds) {
|
public void updateDrawState(@NonNull TextPaint ds) {
|
||||||
super.updateDrawState(ds);
|
super.updateDrawState(ds);
|
||||||
ds.setUnderlineText(false);
|
ds.setUnderlineText(false);
|
||||||
if (theme == THEME_DARK)
|
ds.setColor(link_color);
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.dark_link_toot));
|
|
||||||
else if (theme == THEME_BLACK)
|
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.black_link_toot));
|
|
||||||
else if (theme == THEME_LIGHT)
|
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.light_link_toot));
|
|
||||||
}
|
}
|
||||||
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
}
|
}
|
||||||
|
@ -940,12 +949,7 @@ public class Status implements Parcelable {
|
||||||
public void updateDrawState(@NonNull TextPaint ds) {
|
public void updateDrawState(@NonNull TextPaint ds) {
|
||||||
super.updateDrawState(ds);
|
super.updateDrawState(ds);
|
||||||
ds.setUnderlineText(false);
|
ds.setUnderlineText(false);
|
||||||
if (theme == THEME_DARK)
|
ds.setColor(link_color);
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.dark_link_toot));
|
|
||||||
else if (theme == THEME_BLACK)
|
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.black_link_toot));
|
|
||||||
else if (theme == THEME_LIGHT)
|
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.light_link_toot));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
startPosition, endPosition,
|
startPosition, endPosition,
|
||||||
|
@ -1022,12 +1026,7 @@ public class Status implements Parcelable {
|
||||||
public void updateDrawState(@NonNull TextPaint ds) {
|
public void updateDrawState(@NonNull TextPaint ds) {
|
||||||
super.updateDrawState(ds);
|
super.updateDrawState(ds);
|
||||||
ds.setUnderlineText(false);
|
ds.setUnderlineText(false);
|
||||||
if (theme == THEME_DARK)
|
ds.setColor(link_color);
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.dark_link_toot));
|
|
||||||
else if (theme == THEME_BLACK)
|
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.black_link_toot));
|
|
||||||
else if (theme == THEME_LIGHT)
|
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.light_link_toot));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
startPosition, endPosition,
|
startPosition, endPosition,
|
||||||
|
@ -1059,12 +1058,7 @@ public class Status implements Parcelable {
|
||||||
public void updateDrawState(@NonNull TextPaint ds) {
|
public void updateDrawState(@NonNull TextPaint ds) {
|
||||||
super.updateDrawState(ds);
|
super.updateDrawState(ds);
|
||||||
ds.setUnderlineText(false);
|
ds.setUnderlineText(false);
|
||||||
if (theme == THEME_DARK)
|
ds.setColor(link_color);
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.dark_link_toot));
|
|
||||||
else if (theme == THEME_BLACK)
|
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.black_link_toot));
|
|
||||||
else if (theme == THEME_LIGHT)
|
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.light_link_toot));
|
|
||||||
}
|
}
|
||||||
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
|
|
||||||
|
@ -1093,12 +1087,7 @@ public class Status implements Parcelable {
|
||||||
public void updateDrawState(@NonNull TextPaint ds) {
|
public void updateDrawState(@NonNull TextPaint ds) {
|
||||||
super.updateDrawState(ds);
|
super.updateDrawState(ds);
|
||||||
ds.setUnderlineText(false);
|
ds.setUnderlineText(false);
|
||||||
if (theme == THEME_DARK)
|
ds.setColor(link_color);
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.dark_link_toot));
|
|
||||||
else if (theme == THEME_BLACK)
|
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.black_link_toot));
|
|
||||||
else if (theme == THEME_LIGHT)
|
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.light_link_toot));
|
|
||||||
}
|
}
|
||||||
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
|
|
||||||
|
@ -1109,6 +1098,20 @@ public class Status implements Parcelable {
|
||||||
|
|
||||||
public static void transformTranslation(Context context, Status status) {
|
public static void transformTranslation(Context context, Status status) {
|
||||||
|
|
||||||
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||||
|
int l_c = prefs.getInt("theme_link_color", -1);
|
||||||
|
if( l_c == -1) {
|
||||||
|
if (theme == THEME_DARK)
|
||||||
|
l_c = ContextCompat.getColor(context, R.color.dark_link_toot);
|
||||||
|
else if (theme == THEME_BLACK)
|
||||||
|
l_c = ContextCompat.getColor(context, R.color.black_link_toot);
|
||||||
|
else if (theme == THEME_LIGHT)
|
||||||
|
l_c = ContextCompat.getColor(context, R.color.light_link_toot);
|
||||||
|
}
|
||||||
|
final int link_color = l_c;
|
||||||
|
|
||||||
if (((Activity) context).isFinishing() || status == null)
|
if (((Activity) context).isFinishing() || status == null)
|
||||||
return;
|
return;
|
||||||
if ((status.getReblog() != null && status.getReblog().getContent() == null) || (status.getReblog() == null && status.getContent() == null))
|
if ((status.getReblog() != null && status.getReblog().getContent() == null) || (status.getReblog() == null && status.getContent() == null))
|
||||||
|
@ -1128,8 +1131,8 @@ public class Status implements Parcelable {
|
||||||
}
|
}
|
||||||
SpannableString contentSpanTranslated = status.getContentSpanTranslated();
|
SpannableString contentSpanTranslated = status.getContentSpanTranslated();
|
||||||
Matcher matcherALink = Patterns.WEB_URL.matcher(contentSpanTranslated.toString());
|
Matcher matcherALink = Patterns.WEB_URL.matcher(contentSpanTranslated.toString());
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
|
||||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
|
||||||
while (matcherALink.find()) {
|
while (matcherALink.find()) {
|
||||||
int matchStart = matcherALink.start();
|
int matchStart = matcherALink.start();
|
||||||
int matchEnd = matcherALink.end();
|
int matchEnd = matcherALink.end();
|
||||||
|
@ -1148,12 +1151,7 @@ public class Status implements Parcelable {
|
||||||
public void updateDrawState(@NonNull TextPaint ds) {
|
public void updateDrawState(@NonNull TextPaint ds) {
|
||||||
super.updateDrawState(ds);
|
super.updateDrawState(ds);
|
||||||
ds.setUnderlineText(false);
|
ds.setUnderlineText(false);
|
||||||
if (theme == THEME_DARK)
|
ds.setColor(link_color);
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.dark_link_toot));
|
|
||||||
else if (theme == THEME_BLACK)
|
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.black_link_toot));
|
|
||||||
else if (theme == THEME_LIGHT)
|
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.light_link_toot));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
matchStart, matchEnd,
|
matchStart, matchEnd,
|
||||||
|
|
|
@ -41,6 +41,7 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.widget.PopupMenu;
|
import androidx.appcompat.widget.PopupMenu;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
@ -56,6 +57,7 @@ import android.text.method.LinkMovementMethod;
|
||||||
import android.text.style.ClickableSpan;
|
import android.text.style.ClickableSpan;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
import android.text.style.URLSpan;
|
import android.text.style.URLSpan;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
@ -2106,6 +2108,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
holder.status_boosted_by_info.setVisibility(View.GONE);
|
holder.status_boosted_by_info.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
int reblogColor = prefs.getInt("theme_boost_header_color", -1);
|
||||||
|
if( reblogColor != -1 ){
|
||||||
|
holder.status_boosted_by_info.setBackgroundColor(reblogColor);
|
||||||
|
}
|
||||||
if (type == RetrieveFeedsAsyncTask.Type.CONVERSATION && status.getConversationProfilePicture() != null) {
|
if (type == RetrieveFeedsAsyncTask.Type.CONVERSATION && status.getConversationProfilePicture() != null) {
|
||||||
holder.status_account_profile.setVisibility(View.GONE);
|
holder.status_account_profile.setVisibility(View.GONE);
|
||||||
holder.conversation_pp.setVisibility(View.VISIBLE);
|
holder.conversation_pp.setVisibility(View.VISIBLE);
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package app.fedilab.android.fragments;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import app.fedilab.android.R;
|
||||||
|
|
||||||
|
public class ColorSettingsFragment extends PreferenceFragmentCompat {
|
||||||
|
@Override
|
||||||
|
public void onCreatePreferences(Bundle bundle, String s) {
|
||||||
|
// Load the Preferences from the XML file
|
||||||
|
addPreferencesFromResource(R.xml.fragment_settings_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -119,6 +119,7 @@ import static app.fedilab.android.activities.BaseMainActivity.iconLauncher.FEDIV
|
||||||
import static app.fedilab.android.activities.BaseMainActivity.iconLauncher.HERO;
|
import static app.fedilab.android.activities.BaseMainActivity.iconLauncher.HERO;
|
||||||
import static app.fedilab.android.activities.BaseMainActivity.iconLauncher.MASTALAB;
|
import static app.fedilab.android.activities.BaseMainActivity.iconLauncher.MASTALAB;
|
||||||
import static app.fedilab.android.fragments.ContentSettingsFragment.type.ADMIN;
|
import static app.fedilab.android.fragments.ContentSettingsFragment.type.ADMIN;
|
||||||
|
import static app.fedilab.android.fragments.ContentSettingsFragment.type.COLORS;
|
||||||
import static app.fedilab.android.fragments.ContentSettingsFragment.type.COMPOSE;
|
import static app.fedilab.android.fragments.ContentSettingsFragment.type.COMPOSE;
|
||||||
import static app.fedilab.android.fragments.ContentSettingsFragment.type.INTERFACE;
|
import static app.fedilab.android.fragments.ContentSettingsFragment.type.INTERFACE;
|
||||||
import static app.fedilab.android.fragments.ContentSettingsFragment.type.LANGUAGE;
|
import static app.fedilab.android.fragments.ContentSettingsFragment.type.LANGUAGE;
|
||||||
|
@ -177,7 +178,8 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
|
||||||
INTERFACE,
|
INTERFACE,
|
||||||
COMPOSE,
|
COMPOSE,
|
||||||
LANGUAGE,
|
LANGUAGE,
|
||||||
MENU
|
MENU,
|
||||||
|
COLORS
|
||||||
}
|
}
|
||||||
private List<Account> translators = new ArrayList<>();
|
private List<Account> translators = new ArrayList<>();
|
||||||
private AccountSearchDevAdapter translatorManager;
|
private AccountSearchDevAdapter translatorManager;
|
||||||
|
|
|
@ -1247,4 +1247,9 @@
|
||||||
<string name="title_video_peertube">Title for the video</string>
|
<string name="title_video_peertube">Title for the video</string>
|
||||||
<string name="join_peertube">Join Peertube</string>
|
<string name="join_peertube">Join Peertube</string>
|
||||||
<string name="agreement_check_peertube">I am at least 16 years old and agree to the %1$s of this instance</string>
|
<string name="agreement_check_peertube">I am at least 16 years old and agree to the %1$s of this instance</string>
|
||||||
|
<string name="colors">Colors</string>
|
||||||
|
<string name="link_color_title">Links</string>
|
||||||
|
<string name="link_color">Change the color of links (URLs, mentions, tags, etc.) in messages</string>
|
||||||
|
<string name="boost_header_color_title">Reblogs header</string>
|
||||||
|
<string name="boost_header_color">Change the color of the header for reblogs</string>
|
||||||
</resources>
|
</resources>
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<com.jaredrummler.android.colorpicker.ColorPreferenceCompat
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
android:defaultValue="?colorAccent"
|
||||||
|
android:key="theme_link_color"
|
||||||
|
android:summary="@string/link_color"
|
||||||
|
android:title="@string/link_color_title"/>
|
||||||
|
|
||||||
|
<com.jaredrummler.android.colorpicker.ColorPreferenceCompat
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
android:defaultValue="?boostcolor"
|
||||||
|
android:key="theme_boost_header_color"
|
||||||
|
android:title="@string/boost_header_color_title"
|
||||||
|
android:summary="@string/boost_header_color"/>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
Loading…
Reference in New Issue