Ejemplo n.º 1
0
        @Override
        public boolean onPreferenceClick(Preference preference) {
          String exportStr;
          try {
            exportStr = Parser.serializeSync(Preferences.exportToMessage());
          } catch (JsonProcessingException e) {
            Toast.makeText(context, R.string.preferencesExportFailed, Toast.LENGTH_SHORT).show();
            e.printStackTrace();
            return false;
          }

          if (exportStr == null) return false;

          Log.v("Export", "Config: \n" + exportStr);
          File cDir = App.getInstance().getBaseContext().getCacheDir();
          File tempFile = new File(cDir.getPath() + "/" + TEMP_FILE_NAME);

          try {
            FileWriter writer = new FileWriter(tempFile);

            writer.write(exportStr);
            writer.close();

            Log.v(TAG, "Saved temporary config file for exportToMessage to " + tempFile.getPath());

          } catch (IOException e) {
            e.printStackTrace();
          }
          Uri configUri =
              FileProvider.getUriForFile(
                  App.getInstance(), "org.owntracks.android.fileprovider", tempFile);

          Intent sendIntent = new Intent();
          sendIntent.setAction(Intent.ACTION_SEND);
          sendIntent.putExtra(Intent.EXTRA_STREAM, configUri);
          sendIntent.setType("text/plain");

          context.startActivity(
              Intent.createChooser(sendIntent, context.getString(R.string.exportConfiguration)));
          Toast.makeText(context, R.string.preferencesExportSuccess, Toast.LENGTH_SHORT).show();

          return false;
        }
Ejemplo n.º 2
0
 // For outgoing messages
 public LocationMessage(GeocodableLocation l) {
   super();
   this.location = l;
   this.battery = Preferences.getPubLocationIncludeBattery() ? App.getBatteryLevel() : -1;
   ;
   this.waypoint = null;
   this.supressesTicker = false;
   this.trackerId = null;
   this.trigger = null;
   this.trackerId = Preferences.getTrackerId(true);
 }
Ejemplo n.º 3
0
  protected final ActivityComponent activityComponent() {
    if (mActivityComponent == null) {
      mActivityComponent =
          DaggerActivityComponent.builder()
              .appComponent(App.getAppComponent())
              .activityModule(new ActivityModule(this))
              .build();
    }

    return mActivityComponent;
  }