package com.miniabs; import android.app.Notification; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.net.ConnectivityManager; import android.net.NetworkInfo; /** * What differs between Podlite's builds, for Android 2.2 and later (the Galaxy Mini). platform/api16 has the same * methods for Android 4.1 and later; the rest of the app is shared and calls these. Keep the two in step. */ final class Platform { private Platform() {} /** The Android level this build is for: its minSdkVersion. */ static final int API = 8; /** The player can change speed and skip silences (Android 2.x's can't). */ static final boolean SPEED = false; /** Size the cover is loaded at for the notification and lock screen. */ static final int COVER_PX = 64; /** At the start of each screen and service (main thread). */ static void init(Context c) {} /** The player for an episode. {@code fallback}: the episode failed to decode in the usual one. */ static Engine newEngine(Context c, boolean fallback) { return new MediaPlayerEngine(c); } /** On a network that doesn't cost by the megabyte (for "download only on Wi-Fi"): here, Wi-Fi. */ static boolean unmetered(Context c) { ConnectivityManager cm = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm == null ? null : cm.getActiveNetworkInfo(); return ni != null && ni.isConnected() && ni.getType() == ConnectivityManager.TYPE_WIFI; } /** The phone has no Menu key, so screens need a ⋮ button. Android 2.x phones all have one. */ static boolean needsMenuButton(Context c) { return false; } /** The playback notification. Android 2.x: title and state; its notifications can't have buttons. */ @SuppressWarnings("deprecation") static Notification playerNotification(Context c, Episode ep, String what, Bitmap cover, int state, boolean ongoing) { Notification n = new Notification(R.drawable.ic_stat, null, 0); n.flags |= ongoing ? Notification.FLAG_ONGOING_EVENT : 0; n.setLatestEventInfo(c, ep.title, Util.join(what, ep.show), openPlayer(c)); return n; } static PendingIntent openPlayer(Context c) { Intent i = new Intent(c, PlayerActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); return PendingIntent.getActivity(c, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); } /** The lock screen's player (null episode or IDLE: take it away). Android 2.x has none. */ static void lockScreen(Context c, Episode ep, Bitmap cover, int state) {} }