diff --git a/app/build.gradle b/app/build.gradle index 3a4a35aca..6c95138e1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -124,5 +124,6 @@ dependencies { implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0' implementation 'com.github.smarteist:autoimageslider:1.3.2' //debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-2' - implementation 'com.jaredrummler:cyanea:1.0.2' + implementation 'com.jaredrummler:colorpicker:1.1.0' + implementation 'com.afollestad:aesthetic:1.0.0-beta05' } diff --git a/app/src/main/java/app/fedilab/android/activities/BaseActivity.java b/app/src/main/java/app/fedilab/android/activities/BaseActivity.java index fe1328874..e712e95d3 100644 --- a/app/src/main/java/app/fedilab/android/activities/BaseActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/BaseActivity.java @@ -8,6 +8,8 @@ import android.content.res.Configuration; import androidx.annotation.NonNull; +import com.afollestad.aesthetic.Aesthetic; +import com.afollestad.aesthetic.AestheticActivity; import com.google.android.material.snackbar.Snackbar; import androidx.core.app.ActivityCompat; @@ -19,13 +21,13 @@ import android.view.View; import android.widget.Toast; import com.franmontiel.localechanger.LocaleChanger; -import com.jaredrummler.cyanea.app.CyaneaAppCompatActivity; import com.vanniktech.emoji.EmojiManager; import com.vanniktech.emoji.one.EmojiOneProvider; import java.util.Timer; import app.fedilab.android.helper.Helper; +import app.fedilab.android.helper.ThemeHelper; import es.dmoral.toasty.Toasty; /** @@ -34,7 +36,7 @@ import es.dmoral.toasty.Toasty; */ @SuppressLint("Registered") -public class BaseActivity extends CyaneaAppCompatActivity { +public class BaseActivity extends AestheticActivity { public static final int READ_WRITE_STORAGE = 52; @@ -67,7 +69,6 @@ public class BaseActivity extends CyaneaAppCompatActivity { .build()); }*/ super.onCreate(savedInstanceState); - } @Override diff --git a/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java index b32a4b359..3c9a57fe0 100644 --- a/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java @@ -116,6 +116,7 @@ import app.fedilab.android.fragments.WhoToFollowFragment; import app.fedilab.android.helper.CrossActions; import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.MenuFloating; +import app.fedilab.android.helper.ThemeHelper; import app.fedilab.android.services.BackupStatusService; import app.fedilab.android.services.LiveNotificationDelayedService; import app.fedilab.android.services.LiveNotificationService; @@ -284,19 +285,15 @@ public abstract class BaseMainActivity extends BaseActivity return; } final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); + int themeSwitcher; switch (theme) { case Helper.THEME_LIGHT: - setTheme(R.style.AppTheme_NoActionBar_Fedilab); - break; - case Helper.THEME_DARK: - setTheme(R.style.AppThemeDark_NoActionBar); - break; - case Helper.THEME_BLACK: - setTheme(R.style.AppThemeBlack_NoActionBar); + themeSwitcher = R.style.AppTheme_NoActionBar_Fedilab; break; default: - setTheme(R.style.AppThemeDark_NoActionBar); + themeSwitcher = R.style.AppThemeDark_NoActionBar; } + ThemeHelper.changeTheme(BaseMainActivity.this, themeSwitcher); setContentView(R.layout.activity_main); //Test if user is still log in @@ -485,6 +482,10 @@ public abstract class BaseMainActivity extends BaseActivity tootShow(); DrawerLayout drawer = findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); + + if( tab.getIcon() != null) { + tab.getIcon().setColorFilter(R.attr.colorAccent, PorterDuff.Mode.SRC_IN); + } } @Override @@ -501,6 +502,9 @@ public abstract class BaseMainActivity extends BaseActivity displayStatusFragment.scrollToTop(); } } + if( tab.getIcon() != null) { + tab.getIcon().setColorFilter(R.attr.colorAccent, PorterDuff.Mode.SRC_IN); + } } }); @@ -2095,6 +2099,9 @@ public abstract class BaseMainActivity extends BaseActivity } DrawerLayout drawer = findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); + if( tab.getIcon() != null) { + tab.getIcon().setColorFilter(R.attr.colorAccent, PorterDuff.Mode.SRC_IN); + } } @Override @@ -2145,6 +2152,11 @@ public abstract class BaseMainActivity extends BaseActivity displayStatusFragment.scrollToTop(); } } + DrawerLayout drawer = findViewById(R.id.drawer_layout); + drawer.closeDrawer(GravityCompat.START); + if( tab.getIcon() != null) { + tab.getIcon().setColorFilter(R.attr.colorAccent, PorterDuff.Mode.SRC_IN); + } } }); diff --git a/app/src/main/java/app/fedilab/android/activities/InstanceHealthActivity.java b/app/src/main/java/app/fedilab/android/activities/InstanceHealthActivity.java index 9d3191649..6bc559abb 100644 --- a/app/src/main/java/app/fedilab/android/activities/InstanceHealthActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/InstanceHealthActivity.java @@ -81,9 +81,9 @@ public class InstanceHealthActivity extends BaseActivity { SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); if (theme == Helper.THEME_LIGHT) { - setTheme(R.style.Cyanea_AlertDialog_Theme_Light); + setTheme(R.style.Dialog); } else { - setTheme(R.style.Cyanea_AlertDialog_Theme_Dark); + setTheme(R.style.DialogDark); } setContentView(R.layout.activity_instance_social); getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); diff --git a/app/src/main/java/app/fedilab/android/activities/LiveNotificationSettingsAccountsActivity.java b/app/src/main/java/app/fedilab/android/activities/LiveNotificationSettingsAccountsActivity.java index c52721098..4d2baead0 100644 --- a/app/src/main/java/app/fedilab/android/activities/LiveNotificationSettingsAccountsActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/LiveNotificationSettingsAccountsActivity.java @@ -52,9 +52,9 @@ public class LiveNotificationSettingsAccountsActivity extends BaseActivity { SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); if (theme == Helper.THEME_LIGHT) { - setTheme(R.style.Cyanea_AlertDialog_Theme_Light); + setTheme(R.style.Dialog); } else { - setTheme(R.style.Cyanea_AlertDialog_Theme_Dark); + setTheme(R.style.DialogDark); } setContentView(R.layout.activity_livenotifications_all_accounts); getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); diff --git a/app/src/main/java/app/fedilab/android/activities/MainApplication.java b/app/src/main/java/app/fedilab/android/activities/MainApplication.java index 3d40fed30..b815577f7 100644 --- a/app/src/main/java/app/fedilab/android/activities/MainApplication.java +++ b/app/src/main/java/app/fedilab/android/activities/MainApplication.java @@ -22,12 +22,9 @@ import android.os.StrictMode; import androidx.multidex.MultiDex; import androidx.multidex.MultiDexApplication; -import androidx.core.content.ContextCompat; import com.evernote.android.job.JobManager; import com.franmontiel.localechanger.LocaleChanger; -import com.jaredrummler.cyanea.Cyanea; -import com.jaredrummler.cyanea.CyaneaApp; import net.gotev.uploadservice.UploadService; @@ -84,13 +81,11 @@ public class MainApplication extends MultiDexApplication { ApplicationJob.cancelAllJob(BackupNotificationsSyncJob.BACKUP_NOTIFICATIONS_SYNC); BackupNotificationsSyncJob.schedule(false); - Cyanea.init(this, super.getResources()); + StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.setVmPolicy(builder.build()); - - try { List SUPPORTED_LOCALES = new ArrayList<>(); diff --git a/app/src/main/java/app/fedilab/android/activities/ManageAccountsInListActivity.java b/app/src/main/java/app/fedilab/android/activities/ManageAccountsInListActivity.java index 76e0c30b4..6824c94a3 100644 --- a/app/src/main/java/app/fedilab/android/activities/ManageAccountsInListActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/ManageAccountsInListActivity.java @@ -69,9 +69,9 @@ public class ManageAccountsInListActivity extends BaseActivity implements OnList SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); if (theme == Helper.THEME_LIGHT) { - setTheme(R.style.Cyanea_AlertDialog_Theme_Light); + setTheme(R.style.Dialog); } else { - setTheme(R.style.Cyanea_AlertDialog_Theme_Dark); + setTheme(R.style.DialogDark); } setContentView(R.layout.activity_manage_accounts_list); getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); diff --git a/app/src/main/java/app/fedilab/android/activities/ProxyActivity.java b/app/src/main/java/app/fedilab/android/activities/ProxyActivity.java index 8f8e75b23..2e7faab59 100644 --- a/app/src/main/java/app/fedilab/android/activities/ProxyActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/ProxyActivity.java @@ -51,9 +51,9 @@ public class ProxyActivity extends BaseActivity { SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); if (theme == Helper.THEME_LIGHT) { - setTheme(R.style.Cyanea_AlertDialog_Theme_Light); + setTheme(R.style.Dialog); } else { - setTheme(R.style.Cyanea_AlertDialog_Theme_Dark); + setTheme(R.style.DialogDark); } setContentView(R.layout.activity_proxy); getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); diff --git a/app/src/main/java/app/fedilab/android/activities/TagCacheActivity.java b/app/src/main/java/app/fedilab/android/activities/TagCacheActivity.java index 330877472..0099a00a2 100644 --- a/app/src/main/java/app/fedilab/android/activities/TagCacheActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/TagCacheActivity.java @@ -59,9 +59,9 @@ public class TagCacheActivity extends BaseActivity { SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); if (theme == Helper.THEME_LIGHT) { - setTheme(R.style.Cyanea_AlertDialog_Theme_Light); + setTheme(R.style.Dialog); } else { - setTheme(R.style.Cyanea_AlertDialog_Theme_Dark); + setTheme(R.style.DialogDark); } getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); diff --git a/app/src/main/java/app/fedilab/android/activities/TootInfoActivity.java b/app/src/main/java/app/fedilab/android/activities/TootInfoActivity.java index dd27089ee..30b6e19e6 100644 --- a/app/src/main/java/app/fedilab/android/activities/TootInfoActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/TootInfoActivity.java @@ -58,9 +58,9 @@ public class TootInfoActivity extends BaseActivity { SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); if (theme == Helper.THEME_LIGHT) { - setTheme(R.style.Cyanea_AlertDialog_Theme_Light); + setTheme(R.style.Dialog); } else { - setTheme(R.style.Cyanea_AlertDialog_Theme_Dark); + setTheme(R.style.DialogDark); } setContentView(R.layout.activity_toot_info); getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT); diff --git a/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java b/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java index 13442eeb3..9c5a7daca 100644 --- a/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java +++ b/app/src/main/java/app/fedilab/android/drawers/StatusListAdapter.java @@ -141,6 +141,7 @@ import app.fedilab.android.helper.CrossActions; import app.fedilab.android.helper.CustomTextView; import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.MastalabAutoCompleteTextView; +import app.fedilab.android.helper.ThemeHelper; import app.fedilab.android.interfaces.OnPostStatusActionInterface; import app.fedilab.android.interfaces.OnRetrieveImageInterface; import app.fedilab.android.interfaces.OnRetrieveRelationshipQuickReplyInterface; @@ -1180,11 +1181,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct AlertDialog.Builder builderInner; int style; if (theme == Helper.THEME_DARK) { - style = R.style.Cyanea_AlertDialog_Theme_Dark; + style = R.style.DialogDark; } else if (theme == Helper.THEME_BLACK) { - style = R.style.Cyanea_AlertDialog_Theme_Dark; + style = R.style.DialogDark; } else { - style = R.style.Cyanea_AlertDialog_Theme_Light; + style = R.style.Dialog; } builderInner = new AlertDialog.Builder(context, style); builderInner.setTitle(R.string.comment); @@ -2074,10 +2075,9 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct 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.setCardBackgroundColor(statusColor); - } + int statusColor = prefs.getInt("theme_statuses_color", ThemeHelper.getAttColor(context, R.attr.cardviewColor)); + holder.main_card_container.setCardBackgroundColor(ThemeHelper.getAttColor(context, R.attr.cardviewColor)); + if( holder.main_linear_container != null && statusColor != -1 ){ holder.main_linear_container.setBackgroundColor(statusColor); } @@ -2528,11 +2528,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct int style; if (theme == Helper.THEME_DARK) { - style = R.style.Cyanea_AlertDialog_Theme_Dark; + style = R.style.DialogDark; } else if (theme == Helper.THEME_BLACK) { - style = R.style.Cyanea_AlertDialog_Theme_Dark; + style = R.style.DialogDark; } else { - style = R.style.Cyanea_AlertDialog_Theme_Light; + style = R.style.Dialog; } AlertDialog.Builder dialog = new AlertDialog.Builder(context, style); dialog.setTitle(R.string.toot_visibility_tilte); @@ -2950,11 +2950,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct }); int style; if (theme == Helper.THEME_DARK) { - style = R.style.Cyanea_AlertDialog_Theme_Dark; + style = R.style.DialogDark; } else if (theme == Helper.THEME_BLACK) { - style = R.style.Cyanea_AlertDialog_Theme_Dark; + style = R.style.DialogDark; } else { - style = R.style.Cyanea_AlertDialog_Theme_Light; + style = R.style.Dialog; } holder.status_remove.setOnClickListener(new View.OnClickListener() { @Override @@ -4012,11 +4012,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); int style; if (theme == Helper.THEME_DARK) { - style = R.style.Cyanea_AlertDialog_Theme_Dark; + style = R.style.DialogDark; } else if (theme == Helper.THEME_BLACK) { - style = R.style.Cyanea_AlertDialog_Theme_Dark; + style = R.style.DialogDark; } else { - style = R.style.Cyanea_AlertDialog_Theme_Light; + style = R.style.Dialog; } AlertDialog.Builder dialogBuilderBoost = new AlertDialog.Builder(context, style); @@ -4173,11 +4173,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct stepSpliToot = 1; int style; if (theme == Helper.THEME_DARK) { - style = R.style.Cyanea_AlertDialog_Theme_Dark; + style = R.style.DialogDark; } else if (theme == Helper.THEME_BLACK) { - style = R.style.Cyanea_AlertDialog_Theme_Dark; + style = R.style.DialogDark; } else { - style = R.style.Cyanea_AlertDialog_Theme_Light; + style = R.style.Dialog; } AlertDialog.Builder builderInner = new AlertDialog.Builder(context, style); builderInner.setTitle(R.string.message_preview); diff --git a/app/src/main/java/app/fedilab/android/helper/ThemeHelper.java b/app/src/main/java/app/fedilab/android/helper/ThemeHelper.java index b8a7209bf..045dc43c4 100644 --- a/app/src/main/java/app/fedilab/android/helper/ThemeHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/ThemeHelper.java @@ -1,25 +1,46 @@ package app.fedilab.android.helper; import android.app.Activity; +import android.content.Context; +import android.content.SharedPreferences; +import android.content.res.Resources; +import android.util.TypedValue; + +import com.afollestad.aesthetic.Aesthetic; -import com.jaredrummler.cyanea.Cyanea; import app.fedilab.android.R; + +import static android.content.Context.MODE_PRIVATE; + public class ThemeHelper { - public static void changeTheme(Activity activity){ + public static void changeTheme(Context context, int theme){ + final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); - Cyanea.Editor editor = Cyanea.getInstance().edit(); - editor.accent(R.color.colorAccent); - editor.background(R.color.black); - editor.backgroundDarkResource(R.color.black); - editor.apply(); + Aesthetic.get() + .activityTheme(theme) + .attribute(R.attr.cardviewColor,null, R.color.mastodonC1, true) + .colorAccent(null, R.color.mastodonC4) + .colorPrimary(null,R.color.mastodonC1) + .colorPrimaryDark(null,R.color.mastodonC1) + .colorNavigationBar(null,R.color.mastodonC1) + .colorStatusBar(null,R.color.mastodonC1) + .toolbarIconColor(null,R.color.white) + .colorWindowBackground(null,R.color.mastodonC1) - if( activity != null){ - activity.recreate(); - } + + + .apply(); + } + + public static int getAttColor(Context context, int attColor){ + TypedValue typedValue = new TypedValue(); + Resources.Theme theme = context.getTheme(); + theme.resolveAttribute(attColor, typedValue, true); + return typedValue.data; } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 67bbff9c7..c6524d267 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -55,7 +55,6 @@ android:orientation="horizontal"> + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + -