コード例 #1
0
 @Override
 public void finish() {
   if (!lvPackages.isEnabled()) {
     // if the list is not enabled, we don't want to save settings
     super.finish();
     return;
   }
   save();
   super.finish();
 }
コード例 #2
0
  @Override
  public void onResume() {
    super.onResume();
    if (mode == Mode.STANDARD) {
      sharedPreferences =
          getSharedPreferences(
              Constants.LOG_TAG + "_preferences", MODE_MULTI_PROCESS | MODE_PRIVATE);
      if (sharedPreferences.getBoolean(Constants.PREFERENCE_TASKER_SET, false)) {
        tvTaskerNotice.setVisibility(View.VISIBLE);
      }
      spMode.setSelection(
          sharedPreferences.getInt(Constants.PREFERENCE_MODE, Constants.Mode.OFF.ordinal()));

      // legacy preference handler
      if (sharedPreferences.contains(Constants.PREFERENCE_EXCLUDE_MODE)) {
        if (sharedPreferences.getBoolean(Constants.PREFERENCE_EXCLUDE_MODE, false)) {
          spMode.setSelection(Constants.Mode.INCLUDE.ordinal());
        } else {
          spMode.setSelection(Constants.Mode.EXCLUDE.ordinal());
        }
      }
    } else if (mode == Mode.LOCALE) {
      if (localeBundle != null) {
        spMode.setSelection(
            localeBundle.getInt(Constants.BUNDLE_EXTRA_INT_MODE, Constants.Mode.OFF.ordinal()));
      }
    }
    checkAccessibilityService();

    if (findViewById(R.id.listPackages).isEnabled()) {
      new LoadAppsTask().execute();
    }
  }
コード例 #3
0
  @Override
  public void finish() {
    if (!isCanceled()) {
      final String message = ((EditText) findViewById(android.R.id.text1)).getText().toString();

      if (message.length() > 0) {
        final Intent resultIntent = new Intent();

        /*
         * This extra is the data to ourselves: either for the Activity or the BroadcastReceiver. Note
         * that anything placed in this Bundle must be available to Locale's class loader. So storing
         * String, int, and other standard objects will work just fine. Parcelable objects are not
         * acceptable, unless they also implement Serializable. Serializable objects must be standard
         * Android platform objects (A Serializable class private to this plug-in's APK cannot be
         * stored in the Bundle, as Locale's classloader will not recognize it).
         */
        final Bundle resultBundle =
            PluginBundleManager.generateBundle(getApplicationContext(), message);
        resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE, resultBundle);

        /*
         * The blurb is concise status text to be displayed in the host's UI.
         */
        final String blurb = generateBlurb(getApplicationContext(), message);
        resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB, blurb);

        setResult(RESULT_OK, resultIntent);
      }
    }

    super.finish();
  }
コード例 #4
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   super.onCreateOptionsMenu(menu);
   MenuInflater menuInflater = getMenuInflater();
   menuInflater.inflate(R.menu.activity_edit_notifications, menu);
   if (mode == Mode.LOCALE) {
     menu.removeItem(R.id.btnSettings);
   }
   return true;
 }
コード例 #5
0
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    BundleScrubber.scrub(getIntent());

    final Bundle localeBundle =
        getIntent().getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE);
    BundleScrubber.scrub(localeBundle);

    setContentView(R.layout.main);

    if (null == savedInstanceState) {
      if (PluginBundleManager.isBundleValid(localeBundle)) {
        final String message =
            localeBundle.getString(PluginBundleManager.BUNDLE_EXTRA_STRING_MESSAGE);
        ((EditText) findViewById(android.R.id.text1)).setText(message);
      }
    }
  }
コード例 #6
0
ファイル: EditActivity.java プロジェクト: jamorham/xDrip-plus
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    BundleScrubber.scrub(getIntent());

    final Bundle localeBundle =
        getIntent().getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE);
    BundleScrubber.scrub(localeBundle);

    setContentView(R.layout.activity_tasker_edit);

    if (null == savedInstanceState) {
      if (PluginBundleManager.isBundleValid(localeBundle)) {
        String message = localeBundle.getString(PluginBundleManager.BUNDLE_EXTRA_STRING_MESSAGE);
        if (message.length() == 0) {
          message = "%par1"; // First tasker parameter
        }
        ((EditText) findViewById(R.id.editTextTasker)).setText(message);
      }
    }
  }
コード例 #7
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_notification);

    lvPackages = (ListView) findViewById(R.id.listPackages);
    spMode = (Spinner) findViewById(R.id.spMode);
    tvTaskerNotice = (TextView) findViewById(R.id.tvTaskerNotice);
    findViewById(R.id.tvAccessibilityError)
        .setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS));
              }
            });

    ArrayAdapter<CharSequence> adapter =
        ArrayAdapter.createFromResource(
            this, R.array.mode_choices, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spMode.setAdapter(adapter);
    spMode.setOnItemSelectedListener(
        new OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            mMode = Constants.Mode.values()[pos];
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {
            mMode = Constants.Mode.OFF;
            if (Constants.IS_LOGGABLE) {
              Log.i(Constants.LOG_TAG, "Mode is: off");
            }
          }
        });
  }
コード例 #8
0
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   save();
   super.onSaveInstanceState(outState);
 }