This repository has been archived by the owner on Apr 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 396
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
82 changed files
with
3,916 additions
and
1,062 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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 2019 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.activity | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import android.widget.ImageView | ||
import androidx.appcompat.app.AlertDialog | ||
import com.google.android.material.textfield.TextInputEditText | ||
import com.google.android.material.textfield.TextInputLayout | ||
import im.vector.R | ||
import im.vector.extensions.showPassword | ||
|
||
object DialogUtils { | ||
|
||
fun promptPassword(context: Context, errorText: String? = null, defaultPwd: String? = null, | ||
done: (String) -> Unit, | ||
cancel: (() -> Unit)? = null) { | ||
val view: ViewGroup = LayoutInflater.from(context).inflate(R.layout.dialog_confirm_password, null) as ViewGroup | ||
|
||
val showPassword: ImageView = view.findViewById(R.id.confirm_password_show_passwords) | ||
val passwordTil: TextInputLayout = view.findViewById(R.id.confirm_password_til) | ||
val passwordText: TextInputEditText = view.findViewById(R.id.password_label) | ||
passwordText.setText(defaultPwd) | ||
|
||
var passwordShown = false | ||
|
||
showPassword.setOnClickListener { | ||
passwordShown = !passwordShown | ||
passwordText.showPassword(passwordShown) | ||
showPassword.setImageResource(if (passwordShown) R.drawable.ic_eye_closed_black else R.drawable.ic_eye_black) | ||
} | ||
|
||
passwordTil.error = errorText | ||
|
||
AlertDialog.Builder(context) | ||
.setView(view) | ||
.setPositiveButton(R.string._continue) { tv, _ -> | ||
done(passwordText.text.toString()) | ||
} | ||
.apply { | ||
if (cancel != null) { | ||
setNegativeButton(R.string.cancel) { _, _ -> | ||
cancel() | ||
} | ||
} | ||
} | ||
|
||
.show() | ||
|
||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
vector/src/main/java/im/vector/activity/HandleBackParticipant.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,31 @@ | ||
/* | ||
* Copyright 2019 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.activity | ||
|
||
/** | ||
* A fragment should implement this interface if it wants to intercept backPressed events. | ||
* Any activity extending VectorAppCompatActivity will propagate back pressed event to child | ||
* fragment that implements it. | ||
*/ | ||
interface HandleBackParticipant { | ||
|
||
/** | ||
* Returns true, if the on back pressed event has been handled by this Fragment. | ||
* Otherwise return false | ||
*/ | ||
fun onBackPressed(): Boolean | ||
|
||
} |
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
Oops, something went wrong.