Fix EditHabitDialog theme

This commit is contained in:
2019-12-30 13:12:49 -06:00
parent cc05543692
commit 5191290188
3 changed files with 10 additions and 9 deletions

View File

@@ -60,4 +60,11 @@ class AndroidThemeSwitcher
activity.window.navigationBarColor =
ContextCompat.getColor(activity, R.color.black)
}
fun getDialogTheme(): Int {
return when {
isNightMode -> R.style.DarkDialogWithTitle
else -> R.style.DialogWithTitle
}
}
}

View File

@@ -51,5 +51,5 @@ interface HabitsActivityComponent {
val listHabitsScreen: ListHabitsScreen
val listHabitsSelectionMenu: ListHabitsSelectionMenu
val showHabitScreen: ShowHabitScreen
val themeSwitcher: ThemeSwitcher
val themeSwitcher: AndroidThemeSwitcher
}

View File

@@ -41,7 +41,6 @@ import org.isoron.uhabits.core.preferences.*;
import butterknife.*;
import static android.view.View.GONE;
import static org.isoron.uhabits.core.ui.ThemeSwitcher.THEME_LIGHT;
public class EditHabitDialog extends AppCompatDialogFragment
{
@@ -78,13 +77,8 @@ public class EditHabitDialog extends AppCompatDialogFragment
@Override
public int getTheme()
{
HabitsApplicationComponent component =
((HabitsApplication) getContext().getApplicationContext()).getComponent();
if(component.getPreferences().getTheme() == THEME_LIGHT)
return R.style.DialogWithTitle;
else
return R.style.DarkDialogWithTitle;
HabitsActivity activity = (HabitsActivity) getActivity();
return activity.getComponent().getThemeSwitcher().getDialogTheme();
}
@Override