Some other changes

This commit is contained in:
tom79 2019-11-07 19:07:19 +01:00
parent d687d0682c
commit ac026bc869
14 changed files with 135 additions and 103 deletions

View File

@ -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'
}

View File

@ -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

View File

@ -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);
}
}
});

View File

@ -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);

View File

@ -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);

View File

@ -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<Locale> SUPPORTED_LOCALES = new ArrayList<>();

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;
}
}

View File

@ -55,7 +55,6 @@
android:orientation="horizontal">
<TextView
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:visibility="gone"
android:layout_width="0dp"
@ -87,7 +86,6 @@
android:layout_height="wrap_content" />
<ImageView
android:layout_marginLeft="5dp"
android:layout_gravity="center_vertical"
android:visibility="gone"
android:id="@+id/display_timeline"

View File

@ -1,67 +1,71 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<attr name="cardviewColor" type="color"/>
<!-- Light theme -->
<style name="AppTheme" parent="Theme.Cyanea.Dark.LightActionBar">
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="cardviewColor">@color/white</item>
</style>
<style name="AppTheme_NoActionBar_Fedilab" parent="Theme.Cyanea.Light.NoActionBar">
<style name="AppTheme_NoActionBar_Fedilab" parent="Theme.AppCompat.Light.NoActionBar">
<item name="cardviewColor">@color/white</item>
</style>
<style name="Dialog" parent="Cyanea.AlertDialog.Theme.Light">
</style>
<style name="DialogDark" parent="Cyanea.AlertDialog.Theme.Dark">
</style>
<style name="DialogBlack" parent="Cyanea.AlertDialog.Theme.Dark">
</style>
<style name="TransparentLight" parent="Theme.Cyanea.Light">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
</style>
<style name="TransparentDark" parent="Theme.Cyanea.Dark">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
</style>
<style name="TransparentBlack" parent="Theme.Cyanea.Dark">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
</style>
<!-- BLACK theme -->
<style name="AppThemeBlack" parent="Theme.Cyanea.Dark">
<style name="AppThemeBlack" parent="Theme.AppCompat">
<item name="cardviewColor">@color/black</item>
</style>
<style name="AppThemeBlack_NoActionBar" parent="Theme.Cyanea.Dark.NoActionBar">
<style name="AppThemeBlack_NoActionBar" parent="Theme.AppCompat.NoActionBar">
<item name="cardviewColor">@color/black</item>
</style>
<!-- Dark theme -->
<style name="AppThemeDark" parent="Theme.Cyanea.Dark">
<style name="AppThemeDark" parent="Theme.AppCompat">
<item name="cardviewColor">@color/mastodonC1</item>
</style>
<style name="AppThemeDark_NoActionBar" parent="Theme.Cyanea.Dark.NoActionBar">
<style name="AppThemeDark_NoActionBar" parent="Theme.AppCompat.NoActionBar">
<item name="cardviewColor">@color/mastodonC1</item>
</style>
<style name="Dialog" parent="Theme.AppCompat.Light.Dialog.Alert">
</style>
<style name="DialogDark" parent="Theme.AppCompat.Dialog.Alert">
</style>
<style name="DialogBlack" parent="Theme.AppCompat.Dialog.Alert">
</style>
<style name="TransparentLight" parent="Theme.AppCompat.Light">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
</style>
<style name="TransparentDark" parent="Theme.AppCompat">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
</style>
<style name="TransparentBlack" parent="Theme.AppCompat">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
</style>
<!-- Light theme -->
<style name="AppAdminTheme" parent="Theme.Cyanea.Dark">
<style name="AppAdminTheme" parent="Theme.AppCompat">
</style>