More attempts at fixing day/night

pull/437/head
Alex Baker 8 years ago
parent 12b9059159
commit c9c2dd6d7a

@ -45,6 +45,8 @@ import com.todoroo.astrid.timers.TimerControlSet;
import org.tasks.Broadcaster;
import org.tasks.R;
import org.tasks.analytics.Tracker;
import org.tasks.analytics.Tracking;
import org.tasks.dialogs.SortDialog;
import org.tasks.fragments.CommentBarFragment;
import org.tasks.fragments.TaskEditControlSetFragmentManager;
@ -99,6 +101,7 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
@Inject Broadcaster broadcaster;
@Inject ThemeCache themeCache;
@Inject SyncAdapterHelper syncAdapterHelper;
@Inject Tracker tracker;
@BindView(R.id.drawer_layout) DrawerLayout drawerLayout;
@ -123,8 +126,6 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
theme.applyTheme(this, getDelegate());
currentNightMode = getNightMode();
startupService.onStartupApplication(this);
@ -238,9 +239,9 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
protected void onResume() {
super.onResume();
getDelegate().applyDayNight();
if (currentNightMode != getNightMode()) {
recreate();
tracker.reportEvent(Tracking.Events.NIGHT_MODE_MISMATCH);
restart();
return;
}
@ -271,6 +272,13 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
}
}
public void restart() {
Intent intent = getIntent();
intent.putExtra(TaskListActivity.OPEN_FILTER, getCurrentFilter());
finish();
startActivity(intent);
}
private int getNightMode() {
return getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
}
@ -278,6 +286,7 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
@Override
public void inject(ActivityComponent component) {
component.inject(this);
theme.applyTheme(this);
}
@Override

@ -17,6 +17,7 @@ public class Tracking {
GTASK_DISABLED(R.string.tracking_category_google_tasks, R.string.tracking_action_off),
GTASK_LOGOUT(R.string.tracking_category_google_tasks, R.string.tracking_action_clear),
GTASK_MOVE(R.string.tracking_category_google_tasks, R.string.tracking_action_move),
NIGHT_MODE_MISMATCH(R.string.tracking_category_event, R.string.tracking_event_night_mode_mismatch),
SET_PREFERENCE(R.string.tracking_category_preferences, 0);
public final int category;

@ -1,19 +1,43 @@
package org.tasks.injection;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import org.tasks.analytics.Tracker;
import org.tasks.locale.Locale;
import org.tasks.themes.Theme;
import javax.inject.Inject;
public abstract class ThemedInjectingAppCompatActivity extends InjectingAppCompatActivity {
public abstract class ThemedInjectingAppCompatActivity extends AppCompatActivity implements InjectingActivity {
private ActivityComponent activityComponent;
@Inject Tracker tracker;
@Inject Theme theme;
public ThemedInjectingAppCompatActivity() {
Locale.INSTANCE.applyOverrideConfiguration(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
activityComponent = ((InjectingApplication) getApplication()).getComponent().plus(new ActivityModule(this));
inject(activityComponent);
setTitle(null);
theme.applyTheme(this);
theme.applyStatusBarColor(this);
super.onCreate(savedInstanceState);
}
@Override
protected void onResume() {
super.onResume();
tracker.showScreen(getClass().getSimpleName());
}
theme.applyThemeAndStatusBarColor(this, getDelegate());
@Override
public ActivityComponent getComponent() {
return activityComponent;
}
}

@ -45,13 +45,17 @@ public class Theme {
}
public void applyThemeAndStatusBarColor(Activity activity, AppCompatDelegate delegate) {
applyTheme(activity, delegate);
delegate.applyDayNight();
applyTheme(activity);
applyStatusBarColor(activity);
}
public void applyStatusBarColor(Activity activity) {
themeColor.applyStatusBarColor(activity);
themeColor.applyTaskDescription(activity, activity.getString(R.string.app_name));
}
public void applyTheme(Activity activity, AppCompatDelegate delegate) {
delegate.applyDayNight();
public void applyTheme(Activity activity) {
themeBase.set(activity);
applyToContext(activity);
activity.getWindow().setFormat(PixelFormat.RGBA_8888);

@ -93,10 +93,7 @@ public class NavigationDrawerFragment extends InjectingFragment {
}
if (data.getBooleanExtra(AppearancePreferences.EXTRA_RESTART, false)) {
TaskListActivity activity = (TaskListActivity) getActivity();
Intent intent = activity.getIntent();
intent.putExtra(TaskListActivity.OPEN_FILTER, activity.getCurrentFilter());
activity.finish();
activity.startActivity(intent);
activity.restart();
}
} else if ((requestCode == NavigationDrawerFragment.REQUEST_NEW_LIST ||
requestCode == TaskListFragment.ACTIVITY_REQUEST_NEW_FILTER) &&

@ -286,12 +286,14 @@
<string name="tracking_category_tags">Tags</string>
<string name="tracking_category_iab">IAB</string>
<string name="tracking_category_google_tasks">Gtask</string>
<string name="tracking_category_event">Event</string>
<string name="tracking_action_add">Add</string>
<string name="tracking_action_start">Start</string>
<string name="tracking_action_move">Move</string>
<string name="tracking_action_on">On</string>
<string name="tracking_action_off">Off</string>
<string name="tracking_action_clear">Clear</string>
<string name="tracking_event_night_mode_mismatch">Night Mismatch</string>
<string name="p_tesla_unread_enabled">tesla_unread_enabled</string>
<string name="p_purchased_tesla_unread">purchased_tesla_unread</string>
<string name="p_purchased_tasker">purchased_tasker</string>

Loading…
Cancel
Save