Search in sources :

Example 96 with RequiresApi

use of android.support.annotation.RequiresApi in project AndroidUtilLib by SiberiaDante.

the class SDDateUtil method getStrToSDFTime.

/**
 * 支持输出各种格式的日期、时间
 *
 * @param str    时间戳
 * @param format
 * @return 日期、时间格式
 */
@RequiresApi(api = Build.VERSION_CODES.GINGERBREAD)
public static String getStrToSDFTime(String str, String format) {
    // 判断时间戳是否为空
    if (str == null || str.isEmpty() || str.equals("null")) {
        return "";
    }
    // 未指定format格式时默认输出yyyy-MM-dd HH:mm:ss
    if (format == null || format.isEmpty()) {
        format = "yyyy-MM-dd HH:mm:ss";
    }
    SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.CHINA);
    Long strLong = Long.valueOf(str);
    return sdf.format(new Date(strLong * 1000));
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) RequiresApi(android.support.annotation.RequiresApi)

Example 97 with RequiresApi

use of android.support.annotation.RequiresApi in project xabber-android by redsolution.

the class NotificationManager method createNotificationChannel.

@RequiresApi(api = Build.VERSION_CODES.O)
public String createNotificationChannel() {
    String channelId = "xabber_notification";
    String channelName = "Xabber Notification";
    @SuppressLint("WrongConstant") NotificationChannel channel = new NotificationChannel(channelId, channelName, android.app.NotificationManager.IMPORTANCE_HIGH);
    android.app.NotificationManager service = (android.app.NotificationManager) Application.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);
    if (service != null)
        service.createNotificationChannel(channel);
    return channelId;
}
Also used : NotificationChannel(android.app.NotificationChannel) SuppressLint(android.annotation.SuppressLint) RequiresApi(android.support.annotation.RequiresApi)

Example 98 with RequiresApi

use of android.support.annotation.RequiresApi in project vlc-android by videolan.

the class NotificationHelper method createNotificationChannels.

@RequiresApi(api = Build.VERSION_CODES.O)
public static void createNotificationChannels(Context appCtx) {
    final NotificationManager notificationManager = (NotificationManager) appCtx.getSystemService(Context.NOTIFICATION_SERVICE);
    // Playback channel
    CharSequence name = appCtx.getString(R.string.playback);
    String description = appCtx.getString(R.string.playback_controls);
    NotificationChannel channel = new NotificationChannel("vlc_playback", name, NotificationManager.IMPORTANCE_LOW);
    channel.setDescription(description);
    channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
    notificationManager.createNotificationChannel(channel);
    // Scan channel
    name = appCtx.getString(R.string.medialibrary_scan);
    description = appCtx.getString(R.string.Medialibrary_progress);
    channel = new NotificationChannel("vlc_medialibrary", name, NotificationManager.IMPORTANCE_LOW);
    channel.setDescription(description);
    channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
    notificationManager.createNotificationChannel(channel);
    // Recommendations channel
    if (AndroidDevices.isAndroidTv) {
        name = appCtx.getString(R.string.recommendations);
        description = appCtx.getString(R.string.recommendations_desc);
        channel = new NotificationChannel("vlc_recommendations", name, NotificationManager.IMPORTANCE_LOW);
        channel.setDescription(description);
        channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
        notificationManager.createNotificationChannel(channel);
    }
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationManager(android.app.NotificationManager) RequiresApi(android.support.annotation.RequiresApi)

Example 99 with RequiresApi

use of android.support.annotation.RequiresApi in project vlc-android by videolan.

the class UiTools method blurBitmap.

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap blurBitmap(Bitmap bitmap, float radius) {
    if (bitmap == null || bitmap.getConfig() == null)
        return null;
    // Let's create an empty bitmap with the same size of the bitmap we want to blur
    Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    // Instantiate a new Renderscript
    RenderScript rs = RenderScript.create(VLCApplication.getAppContext());
    // Create an Intrinsic Blur Script using the Renderscript
    ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
    // Create the Allocations (in/out) with the Renderscript and the in/out bitmaps
    Allocation allIn = Allocation.createFromBitmap(rs, bitmap);
    Allocation allOut = Allocation.createFromBitmap(rs, outBitmap);
    // Set the radius of the blur
    blurScript.setRadius(radius);
    // Perform the Renderscript
    blurScript.setInput(allIn);
    blurScript.forEach(allOut);
    // Copy the final bitmap created by the out Allocation to the outBitmap
    allOut.copyTo(outBitmap);
    // After finishing everything, we destroy the Renderscript.
    rs.destroy();
    return outBitmap;
}
Also used : Bitmap(android.graphics.Bitmap) RenderScript(android.renderscript.RenderScript) ScriptIntrinsicBlur(android.renderscript.ScriptIntrinsicBlur) Allocation(android.renderscript.Allocation) RequiresApi(android.support.annotation.RequiresApi)

Example 100 with RequiresApi

use of android.support.annotation.RequiresApi in project vlc-android by videolan.

the class TvUtil method updateBackground.

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public static void updateBackground(final BackgroundManager bm, Object item) {
    if (bm == null)
        return;
    if (item instanceof MediaLibraryItem) {
        final boolean crop = ((MediaLibraryItem) item).getItemType() != MediaLibraryItem.TYPE_MEDIA || ((MediaWrapper) item).getType() == MediaWrapper.TYPE_AUDIO;
        final String artworkMrl = ((MediaLibraryItem) item).getArtworkMrl();
        if (!TextUtils.isEmpty(artworkMrl)) {
            VLCApplication.runBackground(new Runnable() {

                @Override
                public void run() {
                    if (bm == null)
                        return;
                    Bitmap cover = AudioUtil.readCoverBitmap(Uri.decode(artworkMrl), 512);
                    if (cover == null)
                        return;
                    if (crop)
                        cover = BitmapUtil.centerCrop(cover, cover.getWidth(), cover.getWidth() * 10 / 16);
                    final Bitmap blurred = UiTools.blurBitmap(cover, 10f);
                    VLCApplication.runOnMainThread(new Runnable() {

                        @Override
                        public void run() {
                            if (bm == null)
                                return;
                            bm.setColor(0);
                            bm.setDrawable(new BitmapDrawable(VLCApplication.getAppResources(), blurred));
                        }
                    });
                }
            });
            return;
        }
    }
    clearBackground(bm);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Bitmap(android.graphics.Bitmap) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) BitmapDrawable(android.graphics.drawable.BitmapDrawable) RequiresApi(android.support.annotation.RequiresApi)

Aggregations

RequiresApi (android.support.annotation.RequiresApi)191 Intent (android.content.Intent)30 NotificationChannel (android.app.NotificationChannel)28 View (android.view.View)25 NotificationManager (android.app.NotificationManager)17 ViewGroup (android.view.ViewGroup)15 Allocation (android.renderscript.Allocation)14 Bitmap (android.graphics.Bitmap)13 RecyclerView (android.support.v7.widget.RecyclerView)13 ViewTreeObserver (android.view.ViewTreeObserver)12 WindowInsets (android.view.WindowInsets)12 TextView (android.widget.TextView)12 ActionBar (android.support.v7.app.ActionBar)11 Toolbar (android.support.v7.widget.Toolbar)11 Handler (android.os.Handler)10 StatFs (android.os.StatFs)9 Button (android.widget.Button)8 Cipher (javax.crypto.Cipher)8 SuppressLint (android.annotation.SuppressLint)7 Uri (android.net.Uri)7