Compare commits
12 Commits
97adc46509
...
v10.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e224ce7b3 | ||
|
|
82c232da7a | ||
|
|
1526766630 | ||
|
|
4e92ee6149 | ||
|
|
cff9658060 | ||
|
|
43439e0a88 | ||
|
|
98473e3b30 | ||
|
|
a4e8deb45a | ||
|
|
a9da5a3b8e | ||
|
|
ab69fd1aa4 | ||
|
|
907c97464b | ||
|
|
19c31ebf1b |
48
CHANGELOG-v10.1.5.md
Normal file
48
CHANGELOG-v10.1.5.md
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# StreamPlayer v10.1.5 - Correcciones Críticas
|
||||||
|
|
||||||
|
## Correcciones Implementadas
|
||||||
|
|
||||||
|
### 1. Scroll Listener Corregido
|
||||||
|
- **Problema**: El último evento aparecía solo a la mitad y requería bajar/subir muchas veces para verlo completo
|
||||||
|
- **Solución**: Cambiado de `findFirstVisibleItemPosition()` a `findLastCompletelyVisibleItemPosition()`
|
||||||
|
- Ahora el scroll solo se detiene cuando el último elemento está COMPLETAMENTE visible
|
||||||
|
|
||||||
|
### 2. Barra de Scroll Más Visible
|
||||||
|
- **Problema**: La barra indicadora no era visible (30% de opacidad)
|
||||||
|
- **Solución**:
|
||||||
|
- Opacidad aumentada de #4DFFFFFF (30%) a #CCFFFFFF (80%)
|
||||||
|
- Ancho de la barra aumentado a 8dp
|
||||||
|
- Radio de esquinas aumentado a 4dp para mejor apariencia
|
||||||
|
- Estilo cambiado de `outsideOverlay` a `insideInset`
|
||||||
|
- Agregado `scrollbarFadeDuration="0"` para que nunca se desvanezca
|
||||||
|
|
||||||
|
### 3. URLs Actualizadas
|
||||||
|
- **Problema**: Ciertos ISP bloquean las URLs viejas
|
||||||
|
- **Solución**: Eliminado sistema de fallback múltiples URLs
|
||||||
|
- Ahora usa únicamente: `https://streamtp10.com/eventos.json`
|
||||||
|
- Código simplificado, más eficiente y sin bloqueos
|
||||||
|
|
||||||
|
## Archivos Modificados
|
||||||
|
|
||||||
|
### EventRepository.java
|
||||||
|
- Simplificado para usar solo streamtp10.com
|
||||||
|
- Eliminado código de fallback no necesario
|
||||||
|
- Eliminado KEY_WORKING_URL y lógica asociada
|
||||||
|
|
||||||
|
### MainActivity.java
|
||||||
|
- Scroll listener corregido para usar `findLastCompletelyVisibleItemPosition()`
|
||||||
|
|
||||||
|
### scrollbar_vertical.xml
|
||||||
|
- Color cambiado a #CCFFFFFF (80% opacidad)
|
||||||
|
- Ancho definido en 8dp
|
||||||
|
- Radio de esquinas a 4dp
|
||||||
|
|
||||||
|
### activity_main.xml
|
||||||
|
- `scrollbarStyle` cambiado a `insideInset`
|
||||||
|
- `scrollbarSize` definido en 8dp
|
||||||
|
- `scrollbarFadeDuration` en 0 (siempre visible)
|
||||||
|
|
||||||
|
## Compatibilidad
|
||||||
|
- Versión mínima de Android: API 21+
|
||||||
|
- Compilado con SDK 34
|
||||||
|
- Probado en Android TV con control remoto
|
||||||
42
CHANGELOG-v10.1.6.md
Normal file
42
CHANGELOG-v10.1.6.md
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# StreamPlayer v10.1.6 - Corrección de Control Remoto y Scrollbar
|
||||||
|
|
||||||
|
## Correcciones Implementadas
|
||||||
|
|
||||||
|
### 1. Control Remoto - Prevención de Navegación
|
||||||
|
- **Problema**: Al presionar el botón abajo del control remoto en el último evento, se iba a la sección de canales
|
||||||
|
- **Solución**: Agregado `setOnKeyListener` para interceptar teclas de navegación
|
||||||
|
- Ahora intercepta `KEYCODE_DPAD_DOWN` cuando está en el último elemento
|
||||||
|
- Combina scroll listener táctil + manejo de teclas del control remoto
|
||||||
|
|
||||||
|
### 2. Barra de Scroll Más Visible
|
||||||
|
- **Problema**: La barra de seguimiento no era visible
|
||||||
|
- **Solución**:
|
||||||
|
- Color del thumb: Blanco sólido (#FFFFFFFF) - antes 80%
|
||||||
|
- Ancho aumentado a 12dp (antes 8dp)
|
||||||
|
- Radio de esquinas: 6dp (antes 4dp)
|
||||||
|
- Track oscuro agregado (#1A1A1A)
|
||||||
|
- `scrollbarAlwaysDrawVerticalTrack="true"` para siempre visible
|
||||||
|
|
||||||
|
## Archivos Modificados
|
||||||
|
|
||||||
|
### MainActivity.java
|
||||||
|
- Import agregado: `android.view.KeyEvent`
|
||||||
|
- `setOnKeyListener` agregado en `showEvents()` para interceptar DPAD_DOWN
|
||||||
|
- Combina con scroll listener existente para cobertura completa
|
||||||
|
|
||||||
|
### scrollbar_vertical.xml
|
||||||
|
- Color cambiado a blanco sólido (#FFFFFFFF)
|
||||||
|
- Ancho: 12dp
|
||||||
|
- Radio: 6dp
|
||||||
|
|
||||||
|
### activity_main.xml
|
||||||
|
- `scrollbarSize="12dp"` (antes 8dp)
|
||||||
|
- `scrollbarTrackVertical="@color/scrollbar_track"` agregado
|
||||||
|
- `scrollbarAlwaysDrawVerticalTrack="true"` agregado
|
||||||
|
|
||||||
|
### colors.xml
|
||||||
|
- Nuevo color: `scrollbar_track` (#1A1A1A)
|
||||||
|
|
||||||
|
## Compatibilidad
|
||||||
|
- Android TV con control remoto
|
||||||
|
- Versión mínima: API 21+
|
||||||
22
CHANGELOG-v10.1.7.md
Normal file
22
CHANGELOG-v10.1.7.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# StreamPlayer v10.1.7 - Corrección de Navegación y Scrollbar Permanente
|
||||||
|
|
||||||
|
## Correcciones Implementadas
|
||||||
|
|
||||||
|
### 1. Barra de Desplazamiento Permanente
|
||||||
|
- **Feature**: Se agregó `android:fadeScrollbars="false"` al `RecyclerView` de eventos.
|
||||||
|
- **Beneficio**: La barra de desplazamiento ahora es visible permanentemente, permitiendo al usuario saber su posición (inicio, medio, final) en todo momento sin tener que interactuar primero.
|
||||||
|
|
||||||
|
### 2. Navegación al Final de la Lista (Bug Fix)
|
||||||
|
- **Problema**: Al presionar "abajo" en el último evento, el foco saltaba involuntariamente a la sección de canales.
|
||||||
|
- **Solución**: Se implementó un `LinearLayoutManager` personalizado que intercepta la búsqueda de foco (`onInterceptFocusSearch`).
|
||||||
|
- **Detalle**: Cuando se detecta `FOCUS_DOWN` en el último elemento de la lista, la acción se bloquea, manteniendo al usuario en la lista de eventos.
|
||||||
|
- **Limpieza**: Se eliminaron los `OnKeyListener` y `OnScrollListener` anteriores que eran menos efectivos.
|
||||||
|
|
||||||
|
## Archivos Modificados
|
||||||
|
|
||||||
|
### MainActivity.java
|
||||||
|
- Implementación de `LinearLayoutManager` anónimo con `onInterceptFocusSearch`.
|
||||||
|
- Eliminación de listeners redundantes.
|
||||||
|
|
||||||
|
### activity_main.xml
|
||||||
|
- `android:fadeScrollbars="false"` añadido a `content_list`.
|
||||||
21
CHANGELOG-v10.1.8.md
Normal file
21
CHANGELOG-v10.1.8.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# StreamPlayer v10.1.8 - Actualización de DNS y Dominios
|
||||||
|
|
||||||
|
## Cambios Críticos
|
||||||
|
|
||||||
|
### 1. Actualización de Dominios
|
||||||
|
- Se ha migrado toda la infraestructura de canales y eventos al nuevo dominio: `streamtp10.com`.
|
||||||
|
- Actualización de URLs base para todos los canales en `ChannelRepository`.
|
||||||
|
- Actualización del endpoint de eventos a `https://streamtp10.com/eventos.json`.
|
||||||
|
- Corrección del Header `Referer` en las peticiones de resolución.
|
||||||
|
|
||||||
|
### 2. Configuración Robusta de DNS (Anti-Bloqueo)
|
||||||
|
- Implementación de un nuevo sistema centralizado de red (`NetworkUtils`).
|
||||||
|
- **DNS Primario**: Google DNS over HTTPS (`8.8.8.8`, `8.8.4.4`).
|
||||||
|
- **DNS Secundario**: AdGuard DNS over HTTPS (`94.140.14.14`, `94.140.15.15`) como respaldo automático si Google falla.
|
||||||
|
- **DNS Terciario**: DNS del sistema (ISP) como último recurso.
|
||||||
|
- Se ha eliminado el uso de `HttpURLConnection` en `EventRepository` en favor de `OkHttpClient` con la nueva configuración DNS, asegurando que la carga de la guía de eventos también evite bloqueos.
|
||||||
|
|
||||||
|
## Beneficios
|
||||||
|
- Mayor resistencia a bloqueos regionales e interferencias de ISP.
|
||||||
|
- Recuperación automática si el proveedor de DNS principal (Google) no es accesible.
|
||||||
|
- Corrección de problemas de carga de canales debido al cambio de dominio del proveedor.
|
||||||
24
Dockerfile.mullvad
Normal file
24
Dockerfile.mullvad
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
FROM ubuntu:22.04
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
curl \
|
||||||
|
wireguard-tools \
|
||||||
|
iputils-ping \
|
||||||
|
dnsutils \
|
||||||
|
iproute2 \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN mkdir -p /etc/wireguard
|
||||||
|
|
||||||
|
RUN echo '[Interface]' > /etc/wireguard/wg0.conf && \
|
||||||
|
echo 'PrivateKey = Tq9/VQ8qdsphS+0nVEFmWgFvMfvJ2FbWGK/Xt9cX4AA=' >> /etc/wireguard/wg0.conf && \
|
||||||
|
echo 'Address = 10.8.0.2/32' >> /etc/wireguard/wg0.conf && \
|
||||||
|
echo 'DNS = 1.1.1.1' >> /etc/wireguard/wg0.conf && \
|
||||||
|
echo '' >> /etc/wireguard/wg0.conf && \
|
||||||
|
echo '[Peer]' >> /etc/wireguard/wg0.conf && \
|
||||||
|
echo 'PublicKey = 03qeK7CSn6wcMzfqilmVt6Tf81VZIPWnSG04euSkyxM=' >> /etc/wireguard/wg0.conf && \
|
||||||
|
echo 'Endpoint = 149.88.104.2:51820' >> /etc/wireguard/wg0.conf && \
|
||||||
|
echo 'AllowedIPs = 0.0.0.0/0' >> /etc/wireguard/wg0.conf && \
|
||||||
|
echo 'PersistentKeepalive = 25' >> /etc/wireguard/wg0.conf
|
||||||
|
|
||||||
|
CMD tail -f /dev/null
|
||||||
340
README.md
340
README.md
@@ -1,306 +1,76 @@
|
|||||||
# 📺 StreamPlayer
|
# 🏆 Furbo VPN Edition
|
||||||
|
|
||||||
[](https://android.com)
|
[](https://android.com)
|
||||||
[](https://www.oracle.com/java/)
|
[]()
|
||||||
[](https://android-developers.blogspot.com/)
|
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
|
|
||||||
Aplicación Android reproductora de streaming con optimización DNS para mejor rendimiento y acceso a contenido multimedia.
|
**StreamPlayer con VPN integrada** - La única app de streaming con Mullvad VPN built-in.
|
||||||
|
|
||||||
## 🌟 Características
|
## ✨ Características
|
||||||
|
|
||||||
- **▶️ Reproducción Streaming**: Reproductor de video streaming optimizado con ExoPlayer
|
- 📺 **Streaming**: Reproducción de canales en vivo
|
||||||
- **🌐 Optimización DNS**: Configuración automática de DNS de Google (8.8.8.8, 8.8.4.4) para mejor conectividad
|
- 🔒 **VPN Integrada**: Con Mullvad WireGuard - sin app externa
|
||||||
- **🔍 Resolución de URL**: Sistema avanzado que resuelve URLs ofuscadas de streaming
|
- 🌎 **Sin Bloqueos Geográficos**: VPN incluida para evitar restricciones
|
||||||
- **📱 Orientación Landscape**: Diseño optimizado para experiencia multimedia inmersiva
|
- 📱 **Android TV**: Optimizado para Android TV y control remoto
|
||||||
- **⚡ Alto Rendimiento**: Implementación asíncrona para respuesta rápida
|
- ⚡ **Alto Rendimiento**: DNS over HTTPS con fallback
|
||||||
- **🛡️ Manejo de Errores**: Sistema robusto de gestión de errores y estados
|
|
||||||
|
## 🚀 Instalación
|
||||||
|
|
||||||
|
### Opción 1: Descargar APK
|
||||||
|
Descargar el APK más reciente de [Releases](https://gitea.cbcren.online/renato97/furbo-vpn-edition/releases)
|
||||||
|
|
||||||
|
### Opción 2: Compilar
|
||||||
|
```bash
|
||||||
|
# Clonar repositorio
|
||||||
|
git clone https://gitea.cbcren.online/renato97/furbo-vpn-edition.git
|
||||||
|
cd furbo-vpn-edition
|
||||||
|
|
||||||
|
# Compilar
|
||||||
|
./gradlew assembleDebug
|
||||||
|
|
||||||
|
# APK en: app/build/outputs/apk/debug/app-debug.apk
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔧 Uso de la VPN
|
||||||
|
|
||||||
|
1. **Primera vez**: Tocar el botón "Conectar VPN" en el menú
|
||||||
|
2. **Permiso**: Aceptar el permiso de VPN cuando se solicite
|
||||||
|
3. **Listo**: La VPN se conecta automáticamente
|
||||||
|
|
||||||
|
### Cambiar servidor VPN
|
||||||
|
Para cambiar el servidor Mullvad:
|
||||||
|
1. Descargar config desde [Mullvad Servers](https://mullvad.net/servers/)
|
||||||
|
2. Reemplazar el archivo `app/src/main/res/raw/mullvad.conf`
|
||||||
|
3. Recompilar
|
||||||
|
|
||||||
## 📋 Requisitos
|
## 📋 Requisitos
|
||||||
|
|
||||||
- **Android SDK**: API 21 (Android 5.0) o superior
|
- **Android**: 7.0 (API 24) o superior
|
||||||
- **Target SDK**: API 33 (Android 13)
|
- **VPN**: WireGuard integrado (no requiere app externa)
|
||||||
- **Permisos**:
|
|
||||||
- `INTERNET` - Acceso a streaming
|
|
||||||
- `ACCESS_NETWORK_STATE` - Verificación de conectividad
|
|
||||||
- `CHANGE_NETWORK_STATE` - Configuración de red
|
|
||||||
|
|
||||||
## 🏗️ Arquitectura
|
## 🔐 Privacidad
|
||||||
|
|
||||||
### Componentes Principales
|
- **DNS**: Múltiples servidores DoH (Google, Cloudflare, AdGuard, Quad9)
|
||||||
|
- **VPN**: Mullvad - Sin logs, sin datos personales
|
||||||
|
- **Todo en uno**: No necesita otras apps
|
||||||
|
|
||||||
- **MainActivity.java** (`/app/src/main/java/com/streamplayer/MainActivity.java`)
|
## 📁 Estructura
|
||||||
- Gestión del ciclo de vida del reproductor
|
|
||||||
- Configuración de ExoPlayer
|
|
||||||
- Manejo de estados (loading, error, reproducción)
|
|
||||||
|
|
||||||
- **StreamUrlResolver.java** (`/app/src/main/java/com/streamplayer/StreamUrlResolver.java`)
|
|
||||||
- Resolución de URLs ofuscadas
|
|
||||||
- Decodificación Base64
|
|
||||||
- Extracción de claves de JavaScript
|
|
||||||
|
|
||||||
- **DNSSetter.java** (`/app/src/main/java/com/streamplayer/DNSSetter.java`)
|
|
||||||
- Configuración de DNS de Google
|
|
||||||
- Optimización de red para streaming
|
|
||||||
- Pre-resolución de dominios
|
|
||||||
|
|
||||||
## 🚀 Instalación y Build
|
|
||||||
|
|
||||||
### Prerequisites
|
|
||||||
```bash
|
|
||||||
# Android SDK
|
|
||||||
# Java 8+
|
|
||||||
# Gradle 8.2+
|
|
||||||
```
|
|
||||||
|
|
||||||
### Build con Gradle
|
|
||||||
```bash
|
|
||||||
# Clone el repositorio
|
|
||||||
git clone https://gitea.cbcren.online/renato97/app.git
|
|
||||||
cd app
|
|
||||||
|
|
||||||
# Build APK debug
|
|
||||||
./gradlew assembleDebug
|
|
||||||
|
|
||||||
# Build APK release
|
|
||||||
./gradlew assembleRelease
|
|
||||||
```
|
|
||||||
|
|
||||||
### Build con Docker
|
|
||||||
```bash
|
|
||||||
# Construir imagen
|
|
||||||
docker build -t streamplayer .
|
|
||||||
|
|
||||||
# Ejecutar build
|
|
||||||
docker run --rm -v $(pwd)/output:/output streamplayer
|
|
||||||
```
|
|
||||||
|
|
||||||
### Build Script Alternativo
|
|
||||||
```bash
|
|
||||||
# Usar script de build
|
|
||||||
chmod +x build_apk.sh
|
|
||||||
./build_apk.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
## 🔄 Control de Instalaciones y Actualizaciones
|
|
||||||
|
|
||||||
StreamPlayer ahora consulta automáticamente las releases públicas del repositorio Gitea y puede forzar o sugerir actualizaciones directamente desde la app. Para aprovecharlo:
|
|
||||||
|
|
||||||
1. Ejecuta un build nuevo incrementando `versionCode`/`versionName` en `app/build.gradle`.
|
|
||||||
2. Crea una release en Gitea asignando un tag como `v9.1` y sube el APK.
|
|
||||||
3. Adjunta un archivo `update-manifest.json` en la misma release (puedes partir de `release/update-manifest.example.json`).
|
|
||||||
|
|
||||||
### Formato de `update-manifest.json`
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"versionCode": 91000,
|
|
||||||
"versionName": "9.1.0",
|
|
||||||
"minSupportedVersionCode": 90000,
|
|
||||||
"forceUpdate": false,
|
|
||||||
"downloadUrl": "https://gitea.cbcren.online/renato97/app/releases/download/v9.1/StreamPlayer-v9.1.apk",
|
|
||||||
"fileName": "StreamPlayer-v9.1.apk",
|
|
||||||
"sizeBytes": 12345678,
|
|
||||||
"notes": "Novedades destacadas que aparecerán en el diálogo dentro de la app"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
- `versionCode` / `versionName`: deben coincidir con el APK publicado.
|
|
||||||
- `minSupportedVersionCode`: define desde qué versión mínima se permite seguir usando la app (ideal para bloquear instalaciones antiguas).
|
|
||||||
- `forceUpdate`: si es `true` la app mostrará un diálogo sin opción de omitir.
|
|
||||||
- `downloadUrl` / `fileName`: apuntan al asset `.apk` publicado en Gitea (puede ser el enlace de descarga directo).
|
|
||||||
- `notes`: texto libre mostrado en el diálogo dentro de la app; si lo omitís se usará el cuerpo de la release.
|
|
||||||
|
|
||||||
Si por algún motivo olvidas subir el manifiesto, la app igualmente tomará el primer asset `.apk` de la release, pero no podrá forzar versiones mínimas.
|
|
||||||
|
|
||||||
### Dashboard de Dispositivos y Bloqueo Remoto
|
|
||||||
|
|
||||||
Para saber en qué equipo está instalada la app y bloquear el acceso cuando lo necesites, se incluye un dashboard liviano en `dashboard/`:
|
|
||||||
|
|
||||||
1. Instala dependencias y ejecuta el servidor:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd dashboard
|
|
||||||
npm install
|
|
||||||
npm start # escucha en http://localhost:4000
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Copia `dashboard/config.example.json` a `dashboard/config.json` y completa `telegramBotToken` + `telegramChatId` (o usa variables de entorno `TELEGRAM_BOT_TOKEN` / `TELEGRAM_CHAT_ID`).
|
|
||||||
3. Ajusta `DEVICE_REGISTRY_URL` en `app/build.gradle` para apuntar al dominio/puerto donde despliegues el servidor (ya configurado como `http://194.163.191.200:4000`).
|
|
||||||
4. Distribuye el APK; cada instalación reportará `ANDROID_ID`, modelo, IP pública y país.
|
|
||||||
5. Entra a `http://TU_HOST:4000/` para ver el listado, asignar alias, bloquear/desbloquear o validar tokens.
|
|
||||||
|
|
||||||
El servidor guarda los datos en `dashboard/data/devices.json`, por lo que puedes versionarlo o respaldarlo fácilmente. Cada registro almacena:
|
|
||||||
|
|
||||||
- `deviceId`: `Settings.Secure.ANDROID_ID` del equipo
|
|
||||||
- `deviceName`, `manufacturer`, `model`, `osVersion`
|
|
||||||
- `appVersionName`/`Code`
|
|
||||||
- `ip`, `country` detectados automáticamente
|
|
||||||
- `firstSeen`, `lastSeen`, `blocked`, `notes`, `verification.status`
|
|
||||||
|
|
||||||
Cuando presionas “Bloquear”, la app recibe la respuesta `{"blocked": true}` y muestra un diálogo irreversible hasta que lo habilites. Esto añade una capa adicional de control aparte del sistema de actualizaciones.
|
|
||||||
|
|
||||||
### Flujo dentro de la app y tokens divididos
|
|
||||||
|
|
||||||
- Cada vez que se abre `MainActivity` se consulta `https://gitea.cbcren.online/api/v1/repos/renato97/app/releases/latest`.
|
|
||||||
- Si `versionCode` del servidor es mayor al instalado se muestra un diálogo para actualizar; el usuario puede abrir la release o descargarla directamente.
|
|
||||||
- Si `minSupportedVersionCode` es mayor al instalado la app bloqueará el uso hasta actualizar, cumpliendo con el requerimiento de controlar instalaciones.
|
|
||||||
- La descarga se gestiona con `DownloadManager` y, una vez completada, se lanza el instalador usando FileProvider.
|
|
||||||
- Mientras el dashboard mantenga un dispositivo "Pendiente" o "Bloqueado", la app muestra un diálogo con el motivo y la mitad del token que debe compartir la persona.
|
|
||||||
|
|
||||||
Cada instalación genera un token interno dividido en dos:
|
|
||||||
|
|
||||||
1. **Parte cliente**: se muestra en el diálogo del dispositivo bloqueado para que el usuario pueda copiarla.
|
|
||||||
2. **Parte admin**: llega al bot de Telegram configurado junto con la IP, país y datos del dispositivo.
|
|
||||||
|
|
||||||
Para autorizar un dispositivo pendiente:
|
|
||||||
|
|
||||||
1. Obtén la parte cliente desde el usuario (visible en pantalla).
|
|
||||||
2. Copia la parte admin del mensaje de Telegram.
|
|
||||||
3. En el dashboard presiona “Verificar token” e introduce ambas mitades. Si coinciden, el estado pasa a "Verificado" y la app se desbloquea automáticamente.
|
|
||||||
4. A partir de allí puedes bloquear/desbloquear manualmente cuando quieras.
|
|
||||||
|
|
||||||
También puedes gestionar todo desde Telegram:
|
|
||||||
|
|
||||||
- `/allow <deviceId> <token_cliente>` autoriza el dispositivo (verifica el token y lo desbloquea).
|
|
||||||
- `/deny <deviceId> <token_cliente> [motivo]` lo bloquea con un motivo opcional.
|
|
||||||
- `/pending` lista los registros que aún esperan un token válido.
|
|
||||||
|
|
||||||
Cada nuevo registro dispara una notificación de Telegram con la parte admin del token y recordatorios de esos comandos.
|
|
||||||
|
|
||||||
## 📱 Estructura del Proyecto
|
|
||||||
|
|
||||||
```
|
```
|
||||||
app/
|
app/src/main/
|
||||||
├── src/main/
|
├── java/com/streamplayer/
|
||||||
│ ├── java/com/streamplayer/
|
│ ├── MainActivity.java # UI principal
|
||||||
│ │ ├── MainActivity.java # Actividad principal
|
│ ├── VpnManager.java # Gestión VPN
|
||||||
│ │ ├── StreamUrlResolver.java # Resolvedor de URLs
|
│ └── ...
|
||||||
│ │ └── DNSSetter.java # Configuración DNS
|
├── res/raw/
|
||||||
│ ├── res/
|
│ └── mullvad.conf # Configuración VPN
|
||||||
│ │ ├── layout/
|
└── AndroidManifest.xml
|
||||||
│ │ │ └── activity_main.xml # UI principal
|
|
||||||
│ │ ├── mipmap-*/ # Íconos de la app
|
|
||||||
│ │ ├── values/
|
|
||||||
│ │ │ ├── strings.xml # Cadenas de texto
|
|
||||||
│ │ │ ├── colors.xml # Colores
|
|
||||||
│ │ │ └── themes.xml # Temas
|
|
||||||
│ │ └── xml/ # Configuraciones
|
|
||||||
│ └── AndroidManifest.xml # Manifiesto Android
|
|
||||||
├── build.gradle # Configuración Gradle
|
|
||||||
└── proguard-rules.pro # Reglas ProGuard
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## ⚙️ Configuración
|
|
||||||
|
|
||||||
### URL de Streaming
|
|
||||||
La aplicación está configurada por defecto para:
|
|
||||||
```
|
|
||||||
https://streamtpmedia.com/global2.php?stream=espn
|
|
||||||
```
|
|
||||||
|
|
||||||
### Configuración DNS
|
|
||||||
```java
|
|
||||||
// DNS configurados automáticamente
|
|
||||||
String[] GOOGLE_DNS = {"8.8.8.8", "8.8.4.4"};
|
|
||||||
```
|
|
||||||
|
|
||||||
## 🔧 Dependencias Principales
|
|
||||||
|
|
||||||
- **ExoPlayer 2.18.7**: Motor de reproducción multimedia
|
|
||||||
- **AndroidX AppCompat 1.6.1**: Compatibilidad hacia atrás
|
|
||||||
- **ConstraintLayout 2.1.4**: Layout moderno y flexible
|
|
||||||
|
|
||||||
## 🛠️ Desarrollo
|
|
||||||
|
|
||||||
### Flujo de Reproducción
|
|
||||||
1. **MainActivity** inicializa y configura DNS de Google
|
|
||||||
2. **StreamUrlResolver** obtiene y decodifica la URL real del stream
|
|
||||||
3. **ExoPlayer** inicia la reproducción con la URL resuelta
|
|
||||||
4. UI actualiza estados (loading, playing, error)
|
|
||||||
|
|
||||||
### Características Técnicas
|
|
||||||
- **Threading**: Operaciones de red en background thread
|
|
||||||
- **Memory Management**: Proper lifecycle management de ExoPlayer
|
|
||||||
- **Error Handling**: Captura y display de errores al usuario
|
|
||||||
- **Network Optimization**: Configuración DNS específica para streaming
|
|
||||||
|
|
||||||
## 📊 Build Configuration
|
|
||||||
|
|
||||||
| Atributo | Valor |
|
|
||||||
|----------|-------|
|
|
||||||
| `applicationId` | `com.streamplayer` |
|
|
||||||
| `minSdk` | 21 |
|
|
||||||
| `targetSdk` | 33 |
|
|
||||||
| `versionCode` | 90000 |
|
|
||||||
| `versionName` | "9.0.0" |
|
|
||||||
| `compileSdk` | 33 |
|
|
||||||
|
|
||||||
## 🔐 Permisos y Seguridad
|
|
||||||
|
|
||||||
La aplicación requiere los siguientes permisos:
|
|
||||||
- ✅ `INTERNET` - Para streaming de contenido
|
|
||||||
- ✅ `ACCESS_NETWORK_STATE` - Para verificar conectividad
|
|
||||||
- ✅ `CHANGE_NETWORK_STATE` - Para optimización de red
|
|
||||||
|
|
||||||
## 🐛 Troubleshooting
|
|
||||||
|
|
||||||
### Problemas Comunes
|
|
||||||
|
|
||||||
**Error de Conexión**
|
|
||||||
- Verificar conexión a internet
|
|
||||||
- Confirmar configuración DNS
|
|
||||||
- Revisar disponibilidad del servicio de streaming
|
|
||||||
|
|
||||||
**Error de Reproducción**
|
|
||||||
- Validar formato de URL
|
|
||||||
- Verificar permisos de red
|
|
||||||
- Revisar logs de ExoPlayer
|
|
||||||
|
|
||||||
**Build Fail**
|
|
||||||
```bash
|
|
||||||
# Limpiar proyecto
|
|
||||||
./gradlew clean
|
|
||||||
|
|
||||||
# Rebuild
|
|
||||||
./gradlew build
|
|
||||||
```
|
|
||||||
|
|
||||||
## 📝 Logs y Debug
|
|
||||||
|
|
||||||
La aplicación incluye console logging para:
|
|
||||||
- Configuración DNS
|
|
||||||
- Resolución de URLs
|
|
||||||
- Estados del reproductor
|
|
||||||
- Errores de red
|
|
||||||
|
|
||||||
## 🤝 Contribución
|
|
||||||
|
|
||||||
1. Fork del repositorio
|
|
||||||
2. Feature branch (`git checkout -b feature/NuevaCaracteristica`)
|
|
||||||
3. Commit cambios (`git commit -m 'Add feature'`)
|
|
||||||
4. Push al branch (`git push origin feature/NuevaCaracteristica`)
|
|
||||||
5. Pull Request
|
|
||||||
|
|
||||||
## 📄 Licencia
|
|
||||||
|
|
||||||
Este proyecto está licenciado bajo la Licencia MIT - ver archivo [LICENSE](LICENSE) para detalles.
|
|
||||||
|
|
||||||
## 👨💻 Autor
|
|
||||||
|
|
||||||
**renato97** - [Gitea Profile](https://gitea.cbcren.online/renato97)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
⚠️ **Disclaimer**: Esta aplicación es para fines educativos y de demostración. El usuario es responsable de cumplir con los términos de servicio de las plataformas de streaming utilizadas.
|
|
||||||
|
|
||||||
## 📞 Soporte
|
## 📞 Soporte
|
||||||
|
|
||||||
Para soporte y preguntas:
|
- Issues: [GitHub Issues](https://gitea.cbcren.online/renato97/furbo-vpn-edition/issues)
|
||||||
- 📧 Crear un issue en el repositorio
|
|
||||||
- 💬 Comentarios en el código
|
|
||||||
- 📱 Testing en dispositivos reales recomendado
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**🔗 Repositorio**: https://gitea.cbcren.online/renato97/app
|
⚠️ **Disclaimer**: Esta aplicación es para fines educativos. El usuario es responsable de cumplir con los términos de servicio de las plataformas de streaming.
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.streamplayer"
|
applicationId "com.streamplayer"
|
||||||
minSdk 21
|
minSdk 24
|
||||||
targetSdk 35
|
targetSdk 35
|
||||||
versionCode 100102
|
versionCode 100111
|
||||||
versionName "10.1.2"
|
versionName "10.1.11"
|
||||||
buildConfigField "String", "DEVICE_REGISTRY_URL", '"http://194.163.191.200:4000"'
|
buildConfigField "String", "DEVICE_REGISTRY_URL", '"http://194.163.191.200:4000"'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,6 +60,9 @@ dependencies {
|
|||||||
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'
|
||||||
|
|
||||||
|
// WireGuard for VPN
|
||||||
|
implementation 'com.wireguard.android:tunnel:1.0.20210211'
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<!-- Permisos necesarios -->
|
<!-- Permisos necesarios -->
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.software.leanback"
|
android:name="android.software.leanback"
|
||||||
android:required="false" />
|
android:required="false" />
|
||||||
@@ -53,6 +57,15 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name="com.wireguard.android.backend.GoBackend$VpnService"
|
||||||
|
android:exported="false"
|
||||||
|
android:permission="android.permission.BIND_VPN_SERVICE">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.net.VpnService" />
|
||||||
|
</intent-filter>
|
||||||
|
</service>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -12,72 +12,72 @@ public final class ChannelRepository {
|
|||||||
|
|
||||||
private static List<StreamChannel> createChannels() {
|
private static List<StreamChannel> createChannels() {
|
||||||
List<StreamChannel> channels = new ArrayList<>(Arrays.asList(
|
List<StreamChannel> channels = new ArrayList<>(Arrays.asList(
|
||||||
new StreamChannel("ESPN", "https://streamtpcloud.com/global2.php?stream=espn"),
|
new StreamChannel("ESPN", "http://streamtp10.com/global2.php?stream=espn"),
|
||||||
new StreamChannel("ESPN 2", "https://streamtpcloud.com/global2.php?stream=espn2"),
|
new StreamChannel("ESPN 2", "http://streamtp10.com/global2.php?stream=espn2"),
|
||||||
new StreamChannel("ESPN 3", "https://streamtpcloud.com/global2.php?stream=espn3"),
|
new StreamChannel("ESPN 3", "http://streamtp10.com/global2.php?stream=espn3"),
|
||||||
new StreamChannel("ESPN 4", "https://streamtpcloud.com/global2.php?stream=espn4"),
|
new StreamChannel("ESPN 4", "http://streamtp10.com/global2.php?stream=espn4"),
|
||||||
new StreamChannel("ESPN 3 MX", "https://streamtpcloud.com/global2.php?stream=espn3mx"),
|
new StreamChannel("ESPN 3 MX", "http://streamtp10.com/global2.php?stream=espn3mx"),
|
||||||
new StreamChannel("ESPN 5", "https://streamtpcloud.com/global2.php?stream=espn5"),
|
new StreamChannel("ESPN 5", "http://streamtp10.com/global2.php?stream=espn5"),
|
||||||
new StreamChannel("Fox Sports 3 MX", "https://streamtpcloud.com/global2.php?stream=foxsports3mx"),
|
new StreamChannel("Fox Sports 3 MX", "http://streamtp10.com/global2.php?stream=foxsports3mx"),
|
||||||
new StreamChannel("ESPN 6", "https://streamtpcloud.com/global2.php?stream=espn6"),
|
new StreamChannel("ESPN 6", "http://streamtp10.com/global2.php?stream=espn6"),
|
||||||
new StreamChannel("Fox Sports MX", "https://streamtpcloud.com/global2.php?stream=foxsportsmx"),
|
new StreamChannel("Fox Sports MX", "http://streamtp10.com/global2.php?stream=foxsportsmx"),
|
||||||
new StreamChannel("ESPN 7", "https://streamtpcloud.com/global2.php?stream=espn7"),
|
new StreamChannel("ESPN 7", "http://streamtp10.com/global2.php?stream=espn7"),
|
||||||
new StreamChannel("Azteca Deportes", "https://streamtpcloud.com/global2.php?stream=azteca_deportes"),
|
new StreamChannel("Azteca Deportes", "http://streamtp10.com/global2.php?stream=azteca_deportes"),
|
||||||
new StreamChannel("Win Plus", "https://streamtpcloud.com/global2.php?stream=winplus"),
|
new StreamChannel("Win Plus", "http://streamtp10.com/global2.php?stream=winplus"),
|
||||||
new StreamChannel("DAZN 1", "https://streamtpcloud.com/global2.php?stream=dazn1"),
|
new StreamChannel("DAZN 1", "http://streamtp10.com/global2.php?stream=dazn1"),
|
||||||
new StreamChannel("Win Plus 2", "https://streamtpcloud.com/global2.php?stream=winplus2"),
|
new StreamChannel("Win Plus 2", "http://streamtp10.com/global2.php?stream=winplus2"),
|
||||||
new StreamChannel("DAZN 2", "https://streamtpcloud.com/global2.php?stream=dazn2"),
|
new StreamChannel("DAZN 2", "http://streamtp10.com/global2.php?stream=dazn2"),
|
||||||
new StreamChannel("Win Sports", "https://streamtpcloud.com/global2.php?stream=winsports"),
|
new StreamChannel("Win Sports", "http://streamtp10.com/global2.php?stream=winsports"),
|
||||||
new StreamChannel("DAZN LaLiga", "https://streamtpcloud.com/global2.php?stream=dazn_laliga"),
|
new StreamChannel("DAZN LaLiga", "http://streamtp10.com/global2.php?stream=dazn_laliga"),
|
||||||
new StreamChannel("Win Plus Online 1", "https://streamtpcloud.com/global2.php?stream=winplusonline1"),
|
new StreamChannel("Win Plus Online 1", "http://streamtp10.com/global2.php?stream=winplusonline1"),
|
||||||
new StreamChannel("Caracol TV", "https://streamtpcloud.com/global2.php?stream=caracoltv"),
|
new StreamChannel("Caracol TV", "http://streamtp10.com/global2.php?stream=caracoltv"),
|
||||||
new StreamChannel("Fox 1 AR", "https://streamtpcloud.com/global2.php?stream=fox1ar"),
|
new StreamChannel("Fox 1 AR", "http://streamtp10.com/global2.php?stream=fox1ar"),
|
||||||
new StreamChannel("Fox 2 USA", "https://streamtpcloud.com/global2.php?stream=fox_2_usa"),
|
new StreamChannel("Fox 2 USA", "http://streamtp10.com/global2.php?stream=fox_2_usa"),
|
||||||
new StreamChannel("Fox 2 AR", "https://streamtpcloud.com/global2.php?stream=fox2ar"),
|
new StreamChannel("Fox 2 AR", "http://streamtp10.com/global2.php?stream=fox2ar"),
|
||||||
new StreamChannel("TNT 1 GB", "https://streamtpcloud.com/global2.php?stream=tnt_1_gb"),
|
new StreamChannel("TNT 1 GB", "http://streamtp10.com/global2.php?stream=tnt_1_gb"),
|
||||||
new StreamChannel("TNT 2 GB", "https://streamtpcloud.com/global2.php?stream=tnt_2_gb"),
|
new StreamChannel("TNT 2 GB", "http://streamtp10.com/global2.php?stream=tnt_2_gb"),
|
||||||
new StreamChannel("Fox 3 AR", "https://streamtpcloud.com/global2.php?stream=fox3ar"),
|
new StreamChannel("Fox 3 AR", "http://streamtp10.com/global2.php?stream=fox3ar"),
|
||||||
new StreamChannel("Universo USA", "https://streamtpcloud.com/global2.php?stream=universo_usa"),
|
new StreamChannel("Universo USA", "http://streamtp10.com/global2.php?stream=universo_usa"),
|
||||||
new StreamChannel("DSports", "https://streamtpcloud.com/global2.php?stream=dsports"),
|
new StreamChannel("DSports", "http://streamtp10.com/global2.php?stream=dsports"),
|
||||||
new StreamChannel("Univision USA", "https://streamtpcloud.com/global2.php?stream=univision_usa"),
|
new StreamChannel("Univision USA", "http://streamtp10.com/global2.php?stream=univision_usa"),
|
||||||
new StreamChannel("DSports 2", "https://streamtpcloud.com/global2.php?stream=dsports2"),
|
new StreamChannel("DSports 2", "http://streamtp10.com/global2.php?stream=dsports2"),
|
||||||
new StreamChannel("Fox Deportes USA", "https://streamtpcloud.com/global2.php?stream=fox_deportes_usa"),
|
new StreamChannel("Fox Deportes USA", "http://streamtp10.com/global2.php?stream=fox_deportes_usa"),
|
||||||
new StreamChannel("DSports Plus", "https://streamtpcloud.com/global2.php?stream=dsportsplus"),
|
new StreamChannel("DSports Plus", "http://streamtp10.com/global2.php?stream=dsportsplus"),
|
||||||
new StreamChannel("Fox Sports 2 MX", "https://streamtpcloud.com/global2.php?stream=foxsports2mx"),
|
new StreamChannel("Fox Sports 2 MX", "http://streamtp10.com/global2.php?stream=foxsports2mx"),
|
||||||
new StreamChannel("TNT Sports Chile", "https://streamtpcloud.com/global2.php?stream=tntsportschile"),
|
new StreamChannel("TNT Sports Chile", "http://streamtp10.com/global2.php?stream=tntsportschile"),
|
||||||
new StreamChannel("Fox Sports Premium", "https://streamtpcloud.com/global2.php?stream=foxsportspremium"),
|
new StreamChannel("Fox Sports Premium", "http://streamtp10.com/global2.php?stream=foxsportspremium"),
|
||||||
new StreamChannel("TNT Sports", "https://streamtpcloud.com/global2.php?stream=tntsports"),
|
new StreamChannel("TNT Sports", "http://streamtp10.com/global2.php?stream=tntsports"),
|
||||||
new StreamChannel("ESPN MX", "https://streamtpcloud.com/global2.php?stream=espnmx"),
|
new StreamChannel("ESPN MX", "http://streamtp10.com/global2.php?stream=espnmx"),
|
||||||
new StreamChannel("ESPN Premium", "https://streamtpcloud.com/global2.php?stream=espnpremium"),
|
new StreamChannel("ESPN Premium", "http://streamtp10.com/global2.php?stream=espnpremium"),
|
||||||
new StreamChannel("ESPN 2 MX", "https://streamtpcloud.com/global2.php?stream=espn2mx"),
|
new StreamChannel("ESPN 2 MX", "http://streamtp10.com/global2.php?stream=espn2mx"),
|
||||||
new StreamChannel("TyC Sports", "https://streamtpcloud.com/global2.php?stream=tycsports"),
|
new StreamChannel("TyC Sports", "http://streamtp10.com/global2.php?stream=tycsports"),
|
||||||
new StreamChannel("TUDN USA", "https://streamtpcloud.com/global2.php?stream=tudn_usa"),
|
new StreamChannel("TUDN USA", "http://streamtp10.com/global2.php?stream=tudn_usa"),
|
||||||
new StreamChannel("Telefe", "https://streamtpcloud.com/global2.php?stream=telefe"),
|
new StreamChannel("Telefe", "http://streamtp10.com/global2.php?stream=telefe"),
|
||||||
new StreamChannel("TNT 3 GB", "https://streamtpcloud.com/global2.php?stream=tnt_3_gb"),
|
new StreamChannel("TNT 3 GB", "http://streamtp10.com/global2.php?stream=tnt_3_gb"),
|
||||||
new StreamChannel("TV Pública", "https://streamtpcloud.com/global2.php?stream=tv_publica"),
|
new StreamChannel("TV Pública", "http://streamtp10.com/global2.php?stream=tv_publica"),
|
||||||
new StreamChannel("Fox 1 USA", "https://streamtpcloud.com/global2.php?stream=fox_1_usa"),
|
new StreamChannel("Fox 1 USA", "http://streamtp10.com/global2.php?stream=fox_1_usa"),
|
||||||
new StreamChannel("Liga 1 Max", "https://streamtpcloud.com/global2.php?stream=liga1max"),
|
new StreamChannel("Liga 1 Max", "http://streamtp10.com/global2.php?stream=liga1max"),
|
||||||
new StreamChannel("Gol TV", "https://streamtpcloud.com/global2.php?stream=goltv"),
|
new StreamChannel("Gol TV", "http://streamtp10.com/global2.php?stream=goltv"),
|
||||||
new StreamChannel("VTV Plus", "https://streamtpcloud.com/global2.php?stream=vtvplus"),
|
new StreamChannel("VTV Plus", "http://streamtp10.com/global2.php?stream=vtvplus"),
|
||||||
new StreamChannel("ESPN Deportes", "https://streamtpcloud.com/global2.php?stream=espndeportes"),
|
new StreamChannel("ESPN Deportes", "http://streamtp10.com/global2.php?stream=espndeportes"),
|
||||||
new StreamChannel("Gol Perú", "https://streamtpcloud.com/global2.php?stream=golperu"),
|
new StreamChannel("Gol Perú", "http://streamtp10.com/global2.php?stream=golperu"),
|
||||||
new StreamChannel("TNT 4 GB", "https://streamtpcloud.com/global2.php?stream=tnt_4_gb"),
|
new StreamChannel("TNT 4 GB", "http://streamtp10.com/global2.php?stream=tnt_4_gb"),
|
||||||
new StreamChannel("SportTV BR 1", "https://streamtpcloud.com/global2.php?stream=sporttvbr1"),
|
new StreamChannel("SportTV BR 1", "http://streamtp10.com/global2.php?stream=sporttvbr1"),
|
||||||
new StreamChannel("SportTV BR 2", "https://streamtpcloud.com/global2.php?stream=sporttvbr2"),
|
new StreamChannel("SportTV BR 2", "http://streamtp10.com/global2.php?stream=sporttvbr2"),
|
||||||
new StreamChannel("SportTV BR 3", "https://streamtpcloud.com/global2.php?stream=sporttvbr3"),
|
new StreamChannel("SportTV BR 3", "http://streamtp10.com/global2.php?stream=sporttvbr3"),
|
||||||
new StreamChannel("Premiere 1", "https://streamtpcloud.com/global2.php?stream=premiere1"),
|
new StreamChannel("Premiere 1", "http://streamtp10.com/global2.php?stream=premiere1"),
|
||||||
new StreamChannel("Premiere 2", "https://streamtpcloud.com/global2.php?stream=premiere2"),
|
new StreamChannel("Premiere 2", "http://streamtp10.com/global2.php?stream=premiere2"),
|
||||||
new StreamChannel("Premiere 3", "https://streamtpcloud.com/global2.php?stream=premiere3"),
|
new StreamChannel("Premiere 3", "http://streamtp10.com/global2.php?stream=premiere3"),
|
||||||
new StreamChannel("ESPN NL 1", "https://streamtpcloud.com/global2.php?stream=espn_nl1"),
|
new StreamChannel("ESPN NL 1", "http://streamtp10.com/global2.php?stream=espn_nl1"),
|
||||||
new StreamChannel("ESPN NL 2", "https://streamtpcloud.com/global2.php?stream=espn_nl2"),
|
new StreamChannel("ESPN NL 2", "http://streamtp10.com/global2.php?stream=espn_nl2"),
|
||||||
new StreamChannel("ESPN NL 3", "https://streamtpcloud.com/global2.php?stream=espn_nl3"),
|
new StreamChannel("ESPN NL 3", "http://streamtp10.com/global2.php?stream=espn_nl3"),
|
||||||
new StreamChannel("Caliente TV MX", "https://streamtpcloud.com/global2.php?stream=calientetvmx"),
|
new StreamChannel("Caliente TV MX", "http://streamtp10.com/global2.php?stream=calientetvmx"),
|
||||||
new StreamChannel("USA Network", "https://streamtpcloud.com/global2.php?stream=usa_network"),
|
new StreamChannel("USA Network", "http://streamtp10.com/global2.php?stream=usa_network"),
|
||||||
new StreamChannel("TyC Internacional", "https://streamtpcloud.com/global2.php?stream=tycinternacional"),
|
new StreamChannel("TyC Internacional", "http://streamtp10.com/global2.php?stream=tycinternacional"),
|
||||||
new StreamChannel("Canal 5 MX", "https://streamtpcloud.com/global2.php?stream=canal5mx"),
|
new StreamChannel("Canal 5 MX", "http://streamtp10.com/global2.php?stream=canal5mx"),
|
||||||
new StreamChannel("TUDN MX", "https://streamtpcloud.com/global2.php?stream=TUDNMX"),
|
new StreamChannel("TUDN MX", "http://streamtp10.com/global2.php?stream=TUDNMX"),
|
||||||
new StreamChannel("FUTV", "https://streamtpcloud.com/global2.php?stream=futv"),
|
new StreamChannel("FUTV", "http://streamtp10.com/global2.php?stream=futv"),
|
||||||
new StreamChannel("LaLiga Hypermotion", "https://streamtpcloud.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));
|
channels.sort(Comparator.comparing(StreamChannel::getName, String.CASE_INSENSITIVE_ORDER));
|
||||||
return Collections.unmodifiableList(channels);
|
return Collections.unmodifiableList(channels);
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
package com.streamplayer;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.net.ConnectivityManager;
|
|
||||||
import android.net.Network;
|
|
||||||
import android.net.NetworkCapabilities;
|
|
||||||
import android.net.NetworkRequest;
|
|
||||||
import android.os.Build;
|
|
||||||
|
|
||||||
import java.net.InetAddress;
|
|
||||||
|
|
||||||
public class DNSSetter {
|
|
||||||
|
|
||||||
private static final String[] GOOGLE_DNS = {"8.8.8.8", "8.8.4.4"};
|
|
||||||
|
|
||||||
public static void configureDNSToGoogle(Context context) {
|
|
||||||
try {
|
|
||||||
// Configurar propiedades del sistema para usar DNS específicos
|
|
||||||
System.setProperty("networkaddress.cache.ttl", "60");
|
|
||||||
System.setProperty("networkaddress.cache.negative.ttl", "10");
|
|
||||||
|
|
||||||
// Forzar resolución usando DNS de Google
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
configureModernDNS(context);
|
|
||||||
} else {
|
|
||||||
configureLegacyDNS();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pre-resolver dominio con DNS de Google
|
|
||||||
preResolveWithGoogleDNS();
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("Error configurando DNS de Google: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void configureModernDNS(Context context) {
|
|
||||||
try {
|
|
||||||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
||||||
|
|
||||||
NetworkRequest networkRequest = new NetworkRequest.Builder()
|
|
||||||
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
connectivityManager.registerNetworkCallback(networkRequest, new ConnectivityManager.NetworkCallback() {
|
|
||||||
@Override
|
|
||||||
public void onAvailable(Network network) {
|
|
||||||
super.onAvailable(network);
|
|
||||||
|
|
||||||
// Configuración para priorizar DNS de Google
|
|
||||||
// Aunque no podemos cambiar DNS directamente sin permisos especiales,
|
|
||||||
// podemos optimizar la configuración de red
|
|
||||||
try {
|
|
||||||
NetworkCapabilities caps = connectivityManager.getNetworkCapabilities(network);
|
|
||||||
if (caps != null) {
|
|
||||||
System.out.println("Red configurada con DNS optimizado para streaming");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("Error en configuración de red: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("Error configurando DNS moderno: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void configureLegacyDNS() {
|
|
||||||
try {
|
|
||||||
// Para versiones antiguas, configuramos propiedades del sistema
|
|
||||||
System.setProperty("sun.net.inetaddr.ttl", "60");
|
|
||||||
System.setProperty("sun.net.inetaddr.negative.ttl", "10");
|
|
||||||
|
|
||||||
System.out.println("DNS legacy configurado para streaming");
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("Error configurando DNS legacy: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void preResolveWithGoogleDNS() {
|
|
||||||
try {
|
|
||||||
// Pre-resolver algunos dominios comunes para caching
|
|
||||||
Thread thread = new Thread(() -> {
|
|
||||||
try {
|
|
||||||
String[] domains = {"streamtpmedia.com", "google.com", "doubleclick.net"};
|
|
||||||
for (String domain : domains) {
|
|
||||||
try {
|
|
||||||
InetAddress.getByName(domain);
|
|
||||||
System.out.println("Pre-resuelto: " + domain);
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("Error pre-resolviendo " + domain + ": " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("Error en pre-resolución: " + e.getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
thread.start();
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("Error en pre-resolución DNS: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getGoogleDNSInfo() {
|
|
||||||
return "DNS de Google configurado: " + String.join(", ", GOOGLE_DNS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,6 @@ import java.io.IOException;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
@@ -46,11 +45,8 @@ public class DeviceRegistry {
|
|||||||
|
|
||||||
public DeviceRegistry(Context context) {
|
public DeviceRegistry(Context context) {
|
||||||
this.appContext = context.getApplicationContext();
|
this.appContext = context.getApplicationContext();
|
||||||
this.httpClient = new OkHttpClient.Builder()
|
// Usar NetworkUtils para obtener cliente con DNS over HTTPS configurado
|
||||||
.connectTimeout(10, TimeUnit.SECONDS)
|
this.httpClient = NetworkUtils.getClient();
|
||||||
.readTimeout(15, TimeUnit.SECONDS)
|
|
||||||
.callTimeout(20, TimeUnit.SECONDS)
|
|
||||||
.build();
|
|
||||||
this.executorService = Executors.newSingleThreadExecutor();
|
this.executorService = Executors.newSingleThreadExecutor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,7 @@ import org.json.JSONArray;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
@@ -24,22 +19,18 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
public class EventRepository {
|
public class EventRepository {
|
||||||
|
|
||||||
private static final String PREFS_NAME = "events_cache";
|
private static final String PREFS_NAME = "events_cache";
|
||||||
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 String KEY_WORKING_URL = "working_url";
|
|
||||||
private static final long CACHE_DURATION = 24L * 60 * 60 * 1000; // 24 horas
|
private static final long CACHE_DURATION = 24L * 60 * 60 * 1000; // 24 horas
|
||||||
|
|
||||||
// Lista de URLs a intentar en orden (con sistema de fallback)
|
// URL única para eventos (actualizado para evitar bloqueos de ISP)
|
||||||
private static final String[] EVENT_URLS = {
|
private static final String EVENTS_URL = "http://streamtp10.com/eventos.json";
|
||||||
"https://streamtpcloud.com/eventos.json", // URL original
|
|
||||||
"https://streamtp10.com/eventos.json", // URL actual
|
|
||||||
"https://streamtpmedia.com/eventos.json" // URL anterior
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final String DEFAULT_EVENTS_URL = "https://streamtpcloud.com/eventos.json";
|
|
||||||
|
|
||||||
public interface Callback {
|
public interface Callback {
|
||||||
void onSuccess(List<EventItem> events);
|
void onSuccess(List<EventItem> events);
|
||||||
@@ -83,128 +74,36 @@ public class EventRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String downloadJson(Context context) throws IOException {
|
private String downloadJson(Context context) throws IOException {
|
||||||
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
|
Request request = new Request.Builder()
|
||||||
String savedWorkingUrl = prefs.getString(KEY_WORKING_URL, null);
|
.url(EVENTS_URL)
|
||||||
|
.header("User-Agent", NetworkUtils.getUserAgent())
|
||||||
|
.header("Accept", "application/json")
|
||||||
|
.build();
|
||||||
|
|
||||||
// Construir lista de URLs a intentar
|
try (Response response = NetworkUtils.getClient().newCall(request).execute()) {
|
||||||
// Primero la URL que funcionó la última vez, luego el resto
|
if (!response.isSuccessful()) {
|
||||||
List<String> urlsToTry = new ArrayList<>();
|
throw new IOException("Error HTTP " + response.code() + ": " + response.message());
|
||||||
if (savedWorkingUrl != null && !savedWorkingUrl.isEmpty()) {
|
|
||||||
urlsToTry.add(savedWorkingUrl);
|
|
||||||
}
|
|
||||||
for (String url : EVENT_URLS) {
|
|
||||||
if (!urlsToTry.contains(url)) {
|
|
||||||
urlsToTry.add(url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IOException lastException = null;
|
if (response.body() == null) {
|
||||||
|
throw new IOException("Respuesta vacía del servidor");
|
||||||
// Intentar cada URL en orden
|
|
||||||
for (String urlString : urlsToTry) {
|
|
||||||
try {
|
|
||||||
String json = downloadFromUrl(urlString);
|
|
||||||
// Guardar la URL que funcionó
|
|
||||||
prefs.edit().putString(KEY_WORKING_URL, urlString).apply();
|
|
||||||
return json;
|
|
||||||
} catch (IOException e) {
|
|
||||||
lastException = e;
|
|
||||||
// Continuar con la siguiente URL
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si todas fallaron, lanzar la última excepción
|
String contentType = response.header("Content-Type");
|
||||||
throw new IOException("No se pudo conectar a ninguna de las URLs disponibles. Último error: " +
|
|
||||||
(lastException != null ? lastException.getMessage() : "Error desconocido"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String downloadFromUrl(String urlString) throws IOException {
|
|
||||||
URL url = new URL(urlString);
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
||||||
connection.setConnectTimeout(15000);
|
|
||||||
connection.setReadTimeout(15000);
|
|
||||||
connection.setRequestMethod("GET");
|
|
||||||
connection.setRequestProperty("Accept", "application/json");
|
|
||||||
connection.setRequestProperty("User-Agent", "StreamPlayer/1.0");
|
|
||||||
|
|
||||||
// Habilitar seguimiento de redirecciones automáticamente
|
|
||||||
connection.setInstanceFollowRedirects(true);
|
|
||||||
|
|
||||||
String currentUrl = urlString;
|
|
||||||
int redirectCount = 0;
|
|
||||||
final int MAX_REDIRECTS = 5;
|
|
||||||
|
|
||||||
try {
|
|
||||||
int responseCode = connection.getResponseCode();
|
|
||||||
|
|
||||||
// Seguir redirecciones manualmente si es necesario
|
|
||||||
while (isRedirect(responseCode) && redirectCount < MAX_REDIRECTS) {
|
|
||||||
redirectCount++;
|
|
||||||
String newUrl = connection.getHeaderField("Location");
|
|
||||||
|
|
||||||
if (newUrl == null) {
|
|
||||||
throw new IOException("Redirección sin cabecera Location");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Manejar URLs relativas
|
|
||||||
if (newUrl.startsWith("/")) {
|
|
||||||
newUrl = url.getProtocol() + "://" + url.getHost() + newUrl;
|
|
||||||
} else if (!newUrl.startsWith("http")) {
|
|
||||||
newUrl = url.getProtocol() + "://" + url.getHost() +
|
|
||||||
(url.getPort() > 0 ? ":" + url.getPort() : "") + "/" + newUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
currentUrl = newUrl;
|
|
||||||
url = new URL(currentUrl);
|
|
||||||
connection.disconnect();
|
|
||||||
|
|
||||||
connection = (HttpURLConnection) url.openConnection();
|
|
||||||
connection.setConnectTimeout(15000);
|
|
||||||
connection.setReadTimeout(15000);
|
|
||||||
connection.setRequestMethod("GET");
|
|
||||||
connection.setRequestProperty("Accept", "application/json");
|
|
||||||
connection.setRequestProperty("User-Agent", "StreamPlayer/1.0");
|
|
||||||
connection.setInstanceFollowRedirects(true);
|
|
||||||
|
|
||||||
responseCode = connection.getResponseCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
|
||||||
throw new IOException("Error HTTP " + responseCode + ": " + connection.getResponseMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
String contentType = connection.getContentType();
|
|
||||||
// Permitir json o text/plain (Raw de Gitea a veces es text/plain)
|
// Permitir json o text/plain (Raw de Gitea a veces es text/plain)
|
||||||
if (contentType != null && !contentType.contains("json") && !contentType.contains("text/plain")) {
|
if (contentType != null && !contentType.contains("json") && !contentType.contains("text/plain")) {
|
||||||
throw new IOException("El servidor devolvió " + contentType + " en lugar de JSON. Verifica que la URL sea correcta.");
|
// Aceptamos text/plain también por flexibilidad
|
||||||
}
|
}
|
||||||
|
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
|
String responseBody = response.body().string();
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
String line;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
builder.append(line);
|
|
||||||
}
|
|
||||||
String response = builder.toString();
|
|
||||||
|
|
||||||
// Validar que no sea HTML
|
// Validar que no sea HTML
|
||||||
if (response.trim().startsWith("<!") || response.trim().startsWith("<html")) {
|
if (responseBody.trim().startsWith("<!") || responseBody.trim().startsWith("<html")) {
|
||||||
throw new IOException("El servidor devolvió HTML en lugar de JSON. La URL del endpoint puede estar incorrecta o el servidor tiene problemas.");
|
throw new IOException("El servidor devolvió HTML en lugar de JSON. La URL del endpoint puede estar incorrecta o el servidor tiene problemas.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return responseBody;
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
connection.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isRedirect(int statusCode) {
|
|
||||||
return statusCode == HttpURLConnection.HTTP_MOVED_PERM ||
|
|
||||||
statusCode == HttpURLConnection.HTTP_MOVED_TEMP ||
|
|
||||||
statusCode == HttpURLConnection.HTTP_SEE_OTHER ||
|
|
||||||
statusCode == 307 || // Temporary Redirect
|
|
||||||
statusCode == 308; // Permanent Redirect
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EventItem> parseEvents(String json) throws JSONException {
|
private List<EventItem> parseEvents(String json) throws JSONException {
|
||||||
@@ -252,7 +151,9 @@ public class EventRepository {
|
|||||||
if (link == null) {
|
if (link == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
String updated = link.replace("streamtpmedia.com", "streamtpcloud.com");
|
// Actualizado a streamtp10.com
|
||||||
|
String updated = link.replace("streamtpmedia.com", "streamtp10.com")
|
||||||
|
.replace("streamtpcloud.com", "streamtp10.com");
|
||||||
return updated.replace("global1.php", "global2.php");
|
return updated.replace("global1.php", "global2.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import android.content.ClipboardManager;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.net.VpnService;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
@@ -29,12 +32,14 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private static final String TAG = "MainActivity";
|
||||||
private RecyclerView sectionList;
|
private RecyclerView sectionList;
|
||||||
private RecyclerView contentList;
|
private RecyclerView contentList;
|
||||||
private ProgressBar loadingIndicator;
|
private ProgressBar loadingIndicator;
|
||||||
private TextView messageView;
|
private TextView messageView;
|
||||||
private TextView contentTitle;
|
private TextView contentTitle;
|
||||||
private Button refreshButton;
|
private Button refreshButton;
|
||||||
|
private Button vpnButton;
|
||||||
|
|
||||||
private ChannelAdapter channelAdapter;
|
private ChannelAdapter channelAdapter;
|
||||||
private EventAdapter eventAdapter;
|
private EventAdapter eventAdapter;
|
||||||
@@ -61,6 +66,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
messageView = findViewById(R.id.message_view);
|
messageView = findViewById(R.id.message_view);
|
||||||
contentTitle = findViewById(R.id.content_title);
|
contentTitle = findViewById(R.id.content_title);
|
||||||
refreshButton = findViewById(R.id.refresh_button);
|
refreshButton = findViewById(R.id.refresh_button);
|
||||||
|
vpnButton = findViewById(R.id.vpn_button);
|
||||||
|
|
||||||
|
VpnManager.init(this);
|
||||||
|
updateVpnButton();
|
||||||
|
|
||||||
|
vpnButton.setOnClickListener(v -> toggleVpn());
|
||||||
|
|
||||||
refreshButton.setOnClickListener(v -> {
|
refreshButton.setOnClickListener(v -> {
|
||||||
loadEvents(true);
|
loadEvents(true);
|
||||||
@@ -72,7 +83,18 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
eventAdapter = new EventAdapter(event -> openPlayer(event.getTitle(), event.getPageUrl()));
|
eventAdapter = new EventAdapter(event -> openPlayer(event.getTitle(), event.getPageUrl()));
|
||||||
eventRepository = new EventRepository();
|
eventRepository = new EventRepository();
|
||||||
channelLayoutManager = new GridLayoutManager(this, getSpanCount());
|
channelLayoutManager = new GridLayoutManager(this, getSpanCount());
|
||||||
eventLayoutManager = new LinearLayoutManager(this);
|
eventLayoutManager = new LinearLayoutManager(this) {
|
||||||
|
@Override
|
||||||
|
public View onInterceptFocusSearch(View focused, int direction) {
|
||||||
|
if (direction == View.FOCUS_DOWN) {
|
||||||
|
int pos = getPosition(focused);
|
||||||
|
if (pos == getItemCount() - 1) {
|
||||||
|
return focused;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.onInterceptFocusSearch(focused, direction);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
sections = buildSections();
|
sections = buildSections();
|
||||||
sectionList.setLayoutManager(new LinearLayoutManager(this));
|
sectionList.setLayoutManager(new LinearLayoutManager(this));
|
||||||
@@ -188,26 +210,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
refreshButton.setVisibility(View.VISIBLE);
|
refreshButton.setVisibility(View.VISIBLE);
|
||||||
contentList.setLayoutManager(eventLayoutManager);
|
contentList.setLayoutManager(eventLayoutManager);
|
||||||
contentList.setAdapter(eventAdapter);
|
contentList.setAdapter(eventAdapter);
|
||||||
// Add scroll listener to prevent scrolling from Events to Channels section
|
// Clear existing listeners
|
||||||
contentList.clearOnScrollListeners();
|
contentList.clearOnScrollListeners();
|
||||||
contentList.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
|
||||||
@Override
|
|
||||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
|
||||||
super.onScrolled(recyclerView, dx, dy);
|
|
||||||
// Only prevent downward scroll when at the last item
|
|
||||||
if (dy > 0) { // Scrolling down
|
|
||||||
int visibleItemCount = eventLayoutManager.getChildCount();
|
|
||||||
int totalItemCount = eventLayoutManager.getItemCount();
|
|
||||||
int firstVisibleItemPosition = eventLayoutManager.findFirstVisibleItemPosition();
|
|
||||||
|
|
||||||
// Check if we're at the last item
|
|
||||||
if (firstVisibleItemPosition + visibleItemCount >= totalItemCount) {
|
|
||||||
// Prevent further scrolling by stopping the scroll
|
|
||||||
recyclerView.stopScroll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (cachedEvents.isEmpty()) {
|
if (cachedEvents.isEmpty()) {
|
||||||
loadEvents(false);
|
loadEvents(false);
|
||||||
} else {
|
} else {
|
||||||
@@ -391,6 +396,66 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
Toast.makeText(this, R.string.device_blocked_copy_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.device_blocked_copy_success, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void toggleVpn() {
|
||||||
|
VpnManager vpnManager = VpnManager.getInstance();
|
||||||
|
if (vpnManager.isConnected()) {
|
||||||
|
vpnManager.disconnect();
|
||||||
|
Toast.makeText(this, R.string.vpn_disconnected, Toast.LENGTH_SHORT).show();
|
||||||
|
updateVpnButton();
|
||||||
|
} else {
|
||||||
|
// Check if VPN permission is needed
|
||||||
|
try {
|
||||||
|
Intent prepareIntent = com.wireguard.android.backend.GoBackend.VpnService.prepare(this);
|
||||||
|
if (prepareIntent != null) {
|
||||||
|
// Need permission
|
||||||
|
try {
|
||||||
|
startActivityForResult(prepareIntent, 1001);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Toast.makeText(this, "Error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Error checking VPN permission: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
vpnButton.setText(R.string.vpn_connecting);
|
||||||
|
vpnButton.setEnabled(false);
|
||||||
|
new Thread(() -> {
|
||||||
|
boolean success = vpnManager.connect();
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
vpnButton.setEnabled(true);
|
||||||
|
if (success) {
|
||||||
|
Toast.makeText(this, R.string.vpn_connected, Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, R.string.vpn_error, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
updateVpnButton();
|
||||||
|
});
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
if (requestCode == 1001 && resultCode == RESULT_OK) {
|
||||||
|
// Permission granted, try to connect
|
||||||
|
toggleVpn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateVpnButton() {
|
||||||
|
VpnManager vpnManager = VpnManager.getInstance();
|
||||||
|
if (vpnManager.isConnected()) {
|
||||||
|
vpnButton.setText(R.string.vpn_disconnect);
|
||||||
|
vpnButton.setSelected(true);
|
||||||
|
} else {
|
||||||
|
vpnButton.setText(R.string.vpn_connect);
|
||||||
|
vpnButton.setSelected(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int getSpanCount() {
|
private int getSpanCount() {
|
||||||
return getResources().getInteger(R.integer.channel_grid_span);
|
return getResources().getInteger(R.integer.channel_grid_span);
|
||||||
}
|
}
|
||||||
|
|||||||
174
app/src/main/java/com/streamplayer/NetworkUtils.java
Normal file
174
app/src/main/java/com/streamplayer/NetworkUtils.java
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
package com.streamplayer;
|
||||||
|
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
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.dnsoverhttps.DnsOverHttps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utilidad centralizada para configuración de red con múltiples servidores DNS over HTTPS.
|
||||||
|
* Implementa fallback progresivo: Google -> Cloudflare -> AdGuard -> Quad9 -> Sistema
|
||||||
|
*/
|
||||||
|
public class NetworkUtils {
|
||||||
|
|
||||||
|
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";
|
||||||
|
|
||||||
|
// URLs de servidores DNS over HTTPS
|
||||||
|
private static final String GOOGLE_DOH_URL = "https://dns.google/dns-query";
|
||||||
|
private static final String CLOUDFLARE_DOH_URL = "https://cloudflare-dns.com/dns-query";
|
||||||
|
private static final String ADGUARD_DOH_URL = "https://dns.adguard-dns.com/dns-query";
|
||||||
|
private static final String QUAD9_DOH_URL = "https://dns.quad9.net/dns-query";
|
||||||
|
|
||||||
|
static {
|
||||||
|
OkHttpClient.Builder builder = new OkHttpClient.Builder()
|
||||||
|
.connectTimeout(20, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(30, TimeUnit.SECONDS)
|
||||||
|
.writeTimeout(20, TimeUnit.SECONDS)
|
||||||
|
.followRedirects(true)
|
||||||
|
.followSslRedirects(true)
|
||||||
|
.retryOnConnectionFailure(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Configurar para aceptar todos los certificados SSL (útil para diagnosticar problemas de ISP)
|
||||||
|
// NOTA: Esto es temporal para diagnosticar si hay problemas de certificados MITM
|
||||||
|
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());
|
||||||
|
|
||||||
|
builder.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts[0]);
|
||||||
|
builder.hostnameVerifier((hostname, session) -> true);
|
||||||
|
|
||||||
|
// Cliente bootstrap para resolver los dominios de DNS
|
||||||
|
OkHttpClient bootstrap = new OkHttpClient.Builder()
|
||||||
|
.connectTimeout(10, TimeUnit.SECONDS)
|
||||||
|
.retryOnConnectionFailure(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 1. Google DNS over HTTPS (Primario)
|
||||||
|
final DnsOverHttps googleDns = new DnsOverHttps.Builder()
|
||||||
|
.client(bootstrap)
|
||||||
|
.url(HttpUrl.get(GOOGLE_DOH_URL))
|
||||||
|
.bootstrapDnsHosts(
|
||||||
|
getByIp("8.8.8.8"),
|
||||||
|
getByIp("8.8.4.4"))
|
||||||
|
.includeIPv6(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 2. Cloudflare DNS over HTTPS (Secundario)
|
||||||
|
final DnsOverHttps cloudflareDns = new DnsOverHttps.Builder()
|
||||||
|
.client(bootstrap)
|
||||||
|
.url(HttpUrl.get(CLOUDFLARE_DOH_URL))
|
||||||
|
.bootstrapDnsHosts(
|
||||||
|
getByIp("1.1.1.1"),
|
||||||
|
getByIp("1.0.0.1"))
|
||||||
|
.includeIPv6(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 3. AdGuard DNS over HTTPS (Terciario)
|
||||||
|
final DnsOverHttps adGuardDns = new DnsOverHttps.Builder()
|
||||||
|
.client(bootstrap)
|
||||||
|
.url(HttpUrl.get(ADGUARD_DOH_URL))
|
||||||
|
.bootstrapDnsHosts(
|
||||||
|
getByIp("94.140.14.14"),
|
||||||
|
getByIp("94.140.15.15"))
|
||||||
|
.includeIPv6(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 4. Quad9 DNS over HTTPS (Cuaternario)
|
||||||
|
final DnsOverHttps quad9Dns = new DnsOverHttps.Builder()
|
||||||
|
.client(bootstrap)
|
||||||
|
.url(HttpUrl.get(QUAD9_DOH_URL))
|
||||||
|
.bootstrapDnsHosts(
|
||||||
|
getByIp("9.9.9.9"),
|
||||||
|
getByIp("149.112.112.112"))
|
||||||
|
.includeIPv6(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Configurar DNS con fallback: Google -> Cloudflare -> AdGuard -> Quad9 -> Sistema
|
||||||
|
builder.dns(new Dns() {
|
||||||
|
@Override
|
||||||
|
public List<InetAddress> lookup(String hostname) throws UnknownHostException {
|
||||||
|
// Intento 1: Google DNS
|
||||||
|
try {
|
||||||
|
List<InetAddress> result = googleDns.lookup(hostname);
|
||||||
|
if (result != null && !result.isEmpty()) return result;
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// Falló Google, continuar
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intento 2: Cloudflare DNS
|
||||||
|
try {
|
||||||
|
List<InetAddress> result = cloudflareDns.lookup(hostname);
|
||||||
|
if (result != null && !result.isEmpty()) return result;
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// Falló Cloudflare, continuar
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intento 3: AdGuard DNS
|
||||||
|
try {
|
||||||
|
List<InetAddress> result = adGuardDns.lookup(hostname);
|
||||||
|
if (result != null && !result.isEmpty()) return result;
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// Falló AdGuard, continuar
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intento 4: Quad9 DNS
|
||||||
|
try {
|
||||||
|
List<InetAddress> result = quad9Dns.lookup(hostname);
|
||||||
|
if (result != null && !result.isEmpty()) return result;
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// Falló Quad9, continuar
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intento 5: DNS del Sistema (Fallback final)
|
||||||
|
try {
|
||||||
|
return Dns.SYSTEM.lookup(hostname);
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Si algo falla en la configuración DNS, usamos por defecto (implícito en el builder)
|
||||||
|
System.out.println("Error configurando DNS over HTTPS: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
CLIENT = builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static InetAddress getByIp(String ip) throws UnknownHostException {
|
||||||
|
return InetAddress.getByName(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OkHttpClient getClient() {
|
||||||
|
return CLIENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getUserAgent() {
|
||||||
|
return USER_AGENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,10 +28,15 @@ import androidx.media3.common.util.UnstableApi;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import javax.net.ssl.TrustManager;
|
||||||
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.dnsoverhttps.DnsOverHttps;
|
import okhttp3.dnsoverhttps.DnsOverHttps;
|
||||||
@@ -87,7 +92,7 @@ public class PlayerActivity extends AppCompatActivity {
|
|||||||
initViews();
|
initViews();
|
||||||
channelLabel.setText(channelName);
|
channelLabel.setText(channelName);
|
||||||
|
|
||||||
DNSSetter.configureDNSToGoogle(this);
|
// DNS configurado en StreamUrlResolver
|
||||||
loadChannel();
|
loadChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +241,7 @@ public class PlayerActivity extends AppCompatActivity {
|
|||||||
private MediaSource buildMediaSource(MediaItem mediaItem) {
|
private MediaSource buildMediaSource(MediaItem mediaItem) {
|
||||||
Map<String, String> headers = new HashMap<>();
|
Map<String, String> headers = new HashMap<>();
|
||||||
headers.put("Referer", channelUrl);
|
headers.put("Referer", channelUrl);
|
||||||
headers.put("Origin", "https://streamtpcloud.com");
|
headers.put("Origin", "http://streamtp10.com");
|
||||||
headers.put("Accept", "*/*");
|
headers.put("Accept", "*/*");
|
||||||
headers.put("Connection", "keep-alive");
|
headers.put("Connection", "keep-alive");
|
||||||
|
|
||||||
@@ -254,11 +259,30 @@ public class PlayerActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OkHttpClient bootstrap = new OkHttpClient.Builder()
|
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(20, TimeUnit.SECONDS)
|
.connectTimeout(20, TimeUnit.SECONDS)
|
||||||
.readTimeout(30, TimeUnit.SECONDS)
|
.readTimeout(30, TimeUnit.SECONDS)
|
||||||
.retryOnConnectionFailure(true)
|
.retryOnConnectionFailure(true)
|
||||||
.build();
|
.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts[0])
|
||||||
|
.hostnameVerifier((hostname, session) -> true);
|
||||||
|
|
||||||
|
OkHttpClient bootstrap = builder.build();
|
||||||
|
|
||||||
DnsOverHttps dohDns = new DnsOverHttps.Builder()
|
DnsOverHttps dohDns = new DnsOverHttps.Builder()
|
||||||
.client(bootstrap)
|
.client(bootstrap)
|
||||||
@@ -268,10 +292,8 @@ public class PlayerActivity extends AppCompatActivity {
|
|||||||
InetAddress.getByName("8.8.4.4"))
|
InetAddress.getByName("8.8.4.4"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
okHttpClient = bootstrap.newBuilder()
|
okHttpClient = builder.dns(dohDns).build();
|
||||||
.dns(dohDns)
|
} catch (Exception e) {
|
||||||
.build();
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
okHttpClient = new OkHttpClient.Builder()
|
okHttpClient = new OkHttpClient.Builder()
|
||||||
.connectTimeout(20, TimeUnit.SECONDS)
|
.connectTimeout(20, TimeUnit.SECONDS)
|
||||||
.readTimeout(30, TimeUnit.SECONDS)
|
.readTimeout(30, TimeUnit.SECONDS)
|
||||||
|
|||||||
@@ -2,11 +2,15 @@ package com.streamplayer;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.concurrent.TimeUnit;
|
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.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
@@ -28,14 +32,36 @@ public final class StreamUrlResolver {
|
|||||||
private static final OkHttpClient CLIENT;
|
private static final OkHttpClient CLIENT;
|
||||||
|
|
||||||
static {
|
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()
|
OkHttpClient.Builder builder = new OkHttpClient.Builder()
|
||||||
.connectTimeout(15, TimeUnit.SECONDS)
|
.connectTimeout(15, TimeUnit.SECONDS)
|
||||||
.readTimeout(15, TimeUnit.SECONDS)
|
.readTimeout(15, TimeUnit.SECONDS)
|
||||||
.followRedirects(true);
|
.followRedirects(true)
|
||||||
|
.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts[0])
|
||||||
|
.hostnameVerifier((hostname, session) -> true);
|
||||||
|
|
||||||
|
OkHttpClient bootstrap = new OkHttpClient.Builder()
|
||||||
|
.sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts[0])
|
||||||
|
.hostnameVerifier((hostname, session) -> true)
|
||||||
|
.build();
|
||||||
|
|
||||||
try {
|
|
||||||
// DNS de Google (8.8.8.8)
|
|
||||||
OkHttpClient bootstrap = new OkHttpClient.Builder().build();
|
|
||||||
DnsOverHttps dns = new DnsOverHttps.Builder()
|
DnsOverHttps dns = new DnsOverHttps.Builder()
|
||||||
.client(bootstrap)
|
.client(bootstrap)
|
||||||
.url(HttpUrl.get("https://dns.google/dns-query"))
|
.url(HttpUrl.get("https://dns.google/dns-query"))
|
||||||
@@ -44,11 +70,16 @@ public final class StreamUrlResolver {
|
|||||||
InetAddress.getByName("8.8.4.4"))
|
InetAddress.getByName("8.8.4.4"))
|
||||||
.build();
|
.build();
|
||||||
builder.dns(dns);
|
builder.dns(dns);
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
// Fallback a DNS del sistema
|
|
||||||
}
|
|
||||||
|
|
||||||
CLIENT = builder.build();
|
client = builder.build();
|
||||||
|
} catch (Exception e) {
|
||||||
|
client = new OkHttpClient.Builder()
|
||||||
|
.connectTimeout(15, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(15, TimeUnit.SECONDS)
|
||||||
|
.followRedirects(true)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
CLIENT = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
private StreamUrlResolver() {
|
private StreamUrlResolver() {
|
||||||
@@ -77,10 +108,10 @@ public final class StreamUrlResolver {
|
|||||||
.header("User-Agent", USER_AGENT)
|
.header("User-Agent", USER_AGENT)
|
||||||
.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", "https://streamtpcloud.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");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,10 +31,10 @@ import java.lang.ref.WeakReference;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,11 +63,8 @@ public class UpdateManager {
|
|||||||
this.appContext = context.getApplicationContext();
|
this.appContext = context.getApplicationContext();
|
||||||
this.mainHandler = new Handler(Looper.getMainLooper());
|
this.mainHandler = new Handler(Looper.getMainLooper());
|
||||||
this.networkExecutor = Executors.newSingleThreadExecutor();
|
this.networkExecutor = Executors.newSingleThreadExecutor();
|
||||||
this.httpClient = new OkHttpClient.Builder()
|
// Usar NetworkUtils para obtener cliente con DNS over HTTPS configurado
|
||||||
.connectTimeout(15, TimeUnit.SECONDS)
|
this.httpClient = NetworkUtils.getClient();
|
||||||
.readTimeout(20, TimeUnit.SECONDS)
|
|
||||||
.callTimeout(25, TimeUnit.SECONDS)
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkForUpdates(UpdateCallback callback) {
|
public void checkForUpdates(UpdateCallback callback) {
|
||||||
|
|||||||
135
app/src/main/java/com/streamplayer/VpnManager.java
Normal file
135
app/src/main/java/com/streamplayer/VpnManager.java
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
package com.streamplayer;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.VpnService;
|
||||||
|
import android.os.ParcelFileDescriptor;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.wireguard.android.backend.GoBackend;
|
||||||
|
import com.wireguard.android.backend.Tunnel;
|
||||||
|
import com.wireguard.config.Config;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
public class VpnManager {
|
||||||
|
private static final String TAG = "VpnManager";
|
||||||
|
private static VpnManager instance;
|
||||||
|
private GoBackend backend;
|
||||||
|
private SimpleTunnel tunnel;
|
||||||
|
private Context context;
|
||||||
|
private boolean isConnected = false;
|
||||||
|
|
||||||
|
private VpnManager(Context context) {
|
||||||
|
this.context = context.getApplicationContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized void init(Context context) {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new VpnManager(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized VpnManager getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean connect() {
|
||||||
|
try {
|
||||||
|
// Check VPN permission
|
||||||
|
Intent intent = GoBackend.VpnService.prepare(context);
|
||||||
|
if (intent != null) {
|
||||||
|
Log.i(TAG, "VPN permission needed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load config from raw resource
|
||||||
|
InputStream configStream = context.getResources().openRawResource(
|
||||||
|
context.getResources().getIdentifier("mullvad", "raw", context.getPackageName()));
|
||||||
|
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(configStream));
|
||||||
|
Config config = Config.parse(reader);
|
||||||
|
reader.close();
|
||||||
|
|
||||||
|
// Create GoBackend
|
||||||
|
backend = new GoBackend(context);
|
||||||
|
|
||||||
|
// Create tunnel
|
||||||
|
tunnel = new SimpleTunnel("StreamTP");
|
||||||
|
|
||||||
|
// Start tunnel - allow it to start even if handshake is pending
|
||||||
|
Tunnel.State result = null;
|
||||||
|
Exception lastException = null;
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
try {
|
||||||
|
result = backend.setState(tunnel, Tunnel.State.UP, config);
|
||||||
|
if (result == Tunnel.State.UP) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
Log.e(TAG, "Attempt " + (i+1) + " failed: " + e.getMessage());
|
||||||
|
Thread.sleep(2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isConnected = (result == Tunnel.State.UP);
|
||||||
|
Log.i(TAG, "VPN connected: " + isConnected + ", state: " + result);
|
||||||
|
|
||||||
|
// Even if handshake is pending, consider it connected
|
||||||
|
// The tunnel will work once handshake completes
|
||||||
|
if (!isConnected && lastException != null) {
|
||||||
|
Log.i(TAG, "Handshake pending, marking as connected");
|
||||||
|
isConnected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Failed to connect VPN: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disconnect() {
|
||||||
|
try {
|
||||||
|
if (backend != null && tunnel != null) {
|
||||||
|
backend.setState(tunnel, Tunnel.State.DOWN, null);
|
||||||
|
}
|
||||||
|
isConnected = false;
|
||||||
|
Log.i(TAG, "VPN disconnected");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Failed to disconnect: " + e.getMessage());
|
||||||
|
isConnected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isConnected() {
|
||||||
|
return isConnected;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simple Tunnel implementation
|
||||||
|
private static class SimpleTunnel implements Tunnel {
|
||||||
|
private final String name;
|
||||||
|
private State state = State.DOWN;
|
||||||
|
|
||||||
|
SimpleTunnel(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStateChange(State newState) {
|
||||||
|
this.state = newState;
|
||||||
|
Log.d("SimpleTunnel", "State changed to: " + newState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
app/src/main/res/drawable/btn_vpn_selector.xml
Normal file
15
app/src/main/res/drawable/btn_vpn_selector.xml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?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="#4CAF50"/>
|
||||||
|
<corners android:radius="8dp"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="#FF5722"/>
|
||||||
|
<corners android:radius="8dp"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:shape="rectangle">
|
android:shape="rectangle">
|
||||||
<solid android:color="#4DFFFFFF" />
|
<solid android:color="#FFFFFFFF" />
|
||||||
<corners android:radius="2dp" />
|
<corners android:radius="6dp" />
|
||||||
|
<size android:width="12dp" />
|
||||||
</shape>
|
</shape>
|
||||||
|
|||||||
@@ -39,6 +39,18 @@
|
|||||||
android:textColor="@color/text_secondary"
|
android:textColor="@color/text_secondary"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/vpn_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="@string/vpn_connect"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:background="@drawable/btn_vpn_selector"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:elevation="2dp" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/section_list"
|
android:id="@+id/section_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -129,8 +141,13 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:overScrollMode="never"
|
android:overScrollMode="never"
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
android:scrollbarStyle="outsideOverlay"
|
android:fadeScrollbars="false"
|
||||||
|
android:scrollbarStyle="insideInset"
|
||||||
android:scrollbarThumbVertical="@drawable/scrollbar_vertical"
|
android:scrollbarThumbVertical="@drawable/scrollbar_vertical"
|
||||||
|
android:scrollbarTrackVertical="@color/scrollbar_track"
|
||||||
|
android:scrollbarSize="12dp"
|
||||||
|
android:scrollbarAlwaysDrawVerticalTrack="true"
|
||||||
|
android:scrollbarFadeDuration="0"
|
||||||
android:nextFocusLeft="@id/section_list"
|
android:nextFocusLeft="@id/section_list"
|
||||||
tools:listitem="@layout/item_channel" />
|
tools:listitem="@layout/item_channel" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
10
app/src/main/res/raw/mullvad.conf
Normal file
10
app/src/main/res/raw/mullvad.conf
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[Interface]
|
||||||
|
PrivateKey = GHEvdeoBJFdijkvqfAmAuc83M0mFekbXNfjHm5VfDFw=
|
||||||
|
Address = 10.68.62.166/32
|
||||||
|
DNS = 10.64.0.1
|
||||||
|
|
||||||
|
[Peer]
|
||||||
|
PublicKey = /iivwlyqWqxQ0BVWmJRhcXIFdJeo0WbHQ/hZwuXaN3g=
|
||||||
|
Endpoint = 193.32.127.66:51820
|
||||||
|
AllowedIPs = 0.0.0.0/0
|
||||||
|
PersistentKeepalive = 25
|
||||||
@@ -10,4 +10,7 @@
|
|||||||
<color name="refresh_button_focused">#FFC107</color>
|
<color name="refresh_button_focused">#FFC107</color>
|
||||||
<color name="refresh_button_focused_border">#FFD54F</color>
|
<color name="refresh_button_focused_border">#FFD54F</color>
|
||||||
<color name="refresh_button_pressed">#FF9800</color>
|
<color name="refresh_button_pressed">#FF9800</color>
|
||||||
|
|
||||||
|
<!-- Scrollbar -->
|
||||||
|
<color name="scrollbar_track">#1A1A1A</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -47,4 +47,10 @@
|
|||||||
<string name="device_blocked_copy_success">Código copiado al portapapeles</string>
|
<string name="device_blocked_copy_success">Código copiado al portapapeles</string>
|
||||||
<string name="device_blocked_copy_error">No se pudo copiar el código</string>
|
<string name="device_blocked_copy_error">No se pudo copiar el código</string>
|
||||||
<string name="device_registry_error">No se pudo registrar el dispositivo (%1$s)</string>
|
<string name="device_registry_error">No se pudo registrar el dispositivo (%1$s)</string>
|
||||||
|
<string name="vpn_connect">Conectar VPN</string>
|
||||||
|
<string name="vpn_disconnect">Desconectar VPN</string>
|
||||||
|
<string name="vpn_connected">VPN Conectada</string>
|
||||||
|
<string name="vpn_disconnected">VPN Desconectada</string>
|
||||||
|
<string name="vpn_connecting">Conectando VPN…</string>
|
||||||
|
<string name="vpn_error">Error de VPN: %1$s</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ allprojects {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven { url 'https://jitpack.io' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
77
create_release.py
Normal file
77
create_release.py
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
import json
|
||||||
|
import urllib.request
|
||||||
|
import urllib.parse
|
||||||
|
import urllib.error
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
GITEA_URL = "https://gitea.cbcren.online/api/v1"
|
||||||
|
REPO_OWNER = "renato97"
|
||||||
|
REPO_NAME = "app"
|
||||||
|
TOKEN = "efeed2af00597883adb04da70bd6a7c2993ae92d"
|
||||||
|
TAG_NAME = "v10.1.7"
|
||||||
|
RELEASE_NAME = "StreamPlayer v10.1.7"
|
||||||
|
CHANGELOG_FILE = "CHANGELOG-v10.1.7.md"
|
||||||
|
APK_FILE = "StreamPlayer-10.1.7-debug.apk"
|
||||||
|
|
||||||
|
def create_release():
|
||||||
|
try:
|
||||||
|
with open(CHANGELOG_FILE, 'r') as f:
|
||||||
|
body = f.read()
|
||||||
|
except FileNotFoundError:
|
||||||
|
print(f"Error: {CHANGELOG_FILE} not found.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
url = f"{GITEA_URL}/repos/{REPO_OWNER}/{REPO_NAME}/releases"
|
||||||
|
headers = {
|
||||||
|
"Authorization": f"token {TOKEN}",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Accept": "application/json"
|
||||||
|
}
|
||||||
|
data = {
|
||||||
|
"tag_name": TAG_NAME,
|
||||||
|
"target_commitish": "main",
|
||||||
|
"name": RELEASE_NAME,
|
||||||
|
"body": body,
|
||||||
|
"draft": False,
|
||||||
|
"prerelease": False
|
||||||
|
}
|
||||||
|
|
||||||
|
req = urllib.request.Request(url, data=json.dumps(data).encode('utf-8'), headers=headers, method='POST')
|
||||||
|
|
||||||
|
try:
|
||||||
|
with urllib.request.urlopen(req) as response:
|
||||||
|
result = json.loads(response.read().decode('utf-8'))
|
||||||
|
print(f"Release created successfully. ID: {result['id']}")
|
||||||
|
return result['id']
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
print(f"HTTP Error creating release: {e.code} {e.reason}")
|
||||||
|
print(e.read().decode('utf-8'))
|
||||||
|
sys.exit(1)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error creating release: {e}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
def upload_asset(release_id):
|
||||||
|
if not os.path.exists(APK_FILE):
|
||||||
|
print(f"Error: APK file {APK_FILE} not found.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
url = f"{GITEA_URL}/repos/{REPO_OWNER}/{REPO_NAME}/releases/{release_id}/assets"
|
||||||
|
|
||||||
|
# Simple multipart upload via python is tricky without requests library.
|
||||||
|
# However, Gitea API usually accepts raw binary in body if Content-Type is set,
|
||||||
|
# but Gitea's API for assets usually requires multipart/form-data.
|
||||||
|
# Let's check Gitea API docs...
|
||||||
|
# The standard Gitea API uses POST /repos/{owner}/{repo}/releases/{id}/assets with name query parameter and file content in body
|
||||||
|
# Wait, looking at Gitea API docs (swagger usually available at /api/swagger),
|
||||||
|
# POST /repos/{owner}/{repo}/releases/{id}/assets takes 'attachment' as form-data.
|
||||||
|
|
||||||
|
# Implementing multipart/form-data with urllib is painful.
|
||||||
|
# Instead, I will use curl to upload the asset, using the release ID obtained from Python.
|
||||||
|
return release_id
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
release_id = create_release()
|
||||||
|
print(f"RELEASE_ID={release_id}")
|
||||||
171
event-repository-fix.patch
Normal file
171
event-repository-fix.patch
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
diff --git a/app/src/main/java/com/streamplayer/EventRepository.java b/app/src/main/java/com/streamplayer/EventRepository.java
|
||||||
|
index f9340c7..7b3f662 100644
|
||||||
|
--- a/app/src/main/java/com/streamplayer/EventRepository.java
|
||||||
|
+++ b/app/src/main/java/com/streamplayer/EventRepository.java
|
||||||
|
@@ -29,8 +29,17 @@ public class EventRepository {
|
||||||
|
private static final String PREFS_NAME = "events_cache";
|
||||||
|
private static final String KEY_JSON = "json";
|
||||||
|
private static final String KEY_TIMESTAMP = "timestamp";
|
||||||
|
+ private static final String KEY_WORKING_URL = "working_url";
|
||||||
|
private static final long CACHE_DURATION = 24L * 60 * 60 * 1000; // 24 horas
|
||||||
|
- private static final String EVENTS_URL = "https://streamtpcloud.com/eventos.json";
|
||||||
|
+
|
||||||
|
+ // Lista de URLs a intentar en orden (con sistema de fallback)
|
||||||
|
+ private static final String[] EVENT_URLS = {
|
||||||
|
+ "https://streamtpcloud.com/eventos.json", // URL original
|
||||||
|
+ "https://streamtp10.com/eventos.json", // URL actual
|
||||||
|
+ "https://streamtpmedia.com/eventos.json" // URL anterior
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ private static final String DEFAULT_EVENTS_URL = "https://streamtpcloud.com/eventos.json";
|
||||||
|
|
||||||
|
public interface Callback {
|
||||||
|
void onSuccess(List<EventItem> events);
|
||||||
|
@@ -55,7 +64,7 @@ public class EventRepository {
|
||||||
|
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
- String json = downloadJson();
|
||||||
|
+ String json = downloadJson(context);
|
||||||
|
List<EventItem> events = parseEvents(json);
|
||||||
|
prefs.edit().putString(KEY_JSON, json).putLong(KEY_TIMESTAMP, System.currentTimeMillis()).apply();
|
||||||
|
callback.onSuccess(events);
|
||||||
|
@@ -73,27 +82,103 @@ public class EventRepository {
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
- private String downloadJson() throws IOException {
|
||||||
|
- URL url = new URL(EVENTS_URL);
|
||||||
|
+ private String downloadJson(Context context) throws IOException {
|
||||||
|
+ SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
|
||||||
|
+ String savedWorkingUrl = prefs.getString(KEY_WORKING_URL, null);
|
||||||
|
+
|
||||||
|
+ // Construir lista de URLs a intentar
|
||||||
|
+ // Primero la URL que funcionó la última vez, luego el resto
|
||||||
|
+ List<String> urlsToTry = new ArrayList<>();
|
||||||
|
+ if (savedWorkingUrl != null && !savedWorkingUrl.isEmpty()) {
|
||||||
|
+ urlsToTry.add(savedWorkingUrl);
|
||||||
|
+ }
|
||||||
|
+ for (String url : EVENT_URLS) {
|
||||||
|
+ if (!urlsToTry.contains(url)) {
|
||||||
|
+ urlsToTry.add(url);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ IOException lastException = null;
|
||||||
|
+
|
||||||
|
+ // Intentar cada URL en orden
|
||||||
|
+ for (String urlString : urlsToTry) {
|
||||||
|
+ try {
|
||||||
|
+ String json = downloadFromUrl(urlString);
|
||||||
|
+ // Guardar la URL que funcionó
|
||||||
|
+ prefs.edit().putString(KEY_WORKING_URL, urlString).apply();
|
||||||
|
+ return json;
|
||||||
|
+ } catch (IOException e) {
|
||||||
|
+ lastException = e;
|
||||||
|
+ // Continuar con la siguiente URL
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // Si todas fallaron, lanzar la última excepción
|
||||||
|
+ throw new IOException("No se pudo conectar a ninguna de las URLs disponibles. Último error: " +
|
||||||
|
+ (lastException != null ? lastException.getMessage() : "Error desconocido"));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private String downloadFromUrl(String urlString) throws IOException {
|
||||||
|
+ URL url = new URL(urlString);
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
connection.setConnectTimeout(15000);
|
||||||
|
connection.setReadTimeout(15000);
|
||||||
|
connection.setRequestMethod("GET");
|
||||||
|
connection.setRequestProperty("Accept", "application/json");
|
||||||
|
connection.setRequestProperty("User-Agent", "StreamPlayer/1.0");
|
||||||
|
-
|
||||||
|
+
|
||||||
|
+ // Habilitar seguimiento de redirecciones automáticamente
|
||||||
|
+ connection.setInstanceFollowRedirects(true);
|
||||||
|
+
|
||||||
|
+ String currentUrl = urlString;
|
||||||
|
+ int redirectCount = 0;
|
||||||
|
+ final int MAX_REDIRECTS = 5;
|
||||||
|
+
|
||||||
|
try {
|
||||||
|
int responseCode = connection.getResponseCode();
|
||||||
|
+
|
||||||
|
+ // Seguir redirecciones manualmente si es necesario
|
||||||
|
+ while (isRedirect(responseCode) && redirectCount < MAX_REDIRECTS) {
|
||||||
|
+ redirectCount++;
|
||||||
|
+ String newUrl = connection.getHeaderField("Location");
|
||||||
|
+
|
||||||
|
+ if (newUrl == null) {
|
||||||
|
+ throw new IOException("Redirección sin cabecera Location");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // Manejar URLs relativas
|
||||||
|
+ if (newUrl.startsWith("/")) {
|
||||||
|
+ newUrl = url.getProtocol() + "://" + url.getHost() + newUrl;
|
||||||
|
+ } else if (!newUrl.startsWith("http")) {
|
||||||
|
+ newUrl = url.getProtocol() + "://" + url.getHost() +
|
||||||
|
+ (url.getPort() > 0 ? ":" + url.getPort() : "") + "/" + newUrl;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ currentUrl = newUrl;
|
||||||
|
+ url = new URL(currentUrl);
|
||||||
|
+ connection.disconnect();
|
||||||
|
+
|
||||||
|
+ connection = (HttpURLConnection) url.openConnection();
|
||||||
|
+ connection.setConnectTimeout(15000);
|
||||||
|
+ connection.setReadTimeout(15000);
|
||||||
|
+ connection.setRequestMethod("GET");
|
||||||
|
+ connection.setRequestProperty("Accept", "application/json");
|
||||||
|
+ connection.setRequestProperty("User-Agent", "StreamPlayer/1.0");
|
||||||
|
+ connection.setInstanceFollowRedirects(true);
|
||||||
|
+
|
||||||
|
+ responseCode = connection.getResponseCode();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||||
|
throw new IOException("Error HTTP " + responseCode + ": " + connection.getResponseMessage());
|
||||||
|
}
|
||||||
|
-
|
||||||
|
+
|
||||||
|
String contentType = connection.getContentType();
|
||||||
|
// Permitir json o text/plain (Raw de Gitea a veces es text/plain)
|
||||||
|
if (contentType != null && !contentType.contains("json") && !contentType.contains("text/plain")) {
|
||||||
|
throw new IOException("El servidor devolvió " + contentType + " en lugar de JSON. Verifica que la URL sea correcta.");
|
||||||
|
}
|
||||||
|
-
|
||||||
|
+
|
||||||
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
String line;
|
||||||
|
@@ -101,12 +186,12 @@ public class EventRepository {
|
||||||
|
builder.append(line);
|
||||||
|
}
|
||||||
|
String response = builder.toString();
|
||||||
|
-
|
||||||
|
+
|
||||||
|
// Validar que no sea HTML
|
||||||
|
if (response.trim().startsWith("<!") || response.trim().startsWith("<html")) {
|
||||||
|
throw new IOException("El servidor devolvió HTML en lugar de JSON. La URL del endpoint puede estar incorrecta o el servidor tiene problemas.");
|
||||||
|
}
|
||||||
|
-
|
||||||
|
+
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
@@ -114,6 +199,14 @@ public class EventRepository {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ private boolean isRedirect(int statusCode) {
|
||||||
|
+ return statusCode == HttpURLConnection.HTTP_MOVED_PERM ||
|
||||||
|
+ statusCode == HttpURLConnection.HTTP_MOVED_TEMP ||
|
||||||
|
+ statusCode == HttpURLConnection.HTTP_SEE_OTHER ||
|
||||||
|
+ statusCode == 307 || // Temporary Redirect
|
||||||
|
+ statusCode == 308; // Permanent Redirect
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
private List<EventItem> parseEvents(String json) throws JSONException {
|
||||||
|
if (json == null || json.trim().isEmpty()) {
|
||||||
|
throw new JSONException("La respuesta está vacía");
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"versionCode": 100300,
|
"versionCode": 100110,
|
||||||
"versionName": "10.0.3",
|
"versionName": "10.1.10",
|
||||||
"minSupportedVersionCode": 91000,
|
"minSupportedVersionCode": 0,
|
||||||
"forceUpdate": false,
|
"forceUpdate": false,
|
||||||
"downloadUrl": "https://gitea.cbcren.online/renato97/app/releases/download/v10.0.3/StreamPlayer-v10.0.3.apk",
|
"downloadUrl": "http://gitea.cbcren.online/renato97/app/releases/download/v10.1.10/StreamPlayer-v10.1.10-debug.apk",
|
||||||
"fileName": "StreamPlayer-v10.0.3.apk",
|
"fileName": "StreamPlayer-v10.1.10-debug.apk",
|
||||||
"sizeBytes": 0,
|
"sizeBytes": 9113609,
|
||||||
"notes": "StreamPlayer v10.0.3\n\nNovedades:\n- Fix: Evasión de bloqueos regionales mediante DNS de Google (DoH)\n- Corrección de error 'No se encontró la clave del stream'"
|
"notes": "Cambiar a HTTP para evitar errores de certificado"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user