Ejemplo n.º 1
0
 public String getPageContents() {
   StringBuffer buffer = new StringBuffer();
   SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd");
   buffer
       .append("== {{int:filedesc}} ==\n")
       .append("{{Information\n")
       .append("|description=")
       .append(description)
       .append("\n")
       .append("|source=")
       .append("{{own}}\n")
       .append("|author=[[User:"******"]]\n");
   if (dateCreated != null) {
     buffer
         .append("|date={{According to EXIF data|")
         .append(isoFormat.format(dateCreated))
         .append("}}\n");
   }
   buffer
       .append("}}")
       .append("\n")
       .append("== {{int:license-header}} ==\n")
       .append("{{self|cc-by-sa-3.0}}\n\n")
       .append("{{Uploaded from Mobile|platform=Android|version=")
       .append(CommonsApplication.APPLICATION_VERSION)
       .append("}}\n")
       .append("{{subst:unc}}"); // Remove when we have categorization
   return buffer.toString();
 }
Ejemplo n.º 2
0
  private boolean obbIsCorrupted(String f, String main_pack_md5) {

    try {

      InputStream fis = new FileInputStream(f);

      // Create MD5 Hash
      byte[] buffer = new byte[16384];

      MessageDigest complete = MessageDigest.getInstance("MD5");
      int numRead;
      do {
        numRead = fis.read(buffer);
        if (numRead > 0) {
          complete.update(buffer, 0, numRead);
        }
      } while (numRead != -1);

      fis.close();
      byte[] messageDigest = complete.digest();

      // Create Hex String
      StringBuffer hexString = new StringBuffer();
      for (int i = 0; i < messageDigest.length; i++) {
        String s = Integer.toHexString(0xFF & messageDigest[i]);

        if (s.length() == 1) {
          s = "0" + s;
        }
        hexString.append(s);
      }
      String md5str = hexString.toString();

      // Log.d("GODOT","**PACK** - My MD5: "+hexString+" - APK md5: "+main_pack_md5);
      if (!md5str.equals(main_pack_md5)) {
        Log.d(
            "GODOT",
            "**PACK MD5 MISMATCH???** - MD5 Found: "
                + md5str
                + " "
                + Integer.toString(md5str.length())
                + " - MD5 Expected: "
                + main_pack_md5
                + " "
                + Integer.toString(main_pack_md5.length()));
        return true;
      }
      return false;
    } catch (Exception e) {
      e.printStackTrace();
      Log.d("GODOT", "**PACK FAIL**");
      return true;
    }
  }