Added a "SHOW EXTRA CONTENT" button under the "SHOW PASSWORD" button. (#510)

* Add 'SHOW EXTRA CONTENT' button.

* Show the extra content after clicking the 'SHOW EXTRA CONTENT' button.

* Change the regular button to a toggle button and add text for hiding extra contents.

* Change the implementaton of showing/hiding extra contents to accomodate using a toggle button.

* Add padding to the top of the button.
This commit is contained in:
Emmanuel Corrales 2019-05-26 17:24:16 +08:00 committed by Harsh Shandilya
parent b06420eb83
commit c46f50f86f
3 changed files with 33 additions and 2 deletions

View file

@ -271,11 +271,27 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
}
if (entry.hasExtraContent()) {
crypto_extra_show_layout.visibility = if (showExtraContent) View.VISIBLE else View.GONE
crypto_extra_show.typeface = monoTypeface
crypto_extra_show.text = entry.extraContent
if (showExtraContent) {
crypto_extra_show_layout.visibility = View.VISIBLE
crypto_extra_toggle_show.visibility = View.GONE
crypto_extra_show.transformationMethod = null
} else {
crypto_extra_show_layout.visibility = View.GONE
crypto_extra_toggle_show.visibility = View.VISIBLE
crypto_extra_toggle_show.setOnCheckedChangeListener { _, _ ->
crypto_extra_show.text = entry.extraContent
}
crypto_extra_show.transformationMethod = object : PasswordTransformationMethod() {
override fun getTransformation(source: CharSequence, view: View): CharSequence {
return if (crypto_extra_toggle_show.isChecked) source else super.getTransformation(source, view)
}
}
}
if (entry.hasUsername()) {
crypto_username_show.visibility = View.VISIBLE
crypto_username_show_label.visibility = View.VISIBLE

View file

@ -228,6 +228,19 @@
android:textIsSelectable="true"
android:typeface="monospace" />
<ToggleButton
android:id="@+id/crypto_extra_toggle_show"
style="@style/Widget.AppCompat.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/crypto_extra_show"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:checked="false"
android:paddingTop="8dp"
android:textOff="@string/show_extra"
android:textOn="@string/hide_extra" />
</RelativeLayout>
</LinearLayout>

View file

@ -215,6 +215,8 @@
<string name="no_repo_selected">No external repository selected</string>
<string name="send_plaintext_password_to">Send password as plaintext using…</string>
<string name="show_password">Show password</string>
<string name="show_extra">Show extra content</string>
<string name="hide_extra">Hide extra content</string>
<string name="repository_uri">Repository URI</string>
<string name="app_icon_hint">App icon</string>
<string name="folder_icon_hint">Folder icon</string>