Skip to content

Commit 2f222b6

Browse files
committed
Add UI buttons for encryption and decryption of DMs
1 parent 3bb287c commit 2f222b6

2 files changed

Lines changed: 34 additions & 18 deletions

File tree

app/lint-baseline.xml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
99
<location
1010
file="src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt"
11-
line="1475"
11+
line="1529"
1212
column="28"/>
1313
</issue>
1414

@@ -941,6 +941,28 @@
941941
column="26"/>
942942
</issue>
943943

944+
<issue
945+
id="HardcodedText"
946+
message="Hardcoded string &quot;🔓&quot;, should use `@string` resource"
947+
errorLine1=" android:text=&quot;🔓&quot;"
948+
errorLine2=" ~~~~~~~~~~~~~~~~~">
949+
<location
950+
file="src/main/res/layout/activity_compose.xml"
951+
line="69"
952+
column="13"/>
953+
</issue>
954+
955+
<issue
956+
id="HardcodedText"
957+
message="Hardcoded string &quot;🔒&quot;, should use `@string` resource"
958+
errorLine1=" android:text=&quot;🔒&quot;"
959+
errorLine2=" ~~~~~~~~~~~~~~~~~">
960+
<location
961+
file="src/main/res/layout/activity_compose.xml"
962+
line="82"
963+
column="13"/>
964+
</issue>
965+
944966
<issue
945967
id="RtlSymmetry"
946968
message="When you define `paddingStart` you should probably also define `paddingEnd` for right-to-left symmetry"

app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,6 @@ class ComposeActivity :
939939
}
940940
)
941941
}
942-
943942
}
944943

945944
private fun unlockComposeText() {
@@ -956,18 +955,18 @@ class ComposeActivity :
956955
var privKey: ByteArray = "".toByteArray()
957956
if (contentText.split("\n").first() == "-----BEGIN PGP MESSAGE-----" ||
958957
contentText.split("\n").elementAt(1) == "-----BEGIN PGP MESSAGE-----" ||
959-
contentText.split("\n").elementAt(2) == "-----BEGIN PGP MESSAGE-----" ){
960-
961-
Log.d("condition_block","Encrypted message considered well enough formed.")
958+
contentText.split("\n").elementAt(2) == "-----BEGIN PGP MESSAGE-----"
959+
) {
960+
Log.d("condition_block", "Encrypted message considered well enough formed.")
962961

963962
// Try to bring into proper format for decryption
964-
if(contentText.split("\n").elementAt(1) == "-----BEGIN PGP MESSAGE-----"){
965-
contentText=contentText.split("\n").subList(1,contentText.split("\n").size).joinToString().split(",").joinToString("\n")
966-
Log.d("new contentText",contentText)
963+
if (contentText.split("\n").elementAt(1) == "-----BEGIN PGP MESSAGE-----") {
964+
contentText = contentText.split("\n").subList(1, contentText.split("\n").size).joinToString().split(",").joinToString("\n")
965+
Log.d("new contentText", contentText)
967966
} else {
968-
if (contentText.split("\n").elementAt(2) == "-----BEGIN PGP MESSAGE-----" ){
969-
contentText=contentText.split("\n").subList(2,contentText.split("\n").size).joinToString().split(",").joinToString("\n")
970-
Log.d("new contentText",contentText)
967+
if (contentText.split("\n").elementAt(2) == "-----BEGIN PGP MESSAGE-----") {
968+
contentText = contentText.split("\n").subList(2, contentText.split("\n").size).joinToString().split(",").joinToString("\n")
969+
Log.d("new contentText", contentText)
971970
}
972971
}
973972

@@ -992,7 +991,6 @@ class ComposeActivity :
992991
.toByteArrayAndResult()
993992
val decrypted = messageAndVerifications.bytes
994993
binding.composeEditField.setText(decrypted.toString(charset))
995-
996994
} else {
997995
binding.composeEditField.setText(
998996
buildString {
@@ -1001,7 +999,6 @@ class ComposeActivity :
1001999
}
10021000
)
10031001
}
1004-
10051002
}
10061003

10071004
private fun toggleHideMedia() {
@@ -1258,22 +1255,19 @@ class ComposeActivity :
12581255

12591256
binding.lockButton.hide()
12601257
binding.unlockButton.hide()
1261-
12621258
} else {
12631259
if (visibility.toString() == "UNLISTED") {
12641260
Log.i("if block by visibility", visibility.toString())
12651261

12661262
binding.lockButton.hide()
12671263
binding.unlockButton.hide()
1268-
1269-
} else {
1264+
} else {
12701265
if (visibility.toString() == "PRIVATE") {
12711266
Log.i("if block by visibility", visibility.toString())
12721267

12731268
binding.lockButton.hide()
12741269
binding.unlockButton.hide()
1275-
1276-
} else {
1270+
} else {
12771271
if (visibility.toString() == "DIRECT") {
12781272
Log.i("if block by visibility", visibility.toString())
12791273

0 commit comments

Comments
 (0)