mirror of https://github.com/M66B/FairEmail.git
Run tasks in themed context
This commit is contained in:
parent
130fdfcbae
commit
cc088cbc85
|
@ -335,16 +335,16 @@ public class FragmentDialogTheme extends FragmentDialogBase {
|
|||
.create();
|
||||
}
|
||||
|
||||
static int getTheme(ActivityBase activity) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
static int getTheme(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String theme = prefs.getString("theme", "blue_orange_system");
|
||||
boolean composer_light = prefs.getBoolean("composer_light", false);
|
||||
|
||||
boolean night = Helper.isNight(activity);
|
||||
boolean light = (composer_light && activity instanceof ActivityCompose);
|
||||
boolean night = Helper.isNight(context);
|
||||
boolean light = (composer_light && context instanceof ActivityCompose);
|
||||
if (light)
|
||||
night = false;
|
||||
EntityLog.log(activity, "Activity theme=" + theme +
|
||||
EntityLog.log(context, "Activity theme=" + theme +
|
||||
"light = " + light + " night=" + night);
|
||||
|
||||
switch (theme) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.view.ContextThemeWrapper;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
@ -154,6 +155,10 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
|||
}
|
||||
};
|
||||
|
||||
Context themedContext = new ContextThemeWrapper(
|
||||
context.getApplicationContext(),
|
||||
FragmentDialogTheme.getTheme(context));
|
||||
|
||||
future = getExecutor(context).submit(new Runnable() {
|
||||
private Object data;
|
||||
private long elapsed;
|
||||
|
@ -168,7 +173,7 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
|||
if (log)
|
||||
Log.i("Executing task=" + name);
|
||||
long start = new Date().getTime();
|
||||
data = onExecute(context.getApplicationContext(), args);
|
||||
data = onExecute(themedContext, args);
|
||||
elapsed = new Date().getTime() - start;
|
||||
if (log)
|
||||
Log.i("Executed task=" + name + " elapsed=" + elapsed + " ms");
|
||||
|
|
Loading…
Reference in New Issue