Files
plexamp-lite/platform/api8/com/minamp/Platform.java
T
XoséandClaude Opus 5.5 13f29e26c4 Plexamp Lite 1.14: Android 4.1 build with ExoPlayer, lyrics, home-screen widget
- One build per Android level, as in Tenda: build/PlexampLite.apk (Android 2.2+, versionCode 1508) and
  build/PlexampLite-api16.apk (Android 4.1+, 1516), from shared src/ plus platform/api8 or platform/api16.
- Android 4.1 build: ExoPlayer 2.18.7 behind a small Engine interface (gapless hand-over to read-ahead and
  downloaded files, a longer buffer, MediaPlayer fallback for tracks it can't decode), a notification and
  lock screen with art and buttons, a resizable widget, Holo, a menu button without a Menu key, metered networks.
  R8 shrinks ExoPlayer and Guava (tools/fetch_exoplayer.sh, tools/r8-rules.pro).
- Both builds: lyrics in Now Playing as in the Mac app (timed lyrics follow and seek), a home-screen widget,
  media play/pause keys, the moon icon drawn without clipPath.
- PlexampLite-noreport on the SD card stops play reports, for tests against a real server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 18:41:26 +01:00

67 lines
2.6 KiB
Java

package com.minamp;
import android.app.Notification;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import com.minamp.plex.Item;
/**
* What differs between Plexamp Lite'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;
/** Size the current track's art is loaded at for the notification, lock screen and widget, in pixels. */
static final int ART_PX = 96;
/** At start-up, before anything else. */
static void init(App app) {}
/** The player for a track. {@code fallback}: the track failed to decode in the usual one. */
static Engine newEngine(Context c, boolean fallback) {
return new MediaPlayerEngine(c);
}
/** On a network that may cost by the megabyte (the "away" quality applies): here, anything but Wi-Fi. */
static boolean metered(Context c) {
try {
ConnectivityManager cm = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
return ni != null && ni.getType() != ConnectivityManager.TYPE_WIFI;
} catch (Exception e) {
return false;
}
}
/** The phone has no Menu key, so screens need a ⋮ button for the options menu. Android 2.x phones all have one. */
static boolean needsMenuButton(Context c) {
return false;
}
/** The playback notification. Android 2.x: title and artist; its notifications can't have buttons. */
@SuppressWarnings("deprecation")
static Notification playerNotification(Context c, Item it, Bitmap art, int state) {
Notification n = new Notification(R.drawable.ic_stat, null, 0);
n.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;
String line = (state == PlayerService.PAUSED ? c.getString(R.string.paused_dot) : "") + it.artist;
n.setLatestEventInfo(c, it.title, line, PlayerViews.open(c));
return n;
}
/** The lock screen's player (null item or IDLE: take it away). Android 2.x has none. */
static void lockScreen(Context c, Item it, Bitmap art, int state) {}
/** The widget's layout for its current size. Android 2.x widgets have one size. */
static int widgetLayout(AppWidgetManager m, int id) {
return R.layout.widget_player;
}
}