添加分屏测试功能支持多窗口MainActivity

This commit is contained in:
2026-04-27 19:27:25 +08:00
parent d518ac50a9
commit b44fe3aaf3
7 changed files with 66 additions and 4 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Mon Apr 27 18:32:35 CST 2026 #Mon Apr 27 19:22:37 CST 2026
stageCount=20 stageCount=20
libraryProject=libappbase libraryProject=libappbase
baseVersion=15.15 baseVersion=15.15
publishVersion=15.15.19 publishVersion=15.15.19
buildCount=17 buildCount=26
baseBetaVersion=15.15.20 baseBetaVersion=15.15.20

View File

@@ -16,6 +16,17 @@
android:label="@string/app_name" android:label="@string/app_name"
android:exported="true" android:exported="true"
android:resizeableActivity="true" android:resizeableActivity="true"
android:launchMode="singleTop"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation">
</activity>
<activity
android:name=".MainActivityAlias"
android:label="@string/app_name"
android:exported="true"
android:resizeableActivity="true"
android:launchMode="singleTop"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"> android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation">
<intent-filter> <intent-filter>

View File

@@ -161,5 +161,25 @@ public class MainActivity extends Activity {
Intent aboutIntent = new Intent(getApplicationContext(), AboutActivity.class); Intent aboutIntent = new Intent(getApplicationContext(), AboutActivity.class);
startActivity(aboutIntent); startActivity(aboutIntent);
} }
public void onSplitScreenMode(View view) {
LogUtils.d(TAG, "onSplitScreenMode() 分屏测试按钮已点击");
ToastUtils.show("分屏测试:已启动新窗口");
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
android.graphics.Rect bounds = new android.graphics.Rect();
getWindow().getDecorView().getDisplay().getRectSize(bounds);
int height = bounds.height();
int width = bounds.width();
bounds.set(0, 0, width, height / 2);
LogUtils.d(TAG, "onSplitScreenMode() 分屏窗口范围: " + bounds);
android.content.Intent intent = new android.content.Intent(this, MainActivityAlias.class);
intent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
LogUtils.d(TAG, "onSplitScreenMode() 准备启动MainActivityAlias");
android.app.ActivityOptions options = android.app.ActivityOptions.makeBasic();
options.setLaunchBounds(bounds);
startActivity(intent, options.toBundle());
LogUtils.d(TAG, "onSplitScreenMode() MainActivityAlias已启动");
}
}
} }

View File

@@ -0,0 +1,17 @@
package cc.winboll.studio.appbase;
import android.os.Bundle;
import android.view.View;
import android.widget.Toolbar;
import cc.winboll.studio.appbase.R;
public class MainActivityAlias extends MainActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setActionBar(toolbar);
}
}

View File

@@ -83,6 +83,18 @@
android:onClick="onAboutActivity" android:onClick="onAboutActivity"
android:layout_margin="10dp"/> android:layout_margin="10dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="分屏测试"
android:textSize="16sp"
android:textColor="@android:color/white"
android:background="#81C7F5"
android:paddingVertical="12dp"
android:layout_marginHorizontal="24dp"
android:onClick="onSplitScreenMode"
android:layout_margin="10dp"/>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Mon Apr 27 18:32:35 CST 2026 #Mon Apr 27 19:22:37 CST 2026
stageCount=20 stageCount=20
libraryProject=libappbase libraryProject=libappbase
baseVersion=15.15 baseVersion=15.15
publishVersion=15.15.19 publishVersion=15.15.19
buildCount=17 buildCount=26
baseBetaVersion=15.15.20 baseBetaVersion=15.15.20

View File

@@ -59,6 +59,7 @@ public class LogActivity extends Activity {
*/ */
public static void startLogActivity(Context context, boolean newTask) { public static void startLogActivity(Context context, boolean newTask) {
Intent intent = new Intent(context, LogActivity.class); Intent intent = new Intent(context, LogActivity.class);
intent.setFlags(0);
if (newTask) { if (newTask) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -70,6 +71,7 @@ public class LogActivity extends Activity {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
Rect bounds = new Rect(); Rect bounds = new Rect();
if (context instanceof Activity) { if (context instanceof Activity) {
Activity activity = (Activity) context; Activity activity = (Activity) context;