Added menu item to share ensichat apk (fixes #5).
This commit is contained in:
parent
861255e2a9
commit
1e87fd78b7
3 changed files with 21 additions and 0 deletions
|
@ -9,6 +9,10 @@
|
|||
android:icon="@drawable/ic_action_add_person"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/share_app"
|
||||
android:title="@string/share_app" />
|
||||
|
||||
<item
|
||||
android:id="@+id/settings"
|
||||
android:title="@string/settings" />
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
<!-- Empty text for contacts list -->
|
||||
<string name="no_contacts_found">You haven\'t added any contacts yet</string>
|
||||
|
||||
<!-- Menu item to share this app's apk -->
|
||||
<string name="share_app">Share App</string>
|
||||
|
||||
<!-- Menu item to close app and stop service -->
|
||||
<string name="exit">Exit</string>
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.nutomic.ensichat.fragments
|
||||
|
||||
import java.io.File
|
||||
|
||||
import android.app.ListFragment
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view._
|
||||
import android.widget.ListView
|
||||
|
@ -10,6 +13,7 @@ import com.nutomic.ensichat.activities.{AddContactsActivity, EnsiChatActivity, M
|
|||
import com.nutomic.ensichat.protocol.ChatService
|
||||
import com.nutomic.ensichat.util.Database.OnContactsUpdatedListener
|
||||
import com.nutomic.ensichat.util.{Database, UsersAdapter}
|
||||
import scala.collection.JavaConversions._
|
||||
|
||||
/**
|
||||
* Lists all nearby, connected devices.
|
||||
|
@ -45,6 +49,15 @@ class ContactsFragment extends ListFragment with OnContactsUpdatedListener {
|
|||
case R.id.add_contact =>
|
||||
startActivity(new Intent(getActivity, classOf[AddContactsActivity]))
|
||||
true
|
||||
case R.id.share_app =>
|
||||
val pm = getActivity.getPackageManager
|
||||
val ai = pm.getInstalledApplications(0).find(_.sourceDir.contains(getActivity.getPackageName))
|
||||
val intent = new Intent()
|
||||
intent.setAction(Intent.ACTION_SEND)
|
||||
intent.setType("*/*")
|
||||
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(ai.get.sourceDir)))
|
||||
startActivity(intent)
|
||||
true
|
||||
case R.id.settings =>
|
||||
startActivity(new Intent(getActivity, classOf[SettingsActivity]))
|
||||
true
|
||||
|
@ -70,4 +83,5 @@ class ContactsFragment extends ListFragment with OnContactsUpdatedListener {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue