Initial commit for the Lilula app - MVP stage:

At this stage:
- The program launches the rear camera of the smartphone (if 1 camera is available, it uses it).
- Allows you to take a photo and save it on the phone: Pictures/Lilula
- Allows you to broadcast video on the local network to the IP address of the smartphone in Mjpeg format, which can be viewed by any client: browser, VLC, etc. The broadcast address is shown on the screen.

API level 19+ (Android 4.4.+)
Tested on devices Android 4.4.2, Android 13 (Color OS), Android 14 (LineagoOS)
This commit is contained in:
kashamannaya committed 2025-06-08 02:48:00 +03:00
commit f6419500da
57 files changed
+1741

No files matched your search

+1
View File
@@ -0,0 +1 @@
/build
+49
View File
@@ -0,0 +1,49 @@
plugins {
alias(libs.plugins.android.application)
}
android {
namespace = "com.gitea.kashamannaya.lilula"
compileSdk = 35
defaultConfig {
applicationId = "com.gitea.kashamannaya.lilula"
minSdk = 19
targetSdk = 35
versionCode = 1
versionName = "1.0"
multiDexEnabled =true
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
dependencies {
// https://mvnrepository.com/artifact/androidx.appcompat/appcompat
runtimeOnly(libs.appcompat.v161)
implementation(libs.material)
// https://mvnrepository.com/artifact/androidx.activity/activity
runtimeOnly(libs.activity.v190)
implementation (libs.multidex)
implementation(libs.rxandroid)
implementation(libs.rxjava)
implementation (libs.androidasync)
testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
}
+21
View File
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
@@ -0,0 +1,26 @@
package com.gitea.kashamannaya.lilula;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.gitea.kashamannaya.lilula", appContext.getPackageName());
}
}
+42
View File
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.NEARBY_WIFI_DEVICES" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
<application
android:allowBackup="true"
android:usesCleartextTraffic="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Lilula"
tools:targetApi="31"
tools:ignore="GoogleAppIndexingWarning"
>
<activity
android:name=".MainActivity"
android:exported="true"
android:configChanges="orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Binary file not shown.

After

Width:  |  Height:  |  Size: 211 KiB

@@ -0,0 +1,537 @@
package com.gitea.kashamannaya.lilula;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.ImageFormat;
import android.graphics.Rect;
import android.graphics.YuvImage;
import android.hardware.Camera;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
public class MainActivity extends AppCompatActivity implements SurfaceHolder.Callback {
private static final int CAMERA_REQUEST_CODE = 100;
private static final String KEY_CAMERA_ID = "camera_id";
private static final String KEY_PREVIEW_STATE = "preview_state";
private Camera camera;
private SurfaceView surfaceView;
private SurfaceHolder surfaceHolder;
private Button captureButton;
private Button toggleButton;
private boolean isPreviewRunning = false;
private boolean isSurfaceReady = false;
private int cameraId = -1;
private TextView uRLServerLabel;
private MjpegServer mjpegServer;
private static final int STREAM_PORT = 8080;
private boolean isStreaming = false;
private Disposable frameDisposable;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
keepScreenOn();
// ) инициализируем сервер
mjpegServer = new MjpegServer(STREAM_PORT);
// Восстановление cameraId при повороте
if (savedInstanceState != null) {
cameraId = savedInstanceState.getInt(KEY_CAMERA_ID, -1);
isPreviewRunning = savedInstanceState.getBoolean(KEY_PREVIEW_STATE, false);
} else {
// Находим доступную камеру только при первом создании
cameraId = findAvailableCamera();
}
surfaceView = findViewById(R.id.surface_view);
captureButton = findViewById(R.id.capture_button);
toggleButton = findViewById(R.id.toggle_button);
uRLServerLabel = findViewById(R.id.url_server);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
// Проверка наличия камеры
if (cameraId < 0) {
Toast.makeText(this, getResources().getString(R.string.toast_text_error_camera_not_found), Toast.LENGTH_LONG).show();
finish();
return;
}
captureButton.setOnClickListener(v -> captureImage());
toggleButton.setOnClickListener(v -> togglePreview());
}
private void keepScreenOn() {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
private void updateToggleButtonText() {
runOnUiThread(() -> {
if (toggleButton != null) {
String text = isPreviewRunning ? getResources().getString(R.string.text_on_button_video_stream_stop) : getResources().getString(R.string.text_on_button_video_stream_start);
toggleButton.setText(text);
}
});
}
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(KEY_CAMERA_ID, cameraId);
outState.putBoolean(KEY_PREVIEW_STATE, isPreviewRunning);
}
private int findAvailableCamera() {
int numberOfCameras = Camera.getNumberOfCameras();
// Если камер нет вообще
if (numberOfCameras == 0) {
return -1;
}
// Если камера только одна - используем её
if (numberOfCameras == 1) {
return 0;
}
// Если камер несколько - ищем заднюю
int backCameraId = -1;
for (int i = 0; i < numberOfCameras; i++) {
Camera.CameraInfo info = new Camera.CameraInfo();
try {
Camera.getCameraInfo(i, info);
if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
return i; // Нашли заднюю камеру
}
// Запоминаем первую камеру на случай, если задней нет
if (backCameraId == -1) {
backCameraId = i;
}
} catch (RuntimeException e) {
// Log.e("Camera", "Ошибка получения информации о камере " + i, e);
}
}
// Если не нашли заднюю, но есть другие камеры - используем первую доступную
return backCameraId;
}
@Override
protected void onResume() {
super.onResume();
if (checkCameraPermission()) {
startCamera();
}
// Гарантированное обновление состояния кнопки
updateToggleButtonText();
}
@Override
protected void onPause() {
super.onPause();
stopStreaming();
stopCamera();
}
private boolean checkCameraPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.CAMERA},
CAMERA_REQUEST_CODE);
return false;
}
}
return true;
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == CAMERA_REQUEST_CODE) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
startCamera();
} else {
Toast.makeText(this, getResources().getString(R.string.toast_text_error_camera_not_permitted), Toast.LENGTH_SHORT).show();
}
}
}
private void startCamera() {
if (isSurfaceReady && !isPreviewRunning) {
safeCameraOpen();
}
}
private void stopCamera() {
if (camera != null) {
try {
camera.stopPreview();
camera.release();
} catch (Exception e) {
// Log.e("Camera", "Ошибка остановки камеры: " + e.getMessage());
}
isPreviewRunning = false;
}
updateToggleButtonText();
}
private void togglePreview() {
if (isPreviewRunning) {
stopPreview();
toggleButton.setText(R.string.text_on_button_video_stream_start);
} else {
startPreview();
toggleButton.setText(R.string.text_on_button_video_stream_stop);
}
}
private void startPreview() {
if (camera == null) {
safeCameraOpen();
}
if (camera != null) {
try {
camera.setPreviewDisplay(surfaceHolder);
camera.startPreview();
isPreviewRunning = true;
updateToggleButtonText();
// Запускаем трансляцию
startStreaming();
} catch (IOException e) {
// Log.e("Camera", "Ошибка запуска предпросмотра: " + e.getMessage());
}
}
}
private void stopPreview() {
if (camera != null) {
try {
camera.stopPreview();
} catch (Exception e) {
// Log.e("Camera", "Ошибка остановки камеры: " + e.getMessage());
}
isPreviewRunning = false;
updateToggleButtonText();
// Останавливаем трансляцию
stopStreaming();
}
}
// Добавим методы для управления трансляцией
@SuppressLint("LongLogTag")
private void startStreaming() {
if (isStreaming) return;
// Проверяем подключение к Wi-Fi
if (!NetworkUtils.isWifiConnected(this)) {
Toast.makeText(this, getResources().getString(R.string.toast_text_error_wifi_not_available), Toast.LENGTH_LONG).show();
return;
}
mjpegServer.start();
isStreaming = true;
// Получаем и отображаем адрес трансляции
String streamUrl = mjpegServer.getStreamUrl();
String text = getResources().getString(R.string.toast_text_video_stream_start);
Toast.makeText(this, text + "\n" + streamUrl, Toast.LENGTH_LONG).show();
runOnUiThread(() -> uRLServerLabel.setText(streamUrl));
// Начинаем захват кадров для трансляции
startFrameCapture();
// Log.i("startStreaming: >>>>>>>>>>>>>>", "Трансляция запущена: " + streamUrl);
}
private void stopStreaming() {
if (!isStreaming) return;
if (frameDisposable != null && !frameDisposable.isDisposed()) {
frameDisposable.dispose();
}
mjpegServer.stop();
isStreaming = false;
Toast.makeText(this, getResources().getString(R.string.toast_text_video_stream_stop), Toast.LENGTH_SHORT).show();
}
private void startFrameCapture() {
if (frameDisposable != null && !frameDisposable.isDisposed()) {
frameDisposable.dispose();
}
// Используем RxJava для захвата кадров в фоновом потоке
frameDisposable = Observable.interval(100, TimeUnit.MILLISECONDS) // 10 FPS
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe(tick -> captureFrameForStreaming());
}
private void captureFrameForStreaming() {
if (camera == null || !isStreaming) return;
camera.setOneShotPreviewCallback((data, camera) -> {
Camera.Size size = camera.getParameters().getPreviewSize();
YuvImage yuvImage = new YuvImage(data, ImageFormat.NV21, size.width, size.height, null);
ByteArrayOutputStream out = new ByteArrayOutputStream(30 * 1024);
yuvImage.compressToJpeg(new Rect(0, 0, size.width, size.height), 60, out);
byte[] jpegBytes = out.toByteArray();
if (mjpegServer.isRunning()) {
mjpegServer.sendFrame(jpegBytes);
}
});
}
private void safeCameraOpen() {
try {
camera = Camera.open(cameraId);
setupCameraParameters();
if (isSurfaceReady) {
startPreview();
}
} catch (Exception e) {
// Log.e("Camera", "Не удалось открыть камеру: " + e.getMessage());
// Повторная попытка через 500 мс
new Handler().postDelayed(() -> {
try {
camera = Camera.open(cameraId);
setupCameraParameters();
if (isSurfaceReady) {
startPreview();
}
} catch (Exception ex) {
// Log.e("Camera", "Повторная ошибка открытия камеры: " + ex.getMessage());
}
}, 500);
}
}
private void setCameraDisplayOrientation() {
if (camera == null) return;
int rotation = getWindowManager().getDefaultDisplay().getRotation();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0:
degrees = 0;
break;
case Surface.ROTATION_90:
degrees = 90;
break;
case Surface.ROTATION_180:
degrees = 180;
break;
case Surface.ROTATION_270:
degrees = 270;
break;
}
int result;
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(cameraId, info);
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
result = (info.orientation + degrees) % 360;
result = (360 - result) % 360;
} else {
result = (info.orientation - degrees + 360) % 360;
}
camera.setDisplayOrientation(result);
}
private void setupCameraParameters() {
if (camera == null) return;
try {
Camera.Parameters params = camera.getParameters();
// Установка ориентации
setCameraDisplayOrientation();
// Получение поддерживаемых размеров
List<Camera.Size> sizes = params.getSupportedPreviewSizes();
Camera.Size optimalSize = getOptimalPreviewSize(sizes, surfaceView.getWidth(), surfaceView.getHeight());
if (optimalSize != null) {
params.setPreviewSize(optimalSize.width, optimalSize.height);
}
// Настройка FPS
List<int[]> fpsRanges = params.getSupportedPreviewFpsRange();
if (fpsRanges != null && !fpsRanges.isEmpty()) {
int[] maxFps = fpsRanges.get(0);
for (int[] range : fpsRanges) {
if (range[1] > maxFps[1]) maxFps = range;
}
params.setPreviewFpsRange(maxFps[0], maxFps[1]);
}
// Автофокус
if (params.getSupportedFocusModes() != null &&
params.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
camera.setParameters(params);
} catch (Exception e) {
// Log.e("Camera", "Ошибка настройки параметров: " + e.getMessage());
}
}
private Camera.Size getOptimalPreviewSize(List<Camera.Size> sizes, int w, int h) {
final double ASPECT_TOLERANCE = 0.1;
double targetRatio = (double) w / h;
if (sizes == null) return null;
Camera.Size optimalSize = null;
double minDiff = Double.MAX_VALUE;
for (Camera.Size size : sizes) {
double ratio = (double) size.width / size.height;
if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue;
if (Math.abs(size.height - h) < minDiff) {
optimalSize = size;
minDiff = Math.abs(size.height - h);
}
}
if (optimalSize == null) {
for (Camera.Size size : sizes) {
if (Math.abs(size.height - h) < minDiff) {
optimalSize = size;
minDiff = Math.abs(size.height - h);
}
}
}
return optimalSize;
}
private void captureImage() {
if (camera == null) return;
camera.takePicture(null, null, (data, camera) -> {
saveImage(data);
if (isPreviewRunning) {
camera.startPreview();
}
});
}
private void saveImage(byte[] data) {
File pictureFileDir = new File(
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
getResources().getString(R.string.app_name)
);
if (!pictureFileDir.exists() && !pictureFileDir.mkdirs()) {
// Log.e("Camera", "Не удалось создать директорию");
return;
}
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String fileName = pictureFileDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg";
try (FileOutputStream fos = new FileOutputStream(fileName)) {
fos.write(data);
Toast.makeText(this, getResources().getString(R.string.toast_text_snapshot_saved) + fileName, Toast.LENGTH_SHORT).show();
} catch (Exception e) {
// Log.e("Camera", "Ошибка сохранения фото: " + e.getMessage());
}
}
@Override
public void surfaceCreated(@NonNull SurfaceHolder holder) {
isSurfaceReady = true;
startCamera();
updateToggleButtonText();
}
@Override
public void surfaceChanged(@NonNull SurfaceHolder holder, int format, int width, int height) {
if (camera != null && isPreviewRunning) {
try {
camera.stopPreview();
setupCameraParameters();
camera.setPreviewDisplay(holder);
camera.startPreview();
} catch (IOException e) {
// Log.e("Camera", "Ошибка изменения Surface: " + e.getMessage());
}
}
}
@Override
public void surfaceDestroyed(@NonNull SurfaceHolder holder) {
isSurfaceReady = false;
stopCamera();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Перезапускаем превью при изменении конфигурации
if (camera != null && isPreviewRunning) {
new Handler().postDelayed(() -> {
if (surfaceHolder.getSurface().isValid()) {
try {
camera.stopPreview();
setupCameraParameters();
camera.setPreviewDisplay(surfaceHolder);
camera.startPreview();
} catch (Exception e) {
// Log.e("Camera", "Ошибка при повороте: " + e.getMessage());
}
}
}, 300);
}
}
}
@@ -0,0 +1,133 @@
package com.gitea.kashamannaya.lilula;
import com.koushikdutta.async.AsyncServer;
import com.koushikdutta.async.ByteBufferList;
import com.koushikdutta.async.callback.CompletedCallback;
import com.koushikdutta.async.http.server.AsyncHttpServer;
import com.koushikdutta.async.http.server.AsyncHttpServerRequest;
import com.koushikdutta.async.http.server.AsyncHttpServerResponse;
import com.koushikdutta.async.http.server.HttpServerRequestCallback;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.ConcurrentLinkedQueue;
public class MjpegServer {
private static final int MAX_CLIENTS = 5;
private static final String BOUNDARY = "ThisIsTheBoundary";
private final AsyncHttpServer server = new AsyncHttpServer();
private final ConcurrentLinkedQueue<AsyncHttpServerResponse> clients = new ConcurrentLinkedQueue<>();
private boolean isRunning = false;
private final int port;
public MjpegServer(int port) {
this.port = port;
}
public void start() {
if (isRunning) return;
server.get("/stream", new HttpServerRequestCallback() {
@Override
public void onRequest(AsyncHttpServerRequest request, AsyncHttpServerResponse response) {
// Устанавливаем правильные заголовки
response.getHeaders().set("Connection", "close");
response.getHeaders().set("Cache-Control", "no-cache, private");
response.getHeaders().set("Content-Type",
"multipart/x-mixed-replace; boundary=" + BOUNDARY);
// Ограничение количества клиентов
if (clients.size() >= MAX_CLIENTS) {
response.code(503).end(); // Service Unavailable
return;
}
// Добавляем клиента в список
clients.add(response);
// Отправляем начальный заголовок
String initialHeader = "--" + BOUNDARY + "\r\n";
response.write(new ByteBufferList(ByteBuffer.wrap(initialHeader.getBytes(StandardCharsets.UTF_8))));
// Обработка закрытия соединения
response.setClosedCallback(new CompletedCallback() {
@Override
public void onCompleted(Exception ex) {
clients.remove(response);
}
});
}
});
server.listen(AsyncServer.getDefault(), port);
isRunning = true;
}
public void stop() {
if (!isRunning) return;
// Закрываем все соединения
for (AsyncHttpServerResponse client : clients) {
try {
client.end();
} catch (Exception e) {
// Игнорируем ошибки закрытия
}
}
clients.clear();
// Останавливаем сервер
server.stop();
AsyncServer.getDefault().stop();
isRunning = false;
}
public void sendFrame(byte[] jpegData) {
if (!isRunning || clients.isEmpty()) return;
try {
// Формируем полный фрейм
ByteArrayOutputStream frameStream = new ByteArrayOutputStream();
frameStream.write(("\r\n--" + BOUNDARY + "\r\n").getBytes());
frameStream.write("Content-Type: image/jpeg\r\n".getBytes());
frameStream.write(("Content-Length: " + jpegData.length + "\r\n\r\n").getBytes());
frameStream.write(jpegData);
frameStream.write("\r\n".getBytes());
byte[] frame = frameStream.toByteArray();
ByteBuffer buffer = ByteBuffer.wrap(frame);
ByteBufferList bufferList = new ByteBufferList(buffer);
// Отправляем всем активным клиентам
for (AsyncHttpServerResponse client : clients) {
if (!client.isOpen()) {
clients.remove(client);
continue;
}
try {
client.write(bufferList);
} catch (Exception e) {
// Удаляем клиента при ошибке
clients.remove(client);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
public String getStreamUrl() {
return "http://" + NetworkUtils.getLocalIpAddress() + ":" + port + "/stream";
}
public boolean isRunning() {
return isRunning;
}
}
@@ -0,0 +1,41 @@
package com.gitea.kashamannaya.lilula;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
public class NetworkUtils {
public static String getLocalIpAddress() {
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) {
return inetAddress.getHostAddress();
}
}
}
} catch (SocketException ex) {
Log.e("NetworkUtils", "Error getting IP address", ex);
}
return "0.0.0.0";
}
public static boolean isWifiConnected(Context context) {
ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connManager != null) {
NetworkInfo wifiInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
return wifiInfo != null && wifiInfo.isConnected();
}
return false;
}
}
@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
+47
View File
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<SurfaceView
android:id="@+id/surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/button_layout"/>
<LinearLayout
android:id="@+id/button_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:padding="16dp"
android:weightSum="2">
<Button
android:id="@+id/capture_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/text_on_button_catpure_image"
android:layout_marginEnd="8dp"/>
<Button
android:id="@+id/toggle_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:text="@string/text_on_button_video_stream_stop" />
</LinearLayout>
<TextView
android:id="@+id/url_server"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:text="@string/text_url_server" />
</RelativeLayout>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="text_on_button_video_stream_stop">Stop broadcasting</string>
<string name="text_on_button_catpure_image">Take snapshot</string>
<string name="text_on_button_video_stream_start">Start broadcasting</string>
<string name="toast_text_video_stream_start">Video broadcast started</string>
<string name="toast_text_video_stream_stop">Video broadcast stopped</string>
<string name="toast_text_error_camera_not_found">Camera not found!</string>
<string name="toast_text_error_camera_not_permitted">Permission is required to use the camera!</string>
<string name="toast_text_error_wifi_not_available">Wi-Fi connection required for broadcasting</string>
<string name="toast_text_snapshot_saved">"Snapshot saved: "</string>
</resources>
+7
View File
@@ -0,0 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Base.Theme.Lilula" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your dark theme here. -->
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
</style>
</resources>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="text_on_button_video_stream_stop">Остановить трансляцию</string>
<string name="text_on_button_catpure_image">Сделать снимок</string>
<string name="text_on_button_video_stream_start">Начать трансляцию</string>
<string name="toast_text_video_stream_start">Трансляция видео запущена</string>
<string name="toast_text_video_stream_stop">Трансляция видео остановлена</string>
<string name="toast_text_error_camera_not_found">Камера не найдена!</string>
<string name="toast_text_error_camera_not_permitted">Требуется разрешение для использования камеры!</string>
<string name="toast_text_error_wifi_not_available">Для трансляции требуется подключение к Wi-Fi!</string>
<string name="toast_text_snapshot_saved">"Снимок сохранен: "</string>
</resources>
+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>
+14
View File
@@ -0,0 +1,14 @@
<resources>
<string name="app_name" translatable="false">Lilula</string>
<string name="text_on_button_video_stream_stop">Stop broadcasting</string>
<string name="text_on_button_video_stream_start">Start broadcasting</string>
<string name="text_on_button_catpure_image">Take snapshot</string>
<string name="text_url_server" translatable="false">URL Server</string>
<string name="toast_text_video_stream_start">Video broadcast started</string>
<string name="toast_text_video_stream_stop">Video broadcast stopped</string>
<string name="toast_text_error_camera_not_found">Camera not found!</string>
<string name="toast_text_error_camera_not_permitted">Permission is required to use the camera!</string>
<string name="toast_text_error_wifi_not_available">Wi-Fi connection required for broadcasting</string>
<string name="toast_text_snapshot_saved">"Snapshot saved: "</string>
</resources>
+9
View File
@@ -0,0 +1,9 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Base.Theme.Lilula" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your light theme here. -->
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
</style>
<style name="Theme.Lilula" parent="Base.Theme.Lilula" />
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample backup rules file; uncomment and customize as necessary.
See https://developer.android.com/guide/topics/data/autobackup
for details.
Note: This file is ignored for devices older than API 31
See https://developer.android.com/about/versions/12/backup-restore
-->
<full-backup-content>
<!--
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="device.xml"/>
-->
</full-backup-content>
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample data extraction rules file; uncomment and customize as necessary.
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
for details.
-->
<data-extraction-rules>
<cloud-backup>
<!-- TODO: Use <include> and <exclude> to control what is backed up.
<include .../>
<exclude .../>
-->
</cloud-backup>
<!--
<device-transfer>
<include .../>
<exclude .../>
</device-transfer>
-->
</data-extraction-rules>
@@ -0,0 +1,17 @@
package com.gitea.kashamannaya.lilula;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}