|
|
@ -30,6 +30,7 @@ import org.tasks.widget.WidgetHelper;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.inject.Inject;
|
|
|
|
import javax.inject.Inject;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.todoroo.andlib.utility.AndroidUtilities.preHoneycomb;
|
|
|
|
import static com.todoroo.andlib.utility.AndroidUtilities.preIceCreamSandwich;
|
|
|
|
import static com.todoroo.andlib.utility.AndroidUtilities.preIceCreamSandwich;
|
|
|
|
|
|
|
|
|
|
|
|
public class WidgetConfigActivity extends InjectingListActivity {
|
|
|
|
public class WidgetConfigActivity extends InjectingListActivity {
|
|
|
@ -40,7 +41,8 @@ public class WidgetConfigActivity extends InjectingListActivity {
|
|
|
|
public static final String PREF_CUSTOM_INTENT = "widget-intent-";
|
|
|
|
public static final String PREF_CUSTOM_INTENT = "widget-intent-";
|
|
|
|
public static final String PREF_CUSTOM_EXTRAS = "widget-extras-";
|
|
|
|
public static final String PREF_CUSTOM_EXTRAS = "widget-extras-";
|
|
|
|
public static final String PREF_TAG_ID = "widget-tag-id-";
|
|
|
|
public static final String PREF_TAG_ID = "widget-tag-id-";
|
|
|
|
public static final String PREF_DUE_DATE = "widget-due-date-";
|
|
|
|
public static final String PREF_SHOW_DUE_DATE = "widget-show-due-date-";
|
|
|
|
|
|
|
|
public static final String PREF_HIDE_CHECKBOXES = "widget-hide-checkboxes-";
|
|
|
|
public static final String PREF_DARK_THEME = "widget-dark-theme-";
|
|
|
|
public static final String PREF_DARK_THEME = "widget-dark-theme-";
|
|
|
|
|
|
|
|
|
|
|
|
int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
|
|
|
|
int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
|
|
|
@ -65,78 +67,84 @@ public class WidgetConfigActivity extends InjectingListActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle icicle) {
|
|
|
|
public void onCreate(Bundle icicle) {
|
|
|
|
super.onCreate(icicle);
|
|
|
|
super.onCreate(icicle);
|
|
|
|
|
|
|
|
|
|
|
|
// Set the result to CANCELED. This will cause the widget host to cancel
|
|
|
|
// Set the result to CANCELED. This will cause the widget host to cancel
|
|
|
|
// out of the widget placement if they press the back button.
|
|
|
|
// out of the widget placement if they press the back button.
|
|
|
|
setResult(RESULT_CANCELED);
|
|
|
|
setResult(RESULT_CANCELED);
|
|
|
|
|
|
|
|
|
|
|
|
// Set the view layout resource to use.
|
|
|
|
// Set the view layout resource to use.
|
|
|
|
setContentView(R.layout.widget_config_activity);
|
|
|
|
setContentView(R.layout.widget_config_activity);
|
|
|
|
|
|
|
|
|
|
|
|
setTitle(R.string.WCA_title);
|
|
|
|
if (preHoneycomb()) {
|
|
|
|
|
|
|
|
findViewById(R.id.hideCheckboxes).setVisibility(View.GONE);
|
|
|
|
// Find the widget id from the intent.
|
|
|
|
}
|
|
|
|
Intent intent = getIntent();
|
|
|
|
|
|
|
|
Bundle extras = intent.getExtras();
|
|
|
|
setTitle(R.string.WCA_title);
|
|
|
|
if (extras != null) {
|
|
|
|
|
|
|
|
mAppWidgetId = extras.getInt(
|
|
|
|
// Find the widget id from the intent.
|
|
|
|
AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
|
|
|
|
Intent intent = getIntent();
|
|
|
|
}
|
|
|
|
Bundle extras = intent.getExtras();
|
|
|
|
|
|
|
|
if (extras != null) {
|
|
|
|
// If they gave us an intent without the widget id, just bail.
|
|
|
|
mAppWidgetId = extras.getInt(
|
|
|
|
if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
|
|
|
|
AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If they gave us an intent without the widget id, just bail.
|
|
|
|
// set up ui
|
|
|
|
if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
|
|
|
|
adapter = new FilterAdapter(filterProvider, filterCounter, this, getListView(),
|
|
|
|
finish();
|
|
|
|
R.layout.filter_adapter_row, true);
|
|
|
|
}
|
|
|
|
adapter.filterStyle = R.style.TextAppearance_FLA_Filter_Widget;
|
|
|
|
|
|
|
|
setListAdapter(adapter);
|
|
|
|
// set up ui
|
|
|
|
|
|
|
|
adapter = new FilterAdapter(filterProvider, filterCounter, this, getListView(),
|
|
|
|
Button button = (Button)findViewById(R.id.ok);
|
|
|
|
R.layout.filter_adapter_row, true);
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
adapter.filterStyle = R.style.TextAppearance_FLA_Filter_Widget;
|
|
|
|
@Override
|
|
|
|
setListAdapter(adapter);
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
// Save configuration options
|
|
|
|
Button button = (Button) findViewById(R.id.ok);
|
|
|
|
CheckBox showDueDate = (CheckBox) findViewById(R.id.showDueDate);
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
CheckBox darkTheme = (CheckBox) findViewById(R.id.darkTheme);
|
|
|
|
@Override
|
|
|
|
saveConfiguration(adapter.getSelection(), showDueDate.isChecked(), darkTheme.isChecked());
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
// Save configuration options
|
|
|
|
updateWidget();
|
|
|
|
CheckBox hideDueDate = (CheckBox) findViewById(R.id.hideDueDate);
|
|
|
|
|
|
|
|
CheckBox darkTheme = (CheckBox) findViewById(R.id.darkTheme);
|
|
|
|
// Make sure we pass back the original appWidgetId
|
|
|
|
CheckBox hideCheckboxes = (CheckBox) findViewById(R.id.hideCheckboxes);
|
|
|
|
Intent resultValue = new Intent();
|
|
|
|
saveConfiguration(adapter.getSelection(), !hideDueDate.isChecked(),
|
|
|
|
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
|
|
|
|
darkTheme.isChecked(), hideCheckboxes.isChecked());
|
|
|
|
setResult(RESULT_OK, resultValue);
|
|
|
|
|
|
|
|
finish();
|
|
|
|
updateWidget();
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
// Make sure we pass back the original appWidgetId
|
|
|
|
}
|
|
|
|
Intent resultValue = new Intent();
|
|
|
|
|
|
|
|
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
|
|
|
|
|
|
|
|
setResult(RESULT_OK, resultValue);
|
|
|
|
|
|
|
|
finish();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onListItemClick(ListView l, View v, int position, long id) {
|
|
|
|
protected void onListItemClick(ListView l, View v, int position, long id) {
|
|
|
|
super.onListItemClick(l, v, position, id);
|
|
|
|
super.onListItemClick(l, v, position, id);
|
|
|
|
Filter item = adapter.getItem(position);
|
|
|
|
Filter item = adapter.getItem(position);
|
|
|
|
adapter.setSelection(item);
|
|
|
|
adapter.setSelection(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onResume() {
|
|
|
|
protected void onResume() {
|
|
|
|
super.onResume();
|
|
|
|
super.onResume();
|
|
|
|
adapter.registerRecevier();
|
|
|
|
adapter.registerRecevier();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onPause() {
|
|
|
|
protected void onPause() {
|
|
|
|
super.onPause();
|
|
|
|
super.onPause();
|
|
|
|
adapter.unregisterRecevier();
|
|
|
|
adapter.unregisterRecevier();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void saveConfiguration(FilterListItem filterListItem, boolean showDueDate, boolean darkTheme){
|
|
|
|
private void saveConfiguration(FilterListItem filterListItem, boolean showDueDate, boolean darkTheme, boolean hideCheckboxes){
|
|
|
|
DisplayMetrics metrics = new DisplayMetrics();
|
|
|
|
DisplayMetrics metrics = new DisplayMetrics();
|
|
|
|
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
|
|
|
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
|
|
|
|
|
|
|
|
|
|
@ -156,8 +164,9 @@ public class WidgetConfigActivity extends InjectingListActivity {
|
|
|
|
preferences.setString(WidgetConfigActivity.PREF_TITLE + mAppWidgetId, title);
|
|
|
|
preferences.setString(WidgetConfigActivity.PREF_TITLE + mAppWidgetId, title);
|
|
|
|
preferences.setString(WidgetConfigActivity.PREF_SQL + mAppWidgetId, sql);
|
|
|
|
preferences.setString(WidgetConfigActivity.PREF_SQL + mAppWidgetId, sql);
|
|
|
|
preferences.setString(WidgetConfigActivity.PREF_VALUES + mAppWidgetId, contentValuesString);
|
|
|
|
preferences.setString(WidgetConfigActivity.PREF_VALUES + mAppWidgetId, contentValuesString);
|
|
|
|
preferences.setBoolean(WidgetConfigActivity.PREF_DUE_DATE + mAppWidgetId, showDueDate);
|
|
|
|
preferences.setBoolean(WidgetConfigActivity.PREF_SHOW_DUE_DATE + mAppWidgetId, showDueDate);
|
|
|
|
preferences.setBoolean(WidgetConfigActivity.PREF_DARK_THEME + mAppWidgetId, darkTheme);
|
|
|
|
preferences.setBoolean(WidgetConfigActivity.PREF_DARK_THEME + mAppWidgetId, darkTheme);
|
|
|
|
|
|
|
|
preferences.setBoolean(WidgetConfigActivity.PREF_HIDE_CHECKBOXES + mAppWidgetId, hideCheckboxes);
|
|
|
|
|
|
|
|
|
|
|
|
if(filterListItem instanceof FilterWithCustomIntent) {
|
|
|
|
if(filterListItem instanceof FilterWithCustomIntent) {
|
|
|
|
String flattenedName = ((FilterWithCustomIntent)filterListItem).customTaskList.flattenToString();
|
|
|
|
String flattenedName = ((FilterWithCustomIntent)filterListItem).customTaskList.flattenToString();
|
|
|
|