Action bar in settings

Closes #104
pull/253/head
Alex Baker 10 years ago
parent 5e5af08c44
commit 866a5bb2e6

@ -168,12 +168,14 @@
<!-- Activity for preferences -->
<activity
android:name="com.todoroo.astrid.activity.EditPreferences"
android:theme="@android:style/Theme" />
android:name=".preferences.BasicPreferences"
android:label="@string/TLA_menu_settings"
android:theme="@style/Tasks" />
<activity
android:name=".preferences.MiscellaneousPreferences"
android:theme="@android:style/Theme" />
android:label="@string/miscellaneous"
android:theme="@style/Tasks" />
<!-- Activity that configures widget -->
<activity android:name="com.todoroo.astrid.widget.WidgetConfigActivity">
@ -265,7 +267,8 @@
<activity
android:name="com.todoroo.astrid.core.DefaultsPreferences"
android:theme="@android:style/Theme"/>
android:label="@string/task_defaults"
android:theme="@style/Tasks"/>
<activity
android:name="com.todoroo.astrid.activity.BeastModePreferences"
@ -340,7 +343,8 @@
<activity
android:name="com.todoroo.astrid.gtasks.GtasksPreferences"
android:theme="@android:style/Theme"
android:label="@string/synchronization"
android:theme="@style/Tasks"
android:screenOrientation="portrait"/>
<activity
@ -388,7 +392,8 @@
<!-- old tasks -->
<activity
android:name="com.todoroo.astrid.core.OldTaskPreferences"
android:theme="@android:style/Theme"/>
android:label="@string/EPr_manage_header"
android:theme="@style/Tasks"/>
<activity
android:name=".activities.ClearAllDataActivity"
@ -434,7 +439,8 @@
<!-- reminders -->
<activity
android:name="com.todoroo.astrid.reminders.ReminderPreferences"
android:theme="@android:style/Theme"/>
android:label="@string/notifications"
android:theme="@style/Tasks"/>
<activity
android:name=".voice.VoiceCommandActivity"

@ -1,64 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.activity;
import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.core.DefaultsPreferences;
import com.todoroo.astrid.core.OldTaskPreferences;
import com.todoroo.astrid.gtasks.GtasksPreferences;
import com.todoroo.astrid.reminders.ReminderPreferences;
import com.todoroo.astrid.service.StartupService;
import org.tasks.R;
import org.tasks.injection.InjectingPreferenceActivity;
import org.tasks.preferences.MiscellaneousPreferences;
import javax.inject.Inject;
/**
* Displays the preference screen for users to edit their preferences
*
* @author Tim Su <tim@todoroo.com>
*
*/
public class EditPreferences extends InjectingPreferenceActivity {
// --- instance variables
@Inject StartupService startupService;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startupService.onStartupApplication(this);
addPreferencesFromResource(R.xml.preferences);
PreferenceScreen screen= getPreferenceScreen();
addPreferencesFromResource(R.xml.preferences_appearance);
screen.addPreference(getPreference(ReminderPreferences.class, R.string.notifications));
screen.addPreference(getPreference(DefaultsPreferences.class, R.string.task_defaults));
screen.addPreference(getPreference(GtasksPreferences.class, R.string.synchronization));
addPreferencesFromResource(R.xml.preferences_backup);
screen.addPreference(getPreference(OldTaskPreferences.class, R.string.EPr_manage_header));
screen.addPreference(getPreference(MiscellaneousPreferences.class, R.string.miscellaneous));
}
private Preference getPreference(final Class<? extends PreferenceActivity> klass, final int label) {
return new Preference(this) {{
setTitle(getResources().getString(label));
setIntent(new Intent(EditPreferences.this, klass) {{
setAction(AstridApiConstants.ACTION_SETTINGS);
}});
}};
}
}

@ -44,8 +44,9 @@ public class FilePickerBuilder extends AlertDialog.Builder implements DialogInte
setPath(path);
}
public void setOnFilePickedListener(OnFilePickedListener onFilePickedListener) {
public FilePickerBuilder setOnFilePickedListener(OnFilePickedListener onFilePickedListener) {
this.onFilePickedListener = onFilePickedListener;
return this;
}
private void setPath(final File path) {

@ -22,7 +22,7 @@ import android.widget.TextView;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.activity.EditPreferences;
import org.tasks.preferences.BasicPreferences;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.reminders.SnoozeCallback;
import com.todoroo.astrid.reminders.SnoozeDialog;
@ -166,7 +166,7 @@ public class MissedCallActivity extends InjectingActivity {
ignoreSettingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent editPreferences = new Intent(MissedCallActivity.this, EditPreferences.class);
Intent editPreferences = new Intent(MissedCallActivity.this, BasicPreferences.class);
startActivity(editPreferences);
finish();
}

@ -8,7 +8,7 @@ import android.view.View.OnClickListener;
import android.widget.TextView;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.astrid.activity.EditPreferences;
import org.tasks.preferences.BasicPreferences;
import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.dao.TagDataDao;
import com.todoroo.astrid.data.TagData;
@ -119,7 +119,7 @@ public class CalendarAlarmListCreator extends InjectingActivity {
ignoreSettingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent editPreferences = new Intent(CalendarAlarmListCreator.this, EditPreferences.class);
Intent editPreferences = new Intent(CalendarAlarmListCreator.this, BasicPreferences.class);
startActivity(editPreferences);
dismissListener.onClick(v);
}

@ -14,7 +14,7 @@ import android.widget.TextView;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.activity.EditPreferences;
import org.tasks.preferences.BasicPreferences;
import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.api.FilterWithCustomIntent;
@ -161,7 +161,7 @@ public class CalendarReminderActivity extends InjectingActivity {
ignoreSettingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent editPreferences = new Intent(CalendarReminderActivity.this, EditPreferences.class);
Intent editPreferences = new Intent(CalendarReminderActivity.this, BasicPreferences.class);
startActivity(editPreferences);
dismissListener.onClick(v);
}

@ -10,19 +10,19 @@ import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import org.joda.time.DateTime;
import org.tasks.R;
import org.tasks.injection.InjectingPreferenceActivity;
import org.tasks.ui.TimePreference;
import java.text.DateFormat;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastLollipop;
public class ReminderPreferences extends PreferenceActivity {
public class ReminderPreferences extends InjectingPreferenceActivity {
@Override
public void onCreate(Bundle savedInstanceState) {

@ -1,5 +1,6 @@
package org.tasks.activities;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
@ -20,32 +21,31 @@ public class ImportTaskActivity extends InjectingActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FilePickerBuilder filePickerBuilder = new FilePickerBuilder(this,
R.string.import_file_prompt, BackupConstants.defaultExportDirectory());
filePickerBuilder.setOnFilePickedListener(new FilePickerBuilder.OnFilePickedListener() {
@Override
public void onFilePicked(String filePath) {
xmlImporter.importTasks(ImportTaskActivity.this, filePath, new Runnable() {
@Override
public void run() {
Flags.set(Flags.REFRESH);
finish();
}
});
}
});
filePickerBuilder.setOnDismissListener(new DialogInterface.OnDismissListener() {
AlertDialog filePicker =
new FilePickerBuilder(this, R.string.import_file_prompt, BackupConstants.defaultExportDirectory())
.setOnFilePickedListener(new FilePickerBuilder.OnFilePickedListener() {
@Override
public void onFilePicked(String filePath) {
xmlImporter.importTasks(ImportTaskActivity.this, filePath, new Runnable() {
@Override
public void run() {
Flags.set(Flags.REFRESH);
finish();
}
});
}
})
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
finish();
}
}).show();
filePicker.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
finish();
}
});
filePickerBuilder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
finish();
}
});
filePickerBuilder.show();
}
}

@ -5,7 +5,7 @@ import android.app.Activity;
import com.todoroo.astrid.actfm.TagSettingsActivity;
import com.todoroo.astrid.actfm.TagSettingsActivityTablet;
import com.todoroo.astrid.activity.BeastModePreferences;
import com.todoroo.astrid.activity.EditPreferences;
import org.tasks.preferences.BasicPreferences;
import com.todoroo.astrid.activity.FilterShortcutActivity;
import com.todoroo.astrid.activity.ShareLinkActivity;
import com.todoroo.astrid.activity.TaskEditActivity;
@ -20,6 +20,7 @@ import com.todoroo.astrid.gcal.CalendarAlarmListCreator;
import com.todoroo.astrid.gcal.CalendarReminderActivity;
import com.todoroo.astrid.gtasks.GtasksPreferences;
import com.todoroo.astrid.gtasks.auth.GtasksLoginActivity;
import com.todoroo.astrid.reminders.ReminderPreferences;
import com.todoroo.astrid.tags.DeleteTagActivity;
import com.todoroo.astrid.tags.RenameTagActivity;
import com.todoroo.astrid.widget.WidgetConfigActivity;
@ -58,7 +59,7 @@ import dagger.Provides;
VoiceCommandActivity.class,
GtasksLoginActivity.class,
WidgetConfigActivity.class,
EditPreferences.class,
BasicPreferences.class,
GtasksPreferences.class,
OldTaskPreferences.class,
FilterShortcutActivity.class,
@ -74,7 +75,8 @@ import dagger.Provides;
DeleteCompletedActivity.class,
DeleteCompletedEventsActivity.class,
DeleteAllCalendarEventsActivity.class,
ClearGtaskDataActivity.class
ClearGtaskDataActivity.class,
ReminderPreferences.class
})
public class ActivityModule {

@ -2,18 +2,45 @@ package org.tasks.injection;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import org.tasks.R;
import dagger.ObjectGraph;
public abstract class InjectingPreferenceActivity extends PreferenceActivity implements Injector {
private ObjectGraph objectGraph;
protected Toolbar toolbar;
@Override
public void onCreate(Bundle savedInstanceState) {
objectGraph = ((Injector) getApplication()).getObjectGraph().plus(new ActivityModule(this));
inject(this);
super.onCreate(savedInstanceState);
ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
View content = root.getChildAt(0);
LinearLayout toolbarContainer = (LinearLayout) View.inflate(this, R.layout.activity_prefs, null);
root.removeAllViews();
toolbarContainer.addView(content);
root.addView(toolbarContainer);
toolbar = (Toolbar) toolbarContainer.findViewById(R.id.toolbar);
toolbar.setTitle(getTitle());
toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
@Override

@ -0,0 +1,25 @@
package org.tasks.preferences;
import android.os.Bundle;
import org.tasks.R;
import org.tasks.injection.InjectingPreferenceActivity;
public class BasicPreferences extends InjectingPreferenceActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String action = getIntent().getAction();
if (action == null) {
addPreferencesFromResource(R.xml.preferences);
} else if (action.equals(getString(R.string.EPr_appearance_header))) {
toolbar.setTitle(getString(R.string.EPr_appearance_header));
addPreferencesFromResource(R.xml.preferences_appearance);
} else if (action.equals(getString(R.string.backup_BPr_header))) {
toolbar.setTitle(getString(R.string.backup_BPr_header));
addPreferencesFromResource(R.xml.preferences_backup);
}
}
}

@ -29,7 +29,7 @@ import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.todoroo.astrid.activity.EditPreferences;
import org.tasks.preferences.BasicPreferences;
import com.todoroo.astrid.activity.ShortcutActivity;
import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.adapter.FilterAdapter;
@ -135,7 +135,7 @@ public class NavigationDrawerFragment extends InjectingFragment {
layout.findViewById(R.id.settings_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), EditPreferences.class);
Intent intent = new Intent(getActivity(), BasicPreferences.class);
startActivityForResult(intent, ACTIVITY_SETTINGS);
}
});

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/asContentBackground"
android:orientation="vertical">
<include layout="@layout/toolbar" />
</LinearLayout>

@ -1,11 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
** Copyright (c) 2012 Todoroo Inc
**
** See the file "LICENSE" for the full license governing this code.
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/EPr_title">
</PreferenceScreen>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<Preference android:title="@string/EPr_appearance_header">
<intent
android:action="@string/EPr_appearance_header"
android:targetClass="org.tasks.preferences.BasicPreferences"
android:targetPackage="org.tasks" />
</Preference>
<Preference android:title="@string/notifications">
<intent
android:targetClass="com.todoroo.astrid.reminders.ReminderPreferences"
android:targetPackage="org.tasks" />
</Preference>
<Preference android:title="@string/task_defaults">
<intent
android:targetClass="com.todoroo.astrid.core.DefaultsPreferences"
android:targetPackage="org.tasks" />
</Preference>
<Preference android:title="@string/synchronization">
<intent
android:targetClass="com.todoroo.astrid.gtasks.GtasksPreferences"
android:targetPackage="org.tasks" />
</Preference>
<Preference android:title="@string/backup_BPr_header">
<intent
android:action="@string/backup_BPr_header"
android:targetClass="org.tasks.preferences.BasicPreferences"
android:targetPackage="org.tasks" />
</Preference>
<Preference android:title="@string/EPr_manage_header">
<intent
android:targetClass="com.todoroo.astrid.core.OldTaskPreferences"
android:targetPackage="org.tasks" />
</Preference>
<Preference android:title="@string/miscellaneous">
<intent
android:targetClass="org.tasks.preferences.MiscellaneousPreferences"
android:targetPackage="org.tasks" />
</Preference>
</PreferenceScreen>

@ -2,72 +2,69 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/EPr_appearance_header">
<PreferenceScreen android:title="@string/EPr_appearance_header">
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/p_use_dark_theme"
android:title="@string/EPr_use_dark_theme" />
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/p_use_dark_theme"
android:title="@string/EPr_use_dark_theme" />
<PreferenceCategory android:title="@string/task_list_options">
<com.todoroo.astrid.ui.MultilineListPreference
android:entries="@array/EPr_font_size"
android:entryValues="@array/EPr_font_size"
android:key="@string/p_fontSize"
android:title="@string/EPr_fontSize_title"
android:defaultValue="16"/>
<PreferenceCategory android:title="@string/task_list_options">
<com.todoroo.astrid.ui.MultilineListPreference
android:defaultValue="16"
android:entries="@array/EPr_font_size"
android:entryValues="@array/EPr_font_size"
android:key="@string/p_fontSize"
android:title="@string/EPr_fontSize_title" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="false"
android:key="@string/p_fullTaskTitle"
android:summaryOff="@string/EPr_fullTask_desc_disabled"
android:summaryOn="@string/EPr_fullTask_desc_enabled"
android:title="@string/EPr_fullTask_title" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="false"
android:key="@string/p_fullTaskTitle"
android:summaryOff="@string/EPr_fullTask_desc_disabled"
android:summaryOn="@string/EPr_fullTask_desc_enabled"
android:title="@string/EPr_fullTask_title" />
</PreferenceCategory>
</PreferenceCategory>
<PreferenceCategory android:title="@string/EPr_edit_screen_options">
<Preference android:title="@string/EPr_beastMode_title">
<intent
android:targetClass="com.todoroo.astrid.activity.BeastModePreferences"
android:targetPackage="org.tasks" />
</Preference>
<PreferenceCategory android:title="@string/EPr_edit_screen_options">
<Preference android:title="@string/EPr_beastMode_title">
<intent
android:targetClass="com.todoroo.astrid.activity.BeastModePreferences"
android:targetPackage="org.tasks" />
</Preference>
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="true"
android:key="@string/p_show_task_edit_comments"
android:title="@string/EPr_show_task_edit_comments" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="true"
android:key="@string/p_show_task_edit_comments"
android:title="@string/EPr_show_task_edit_comments" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="true"
android:key="@string/p_time_increment"
android:title="@string/EPr_time_increment" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="true"
android:key="@string/p_time_increment"
android:title="@string/EPr_time_increment" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="false"
android:key="@string/p_show_timer_shortcut"
android:title="@string/EPr_show_timer_shortcut" />
</PreferenceCategory>
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="false"
android:key="@string/p_show_timer_shortcut"
android:title="@string/EPr_show_timer_shortcut" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/EPr_filters_to_show_title">
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="true"
android:enabled="false"
android:key="@string/p_show_my_tasks_filter"
android:title="@string/BFE_Active" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="true"
android:key="@string/p_show_today_filter"
android:title="@string/today" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="true"
android:key="@string/p_show_recently_modified_filter"
android:title="@string/BFE_Recent" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="true"
android:key="@string/p_show_not_in_list_filter"
android:title="@string/tag_FEx_untagged" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/EPr_filters_to_show_title">
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="true"
android:enabled="false"
android:key="@string/p_show_my_tasks_filter"
android:title="@string/BFE_Active" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="true"
android:key="@string/p_show_today_filter"
android:title="@string/today" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="true"
android:key="@string/p_show_recently_modified_filter"
android:title="@string/BFE_Recent" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="true"
android:key="@string/p_show_not_in_list_filter"
android:title="@string/tag_FEx_untagged" />
</PreferenceCategory>
</PreferenceScreen>
</PreferenceScreen>

@ -6,23 +6,20 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/backup_BPr_header">
<PreferenceScreen android:title="@string/backup_BPr_header">
<Preference
android:key="@string/backup_BAc_import"
android:title="@string/backup_BAc_import">
<intent
android:targetClass="org.tasks.activities.ImportTaskActivity"
android:targetPackage="org.tasks" />
</Preference>
<Preference
android:key="@string/backup_BAc_import"
android:title="@string/backup_BAc_import">
<intent
android:targetClass="org.tasks.activities.ImportTaskActivity"
android:targetPackage="org.tasks" />
</Preference>
<Preference
android:key="@string/backup_BAc_export"
android:title="@string/backup_BAc_export">
<intent
android:targetClass="org.tasks.activities.ExportTaskActivity"
android:targetPackage="org.tasks" />
</Preference>
<Preference
android:key="@string/backup_BAc_export"
android:title="@string/backup_BAc_export">
<intent
android:targetClass="org.tasks.activities.ExportTaskActivity"
android:targetPackage="org.tasks" />
</Preference>
</PreferenceScreen>
</PreferenceScreen>

Loading…
Cancel
Save