Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

activity embedding (android 12L) #179

Open
wants to merge 1 commit into
base: sc
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions vector-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
android:theme="@style/AppTheme.SC.Light"
tools:ignore="UnusedAttribute"
tools:replace="android:allowBackup">
<property
android:name="android.window.PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED"
android:value="true" />

<!-- Activity alias for the launcher Activity (must be declared after the Activity it targets) -->
<!-- exported="true" is required to launch application -->
Expand Down Expand Up @@ -53,6 +56,9 @@
<meta-data
android:name="androidx.emoji2.text.EmojiCompatInitializer"
tools:node="remove" />
<meta-data
android:name="im.vector.app.features.ui.SplitInitializer"
android:value="androidx.startup" />
</provider>

<provider
Expand Down
2 changes: 2 additions & 0 deletions vector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ dependencies {
implementation libs.androidx.autoFill
implementation 'jp.wasabeef:glide-transformations:4.3.0'
implementation 'com.github.hyuwah:DraggableView:1.0.0'
implementation 'androidx.window:window:1.1.0-alpha04'
implementation 'androidx.startup:startup-runtime:1.1.1'

// Custom Tab
implementation 'androidx.browser:browser:1.4.0'
Expand Down
4 changes: 4 additions & 0 deletions vector/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@

<application android:supportsRtl="true">

<activity
android:name=".features.home.PlaceholderActivity"
android:exported="false" />

<!-- Sentry auto-initialization disable -->
<meta-data
android:name="io.sentry.auto-init"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* 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
*
* http://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.
*/

package im.vector.app.features.home

import android.annotation.SuppressLint
import android.graphics.Color
import android.os.Bundle
import androidx.core.view.WindowCompat
import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.R
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivityPlaceholderBinding
@AndroidEntryPoint
class PlaceholderActivity :
VectorBaseActivity<ActivityPlaceholderBinding>(){
override fun getBinding() = ActivityPlaceholderBinding.inflate(layoutInflater)
@SuppressLint("ResourceAsColor")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
window.statusBarColor = Color.TRANSPARENT
setContentView(R.layout.activity_placeholder)
}
}
33 changes: 33 additions & 0 deletions vector/src/main/java/im/vector/app/features/ui/SplitInitializer.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* 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
*
* http://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.
*/

package im.vector.app.features.ui

import android.content.Context
import androidx.startup.Initializer
import androidx.window.embedding.SplitController
import im.vector.app.R
class SplitInitializer : Initializer<SplitController> {

override fun create(context: Context): SplitController {
SplitController.initialize(context, R.xml.split_configuration)
return SplitController.getInstance()
}

override fun dependencies(): List<Class<out Initializer<*>>> {
return emptyList()
}
}
9 changes: 9 additions & 0 deletions vector/src/main/res/layout/activity_placeholder.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/placeholder">
</androidx.constraintlayout.widget.ConstraintLayout>
34 changes: 34 additions & 0 deletions vector/src/main/res/xml/split_configuration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<resources
xmlns:window="http://schemas.android.com/apk/res-auto">

<!-- Define a split for the named activity pair. -->
<SplitPairRule
window:splitRatio="0.4"
window:splitMinWidth="600dp"
window:finishPrimaryWithSecondary="never"
window:finishSecondaryWithPrimary="always">
<SplitPairFilter
window:primaryActivityName="im.vector.app.features.home.HomeActivity"
window:secondaryActivityName="im.vector.app.features.home.room.detail.RoomDetailActivity"/>
</SplitPairRule>


<!-- Automatically launch a placeholder for the list activity. -->
<SplitPlaceholderRule
window:placeholderActivityName="im.vector.app.features.home.PlaceholderActivity"
window:splitRatio="0.4"
window:splitMinWidth="600dp">
<ActivityFilter
window:activityName="im.vector.app.features.home.HomeActivity"/>
</SplitPlaceholderRule>

<!-- Define activities that should never enter a split. Note: Takes
precedence over other split rules. -->
<ActivityRule
window:alwaysExpand="true">
<ActivityFilter window:activityName="im.vector.app.features.media.VectorAttachmentViewerActivity"/>
<ActivityFilter window:activityName="im.vector.app.features.media.BigImageViewerActivity"/>

</ActivityRule>

</resources>