Refresh name feature
This commit is contained in:
parent
163637c710
commit
d6a7d1466d
@ -148,7 +148,7 @@ class ChatActivity : ServiceBoundActivity() {
|
||||
if (airaService.contacts.contains(sessionId)) {
|
||||
lastLoadedMessageOffset += 1
|
||||
}
|
||||
airaService.isAppInBackground
|
||||
!airaService.isAppInBackground
|
||||
} else {
|
||||
false
|
||||
}
|
||||
@ -204,17 +204,15 @@ class ChatActivity : ServiceBoundActivity() {
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.chat_activity, menu)
|
||||
val contact = airaService.contacts[sessionId]
|
||||
if (contact == null){
|
||||
menu.findItem(R.id.delete_conversation).isVisible = false
|
||||
menu.findItem(R.id.set_as_contact).isVisible = true
|
||||
menu.findItem(R.id.remove_contact).isVisible = false
|
||||
menu.findItem(R.id.delete_conversation).isVisible = contact != null
|
||||
menu.findItem(R.id.set_as_contact).isVisible = contact == null
|
||||
menu.findItem(R.id.remove_contact).isVisible = contact != null
|
||||
if (contact == null) {
|
||||
menu.findItem(R.id.verify).isVisible = false
|
||||
} else {
|
||||
menu.findItem(R.id.delete_conversation).isVisible = true
|
||||
menu.findItem(R.id.set_as_contact).isVisible = false
|
||||
menu.findItem(R.id.remove_contact).isVisible = true
|
||||
menu.findItem(R.id.verify).isVisible = !contact.verified
|
||||
}
|
||||
menu.findItem(R.id.refresh_name).isEnabled = airaService.isOnline(sessionId)
|
||||
return true
|
||||
}
|
||||
|
||||
@ -303,6 +301,10 @@ class ChatActivity : ServiceBoundActivity() {
|
||||
.show()
|
||||
true
|
||||
}
|
||||
R.id.refresh_name -> {
|
||||
airaService.sendTo(sessionId, Protocol.askName())
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ class AIRAService : Service() {
|
||||
override fun onCreate() {
|
||||
HandlerThread("", THREAD_PRIORITY_BACKGROUND).apply {
|
||||
start()
|
||||
serviceHandler = object : Handler(looper){
|
||||
serviceHandler = object : Handler(looper) {
|
||||
override fun handleMessage(msg: Message) {
|
||||
try {
|
||||
when (msg.what) {
|
||||
@ -438,15 +438,16 @@ class AIRAService : Service() {
|
||||
}
|
||||
MESSAGE_CONNECT_TO -> {
|
||||
msg.data.getString("ip")?.let { ip ->
|
||||
Thread {
|
||||
try {
|
||||
val socket = SocketChannel.open()
|
||||
if (socket.connect(InetSocketAddress(ip, Constants.port))) {
|
||||
handleNewSocket(socket, true)
|
||||
}
|
||||
} catch (e: ConnectException) {
|
||||
Log.w("Connect failed", e.message.toString())
|
||||
return
|
||||
Log.w("Connect failed", "$ip: "+e.message)
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
MESSAGE_CANCEL_FILE_TRANSFER -> {
|
||||
@ -483,6 +484,7 @@ class AIRAService : Service() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val contactList = AIRADatabase.loadContacts()
|
||||
if (contactList == null) {
|
||||
contacts = HashMap(0)
|
||||
@ -497,7 +499,6 @@ class AIRAService : Service() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun encryptNextChunk(session: Session, filesSender: FilesSender) {
|
||||
val nextChunk = ByteArray(Constants.FILE_CHUNK_SIZE)
|
||||
|
@ -32,4 +32,9 @@
|
||||
android:icon="@drawable/ic_info"
|
||||
android:title="@string/details"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/refresh_name"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/refresh_name"/>
|
||||
|
||||
</menu>
|
@ -80,4 +80,5 @@
|
||||
<string name="identity">Identity</string>
|
||||
<string name="about">About</string>
|
||||
<string name="version">AIRA version</string>
|
||||
<string name="refresh_name">Refresh name</string>
|
||||
</resources>
|
||||
|
@ -6,7 +6,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
||||
classpath 'com.android.tools.build:gradle:4.2.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
|
||||
|
Loading…
Reference in New Issue
Block a user