Search in sources :

Example 91 with SuppressLint

use of android.annotation.SuppressLint in project mobile-center-sdk-android by Microsoft.

the class DeviceInfoHelper method getScreenSize.

/**
     * Gets a size of a device for base orientation.
     *
     * @param context The context of the application.
     * @return A string with {@code <width>x<height>} format.
     */
@SuppressLint("SwitchIntDef")
@SuppressWarnings("SuspiciousNameCombination")
private static String getScreenSize(Context context) {
    /* Guess resolution based on the natural device orientation */
    int screenWidth;
    int screenHeight;
    Display defaultDisplay = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    Point size = new Point();
    defaultDisplay.getSize(size);
    switch(defaultDisplay.getRotation()) {
        case Surface.ROTATION_90:
        case Surface.ROTATION_270:
            screenHeight = size.x;
            screenWidth = size.y;
            break;
        default:
            screenWidth = size.x;
            screenHeight = size.y;
    }
    /* Serialize screen resolution */
    return screenWidth + "x" + screenHeight;
}
Also used : Point(android.graphics.Point) Point(android.graphics.Point) SuppressLint(android.annotation.SuppressLint) Display(android.view.Display) WindowManager(android.view.WindowManager) SuppressLint(android.annotation.SuppressLint)

Example 92 with SuppressLint

use of android.annotation.SuppressLint in project android_frameworks_base by DirtyUnicorns.

the class VolumeDialog method initRow.

@SuppressLint("InflateParams")
private void initRow(final VolumeRow row, final int stream, int iconRes, int iconMuteRes, boolean important) {
    row.stream = stream;
    row.iconRes = iconRes;
    row.iconMuteRes = iconMuteRes;
    row.important = important;
    row.view = mDialog.getLayoutInflater().inflate(R.layout.volume_dialog_row, null);
    row.view.setId(row.stream);
    row.view.setTag(row);
    row.header = (TextView) row.view.findViewById(R.id.volume_row_header);
    row.header.setId(20 * row.stream);
    mSpTexts.add(row.header);
    row.slider = (SeekBar) row.view.findViewById(R.id.volume_row_slider);
    row.slider.setOnSeekBarChangeListener(new VolumeSeekBarChangeListener(row));
    row.anim = null;
    row.cachedShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS;
    // forward events above the slider into the slider
    row.view.setOnTouchListener(new OnTouchListener() {

        private final Rect mSliderHitRect = new Rect();

        private boolean mDragging;

        @SuppressLint("ClickableViewAccessibility")
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            row.slider.getHitRect(mSliderHitRect);
            if (!mDragging && event.getActionMasked() == MotionEvent.ACTION_DOWN && event.getY() < mSliderHitRect.top) {
                mDragging = true;
            }
            if (mDragging) {
                event.offsetLocation(-mSliderHitRect.left, -mSliderHitRect.top);
                row.slider.dispatchTouchEvent(event);
                if (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
                    mDragging = false;
                }
                return true;
            }
            return false;
        }
    });
    row.icon = (ImageButton) row.view.findViewById(R.id.volume_row_icon);
    row.icon.setImageResource(iconRes);
    row.icon.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Events.writeEvent(mContext, Events.EVENT_ICON_CLICK, row.stream, row.iconState);
            mController.setActiveStream(row.stream);
            if (row.stream == AudioManager.STREAM_RING) {
                final boolean hasVibrator = mController.hasVibrator();
                if (mState.ringerModeInternal == AudioManager.RINGER_MODE_NORMAL) {
                    if (hasVibrator) {
                        mController.setRingerMode(AudioManager.RINGER_MODE_VIBRATE, false);
                    } else {
                        final boolean wasZero = row.ss.level == 0;
                        mController.setStreamVolume(stream, wasZero ? row.lastAudibleLevel : 0);
                    }
                } else {
                    mController.setRingerMode(AudioManager.RINGER_MODE_NORMAL, false);
                    if (row.ss.level == 0) {
                        mController.setStreamVolume(stream, 1);
                    }
                }
            } else if (row.stream == AudioManager.STREAM_NOTIFICATION) {
                // only ringer icon can change silent or vibrate mode
                if (mState.ringerModeInternal == AudioManager.RINGER_MODE_NORMAL) {
                    final boolean vmute = row.ss.level == 0;
                    mController.setStreamVolume(stream, vmute ? row.lastAudibleLevel : 0);
                }
            } else {
                final boolean vmute = row.ss.level == row.ss.levelMin;
                mController.setStreamVolume(stream, vmute ? row.lastAudibleLevel : row.ss.levelMin);
            }
            // reset the grace period, slider should update immediately
            row.userAttempt = 0;
        }
    });
}
Also used : Rect(android.graphics.Rect) OnTouchListener(android.view.View.OnTouchListener) SuppressLint(android.annotation.SuppressLint) OnClickListener(android.view.View.OnClickListener) View(android.view.View) TextView(android.widget.TextView) MotionEvent(android.view.MotionEvent) SuppressLint(android.annotation.SuppressLint)

Example 93 with SuppressLint

use of android.annotation.SuppressLint in project UltimateAndroid by cymcsg.

the class Blur method fastblur.

@SuppressLint("NewApi")
public static Bitmap fastblur(Context context, Bitmap sentBitmap, int radius) throws Exception {
    if (VERSION.SDK_INT > 16) {
        Bitmap bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);
        final RenderScript rs = RenderScript.create(context);
        final Allocation input = Allocation.createFromBitmap(rs, sentBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
        final Allocation output = Allocation.createTyped(rs, input.getType());
        final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
        script.setRadius(radius);
        script.setInput(input);
        script.forEach(output);
        output.copyTo(bitmap);
        return bitmap;
    }
    // Stack Blur v1.0 from
    // http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html
    //
    // Java Author: Mario Klingemann <mario at quasimondo.com>
    // http://incubator.quasimondo.com
    // created Feburary 29, 2004
    // Android port : Yahel Bouaziz <yahel at kayenko.com>
    // http://www.kayenko.com
    // ported april 5th, 2012
    // This is a compromise between Gaussian Blur and Box blur
    // It creates much better looking blurs than Box Blur, but is
    // 7x faster than my Gaussian Blur implementation.
    //
    // I called it Stack Blur because this describes best how this
    // filter works internally: it creates a kind of moving stack
    // of colors whilst scanning through the image. Thereby it
    // just has to add one new block of color to the right side
    // of the stack and remove the leftmost color. The remaining
    // colors on the topmost layer of the stack are either added on
    // or reduced by one, depending on if they are on the right or
    // on the left side of the stack.
    //
    // If you are using this algorithm in your code please add
    // the following line:
    //
    // Stack Blur Algorithm by Mario Klingemann <mario@quasimondo.com>
    Bitmap bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);
    if (radius < 1) {
        return (null);
    }
    int w = bitmap.getWidth();
    int h = bitmap.getHeight();
    int[] pix = new int[w * h];
    Log.e("pix", w + " " + h + " " + pix.length);
    bitmap.getPixels(pix, 0, w, 0, 0, w, h);
    int wm = w - 1;
    int hm = h - 1;
    int wh = w * h;
    int div = radius + radius + 1;
    int[] r = new int[wh];
    int[] g = new int[wh];
    int[] b = new int[wh];
    int rsum, gsum, bsum, x, y, i, p, yp, yi, yw;
    int[] vmin = new int[Math.max(w, h)];
    int divsum = (div + 1) >> 1;
    divsum *= divsum;
    int[] dv = new int[256 * divsum];
    for (i = 0; i < 256 * divsum; i++) {
        dv[i] = (i / divsum);
    }
    yw = yi = 0;
    int[][] stack = new int[div][3];
    int stackpointer;
    int stackstart;
    int[] sir;
    int rbs;
    int r1 = radius + 1;
    int routsum, goutsum, boutsum;
    int rinsum, ginsum, binsum;
    for (y = 0; y < h; y++) {
        rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
        for (i = -radius; i <= radius; i++) {
            p = pix[yi + Math.min(wm, Math.max(i, 0))];
            sir = stack[i + radius];
            sir[0] = (p & 0xff0000) >> 16;
            sir[1] = (p & 0x00ff00) >> 8;
            sir[2] = (p & 0x0000ff);
            rbs = r1 - Math.abs(i);
            rsum += sir[0] * rbs;
            gsum += sir[1] * rbs;
            bsum += sir[2] * rbs;
            if (i > 0) {
                rinsum += sir[0];
                ginsum += sir[1];
                binsum += sir[2];
            } else {
                routsum += sir[0];
                goutsum += sir[1];
                boutsum += sir[2];
            }
        }
        stackpointer = radius;
        for (x = 0; x < w; x++) {
            r[yi] = dv[rsum];
            g[yi] = dv[gsum];
            b[yi] = dv[bsum];
            rsum -= routsum;
            gsum -= goutsum;
            bsum -= boutsum;
            stackstart = stackpointer - radius + div;
            sir = stack[stackstart % div];
            routsum -= sir[0];
            goutsum -= sir[1];
            boutsum -= sir[2];
            if (y == 0) {
                vmin[x] = Math.min(x + radius + 1, wm);
            }
            p = pix[yw + vmin[x]];
            sir[0] = (p & 0xff0000) >> 16;
            sir[1] = (p & 0x00ff00) >> 8;
            sir[2] = (p & 0x0000ff);
            rinsum += sir[0];
            ginsum += sir[1];
            binsum += sir[2];
            rsum += rinsum;
            gsum += ginsum;
            bsum += binsum;
            stackpointer = (stackpointer + 1) % div;
            sir = stack[(stackpointer) % div];
            routsum += sir[0];
            goutsum += sir[1];
            boutsum += sir[2];
            rinsum -= sir[0];
            ginsum -= sir[1];
            binsum -= sir[2];
            yi++;
        }
        yw += w;
    }
    for (x = 0; x < w; x++) {
        rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
        yp = -radius * w;
        for (i = -radius; i <= radius; i++) {
            yi = Math.max(0, yp) + x;
            sir = stack[i + radius];
            sir[0] = r[yi];
            sir[1] = g[yi];
            sir[2] = b[yi];
            rbs = r1 - Math.abs(i);
            rsum += r[yi] * rbs;
            gsum += g[yi] * rbs;
            bsum += b[yi] * rbs;
            if (i > 0) {
                rinsum += sir[0];
                ginsum += sir[1];
                binsum += sir[2];
            } else {
                routsum += sir[0];
                goutsum += sir[1];
                boutsum += sir[2];
            }
            if (i < hm) {
                yp += w;
            }
        }
        yi = x;
        stackpointer = radius;
        for (y = 0; y < h; y++) {
            // Preserve alpha channel: ( 0xff000000 & pix[yi] )
            pix[yi] = (0xff000000 & pix[yi]) | (dv[rsum] << 16) | (dv[gsum] << 8) | dv[bsum];
            rsum -= routsum;
            gsum -= goutsum;
            bsum -= boutsum;
            stackstart = stackpointer - radius + div;
            sir = stack[stackstart % div];
            routsum -= sir[0];
            goutsum -= sir[1];
            boutsum -= sir[2];
            if (x == 0) {
                vmin[y] = Math.min(y + r1, hm) * w;
            }
            p = x + vmin[y];
            sir[0] = r[p];
            sir[1] = g[p];
            sir[2] = b[p];
            rinsum += sir[0];
            ginsum += sir[1];
            binsum += sir[2];
            rsum += rinsum;
            gsum += ginsum;
            bsum += binsum;
            stackpointer = (stackpointer + 1) % div;
            sir = stack[stackpointer];
            routsum += sir[0];
            goutsum += sir[1];
            boutsum += sir[2];
            rinsum -= sir[0];
            ginsum -= sir[1];
            binsum -= sir[2];
            yi += w;
        }
    }
    Log.e("pix", w + " " + h + " " + pix.length);
    bitmap.setPixels(pix, 0, w, 0, 0, w, h);
    return (bitmap);
}
Also used : Bitmap(android.graphics.Bitmap) RenderScript(android.renderscript.RenderScript) Allocation(android.renderscript.Allocation) ScriptIntrinsicBlur(android.renderscript.ScriptIntrinsicBlur) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 94 with SuppressLint

use of android.annotation.SuppressLint in project mobile-center-sdk-android by Microsoft.

the class CryptoRsaHandler method generateKey.

/*
     * We don't run this code prior to Android 4.4 hence no 4.3 secure random problem.
     */
@Override
@SuppressWarnings("deprecation")
@SuppressLint({ "InlinedApi", "TrulyRandom" })
public void generateKey(CryptoUtils.ICryptoFactory cryptoFactory, String alias, Context context) throws Exception {
    Calendar writeExpiry = Calendar.getInstance();
    writeExpiry.add(Calendar.YEAR, ENCRYPT_KEY_LIFETIME_IN_YEARS);
    KeyPairGenerator generator = KeyPairGenerator.getInstance(KeyProperties.KEY_ALGORITHM_RSA, ANDROID_KEY_STORE);
    generator.initialize(new KeyPairGeneratorSpec.Builder(context).setAlias(alias).setSubject(new X500Principal("CN=" + alias)).setStartDate(new Date()).setEndDate(writeExpiry.getTime()).setSerialNumber(BigInteger.TEN).setKeySize(RSA_KEY_SIZE).build());
    generator.generateKeyPair();
}
Also used : Calendar(java.util.Calendar) X500Principal(javax.security.auth.x500.X500Principal) KeyPairGenerator(java.security.KeyPairGenerator) Date(java.util.Date) SuppressLint(android.annotation.SuppressLint)

Example 95 with SuppressLint

use of android.annotation.SuppressLint in project MaterialDateTimePicker by wdullaer.

the class DayPickerView method performAccessibilityAction.

/**
     * When scroll forward/backward events are received, announce the newly scrolled-to month.
     */
@SuppressLint("NewApi")
@Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
    if (action != AccessibilityNodeInfo.ACTION_SCROLL_FORWARD && action != AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) {
        return super.performAccessibilityAction(action, arguments);
    }
    // Figure out what month is showing.
    int firstVisiblePosition = getFirstVisiblePosition();
    int minMonth = mController.getStartDate().get(Calendar.MONTH);
    int month = (firstVisiblePosition + minMonth) % MonthAdapter.MONTHS_IN_YEAR;
    int year = (firstVisiblePosition + minMonth) / MonthAdapter.MONTHS_IN_YEAR + mController.getMinYear();
    MonthAdapter.CalendarDay day = new MonthAdapter.CalendarDay(year, month, 1);
    // Scroll either forward or backward one month.
    if (action == AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) {
        day.month++;
        if (day.month == 12) {
            day.month = 0;
            day.year++;
        }
    } else if (action == AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) {
        View firstVisibleView = getChildAt(0);
        // to the first day of first visible month.
        if (firstVisibleView != null && firstVisibleView.getTop() >= -1) {
            // There's an off-by-one somewhere, so the top of the first visible item will
            // actually be -1 when it's at the exact top.
            day.month--;
            if (day.month == -1) {
                day.month = 11;
                day.year--;
            }
        }
    }
    // Go to that month.
    Utils.tryAccessibilityAnnounce(this, getMonthAndYearString(day));
    goTo(day, true, false, true);
    mPerformingScroll = true;
    return true;
}
Also used : AbsListView(android.widget.AbsListView) View(android.view.View) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1773 View (android.view.View)369 TextView (android.widget.TextView)243 Intent (android.content.Intent)232 ImageView (android.widget.ImageView)112 Paint (android.graphics.Paint)109 File (java.io.File)102 IOException (java.io.IOException)96 ArrayList (java.util.ArrayList)93 Context (android.content.Context)91 LayoutInflater (android.view.LayoutInflater)89 Uri (android.net.Uri)84 Bundle (android.os.Bundle)83 SharedPreferences (android.content.SharedPreferences)78 Bitmap (android.graphics.Bitmap)78 WebView (android.webkit.WebView)76 PendingIntent (android.app.PendingIntent)72 Method (java.lang.reflect.Method)72 SimpleDateFormat (java.text.SimpleDateFormat)69 ViewGroup (android.view.ViewGroup)66