Remove Android resource references from K9

This commit is contained in:
cketti 2018-07-06 16:41:36 +02:00
parent de2b99a066
commit 548f908d7c
5 changed files with 15 additions and 13 deletions

View file

@ -14,7 +14,6 @@ import android.os.Environment;
import com.fsck.k9.Account.SortType;
import com.fsck.k9.core.BuildConfig;
import com.fsck.k9.core.R;
import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mailstore.LocalStore;
import com.fsck.k9.preferences.Storage;
@ -548,14 +547,6 @@ public class K9 {
USE_GLOBAL
}
public static int getK9ThemeResourceId(Theme themeId) {
return (themeId == Theme.LIGHT) ? R.style.Theme_K9_Light : R.style.Theme_K9_Dark;
}
public static int getK9ThemeResourceId() {
return getK9ThemeResourceId(theme);
}
public static Theme getK9MessageViewTheme() {
return messageViewTheme == Theme.USE_GLOBAL ? theme : messageViewTheme;
}

View file

@ -12,8 +12,10 @@ import android.view.GestureDetector;
import android.view.MotionEvent;
import com.fsck.k9.K9;
import com.fsck.k9.K9.Theme;
import com.fsck.k9.activity.misc.SwipeGestureDetector;
import com.fsck.k9.activity.misc.SwipeGestureDetector.OnSwipeGestureListener;
import com.fsck.k9.ui.R;
/**
@ -72,7 +74,7 @@ public class K9ActivityCommon {
private K9ActivityCommon(Activity activity) {
mActivity = activity;
setLanguage(mActivity, K9.getK9Language());
mActivity.setTheme(K9.getK9ThemeResourceId());
mActivity.setTheme(getK9ThemeResourceId());
}
/**
@ -111,4 +113,12 @@ public class K9ActivityCommon {
mGestureDetector = new GestureDetector(mActivity,
new SwipeGestureDetector(mActivity, listener));
}
public static int getK9ThemeResourceId(Theme themeId) {
return (themeId == Theme.LIGHT) ? R.style.Theme_K9_Light : R.style.Theme_K9_Dark;
}
public static int getK9ThemeResourceId() {
return getK9ThemeResourceId(K9.getK9Theme());
}
}

View file

@ -20,7 +20,7 @@ public abstract class K9PreferenceActivity extends PreferenceActivity implements
@Override
public void onCreate(Bundle icicle) {
K9ActivityCommon.setLanguage(this, K9.getK9Language());
setTheme(K9.getK9ThemeResourceId());
setTheme(K9ActivityCommon.getK9ThemeResourceId());
super.onCreate(icicle);
lifecycleRegistry = new LifecycleRegistry(this);
lifecycleRegistry.markState(State.CREATED);

View file

@ -233,7 +233,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
if (K9.getK9ComposerThemeSetting() != K9.Theme.USE_GLOBAL) {
// theme the whole content according to the theme (except the action bar)
ContextThemeWrapper themeContext = new ContextThemeWrapper(this,
K9.getK9ThemeResourceId(K9.getK9ComposerTheme()));
K9ActivityCommon.getK9ThemeResourceId(K9.getK9ComposerTheme()));
@SuppressLint("InflateParams") // this is the top level activity element, it has no root
View v = LayoutInflater.from(themeContext).inflate(R.layout.message_compose, null);
TypedValue outValue = new TypedValue();

View file

@ -31,6 +31,7 @@ import android.widget.Toast;
import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.Preferences;
import com.fsck.k9.activity.K9ActivityCommon;
import com.fsck.k9.ui.R;
import com.fsck.k9.activity.ChooseFolder;
import com.fsck.k9.activity.MessageLoaderHelper;
@ -163,7 +164,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Context context = new ContextThemeWrapper(inflater.getContext(),
K9.getK9ThemeResourceId(K9.getK9MessageViewTheme()));
K9ActivityCommon.getK9ThemeResourceId(K9.getK9MessageViewTheme()));
LayoutInflater layoutInflater = LayoutInflater.from(context);
View view = layoutInflater.inflate(R.layout.message, container, false);