mirror of https://github.com/tasks/tasks
Premium IAPs for Tasker and TeslaUnread
parent
ff98c7a849
commit
3db5a847d4
@ -0,0 +1,79 @@
|
||||
package org.tasks.locale.bundle;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.tasks.BuildConfig;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public final class PluginBundleValues {
|
||||
|
||||
public static final String BUNDLE_EXTRA_STRING_TITLE = "org.tasks.locale.STRING_TITLE";
|
||||
public static final String BUNDLE_EXTRA_STRING_QUERY = "org.tasks.locale.STRING_QUERY";
|
||||
public static final String BUNDLE_EXTRA_STRING_VALUES = "org.tasks.locale.STRING_VALUES";
|
||||
public static final String BUNDLE_EXTRA_PREVIOUS_BUNDLE = "org.tasks.locale.PREVIOUS_BUNDLE";
|
||||
public static final String BUNDLE_EXTRA_INT_VERSION_CODE = "org.tasks.locale.INT_VERSION_CODE";
|
||||
|
||||
public static boolean isBundleValid(final Bundle bundle) {
|
||||
if (null == bundle) {
|
||||
Timber.e("bundle is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isNullOrEmpty(bundle, BUNDLE_EXTRA_STRING_TITLE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isNullOrEmpty(bundle, BUNDLE_EXTRA_STRING_QUERY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bundle.containsKey(BUNDLE_EXTRA_STRING_VALUES) && bundle.getString(BUNDLE_EXTRA_STRING_VALUES).trim().length() == 0) {
|
||||
Timber.e("Empty %s", BUNDLE_EXTRA_STRING_VALUES);
|
||||
return false;
|
||||
}
|
||||
|
||||
Integer version = bundle.getInt(BUNDLE_EXTRA_INT_VERSION_CODE, -1);
|
||||
if (version == -1) {
|
||||
Timber.e("invalid version code: %s", version);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isNullOrEmpty(Bundle bundle, String key) {
|
||||
String value = bundle.getString(key);
|
||||
boolean isNullOrEmpty = value == null || value.trim().length() == 0;
|
||||
if (isNullOrEmpty) {
|
||||
Timber.e("Invalid %s", key);
|
||||
}
|
||||
return isNullOrEmpty;
|
||||
}
|
||||
|
||||
public static Bundle generateBundle(String title, String query, String values) {
|
||||
Bundle result = new Bundle();
|
||||
result.putInt(BUNDLE_EXTRA_INT_VERSION_CODE, BuildConfig.VERSION_CODE);
|
||||
result.putString(BUNDLE_EXTRA_STRING_TITLE, title);
|
||||
result.putString(BUNDLE_EXTRA_STRING_QUERY, query);
|
||||
if (values != null) {
|
||||
result.putString(BUNDLE_EXTRA_STRING_VALUES, values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getTitle(Bundle bundle) {
|
||||
return bundle.getString(BUNDLE_EXTRA_STRING_TITLE);
|
||||
}
|
||||
|
||||
public static String getQuery(Bundle bundle) {
|
||||
return bundle.getString(BUNDLE_EXTRA_STRING_QUERY);
|
||||
}
|
||||
|
||||
public static String getValuesForNewTasks(Bundle bundle) {
|
||||
return bundle.getString(BUNDLE_EXTRA_STRING_VALUES);
|
||||
}
|
||||
|
||||
private PluginBundleValues() {
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package org.tasks.locale.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.tasks.locale.bundle.PluginBundleValues;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public final class FireReceiver extends BroadcastReceiver {
|
||||
|
||||
protected boolean isBundleValid(final Bundle bundle) {
|
||||
return PluginBundleValues.isBundleValid(bundle);
|
||||
}
|
||||
|
||||
protected void firePluginSetting(final Context context, final Bundle bundle) {
|
||||
context.sendBroadcast(new Intent() {{
|
||||
setComponent(new ComponentName("org.tasks", "org.tasks.receivers.ListNotificationReceiver"));
|
||||
putExtra("extra_filter_title", PluginBundleValues.getTitle(bundle));
|
||||
putExtra("extra_filter_query", PluginBundleValues.getQuery(bundle));
|
||||
String valuesForNewTasks = PluginBundleValues.getValuesForNewTasks(bundle);
|
||||
if (valuesForNewTasks != null) {
|
||||
putExtra("extra_filter_values", valuesForNewTasks);
|
||||
}
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onReceive(final Context context, final Intent intent) {
|
||||
Timber.d("Received %s", intent); //$NON-NLS-1$
|
||||
|
||||
/*
|
||||
* Note: It is OK if a host sends an ordered broadcast for plug-in
|
||||
* settings. Such a behavior would allow the host to optionally block until the
|
||||
* plug-in setting finishes.
|
||||
*/
|
||||
|
||||
if (!com.twofortyfouram.locale.api.Intent.ACTION_FIRE_SETTING.equals(intent.getAction())) {
|
||||
Timber.e("Intent action is not %s", com.twofortyfouram.locale.api.Intent.ACTION_FIRE_SETTING); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ignore implicit intents, because they are not valid. It would be
|
||||
* meaningless if ALL plug-in setting BroadcastReceivers installed were
|
||||
* asked to handle queries not intended for them. Ideally this
|
||||
* implementation here would also explicitly assert the class name as
|
||||
* well, but then the unit tests would have trouble. In the end,
|
||||
* asserting the package is probably good enough.
|
||||
*/
|
||||
if (!context.getPackageName().equals(intent.getPackage())
|
||||
&& !new ComponentName(context, this.getClass().getName()).equals(intent
|
||||
.getComponent())) {
|
||||
Timber.e("Intent is not explicit"); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
|
||||
final Bundle bundle = intent
|
||||
.getBundleExtra(com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE);
|
||||
|
||||
if (null == bundle) {
|
||||
Timber.e("%s is missing",
|
||||
com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isBundleValid(bundle)) {
|
||||
Timber.e("%s is invalid",
|
||||
com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
|
||||
firePluginSetting(context, bundle);
|
||||
}
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
package org.tasks.locale.ui.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import org.tasks.injection.InjectingAppCompatActivity;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public abstract class AbstractFragmentPluginAppCompatActivity extends InjectingAppCompatActivity {
|
||||
|
||||
protected boolean mIsCancelled = false;
|
||||
|
||||
/* package */ static boolean isLocalePluginIntent(final Intent intent) {
|
||||
final String action = intent.getAction();
|
||||
|
||||
return com.twofortyfouram.locale.api.Intent.ACTION_EDIT_CONDITION.equals(action)
|
||||
|| com.twofortyfouram.locale.api.Intent.ACTION_EDIT_SETTING.equals(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (isLocalePluginIntent(getIntent())) {
|
||||
final Bundle previousBundle = getPreviousBundle();
|
||||
|
||||
Timber.d("Creating Activity with Intent=%s, savedInstanceState=%s, EXTRA_BUNDLE=%s",
|
||||
getIntent(), savedInstanceState, previousBundle); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(final Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
|
||||
if (isLocalePluginIntent(getIntent())) {
|
||||
if (null == savedInstanceState) {
|
||||
final Bundle previousBundle = getPreviousBundle();
|
||||
final String previousBlurb = getPreviousBlurb();
|
||||
if (null != previousBundle && null != previousBlurb) {
|
||||
onPostCreateWithPreviousResult(previousBundle, previousBlurb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
if (isLocalePluginIntent(getIntent())) {
|
||||
if (!mIsCancelled) {
|
||||
final Bundle resultBundle = getResultBundle();
|
||||
|
||||
if (null != resultBundle) {
|
||||
String blurb = getResultBlurb(resultBundle);
|
||||
Intent resultIntent = new Intent();
|
||||
resultIntent.putExtra(com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE,
|
||||
resultBundle);
|
||||
resultIntent.putExtra(com.twofortyfouram.locale.api.Intent.EXTRA_STRING_BLURB,
|
||||
blurb);
|
||||
setResult(RESULT_OK, resultIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.finish();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The {@link com.twofortyfouram.locale.api.Intent#EXTRA_BUNDLE EXTRA_BUNDLE} that was
|
||||
* previously saved to the host and subsequently passed back to this Activity for further
|
||||
* editing. Internally, this method relies on {@link #isBundleValid(Bundle)}. If
|
||||
* the bundle exists but is not valid, this method will return null.
|
||||
*/
|
||||
public final Bundle getPreviousBundle() {
|
||||
final Bundle bundle = getIntent().getBundleExtra(
|
||||
com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE);
|
||||
|
||||
if (null != bundle) {
|
||||
if (isBundleValid(bundle)) {
|
||||
return bundle;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The {@link com.twofortyfouram.locale.api.Intent#EXTRA_STRING_BLURB
|
||||
* EXTRA_STRING_BLURB} that was
|
||||
* previously saved to the host and subsequently passed back to this Activity for further
|
||||
* editing.
|
||||
*/
|
||||
public final String getPreviousBlurb() {
|
||||
return getIntent().getStringExtra(
|
||||
com.twofortyfouram.locale.api.Intent.EXTRA_STRING_BLURB);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Validates the Bundle, to ensure that a malicious application isn't attempting to pass
|
||||
* an invalid Bundle.</p>
|
||||
*
|
||||
* @param bundle The plug-in's Bundle previously returned by the edit
|
||||
* Activity. {@code bundle} should not be mutated by this method.
|
||||
* @return true if {@code bundle} is valid for the plug-in.
|
||||
*/
|
||||
public abstract boolean isBundleValid(final Bundle bundle);
|
||||
|
||||
/**
|
||||
* Plug-in Activity lifecycle callback to allow the Activity to restore
|
||||
* state for editing a previously saved plug-in instance. This callback will
|
||||
* occur during the onPostCreate() phase of the Activity lifecycle.
|
||||
* <p>{@code bundle} will have been
|
||||
* validated by {@link #isBundleValid(Bundle)} prior to this
|
||||
* method being called. If {@link #isBundleValid(Bundle)} returned false, then this
|
||||
* method will not be called. This helps ensure that plug-in Activity subclasses only have to
|
||||
* worry about bundle validation once, in the {@link #isBundleValid(Bundle)}
|
||||
* method.</p>
|
||||
* <p>Note this callback only occurs the first time the Activity is created, so it will not be
|
||||
* called
|
||||
* when the Activity is recreated (e.g. {@code savedInstanceState != null}) such as after a
|
||||
* configuration change like a screen rotation.</p>
|
||||
*
|
||||
* @param previousBundle Previous bundle that the Activity saved.
|
||||
* @param previousBlurb Previous blurb that the Activity saved
|
||||
*/
|
||||
public abstract void onPostCreateWithPreviousResult(
|
||||
final Bundle previousBundle, final String previousBlurb);
|
||||
|
||||
/**
|
||||
* @return Bundle for the plug-in or {@code null} if a valid Bundle cannot
|
||||
* be generated.
|
||||
*/
|
||||
public abstract Bundle getResultBundle();
|
||||
|
||||
/**
|
||||
* @param bundle Valid bundle for the component.
|
||||
* @return Blurb for {@code bundle}.
|
||||
*/
|
||||
public abstract String getResultBlurb(final Bundle bundle);
|
||||
}
|
@ -0,0 +1,207 @@
|
||||
package org.tasks.locale.ui.activity;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.tasks.R;
|
||||
import org.tasks.activities.FilterSelectionActivity;
|
||||
import org.tasks.injection.ActivityComponent;
|
||||
import org.tasks.locale.bundle.PluginBundleValues;
|
||||
import org.tasks.preferences.ActivityPreferences;
|
||||
import org.tasks.ui.MenuColorizer;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public final class TaskerSettingsActivity extends AbstractFragmentPluginAppCompatActivity {
|
||||
|
||||
private static final int REQUEST_SELECT_FILTER = 10124;
|
||||
|
||||
@Bind(R.id.toolbar) Toolbar toolbar;
|
||||
|
||||
@Inject ActivityPreferences preferences;
|
||||
|
||||
private Bundle previousBundle;
|
||||
private String title;
|
||||
private String query;
|
||||
private String values;
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
preferences.applyThemeAndStatusBarColor();
|
||||
setContentView(R.layout.tasker_settings);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
previousBundle = savedInstanceState.getParcelable(PluginBundleValues.BUNDLE_EXTRA_PREVIOUS_BUNDLE);
|
||||
title = savedInstanceState.getString(PluginBundleValues.BUNDLE_EXTRA_STRING_TITLE);
|
||||
query = savedInstanceState.getString(PluginBundleValues.BUNDLE_EXTRA_STRING_QUERY);
|
||||
values = savedInstanceState.getString(PluginBundleValues.BUNDLE_EXTRA_STRING_VALUES);
|
||||
updateActivity();
|
||||
}
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
ActionBar supportActionBar = getSupportActionBar();
|
||||
if (supportActionBar != null) {
|
||||
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
Drawable drawable = DrawableCompat.wrap(getResources().getDrawable(R.drawable.ic_close_24dp));
|
||||
DrawableCompat.setTint(drawable, getResources().getColor(android.R.color.white));
|
||||
supportActionBar.setHomeAsUpIndicator(drawable);
|
||||
supportActionBar.setDisplayShowTitleEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.filter_selection)
|
||||
void selectFilter() {
|
||||
startActivityForResult(new Intent(TaskerSettingsActivity.this, FilterSelectionActivity.class), REQUEST_SELECT_FILTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostCreateWithPreviousResult(final Bundle previousBundle, final String previousBlurb) {
|
||||
this.previousBundle = previousBundle;
|
||||
title = PluginBundleValues.getTitle(previousBundle);
|
||||
query = PluginBundleValues.getQuery(previousBundle);
|
||||
updateActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBundleValid(final Bundle bundle) {
|
||||
return PluginBundleValues.isBundleValid(bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle getResultBundle() {
|
||||
return PluginBundleValues.generateBundle(title, query, values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResultBlurb(final Bundle bundle) {
|
||||
return PluginBundleValues.getTitle(bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.tasker_menu, menu);
|
||||
MenuColorizer.colorMenu(this, menu, getResources().getColor(android.R.color.white));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_save:
|
||||
finish();
|
||||
break;
|
||||
case android.R.id.home:
|
||||
if (equalBundles(getResultBundle(), previousBundle)) {
|
||||
cancel();
|
||||
} else {
|
||||
new AlertDialog.Builder(this, R.style.TasksDialog)
|
||||
.setMessage(R.string.discard_changes)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
cancel();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cancel() {
|
||||
mIsCancelled = true;
|
||||
finish();
|
||||
}
|
||||
|
||||
private boolean equalBundles(Bundle one, Bundle two) {
|
||||
if (one == null) {
|
||||
return two == null;
|
||||
}
|
||||
if (two == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(one.size() != two.size())
|
||||
return false;
|
||||
|
||||
Set<String> setOne = one.keySet();
|
||||
Object valueOne;
|
||||
Object valueTwo;
|
||||
|
||||
for(String key : setOne) {
|
||||
valueOne = one.get(key);
|
||||
valueTwo = two.get(key);
|
||||
if(valueOne instanceof Bundle && valueTwo instanceof Bundle &&
|
||||
!equalBundles((Bundle) valueOne, (Bundle) valueTwo)) {
|
||||
return false;
|
||||
}
|
||||
else if(valueOne == null) {
|
||||
if(valueTwo != null || !two.containsKey(key))
|
||||
return false;
|
||||
}
|
||||
else if(!valueOne.equals(valueTwo))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == REQUEST_SELECT_FILTER) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
title = data.getStringExtra("extra_filter_name");
|
||||
query = data.getStringExtra("extra_filter_query");
|
||||
values = data.getStringExtra("extra_filter_values");
|
||||
updateActivity();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putParcelable(PluginBundleValues.BUNDLE_EXTRA_PREVIOUS_BUNDLE, previousBundle);
|
||||
outState.putString(PluginBundleValues.BUNDLE_EXTRA_STRING_TITLE, title);
|
||||
outState.putString(PluginBundleValues.BUNDLE_EXTRA_STRING_QUERY, query);
|
||||
outState.putString(PluginBundleValues.BUNDLE_EXTRA_STRING_VALUES, values);
|
||||
}
|
||||
|
||||
private void updateActivity() {
|
||||
((TextView) findViewById(R.id.text_view)).setText(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inject(ActivityComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package org.tasks.receivers;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.todoroo.andlib.sql.Query;
|
||||
import com.todoroo.astrid.api.AstridApiConstants;
|
||||
import com.todoroo.astrid.api.Filter;
|
||||
import com.todoroo.astrid.api.PermaSql;
|
||||
import com.todoroo.astrid.dao.TaskDao;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
|
||||
import org.tasks.BuildConfig;
|
||||
import org.tasks.analytics.Tracker;
|
||||
import org.tasks.injection.BroadcastComponent;
|
||||
import org.tasks.injection.ForApplication;
|
||||
import org.tasks.injection.InjectingBroadcastReceiver;
|
||||
import org.tasks.preferences.DefaultFilterProvider;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
@Singleton
|
||||
public class TeslaUnreadReceiver extends InjectingBroadcastReceiver {
|
||||
|
||||
private static final String TESLA_URI = "content://com.teslacoilsw.notifier/unread_count";
|
||||
private static final String TESLA_TAG = BuildConfig.APPLICATION_ID + "/com.todoroo.astrid.activity.TaskListActivity";
|
||||
|
||||
private final Context context;
|
||||
private final DefaultFilterProvider defaultFilterProvider;
|
||||
private final TaskDao taskDao;
|
||||
private final Tracker tracker;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
@Inject
|
||||
public TeslaUnreadReceiver(@ForApplication Context context, DefaultFilterProvider defaultFilterProvider,
|
||||
TaskDao taskDao, Tracker tracker) {
|
||||
this.context = context;
|
||||
this.defaultFilterProvider = defaultFilterProvider;
|
||||
this.taskDao = taskDao;
|
||||
this.tracker = tracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
super.onReceive(context, intent);
|
||||
|
||||
try {
|
||||
Filter defaultFilter = defaultFilterProvider.getDefaultFilter();
|
||||
String query = PermaSql.replacePlaceholders(defaultFilter.getSqlQuery());
|
||||
int count = taskDao.count(Query.select(Task.ID).withQueryTemplate(query));
|
||||
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put("tag", TESLA_TAG);
|
||||
contentValues.put("count", count);
|
||||
context.getContentResolver().insert(Uri.parse(TESLA_URI), contentValues);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
/* Fine, TeslaUnread is not installed. */
|
||||
} catch (Exception e) {
|
||||
Timber.e(e, e.getMessage());
|
||||
tracker.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inject(BroadcastComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean newValue) {
|
||||
try {
|
||||
if (newValue) {
|
||||
context.registerReceiver(this, new IntentFilter(AstridApiConstants.BROADCAST_EVENT_REFRESH));
|
||||
} else if (enabled) {
|
||||
context.unregisterReceiver(this);
|
||||
}
|
||||
enabled = newValue;
|
||||
} catch (Exception e) {
|
||||
Timber.e(e, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?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:orientation="vertical">
|
||||
|
||||
<include layout="@layout/toolbar"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/filter_selection"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:orientation="horizontal"
|
||||
android:padding="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="100"
|
||||
android:clickable="false"
|
||||
android:text="@string/filter"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="false"
|
||||
android:gravity="end"
|
||||
android:hint="@string/select_filter"
|
||||
android:textColorHint="@android:color/darker_gray"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/menu_save"
|
||||
android:title="@string/save"
|
||||
android:icon="@drawable/ic_save_24dp"
|
||||
app:showAsAction="always"/>
|
||||
</menu>
|
@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="gp_key">MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk8mXRE3dDXwtinUILCEzKjov2rxs3kZbLRzNrcjFWXpG9OEsUzRGLzqEN+WwibVuMRpZLj/+IxbU2sJWq/M0q+90rOhmXn46ZPeNyr77IqX2pWKIAWpzBoWq/mshRwtm9m1FIiGdBNlXrhSE7u3TGB5FuEuuSqKWvWzxeqQ7fHmlM04Lqrh1mN3FaMne8rWv+DWVHDbLrtnXBuC36glOAj17HxrzaE2v6Pv7Df3QefJ3rM1+0fAp/5jNInaP0qHAlG8WTbUmDShQ5kG3urbv3HLByyx6TSqhmNudXUK/6TusvIj50OptAG7x+UFYf956dD3diXhY3yoICvyFWx1sNwIDAQAB</string>
|
||||
<string name="sku_tasker">tasker</string>
|
||||
<string name="sku_tesla_unread">tesla_unread</string>
|
||||
</resources>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="select_filter">Select Filter</string>
|
||||
<string name="filter">Filter</string>
|
||||
<string name="discard_changes">Discard changes?</string>
|
||||
|
||||
</resources>
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M11.8,10.9c-2.27,-0.59 -3,-1.2 -3,-2.15 0,-1.09 1.01,-1.85 2.7,-1.85 1.78,0 2.44,0.85 2.5,2.1h2.21c-0.07,-1.72 -1.12,-3.3 -3.21,-3.81V3h-3v2.16c-1.94,0.42 -3.5,1.68 -3.5,3.61 0,2.31 1.91,3.46 4.7,4.13 2.5,0.6 3,1.48 3,2.41 0,0.69 -0.49,1.79 -2.7,1.79 -2.06,0 -2.87,-0.92 -2.98,-2.1h-2.2c0.12,2.19 1.76,3.42 3.68,3.83V21h3v-2.15c1.95,-0.37 3.5,-1.5 3.5,-3.55 0,-2.84 -2.43,-3.81 -4.7,-4.4z"/>
|
||||
</vector>
|
Loading…
Reference in New Issue