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)
64
.gitignore
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
*.iml
|
||||
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
# default output directories
|
||||
classes/
|
||||
deploy/
|
||||
javadoc/
|
||||
|
||||
##### Gradle
|
||||
.gradle
|
||||
**/build/
|
||||
!src/**/build/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Log/OS Files
|
||||
*.log
|
||||
|
||||
# Android Studio generated files and folders
|
||||
captures/
|
||||
.externalNativeBuild/
|
||||
.cxx/
|
||||
*.apk
|
||||
output.json
|
||||
|
||||
# IntelliJ
|
||||
*.iml
|
||||
.idea/
|
||||
misc.xml
|
||||
deploymentTargetDropDown.xml
|
||||
render.experimental.xml
|
||||
|
||||
# Keystore files
|
||||
*.jks
|
||||
*.keystore
|
||||
|
||||
# Google Services (e.g. APIs or Firebase)
|
||||
google-services.json
|
||||
|
||||
# Android Profiling
|
||||
*.hprof
|
||||
|
||||
### Android Patch ###
|
||||
gen-external-apklibs
|
||||
3
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
6
.idea/AndroidProjectSystem.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AndroidProjectSystem">
|
||||
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/compiler.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="21" />
|
||||
</component>
|
||||
</project>
|
||||
18
.idea/deploymentTargetSelector.xml
generated
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetSelector">
|
||||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2025-06-07T18:14:14.104258546Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=M7GEJFYHBA554L7T" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
<DialogSelection />
|
||||
</SelectionState>
|
||||
</selectionStates>
|
||||
</component>
|
||||
</project>
|
||||
19
.idea/gradle.xml
generated
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
10
.idea/migrations.xml
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectMigrations">
|
||||
<option name="MigrateToGradleLocalJavaHome">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
10
.idea/misc.xml
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
||||
17
.idea/runConfigurations.xml
generated
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
|
||||
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
|
||||
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
1
app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build
|
||||
49
app/build.gradle.kts
Normal 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
app/proguard-rules.pro
vendored
Normal 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
app/src/main/AndroidManifest.xml
Normal 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>
|
||||
BIN
app/src/main/ic_launcher-playstore.png
Normal file
|
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
133
app/src/main/java/com/gitea/kashamannaya/lilula/MjpegServer.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
30
app/src/main/res/drawable-v24/ic_launcher_foreground.xml
Normal file
@ -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>
|
||||
170
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@ -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
app/src/main/res/layout/activity_main.xml
Normal 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>
|
||||
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
@ -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>
|
||||
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
@ -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>
|
||||
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 7.1 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 21 KiB |
12
app/src/main/res/values-en/strings.xml
Normal 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
app/src/main/res/values-night/themes.xml
Normal 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>
|
||||
12
app/src/main/res/values-ru-rRU/strings.xml
Normal file
@ -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
app/src/main/res/values/colors.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
||||
4
app/src/main/res/values/ic_launcher_background.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#FFFFFF</color>
|
||||
</resources>
|
||||
14
app/src/main/res/values/strings.xml
Normal 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
app/src/main/res/values/themes.xml
Normal 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
app/src/main/res/xml/backup_rules.xml
Normal 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>
|
||||
19
app/src/main/res/xml/data_extraction_rules.xml
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
4
build.gradle.kts
Normal file
@ -0,0 +1,4 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
}
|
||||
21
gradle.properties
Normal file
@ -0,0 +1,21 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. For more details, visit
|
||||
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
34
gradle/libs.versions.toml
Normal file
@ -0,0 +1,34 @@
|
||||
[versions]
|
||||
activityVersion = "1.9.0"
|
||||
agp = "8.10.0"
|
||||
androidasync = "3.1.0"
|
||||
appcompatVersion = "1.6.1"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.2.1"
|
||||
espressoCore = "3.6.1"
|
||||
appcompat = "1.7.1"
|
||||
material = "1.12.0"
|
||||
activity = "1.10.1"
|
||||
constraintlayout = "2.2.1"
|
||||
multidex = "2.0.1"
|
||||
rxandroid = "2.1.1"
|
||||
rxjava = "2.2.21"
|
||||
|
||||
[libraries]
|
||||
activity-v190 = { module = "androidx.activity:activity", version.ref = "activityVersion" }
|
||||
androidasync = { module = "com.koushikdutta.async:androidasync", version.ref = "androidasync" }
|
||||
appcompat-v161 = { module = "androidx.appcompat:appcompat", version.ref = "appcompatVersion" }
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
|
||||
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
||||
activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
|
||||
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
|
||||
multidex = { module = "androidx.multidex:multidex", version.ref = "multidex" }
|
||||
rxandroid = { module = "io.reactivex.rxjava2:rxandroid", version.ref = "rxandroid" }
|
||||
rxjava = { module = "io.reactivex.rxjava2:rxjava", version.ref = "rxjava" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
#Sat Jun 07 01:17:32 MSK 2025
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
185
gradlew
vendored
Executable file
@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
89
gradlew.bat
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
24
settings.gradle.kts
Normal file
@ -0,0 +1,24 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
google {
|
||||
content {
|
||||
includeGroupByRegex("com\\.android.*")
|
||||
includeGroupByRegex("com\\.google.*")
|
||||
includeGroupByRegex("androidx.*")
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "Lilula"
|
||||
include(":app")
|
||||
|
||||