refactor: optimizar app sin cambios funcionales y publicar v11.0.1
This commit is contained in:
@@ -8,8 +8,8 @@ android {
|
|||||||
applicationId "com.streamplayer"
|
applicationId "com.streamplayer"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 35
|
targetSdk 35
|
||||||
versionCode 100200
|
versionCode 100201
|
||||||
versionName "11.0.0"
|
versionName "11.0.1"
|
||||||
buildConfigField "String", "DEVICE_REGISTRY_URL", '"http://194.163.191.200:4000"'
|
buildConfigField "String", "DEVICE_REGISTRY_URL", '"http://194.163.191.200:4000"'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,9 +51,6 @@ dependencies {
|
|||||||
implementation 'androidx.media3:media3-exoplayer-hls:1.4.1'
|
implementation 'androidx.media3:media3-exoplayer-hls:1.4.1'
|
||||||
implementation 'androidx.media3:media3-ui:1.4.1'
|
implementation 'androidx.media3:media3-ui:1.4.1'
|
||||||
|
|
||||||
// VLC Player para reproduccion de video (soporte DRM mejorado)
|
|
||||||
implementation 'org.videolan.android:libvlc-all:3.4.4'
|
|
||||||
|
|
||||||
// OkHttp con DNS over HTTPS (para StreamUrlResolver)
|
// OkHttp con DNS over HTTPS (para StreamUrlResolver)
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
||||||
implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.12.0'
|
implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.12.0'
|
||||||
|
|||||||
@@ -7,21 +7,37 @@ import android.widget.ImageView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.DiffUtil;
|
||||||
|
import androidx.recyclerview.widget.ListAdapter;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ChannelAdapter extends RecyclerView.Adapter<ChannelAdapter.ChannelViewHolder> {
|
public class ChannelAdapter extends ListAdapter<StreamChannel, ChannelAdapter.ChannelViewHolder> {
|
||||||
|
|
||||||
public interface OnChannelClickListener {
|
public interface OnChannelClickListener {
|
||||||
void onChannelClick(StreamChannel channel);
|
void onChannelClick(StreamChannel channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final List<StreamChannel> channels = new ArrayList<>();
|
private static final DiffUtil.ItemCallback<StreamChannel> DIFF_CALLBACK =
|
||||||
|
new DiffUtil.ItemCallback<StreamChannel>() {
|
||||||
|
@Override
|
||||||
|
public boolean areItemsTheSame(@NonNull StreamChannel oldItem, @NonNull StreamChannel newItem) {
|
||||||
|
return oldItem.getPageUrl().equals(newItem.getPageUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areContentsTheSame(@NonNull StreamChannel oldItem, @NonNull StreamChannel newItem) {
|
||||||
|
return oldItem.getName().equals(newItem.getName())
|
||||||
|
&& oldItem.getPageUrl().equals(newItem.getPageUrl());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private final OnChannelClickListener listener;
|
private final OnChannelClickListener listener;
|
||||||
|
|
||||||
public ChannelAdapter(OnChannelClickListener listener) {
|
public ChannelAdapter(OnChannelClickListener listener) {
|
||||||
|
super(DIFF_CALLBACK);
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +51,7 @@ public class ChannelAdapter extends RecyclerView.Adapter<ChannelAdapter.ChannelV
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ChannelViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull ChannelViewHolder holder, int position) {
|
||||||
StreamChannel channel = channels.get(position);
|
StreamChannel channel = getItem(position);
|
||||||
holder.name.setText(channel.getName());
|
holder.name.setText(channel.getName());
|
||||||
holder.icon.setImageResource(R.drawable.ic_channel_default);
|
holder.icon.setImageResource(R.drawable.ic_channel_default);
|
||||||
holder.itemView.setOnClickListener(v -> {
|
holder.itemView.setOnClickListener(v -> {
|
||||||
@@ -52,7 +68,7 @@ public class ChannelAdapter extends RecyclerView.Adapter<ChannelAdapter.ChannelV
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return channels.size();
|
return super.getItemCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ChannelViewHolder extends RecyclerView.ViewHolder {
|
static class ChannelViewHolder extends RecyclerView.ViewHolder {
|
||||||
@@ -67,10 +83,10 @@ public class ChannelAdapter extends RecyclerView.Adapter<ChannelAdapter.ChannelV
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void submitList(List<StreamChannel> newChannels) {
|
public void submitList(List<StreamChannel> newChannels) {
|
||||||
channels.clear();
|
if (newChannels == null) {
|
||||||
if (newChannels != null) {
|
super.submitList(null);
|
||||||
channels.addAll(newChannels);
|
return;
|
||||||
}
|
}
|
||||||
notifyDataSetChanged();
|
super.submitList(new ArrayList<>(newChannels));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,13 @@ import java.util.List;
|
|||||||
public final class ChannelRepository {
|
public final class ChannelRepository {
|
||||||
|
|
||||||
private static final List<StreamChannel> CHANNELS = createChannels();
|
private static final List<StreamChannel> CHANNELS = createChannels();
|
||||||
|
private static final Comparator<StreamChannel> CHANNEL_NAME_COMPARATOR =
|
||||||
|
new Comparator<StreamChannel>() {
|
||||||
|
@Override
|
||||||
|
public int compare(StreamChannel left, StreamChannel right) {
|
||||||
|
return String.CASE_INSENSITIVE_ORDER.compare(left.getName(), right.getName());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private static List<StreamChannel> createChannels() {
|
private static List<StreamChannel> createChannels() {
|
||||||
List<StreamChannel> channels = new ArrayList<>(Arrays.asList(
|
List<StreamChannel> channels = new ArrayList<>(Arrays.asList(
|
||||||
@@ -79,7 +86,7 @@ public final class ChannelRepository {
|
|||||||
new StreamChannel("FUTV", "http://streamtp10.com/global2.php?stream=futv"),
|
new StreamChannel("FUTV", "http://streamtp10.com/global2.php?stream=futv"),
|
||||||
new StreamChannel("LaLiga Hypermotion", "http://streamtp10.com/global2.php?stream=laligahypermotion")
|
new StreamChannel("LaLiga Hypermotion", "http://streamtp10.com/global2.php?stream=laligahypermotion")
|
||||||
));
|
));
|
||||||
channels.sort(Comparator.comparing(StreamChannel::getName, String.CASE_INSENSITIVE_ORDER));
|
Collections.sort(channels, CHANNEL_NAME_COMPARATOR);
|
||||||
return Collections.unmodifiableList(channels);
|
return Collections.unmodifiableList(channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ public class DeviceRegistry {
|
|||||||
if (TextUtils.isEmpty(value)) {
|
if (TextUtils.isEmpty(value)) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return value.substring(0, 1).toUpperCase(Locale.getDefault())
|
return value.substring(0, 1).toUpperCase(Locale.ROOT)
|
||||||
+ value.substring(1);
|
+ value.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,29 +6,53 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.DiffUtil;
|
||||||
|
import androidx.recyclerview.widget.ListAdapter;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class EventAdapter extends RecyclerView.Adapter<EventAdapter.EventViewHolder> {
|
public class EventAdapter extends ListAdapter<EventItem, EventAdapter.EventViewHolder> {
|
||||||
|
|
||||||
public interface OnEventClickListener {
|
public interface OnEventClickListener {
|
||||||
void onEventClick(EventItem event);
|
void onEventClick(EventItem event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final List<EventItem> events = new ArrayList<>();
|
private static final DiffUtil.ItemCallback<EventItem> DIFF_CALLBACK =
|
||||||
|
new DiffUtil.ItemCallback<EventItem>() {
|
||||||
|
@Override
|
||||||
|
public boolean areItemsTheSame(@NonNull EventItem oldItem, @NonNull EventItem newItem) {
|
||||||
|
return oldItem.getPageUrl().equals(newItem.getPageUrl())
|
||||||
|
&& oldItem.getStartMillis() == newItem.getStartMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areContentsTheSame(@NonNull EventItem oldItem, @NonNull EventItem newItem) {
|
||||||
|
return oldItem.getTitle().equals(newItem.getTitle())
|
||||||
|
&& oldItem.getTime().equals(newItem.getTime())
|
||||||
|
&& oldItem.getCategory().equals(newItem.getCategory())
|
||||||
|
&& oldItem.getStatus().equals(newItem.getStatus())
|
||||||
|
&& oldItem.getPageUrl().equals(newItem.getPageUrl())
|
||||||
|
&& oldItem.getChannelName().equals(newItem.getChannelName())
|
||||||
|
&& oldItem.getStartMillis() == newItem.getStartMillis();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private final OnEventClickListener listener;
|
private final OnEventClickListener listener;
|
||||||
|
|
||||||
public EventAdapter(OnEventClickListener listener) {
|
public EventAdapter(OnEventClickListener listener) {
|
||||||
|
super(DIFF_CALLBACK);
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void submitList(List<EventItem> newEvents) {
|
public void submitList(List<EventItem> newEvents) {
|
||||||
events.clear();
|
if (newEvents == null) {
|
||||||
events.addAll(newEvents);
|
super.submitList(null);
|
||||||
notifyDataSetChanged();
|
return;
|
||||||
|
}
|
||||||
|
super.submitList(new ArrayList<>(newEvents));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -41,7 +65,7 @@ public class EventAdapter extends RecyclerView.Adapter<EventAdapter.EventViewHol
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull EventViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull EventViewHolder holder, int position) {
|
||||||
EventItem event = events.get(position);
|
EventItem event = getItem(position);
|
||||||
holder.title.setText(event.getTitle());
|
holder.title.setText(event.getTitle());
|
||||||
holder.time.setText(event.getTime());
|
holder.time.setText(event.getTime());
|
||||||
holder.channel.setText(event.getChannelName());
|
holder.channel.setText(event.getChannelName());
|
||||||
@@ -55,7 +79,7 @@ public class EventAdapter extends RecyclerView.Adapter<EventAdapter.EventViewHol
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return events.size();
|
return super.getItemCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
static class EventViewHolder extends RecyclerView.ViewHolder {
|
static class EventViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|||||||
@@ -8,16 +8,14 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.time.format.DateTimeParseException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
@@ -28,6 +26,10 @@ public class EventRepository {
|
|||||||
private static final String KEY_JSON = "json";
|
private static final String KEY_JSON = "json";
|
||||||
private static final String KEY_TIMESTAMP = "timestamp";
|
private static final String KEY_TIMESTAMP = "timestamp";
|
||||||
private static final long CACHE_DURATION = 24L * 60 * 60 * 1000; // 24 horas
|
private static final long CACHE_DURATION = 24L * 60 * 60 * 1000; // 24 horas
|
||||||
|
private static final String ARGENTINA_TIMEZONE_ID = "America/Argentina/Buenos_Aires";
|
||||||
|
private static final TimeZone ARGENTINA_TIMEZONE = TimeZone.getTimeZone(ARGENTINA_TIMEZONE_ID);
|
||||||
|
private static final int ARGENTINA_OFFSET_HOURS = 2;
|
||||||
|
private static final long EVENT_ROLLOVER_WINDOW_MS = 12L * 60 * 60 * 1000;
|
||||||
|
|
||||||
// URL única para eventos (actualizado para evitar bloqueos de ISP)
|
// URL única para eventos (actualizado para evitar bloqueos de ISP)
|
||||||
private static final String EVENTS_URL = "http://streamtp10.com/eventos.json";
|
private static final String EVENTS_URL = "http://streamtp10.com/eventos.json";
|
||||||
@@ -89,12 +91,6 @@ public class EventRepository {
|
|||||||
throw new IOException("Respuesta vacía del servidor");
|
throw new IOException("Respuesta vacía del servidor");
|
||||||
}
|
}
|
||||||
|
|
||||||
String contentType = response.header("Content-Type");
|
|
||||||
// Permitir json o text/plain (Raw de Gitea a veces es text/plain)
|
|
||||||
if (contentType != null && !contentType.contains("json") && !contentType.contains("text/plain")) {
|
|
||||||
// Aceptamos text/plain también por flexibilidad
|
|
||||||
}
|
|
||||||
|
|
||||||
String responseBody = response.body().string();
|
String responseBody = response.body().string();
|
||||||
|
|
||||||
// Validar que no sea HTML
|
// Validar que no sea HTML
|
||||||
@@ -119,7 +115,6 @@ public class EventRepository {
|
|||||||
|
|
||||||
JSONArray array = new JSONArray(json);
|
JSONArray array = new JSONArray(json);
|
||||||
List<EventItem> events = new ArrayList<>();
|
List<EventItem> events = new ArrayList<>();
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
|
||||||
|
|
||||||
for (int i = 0; i < array.length(); i++) {
|
for (int i = 0; i < array.length(); i++) {
|
||||||
JSONObject obj = array.getJSONObject(i);
|
JSONObject obj = array.getJSONObject(i);
|
||||||
@@ -129,19 +124,10 @@ public class EventRepository {
|
|||||||
String status = obj.optString("status");
|
String status = obj.optString("status");
|
||||||
String link = obj.optString("link");
|
String link = obj.optString("link");
|
||||||
String normalized = normalizeLink(link);
|
String normalized = normalizeLink(link);
|
||||||
|
|
||||||
// Ajustar hora: la web muestra hora de España, Argentina es +2 horas
|
EventSchedule schedule = computeEventSchedule(time);
|
||||||
String displayTime = time;
|
String displayTime = schedule.displayTime;
|
||||||
try {
|
long startMillis = schedule.startMillis;
|
||||||
if (time != null && !time.isEmpty()) {
|
|
||||||
LocalTime localTime = LocalTime.parse(time.trim(), formatter);
|
|
||||||
LocalTime adjustedTime = localTime.plusHours(2);
|
|
||||||
displayTime = adjustedTime.format(formatter);
|
|
||||||
}
|
|
||||||
} catch (DateTimeParseException ignored) {
|
|
||||||
}
|
|
||||||
|
|
||||||
long startMillis = parseEventTime(time);
|
|
||||||
events.add(new EventItem(title, displayTime, category, status, normalized, extractChannelName(link), startMillis));
|
events.add(new EventItem(title, displayTime, category, status, normalized, extractChannelName(link), startMillis));
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableList(events);
|
return Collections.unmodifiableList(events);
|
||||||
@@ -164,28 +150,69 @@ public class EventRepository {
|
|||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return link.substring(idx + 7).replace("_", " ").toUpperCase();
|
return link.substring(idx + 7).replace("_", " ").toUpperCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private long parseEventTime(String time) {
|
private EventSchedule computeEventSchedule(String time) {
|
||||||
if (time == null || time.isEmpty()) {
|
if (time == null || time.trim().isEmpty()) {
|
||||||
return -1;
|
return new EventSchedule(time == null ? "" : time, -1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
Calendar adjustedTime = parseAdjustedTime(time);
|
||||||
LocalTime localTime = LocalTime.parse(time.trim(), formatter);
|
String displayTime = formatTime(adjustedTime);
|
||||||
// Ajustar hora: la web muestra hora de España, Argentina es +2 horas
|
|
||||||
LocalTime adjustedTime = localTime.plusHours(2);
|
Calendar now = Calendar.getInstance(ARGENTINA_TIMEZONE, Locale.US);
|
||||||
ZoneId zone = ZoneId.of("America/Argentina/Buenos_Aires");
|
Calendar start = Calendar.getInstance(ARGENTINA_TIMEZONE, Locale.US);
|
||||||
LocalDate today = LocalDate.now(zone);
|
start.set(Calendar.YEAR, now.get(Calendar.YEAR));
|
||||||
ZonedDateTime start = ZonedDateTime.of(LocalDateTime.of(today, adjustedTime), zone);
|
start.set(Calendar.MONTH, now.get(Calendar.MONTH));
|
||||||
ZonedDateTime now = ZonedDateTime.now(zone);
|
start.set(Calendar.DAY_OF_MONTH, now.get(Calendar.DAY_OF_MONTH));
|
||||||
if (start.isBefore(now.minusHours(12))) {
|
start.set(Calendar.HOUR_OF_DAY, adjustedTime.get(Calendar.HOUR_OF_DAY));
|
||||||
start = start.plusDays(1);
|
start.set(Calendar.MINUTE, adjustedTime.get(Calendar.MINUTE));
|
||||||
|
start.set(Calendar.SECOND, 0);
|
||||||
|
start.set(Calendar.MILLISECOND, 0);
|
||||||
|
|
||||||
|
long nowMillis = now.getTimeInMillis();
|
||||||
|
long startMillis = start.getTimeInMillis();
|
||||||
|
if (startMillis < nowMillis - EVENT_ROLLOVER_WINDOW_MS) {
|
||||||
|
start.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
startMillis = start.getTimeInMillis();
|
||||||
}
|
}
|
||||||
return start.toInstant().toEpochMilli();
|
|
||||||
} catch (DateTimeParseException e) {
|
return new EventSchedule(displayTime, startMillis);
|
||||||
return -1;
|
} catch (ParseException ignored) {
|
||||||
|
return new EventSchedule(time, -1L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Calendar parseAdjustedTime(String time) throws ParseException {
|
||||||
|
SimpleDateFormat parser = new SimpleDateFormat("HH:mm", Locale.US);
|
||||||
|
parser.setLenient(false);
|
||||||
|
parser.setTimeZone(ARGENTINA_TIMEZONE);
|
||||||
|
java.util.Date parsedDate = parser.parse(time.trim());
|
||||||
|
if (parsedDate == null) {
|
||||||
|
throw new ParseException("Hora inválida: " + time, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Calendar adjusted = Calendar.getInstance(ARGENTINA_TIMEZONE, Locale.US);
|
||||||
|
adjusted.setTime(parsedDate);
|
||||||
|
adjusted.add(Calendar.HOUR_OF_DAY, ARGENTINA_OFFSET_HOURS);
|
||||||
|
return adjusted;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String formatTime(Calendar calendar) {
|
||||||
|
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm", Locale.US);
|
||||||
|
formatter.setTimeZone(ARGENTINA_TIMEZONE);
|
||||||
|
return formatter.format(calendar.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class EventSchedule {
|
||||||
|
final String displayTime;
|
||||||
|
final long startMillis;
|
||||||
|
|
||||||
|
EventSchedule(String displayTime, long startMillis) {
|
||||||
|
this.displayTime = displayTime;
|
||||||
|
this.startMillis = startMillis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.streamplayer;
|
package com.streamplayer;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -333,7 +334,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||||
try {
|
try {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} catch (Exception e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
Toast.makeText(this, R.string.update_error_open_release, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.update_error_open_release, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -398,7 +399,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
List<StreamChannel> allChannels = ChannelRepository.getChannels();
|
List<StreamChannel> allChannels = ChannelRepository.getChannels();
|
||||||
for (StreamChannel channel : allChannels) {
|
for (StreamChannel channel : allChannels) {
|
||||||
String key = deriveGroupName(channel.getName());
|
String key = deriveGroupName(channel.getName());
|
||||||
grouped.computeIfAbsent(key, k -> new ArrayList<>()).add(channel);
|
List<StreamChannel> group = grouped.get(key);
|
||||||
|
if (group == null) {
|
||||||
|
group = new ArrayList<>();
|
||||||
|
grouped.put(key, group);
|
||||||
|
}
|
||||||
|
group.add(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<StreamChannel> espnChannels = grouped.remove("ESPN");
|
List<StreamChannel> espnChannels = grouped.remove("ESPN");
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package com.streamplayer;
|
package com.streamplayer;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -19,8 +20,9 @@ import okhttp3.dnsoverhttps.DnsOverHttps;
|
|||||||
* Utilidad centralizada para configuración de red.
|
* Utilidad centralizada para configuración de red.
|
||||||
* Fuerza DNS over HTTPS con fallback Google -> Cloudflare -> DNS del sistema.
|
* Fuerza DNS over HTTPS con fallback Google -> Cloudflare -> DNS del sistema.
|
||||||
*/
|
*/
|
||||||
public class NetworkUtils {
|
public final class NetworkUtils {
|
||||||
|
|
||||||
|
private static final String TAG = "NetworkUtils";
|
||||||
private static final OkHttpClient CLIENT;
|
private static final OkHttpClient CLIENT;
|
||||||
private static final String USER_AGENT = "Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36";
|
private static final String USER_AGENT = "Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36";
|
||||||
private static final String GOOGLE_DOH_URL = "https://dns.google/dns-query";
|
private static final String GOOGLE_DOH_URL = "https://dns.google/dns-query";
|
||||||
@@ -51,7 +53,7 @@ public class NetworkUtils {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
final SSLContext sslContext = SSLContext.getInstance("SSL");
|
final SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||||
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
|
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||||
|
|
||||||
builder.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts[0]);
|
builder.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts[0]);
|
||||||
@@ -105,12 +107,15 @@ public class NetworkUtils {
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
builder.dns(Dns.SYSTEM);
|
builder.dns(Dns.SYSTEM);
|
||||||
System.out.println("Error configurando DNS over HTTPS: " + e.getMessage());
|
Log.w(TAG, "Error configurando DNS over HTTPS", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLIENT = builder.build();
|
CLIENT = builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private NetworkUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
public static OkHttpClient getClient() {
|
public static OkHttpClient getClient() {
|
||||||
return CLIENT;
|
return CLIENT;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.StrictMode;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
@@ -13,10 +12,12 @@ import android.widget.Button;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.OptIn;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.media3.common.MediaItem;
|
import androidx.media3.common.MediaItem;
|
||||||
import androidx.media3.common.PlaybackException;
|
import androidx.media3.common.PlaybackException;
|
||||||
import androidx.media3.common.Player;
|
import androidx.media3.common.Player;
|
||||||
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.datasource.DefaultHttpDataSource;
|
import androidx.media3.datasource.DefaultHttpDataSource;
|
||||||
import androidx.media3.exoplayer.ExoPlayer;
|
import androidx.media3.exoplayer.ExoPlayer;
|
||||||
import androidx.media3.exoplayer.hls.HlsMediaSource;
|
import androidx.media3.exoplayer.hls.HlsMediaSource;
|
||||||
@@ -24,8 +25,10 @@ import androidx.media3.ui.PlayerView;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@OptIn(markerClass = UnstableApi.class)
|
||||||
public class PlayerActivity extends AppCompatActivity {
|
public class PlayerActivity extends AppCompatActivity {
|
||||||
|
|
||||||
public static final String EXTRA_CHANNEL_NAME = "extra_channel_name";
|
public static final String EXTRA_CHANNEL_NAME = "extra_channel_name";
|
||||||
@@ -58,10 +61,6 @@ public class PlayerActivity extends AppCompatActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
StrictMode.setThreadPolicy(
|
|
||||||
new StrictMode.ThreadPolicy.Builder().permitAll().build()
|
|
||||||
);
|
|
||||||
|
|
||||||
setContentView(R.layout.activity_player);
|
setContentView(R.layout.activity_player);
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
||||||
@@ -261,7 +260,7 @@ public class PlayerActivity extends AppCompatActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String lower = errorMsg.toLowerCase();
|
String lower = errorMsg.toLowerCase(Locale.ROOT);
|
||||||
boolean isRetryableError =
|
boolean isRetryableError =
|
||||||
lower.contains("404") ||
|
lower.contains("404") ||
|
||||||
lower.contains("403") ||
|
lower.contains("403") ||
|
||||||
@@ -275,7 +274,7 @@ public class PlayerActivity extends AppCompatActivity {
|
|||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
showLoading(true);
|
showLoading(true);
|
||||||
errorMessage.setVisibility(View.VISIBLE);
|
errorMessage.setVisibility(View.VISIBLE);
|
||||||
errorMessage.setText("Error de conexión. Reintentando... (" + retryCount + "/" + VlcPlayerConfig.MAX_RETRIES + ")");
|
errorMessage.setText(getString(R.string.player_retrying, retryCount, VlcPlayerConfig.MAX_RETRIES));
|
||||||
});
|
});
|
||||||
|
|
||||||
mainHandler.postDelayed(() -> {
|
mainHandler.postDelayed(() -> {
|
||||||
@@ -406,6 +405,7 @@ public class PlayerActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
|
mainHandler.removeCallbacksAndMessages(null);
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
releasePlayer();
|
releasePlayer();
|
||||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|||||||
@@ -3,35 +3,24 @@ package com.streamplayer;
|
|||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
|
||||||
import javax.net.ssl.TrustManager;
|
|
||||||
import javax.net.ssl.X509TrustManager;
|
|
||||||
|
|
||||||
import okhttp3.Dns;
|
|
||||||
import okhttp3.HttpUrl;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import okhttp3.dnsoverhttps.DnsOverHttps;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resuelve la URL real del stream extrayendo playbackURL de la página.
|
* Resuelve la URL real del stream extrayendo playbackURL de la página.
|
||||||
* Utiliza DNS over HTTPS (Google + Cloudflare) para evitar bloqueos.
|
* Utiliza DNS over HTTPS (Google + Cloudflare) para evitar bloqueos.
|
||||||
* Soporta múltiples formatos de páginas y streams directos.
|
* Soporta múltiples formatos de páginas y streams directos.
|
||||||
* Soporta JWPlayer con DRM ClearKey.
|
* Incluye fallback para páginas con JWPlayer y formatos ofuscados.
|
||||||
*/
|
*/
|
||||||
public final class StreamUrlResolver {
|
public final class StreamUrlResolver {
|
||||||
|
|
||||||
@@ -73,93 +62,6 @@ public final class StreamUrlResolver {
|
|||||||
Pattern.compile("function\\s+([A-Za-z_$][\\w$]*)\\s*\\(\\)\\s*\\{\\s*return\\s*(\\d+)\\s*;?\\s*\\}",
|
Pattern.compile("function\\s+([A-Za-z_$][\\w$]*)\\s*\\(\\)\\s*\\{\\s*return\\s*(\\d+)\\s*;?\\s*\\}",
|
||||||
Pattern.DOTALL);
|
Pattern.DOTALL);
|
||||||
|
|
||||||
private static final String USER_AGENT = "Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36";
|
|
||||||
|
|
||||||
private static final OkHttpClient CLIENT;
|
|
||||||
|
|
||||||
static {
|
|
||||||
OkHttpClient client = null;
|
|
||||||
try {
|
|
||||||
final TrustManager[] trustAllCerts = new TrustManager[]{
|
|
||||||
new X509TrustManager() {
|
|
||||||
@Override
|
|
||||||
public void checkClientTrusted(X509Certificate[] chain, String authType) {}
|
|
||||||
@Override
|
|
||||||
public void checkServerTrusted(X509Certificate[] chain, String authType) {}
|
|
||||||
@Override
|
|
||||||
public X509Certificate[] getAcceptedIssuers() {
|
|
||||||
return new X509Certificate[]{};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
final SSLContext sslContext = SSLContext.getInstance("SSL");
|
|
||||||
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
|
|
||||||
|
|
||||||
OkHttpClient.Builder builder = new OkHttpClient.Builder()
|
|
||||||
.connectTimeout(15, TimeUnit.SECONDS)
|
|
||||||
.readTimeout(15, TimeUnit.SECONDS)
|
|
||||||
.followRedirects(true)
|
|
||||||
.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts[0])
|
|
||||||
.hostnameVerifier((hostname, session) -> true);
|
|
||||||
|
|
||||||
OkHttpClient bootstrap = new OkHttpClient.Builder()
|
|
||||||
.connectTimeout(10, TimeUnit.SECONDS)
|
|
||||||
.readTimeout(10, TimeUnit.SECONDS)
|
|
||||||
.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts[0])
|
|
||||||
.hostnameVerifier((hostname, session) -> true)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
final DnsOverHttps googleDns = new DnsOverHttps.Builder()
|
|
||||||
.client(bootstrap)
|
|
||||||
.url(HttpUrl.get("https://dns.google/dns-query"))
|
|
||||||
.bootstrapDnsHosts(
|
|
||||||
InetAddress.getByName("8.8.8.8"),
|
|
||||||
InetAddress.getByName("8.8.4.4"))
|
|
||||||
.includeIPv6(false)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
final DnsOverHttps cloudflareDns = new DnsOverHttps.Builder()
|
|
||||||
.client(bootstrap)
|
|
||||||
.url(HttpUrl.get("https://cloudflare-dns.com/dns-query"))
|
|
||||||
.bootstrapDnsHosts(
|
|
||||||
InetAddress.getByName("1.1.1.1"),
|
|
||||||
InetAddress.getByName("1.0.0.1"))
|
|
||||||
.includeIPv6(false)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
builder.dns(hostname -> {
|
|
||||||
try {
|
|
||||||
List<InetAddress> result = googleDns.lookup(hostname);
|
|
||||||
if (result != null && !result.isEmpty()) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
List<InetAddress> result = cloudflareDns.lookup(hostname);
|
|
||||||
if (result != null && !result.isEmpty()) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return Dns.SYSTEM.lookup(hostname);
|
|
||||||
});
|
|
||||||
|
|
||||||
client = builder.build();
|
|
||||||
} catch (Exception e) {
|
|
||||||
client = new OkHttpClient.Builder()
|
|
||||||
.connectTimeout(15, TimeUnit.SECONDS)
|
|
||||||
.readTimeout(15, TimeUnit.SECONDS)
|
|
||||||
.followRedirects(true)
|
|
||||||
.dns(Dns.SYSTEM)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
CLIENT = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
private StreamUrlResolver() {
|
private StreamUrlResolver() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +208,12 @@ public final class StreamUrlResolver {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(pairs, Comparator.comparingInt(pair -> pair.index));
|
Collections.sort(pairs, new Comparator<EncodedPair>() {
|
||||||
|
@Override
|
||||||
|
public int compare(EncodedPair left, EncodedPair right) {
|
||||||
|
return Integer.compare(left.index, right.index);
|
||||||
|
}
|
||||||
|
});
|
||||||
StringBuilder decoded = new StringBuilder(pairs.size());
|
StringBuilder decoded = new StringBuilder(pairs.size());
|
||||||
|
|
||||||
for (EncodedPair pair : pairs) {
|
for (EncodedPair pair : pairs) {
|
||||||
@@ -357,10 +264,10 @@ public final class StreamUrlResolver {
|
|||||||
if (url == null || url.isEmpty()) {
|
if (url == null || url.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String lower = url.toLowerCase();
|
String lower = url.toLowerCase(Locale.ROOT);
|
||||||
return lower.contains(".m3u8") ||
|
return lower.contains(".m3u8") ||
|
||||||
lower.contains(".mpd") ||
|
lower.contains(".mpd") ||
|
||||||
lower.contains("stream") && lower.contains(".php") == false ||
|
(lower.contains("stream") && !lower.contains(".php")) ||
|
||||||
lower.endsWith(".mp4") ||
|
lower.endsWith(".mp4") ||
|
||||||
lower.endsWith(".ts");
|
lower.endsWith(".ts");
|
||||||
}
|
}
|
||||||
@@ -390,36 +297,16 @@ public final class StreamUrlResolver {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Intenta determinar el tipo de contenido del HTML
|
|
||||||
*/
|
|
||||||
private static String getContentTypeFromHtml(String html) {
|
|
||||||
if (html == null || html.isEmpty()) {
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
String trimmed = html.trim();
|
|
||||||
if (trimmed.startsWith("#EXTM3U") || trimmed.startsWith("#EXT")) {
|
|
||||||
return "m3u8";
|
|
||||||
}
|
|
||||||
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
||||||
return "json";
|
|
||||||
}
|
|
||||||
if (trimmed.startsWith("<")) {
|
|
||||||
return "html";
|
|
||||||
}
|
|
||||||
return "text";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String downloadPage(String pageUrl) throws IOException {
|
private static String downloadPage(String pageUrl) throws IOException {
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(pageUrl)
|
.url(pageUrl)
|
||||||
.header("User-Agent", USER_AGENT)
|
.header("User-Agent", NetworkUtils.getUserAgent())
|
||||||
.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
|
.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
|
||||||
.header("Accept-Language", "es-ES,es;q=0.9,en;q=0.8")
|
.header("Accept-Language", "es-ES,es;q=0.9,en;q=0.8")
|
||||||
.header("Referer", "http://streamtp10.com/")
|
.header("Referer", "http://streamtp10.com/")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = CLIENT.newCall(request).execute()) {
|
try (Response response = NetworkUtils.getClient().newCall(request).execute()) {
|
||||||
if (!response.isSuccessful()) {
|
if (!response.isSuccessful()) {
|
||||||
throw new IOException("Error HTTP " + response.code() + " al cargar la página del stream");
|
throw new IOException("Error HTTP " + response.code() + " al cargar la página del stream");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import android.util.Log;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@@ -34,7 +35,6 @@ import java.util.concurrent.Executors;
|
|||||||
|
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Request;
|
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,7 +117,7 @@ public class UpdateManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File targetDir = appContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
|
File targetDir = appContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
|
||||||
if (targetDir == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (targetDir == null) {
|
||||||
targetDir = appContext.getExternalFilesDir(null);
|
targetDir = appContext.getExternalFilesDir(null);
|
||||||
}
|
}
|
||||||
if (targetDir == null) {
|
if (targetDir == null) {
|
||||||
@@ -273,21 +273,27 @@ public class UpdateManager {
|
|||||||
if (assets == null) {
|
if (assets == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
JSONObject fallback = null;
|
JSONObject firstApk = null;
|
||||||
|
JSONObject debugApk = null;
|
||||||
for (int i = 0; i < assets.length(); i++) {
|
for (int i = 0; i < assets.length(); i++) {
|
||||||
JSONObject asset = assets.optJSONObject(i);
|
JSONObject asset = assets.optJSONObject(i);
|
||||||
if (asset == null) {
|
if (asset == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (fallback == null) {
|
|
||||||
fallback = asset;
|
|
||||||
}
|
|
||||||
String name = asset.optString("name", "").toLowerCase(Locale.US);
|
String name = asset.optString("name", "").toLowerCase(Locale.US);
|
||||||
if (name.endsWith(".apk")) {
|
if (name.endsWith(".apk")) {
|
||||||
return asset;
|
if (name.contains("release")) {
|
||||||
|
return asset;
|
||||||
|
}
|
||||||
|
if (firstApk == null) {
|
||||||
|
firstApk = asset;
|
||||||
|
}
|
||||||
|
if (name.contains("debug") && debugApk == null) {
|
||||||
|
debugApk = asset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fallback;
|
return firstApk != null ? firstApk : debugApk;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String deriveVersionName(String tagName, String fallback) {
|
private String deriveVersionName(String tagName, String fallback) {
|
||||||
@@ -363,7 +369,12 @@ public class UpdateManager {
|
|||||||
}
|
}
|
||||||
downloadReceiver = new DownloadReceiver();
|
downloadReceiver = new DownloadReceiver();
|
||||||
IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
|
IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
|
||||||
appContext.registerReceiver(downloadReceiver, filter);
|
ContextCompat.registerReceiver(
|
||||||
|
appContext,
|
||||||
|
downloadReceiver,
|
||||||
|
filter,
|
||||||
|
ContextCompat.RECEIVER_NOT_EXPORTED
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unregisterDownloadReceiver() {
|
private void unregisterDownloadReceiver() {
|
||||||
@@ -440,7 +451,10 @@ public class UpdateManager {
|
|||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mainHandler.post(() -> callback.onError(message));
|
String safeMessage = TextUtils.isEmpty(message)
|
||||||
|
? appContext.getString(R.string.update_error_unknown)
|
||||||
|
: message;
|
||||||
|
mainHandler.post(() -> callback.onError(safeMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showToast(String message) {
|
private void showToast(String message) {
|
||||||
@@ -533,4 +547,3 @@ public class UpdateManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
package com.streamplayer;
|
|
||||||
|
|
||||||
import org.videolan.libvlc.Media;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles DRM configuration for VLC Media Player
|
|
||||||
* Supports ClearKey DRM for protected streaming services
|
|
||||||
*/
|
|
||||||
public class VlcDrmManager {
|
|
||||||
|
|
||||||
// ClearKey DRM configuration
|
|
||||||
private static final String CLEARKEY_KEY_SYSTEM = "org.w3.clearkey";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure ClearKey DRM for a Media object
|
|
||||||
* @param media The VLC Media object
|
|
||||||
* @param keyId The key ID (extracted from manifest or license server)
|
|
||||||
* @param key The content key
|
|
||||||
*/
|
|
||||||
public static void configureClearKey(Media media, String keyId, String key) {
|
|
||||||
if (media == null || keyId == null || key == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// VLC uses a specific format for ClearKey
|
|
||||||
// Format: keyid:key
|
|
||||||
String keyPair = keyId + ":" + key;
|
|
||||||
media.addOption(":demux=avformat");
|
|
||||||
media.addOption(":key-format=" + CLEARKEY_KEY_SYSTEM);
|
|
||||||
media.addOption(":key=" + keyPair);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure ClearKey DRM with multiple keys
|
|
||||||
* @param media The VLC Media object
|
|
||||||
* @param keys Map of keyId -> key pairs
|
|
||||||
*/
|
|
||||||
public static void configureClearKey(Media media, Map<String, String> keys) {
|
|
||||||
if (media == null || keys == null || keys.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
media.addOption(":demux=avformat");
|
|
||||||
media.addOption(":key-format=" + CLEARKEY_KEY_SYSTEM);
|
|
||||||
|
|
||||||
for (Map.Entry<String, String> entry : keys.entrySet()) {
|
|
||||||
String keyPair = entry.getKey() + ":" + entry.getValue();
|
|
||||||
media.addOption(":key=" + keyPair);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure Widevine DRM (for reference, if needed later)
|
|
||||||
* VLC supports Widevine via specific options
|
|
||||||
*/
|
|
||||||
public static void configureWidevine(Media media, String drmServerUrl) {
|
|
||||||
if (media == null || drmServerUrl == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
media.addOption(":drm=widevine");
|
|
||||||
media.addOption(":aes-key=" + drmServerUrl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +1,14 @@
|
|||||||
package com.streamplayer;
|
package com.streamplayer;
|
||||||
|
|
||||||
/**
|
public final class VlcPlayerConfig {
|
||||||
* Configuration constants for VLC Player
|
|
||||||
*/
|
|
||||||
public class VlcPlayerConfig {
|
|
||||||
|
|
||||||
// Network caching (ms)
|
|
||||||
public static final int NETWORK_CACHING = 1500;
|
|
||||||
|
|
||||||
// Live streaming caching (ms)
|
|
||||||
public static final int LIVE_CACHING = 5000;
|
|
||||||
|
|
||||||
// User Agent
|
// User Agent
|
||||||
public static final String USER_AGENT =
|
public static final String USER_AGENT =
|
||||||
"Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36";
|
"Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36";
|
||||||
|
|
||||||
// Hardware acceleration
|
|
||||||
public static final String HW_ACCELERATION = "automatic";
|
|
||||||
|
|
||||||
// Chroma format
|
|
||||||
public static final String CHROMA = "RV32";
|
|
||||||
|
|
||||||
// Audio output
|
|
||||||
public static final String AUDIO_OUTPUT = "opensles";
|
|
||||||
|
|
||||||
// Maximum retries for playback
|
// Maximum retries for playback
|
||||||
public static final int MAX_RETRIES = 3;
|
public static final int MAX_RETRIES = 3;
|
||||||
|
|
||||||
|
private VlcPlayerConfig() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item android:state_selected="true">
|
|
||||||
<shape android:shape="rectangle">
|
|
||||||
<solid android:color="#18d763" />
|
|
||||||
<corners android:radius="20dp" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
<item android:state_focused="true">
|
|
||||||
<shape android:shape="rectangle">
|
|
||||||
<solid android:color="#5522c1ff" />
|
|
||||||
<corners android:radius="20dp" />
|
|
||||||
<stroke
|
|
||||||
android:width="2dp"
|
|
||||||
android:color="#88FFFFFF" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
<item android:state_pressed="true">
|
|
||||||
<shape android:shape="rectangle">
|
|
||||||
<solid android:color="#3322c1ff" />
|
|
||||||
<corners android:radius="20dp" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<shape android:shape="rectangle">
|
|
||||||
<solid android:color="#222222" />
|
|
||||||
<corners android:radius="20dp" />
|
|
||||||
<stroke
|
|
||||||
android:width="1dp"
|
|
||||||
android:color="#44FFFFFF" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
</selector>
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 850 B |
@@ -34,7 +34,7 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="Canal"
|
android:text="@string/player_channel_default"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
android:id="@+id/close_button"
|
android:id="@+id/close_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Elegir otro"
|
android:text="@string/player_action_choose_other"
|
||||||
android:textAllCaps="false" />
|
android:textAllCaps="false" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="6dp"
|
android:layout_margin="6dp"
|
||||||
@@ -16,8 +17,8 @@
|
|||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:contentDescription="@string/app_name"
|
android:contentDescription="@string/app_name"
|
||||||
android:tint="@color/white"
|
android:src="@drawable/ic_channel_default"
|
||||||
android:src="@drawable/ic_channel_default" />
|
app:tint="@color/white" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/channel_name"
|
android:id="@+id/channel_name"
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
android:id="@+id/event_status"
|
android:id="@+id/event_status"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
android:paddingStart="8dp"
|
android:paddingStart="8dp"
|
||||||
android:textColor="#18d763"
|
android:textColor="#18d763"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<string-array name="channel_entries">
|
|
||||||
<item>Azteca Deportes</item>
|
|
||||||
<item>Canal 5 MX</item>
|
|
||||||
<item>Caliente TV MX</item>
|
|
||||||
<item>DAZN 1</item>
|
|
||||||
<item>DAZN 2</item>
|
|
||||||
<item>DAZN LaLiga</item>
|
|
||||||
<item>DSports</item>
|
|
||||||
<item>DSports 2</item>
|
|
||||||
<item>DSports Plus</item>
|
|
||||||
<item>ESPN</item>
|
|
||||||
</string-array>
|
|
||||||
</resources>
|
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">StreamPlayer</string>
|
<string name="app_name">StreamPlayer</string>
|
||||||
<string name="home_tagline">Todo el deporte en un solo lugar</string>
|
<string name="home_tagline">Todo el deporte en un solo lugar</string>
|
||||||
<string name="section_channels">Canales</string>
|
|
||||||
<string name="section_events">Eventos</string>
|
<string name="section_events">Eventos</string>
|
||||||
<string name="section_all_channels">Todos los canales</string>
|
<string name="section_all_channels">Todos los canales</string>
|
||||||
<string name="message_no_channels">No hay canales disponibles</string>
|
<string name="message_no_channels">No hay canales disponibles</string>
|
||||||
<string name="message_no_events">No hay eventos disponibles</string>
|
<string name="message_no_events">No hay eventos disponibles</string>
|
||||||
<string name="action_refresh">Actualizar</string>
|
<string name="action_refresh">Actualizar</string>
|
||||||
<string name="message_events_error">No se pudieron cargar los eventos: %1$s</string>
|
<string name="message_events_error">No se pudieron cargar los eventos: %1$s</string>
|
||||||
|
<string name="player_channel_default">Canal</string>
|
||||||
|
<string name="player_action_choose_other">Elegir otro</string>
|
||||||
|
<string name="player_retrying">Error de conexión. Reintentando... (%1$d/%2$d)</string>
|
||||||
<string name="update_required_title">Actualización obligatoria</string>
|
<string name="update_required_title">Actualización obligatoria</string>
|
||||||
<string name="update_available_title">Actualización disponible</string>
|
<string name="update_available_title">Actualización disponible</string>
|
||||||
<string name="update_action_download">Actualizar</string>
|
<string name="update_action_download">Actualizar</string>
|
||||||
@@ -22,6 +24,7 @@
|
|||||||
<string name="update_release_notes_title">Novedades</string>
|
<string name="update_release_notes_title">Novedades</string>
|
||||||
<string name="update_optional_hint">Puedes continuar usando la app, pero recomendamos instalar la actualización para obtener el mejor rendimiento.</string>
|
<string name="update_optional_hint">Puedes continuar usando la app, pero recomendamos instalar la actualización para obtener el mejor rendimiento.</string>
|
||||||
<string name="update_error_checking">No se pudo verificar actualizaciones (%1$s)</string>
|
<string name="update_error_checking">No se pudo verificar actualizaciones (%1$s)</string>
|
||||||
|
<string name="update_error_unknown">Error desconocido</string>
|
||||||
<string name="update_error_open_release">No se pudo abrir el detalle de la versión</string>
|
<string name="update_error_open_release">No se pudo abrir el detalle de la versión</string>
|
||||||
<string name="update_error_empty_response">Respuesta vacía del servidor de releases</string>
|
<string name="update_error_empty_response">Respuesta vacía del servidor de releases</string>
|
||||||
<string name="update_error_http">Error de red (%1$d)</string>
|
<string name="update_error_http">Error de red (%1$d)</string>
|
||||||
@@ -40,7 +43,6 @@
|
|||||||
<string name="device_blocked_title">Dispositivo bloqueado</string>
|
<string name="device_blocked_title">Dispositivo bloqueado</string>
|
||||||
<string name="device_blocked_message">Este dispositivo fue bloqueado desde el panel de control. Motivo: %1$s</string>
|
<string name="device_blocked_message">Este dispositivo fue bloqueado desde el panel de control. Motivo: %1$s</string>
|
||||||
<string name="device_blocked_default_reason">Sin motivo especificado.</string>
|
<string name="device_blocked_default_reason">Sin motivo especificado.</string>
|
||||||
<string name="device_blocked_token_hint">Comparte este código con el administrador para solicitar acceso: %1$s</string>
|
|
||||||
<string name="device_blocked_token_label">Código de verificación</string>
|
<string name="device_blocked_token_label">Código de verificación</string>
|
||||||
<string name="device_blocked_close">Salir</string>
|
<string name="device_blocked_close">Salir</string>
|
||||||
<string name="device_blocked_copy_token">Copiar código</string>
|
<string name="device_blocked_copy_token">Copiar código</string>
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?><!--
|
|
||||||
Sample backup rules file; uncomment and customize as necessary.
|
|
||||||
See https://developer.android.com/guide/topics/data/autobackup
|
|
||||||
for details.
|
|
||||||
Note: This file is ignored for devices older that API 23, even
|
|
||||||
if they have auto backup available.
|
|
||||||
-->
|
|
||||||
<full-backup-content>
|
|
||||||
<!--
|
|
||||||
<include domain="sharedpref" path="."/>
|
|
||||||
<exclude domain="sharedpref" path="device.xml"/>
|
|
||||||
-->
|
|
||||||
<exclude domain="sharedpref" path="." />
|
|
||||||
</full-backup-content>
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?><!--
|
|
||||||
Sample data extraction rules file; uncomment and customize as necessary.
|
|
||||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
|
||||||
for details.
|
|
||||||
-->
|
|
||||||
<data-extraction-rules>
|
|
||||||
<cloud-backup>
|
|
||||||
<!--
|
|
||||||
<include domain="file" path="."/>
|
|
||||||
<exclude domain="file" path="no_backup/"/>
|
|
||||||
-->
|
|
||||||
<exclude domain="sharedpref" path="." />
|
|
||||||
</cloud-backup>
|
|
||||||
<!--
|
|
||||||
<device-transfer>
|
|
||||||
<include domain="file" path="."/>
|
|
||||||
<exclude domain="file" path="no_backup/"/>
|
|
||||||
</device-transfer>
|
|
||||||
-->
|
|
||||||
</data-extraction-rules>
|
|
||||||
@@ -12,7 +12,6 @@ allprojects {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url "https://get.videolan.org/android/maven2/" }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user