[+] UI
This commit is contained in:
@@ -6,7 +6,7 @@ android {
|
||||
namespace 'com.acgist.client.boot'
|
||||
compileSdk 32
|
||||
defaultConfig {
|
||||
minSdk 31
|
||||
minSdk 30
|
||||
targetSdk 32
|
||||
versionCode 100
|
||||
versionName "1.0.0"
|
||||
|
||||
@@ -6,7 +6,7 @@ android {
|
||||
namespace 'com.acgist.taoyao.client'
|
||||
compileSdk 32
|
||||
defaultConfig {
|
||||
minSdk 31
|
||||
minSdk 30
|
||||
targetSdk 32
|
||||
versionCode 100
|
||||
versionName "1.0.0"
|
||||
@@ -31,9 +31,9 @@ android {
|
||||
dependencies {
|
||||
implementation project(path: ':boot')
|
||||
implementation project(path: ':media')
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
implementation 'androidx.appcompat:appcompat:1.5.1'
|
||||
implementation 'com.google.android.material:material:1.8.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
||||
implementation 'org.apache.commons:commons-collections4:4.4'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.2'
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/title_activity_main">
|
||||
android:label="@string/title_activity_main"
|
||||
android:theme="@style/Theme.Taoyao">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
@@ -25,7 +26,8 @@
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_settings" />
|
||||
android:label="@string/title_activity_settings"
|
||||
android:theme="@style/Theme.Taoyao" />
|
||||
|
||||
<service
|
||||
android:name=".MediaService"
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
package com.acgist.taoyao.client;
|
||||
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
|
||||
/**
|
||||
* 开机启动
|
||||
@@ -13,11 +19,23 @@ public class BootReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
|
||||
final Intent mainActivity = new Intent(context, MainActivity.class);
|
||||
mainActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(mainActivity);
|
||||
final Resources resources = context.getResources();
|
||||
if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
|
||||
if(resources.getBoolean(R.bool.preview)) {
|
||||
this.launchPreview(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉起预览
|
||||
*
|
||||
* @param context 上下文
|
||||
*/
|
||||
private void launchPreview(Context context) {
|
||||
final Intent mainActivity = new Intent(context, MainActivity.class);
|
||||
mainActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startForegroundService(mainActivity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package com.acgist.taoyao.client;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.TextView;
|
||||
import android.os.Process;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.acgist.taoyao.client.databinding.ActivityMainBinding;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
/**
|
||||
* 预览界面
|
||||
@@ -20,19 +23,53 @@ public class MainActivity extends AppCompatActivity {
|
||||
private ActivityMainBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// 媒体服务
|
||||
final Intent mediaService = new Intent(this, MediaService.class);
|
||||
this.startService(mediaService);
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
// 启动点亮屏幕
|
||||
this.setTurnScreenOn(true);
|
||||
// 锁屏显示屏幕
|
||||
this.setShowWhenLocked(true);
|
||||
// 设置屏幕常亮
|
||||
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
// 拉起媒体服务
|
||||
this.launchMediaService();
|
||||
// 布局
|
||||
this.binding = ActivityMainBinding.inflate(this.getLayoutInflater());
|
||||
this.setContentView(this.binding.getRoot());
|
||||
// 设置按钮
|
||||
this.binding.settings.setOnClickListener(view -> {
|
||||
final Intent settings = new Intent(this, SettingsActivity.class);
|
||||
this.startService(settings);
|
||||
this.startActivity(settings);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉起媒体服务
|
||||
*/
|
||||
private void launchMediaService() {
|
||||
int times = 0;
|
||||
final Display display = this.getWindow().getContext().getDisplay();
|
||||
while(Display.STATE_ON != display.getState() && times++ < 10) {
|
||||
SystemClock.sleep(100);
|
||||
}
|
||||
if(display.STATE_ON == display.getState()) {
|
||||
// 媒体服务
|
||||
Log.i(MainActivity.class.getSimpleName(), "拉起媒体服务");
|
||||
final Intent mediaService = new Intent(this, MediaService.class);
|
||||
this.startService(mediaService);
|
||||
} else {
|
||||
Log.w(MainActivity.class.getSimpleName(), "拉起媒体服务失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.acgist.taoyao.client;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import com.acgist.taoyao.client.signal.Taoyao;
|
||||
|
||||
@@ -20,6 +21,12 @@ public class MediaService extends Service {
|
||||
public MediaService() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Log.d(MediaService.class.getSimpleName(), "启动媒体服务");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.acgist.taoyao.client;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.acgist.taoyao.client.databinding.ActivitySettingsBinding;
|
||||
import com.acgist.taoyao.client.signal.Taoyao;
|
||||
|
||||
/**
|
||||
* 设置界面
|
||||
@@ -26,12 +25,15 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
this.setContentView(this.binding.getRoot());
|
||||
// 设置按钮
|
||||
this.binding.connect.setOnClickListener(view -> {
|
||||
final String port = this.binding.port.getText().toString();
|
||||
final String name = this.binding.name.getText().toString();
|
||||
final String host = this.binding.host.getText().toString();
|
||||
// final Taoyao taoyao = new Taoyao(
|
||||
//
|
||||
// );
|
||||
// Log.d(SettingsActivity.class.getSimpleName(), "连接信令:" + taoyao);
|
||||
final Intent main = new Intent(this, MainActivity.class);
|
||||
this.startService(main);
|
||||
this.startActivity(main);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -11,13 +11,14 @@
|
||||
android:id="@+id/settings"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:contentDescription="@string/button_setting"
|
||||
android:src="@drawable/settings"
|
||||
app:borderWidth="16dp"
|
||||
app:fabSize="normal"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -4,7 +4,8 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/settings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.acgist.taoyao.client.SettingsActivity">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/port"
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
</resources>
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- 是否开启预览:关闭预览不会播放视频 -->
|
||||
<bool name="preview">true</bool>
|
||||
<string name="version">1.0.0</string>
|
||||
<integer name="timeout">5000</integer>
|
||||
<string name="clientType">MOBILE</string>
|
||||
<string name="algo">DES</string>
|
||||
<string name="secret">DES</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<style name="Theme.Taoyao" parent="Theme.MaterialComponents.Light.DarkActionBar">
|
||||
<item name="colorPrimary">@color/purple_500</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -9,7 +9,7 @@ android {
|
||||
namespace 'com.acgist.mediasoup'
|
||||
compileSdk 32
|
||||
defaultConfig {
|
||||
minSdk 31
|
||||
minSdk 30
|
||||
targetSdk 32
|
||||
versionCode 100
|
||||
versionName "1.0.0"
|
||||
|
||||
Reference in New Issue
Block a user