Skip to content

Commit

Permalink
split
Browse files Browse the repository at this point in the history
  • Loading branch information
Sinofine committed Feb 25, 2023
1 parent 828ab89 commit 1a2c172
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 0 deletions.
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>
37 changes: 37 additions & 0 deletions vector/src/main/res/xml/split_configuration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<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"/>
<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>

0 comments on commit 1a2c172

Please sign in to comment.