Use support fragments

pull/437/head
Alex Baker 8 years ago
parent df501ff335
commit ff40202128

@ -124,7 +124,6 @@ dependencies {
compile 'com.android.support:multidex:1.0.1'
compile 'com.nononsenseapps:filepicker:2.5.2'
compile "com.android.support:design:${SUPPORT_VERSION}"
compile "com.android.support:support-v13:${SUPPORT_VERSION}"
compile 'com.jakewharton.timber:timber:4.1.2'
compile 'com.google.guava:guava:19.0'
compile 'com.jakewharton:process-phoenix:1.0.2'

@ -5,7 +5,6 @@
*/
package com.todoroo.astrid.gtasks;
import android.app.FragmentManager;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
@ -17,7 +16,7 @@ import com.todoroo.astrid.gtasks.auth.GtasksLoginActivity;
import org.tasks.R;
import org.tasks.activities.ClearGtaskDataActivity;
import org.tasks.activities.GoogleTaskListSelectionDialog;
import org.tasks.activities.NativeGoogleTaskListPicker;
import org.tasks.analytics.Tracker;
import org.tasks.analytics.Tracking;
import org.tasks.gtasks.GoogleTaskListSelectionHandler;
@ -88,12 +87,8 @@ public class GtasksPreferences extends InjectingPreferenceActivity implements Go
getPref(R.string.p_gtasks_default_list).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
FragmentManager fragmentManager = getFragmentManager();
GoogleTaskListSelectionDialog dialog = (GoogleTaskListSelectionDialog) fragmentManager.findFragmentByTag(FRAG_TAG_GOOGLE_TASK_LIST_SELECTION);
if (dialog == null) {
dialog = new GoogleTaskListSelectionDialog();
dialog.show(fragmentManager, FRAG_TAG_GOOGLE_TASK_LIST_SELECTION);
}
new NativeGoogleTaskListPicker()
.show(getFragmentManager(), FRAG_TAG_GOOGLE_TASK_LIST_SELECTION);
return false;
}
});

@ -5,7 +5,7 @@
*/
package com.todoroo.astrid.gtasks.auth;
import android.app.FragmentManager;
import android.support.v4.app.FragmentManager;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
@ -53,7 +53,7 @@ public class GtasksLoginActivity extends InjectingAppCompatActivity implements A
Toast.makeText(this, R.string.gtasks_GLA_noaccounts, Toast.LENGTH_LONG).show();
finish();
} else {
FragmentManager fragmentManager = getFragmentManager();
FragmentManager fragmentManager = getSupportFragmentManager();
AccountSelectionDialog fragmentByTag = (AccountSelectionDialog) fragmentManager.findFragmentByTag(FRAG_TAG_ACCOUNT_SELECTION_DIALOG);
if (fragmentByTag == null) {
fragmentByTag = new AccountSelectionDialog();

@ -0,0 +1,47 @@
package org.tasks.activities;
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import com.todoroo.astrid.gtasks.GtasksList;
import com.todoroo.astrid.gtasks.GtasksListService;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.gtasks.GoogleTaskListSelectionHandler;
import org.tasks.injection.InjectingNativeDialogFragment;
import org.tasks.injection.NativeDialogFragmentComponent;
import javax.inject.Inject;
import static org.tasks.activities.SupportGoogleTaskListPicker.createDialog;
public class NativeGoogleTaskListPicker extends InjectingNativeDialogFragment {
@Inject DialogBuilder dialogBuilder;
@Inject GtasksListService gtasksListService;
private GoogleTaskListSelectionHandler handler;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return createDialog(dialogBuilder, gtasksListService, new GoogleTaskListSelectionHandler() {
@Override
public void selectedList(GtasksList list) {
handler.selectedList(list);
}
});
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
handler = (GoogleTaskListSelectionHandler) activity;
}
@Override
protected void inject(NativeDialogFragmentComponent component) {
component.inject(this);
}
}

@ -4,6 +4,7 @@ import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import com.google.common.base.Function;
import com.todoroo.astrid.gtasks.GtasksList;
@ -20,7 +21,7 @@ import javax.inject.Inject;
import static com.google.common.collect.Lists.transform;
public class GoogleTaskListSelectionDialog extends InjectingDialogFragment {
public class SupportGoogleTaskListPicker extends InjectingDialogFragment {
@Inject DialogBuilder dialogBuilder;
@Inject GtasksListService gtasksListService;
@ -29,6 +30,22 @@ public class GoogleTaskListSelectionDialog extends InjectingDialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return createDialog(dialogBuilder, gtasksListService, new GoogleTaskListSelectionHandler() {
@Override
public void selectedList(GtasksList list) {
handler.selectedList(list);
}
});
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
handler = (GoogleTaskListSelectionHandler) activity;
}
public static AlertDialog createDialog(DialogBuilder dialogBuilder, GtasksListService gtasksListService, final GoogleTaskListSelectionHandler handler) {
final List<GtasksList> lists = gtasksListService.getLists();
List<String> listNames = transform(lists, new Function<GtasksList, String>() {
@Override
@ -53,13 +70,6 @@ public class GoogleTaskListSelectionDialog extends InjectingDialogFragment {
.show();
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
handler = (GoogleTaskListSelectionHandler) activity;
}
@Override
protected void inject(DialogFragmentComponent component) {
component.inject(this);

@ -1,12 +1,12 @@
package org.tasks.injection;
import org.tasks.activities.GoogleTaskListSelectionDialog;
import org.tasks.activities.SupportGoogleTaskListPicker;
import dagger.Subcomponent;
@Subcomponent(modules = DialogFragmentModule.class)
public interface DialogFragmentComponent extends BaseDialogFragmentComponent {
void inject(GoogleTaskListSelectionDialog googleTaskListSelectionDialog);
void inject(SupportGoogleTaskListPicker supportGoogleTaskListPicker);
}

@ -0,0 +1,10 @@
package org.tasks.injection;
import org.tasks.activities.NativeGoogleTaskListPicker;
import dagger.Subcomponent;
@Subcomponent(modules = NativeDialogFragmentModule.class)
public interface NativeDialogFragmentComponent extends BaseNativeDialogFragmentComponent {
void inject(NativeGoogleTaskListPicker nativeGoogleTaskListPicker);
}

@ -1,6 +1,5 @@
package org.tasks.ui;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
@ -19,7 +18,7 @@ import com.todoroo.astrid.gtasks.GtasksMetadata;
import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import org.tasks.R;
import org.tasks.activities.GoogleTaskListSelectionDialog;
import org.tasks.activities.SupportGoogleTaskListPicker;
import org.tasks.analytics.Tracker;
import org.tasks.analytics.Tracking;
import org.tasks.injection.FragmentComponent;
@ -111,12 +110,8 @@ public class GoogleTaskListFragment extends TaskEditControlFragment {
@OnClick(R.id.google_task_list)
void clickGoogleTaskList(View view) {
FragmentManager fragmentManager = getFragmentManager();
GoogleTaskListSelectionDialog dialog = (GoogleTaskListSelectionDialog) fragmentManager.findFragmentByTag(FRAG_TAG_GOOGLE_TASK_LIST_SELECTION);
if (dialog == null) {
dialog = new GoogleTaskListSelectionDialog();
dialog.show(fragmentManager, FRAG_TAG_GOOGLE_TASK_LIST_SELECTION);
}
new SupportGoogleTaskListPicker()
.show(getChildFragmentManager(), FRAG_TAG_GOOGLE_TASK_LIST_SELECTION);
}
@Override

@ -5,7 +5,6 @@
*/
package com.todoroo.astrid.actfm;
import android.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@ -50,7 +49,7 @@ import butterknife.OnClick;
import timber.log.Timber;
import static android.text.TextUtils.isEmpty;
import static org.tasks.dialogs.ThemePickerDialog.newThemePickerDialog;
import static org.tasks.dialogs.SupportThemePickerDialog.newSupportThemePickerDialog;
public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implements ThemePickerDialog.ThemePickerCallback, PurchaseHelperCallback, Toolbar.OnMenuItemClickListener {
@ -133,11 +132,8 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
@OnClick(R.id.theme_row)
protected void showThemePicker() {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager.findFragmentByTag(FRAG_TAG_COLOR_PICKER) == null) {
newThemePickerDialog(ThemePickerDialog.ColorPalette.COLORS)
.show(fragmentManager, FRAG_TAG_COLOR_PICKER);
}
newSupportThemePickerDialog(ThemePickerDialog.ColorPalette.COLORS)
.show(getSupportFragmentManager(), FRAG_TAG_COLOR_PICKER);
}
@OnClick(R.id.clear)

@ -8,13 +8,10 @@ package com.todoroo.astrid.activity;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.widget.Toolbar;
import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
@ -242,7 +239,7 @@ public final class TaskEditFragment extends InjectingFragment implements Toolbar
@SuppressWarnings("unchecked")
private <T extends TaskEditControlFragment> T getFragment(int tag) {
return (T) getFragmentManager().findFragmentByTag(getString(tag));
return (T) getActivity().getSupportFragmentManager().findFragmentByTag(getString(tag));
}
/*

@ -6,8 +6,7 @@
package com.todoroo.astrid.activity;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.support.v4.app.FragmentManager;
import android.content.ContentValues;
import android.content.Intent;
import android.content.IntentFilter;
@ -15,6 +14,7 @@ import android.content.res.Configuration;
import android.os.Bundle;
import android.provider.Settings;
import android.support.design.widget.Snackbar;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@ -182,7 +182,7 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
loadTaskListFragment(taskListFragment);
if (isDoublePaneLayout()) {
getFragmentManager().beginTransaction()
getSupportFragmentManager().beginTransaction()
.replace(R.id.detail_dual, new EmptyTaskEditFragment())
.commit();
}
@ -201,7 +201,7 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
themeColor.applyStyle(this);
themeColor.applyTaskDescription(this, filter.listingTitle);
FragmentManager fragmentManager = getFragmentManager();
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
fragmentManager.beginTransaction()
.replace(isDoublePaneLayout() ? R.id.master_dual : R.id.single_pane, taskListFragment, TaskListFragment.TAG_TASKLIST_FRAGMENT)
@ -210,7 +210,7 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
}
private void loadTaskEditFragment(boolean onCreate, TaskEditFragment taskEditFragment, List<TaskEditControlFragment> taskEditControlFragments) {
FragmentManager fragmentManager = getFragmentManager();
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction()
.replace(isDoublePaneLayout() ? R.id.detail_dual : R.id.single_pane, taskEditFragment, TaskEditFragment.TAG_TASKEDIT_FRAGMENT)
.addToBackStack(TaskEditFragment.TAG_TASKEDIT_FRAGMENT)
@ -220,7 +220,7 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
fragmentManager.executePendingTransactions();
}
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
for (int i = 0 ; i < taskEditControlFragments.size() ; i++) {
TaskEditControlFragment taskEditControlFragment = taskEditControlFragments.get(i);
String tag = getString(taskEditControlFragment.controlId());
@ -231,7 +231,7 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
}
public NavigationDrawerFragment getNavigationDrawerFragment() {
return (NavigationDrawerFragment) getFragmentManager()
return (NavigationDrawerFragment) getSupportFragmentManager()
.findFragmentById(NavigationDrawerFragment.FRAGMENT_NAVIGATION_DRAWER);
}
@ -442,12 +442,12 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
}
public TaskListFragment getTaskListFragment() {
return (TaskListFragment) getFragmentManager()
return (TaskListFragment) getSupportFragmentManager()
.findFragmentByTag(TaskListFragment.TAG_TASKLIST_FRAGMENT);
}
public TaskEditFragment getTaskEditFragment() {
return (TaskEditFragment) getFragmentManager()
return (TaskEditFragment) getSupportFragmentManager()
.findFragmentByTag(TaskEditFragment.TAG_TASKEDIT_FRAGMENT);
}
@ -507,7 +507,7 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
@Override
public void taskEditFinished() {
getFragmentManager().popBackStackImmediate(TaskEditFragment.TAG_TASKEDIT_FRAGMENT, FragmentManager.POP_BACK_STACK_INCLUSIVE);
getSupportFragmentManager().popBackStackImmediate(TaskEditFragment.TAG_TASKEDIT_FRAGMENT, FragmentManager.POP_BACK_STACK_INCLUSIVE);
hideKeyboard();
}

@ -337,7 +337,7 @@ public class TaskListFragment extends InjectingListFragment implements
voiceInputAssistant.startVoiceRecognitionActivity(R.string.voice_create_prompt);
return true;
case R.id.menu_sort:
SortDialog.newSortDialog(hasDraggableOption()).show(getFragmentManager(), FRAG_TAG_SORT_DIALOG);
SortDialog.newSortDialog(hasDraggableOption()).show(getChildFragmentManager(), FRAG_TAG_SORT_DIALOG);
return true;
case R.id.menu_show_hidden:
item.setChecked(!item.isChecked());

@ -5,7 +5,7 @@
*/
package com.todoroo.astrid.voice;
import android.app.Fragment;
import android.support.v4.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;

@ -1,6 +1,6 @@
package org.tasks.activities;
import android.app.FragmentManager;
import android.support.v4.app.FragmentManager;
import android.content.ContentResolver;
import android.content.DialogInterface;
import android.content.Intent;
@ -49,7 +49,7 @@ public class AddAttachmentActivity extends InjectingAppCompatActivity implements
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FragmentManager fragmentManager = getFragmentManager();
FragmentManager fragmentManager = getSupportFragmentManager();
AddAttachmentDialog dialog = (AddAttachmentDialog) fragmentManager.findFragmentByTag(FRAG_TAG_ATTACHMENT_DIALOG);
if (dialog == null) {
dialog = new AddAttachmentDialog();

@ -1,6 +1,6 @@
package org.tasks.activities;
import android.app.FragmentManager;
import android.support.v4.app.FragmentManager;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
@ -64,7 +64,7 @@ public class CalendarSelectionActivity extends InjectingAppCompatActivity implem
}
private void showDialog() {
FragmentManager fragmentManager = getFragmentManager();
FragmentManager fragmentManager = getSupportFragmentManager();
CalendarSelectionDialog fragmentByTag = (CalendarSelectionDialog) fragmentManager.findFragmentByTag(FRAG_TAG_CALENDAR_PREFERENCE_SELECTION);
if (fragmentByTag == null) {
fragmentByTag = new CalendarSelectionDialog();

@ -0,0 +1,63 @@
package org.tasks.dialogs;
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import org.tasks.injection.InjectingNativeDialogFragment;
import org.tasks.injection.NativeDialogFragmentComponent;
import javax.inject.Inject;
public class NativeThemePickerDialog extends InjectingNativeDialogFragment implements ThemePickerDialog.ThemePickerCallback {
private static final String EXTRA_PALETTE = "extra_palette";
public static NativeThemePickerDialog newNativeThemePickerDialog(ThemePickerDialog.ColorPalette palette) {
NativeThemePickerDialog dialog = new NativeThemePickerDialog();
dialog.palette = palette;
return dialog;
}
@Inject ThemePickerDialog themePickerDialog;
private ThemePickerDialog.ColorPalette palette;
private ThemePickerDialog.ThemePickerCallback callback;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (savedInstanceState != null) {
palette = (ThemePickerDialog.ColorPalette) savedInstanceState.getSerializable(EXTRA_PALETTE);
}
return themePickerDialog.createDialog(palette, this);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
callback = (ThemePickerDialog.ThemePickerCallback) activity;
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putSerializable(EXTRA_PALETTE, palette);
}
@Override
protected void inject(NativeDialogFragmentComponent component) {
component.inject(this);
}
@Override
public void themePicked(ThemePickerDialog.ColorPalette palette, int index) {
callback.themePicked(palette, index);
}
@Override
public void initiateThemePurchase() {
callback.initiateThemePurchase();
}
}

@ -0,0 +1,63 @@
package org.tasks.dialogs;
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.InjectingDialogFragment;
import javax.inject.Inject;
public class SupportThemePickerDialog extends InjectingDialogFragment implements ThemePickerDialog.ThemePickerCallback {
private static final String EXTRA_PALETTE = "extra_palette";
public static SupportThemePickerDialog newSupportThemePickerDialog(ThemePickerDialog.ColorPalette palette) {
SupportThemePickerDialog dialog = new SupportThemePickerDialog();
dialog.palette = palette;
return dialog;
}
@Inject ThemePickerDialog themePickerDialog;
private ThemePickerDialog.ColorPalette palette;
private ThemePickerDialog.ThemePickerCallback callback;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (savedInstanceState != null) {
palette = (ThemePickerDialog.ColorPalette) savedInstanceState.getSerializable(EXTRA_PALETTE);
}
return themePickerDialog.createDialog(palette, this);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
callback = (ThemePickerDialog.ThemePickerCallback) activity;
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putSerializable(EXTRA_PALETTE, palette);
}
@Override
protected void inject(DialogFragmentComponent component) {
component.inject(this);
}
@Override
public void themePicked(ThemePickerDialog.ColorPalette palette, int index) {
callback.themePicked(palette, index);
}
@Override
public void initiateThemePurchase() {
callback.initiateThemePurchase();
}
}

@ -1,12 +1,10 @@
package org.tasks.dialogs;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -15,9 +13,7 @@ import android.widget.ListAdapter;
import android.widget.TextView;
import org.tasks.R;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ForApplication;
import org.tasks.injection.InjectingDialogFragment;
import org.tasks.preferences.Preferences;
import org.tasks.themes.Theme;
import org.tasks.themes.ThemeCache;
@ -26,22 +22,9 @@ import javax.inject.Inject;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastJellybeanMR1;
public class ThemePickerDialog extends InjectingDialogFragment {
public class ThemePickerDialog {
private static final String EXTRA_COLOR_PALETTE = "extra_color_palette";
public enum ColorPalette {
THEMES,
COLORS,
ACCENTS,
WIDGET_BACKGROUND
}
public static ThemePickerDialog newThemePickerDialog(ColorPalette palette) {
ThemePickerDialog dialog = new ThemePickerDialog();
dialog.palette = palette;
return dialog;
}
public enum ColorPalette {THEMES, COLORS, ACCENTS, WIDGET_BACKGROUND}
public interface ThemePickerCallback {
void themePicked(ColorPalette palette, int index);
@ -49,27 +32,28 @@ public class ThemePickerDialog extends InjectingDialogFragment {
void initiateThemePurchase();
}
@Inject DialogBuilder dialogBuilder;
@Inject @ForApplication Context context;
@Inject Preferences preferences;
@Inject Theme theme;
@Inject ThemeCache themeCache;
private ThemePickerCallback callback;
private ColorPalette palette;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (savedInstanceState != null) {
palette = (ColorPalette) savedInstanceState.getSerializable(EXTRA_COLOR_PALETTE);
}
private DialogBuilder dialogBuilder;
private Context context;
private Preferences preferences;
private ThemeCache themeCache;
private Theme theme;
@Inject
public ThemePickerDialog(DialogBuilder dialogBuilder, @ForApplication Context context, Preferences preferences,
Theme theme, ThemeCache themeCache) {
this.dialogBuilder = dialogBuilder;
this.context = context;
this.preferences = preferences;
this.theme = theme;
this.themeCache = themeCache;
}
public AlertDialog createDialog(final ColorPalette palette, final ThemePickerCallback callback) {
if (palette == ColorPalette.THEMES || palette == ColorPalette.WIDGET_BACKGROUND) {
theme = theme.withBaseTheme(themeCache.getThemeBase(2));
}
final String[] themes = getResources().getStringArray(getNameRes());
final String[] themes = context.getResources().getStringArray(getNameRes(palette));
final boolean purchasedThemes = preferences.hasPurchase(R.string.p_purchased_themes);
@ -80,11 +64,11 @@ public class ThemePickerDialog extends InjectingDialogFragment {
TextView textView = (TextView) (convertView == null
? inflater.inflate(R.layout.color_selection_row, parent, false)
: convertView);
Drawable original = getResources().getDrawable(purchasedThemes || position < 2
Drawable original = context.getResources().getDrawable(purchasedThemes || position < 2
? R.drawable.ic_lens_black_24dp
: R.drawable.ic_vpn_key_black_24dp);
Drawable wrapped = DrawableCompat.wrap(original.mutate());
DrawableCompat.setTint(wrapped, getDisplayColor(position));
DrawableCompat.setTint(wrapped, getDisplayColor(palette, position));
if (atLeastJellybeanMR1()) {
textView.setCompoundDrawablesRelativeWithIntrinsicBounds(wrapped, null, null, null);
} else {
@ -110,7 +94,7 @@ public class ThemePickerDialog extends InjectingDialogFragment {
.show();
}
private int getNameRes() {
private int getNameRes(ColorPalette palette) {
switch (palette) {
case COLORS:
return R.array.colors;
@ -123,7 +107,7 @@ public class ThemePickerDialog extends InjectingDialogFragment {
}
}
private int getDisplayColor(int index) {
private int getDisplayColor(ColorPalette palette, int index) {
switch (palette) {
case COLORS:
return themeCache.getThemeColor(index).getPrimaryColor();
@ -135,23 +119,4 @@ public class ThemePickerDialog extends InjectingDialogFragment {
return themeCache.getThemeBase(index).getContentBackground();
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putSerializable(EXTRA_COLOR_PALETTE, palette);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
callback = (ThemePickerCallback) activity;
}
@Override
protected void inject(DialogFragmentComponent component) {
component.inject(this);
}
}

@ -1,9 +1,10 @@
package org.tasks.fragments;
import android.app.Activity;
import android.app.FragmentManager;
import android.support.v4.app.FragmentManager;
import com.todoroo.astrid.activity.BeastModePreferences;
import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.files.FilesControlSet;
import com.todoroo.astrid.repeats.RepeatControlSet;
@ -87,7 +88,7 @@ public class TaskEditControlSetFragmentManager {
displayOrder = BeastModePreferences.constructOrderedControlList(preferences, activity);
displayOrder.add(0, activity.getString(EditTitleControlSet.TAG));
displayOrder.add(1, activity.getString(CommentBarFragment.TAG));
fragmentManager = activity.getFragmentManager();
fragmentManager = ((TaskListActivity) activity).getSupportFragmentManager();
String hideAlwaysTrigger = activity.getString(R.string.TEA_ctrl_hide_section_pref);
for (numRows = 0 ; numRows < displayOrder.size() ; numRows++) {
if (displayOrder.get(numRows).equals(hideAlwaysTrigger)) {

@ -50,6 +50,8 @@ public interface BaseActivityComponent {
DialogFragmentComponent plus(DialogFragmentModule dialogFragmentModule);
NativeDialogFragmentComponent plus(NativeDialogFragmentModule nativeDialogFragmentModule);
void inject(AACRecordingActivity aacRecordingActivity);
void inject(CustomFilterActivity customFilterActivity);

@ -3,9 +3,8 @@ package org.tasks.injection;
import org.tasks.activities.CalendarSelectionDialog;
import org.tasks.dialogs.AccountSelectionDialog;
import org.tasks.dialogs.AddAttachmentDialog;
import org.tasks.locale.LocalePickerDialog;
import org.tasks.dialogs.SortDialog;
import org.tasks.dialogs.ThemePickerDialog;
import org.tasks.dialogs.SupportThemePickerDialog;
import org.tasks.reminders.MissedCallDialog;
import org.tasks.reminders.NotificationDialog;
import org.tasks.reminders.SnoozeDialog;
@ -26,9 +25,7 @@ public interface BaseDialogFragmentComponent {
void inject(WidgetConfigDialog widgetConfigDialog);
void inject(ThemePickerDialog themePickerDialog);
void inject(SortDialog sortDialog);
void inject(LocalePickerDialog localePickerDialog);
void inject(SupportThemePickerDialog supportThemePickerDialog);
}

@ -0,0 +1,10 @@
package org.tasks.injection;
import org.tasks.dialogs.NativeThemePickerDialog;
import org.tasks.locale.LocalePickerDialog;
public interface BaseNativeDialogFragmentComponent {
void inject(NativeThemePickerDialog themePickerDialog);
void inject(LocalePickerDialog localePickerDialog);
}

@ -1,7 +1,7 @@
package org.tasks.injection;
import android.app.Activity;
import android.app.DialogFragment;
import android.support.v4.app.DialogFragment;
import dagger.Module;
import dagger.Provides;

@ -1,7 +1,7 @@
package org.tasks.injection;
import android.app.Fragment;
import android.content.Context;
import android.support.v4.app.Fragment;
import dagger.Module;
import dagger.Provides;

@ -1,7 +1,7 @@
package org.tasks.injection;
import android.app.Activity;
import android.app.DialogFragment;
import android.support.v4.app.DialogFragment;
public abstract class InjectingDialogFragment extends DialogFragment {
private boolean injected;

@ -1,7 +1,7 @@
package org.tasks.injection;
import android.app.Activity;
import android.app.Fragment;
import android.support.v4.app.Fragment;
public abstract class InjectingFragment extends Fragment {

@ -1,7 +1,7 @@
package org.tasks.injection;
import android.app.Activity;
import android.app.ListFragment;
import android.support.v4.app.ListFragment;
public abstract class InjectingListFragment extends ListFragment {

@ -0,0 +1,22 @@
package org.tasks.injection;
import android.app.Activity;
import android.app.DialogFragment;
public abstract class InjectingNativeDialogFragment extends DialogFragment {
private boolean injected;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
if (!injected) {
inject(((InjectingActivity) activity)
.getComponent()
.plus(new NativeDialogFragmentModule(this)));
injected = true;
}
}
protected abstract void inject(NativeDialogFragmentComponent component);
}

@ -0,0 +1,21 @@
package org.tasks.injection;
import android.app.Activity;
import android.app.DialogFragment;
import dagger.Module;
import dagger.Provides;
@Module
public class NativeDialogFragmentModule {
private DialogFragment dialogFragment;
public NativeDialogFragmentModule(DialogFragment dialogFragment) {
this.dialogFragment = dialogFragment;
}
@Provides
public Activity getActivity() {
return dialogFragment.getActivity();
}
}

@ -2,7 +2,6 @@ package org.tasks.locale;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
@ -10,9 +9,8 @@ import com.google.common.base.Function;
import org.tasks.R;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ForApplication;
import org.tasks.injection.InjectingDialogFragment;
import org.tasks.injection.InjectingNativeDialogFragment;
import org.tasks.injection.NativeDialogFragmentComponent;
import java.util.ArrayList;
import java.util.List;
@ -22,7 +20,7 @@ import javax.inject.Inject;
import static com.google.common.collect.Lists.transform;
public class LocalePickerDialog extends InjectingDialogFragment {
public class LocalePickerDialog extends InjectingNativeDialogFragment {
public static LocalePickerDialog newLocalePickerDialog() {
return new LocalePickerDialog();
@ -33,7 +31,6 @@ public class LocalePickerDialog extends InjectingDialogFragment {
}
@Inject DialogBuilder dialogBuilder;
@Inject @ForApplication Context context;
@Inject Locale locale;
private LocaleSelectionHandler callback;
@ -71,7 +68,7 @@ public class LocalePickerDialog extends InjectingDialogFragment {
}
@Override
protected void inject(DialogFragmentComponent component) {
protected void inject(NativeDialogFragmentComponent component) {
component.inject(this);
}
}

@ -1,7 +1,6 @@
package org.tasks.preferences;
import android.app.Activity;
import android.app.FragmentManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
@ -30,7 +29,7 @@ import org.tasks.themes.ThemeColor;
import javax.inject.Inject;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastJellybeanMR1;
import static org.tasks.dialogs.ThemePickerDialog.newThemePickerDialog;
import static org.tasks.dialogs.NativeThemePickerDialog.newNativeThemePickerDialog;
import static org.tasks.locale.LocalePickerDialog.newLocalePickerDialog;
public abstract class BaseBasicPreferences extends InjectingPreferenceActivity implements
@ -70,11 +69,8 @@ public abstract class BaseBasicPreferences extends InjectingPreferenceActivity i
themePreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager.findFragmentByTag(FRAG_TAG_THEME_PICKER) == null) {
newThemePickerDialog(ThemePickerDialog.ColorPalette.THEMES)
.show(fragmentManager, FRAG_TAG_THEME_PICKER);
}
newNativeThemePickerDialog(ThemePickerDialog.ColorPalette.THEMES)
.show(getFragmentManager(), FRAG_TAG_THEME_PICKER);
return false;
}
});
@ -83,11 +79,8 @@ public abstract class BaseBasicPreferences extends InjectingPreferenceActivity i
colorPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager.findFragmentByTag(FRAG_TAG_THEME_PICKER) == null) {
newThemePickerDialog(ThemePickerDialog.ColorPalette.COLORS)
.show(fragmentManager, FRAG_TAG_COLOR_PICKER);
}
newNativeThemePickerDialog(ThemePickerDialog.ColorPalette.COLORS)
.show(getFragmentManager(), FRAG_TAG_COLOR_PICKER);
return false;
}
});
@ -96,11 +89,8 @@ public abstract class BaseBasicPreferences extends InjectingPreferenceActivity i
accentPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager.findFragmentByTag(FRAG_TAG_ACCENT_PICKER) == null) {
newThemePickerDialog(ThemePickerDialog.ColorPalette.ACCENTS)
.show(fragmentManager, FRAG_TAG_ACCENT_PICKER);
}
newNativeThemePickerDialog(ThemePickerDialog.ColorPalette.ACCENTS)
.show(getFragmentManager(), FRAG_TAG_ACCENT_PICKER);
return false;
}
});

@ -1,7 +1,6 @@
package org.tasks.preferences;
import android.app.Fragment;
import android.support.v13.app.FragmentCompat;
import android.support.v4.app.Fragment;
import javax.inject.Inject;
@ -17,6 +16,6 @@ public class FragmentPermissionRequestor extends PermissionRequestor {
@Override
protected void requestPermissions(String[] permissions, int rc) {
FragmentCompat.requestPermissions(fragment, permissions, rc);
fragment.requestPermissions(permissions, rc);
}
}

@ -1,6 +1,6 @@
package org.tasks.reminders;
import android.app.FragmentManager;
import android.support.v4.app.FragmentManager;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
@ -61,7 +61,7 @@ public class MissedCallActivity extends InjectingAppCompatActivity implements Mi
} else if (intent.getBooleanExtra(EXTRA_CALL_LATER, false)) {
callLater();
} else {
FragmentManager fragmentManager = getFragmentManager();
FragmentManager fragmentManager = getSupportFragmentManager();
MissedCallDialog fragment = (MissedCallDialog) fragmentManager.findFragmentByTag(FRAG_TAG_MISSED_CALL_FRAGMENT);
if (fragment == null) {
fragment = new MissedCallDialog();

@ -1,6 +1,6 @@
package org.tasks.reminders;
import android.app.FragmentManager;
import android.support.v4.app.FragmentManager;
import android.content.Intent;
import android.os.Bundle;
@ -46,7 +46,7 @@ public class NotificationActivity extends InjectingAppCompatActivity implements
taskId = intent.getLongExtra(EXTRA_TASK_ID, 0L);
FragmentManager fragmentManager = getFragmentManager();
FragmentManager fragmentManager = getSupportFragmentManager();
NotificationDialog fragment = (NotificationDialog) fragmentManager.findFragmentByTag(FRAG_TAG_NOTIFICATION_FRAGMENT);
if (fragment == null) {
fragment = new NotificationDialog();

@ -1,6 +1,6 @@
package org.tasks.reminders;
import android.app.FragmentManager;
import android.support.v4.app.FragmentManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
@ -68,7 +68,7 @@ public class SnoozeActivity extends InjectingAppCompatActivity implements Snooze
if (intent.hasExtra(EXTRA_SNOOZE_TIME)) {
snoozeForTime(new DateTime(intent.getLongExtra(EXTRA_SNOOZE_TIME, 0L)));
} else {
FragmentManager fragmentManager = getFragmentManager();
FragmentManager fragmentManager = getSupportFragmentManager();
SnoozeDialog fragmentByTag = (SnoozeDialog) fragmentManager.findFragmentByTag(FRAG_TAG_SNOOZE_DIALOG);
if (fragmentByTag == null) {
fragmentByTag = new SnoozeDialog();

@ -1,8 +1,8 @@
package org.tasks.ui;
import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

@ -1,6 +1,6 @@
package org.tasks.widget;
import android.app.FragmentManager;
import android.support.v4.app.FragmentManager;
import android.appwidget.AppWidgetManager;
import android.content.Intent;
import android.os.Bundle;
@ -58,7 +58,7 @@ public class WidgetConfigActivity extends InjectingAppCompatActivity implements
if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
finish();
} else {
FragmentManager fragmentManager = getFragmentManager();
FragmentManager fragmentManager = getSupportFragmentManager();
widgetConfigDialog = (WidgetConfigDialog) fragmentManager.findFragmentByTag(FRAG_TAG_WIDGET_CONFIG);
if (widgetConfigDialog == null) {
widgetConfigDialog = WidgetConfigDialog.newWidgetConfigDialog(appWidgetId);

@ -2,7 +2,6 @@ package org.tasks.widget;
import android.app.Activity;
import android.app.Dialog;
import android.app.FragmentManager;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.DialogInterface;
@ -35,7 +34,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import static org.tasks.dialogs.ThemePickerDialog.newThemePickerDialog;
import static org.tasks.dialogs.SupportThemePickerDialog.newSupportThemePickerDialog;
public class WidgetConfigDialog extends InjectingDialogFragment implements SeekBar.OnSeekBarChangeListener {
@ -190,18 +189,14 @@ public class WidgetConfigDialog extends InjectingDialogFragment implements SeekB
@OnClick(R.id.theme_selection)
public void showThemeSelection() {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager.findFragmentByTag(FRAG_TAG_THEME_SELECTION) == null) {
newThemePickerDialog(ThemePickerDialog.ColorPalette.WIDGET_BACKGROUND).show(fragmentManager, FRAG_TAG_THEME_SELECTION);
}
newSupportThemePickerDialog(ThemePickerDialog.ColorPalette.WIDGET_BACKGROUND)
.show(getChildFragmentManager(), FRAG_TAG_THEME_SELECTION);
}
@OnClick(R.id.theme_color)
public void showColorSelection() {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager.findFragmentByTag(FRAG_TAG_COLOR_SELECTION) == null) {
newThemePickerDialog(ThemePickerDialog.ColorPalette.COLORS).show(fragmentManager, FRAG_TAG_COLOR_SELECTION);
}
newSupportThemePickerDialog(ThemePickerDialog.ColorPalette.COLORS)
.show(getChildFragmentManager(), FRAG_TAG_COLOR_SELECTION);
}
@Override

Loading…
Cancel
Save