public FREObject call(FREContext context, FREObject[] args) { if (Build.MANUFACTURER.equals("Amazon")) { Log.d(TAG, "push notifications disabled on amazon devices, ignoring unregister"); return null; } PushWoosh.getInstance().PushWooshNotificationUnRegister(context.getActivity()); return null; }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu items for use in the action bar MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_reminders, menu); final MenuItem searchItem = menu.findItem(R.id.action_search); if (android.os.Build.MANUFACTURER.equals("samsung")) { searchItem.setVisible(false); } SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.addOnAttachStateChangeListener( new View.OnAttachStateChangeListener() { @Override public void onViewDetachedFromWindow(View arg0) { ExpAdapter.removeFilter(); // fix collapsed groups for (int i = 0; i < ExpAdapter.getGroupCount(); i++) { expandableListView.expandGroup(i); } } @Override public void onViewAttachedToWindow(View arg0) { ExpAdapter.searchStarted(); } }); searchView.setOnQueryTextListener( new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { ExpAdapter.filter(newText); // fix collapsed groups for (int i = 0; i < ExpAdapter.getGroupCount(); i++) { expandableListView.expandGroup(i); } return true; } }); return super.onCreateOptionsMenu(menu); }
public void DD() throws FailedExecuteCommand, IOException, InterruptedException { String Command = ""; if (isJobFlash() || isJobRestore()) { if (mDevice.getName().startsWith("g2") && Build.MANUFACTURER.equals("lge") && isJobFlash()) { File aboot = new File("/dev/block/platform/msm_sdcc.1/by-name/aboot"); File extracted_aboot = new File(mContext.getFilesDir(), "aboot.img"); File patched_CustomIMG = new File(mContext.getFilesDir(), CustomIMG.getName() + ".lok"); File loki_patch = new File(mContext.getFilesDir(), "loki_patch"); File loki_flash = new File(mContext.getFilesDir(), "loki_flash"); mShell.execCommand( "dd if=" + aboot.getAbsolutePath() + " of=" + extracted_aboot.getAbsolutePath(), true); mShell.execCommand( loki_patch.getAbsolutePath() + " recovery " + CustomIMG.getAbsolutePath() + " " + patched_CustomIMG.getAbsolutePath() + " || exit 1", true); Command = loki_flash.getAbsolutePath() + " recovery " + patched_CustomIMG.getAbsolutePath() + " || exit 1"; } else { Log.i(TAG, "Flash started!"); Common.copyFile(CustomIMG, tmpFile); Command = busybox.getAbsolutePath() + " dd if=\"" + tmpFile.getAbsolutePath() + "\" " + "of=\"" + CurrentPartition.getAbsolutePath() + "\""; } } else if (isJobBackup()) { Log.i(TAG, "Backup started!"); Command = busybox.getAbsolutePath() + " dd if=\"" + CurrentPartition.getAbsolutePath() + "\" " + "of=\"" + tmpFile.getAbsolutePath() + "\""; } mShell.execCommand(Command, true); if (isJobBackup()) placeImgBack(); }
/** sets the Orientation of the camera Preview o be the same as MoSyncApp */ private void setCameraDisplayOrientation() { // Use reflection to correct the preview on 2.2 and higher versions try { mCameraDisplayOrientation = mCamera.getClass().getMethod("setDisplayOrientation", Integer.TYPE); // Set the orientation of the picture on old Android phones Camera.Parameters parameters = mCamera.getParameters(); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { parameters.set("orientation", "portrait"); // default camera orientation on android is landscape // So we need to rotate the preview parameters.setRotation(90); mCamera.setDisplayOrientation(90); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { parameters.set("orientation", "landscape"); parameters.setRotation(0); mCamera.setDisplayOrientation(0); } mCamera.setParameters(parameters); } catch (NoSuchMethodException nsme) { SYSLOG("ANDROID Version is less than 2.2!!"); // Set the orientation of the picture on old Android phones Camera.Parameters parameters = mCamera.getParameters(); // an Ugly hack to make HTC wildfire work if (Build.MANUFACTURER.equals("HTC")) { parameters.set("orientation", "landscape"); parameters.setRotation(90); } // rest of the phones work fine with the standard settings else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { parameters.set("orientation", "portrait"); parameters.setRotation(90); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { parameters.set("orientation", "landscape"); parameters.setRotation(0); } mCamera.setParameters(parameters); } catch (RuntimeException e) { SYSLOG("Failed to set camera Parameters"); } }
private void initializePreferenceDisplay() { // XXX-S Why are there two separate if blocks to do this? Merely setting these UI elements to // "checked" won't necessarily change the underlying preferences, and it won't have any // effect until this activity is opened. if (DeviceAudioSettings.useInCallMode()) { CheckBoxPreference speakerPreference = (CheckBoxPreference) this.findPreference(AUDIO_SPEAKER_INCALL); speakerPreference.setChecked(true); } if (Build.MANUFACTURER.equals("Samsung")) { CheckBoxPreference speakerPreference = (CheckBoxPreference) this.findPreference(AUDIO_SPEAKER_INCALL); speakerPreference.setChecked(false); } if (Build.VERSION.SDK_INT < 8) ((CheckBoxPreference) findPreference(USE_C2DM)).setEnabled(false); }
@Kroll.method public void showCamera(@SuppressWarnings("rawtypes") HashMap options) { Activity activity = TiApplication.getInstance().getCurrentActivity(); Log.d(TAG, "showCamera called", Log.DEBUG_MODE); KrollFunction successCallback = null; KrollFunction cancelCallback = null; KrollFunction errorCallback = null; boolean autohide = true; boolean saveToPhotoGallery = false; if (options.containsKey("success")) { successCallback = (KrollFunction) options.get("success"); } if (options.containsKey("cancel")) { cancelCallback = (KrollFunction) options.get("cancel"); } if (options.containsKey("error")) { errorCallback = (KrollFunction) options.get("error"); } Object autohideOption = options.get("autohide"); if (autohideOption != null) { autohide = TiConvert.toBoolean(autohideOption); } Object saveToPhotoGalleryOption = options.get("saveToPhotoGallery"); if (saveToPhotoGalleryOption != null) { saveToPhotoGallery = TiConvert.toBoolean(saveToPhotoGalleryOption); } // Use our own custom camera activity when an overlay is provided. if (options.containsKey("overlay")) { TiCameraActivity.overlayProxy = (TiViewProxy) options.get("overlay"); TiCameraActivity.callbackContext = getKrollObject(); TiCameraActivity.successCallback = successCallback; TiCameraActivity.errorCallback = errorCallback; TiCameraActivity.cancelCallback = cancelCallback; TiCameraActivity.saveToPhotoGallery = saveToPhotoGallery; TiCameraActivity.whichCamera = CAMERA_REAR; // default. // This option is only applicable when running the custom // TiCameraActivity, since we can't direct the built-in // Activity to open a specific camera. Object whichCamera = options.get("whichCamera"); if (whichCamera != null) { TiCameraActivity.whichCamera = TiConvert.toInt(whichCamera); } TiCameraActivity.autohide = autohide; Intent intent = new Intent(activity, TiCameraActivity.class); activity.startActivity(intent); return; } Camera camera = null; try { camera = Camera.open(); if (camera != null) { camera.release(); camera = null; } } catch (Throwable t) { if (camera != null) { camera.release(); } if (errorCallback != null) { errorCallback.call( getKrollObject(), new Object[] {createErrorResponse(NO_CAMERA, "Camera not available.")}); } return; } TiActivitySupport activitySupport = (TiActivitySupport) activity; TiFileHelper tfh = TiFileHelper.getInstance(); TiIntentWrapper cameraIntent = new TiIntentWrapper(new Intent()); if (TiCameraActivity.overlayProxy == null) { cameraIntent.getIntent().setAction(MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent.getIntent().addCategory(Intent.CATEGORY_DEFAULT); } else { cameraIntent .getIntent() .setClass(TiApplication.getInstance().getBaseContext(), TiCameraActivity.class); } cameraIntent.setWindowId(TiIntentWrapper.createActivityName("CAMERA")); PackageManager pm = (PackageManager) activity.getPackageManager(); List<ResolveInfo> activities = pm.queryIntentActivities(cameraIntent.getIntent(), PackageManager.MATCH_DEFAULT_ONLY); // See if it's the HTC camera app boolean isHTCCameraApp = false; for (ResolveInfo rs : activities) { try { if (rs.activityInfo.applicationInfo.sourceDir.contains("HTC") || Build.MANUFACTURER.equals("HTC")) { isHTCCameraApp = true; break; } } catch (NullPointerException e) { // Ignore } } File imageDir = null; File imageFile = null; try { if (saveToPhotoGallery) { // HTC camera application will create its own gallery image // file. if (!isHTCCameraApp) { imageFile = createGalleryImageFile(); } } else { if (activity.getIntent() != null) { String name = TiApplication.getInstance().getAppInfo().getName(); // For HTC cameras, specifying the directory from // getExternalStorageDirectory is /mnt/sdcard and // using that path prevents the gallery from recognizing it. // To avoid this we use /sdcard instead // (this is a legacy path we've been using) if (isHTCCameraApp) { imageDir = new File(PHOTO_DCIM_CAMERA, name); } else { File rootsd = Environment.getExternalStorageDirectory(); imageDir = new File(rootsd.getAbsolutePath() + "/dcim/Camera/", name); } if (!imageDir.exists()) { imageDir.mkdirs(); if (!imageDir.exists()) { Log.w(TAG, "Attempt to create '" + imageDir.getAbsolutePath() + "' failed silently."); } } } else { imageDir = tfh.getDataDirectory(false); } imageFile = tfh.getTempFile(imageDir, ".jpg", true); } } catch (IOException e) { Log.e(TAG, "Unable to create temp file", e); if (errorCallback != null) { errorCallback.callAsync( getKrollObject(), createErrorResponse(UNKNOWN_ERROR, e.getMessage())); } return; } // Get the taken date for the last image in EXTERNAL_CONTENT_URI. String[] projection = {Images.ImageColumns.DATE_TAKEN}; String dateTaken = null; Cursor c = activity .getContentResolver() .query( Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, Images.ImageColumns.DATE_TAKEN); if (c != null) { if (c.moveToLast()) { dateTaken = c.getString(0); } c.close(); c = null; } CameraResultHandler resultHandler = new CameraResultHandler(); resultHandler.imageFile = imageFile; resultHandler.saveToPhotoGallery = saveToPhotoGallery; resultHandler.successCallback = successCallback; resultHandler.cancelCallback = cancelCallback; resultHandler.errorCallback = errorCallback; resultHandler.activitySupport = activitySupport; resultHandler.cameraIntent = cameraIntent.getIntent(); resultHandler.dateTaken_lastImageInExternalContentURI = dateTaken; if (imageFile != null) { String imageUrl = "file://" + imageFile.getAbsolutePath(); cameraIntent.getIntent().putExtra(MediaStore.EXTRA_OUTPUT, Uri.parse(imageUrl)); resultHandler.imageUrl = imageUrl; } activity.runOnUiThread(resultHandler); }
/** @return true if the device is a kindle fire and needs special treatment */ public static boolean isKindleFire() { return android.os.Build.MANUFACTURER.equals("Amazon") && //$NON-NLS-1$ android.os.Build.MODEL.contains("Kindle"); // $NON-NLS-1$ }