示例#1
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    // Get the item that was clicked
    NSDictionary item = (NSDictionary) getListAdapter().getItem(position);

    NSObject action;
    if ((action = item.objectForKey("subcontent")) != null) {
      NSArrayWrapper wrapper = new NSArrayWrapper((NSArray) action);

      Intent intent = new Intent(this, Info.class);
      intent.putExtra("class", this.getClass().getCanonicalName());
      intent.putExtra(
          "tracking", getIntent().getStringExtra("tracking") + "/" + item.objectForKey("title"));
      intent.putExtra("content", wrapper);
      startActivity(intent);

    } else if ((action = item.objectForKey("url")) != null
        || (action = item.objectForKey("url-android")) != null) {
      Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(((NSString) action).toString()));
      // Handle external activities as described in
      // http://developer.android.com/training/implementing-navigation/descendant.html#external-activities
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);

      // We can't call the code in the onCreate as we may be opening the play store, so track it
      // here.
      EasyTracker.getTracker()
          .sendView(getIntent().getStringExtra("tracking") + " > " + item.objectForKey("title"));
      Log.i(
          "Tracking", getIntent().getStringExtra("tracking") + " > " + item.objectForKey("title"));

      startActivity(intent);
    } else if ((action = item.objectForKey("html")) != null) {
      Intent intent = new Intent(this, InfoWebActivity.class);
      intent.putExtra("class", this.getClass().getCanonicalName());

      EasyTracker.getTracker()
          .sendView(getIntent().getStringExtra("tracking") + " > " + item.objectForKey("title"));
      Log.i(
          "Tracking", getIntent().getStringExtra("tracking") + " > " + item.objectForKey("title"));

      intent.putExtra("page", ((NSString) action).toString());
      startActivity(intent);
    } else if ((action = item.objectForKey("association")) != null) {
      Toast.makeText(
              this, "TODO: implement the association for " + action.toString(), Toast.LENGTH_SHORT)
          .show();
      System.err.println(action);
    } else {
      System.err.println("WHAT THE F**K IS THIS SHIT?");
    }
  }
  public static Optional<AppleSimulatorProfile> parseProfilePlistStream(InputStream inputStream)
      throws IOException {
    NSDictionary profile;
    try (BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)) {
      try {
        profile = (NSDictionary) PropertyListParser.parse(bufferedInputStream);
      } catch (Exception e) {
        throw new IOException(e);
      }
    }

    NSObject supportedProductFamilyIDsObject = profile.objectForKey("supportedProductFamilyIDs");
    if (!(supportedProductFamilyIDsObject instanceof NSArray)) {
      LOG.warn(
          "Invalid simulator profile.plist (supportedProductFamilyIDs missing or not an array)");
      return Optional.absent();
    }
    NSArray supportedProductFamilyIDs = (NSArray) supportedProductFamilyIDsObject;

    AppleSimulatorProfile.Builder profileBuilder = AppleSimulatorProfile.builder();
    for (NSObject supportedProductFamilyID : supportedProductFamilyIDs.getArray()) {
      if (supportedProductFamilyID instanceof NSNumber) {
        profileBuilder.addSupportedProductFamilyIDs(
            ((NSNumber) supportedProductFamilyID).intValue());
      } else {
        LOG.warn(
            "Invalid simulator profile.plist (supportedProductFamilyIDs contains non-number %s)",
            supportedProductFamilyID);
        return Optional.absent();
      }
    }

    NSObject supportedArchsObject = profile.objectForKey("supportedArchs");
    if (!(supportedArchsObject instanceof NSArray)) {
      LOG.warn("Invalid simulator profile.plist (supportedArchs missing or not an array)");
      return Optional.absent();
    }
    NSArray supportedArchs = (NSArray) supportedArchsObject;
    for (NSObject supportedArch : supportedArchs.getArray()) {
      profileBuilder.addSupportedArchitectures(supportedArch.toString());
    }

    return Optional.of(profileBuilder.build());
  }
  private ProvisioningProfile(File file, NSDictionary dict) {
    this.file = file;
    this.dict = dict;
    this.uuid = dict.objectForKey("UUID").toString();
    this.name = dict.objectForKey("Name").toString();
    this.appIdName =
        dict.objectForKey("AppIDName") != null ? dict.objectForKey("AppIDName").toString() : null;
    this.appIdPrefix =
        ((NSArray) dict.objectForKey("ApplicationIdentifierPrefix")).objectAtIndex(0).toString();
    this.creationDate = ((NSDate) dict.objectForKey("CreationDate")).getDate();
    this.expirationDate = ((NSDate) dict.objectForKey("ExpirationDate")).getDate();
    this.entitlements = (NSDictionary) dict.objectForKey("Entitlements");

    for (NSObject o : ((NSArray) dict.objectForKey("DeveloperCertificates")).getArray()) {
      NSData data = (NSData) o;
      certFingerprints.add(getCertFingerprint(data.bytes()));
    }
  }