Skip to content

Commit

Permalink
Add UI buttons for encryption and decryption of DMs
Browse files Browse the repository at this point in the history
  • Loading branch information
programizer committed Jun 28, 2024
1 parent 3bb287c commit 2f222b6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
24 changes: 23 additions & 1 deletion app/lint-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt"
line="1475"
line="1529"
column="28"/>
</issue>

Expand Down Expand Up @@ -941,6 +941,28 @@
column="26"/>
</issue>

<issue
id="HardcodedText"
message="Hardcoded string &quot;🔓&quot;, should use `@string` resource"
errorLine1=" android:text=&quot;🔓&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/layout/activity_compose.xml"
line="69"
column="13"/>
</issue>

<issue
id="HardcodedText"
message="Hardcoded string &quot;🔒&quot;, should use `@string` resource"
errorLine1=" android:text=&quot;🔒&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/layout/activity_compose.xml"
line="82"
column="13"/>
</issue>

<issue
id="RtlSymmetry"
message="When you define `paddingStart` you should probably also define `paddingEnd` for right-to-left symmetry"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,6 @@ class ComposeActivity :
}
)
}

}

private fun unlockComposeText() {
Expand All @@ -956,18 +955,18 @@ class ComposeActivity :
var privKey: ByteArray = "".toByteArray()
if (contentText.split("\n").first() == "-----BEGIN PGP MESSAGE-----" ||
contentText.split("\n").elementAt(1) == "-----BEGIN PGP MESSAGE-----" ||
contentText.split("\n").elementAt(2) == "-----BEGIN PGP MESSAGE-----" ){

Log.d("condition_block","Encrypted message considered well enough formed.")
contentText.split("\n").elementAt(2) == "-----BEGIN PGP MESSAGE-----"
) {
Log.d("condition_block", "Encrypted message considered well enough formed.")

// Try to bring into proper format for decryption
if(contentText.split("\n").elementAt(1) == "-----BEGIN PGP MESSAGE-----"){
contentText=contentText.split("\n").subList(1,contentText.split("\n").size).joinToString().split(",").joinToString("\n")
Log.d("new contentText",contentText)
if (contentText.split("\n").elementAt(1) == "-----BEGIN PGP MESSAGE-----") {
contentText = contentText.split("\n").subList(1, contentText.split("\n").size).joinToString().split(",").joinToString("\n")
Log.d("new contentText", contentText)
} else {
if (contentText.split("\n").elementAt(2) == "-----BEGIN PGP MESSAGE-----" ){
contentText=contentText.split("\n").subList(2,contentText.split("\n").size).joinToString().split(",").joinToString("\n")
Log.d("new contentText",contentText)
if (contentText.split("\n").elementAt(2) == "-----BEGIN PGP MESSAGE-----") {
contentText = contentText.split("\n").subList(2, contentText.split("\n").size).joinToString().split(",").joinToString("\n")
Log.d("new contentText", contentText)
}
}

Expand All @@ -992,7 +991,6 @@ class ComposeActivity :
.toByteArrayAndResult()
val decrypted = messageAndVerifications.bytes
binding.composeEditField.setText(decrypted.toString(charset))

} else {
binding.composeEditField.setText(
buildString {
Expand All @@ -1001,7 +999,6 @@ class ComposeActivity :
}
)
}

}

private fun toggleHideMedia() {
Expand Down Expand Up @@ -1258,22 +1255,19 @@ class ComposeActivity :

binding.lockButton.hide()
binding.unlockButton.hide()

} else {
if (visibility.toString() == "UNLISTED") {
Log.i("if block by visibility", visibility.toString())

binding.lockButton.hide()
binding.unlockButton.hide()

} else {
} else {
if (visibility.toString() == "PRIVATE") {
Log.i("if block by visibility", visibility.toString())

binding.lockButton.hide()
binding.unlockButton.hide()

} else {
} else {
if (visibility.toString() == "DIRECT") {
Log.i("if block by visibility", visibility.toString())

Expand Down

0 comments on commit 2f222b6

Please sign in to comment.