public void handleIntent(Intent intent) {
   if (intent == null) {
     return;
   }
   try {
     Intent firstIntent = getIntent();
     int type = intent.getIntExtra("ntype", 0);
     ;
     switch (type) {
       case ENotification.F_TYPE_PUSH:
         if (null != mBrowser) {
           String data = intent.getStringExtra("data");
           String pushMessage = intent.getStringExtra("message");
           SharedPreferences sp =
               getSharedPreferences(PushReportConstants.PUSH_DATA_SHAREPRE, Context.MODE_PRIVATE);
           Editor editor = sp.edit();
           editor.putString(PushReportConstants.PUSH_DATA_SHAREPRE_DATA, data);
           editor.putString(PushReportConstants.PUSH_DATA_SHAREPRE_MESSAGE, pushMessage);
           editor.commit();
           mBrowser.pushNotify();
         }
         break;
       case ENotification.F_TYPE_USER:
         break;
       case ENotification.F_TYPE_SYS:
         break;
       default:
         getIntentData(intent);
         firstIntent.putExtras(intent);
         break;
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
예제 #2
0
  protected void onListItemClick(ListView l, View v, int position, long id) {
    ProfilerAudioAdapter profileAudioAdapter = (ProfilerAudioAdapter) getListAdapter();
    String selectedValue = profileAudioAdapter.getItem(position);
    Toast.makeText(this, selectedValue, Toast.LENGTH_SHORT).show();

    GetFile task = new GetFile();
    String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
    File folder = new File(extStorageDirectory, "Audio");
    folder.mkdir();
    ArrayList<String> params = new ArrayList<String>();
    params.add(fileLocation[position]);
    params.add(fileName[position]);
    params.add(String.valueOf(folder));
    task.execute(new ArrayList[] {params});

    try {
      Intent intent = new Intent();
      intent.setAction(Intent.ACTION_VIEW);
      File fileToRead = new File(folder + "/" + fileName[position]);
      Uri uri = Uri.fromFile(fileToRead.getAbsoluteFile());
      intent.setDataAndType(uri, "audio/mp3");
      startActivity(intent);
    } catch (ActivityNotFoundException activityNotFoundException) {
      activityNotFoundException.printStackTrace();
      Toast.makeText(this, "There doesn't seem to be an Audio player installed.", Toast.LENGTH_LONG)
          .show();
    } catch (Exception ex) {
      ex.printStackTrace();
      Toast.makeText(this, "Cannot open the selected file.", Toast.LENGTH_LONG).show();
    }
  }
예제 #3
0
  // EGL functions
  public static boolean initEGL(int majorVersion, int minorVersion, int[] attribs) {
    try {
      if (SDLActivity.mEGLDisplay == null) {
        Log.v("SDL", "Starting up OpenGL ES " + majorVersion + "." + minorVersion);

        EGL10 egl = (EGL10) EGLContext.getEGL();

        EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

        int[] version = new int[2];
        egl.eglInitialize(dpy, version);

        EGLConfig[] configs = new EGLConfig[1];
        int[] num_config = new int[1];
        if (!egl.eglChooseConfig(dpy, attribs, configs, 1, num_config) || num_config[0] == 0) {
          Log.e("SDL", "No EGL config available");
          return false;
        }
        EGLConfig config = configs[0];

        SDLActivity.mEGLDisplay = dpy;
        SDLActivity.mEGLConfig = config;
        SDLActivity.mGLMajor = majorVersion;
        SDLActivity.mGLMinor = minorVersion;
      }
      return SDLActivity.createEGLSurface();

    } catch (Exception e) {
      Log.v("SDL", e + "");
      for (StackTraceElement s : e.getStackTrace()) {
        Log.v("SDL", s.toString());
      }
      return false;
    }
  }
예제 #4
0
파일: D4.java 프로젝트: sarekautowerke/D4
  public List parsePage(String pageCode) {
    List sections = new ArrayList();
    List folders = new ArrayList();
    List files = new ArrayList();
    int start = pageCode.indexOf("<div id=\"list-view\" class=\"view\"");
    int end = pageCode.indexOf("<div id=\"gallery-view\" class=\"view\"");
    String usefulSection = "";
    if (start != -1 && end != -1) {
      usefulSection = pageCode.substring(start, end);
    } else {
      debug("Could not parse page");
    }
    try {
      DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      InputSource is = new InputSource();
      is.setCharacterStream(new StringReader(usefulSection));
      Document doc = db.parse(is);

      NodeList divs = doc.getElementsByTagName("div");
      for (int i = 0; i < divs.getLength(); i++) {
        Element div = (Element) divs.item(i);
        boolean isFolder = false;
        if (div.getAttribute("class").equals("filename")) {
          NodeList imgs = div.getElementsByTagName("img");
          for (int j = 0; j < imgs.getLength(); j++) {
            Element img = (Element) imgs.item(j);
            if (img.getAttribute("class").indexOf("folder") > 0) {
              isFolder = true;
            } else {
              isFolder = false; // it's a file
            }
          }

          NodeList anchors = div.getElementsByTagName("a");
          Element anchor = (Element) anchors.item(0);
          String attr = anchor.getAttribute("href");
          String fileName = anchor.getAttribute("title");
          String fileURL;
          if (isFolder && !attr.equals("#")) {
            folders.add(attr);
            folders.add(fileName);
          } else if (!isFolder && !attr.equals("#")) {
            // Dropbox uses ajax to get the file for download, so the url isn't enough. We must be
            // sneaky here.
            fileURL = "https://dl.dropbox.com" + attr.substring(23) + "?dl=1";
            files.add(fileURL);
            files.add(fileName);
          }
        }
      }
    } catch (Exception e) {
      debug(e.toString());
    }

    sections.add(files);
    sections.add(folders);

    return sections;
  }
예제 #5
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;
    }
  }
예제 #6
0
  private Bitmap getVideoDrawable(String path) throws OutOfMemoryError {

    try {
      Bitmap thumb =
          ThumbnailUtils.createVideoThumbnail(path, MediaStore.Images.Thumbnails.MINI_KIND);
      return thumb;
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
예제 #7
0
파일: D4.java 프로젝트: sarekautowerke/D4
 public String getData(String url) {
   HttpClient client = new DefaultHttpClient();
   HttpGet get = new HttpGet(url);
   String response = "";
   try {
     ResponseHandler<String> responseHandler = new BasicResponseHandler();
     response = client.execute(get, responseHandler);
   } catch (Exception e) {
     debug(e.toString());
   }
   return response;
 }
  public String ReadFileContents(File fileToHandle) {
    String output = "";
    try {
      BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(fileToHandle));
      while (inputStream.available() > 0) {
        output = output + (char) inputStream.read();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    return output;
  }
예제 #9
0
 private void sendExceptionMsg(int what, Exception e) {
   e.printStackTrace();
   Message msg = Message.obtain();
   msg.obj = e;
   msg.what = what;
   queryHandler.sendMessage(msg);
 }
예제 #10
0
  public static void reconnect1() {
    try {
      List<WifiConfiguration> list = wifiManager.getConfiguredNetworks();
      for (WifiConfiguration i : list) {
        if (i.SSID.equals(FirstSettings_two.first_ssid)) {
          wifiManager.enableNetwork(i.networkId, true);
          wifiManager.reconnect();

          break;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    ;
  }
예제 #11
0
  private String[] getCommandLine() {
    InputStream is;
    try {
      is = getAssets().open("_cl_");
      byte[] len = new byte[4];
      int r = is.read(len);
      if (r < 4) {
        Log.d("XXX", "**ERROR** Wrong cmdline length.\n");
        Log.d("GODOT", "**ERROR** Wrong cmdline length.\n");
        return new String[0];
      }
      int argc =
          ((int) (len[3] & 0xFF) << 24)
              | ((int) (len[2] & 0xFF) << 16)
              | ((int) (len[1] & 0xFF) << 8)
              | ((int) (len[0] & 0xFF));
      String[] cmdline = new String[argc];

      for (int i = 0; i < argc; i++) {
        r = is.read(len);
        if (r < 4) {

          Log.d("GODOT", "**ERROR** Wrong cmdline param lenght.\n");
          return new String[0];
        }
        int strlen =
            ((int) (len[3] & 0xFF) << 24)
                | ((int) (len[2] & 0xFF) << 16)
                | ((int) (len[1] & 0xFF) << 8)
                | ((int) (len[0] & 0xFF));
        if (strlen > 65535) {
          Log.d("GODOT", "**ERROR** Wrong command len\n");
          return new String[0];
        }
        byte[] arg = new byte[strlen];
        r = is.read(arg);
        if (r == strlen) {
          cmdline[i] = new String(arg, "UTF-8");
        }
      }
      return cmdline;
    } catch (Exception e) {
      e.printStackTrace();
      Log.d("GODOT", "**ERROR** Exception " + e.getClass().getName() + ":" + e.getMessage());
      return new String[0];
    }
  }
예제 #12
0
 public void reconnect5() {
   try {
     List<WifiConfiguration> list = wifiManager.getConfiguredNetworks();
     for (WifiConfiguration i : list) {
       if (i.SSID.equals(FirstSettings_two.first_ssid)) {
         wifiManager.enableNetwork(i.networkId, true);
         wifiManager.reconnect();
         File_Video downloadFile_video = new File_Video();
         downloadFile_video.execute(BroadcastNewSms.filepath);
         break;
       }
     }
   } catch (Exception e) {
     Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG).show();
   }
   ;
 }
예제 #13
0
 @Override
 protected void onPostExecute(String result) {
   try {
     if (result.equals("Downloaded")) {
       Toast.makeText(getApplicationContext(), "Загрузка видео завершена", Toast.LENGTH_LONG)
           .show();
       play();
       Toast.makeText(getApplicationContext(), "отключение Wi-Fi", Toast.LENGTH_LONG).show();
       disconnect();
     } else {
       Toast.makeText(getApplicationContext(), "Ошибка с загрузкой видео", Toast.LENGTH_LONG)
           .show();
     }
   } catch (Exception e) {
     Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG)
         .show();
   }
 }
예제 #14
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.receiver);

    final Button cancelbtn = (Button) findViewById(R.id.ButtonCancel);
    // cancelbtn.setEnabled(false);
    cancelbtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // streamtask.cancel(true);
            finish();
          }
        });

    try {
      Intent intent = getIntent();
      String action = intent.getAction();
      String type = intent.getType();

      if ((!(Intent.ACTION_SEND.equals(action))) || (type == null)) {
        throw new RuntimeException("Unknown intent action or type");
      }

      if (!("text/plain".equals(type))) {
        throw new RuntimeException("Type is not text/plain");
      }

      String extra = intent.getStringExtra(Intent.EXTRA_TEXT);
      if (extra == null) {
        throw new RuntimeException("Cannot get shared text");
      }

      final DownloadStreamTask streamtask = new DownloadStreamTask(this);

      //	Once created, a task is executed very simply:
      streamtask.execute(extra);

    } catch (Exception e) {
      Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
    }
  }
예제 #15
0
 private void exitByDoubleClick() {
   try {
     long cTime = System.currentTimeMillis();
     if (cTime - lastBackClickTime > 2000) {
       if (toast != null) {
         toast.cancel();
       }
       lastBackClickTime = cTime;
       (toast = Toast.makeText(this, "再按一次退出程序", Toast.LENGTH_SHORT)).show();
     } else {
       if (toast != null) {
         toast.cancel();
       }
       exit();
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
예제 #16
0
 public void mOnClick(View v) {
   switch (v.getId()) {
     case R.id.test:
       String rootdir = Environment.getRootDirectory().getAbsolutePath();
       String datadir = Environment.getDataDirectory().getAbsolutePath();
       String cachedir = Environment.getDownloadCacheDirectory().getAbsolutePath();
       mEdit.setText(
           String.format(
               "ext = %s\nroot=%s\ndata=%s\ncache=%s", mSdPath, rootdir, datadir, cachedir));
       break;
     case R.id.save:
       File dir = new File(mSdPath + "/dir");
       dir.mkdir();
       File file = new File(mSdPath + "/dir/file.txt");
       try {
         FileOutputStream fos = new FileOutputStream(file);
         String str = "This file exists in SDcard";
         fos.write(str.getBytes());
         fos.close();
         mEdit.setText("write success");
       } catch (FileNotFoundException e) {
         mEdit.setText("File Not Found." + e.getMessage());
       } catch (SecurityException e) {
         mEdit.setText("Security Exception");
       } catch (Exception e) {
         mEdit.setText(e.getMessage());
       }
       break;
     case R.id.load:
       try {
         FileInputStream fis = new FileInputStream(mSdPath + "/dir/file.txt");
         byte[] data = new byte[fis.available()];
         while (fis.read(data) != -1) {;
         }
         fis.close();
         mEdit.setText(new String(data));
       } catch (FileNotFoundException e) {
         mEdit.setText("File Not Found");
       } catch (Exception e) {;
       }
       break;
   }
 }
예제 #17
0
  // EGL buffer flip
  public static void flipEGL() {
    try {
      EGL10 egl = (EGL10) EGLContext.getEGL();

      egl.eglWaitNative(EGL10.EGL_CORE_NATIVE_ENGINE, null);

      // drawing here

      egl.eglWaitGL();

      egl.eglSwapBuffers(SDLActivity.mEGLDisplay, SDLActivity.mEGLSurface);

    } catch (Exception e) {
      Log.v("SDL", "flipEGL(): " + e);
      for (StackTraceElement s : e.getStackTrace()) {
        Log.v("SDL", s.toString());
      }
    }
  }
예제 #18
0
파일: D4.java 프로젝트: sarekautowerke/D4
  public void downloadFile(String url, String savePath, String fileName) {

    try {
      URL theURL = new URL(url);
      InputStream input = theURL.openStream();
      OutputStream output = new FileOutputStream(new File(savePath, fileName));
      try {
        byte[] buffer = new byte[1024];
        int bytesRead = 0;
        while ((bytesRead = input.read(buffer, 0, buffer.length)) >= 0) {
          output.write(buffer, 0, bytesRead);
        }
      } catch (Exception e) {
        debug(e.toString());
      } finally {
        output.close();
      }
    } catch (Exception e) {
      debug(e.toString());
    }
  }
예제 #19
0
  /** This method is called by SDL using JNI. */
  public InputStream openAPKExtensionInputStream(String fileName) throws IOException {
    // Get a ZipResourceFile representing a merger of both the main and patch files
    if (expansionFile == null) {
      Integer mainVersion =
          Integer.valueOf(nativeGetHint("SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION"));
      Integer patchVersion =
          Integer.valueOf(nativeGetHint("SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION"));

      try {
        // To avoid direct dependency on Google APK extension library that is
        // not a part of Android SDK we access it using reflection
        expansionFile =
            Class.forName("com.android.vending.expansion.zipfile.APKExpansionSupport")
                .getMethod("getAPKExpansionZipFile", Context.class, int.class, int.class)
                .invoke(null, this, mainVersion, patchVersion);

        expansionFileMethod = expansionFile.getClass().getMethod("getInputStream", String.class);
      } catch (Exception ex) {
        ex.printStackTrace();
        expansionFile = null;
        expansionFileMethod = null;
      }
    }

    // Get an input stream for a known file inside the expansion file ZIPs
    InputStream fileStream;
    try {
      fileStream = (InputStream) expansionFileMethod.invoke(expansionFile, fileName);
    } catch (Exception ex) {
      ex.printStackTrace();
      fileStream = null;
    }

    if (fileStream == null) {
      throw new IOException();
    }

    return fileStream;
  }
예제 #20
0
파일: D4.java 프로젝트: sarekautowerke/D4
 public String getFolderName(String pageCode) {
   String usefulSection =
       pageCode.substring(
           pageCode.indexOf("<h3 id=\"breadcrumb\">"),
           pageCode.indexOf("<div id=\"list-view\" class=\"view\""));
   String folderName;
   try {
     DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
     InputSource is = new InputSource();
     is.setCharacterStream(new StringReader(usefulSection));
     Document doc = db.parse(is);
     NodeList divs = doc.getElementsByTagName("h3");
     for (int i = 0; i < divs.getLength(); i++) {
       Element div = (Element) divs.item(i);
       String a = div.getTextContent();
       folderName = a.substring(a.indexOf("/>") + 2).trim();
       return folderName;
     }
   } catch (Exception e) {
     debug(e.toString());
   }
   return "Error!";
 }
예제 #21
0
파일: Expr.java 프로젝트: thorntonrose/Expr
  @Override
  public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
    Log.d(TAG, "onEditorAction: actionId: " + actionId + ", keyEvent: " + keyEvent);

    if ((actionId == EditorInfo.IME_ACTION_DONE)
        || ((keyEvent != null) && (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER))) {
      Log.d(TAG, "onEditorAction: IME_ACTION_DONE || KEYCODE_ENTER");
      String input = textView.getText().toString().trim();

      if (input.length() > 0) {
        String result = "";

        try {
          result += calculator.calculate(input);
        } catch (Exception e) {
          result = "no result (" + e.getMessage() + ")";
        }

        if (listAdapter.getCount() > 0) {
          listAdapter.add("");
        }

        listAdapter.add(input + " =");
        if (input.indexOf("@") > -1) {
          listAdapter.add(calculator.getEquation() + " =");
        }
        listAdapter.add(result);
        listAdapter.notifyDataSetChanged();

        inputView.endBatchEdit();
        inputView.setText("");
        hideKeyboard();
      }
    }

    return false;
  }
 public void handleMessage(Message msg) {
   switch (msg.what) {
     case F_MSG_INIT_APP:
       initEngine(msg);
       break;
     case F_MSG_LOAD_DELAY:
       try {
         Intent intent = getIntent();
         int type = intent.getIntExtra("ntype", 0);
         switch (type) {
           case ENotification.F_TYPE_PUSH:
             mBrowser.setFromPush(true);
             break;
           case ENotification.F_TYPE_USER:
             // onNewIntent(intent);
             break;
         }
         mBrowser.start();
         break;
       } catch (Exception e) {
         e.printStackTrace();
       }
     case F_MSG_LOAD_HIDE_SH:
       mScreen.setVisibility(View.VISIBLE);
       setContentViewVisible();
       if (mBrowserAround.checkTimeFlag()) {
         mBrowser.hiddenShelter();
       } else {
         mBrowserAround.setTimeFlag(true);
       }
       break;
     case F_MSG_EXIT_APP:
       readyExit((Boolean) msg.obj);
       break;
   }
 }
예제 #23
0
        private void doRetryableAlert(Exception e, String msg) {
          AlertDialog.Builder dialog = new AlertDialog.Builder(SelectAccount.this);
          dialog.setTitle(msg);
          String dispMsg = msg + "\n\n" + e.getMessage();
          dialog.setMessage(dispMsg);
          dialog.setPositiveButton(
              "Retry",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  requestAccountList();
                }
              });
          dialog.setNegativeButton("Cancel", emptyClickListener);

          AlertDialog dlg = dialog.create();
          dlg.show();
        }
예제 #24
0
  // EGL functions
  public boolean initEGL(int majorVersion, int minorVersion) {
    Log.v("SDL", "Starting up OpenGL ES " + majorVersion + "." + minorVersion);

    try {
      EGL10 egl = (EGL10) EGLContext.getEGL();

      EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

      int[] version = new int[2];
      egl.eglInitialize(dpy, version);

      int EGL_OPENGL_ES_BIT = 1;
      int EGL_OPENGL_ES2_BIT = 4;
      int renderableType = 0;
      if (majorVersion == 2) {
        renderableType = EGL_OPENGL_ES2_BIT;
      } else if (majorVersion == 1) {
        renderableType = EGL_OPENGL_ES_BIT;
      }
      int[] configSpec = {
        // EGL10.EGL_DEPTH_SIZE,   16,
        EGL10.EGL_RENDERABLE_TYPE, renderableType, EGL10.EGL_NONE
      };
      EGLConfig[] configs = new EGLConfig[1];
      int[] num_config = new int[1];
      if (!egl.eglChooseConfig(dpy, configSpec, configs, 1, num_config) || num_config[0] == 0) {
        Log.e("SDL", "No EGL config available");
        return false;
      }
      EGLConfig config = configs[0];

      EGLContext ctx = egl.eglCreateContext(dpy, config, EGL10.EGL_NO_CONTEXT, null);
      if (ctx == EGL10.EGL_NO_CONTEXT) {
        Log.e("SDL", "Couldn't create context");
        return false;
      }

      EGLSurface surface = egl.eglCreateWindowSurface(dpy, config, this, null);
      if (surface == EGL10.EGL_NO_SURFACE) {
        Log.e("SDL", "Couldn't create surface");
        return false;
      }

      if (!egl.eglMakeCurrent(dpy, surface, surface, ctx)) {
        Log.e("SDL", "Couldn't make context current");
        return false;
      }

      mEGLContext = ctx;
      mEGLDisplay = dpy;
      mEGLSurface = surface;

    } catch (Exception e) {
      Log.v("SDL", e + "");
      for (StackTraceElement s : e.getStackTrace()) {
        Log.v("SDL", s.toString());
      }
    }

    return true;
  }
예제 #25
0
  @Override
  protected void onCreate(Bundle icicle) {

    Log.d("GODOT", "** GODOT ACTIVITY CREATED HERE ***\n");

    super.onCreate(icicle);
    _self = this;
    Window window = getWindow();
    window.addFlags(
        WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // check for apk expansion API
    if (true) {
      boolean md5mismatch = false;
      command_line = getCommandLine();
      boolean use_apk_expansion = false;
      String main_pack_md5 = null;
      String main_pack_key = null;

      List<String> new_args = new LinkedList<String>();

      for (int i = 0; i < command_line.length; i++) {

        boolean has_extra = i < command_line.length - 1;
        if (command_line[i].equals("-use_apk_expansion")) {
          use_apk_expansion = true;
        } else if (has_extra && command_line[i].equals("-apk_expansion_md5")) {
          main_pack_md5 = command_line[i + 1];
          i++;
        } else if (has_extra && command_line[i].equals("-apk_expansion_key")) {
          main_pack_key = command_line[i + 1];
          SharedPreferences prefs = getSharedPreferences("app_data_keys", MODE_PRIVATE);
          Editor editor = prefs.edit();
          editor.putString("store_public_key", main_pack_key);

          editor.commit();
          i++;
        } else if (command_line[i].trim().length() != 0) {
          new_args.add(command_line[i]);
        }
      }

      if (new_args.isEmpty()) {
        command_line = null;
      } else {

        command_line = new_args.toArray(new String[new_args.size()]);
      }
      if (use_apk_expansion && main_pack_md5 != null && main_pack_key != null) {
        // check that environment is ok!
        if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
          Log.d("GODOT", "**ERROR! No media mounted!");
          // show popup and die
        }

        // Build the full path to the app's expansion files
        try {
          expansion_pack_path =
              Environment.getExternalStorageDirectory().toString()
                  + "/Android/obb/"
                  + this.getPackageName();
          expansion_pack_path +=
              "/"
                  + "main."
                  + getPackageManager().getPackageInfo(getPackageName(), 0).versionCode
                  + "."
                  + this.getPackageName()
                  + ".obb";
        } catch (Exception e) {
          e.printStackTrace();
        }

        File f = new File(expansion_pack_path);

        boolean pack_valid = true;
        Log.d("GODOT", "**PACK** - Path " + expansion_pack_path);

        if (!f.exists()) {

          pack_valid = false;
          Log.d("GODOT", "**PACK** - File does not exist");

        } else if (obbIsCorrupted(expansion_pack_path, main_pack_md5)) {
          Log.d("GODOT", "**PACK** - Expansion pack (obb) is corrupted");
          pack_valid = false;
          try {
            f.delete();
          } catch (Exception e) {
            Log.d("GODOT", "**PACK** - Error deleting corrupted expansion pack (obb)");
          }
        }

        if (!pack_valid) {
          Log.d("GODOT", "Pack Invalid, try re-downloading.");

          Intent notifierIntent = new Intent(this, this.getClass());
          notifierIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);

          PendingIntent pendingIntent =
              PendingIntent.getActivity(this, 0, notifierIntent, PendingIntent.FLAG_UPDATE_CURRENT);

          int startResult;
          try {
            Log.d("GODOT", "INITIALIZING DOWNLOAD");
            startResult =
                DownloaderClientMarshaller.startDownloadServiceIfRequired(
                    getApplicationContext(), pendingIntent, GodotDownloaderService.class);
            Log.d("GODOT", "DOWNLOAD SERVICE FINISHED:" + startResult);

            if (startResult != DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED) {
              Log.d("GODOT", "DOWNLOAD REQUIRED");
              // This is where you do set up to display the download
              // progress (next step)
              mDownloaderClientStub =
                  DownloaderClientMarshaller.CreateStub(this, GodotDownloaderService.class);

              setContentView(com.godot.game.R.layout.downloading_expansion);
              mPB = (ProgressBar) findViewById(com.godot.game.R.id.progressBar);
              mStatusText = (TextView) findViewById(com.godot.game.R.id.statusText);
              mProgressFraction = (TextView) findViewById(com.godot.game.R.id.progressAsFraction);
              mProgressPercent = (TextView) findViewById(com.godot.game.R.id.progressAsPercentage);
              mAverageSpeed = (TextView) findViewById(com.godot.game.R.id.progressAverageSpeed);
              mTimeRemaining = (TextView) findViewById(com.godot.game.R.id.progressTimeRemaining);
              mDashboard = findViewById(com.godot.game.R.id.downloaderDashboard);
              mCellMessage = findViewById(com.godot.game.R.id.approveCellular);
              mPauseButton = (Button) findViewById(com.godot.game.R.id.pauseButton);
              mWiFiSettingsButton = (Button) findViewById(com.godot.game.R.id.wifiSettingsButton);

              return;
            } else {
              Log.d("GODOT", "NO DOWNLOAD REQUIRED");
            }
          } catch (NameNotFoundException e) {
            // TODO Auto-generated catch block
            Log.d("GODOT", "Error downloading expansion package:" + e.getMessage());
          }
        }
      }
    }

    initializeGodot();

    //	instanceSingleton( new GodotFacebook(this) );

  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(null);
    if (!EResources.init(this)) {
      loadResError();
      return;
    }
    Intent intent = new Intent(EBrowserActivity.this, TempActivity.class);
    intent.putExtra("isTemp", true);
    startActivity(intent);
    overridePendingTransition(
        EUExUtil.getResAnimID("platform_myspace_no_anim"),
        EUExUtil.getResAnimID("platform_myspace_no_anim"));

    mVisable = true;
    Window activityWindow = getWindow();
    ESystemInfo.getIntence().init(this);
    mBrowser = new EBrowser(this);
    mEHandler = new EHandler(Looper.getMainLooper());
    View splash = initEngineUI();
    mBrowserAround = new EBrowserAround(splash);
    //		mScreen.setVisibility(View.INVISIBLE);
    setContentView(mScreen);
    initInternalBranch();

    ACEDes.setContext(this);

    Message loadDelayMsg = mEHandler.obtainMessage(EHandler.F_MSG_LOAD_HIDE_SH);
    long delay = 3 * 1000L;
    if (mSipBranch) {
      delay = 1000L;
    }
    mEHandler.sendMessageDelayed(loadDelayMsg, delay);
    Message initAppMsg = mEHandler.obtainMessage(EHandler.F_MSG_INIT_APP);
    WidgetOneApplication app = (WidgetOneApplication) getApplication();
    app.initApp(this, initAppMsg);

    EUtil.printeBackup(savedInstanceState, "onCreate");
    // EUtil.checkAndroidProxy(getBaseContext());

    handleIntent(getIntent());
    PushRecieveMsgReceiver.setContext(this);

    globalSlidingMenu = new SlidingMenu(this);
    globalSlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

    //        globalSlidingMenu.setShadowWidthRes(EUExUtil.getResDimenID("shadow_width"));
    //        globalSlidingMenu.setShadowDrawable(EUExUtil.getResDrawableID("shadow"));

    //        globalSlidingMenu.setShadowWidthRes(R.dimen.shadow_width);
    //        globalSlidingMenu.setShadowDrawable(R.drawable.shadow);
    //        globalSlidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    //        globalSlidingMenu.setFadeDegree(0.35f);
    //        globalSlidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    //        globalSlidingMenu.setMenu(R.layout.menu_frame);
    //        globalSlidingMenu.setMode(SlidingMenu.LEFT_RIGHT);
    //
    //        globalSlidingMenu.setSecondaryMenu(R.layout.menu_frame_two);
    //        globalSlidingMenu.setSecondaryShadowDrawable(R.drawable.shadowright);
    //        globalSlidingMenu.setBehindWidthRes(R.dimen.slidingmenu_width);
    //        globalSlidingMenu.setBehindWidthRes(0);
    reflectionPluginMethod("onActivityCreate");
    try {
      activityWindow.clearFlags(
          WindowManager.LayoutParams.class.getField("FLAG_NEEDS_MENU_KEY").getInt(null));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #27
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR); // new
    getActionBar().hide(); // new
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.main);
    first_activity_bool = true;
    Window window = this.getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    first_activity = this;
    context = getApplicationContext();
    ConnectivityManager connMgr =
        (ConnectivityManager) context.getSystemService(context.CONNECTIVITY_SERVICE);
    android.net.NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    try {
      if ((wifi.isConnected() == false)) {
        Toast.makeText(getApplicationContext(), "подключение к сети Wi-Fi", Toast.LENGTH_LONG)
            .show();
        reconnect5();
      } else {
        //  Toast.makeText(getApplicationContext(), "Уже соеденено", Toast.LENGTH_LONG).show();
        File_Video downloadFile_video = new File_Video();
        downloadFile_video.execute(BroadcastNewSms.filepath);
      }

    } catch (Exception e) {
      Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_LONG).show();
    }

    mPreview = (SurfaceView) findViewById(R.id.video_surface);
    holder = mPreview.getHolder();
    holder.addCallback(BroadcastNewSms_Two.this);
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    mp = new MediaPlayer();

    decorView = findViewById(R.id.firstsettings_two_layout);

    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;

    decorView.setSystemUiVisibility(uiOptions);
    View decorView2 = getWindow().getDecorView();
    decorView2.setOnSystemUiVisibilityChangeListener(
        new View.OnSystemUiVisibilityChangeListener() {
          @Override
          public void onSystemUiVisibilityChange(int visibility) {
            // Note that system bars will only be "visible" if none of the
            // LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.
            if ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {

              timer1();

            } else {

            }
          }
        });

    timer2();
  }
예제 #28
0
  // Setup
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Log.v("SDL", "Device: " + android.os.Build.DEVICE);
    Log.v("SDL", "Model: " + android.os.Build.MODEL);
    Log.v("SDL", "onCreate():" + mSingleton);
    super.onCreate(savedInstanceState);

    SDLActivity.initialize();
    // So we can call stuff from static callbacks
    mSingleton = this;

    // Load shared libraries
    String errorMsgBrokenLib = "";
    try {
      loadLibraries();
    } catch (UnsatisfiedLinkError e) {
      System.err.println(e.getMessage());
      mBrokenLibraries = true;
      errorMsgBrokenLib = e.getMessage();
    } catch (Exception e) {
      System.err.println(e.getMessage());
      mBrokenLibraries = true;
      errorMsgBrokenLib = e.getMessage();
    }

    if (mBrokenLibraries) {
      AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
      dlgAlert.setMessage(
          "An error occurred while trying to start the application. Please try again and/or reinstall."
              + System.getProperty("line.separator")
              + System.getProperty("line.separator")
              + "Error: "
              + errorMsgBrokenLib);
      dlgAlert.setTitle("SDL Error");
      dlgAlert.setPositiveButton(
          "Exit",
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
              // if this button is clicked, close current activity
              SDLActivity.mSingleton.finish();
            }
          });
      dlgAlert.setCancelable(false);
      dlgAlert.create().show();

      return;
    }

    // Set up the surface
    mSurface = new SDLSurface(getApplication());

    if (Build.VERSION.SDK_INT >= 12) {
      mJoystickHandler = new SDLJoystickHandler_API12();
    } else {
      mJoystickHandler = new SDLJoystickHandler();
    }

    mLayout = new AbsoluteLayout(this);
    mLayout.addView(mSurface);

    setContentView(mLayout);
  }
예제 #29
0
  // EGL functions
  public static boolean initEGL(int majorVersion, int minorVersion, int[] attribs) {
    try {
      EGL10 egl = (EGL10) EGLContext.getEGL();

      if (SDLActivity.mEGLDisplay == null) {
        SDLActivity.mEGLDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
        int[] version = new int[2];
        egl.eglInitialize(SDLActivity.mEGLDisplay, version);
      }

      if (SDLActivity.mEGLDisplay != null && SDLActivity.mEGLContext == EGL10.EGL_NO_CONTEXT) {
        // No current GL context exists, we will create a new one.
        Log.v("SDL", "Starting up OpenGL ES " + majorVersion + "." + minorVersion);
        EGLConfig[] configs = new EGLConfig[128];
        int[] num_config = new int[1];
        if (!egl.eglChooseConfig(SDLActivity.mEGLDisplay, attribs, configs, 1, num_config)
            || num_config[0] == 0) {
          Log.e("SDL", "No EGL config available");
          return false;
        }
        EGLConfig config = null;
        int bestdiff = -1, bitdiff;
        int[] value = new int[1];

        // eglChooseConfig returns a number of configurations that match or exceed the requested
        // attribs.
        // From those, we select the one that matches our requirements more closely
        Log.v("SDL", "Got " + num_config[0] + " valid modes from egl");
        for (int i = 0; i < num_config[0]; i++) {
          bitdiff = 0;
          // Go through some of the attributes and compute the bit difference between what we want
          // and what we get.
          for (int j = 0; ; j += 2) {
            if (attribs[j] == EGL10.EGL_NONE) break;

            if (attribs[j + 1] != EGL10.EGL_DONT_CARE
                && (attribs[j] == EGL10.EGL_RED_SIZE
                    || attribs[j] == EGL10.EGL_GREEN_SIZE
                    || attribs[j] == EGL10.EGL_BLUE_SIZE
                    || attribs[j] == EGL10.EGL_ALPHA_SIZE
                    || attribs[j] == EGL10.EGL_DEPTH_SIZE
                    || attribs[j] == EGL10.EGL_STENCIL_SIZE)) {
              egl.eglGetConfigAttrib(SDLActivity.mEGLDisplay, configs[i], attribs[j], value);
              bitdiff += value[0] - attribs[j + 1]; // value is always >= attrib
            }
          }

          if (bitdiff < bestdiff || bestdiff == -1) {
            config = configs[i];
            bestdiff = bitdiff;
          }

          if (bitdiff == 0) break; // we found an exact match!
        }

        Log.d("SDL", "Selected mode with a total bit difference of " + bestdiff);

        SDLActivity.mEGLConfig = config;
        SDLActivity.mGLMajor = majorVersion;
        SDLActivity.mGLMinor = minorVersion;
      }

      return SDLActivity.createEGLSurface();

    } catch (Exception e) {
      Log.v("SDL", e + "");
      for (StackTraceElement s : e.getStackTrace()) {
        Log.v("SDL", s.toString());
      }
      return false;
    }
  }
예제 #30
-52
    @Override
    protected String[] doInBackground(String... parms) {
      String[] resultarr = new String[1];
      String intentstr = parms[0];

      // int count = urls.length;
      // long totalSize = 0; for (int i = 0; i < count; i++) { totalSize +=
      // Downloader.downloadFile(urls[i]);
      // publishProgress((int) ((i / (float) count) * 100));
      // Escape early if cancel() is called
      // if (isCancelled())
      //		break;

      try {
        // Connect to API and authenticate
        publishProgress("Connecting and authenticating API session...");

        ApiWrapper wrapper;
        // wrapper = Api.wrapper;
        wrapper = new ApiWrapper(Api.mClientID, Api.mClientSecret, null, null);
        wrapper.login("un1tz3r0", "Farscap3");

        publishProgress("Resolving url...");

        String resolvedurl = resolveURL(wrapper, intentstr);

        publishProgress("Getting metadata...");

        HttpResponse resp = wrapper.get(Request.to(resolvedurl));

        JSONObject jso = Http.getJSON(resp);
        // resultstr = jso.toString();

        if (jso.getString("kind").equals("track")) {
          if (jso.getBoolean("downloadable")) {
            publishProgress("Getting download redirect URL...");

            String dlrurl =
                wrapper
                    .getURI(
                        Request.to(jso.getString("download_url")).add("allow_redirect", false),
                        false,
                        false)
                    .toString();
            HttpResponse dlrresp = wrapper.get(Request.to(dlrurl));
            String dlstr = dlrurl;
            if (dlrresp.getStatusLine().getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY) {
              Header dlloch = dlrresp.getFirstHeader("location");
              if ((dlloch == null) || (dlloch.getValue() == null))
                throw new RuntimeException("Download url HEAD response has no location header");

              dlstr = wrapper.getURI(Request.to(dlloch.getValue()), false, false).toString();
            } else if (dlrresp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
              dlstr = dlrurl;
            } else {
              throw new RuntimeException(
                  "Download url HEAD response has wrong status ("
                      + String.valueOf(dlrresp.getStatusLine().getStatusCode())
                      + " "
                      + dlrresp.getStatusLine().getReasonPhrase()
                      + ")");
            }
            // String dlstr = Request.to( dlloch.getValue() ).add("CLIENT_ID",
            // Api.mClientID).toString();

            //												if(dlresp2.getStatusLine().getStatusCode() !=
            // HttpStatus.SC_MOVED_TEMPORARILY)
            //														throw new RuntimeException("Download redirect url HEAD response has
            // wrong status: " + dlresp2.getStatusLine().toString());
            //												Header dlloc2 = dlresp2.getFirstHeader("location");
            //												if((dlloc2 == null) || (dlloc2.getValue() == null))
            //														throw new RuntimeException("Download redirect url HEAD response has no
            // location header");
            //

            resultarr = new String[2];
            resultarr[1] =
                jso.getString("title").replaceAll("[^A-Za-z0-9 -]*", "")
                    + "."
                    + jso.getString("original_format");
            resultarr[0] = dlstr;
          } else {
            Stream st = wrapper.resolveStreamUrl(jso.getString("stream_url"), true);
            resultarr = new String[2];
            resultarr[1] = jso.getString("title").replaceAll("[^A-Za-z0-9 -]*", "").concat(".mp3");
            resultarr[0] = st.streamUrl;
          }
        }
      } catch (JSONException e) {
        resultarr = new String[1];
        resultarr[0] = e.toString();
      } catch (IOException e) {
        resultarr = new String[1];
        resultarr[0] = e.toString();
      } catch (Exception e) {
        resultarr = new String[1];
        resultarr[0] = e.toString();
      }

      return resultarr;
    }