Search in sources :

Example 31 with SuppressLint

use of android.annotation.SuppressLint in project androidannotations by androidannotations.

the class PreferenceEventsHandledActivityTest method testPreferenceChangeParameterPassed.

@SuppressLint("UseValueOf")
@Test
public void testPreferenceChangeParameterPassed() {
    Preference preference = activity.findPreference(activity.getString(R.string.checkBoxPrefKey));
    Boolean newValue = new Boolean(true);
    preference.getOnPreferenceChangeListener().onPreferenceChange(preference, newValue);
    assertThat(activity.preference).isSameAs(preference);
    assertThat(activity.newValue).isSameAs(newValue);
}
Also used : Preference(android.preference.Preference) Test(org.junit.Test) SuppressLint(android.annotation.SuppressLint)

Example 32 with SuppressLint

use of android.annotation.SuppressLint in project android-vision by googlesamples.

the class BarcodeCaptureActivity method createCameraSource.

/**
     * Creates and starts the camera.  Note that this uses a higher resolution in comparison
     * to other detection examples to enable the barcode detector to detect small barcodes
     * at long distances.
     *
     * Suppressing InlinedApi since there is a check that the minimum version is met before using
     * the constant.
     */
@SuppressLint("InlinedApi")
private void createCameraSource(boolean autoFocus, boolean useFlash) {
    Context context = getApplicationContext();
    // A barcode detector is created to track barcodes.  An associated multi-processor instance
    // is set to receive the barcode detection results, track the barcodes, and maintain
    // graphics for each barcode on screen.  The factory is used by the multi-processor to
    // create a separate tracker instance for each barcode.
    BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(context).build();
    BarcodeTrackerFactory barcodeFactory = new BarcodeTrackerFactory(mGraphicOverlay);
    barcodeDetector.setProcessor(new MultiProcessor.Builder<>(barcodeFactory).build());
    if (!barcodeDetector.isOperational()) {
        // Note: The first time that an app using the barcode or face API is installed on a
        // device, GMS will download a native libraries to the device in order to do detection.
        // Usually this completes before the app is run for the first time.  But if that
        // download has not yet completed, then the above call will not detect any barcodes
        // and/or faces.
        //
        // isOperational() can be used to check if the required native libraries are currently
        // available.  The detectors will automatically become operational once the library
        // downloads complete on device.
        Log.w(TAG, "Detector dependencies are not yet available.");
        // Check for low storage.  If there is low storage, the native library will not be
        // downloaded, so detection will not become operational.
        IntentFilter lowstorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
        boolean hasLowStorage = registerReceiver(null, lowstorageFilter) != null;
        if (hasLowStorage) {
            Toast.makeText(this, R.string.low_storage_error, Toast.LENGTH_LONG).show();
            Log.w(TAG, getString(R.string.low_storage_error));
        }
    }
    // Creates and starts the camera.  Note that this uses a higher resolution in comparison
    // to other detection examples to enable the barcode detector to detect small barcodes
    // at long distances.
    CameraSource.Builder builder = new CameraSource.Builder(getApplicationContext(), barcodeDetector).setFacing(CameraSource.CAMERA_FACING_BACK).setRequestedPreviewSize(1600, 1024).setRequestedFps(15.0f);
    // make sure that auto focus is an available option
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        builder = builder.setFocusMode(autoFocus ? Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE : null);
    }
    mCameraSource = builder.setFlashMode(useFlash ? Camera.Parameters.FLASH_MODE_TORCH : null).build();
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) CameraSource(com.google.android.gms.samples.vision.barcodereader.ui.camera.CameraSource) BarcodeDetector(com.google.android.gms.vision.barcode.BarcodeDetector) SuppressLint(android.annotation.SuppressLint)

Example 33 with SuppressLint

use of android.annotation.SuppressLint in project android-vision by googlesamples.

the class CameraSource method createCamera.

/**
     * Opens the camera and applies the user settings.
     *
     * @throws RuntimeException if the method fails
     */
@SuppressLint("InlinedApi")
private Camera createCamera() {
    int requestedCameraId = getIdForRequestedCamera(mFacing);
    if (requestedCameraId == -1) {
        throw new RuntimeException("Could not find requested camera.");
    }
    Camera camera = Camera.open(requestedCameraId);
    SizePair sizePair = selectSizePair(camera, mRequestedPreviewWidth, mRequestedPreviewHeight);
    if (sizePair == null) {
        throw new RuntimeException("Could not find suitable preview size.");
    }
    Size pictureSize = sizePair.pictureSize();
    mPreviewSize = sizePair.previewSize();
    int[] previewFpsRange = selectPreviewFpsRange(camera, mRequestedFps);
    if (previewFpsRange == null) {
        throw new RuntimeException("Could not find suitable preview frames per second range.");
    }
    Camera.Parameters parameters = camera.getParameters();
    if (pictureSize != null) {
        parameters.setPictureSize(pictureSize.getWidth(), pictureSize.getHeight());
    }
    parameters.setPreviewSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
    parameters.setPreviewFpsRange(previewFpsRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX], previewFpsRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
    parameters.setPreviewFormat(ImageFormat.NV21);
    setRotation(camera, parameters, requestedCameraId);
    if (mFocusMode != null) {
        if (parameters.getSupportedFocusModes().contains(mFocusMode)) {
            parameters.setFocusMode(mFocusMode);
        } else {
            Log.i(TAG, "Camera focus mode: " + mFocusMode + " is not supported on this device.");
        }
    }
    // setting mFocusMode to the one set in the params
    mFocusMode = parameters.getFocusMode();
    if (mFlashMode != null) {
        if (parameters.getSupportedFlashModes() != null) {
            if (parameters.getSupportedFlashModes().contains(mFlashMode)) {
                parameters.setFlashMode(mFlashMode);
            } else {
                Log.i(TAG, "Camera flash mode: " + mFlashMode + " is not supported on this device.");
            }
        }
    }
    // setting mFlashMode to the one set in the params
    mFlashMode = parameters.getFlashMode();
    camera.setParameters(parameters);
    // Four frame buffers are needed for working with the camera:
    //
    //   one for the frame that is currently being executed upon in doing detection
    //   one for the next pending frame to process immediately upon completing detection
    //   two for the frames that the camera uses to populate future preview images
    camera.setPreviewCallbackWithBuffer(new CameraPreviewCallback());
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
    camera.addCallbackBuffer(createPreviewBuffer(mPreviewSize));
    return camera;
}
Also used : Size(com.google.android.gms.common.images.Size) Camera(android.hardware.Camera) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 34 with SuppressLint

use of android.annotation.SuppressLint in project react-native-image-picker by marcshilling.

the class RealPathUtil method getRealPathFromURI.

@SuppressLint("NewApi")
@Nullable
public static String getRealPathFromURI(@NonNull final Context context, @NonNull final Uri uri) {
    final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
    // DocumentProvider
    if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
        // ExternalStorageProvider
        if (isExternalStorageDocument(uri)) {
            final String docId = DocumentsContract.getDocumentId(uri);
            final String[] split = docId.split(":");
            final String type = split[0];
            if ("primary".equalsIgnoreCase(type)) {
                return Environment.getExternalStorageDirectory() + "/" + split[1];
            }
        // TODO handle non-primary volumes
        } else // DownloadsProvider
        if (isDownloadsDocument(uri)) {
            final String id = DocumentsContract.getDocumentId(uri);
            final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
            return getDataColumn(context, contentUri, null, null);
        } else // MediaProvider
        if (isMediaDocument(uri)) {
            final String docId = DocumentsContract.getDocumentId(uri);
            final String[] split = docId.split(":");
            final String type = split[0];
            Uri contentUri = null;
            if ("image".equals(type)) {
                contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
            } else if ("video".equals(type)) {
                contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
            } else if ("audio".equals(type)) {
                contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
            }
            final String selection = "_id=?";
            final String[] selectionArgs = new String[] { split[1] };
            return getDataColumn(context, contentUri, selection, selectionArgs);
        }
    } else // MediaStore (and general)
    if ("content".equalsIgnoreCase(uri.getScheme())) {
        // Return the remote address
        if (isGooglePhotosUri(uri))
            return uri.getLastPathSegment();
        if (isFileProviderUri(context, uri))
            return getFileProviderPath(context, uri);
        return getDataColumn(context, uri, null, null);
    } else // File
    if ("file".equalsIgnoreCase(uri.getScheme())) {
        return uri.getPath();
    }
    return null;
}
Also used : Uri(android.net.Uri) SuppressLint(android.annotation.SuppressLint) Nullable(android.support.annotation.Nullable)

Example 35 with SuppressLint

use of android.annotation.SuppressLint in project AndroidTwitter by lorensiuswlt.

the class TwitterDialog method setUpWebView.

@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView() {
    CookieSyncManager.createInstance(getContext());
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.removeAllCookie();
    mWebView = new WebView(getContext());
    mWebView.setVerticalScrollBarEnabled(false);
    mWebView.setHorizontalScrollBarEnabled(false);
    mWebView.setWebViewClient(new TwitterWebViewClient());
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.loadUrl(mUrl);
    mWebView.setLayoutParams(FILL);
    mContent.addView(mWebView);
}
Also used : WebView(android.webkit.WebView) CookieManager(android.webkit.CookieManager) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)739 View (android.view.View)168 TextView (android.widget.TextView)106 Intent (android.content.Intent)86 Paint (android.graphics.Paint)63 ImageView (android.widget.ImageView)44 File (java.io.File)42 LayoutInflater (android.view.LayoutInflater)37 WebView (android.webkit.WebView)37 Uri (android.net.Uri)35 ArrayList (java.util.ArrayList)34 Context (android.content.Context)33 Bitmap (android.graphics.Bitmap)31 ViewGroup (android.view.ViewGroup)30 ListView (android.widget.ListView)30 Bundle (android.os.Bundle)27 IOException (java.io.IOException)26 AlertDialog (android.app.AlertDialog)25 DialogInterface (android.content.DialogInterface)25 AdapterView (android.widget.AdapterView)25