Allow to change colors
This commit is contained in:
parent
479d6dcf9b
commit
c956d44a3b
|
@ -34,6 +34,7 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
|||
import androidx.core.content.ContextCompat;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
|
@ -215,6 +216,8 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
boolean confirmBoost = sharedpreferences.getBoolean(Helper.SET_NOTIF_VALIDATION, true);
|
||||
boolean hide_notification_delete = sharedpreferences.getBoolean(Helper.SET_HIDE_DELETE_BUTTON_ON_TAB, false);
|
||||
|
||||
|
||||
|
||||
if (theme == Helper.THEME_DARK) {
|
||||
holder.main_container_trans.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_1));
|
||||
holder.main_container_trans.setAlpha(.5f);
|
||||
|
@ -233,6 +236,12 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
style = R.style.Dialog;
|
||||
}
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
int reblogColor = prefs.getInt("theme_statuses_color", -1);
|
||||
if( holder.main_linear_container != null && reblogColor != -1 ){
|
||||
holder.main_linear_container.setBackgroundColor(reblogColor);
|
||||
}
|
||||
|
||||
if (hide_notification_delete)
|
||||
holder.notification_delete.setVisibility(View.GONE);
|
||||
Drawable imgH = null;
|
||||
|
@ -1492,7 +1501,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
RadioGroup radio_group;
|
||||
TextView number_votes, remaining_time;
|
||||
Button submit_vote, refresh_poll;
|
||||
|
||||
LinearLayout main_linear_container;
|
||||
public View getView() {
|
||||
return itemView;
|
||||
}
|
||||
|
@ -1546,6 +1555,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
remaining_time = itemView.findViewById(R.id.remaining_time);
|
||||
submit_vote = itemView.findViewById(R.id.submit_vote);
|
||||
refresh_poll = itemView.findViewById(R.id.refresh_poll);
|
||||
main_linear_container = itemView.findViewById(R.id.main_linear_container);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ import android.os.Handler;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.appcompat.widget.TooltipCompat;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
@ -709,7 +710,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
Button quick_reply_button;
|
||||
ImageView quick_reply_privacy;
|
||||
View status_reply_indicator_top, reply_indicator_dot, status_reply_indicator_bottom, status_reply_indicator_diag_top, status_reply_indicator_diag_bottom;
|
||||
|
||||
CardView main_card_container;
|
||||
LinearLayout main_linear_container;
|
||||
public View getView() {
|
||||
return itemView;
|
||||
}
|
||||
|
@ -844,6 +846,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
status_reply_indicator_diag_bottom.setBackgroundResource(R.drawable.diag_bottom);
|
||||
}
|
||||
}
|
||||
main_card_container = itemView.findViewById(R.id.main_card_container);
|
||||
main_linear_container = itemView.findViewById(R.id.main_linear_container);
|
||||
}
|
||||
|
||||
void updateAnimatedEmoji() {
|
||||
|
@ -2110,9 +2114,16 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
int reblogColor = prefs.getInt("theme_boost_header_color", -1);
|
||||
if( reblogColor != -1 ){
|
||||
if( holder.status_boosted_by_info != null && reblogColor != -1 ){
|
||||
holder.status_boosted_by_info.setBackgroundColor(reblogColor);
|
||||
}
|
||||
int statusColor = prefs.getInt("theme_statuses_color", -1);
|
||||
if( holder.main_card_container != null && statusColor != -1 ){
|
||||
holder.main_card_container.setBackgroundColor(statusColor);
|
||||
}
|
||||
if( holder.main_linear_container != null && statusColor != -1 ){
|
||||
holder.main_linear_container.setBackgroundColor(statusColor);
|
||||
}
|
||||
if (type == RetrieveFeedsAsyncTask.Type.CONVERSATION && status.getConversationProfilePicture() != null) {
|
||||
holder.status_account_profile.setVisibility(View.GONE);
|
||||
holder.conversation_pp.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -1,30 +1,69 @@
|
|||
package app.fedilab.android.fragments;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
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.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
|
||||
|
||||
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);
|
||||
|
||||
Preference button = findPreference("reset_pref");
|
||||
FragmentActivity context = getActivity();
|
||||
int style;
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
if (theme == Helper.THEME_DARK) {
|
||||
style = R.style.DialogDark;
|
||||
} else if (theme == Helper.THEME_BLACK) {
|
||||
style = R.style.DialogBlack;
|
||||
} else {
|
||||
style = R.style.Dialog;
|
||||
}
|
||||
|
||||
|
||||
PreferenceFragmentCompat preferenceFragmentCompat = this;
|
||||
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context, style);
|
||||
dialogBuilder.setMessage(R.string.reset_color);
|
||||
dialogBuilder.setPositiveButton(R.string.reset, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.remove("theme_boost_header_color");
|
||||
editor.remove("theme_statuses_color");
|
||||
editor.remove("theme_link_color");
|
||||
editor.commit();
|
||||
dialog.dismiss();
|
||||
setPreferenceScreen(null);
|
||||
addPreferencesFromResource(R.xml.fragment_settings_color);
|
||||
|
||||
}
|
||||
});
|
||||
dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = dialogBuilder.create();
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@
|
|||
android:id="@+id/card_status_container">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/main_linear_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dp"
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
style="?attr/cardStyle"
|
||||
android:id="@+id/main_card_container"
|
||||
app:layout_constraintStart_toEndOf="@id/reply_indicator_dot"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:id="@+id/main_card_container"
|
||||
style="?attr/cardStyleOver"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/main_card_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dp"
|
||||
|
|
|
@ -84,6 +84,7 @@
|
|||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/main_linear_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Button
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/Base.Widget.AppCompat.Button.Colored"
|
||||
android:id="@+id/resetButton"
|
||||
android:text="@string/reset_color"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
</Button>
|
|
@ -1252,4 +1252,9 @@
|
|||
<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>
|
||||
<string name="background_status_title">Posts</string>
|
||||
<string name="background_status">Bakground color of posts in timelines</string>
|
||||
<string name="reset_color">Reset colors</string>
|
||||
<string name="clik_reset">Click here to reset all your custom colors</string>
|
||||
<string name="reset">Reset</string>
|
||||
</resources>
|
|
@ -13,12 +13,14 @@
|
|||
<attr format="color" name="textColor" />
|
||||
<attr format="color" name="cardBorder" />
|
||||
<attr format="color" name="boostcolor" />
|
||||
<attr format="color" name="backgroundColor" />
|
||||
|
||||
<!-- Light theme -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<item name="android:textColor">@color/light_black</item>
|
||||
<item name="colorPrimary">@color/white</item>
|
||||
<item name="colorPrimaryDark">@color/mastodonC2</item>
|
||||
<item name="backgroundColor">@color/white</item>
|
||||
<item name="colorAccent">@color/mastodonC4</item>
|
||||
<item name="cardStyle">@style/CardViewStyle.Light</item>
|
||||
<item name="cardStyleOver">@style/CardViewStyleOver.Light</item>
|
||||
|
@ -69,6 +71,7 @@
|
|||
<item name="cardStyleOver">@style/CardViewStyleOver.Light</item>
|
||||
<item name="cardBorder">@color/cardBorderLight</item>
|
||||
<item name="boostcolor">@color/mastodonC2</item>
|
||||
<item name="backgroundColor">@color/white</item>
|
||||
<item name="textColor">@color/black</item>
|
||||
<item name="colorPrimaryDark">@color/mastodonC2</item>
|
||||
<item name="colorAccent">@color/mastodonC4</item>
|
||||
|
@ -225,6 +228,7 @@
|
|||
<item name="color_in_account_header">@color/mastodonC3</item>
|
||||
<item name="colorBackgroundFloating">@color/black_3</item>
|
||||
<item name="android:colorBackground">@color/black</item>
|
||||
<item name="backgroundColor">@color/black</item>
|
||||
</style>
|
||||
|
||||
<style name="AppThemeBlack_NoActionBar" parent="Theme.AppCompat.NoActionBar">
|
||||
|
@ -259,6 +263,7 @@
|
|||
<item name="android:actionBarStyle">@style/BlackActionBarTheme</item>
|
||||
<item name="colorBackgroundFloating">@color/black_3</item>
|
||||
<item name="android:colorBackground">@color/black</item>
|
||||
<item name="backgroundColor">@color/black</item>
|
||||
</style>
|
||||
|
||||
<style name="CardViewStyle.Black" parent="CardView">
|
||||
|
@ -354,6 +359,7 @@
|
|||
<item name="color_in_account_header">@color/mastodonC3</item>
|
||||
<item name="colorBackgroundFloating">@color/mastodonC1</item>
|
||||
<item name="android:colorBackground">@color/mastodonC1</item>
|
||||
<item name="backgroundColor">@color/mastodonC1_</item>
|
||||
</style>
|
||||
|
||||
<style name="AppThemeDark_NoActionBar" parent="Theme.AppCompat.NoActionBar">
|
||||
|
@ -387,6 +393,7 @@
|
|||
<item name="color_in_account_header">@color/mastodonC3</item>
|
||||
<item name="colorBackgroundFloating">@color/mastodonC1</item>
|
||||
<item name="android:colorBackground">@color/mastodonC1</item>
|
||||
<item name="backgroundColor">@color/mastodonC1_</item>
|
||||
</style>
|
||||
|
||||
<style name="CardViewStyle.Dark" parent="CardView">
|
||||
|
|
|
@ -15,4 +15,17 @@
|
|||
android:title="@string/boost_header_color_title"
|
||||
android:summary="@string/boost_header_color"/>
|
||||
|
||||
<com.jaredrummler.android.colorpicker.ColorPreferenceCompat
|
||||
app:iconSpaceReserved="false"
|
||||
android:defaultValue="?backgroundColor"
|
||||
android:key="theme_statuses_color"
|
||||
android:title="@string/background_status_title"
|
||||
android:summary="@string/background_status"/>
|
||||
|
||||
|
||||
<Preference android:title="@string/reset_color"
|
||||
app:iconSpaceReserved="false"
|
||||
android:id="@+id/resetButton"
|
||||
android:key="reset_pref"
|
||||
android:summary="@string/clik_reset"/>
|
||||
</PreferenceScreen>
|
Loading…
Reference in New Issue