Ejemplo n.º 1
0
  @Override
  public void onReceive(Context context, Intent intent) {
    DependencyInjectionService.getInstance().inject(this);
    ContextManager.setContext(context);
    tagService = TagService.getInstance();

    Resources r = context.getResources();
    ArrayList<FilterListItem> list = new ArrayList<FilterListItem>();

    // --- header
    FilterListHeader tagsHeader = new FilterListHeader(context.getString(R.string.tag_FEx_header));
    list.add(tagsHeader);

    // --- untagged
    Filter untagged =
        new Filter(
            r.getString(R.string.tag_FEx_untagged),
            r.getString(R.string.tag_FEx_untagged),
            tagService.untaggedTemplate(),
            null);
    untagged.listingIcon = ((BitmapDrawable) r.getDrawable(R.drawable.filter_untagged)).getBitmap();
    list.add(untagged);

    addTags(list);

    // transmit filter list
    FilterListItem[] listAsArray = list.toArray(new FilterListItem[list.size()]);
    Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_FILTERS);
    broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, listAsArray);
    broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, TagsPlugin.IDENTIFIER);
    context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
  }
Ejemplo n.º 2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ContextManager.setContext(this);
    addPreferencesFromResource(getPreferenceResource());
  }
Ejemplo n.º 3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    new StartupService().onStartupApplication(this);
    ContextManager.setContext(this);

    PreferenceScreen screen = getPreferenceScreen();
    voiceInputAssistant = new VoiceInputAssistant(this);

    addPluginPreferences(screen);

    screen.getPreference(POWER_PACK_PREFERENCE).setEnabled(addOnService.hasPowerPack());

    final Resources r = getResources();
    // About pref
    Preference preference = screen.getPreference(ABOUT_PREFERENCE);
    preference.setTitle(r.getString(R.string.p_about));
    preference.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {
          public boolean onPreferenceClick(Preference p) {
            showAbout();
            return true;
          }
        });

    addDebugPreferences();

    addPreferenceListeners();
  }
Ejemplo n.º 4
0
  @Override
  public void onReceive(Context context, Intent intent) {
    Resources r = context.getResources();
    ContextManager.setContext(context);

    FilterListItem[] list = prepareFilters(r);
    Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_FILTERS);
    broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, list);
    context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
  }
Ejemplo n.º 5
0
  @Override
  public void onReceive(Context context, Intent intent) {
    ContextManager.setContext(context);
    // if we aren't logged in, don't expose features
    if (!ProducteevUtilities.INSTANCE.isLoggedIn()) return;

    StoreObject[] dashboards = ProducteevDataService.getInstance().getDashboards();

    // If user does not have any dashboards, don't show this section at all
    if (dashboards.length == 0) return;

    FilterListHeader producteevHeader =
        new FilterListHeader(context.getString(R.string.producteev_FEx_header));

    long currentUserId = Preferences.getLong(ProducteevUtilities.PREF_USER_ID, -1);

    // load dashboards
    Filter[] dashboardFilters = new Filter[dashboards.length];
    for (int i = 0; i < dashboards.length; i++)
      dashboardFilters[i] =
          filterFromList(context, new ProducteevDashboard(dashboards[i]), currentUserId);
    FilterCategory producteevDashboards =
        new FilterCategory(context.getString(R.string.producteev_FEx_dashboard), dashboardFilters);

    // load responsible people, assigned by me
    TreeSet<ProducteevUser> people = loadResponsiblePeople(dashboards);
    Filter[] peopleByMeFilters = new Filter[people.size()];
    int index = 0;
    for (ProducteevUser person : people)
      peopleByMeFilters[index++] = filterUserAssignedByMe(context, person, currentUserId);
    FilterCategory producteevUsersByMeCategory =
        new FilterCategory(
            context.getString(R.string.producteev_FEx_responsible_byme), peopleByMeFilters);

    // load responsible people, assigned by others
    Filter[] peopleByOthersFilters = new Filter[people.size()];
    index = 0;
    for (ProducteevUser person : people)
      peopleByOthersFilters[index++] = filterUserAssignedByOthers(context, person, currentUserId);
    FilterCategory producteevUsersByOthersCategory =
        new FilterCategory(
            context.getString(R.string.producteev_FEx_responsible_byothers), peopleByOthersFilters);

    // transmit filter list
    FilterListItem[] list = new FilterListItem[4];
    list[0] = producteevHeader;
    list[1] = producteevDashboards;
    list[2] = producteevUsersByMeCategory;
    list[3] = producteevUsersByOthersCategory;
    Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_FILTERS);
    broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, ProducteevUtilities.IDENTIFIER);
    broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, list);
    context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
  }
Ejemplo n.º 6
0
 @Override
 public void onStart(final Intent intent, int startId) {
   ContextManager.setContext(this);
   new Thread(
           new Runnable() {
             @Override
             public void run() {
               startServiceInBackgroundThread(intent);
             }
           })
       .start();
 }
Ejemplo n.º 7
0
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

    try {
      ContextManager.setContext(context);
      super.onUpdate(context, appWidgetManager, appWidgetIds);

      // Start in service to prevent Application Not Responding timeout
      updateWidgets(context);
    } catch (Exception e) {
      Log.e("astrid-update-widget", "widget update error", e); // $NON-NLS-1$ //$NON-NLS-2$
    }
  }
  @Override
  public void onReceive(Context context, Intent intent) {
    ContextManager.setContext(context);
    DependencyInjectionService.getInstance().inject(this);
    long taskId = intent.getLongExtra(AstridApiConstants.EXTRAS_TASK_ID, -1);
    if (taskId == -1) return;

    Task task = PluginServices.getTaskService().fetchById(taskId, Task.PROPERTIES);
    if (task == null || !task.isCompleted()) return;

    String recurrence = task.getValue(Task.RECURRENCE);
    if (recurrence != null && recurrence.length() > 0) {
      long newDueDate;
      try {
        newDueDate = computeNextDueDate(task, recurrence);
        if (newDueDate == -1) return;
      } catch (ParseException e) {
        PluginServices.getExceptionService().reportError("repeat-parse", e); // $NON-NLS-1$
        return;
      }

      StatisticsService.reportEvent(StatisticsConstants.V2_TASK_REPEAT);

      long oldDueDate = task.getValue(Task.DUE_DATE);
      long repeatUntil = task.getValue(Task.REPEAT_UNTIL);

      boolean repeatFinished = repeatUntil > 0 && newDueDate >= repeatUntil;
      if (repeatFinished) {
        Intent repeatFinishedIntent =
            new Intent(AstridApiConstants.BROADCAST_EVENT_TASK_REPEAT_FINISHED);
        repeatFinishedIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, task.getId());
        repeatFinishedIntent.putExtra(AstridApiConstants.EXTRAS_OLD_DUE_DATE, oldDueDate);
        repeatFinishedIntent.putExtra(AstridApiConstants.EXTRAS_NEW_DUE_DATE, newDueDate);
        context.sendOrderedBroadcast(repeatFinishedIntent, null);
        return;
      }

      rescheduleTask(task, newDueDate);

      // send a broadcast
      Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_TASK_REPEATED);
      broadcastIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, task.getId());
      broadcastIntent.putExtra(AstridApiConstants.EXTRAS_OLD_DUE_DATE, oldDueDate);
      broadcastIntent.putExtra(AstridApiConstants.EXTRAS_NEW_DUE_DATE, newDueDate);
      context.sendOrderedBroadcast(broadcastIntent, null);
      Flags.set(Flags.REFRESH);
      return;
    }
  }
Ejemplo n.º 9
0
  @Override
  /** Alarm intent */
  public void onReceive(Context context, Intent intent) {
    ContextManager.setContext(context);

    long id = intent.getLongExtra(ID_KEY, 0);
    int type = intent.getIntExtra(TYPE_KEY, (byte) 0);

    Resources r = context.getResources();
    String reminder;

    if (type == ReminderService.TYPE_ALARM)
      reminder = getRandomReminder(r.getStringArray(R.array.reminders_alarm));
    else if (Preferences.getBoolean(R.string.p_rmd_nagging, true)) {
      if (type == ReminderService.TYPE_DUE || type == ReminderService.TYPE_OVERDUE)
        reminder = getRandomReminder(r.getStringArray(R.array.reminders_due));
      else if (type == ReminderService.TYPE_SNOOZE)
        reminder = getRandomReminder(r.getStringArray(R.array.reminders_snooze));
      else reminder = getRandomReminder(r.getStringArray(R.array.reminders));
    } else reminder = ""; // $NON-NLS-1$

    synchronized (Notifications.class) {
      if (notificationManager == null)
        notificationManager = new AndroidNotificationManager(context);
    }

    if (!showTaskNotification(id, type, reminder)) {
      notificationManager.cancel((int) id);
    }

    try {
      VoiceOutputService.getVoiceOutputInstance().onDestroy();
    } catch (VerifyError e) {
      // unavailable
    }
  }
Ejemplo n.º 10
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    new StartupService().onStartupApplication(this);
    ContextManager.setContext(this);

    PreferenceScreen screen = getPreferenceScreen();
    voiceInputAssistant = new VoiceInputAssistant(this);

    addPluginPreferences(screen);

    screen.getPreference(POWER_PACK_PREFERENCE).setEnabled(addOnService.hasPowerPack());

    final Resources r = getResources();

    // first-order preferences
    Preference preference = screen.findPreference(getString(R.string.p_about));
    preference.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {
          public boolean onPreferenceClick(Preference p) {
            showAbout();
            return true;
          }
        });

    preference = screen.findPreference(getString(R.string.p_tutorial));
    preference.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {
          @Override
          public boolean onPreferenceClick(Preference p) {
            Intent showWelcomeLogin = new Intent(EditPreferences.this, WelcomeWalkthrough.class);
            showWelcomeLogin.putExtra(ActFmLoginActivity.SHOW_TOAST, false);
            showWelcomeLogin.putExtra(WelcomeWalkthrough.TOKEN_MANUAL_SHOW, true);
            startActivity(showWelcomeLogin);
            return true;
          }
        });

    preference = screen.findPreference(getString(R.string.p_help));
    preference.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {
          @Override
          public boolean onPreferenceClick(Preference p) {
            showSupport();
            return true;
          }
        });

    preference = screen.findPreference(getString(R.string.p_forums));
    preference.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {
          @Override
          public boolean onPreferenceClick(Preference p) {
            showForums();
            return true;
          }
        });

    PreferenceCategory appearance =
        (PreferenceCategory) screen.getPreference(APPEARANCE_PREFERENCE);
    Preference beastMode = appearance.getPreference(1);
    beastMode.setTitle(r.getString(R.string.EPr_beastMode_title));
    beastMode.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {
          @Override
          public boolean onPreferenceClick(Preference p) {
            showBeastMode();
            return true;
          }
        });

    addDebugPreferences();

    addPreferenceListeners();
  }
Ejemplo n.º 11
0
 @Override
 public boolean onCreate() {
   ctx = getContext();
   ContextManager.setContext(ctx);
   return false;
 }
Ejemplo n.º 12
0
  /** Called when this application is started up */
  public synchronized void onStartupApplication(final Activity context) {
    if (hasStartedUp || context == null) {
      return;
    }

    // sets up context manager
    ContextManager.setContext(context);

    try {
      database.openForWriting();
      checkForMissingColumns();
    } catch (SQLiteException e) {
      handleSQLiteError(context, e);
      return;
    }

    // show notification if reminders are silenced
    if (context instanceof Activity) {
      AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
      if (!Preferences.getBoolean(R.string.p_rmd_enabled, true)) {
        Toast.makeText(context, R.string.TLA_notification_disabled, Toast.LENGTH_LONG).show();
      } else if (audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION) == 0) {
        Toast.makeText(context, R.string.TLA_notification_volume_low, Toast.LENGTH_LONG).show();
      }
    }

    // read current version
    int latestSetVersion = 0;
    try {
      latestSetVersion = AstridPreferences.getCurrentVersion();
    } catch (Exception e) {
      exceptionService.reportError("astrid-startup-version-read", e); // $NON-NLS-1$
    }

    if (latestSetVersion == 0) {
      if (Preferences.getLong(AstridPreferences.P_FIRST_LAUNCH, -1) < 0) {
        Preferences.setLong(AstridPreferences.P_FIRST_LAUNCH, DateUtilities.now());
      }
    }

    BeastModePreferences.assertHideUntilSectionExists(context, latestSetVersion);

    int version = 0;
    String versionName = "0"; // $NON-NLS-1$
    try {
      PackageManager pm = context.getPackageManager();
      PackageInfo pi = pm.getPackageInfo(Constants.PACKAGE, PackageManager.GET_META_DATA);
      version = pi.versionCode;
      versionName = pi.versionName;
    } catch (Exception e) {
      exceptionService.reportError("astrid-startup-package-read", e); // $NON-NLS-1$
    }

    Log.i(
        "astrid",
        "Astrid Startup. "
            + latestSetVersion
            + //$NON-NLS-1$ //$NON-NLS-2$
            " => "
            + version); //$NON-NLS-1$

    databaseRestoreIfEmpty(context);

    // invoke upgrade service
    boolean justUpgraded = latestSetVersion != version;
    if (justUpgraded && version > 0) {
      if (latestSetVersion > 0) {
        upgradeService.performUpgrade(context, latestSetVersion);
      }
      AstridPreferences.setCurrentVersion(version);
      AstridPreferences.setCurrentVersionName(versionName);
    }

    final int finalLatestVersion = latestSetVersion;

    initializeDatabaseListeners();

    // perform startup activities in a background thread
    new Thread(
            new Runnable() {
              @Override
              public void run() {
                taskService.cleanup();

                // if sync ongoing flag was set, clear it
                gtasksPreferenceService.stopOngoing();

                // perform initialization
                ReminderStartupReceiver.startReminderSchedulingService(context);
                BackupService.scheduleService(context);

                gtasksSyncService.initialize();

                // get and display update messages
                if (finalLatestVersion != 0) {
                  //                    new UpdateMessageService(context).processUpdates();
                }
              }
            })
        .start();

    AstridPreferences.setPreferenceDefaults();
    CalendarStartupReceiver.scheduleCalendarAlarms(
        context,
        false); // This needs to be after set preference defaults for the purposes of ab testing

    showTaskKillerHelp(context);

    hasStartedUp = true;
  }