-
Notifications
You must be signed in to change notification settings - Fork 759
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7189 from vector-im/feature/mna/device-manager-re…
…name-session [Device management] Rename a session (PSG-747)
- Loading branch information
Showing
25 changed files
with
1,026 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[Device management] Rename a session |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
library/ui-styles/src/main/res/values/stylable_session_warning_info_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<declare-styleable name="SessionWarningInfoView"> | ||
<attr name="sessionsWarningInfoDescription" format="string" /> | ||
<attr name="sessionsWarningInfoHasLearnMore" format="boolean" /> | ||
</declare-styleable> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
vector/src/main/java/im/vector/app/features/settings/devices/v2/SessionWarningInfoView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright (c) 2022 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.settings.devices.v2 | ||
|
||
import android.content.Context | ||
import android.content.res.TypedArray | ||
import android.util.AttributeSet | ||
import android.view.LayoutInflater | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import androidx.core.content.res.use | ||
import im.vector.app.R | ||
import im.vector.app.core.extensions.setTextWithColoredPart | ||
import im.vector.app.databinding.ViewSessionWarningInfoBinding | ||
|
||
class SessionWarningInfoView @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0 | ||
) : ConstraintLayout(context, attrs, defStyleAttr) { | ||
|
||
private val binding = ViewSessionWarningInfoBinding.inflate( | ||
LayoutInflater.from(context), | ||
this | ||
) | ||
|
||
var onLearnMoreClickListener: (() -> Unit)? = null | ||
|
||
init { | ||
context.obtainStyledAttributes( | ||
attrs, | ||
R.styleable.SessionWarningInfoView, | ||
0, | ||
0 | ||
).use { | ||
setDescription(it) | ||
} | ||
} | ||
|
||
private fun setDescription(typedArray: TypedArray) { | ||
val description = typedArray.getString(R.styleable.SessionWarningInfoView_sessionsWarningInfoDescription) | ||
val hasLearnMore = typedArray.getBoolean(R.styleable.SessionWarningInfoView_sessionsWarningInfoHasLearnMore, false) | ||
if (hasLearnMore) { | ||
val learnMore = context.getString(R.string.action_learn_more) | ||
val fullDescription = buildString { | ||
append(description) | ||
append(" ") | ||
append(learnMore) | ||
} | ||
|
||
binding.sessionWarningInfoDescription.setTextWithColoredPart( | ||
fullText = fullDescription, | ||
coloredPart = learnMore, | ||
underline = false | ||
) { | ||
onLearnMoreClickListener?.invoke() | ||
} | ||
} else { | ||
binding.sessionWarningInfoDescription.text = description | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...or/src/main/java/im/vector/app/features/settings/devices/v2/rename/RenameSessionAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2020 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.settings.devices.v2.rename | ||
|
||
import im.vector.app.core.platform.VectorViewModelAction | ||
|
||
sealed class RenameSessionAction : VectorViewModelAction { | ||
object InitWithLastEditedName : RenameSessionAction() | ||
object SaveModifications : RenameSessionAction() | ||
data class EditLocally(val editedName: String) : RenameSessionAction() | ||
} |
57 changes: 57 additions & 0 deletions
57
.../src/main/java/im/vector/app/features/settings/devices/v2/rename/RenameSessionActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2022 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.settings.devices.v2.rename | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.view.WindowManager | ||
import com.airbnb.mvrx.Mavericks | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import im.vector.app.core.extensions.addFragment | ||
import im.vector.app.core.platform.VectorBaseActivity | ||
import im.vector.app.databinding.ActivitySimpleBinding | ||
|
||
/** | ||
* Display the screen to rename a Session. | ||
*/ | ||
@AndroidEntryPoint | ||
class RenameSessionActivity : VectorBaseActivity<ActivitySimpleBinding>() { | ||
|
||
override fun getBinding() = ActivitySimpleBinding.inflate(layoutInflater) | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
if (isFirstCreation()) { | ||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE) | ||
addFragment( | ||
container = views.simpleFragmentContainer, | ||
fragmentClass = RenameSessionFragment::class.java, | ||
params = intent.getParcelableExtra(Mavericks.KEY_ARG) | ||
) | ||
} | ||
} | ||
|
||
companion object { | ||
fun newIntent(context: Context, deviceId: String): Intent { | ||
return Intent(context, RenameSessionActivity::class.java).apply { | ||
putExtra(Mavericks.KEY_ARG, RenameSessionArgs(deviceId)) | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
vector/src/main/java/im/vector/app/features/settings/devices/v2/rename/RenameSessionArgs.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2022 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.settings.devices.v2.rename | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
|
||
@Parcelize | ||
data class RenameSessionArgs( | ||
val deviceId: String | ||
) : Parcelable |
Oops, something went wrong.