├── settings.gradle
├── letsChat
├── libs
│ ├── dnsjava-2.1.6.jar
│ └── asmack-android-8-4.0.6.jar
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── ic_send.png
│ │ │ │ ├── ic_account.png
│ │ │ │ ├── ic_delete.png
│ │ │ │ ├── ic_photo.png
│ │ │ │ ├── msg_in.9.png
│ │ │ │ ├── msg_out.9.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_location.png
│ │ │ │ ├── ic_attach_photo.png
│ │ │ │ ├── ic_notification.png
│ │ │ │ ├── ic_action_attach.png
│ │ │ │ ├── ic_action_search.png
│ │ │ │ ├── ic_default_avatar.png
│ │ │ │ ├── ic_network_usage.png
│ │ │ │ ├── ic_action_add_person.png
│ │ │ │ ├── ic_action_new_chat.png
│ │ │ │ └── ic_action_settings.png
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── ic_send.png
│ │ │ │ ├── ic_account.png
│ │ │ │ ├── ic_delete.png
│ │ │ │ ├── ic_photo.png
│ │ │ │ ├── msg_in.9.png
│ │ │ │ ├── msg_out.9.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_location.png
│ │ │ │ ├── ic_attach_photo.png
│ │ │ │ ├── ic_notification.png
│ │ │ │ ├── ic_action_attach.png
│ │ │ │ ├── ic_action_search.png
│ │ │ │ ├── ic_default_avatar.png
│ │ │ │ ├── ic_network_usage.png
│ │ │ │ ├── ic_action_add_person.png
│ │ │ │ ├── ic_action_new_chat.png
│ │ │ │ └── ic_action_settings.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── ic_delete.png
│ │ │ │ ├── ic_photo.png
│ │ │ │ ├── ic_send.png
│ │ │ │ ├── msg_in.9.png
│ │ │ │ ├── msg_out.9.png
│ │ │ │ ├── ic_account.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_location.png
│ │ │ │ ├── ic_action_attach.png
│ │ │ │ ├── ic_action_search.png
│ │ │ │ ├── ic_attach_photo.png
│ │ │ │ ├── ic_network_usage.png
│ │ │ │ ├── ic_notification.png
│ │ │ │ ├── ic_action_new_chat.png
│ │ │ │ ├── ic_action_settings.png
│ │ │ │ ├── ic_default_avatar.png
│ │ │ │ └── ic_action_add_person.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── ic_photo.png
│ │ │ │ ├── ic_send.png
│ │ │ │ ├── msg_in.9.png
│ │ │ │ ├── ic_account.png
│ │ │ │ ├── ic_delete.png
│ │ │ │ ├── msg_out.9.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_location.png
│ │ │ │ ├── ic_attach_photo.png
│ │ │ │ ├── ic_notification.png
│ │ │ │ ├── ic_action_attach.png
│ │ │ │ ├── ic_action_new_chat.png
│ │ │ │ ├── ic_action_search.png
│ │ │ │ ├── ic_action_settings.png
│ │ │ │ ├── ic_default_avatar.png
│ │ │ │ ├── ic_network_usage.png
│ │ │ │ └── ic_action_add_person.png
│ │ │ ├── values
│ │ │ │ ├── attrs.xml
│ │ │ │ ├── arrays.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── drawable
│ │ │ │ ├── date_separator_background.xml
│ │ │ │ ├── conversation_unread_count_bg.xml
│ │ │ │ ├── splash_background.xml
│ │ │ │ ├── btn_light.xml
│ │ │ │ ├── attach_photo_background.xml
│ │ │ │ ├── attach_location_background.xml
│ │ │ │ └── btn_green.xml
│ │ │ ├── color
│ │ │ │ └── btn_green_text.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_contact_requests.xml
│ │ │ │ ├── message_date_separator.xml
│ │ │ │ ├── plain_text_view.xml
│ │ │ │ ├── fragment_contacts.xml
│ │ │ │ ├── fragment_conversation.xml
│ │ │ │ ├── activity_add_contact.xml
│ │ │ │ ├── contact_list_header.xml
│ │ │ │ ├── location_text_view.xml
│ │ │ │ ├── incoming_plain_text_view.xml
│ │ │ │ ├── preference_user_avatar.xml
│ │ │ │ ├── activity_login.xml
│ │ │ │ ├── preference_username.xml
│ │ │ │ ├── contact_list_item.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── activity_startup.xml
│ │ │ │ ├── contact_request_list_item.xml
│ │ │ │ ├── outgoing_plain_text_view.xml
│ │ │ │ ├── incoming_location_view.xml
│ │ │ │ ├── incoming_image_view.xml
│ │ │ │ ├── user_search_result_list_item.xml
│ │ │ │ ├── activity_signup.xml
│ │ │ │ ├── attach_options_view.xml
│ │ │ │ ├── fragment_profile.xml
│ │ │ │ ├── outgoing_location_view.xml
│ │ │ │ ├── activity_chat.xml
│ │ │ │ ├── outgoing_image_view.xml
│ │ │ │ ├── activity_user_profile.xml
│ │ │ │ ├── conversation_list_item.xml
│ │ │ │ └── activity_set_status.xml
│ │ │ ├── values-v21
│ │ │ │ └── styles.xml
│ │ │ ├── menu
│ │ │ │ ├── connectivity_menu.xml
│ │ │ │ ├── contact_profile_menu.xml
│ │ │ │ ├── chat_menu.xml
│ │ │ │ ├── chat_select_context.xml
│ │ │ │ ├── add_contact_menu.xml
│ │ │ │ ├── contact_list_menu.xml
│ │ │ │ ├── main_menu.xml
│ │ │ │ └── conversation_menu.xml
│ │ │ ├── values-v11
│ │ │ │ └── styles.xml
│ │ │ ├── values-v14
│ │ │ │ └── styles.xml
│ │ │ ├── xml
│ │ │ │ ├── server_preference.xml
│ │ │ │ ├── profile_preferences.xml
│ │ │ │ ├── network_traffic_preferences.xml
│ │ │ │ └── preference_headers.xml
│ │ │ └── layout-v21
│ │ │ │ ├── preference_user_avatar.xml
│ │ │ │ └── preference_username.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── mstr
│ │ │ └── letschat
│ │ │ ├── receivers
│ │ │ ├── ShutDownReceiver.java
│ │ │ ├── BootReceiver.java
│ │ │ ├── NetworkReceiver.java
│ │ │ └── IncomingContactRequestReceiver.java
│ │ │ ├── utils
│ │ │ ├── AppLog.java
│ │ │ ├── NotificationUtils.java
│ │ │ ├── ProviderUtils.java
│ │ │ ├── Utils.java
│ │ │ ├── PreferenceUtils.java
│ │ │ └── NetworkUtils.java
│ │ │ ├── SmackInvocationException.java
│ │ │ ├── views
│ │ │ ├── IncomingPlainTextView.java
│ │ │ ├── IncomingImageMessageView.java
│ │ │ ├── IncomingLocationView.java
│ │ │ ├── ImageMessageView.java
│ │ │ ├── PlainTextView.java
│ │ │ ├── OutgoingPlainTextView.java
│ │ │ ├── OutgoingLocationView.java
│ │ │ ├── OutgoingImageMessageView.java
│ │ │ └── MessageView.java
│ │ │ ├── model
│ │ │ ├── SubscribeInfo.java
│ │ │ ├── LoginUserProfile.java
│ │ │ └── Contact.java
│ │ │ ├── tasks
│ │ │ ├── Response.java
│ │ │ ├── SendPlainTextTask.java
│ │ │ ├── LoadStatusTask.java
│ │ │ ├── DeleteContactTask.java
│ │ │ ├── BaseAsyncTask.java
│ │ │ ├── SendLocationTask.java
│ │ │ ├── SendContactRequestTask.java
│ │ │ ├── SearchUserTask.java
│ │ │ ├── LoadProfileTask.java
│ │ │ ├── LoginTask.java
│ │ │ ├── SendImageTask.java
│ │ │ ├── SignupTask.java
│ │ │ ├── AcceptContactRequestTask.java
│ │ │ └── SaveStatusTask.java
│ │ │ ├── SettingsActivity.java
│ │ │ ├── ServerSettingsActivity.java
│ │ │ ├── fragments
│ │ │ ├── ProfileFragment.java
│ │ │ └── NetworkUsageFragment.java
│ │ │ ├── xmpp
│ │ │ ├── PresencePacketListener.java
│ │ │ ├── MessagePacketListener.java
│ │ │ ├── SmackVCardHelper.java
│ │ │ ├── LocationMessageProvider.java
│ │ │ └── SmackContactHelper.java
│ │ │ ├── databases
│ │ │ ├── ChatDbHelper.java
│ │ │ ├── ContactTableHelper.java
│ │ │ ├── ContactRequestTableHelper.java
│ │ │ └── ConversationTableHelper.java
│ │ │ ├── adapters
│ │ │ ├── StatusListAdapter.java
│ │ │ └── ContactCursorAdapter.java
│ │ │ ├── StartupActivity.java
│ │ │ └── LoginActivity.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── mstr
│ │ └── letschat
│ │ ├── ConversationActivityTest.java
│ │ └── ChatActivityTest.java
├── proguard-rules.txt
├── .gitignore
└── build.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── library
├── cropImage
│ ├── src
│ │ └── main
│ │ │ ├── res
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── ic_menu_3d_globe.png
│ │ │ │ ├── camera_crop_height.png
│ │ │ │ ├── camera_crop_width.png
│ │ │ │ ├── indicator_autocrop.png
│ │ │ │ ├── detail_photo_border.9.png
│ │ │ │ ├── ic_menu_view_details.png
│ │ │ │ └── ic_menu_camera_video_view.png
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── ic_menu_3d_globe.png
│ │ │ │ ├── camera_crop_height.png
│ │ │ │ ├── camera_crop_width.png
│ │ │ │ ├── indicator_autocrop.png
│ │ │ │ ├── detail_photo_border.9.png
│ │ │ │ ├── ic_menu_view_details.png
│ │ │ │ └── ic_menu_camera_video_view.png
│ │ │ └── layout
│ │ │ │ └── cropimage.xml
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ └── com
│ │ │ └── android
│ │ │ └── camera
│ │ │ ├── NoSearchActivity.java
│ │ │ └── gallery
│ │ │ ├── SingleImageList.java
│ │ │ ├── IImageList.java
│ │ │ └── LruCache.java
│ ├── .gitignore
│ └── build.gradle
├── memorizingTrustManager
│ ├── src
│ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── res
│ │ │ ├── values-zh-rCN
│ │ │ │ └── strings.xml
│ │ │ ├── values-iw
│ │ │ │ └── strings.xml
│ │ │ ├── values-no
│ │ │ │ └── strings.xml
│ │ │ ├── values
│ │ │ │ └── strings.xml
│ │ │ ├── values-de
│ │ │ │ └── strings.xml
│ │ │ ├── values-tr
│ │ │ │ └── strings.xml
│ │ │ ├── values-es
│ │ │ │ └── strings.xml
│ │ │ ├── values-eu
│ │ │ │ └── strings.xml
│ │ │ ├── values-fi
│ │ │ │ └── strings.xml
│ │ │ └── values-fr
│ │ │ │ └── strings.xml
│ │ │ └── java
│ │ │ └── de
│ │ │ └── duenndns
│ │ │ └── ssl
│ │ │ └── MTMDecision.java
│ ├── build.gradle
│ └── .gitignore
└── library.iml
├── .gitignore
├── README.md
├── LetsChat.iml
└── gradlew.bat
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':library:cropImage', ':letsChat'
2 | include ':library:memorizingTrustManager'
--------------------------------------------------------------------------------
/letsChat/libs/dnsjava-2.1.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/libs/dnsjava-2.1.6.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/letsChat/libs/asmack-android-8-4.0.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/libs/asmack-android-8-4.0.6.jar
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/ic_send.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/ic_send.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/ic_send.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/ic_send.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/ic_account.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/ic_account.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/ic_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/ic_delete.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/ic_photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/ic_photo.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/msg_in.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/msg_in.9.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/msg_out.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/msg_out.9.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/ic_account.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/ic_account.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/ic_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/ic_delete.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/ic_photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/ic_photo.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/msg_in.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/msg_in.9.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/msg_out.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/msg_out.9.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/ic_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/ic_delete.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/ic_photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/ic_photo.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/ic_send.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/ic_send.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/msg_in.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/msg_in.9.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/msg_out.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/msg_out.9.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/ic_photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/ic_photo.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/ic_send.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/ic_send.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/msg_in.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/msg_in.9.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/ic_location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/ic_location.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/ic_location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/ic_location.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/ic_account.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/ic_account.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/ic_location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/ic_location.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/ic_account.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/ic_account.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/ic_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/ic_delete.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/msg_out.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/msg_out.9.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/ic_attach_photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/ic_attach_photo.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/ic_notification.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/ic_notification.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/ic_attach_photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/ic_attach_photo.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/ic_notification.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/ic_notification.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/ic_location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/ic_location.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/ic_action_attach.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/ic_action_attach.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/ic_action_search.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/ic_default_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/ic_default_avatar.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/ic_network_usage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/ic_network_usage.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/ic_action_attach.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/ic_action_attach.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/ic_action_search.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/ic_default_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/ic_default_avatar.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/ic_network_usage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/ic_network_usage.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/ic_action_attach.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/ic_action_attach.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/ic_action_search.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/ic_attach_photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/ic_attach_photo.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/ic_network_usage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/ic_network_usage.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/ic_notification.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/ic_notification.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/ic_attach_photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/ic_attach_photo.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/ic_notification.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/ic_notification.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/ic_action_add_person.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/ic_action_add_person.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/ic_action_new_chat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/ic_action_new_chat.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-hdpi/ic_action_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-hdpi/ic_action_settings.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/ic_action_add_person.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/ic_action_add_person.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/ic_action_new_chat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/ic_action_new_chat.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-mdpi/ic_action_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-mdpi/ic_action_settings.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/ic_action_new_chat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/ic_action_new_chat.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/ic_action_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/ic_action_settings.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/ic_default_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/ic_default_avatar.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/ic_action_attach.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/ic_action_attach.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/ic_action_new_chat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/ic_action_new_chat.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/ic_action_search.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/ic_action_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/ic_action_settings.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/ic_default_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/ic_default_avatar.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/ic_network_usage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/ic_network_usage.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xhdpi/ic_action_add_person.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xhdpi/ic_action_add_person.png
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable-xxhdpi/ic_action_add_person.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/letsChat/src/main/res/drawable-xxhdpi/ic_action_add_person.png
--------------------------------------------------------------------------------
/library/cropImage/src/main/res/drawable-hdpi/ic_menu_3d_globe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/library/cropImage/src/main/res/drawable-hdpi/ic_menu_3d_globe.png
--------------------------------------------------------------------------------
/library/cropImage/src/main/res/drawable-mdpi/ic_menu_3d_globe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/library/cropImage/src/main/res/drawable-mdpi/ic_menu_3d_globe.png
--------------------------------------------------------------------------------
/library/cropImage/src/main/res/drawable-hdpi/camera_crop_height.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/library/cropImage/src/main/res/drawable-hdpi/camera_crop_height.png
--------------------------------------------------------------------------------
/library/cropImage/src/main/res/drawable-hdpi/camera_crop_width.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/library/cropImage/src/main/res/drawable-hdpi/camera_crop_width.png
--------------------------------------------------------------------------------
/library/cropImage/src/main/res/drawable-hdpi/indicator_autocrop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/library/cropImage/src/main/res/drawable-hdpi/indicator_autocrop.png
--------------------------------------------------------------------------------
/library/cropImage/src/main/res/drawable-mdpi/camera_crop_height.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/library/cropImage/src/main/res/drawable-mdpi/camera_crop_height.png
--------------------------------------------------------------------------------
/library/cropImage/src/main/res/drawable-mdpi/camera_crop_width.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/library/cropImage/src/main/res/drawable-mdpi/camera_crop_width.png
--------------------------------------------------------------------------------
/library/cropImage/src/main/res/drawable-mdpi/indicator_autocrop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/library/cropImage/src/main/res/drawable-mdpi/indicator_autocrop.png
--------------------------------------------------------------------------------
/library/cropImage/src/main/res/drawable-hdpi/detail_photo_border.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/library/cropImage/src/main/res/drawable-hdpi/detail_photo_border.9.png
--------------------------------------------------------------------------------
/library/cropImage/src/main/res/drawable-hdpi/ic_menu_view_details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/library/cropImage/src/main/res/drawable-hdpi/ic_menu_view_details.png
--------------------------------------------------------------------------------
/library/cropImage/src/main/res/drawable-mdpi/detail_photo_border.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/library/cropImage/src/main/res/drawable-mdpi/detail_photo_border.9.png
--------------------------------------------------------------------------------
/library/cropImage/src/main/res/drawable-mdpi/ic_menu_view_details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/library/cropImage/src/main/res/drawable-mdpi/ic_menu_view_details.png
--------------------------------------------------------------------------------
/library/cropImage/src/main/res/drawable-hdpi/ic_menu_camera_video_view.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/library/cropImage/src/main/res/drawable-hdpi/ic_menu_camera_video_view.png
--------------------------------------------------------------------------------
/library/cropImage/src/main/res/drawable-mdpi/ic_menu_camera_video_view.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dilicode/LetsChat/HEAD/library/cropImage/src/main/res/drawable-mdpi/ic_menu_camera_video_view.png
--------------------------------------------------------------------------------
/letsChat/proguard-rules.txt:
--------------------------------------------------------------------------------
1 | -keep class org.jivesoftware.** { *; }
2 | -keep class android.support.v7.widget.SearchView { *; }
3 |
4 | -dontwarn sun.net.spi.nameservice.**
5 | -dontwarn de.duenndns.ssl.MemorizingTrustManager
--------------------------------------------------------------------------------
/letsChat/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable/date_separator_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/library/memorizingTrustManager/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/color/btn_green_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable/conversation_unread_count_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/activity_contact_requests.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
--------------------------------------------------------------------------------
/library/cropImage/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/menu/connectivity_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/menu/contact_profile_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/menu/chat_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/menu/chat_select_context.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable/splash_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - @string/status_available
5 | - @string/status_busy
6 | - @string/status_At_school
7 | - @string/status_At_work
8 | - @string/status_meeting
9 |
10 |
--------------------------------------------------------------------------------
/library/memorizingTrustManager/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 19
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | }
9 |
10 | buildTypes {
11 | release {
12 | minifyEnabled false
13 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/letsChat/.gitignore:
--------------------------------------------------------------------------------
1 | #Android generated
2 | bin
3 | gen
4 |
5 | #Eclipse
6 | .project
7 | .classpath
8 | .settings
9 |
10 | #Maven
11 | target
12 | release.properties
13 | pom.xml.*
14 |
15 | #Ant
16 | build.xml
17 | local.properties
18 | proguard.cfg
19 |
20 | #OSX
21 | .DS_Store
22 |
23 | #Android Studio
24 | .gradle
25 | /local.properties
26 | /.idea/workspace.xml
27 | /.idea/libraries
28 | .DS_Store
29 | /build
--------------------------------------------------------------------------------
/library/cropImage/.gitignore:
--------------------------------------------------------------------------------
1 | #Android generated
2 | bin
3 | gen
4 |
5 | #Eclipse
6 | .project
7 | .classpath
8 | .settings
9 |
10 | #Maven
11 | target
12 | release.properties
13 | pom.xml.*
14 |
15 | #Ant
16 | build.xml
17 | local.properties
18 | proguard.cfg
19 |
20 | #OSX
21 | .DS_Store
22 |
23 | #Android Studio
24 | .gradle
25 | /local.properties
26 | /.idea/workspace.xml
27 | /.idea/libraries
28 | .DS_Store
29 | /build
--------------------------------------------------------------------------------
/library/memorizingTrustManager/.gitignore:
--------------------------------------------------------------------------------
1 | #Android generated
2 | bin
3 | gen
4 |
5 | #Eclipse
6 | .project
7 | .classpath
8 | .settings
9 |
10 | #Maven
11 | target
12 | release.properties
13 | pom.xml.*
14 |
15 | #Ant
16 | build.xml
17 | local.properties
18 | proguard.cfg
19 |
20 | #OSX
21 | .DS_Store
22 |
23 | #Android Studio
24 | .gradle
25 | /local.properties
26 | /.idea/workspace.xml
27 | /.idea/libraries
28 | .DS_Store
29 | /build
--------------------------------------------------------------------------------
/letsChat/src/main/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/xml/server_preference.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/library/cropImage/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 19
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 19
10 | }
11 |
12 | buildTypes {
13 | release {
14 | minifyEnabled false
15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #Android generated
2 | bin
3 | gen
4 |
5 | #Eclipse
6 | .project
7 | .classpath
8 | .settings
9 |
10 | #Maven
11 | target
12 | release.properties
13 | pom.xml.*
14 |
15 | #Ant
16 | build.xml
17 | local.properties
18 | proguard.cfg
19 |
20 | #OSX
21 | .DS_Store
22 |
23 | #Android Studio
24 | .gradle
25 | local.properties
26 | /.idea/workspace.xml
27 | /.idea/libraries
28 | .DS_Store
29 | /build
30 | /import-summary.txt
31 | /.idea
32 | *.iml
33 | /captures
--------------------------------------------------------------------------------
/letsChat/src/main/res/menu/add_contact_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/message_date_separator.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/xml/profile_preferences.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/xml/network_traffic_preferences.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/plain_text_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
15 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable/btn_light.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/receivers/ShutDownReceiver.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.receivers;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 |
7 | import com.mstr.letschat.utils.NetworkUtils;
8 |
9 | /**
10 | * Created by dilli on 1/21/2016.
11 | */
12 | public class ShutDownReceiver extends BroadcastReceiver {
13 | public void onReceive(Context context, Intent intent) {
14 | if (Intent.ACTION_SHUTDOWN.equals(intent.getAction())) {
15 | NetworkUtils.saveNetworkUsageOnShutDown(context);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/xml/preference_headers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/receivers/BootReceiver.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.receivers;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 |
7 | import com.mstr.letschat.service.MessageService;
8 |
9 | public class BootReceiver extends BroadcastReceiver {
10 |
11 | @Override
12 | public void onReceive(Context context, Intent intent) {
13 | if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
14 | context.startService(new Intent(MessageService.ACTION_CONNECT, null, context, MessageService.class));
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/utils/AppLog.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.utils;
2 |
3 | import android.util.Log;
4 |
5 | public class AppLog {
6 | public static String TAG = "com.mstr.Letschat";
7 |
8 | public static void i(String msg) {
9 | Log.i(TAG, msg);
10 | }
11 |
12 | public static void d(String msg) {
13 | Log.d(TAG, msg);
14 | }
15 |
16 | public static void d(String msg, Throwable tr) {
17 | Log.d(TAG, msg, tr);
18 | }
19 |
20 | public static void e(String msg) {
21 | Log.e(TAG, msg);
22 | }
23 |
24 | public static void e(String msg, Throwable tr) {
25 | Log.e(TAG, msg, tr);
26 | }
27 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable/attach_photo_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable/attach_location_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/menu/contact_list_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/SmackInvocationException.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat;
2 |
3 | import org.jivesoftware.smack.sasl.SASLErrorException;
4 |
5 | @SuppressWarnings("serial")
6 | public class SmackInvocationException extends Exception {
7 | public SmackInvocationException(String detailMessage) {
8 | super(detailMessage);
9 | }
10 |
11 | public SmackInvocationException(Throwable throwable) {
12 | super(throwable);
13 | }
14 |
15 | public SmackInvocationException(String detailMessage, Throwable throwable) {
16 | super(detailMessage, throwable);
17 | }
18 |
19 | public boolean isCausedBySASLError() {
20 | return getCause() != null && (getCause() instanceof SASLErrorException);
21 | }
22 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/views/IncomingPlainTextView.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.views;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | import com.mstr.letschat.R;
7 |
8 | public class IncomingPlainTextView extends PlainTextView {
9 | public IncomingPlainTextView(Context context) {
10 | this(context, null);
11 | }
12 |
13 | public IncomingPlainTextView(Context context, AttributeSet attrs) {
14 | super(context, attrs);
15 | }
16 |
17 | protected int getLayoutResource() {
18 | return R.layout.incoming_plain_text_view;
19 | }
20 |
21 | public void showProgress(boolean sent) {
22 | throw new UnsupportedOperationException("progress is not displayed for incoming messages");
23 | }
24 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/fragment_contacts.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
20 |
21 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/fragment_conversation.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
20 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/views/IncomingImageMessageView.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.views;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | import com.mstr.letschat.R;
7 |
8 | /**
9 | * Created by dilli on 1/29/2016.
10 | */
11 | public class IncomingImageMessageView extends ImageMessageView {
12 | public IncomingImageMessageView(Context context) {
13 | super(context);
14 | }
15 |
16 | public IncomingImageMessageView(Context context, AttributeSet attrs) {
17 | super(context, attrs);
18 | }
19 |
20 | @Override
21 | protected int getLayoutResource() {
22 | return R.layout.incoming_image_view;
23 | }
24 |
25 | @Override
26 | public void showProgress(boolean sent) {}
27 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #d4d4d4
4 | #ffb2b2b2
5 | #45c01a
6 | #4e7777
7 | #336699
8 | #39b44a
9 | #0fad68
10 | #3F51B5
11 | #303F9F
12 | #2bacfe
13 | #00897b
14 | #b6dbe0
15 | #02a8f3
16 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/activity_add_contact.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/letsChat/src/androidTest/java/com/mstr/letschat/ConversationActivityTest.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat;
2 |
3 | import android.test.ActivityInstrumentationTestCase2;
4 | import android.test.suitebuilder.annotation.MediumTest;
5 |
6 | /**
7 | * Created by dilli on 7/26/2015.
8 | */
9 | public class ConversationActivityTest extends ActivityInstrumentationTestCase2 {
10 | private ConversationFragment activity;
11 |
12 | public ConversationActivityTest() {
13 | super(ConversationFragment.class);
14 | }
15 |
16 | @Override
17 | protected void setUp() throws Exception {
18 | super.setUp();
19 |
20 | activity = getActivity();
21 | }
22 |
23 | @MediumTest
24 | public void testPreconditions() {
25 | assertNotNull("activity is null", activity);
26 | }
27 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/views/IncomingLocationView.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.views;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | import com.mstr.letschat.R;
7 |
8 | /**
9 | * Created by dilli on 12/2/2015.
10 | */
11 | public class IncomingLocationView extends LocationView {
12 | public IncomingLocationView(Context context) {
13 | this(context, null);
14 | }
15 |
16 | public IncomingLocationView(Context context, AttributeSet attrs) {
17 | super(context, attrs);
18 | }
19 |
20 | public void showProgress(boolean sent) {
21 | throw new UnsupportedOperationException("progress is not displayed for incoming messages");
22 | }
23 |
24 | protected int getLayoutResource() {
25 | return R.layout.incoming_location_view;
26 | }
27 | }
--------------------------------------------------------------------------------
/library/memorizingTrustManager/src/main/res/values-zh-rCN/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 是否接受未知的证书?
4 | 服务器证书没有被签名
5 | The server certificate is expired.
6 | 是否接受不匹配的服务器名
7 | 服务器不能给\"%s\"授权. 证书只对:有效
8 |
9 | Do you want to connect anyway?
10 | 证书详情
11 |
12 | 总是
13 | 一次
14 | 放弃
15 |
16 | 证书验证
17 |
18 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/model/SubscribeInfo.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.model;
2 |
3 | public class SubscribeInfo {
4 | public static final int TYPE_UNKNOWN = -1;
5 | public static final int TYPE_WAIT_FOR_APPROVAL = 0;
6 | public static final int TYPE_APPROVED = 1;
7 |
8 | private String from;
9 | private String nickname;
10 | private int type = TYPE_UNKNOWN;
11 |
12 | public String getFrom() {
13 | return from;
14 | }
15 |
16 | public void setFrom(String from) {
17 | this.from = from;
18 | }
19 |
20 | public String getNickname() {
21 | return nickname;
22 | }
23 |
24 | public void setNickname(String nickname) {
25 | this.nickname = nickname;
26 | }
27 |
28 | public int getType() {
29 | return type;
30 | }
31 |
32 | public void setType(int type) {
33 | this.type = type;
34 | }
35 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/contact_list_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
19 |
24 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/menu/main_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LetsChat
2 | This app does not work any more due to the server deployed on AWS is closed.
3 |
4 | LetsChat is a Android chat application based on Openfire XMPP and Smack.
5 |
6 | ## Features
7 |
8 | - register/login
9 | - send location/image/plain text
10 | - TLS support
11 | - chat history
12 | - avatars
13 | - view contact's information (vCard)
14 | - contact search
15 | - update status
16 | - delete messages
17 | - material design
18 |
19 | ## Sample Application
20 | The sample application (the source is in the repository) has been published onto Google Play for easy access:
21 |
22 | [](https://play.google.com/store/apps/details?id=com.mstr.letschat)
23 |
24 | ## Libraries
25 | Libraries used in this project include:
26 | - [MemorizingTrustManager](https://github.com/ge0rg/MemorizingTrustManager)
27 | - [android-cropimage](https://github.com/lvillani/android-cropimage)
28 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/drawable/btn_green.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | -
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/model/LoginUserProfile.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.model;
2 |
3 | import android.graphics.Bitmap;
4 |
5 | public class LoginUserProfile {
6 | private String user;
7 | private String password;
8 | private String nickname;
9 |
10 | private Bitmap avatar;
11 |
12 | public String getUser() {
13 | return user;
14 | }
15 |
16 | public void setUser(String user) {
17 | this.user = user;
18 | }
19 |
20 | public String getPassword() {
21 | return password;
22 | }
23 |
24 | public void setPassword(String password) {
25 | this.password = password;
26 | }
27 |
28 | public String getNickname() {
29 | return nickname;
30 | }
31 |
32 | public void setNickname(String nickname) {
33 | this.nickname = nickname;
34 | }
35 |
36 | public Bitmap getAvatar() {
37 | return avatar;
38 | }
39 |
40 | public void setAvatar(Bitmap avatar) {
41 | this.avatar = avatar;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/library/cropImage/src/main/java/com/android/camera/NoSearchActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2009 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.camera;
18 |
19 | import android.app.Activity;
20 |
21 | public class NoSearchActivity extends Activity {
22 | @Override
23 | public boolean onSearchRequested() {
24 | return false;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/library/memorizingTrustManager/src/main/res/values-iw/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | לקבל תעודה לא מוכרת?
4 | תעודת השרת אינה חתומה על ידי Certificate Authority מוכר.
5 | The server certificate is expired.
6 | לקבל שם שרת לא תואם?
7 | שרת לא היה מסוגל לאמת בתור \"%s\". התעודה הינה ברת תוקף רק עבור:
8 |
9 | האם ברצונך להתחבר בכל אופן?
10 | פרטי תעודה:
11 |
12 | תמיד
13 | פעם אחת
14 | נטוש
15 |
16 | אימות תעודה
17 |
18 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/tasks/Response.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.tasks;
2 |
3 | public class Response {
4 | public interface Listener {
5 | public void onResponse(T result);
6 |
7 | public void onErrorResponse(Exception exception);
8 | }
9 |
10 | public static Response success(T result) {
11 | return new Response(result);
12 | }
13 |
14 | public static Response error(Exception e) {
15 | return new Response(e);
16 | }
17 |
18 | private T result;
19 |
20 | private Exception exception;
21 |
22 | private Response(T result) {
23 | this.result = result;
24 | }
25 |
26 | private Response(Exception exception) {
27 | this.exception = exception;
28 | }
29 |
30 | public boolean isSuccess() {
31 | return exception == null;
32 | }
33 |
34 | public T getResult() {
35 | return result;
36 | }
37 |
38 | public Exception getException() {
39 | return exception;
40 | }
41 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/views/ImageMessageView.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.views;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.ImageView;
6 | import android.widget.LinearLayout;
7 |
8 | import com.mstr.letschat.R;
9 |
10 | /**
11 | * Created by dilli on 1/29/2016.
12 | */
13 | public abstract class ImageMessageView extends MessageView {
14 | private ImageView image;
15 |
16 | public ImageMessageView(Context context) {
17 | this(context, null);
18 | }
19 |
20 | public ImageMessageView(Context context, AttributeSet attrs) {
21 | super(context, attrs);
22 | }
23 |
24 | @Override
25 | protected void init(Context context) {
26 | super.init(context);
27 | image = (ImageView)findViewById(R.id.image);
28 |
29 | setOrientation(LinearLayout.VERTICAL);
30 | }
31 |
32 | public ImageView getImageView() {
33 | return image;
34 | }
35 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 50dp
4 | 50dp
5 | 50dp
6 | 20dp
7 | 72dp
8 | 2dp
9 | 120dp
10 | 15dp
11 | 5dp
12 | 300dp
13 | 48dp
14 | 100dp
15 | 200dp
16 | 200
17 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/tasks/SendPlainTextTask.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.tasks;
2 |
3 | import android.content.ContentValues;
4 | import android.content.Context;
5 |
6 | import com.mstr.letschat.SmackInvocationException;
7 | import com.mstr.letschat.databases.ChatMessageTableHelper;
8 | import com.mstr.letschat.tasks.Response.Listener;
9 | import com.mstr.letschat.xmpp.SmackHelper;
10 |
11 | public class SendPlainTextTask extends SendMessageTask {
12 | public SendPlainTextTask(Listener listener, Context context, String to, String nickname, String body) {
13 | super(listener, context, to, nickname, body);
14 | }
15 |
16 | @Override
17 | protected ContentValues newMessage(long timeMillis) {
18 | return ChatMessageTableHelper.newPlainTextMessage(to, body, timeMillis, true);
19 | }
20 |
21 | @Override
22 | protected void doSend(Context context) throws SmackInvocationException {
23 | SmackHelper.getInstance(context).sendChatMessage(to, body, null);
24 | }
25 | }
--------------------------------------------------------------------------------
/library/memorizingTrustManager/src/main/res/values-no/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Godta ukjent sertifikat?
4 | Sertifikatet er ikke utstilt av en kjent utstiller (CA).
5 | The server certificate is expired.
6 | Godta feil servernavn?
7 | Serveren heter ikke \"%s\". Sertifikatet gjelder bare for:
8 |
9 | Vil du bruke serveren likevel?
10 | Sertifikatdetaljer:
11 |
12 | Alltid
13 | En gang
14 | Avbryt
15 |
16 | Sertifikat-sjekk
17 |
18 |
--------------------------------------------------------------------------------
/LetsChat.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/views/PlainTextView.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.views;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.LinearLayout;
6 | import android.widget.TextView;
7 |
8 | import com.mstr.letschat.R;
9 |
10 | /**
11 | * Created by dilli on 12/1/2015.
12 | */
13 | public abstract class PlainTextView extends MessageView {
14 | protected TextView messageText;
15 |
16 | public PlainTextView(Context context) {
17 | this(context, null);
18 | }
19 |
20 | public PlainTextView(Context context, AttributeSet attrs) {
21 | super(context, attrs);
22 | }
23 |
24 | public void setMessageText(String text) {
25 | messageText.setText(text);
26 | }
27 |
28 | @Override
29 | protected void init(Context context) {
30 | super.init(context);
31 | messageText = (TextView)findViewById(R.id.tv_message);
32 |
33 | setOrientation(LinearLayout.VERTICAL);
34 | }
35 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/SettingsActivity.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat;
2 |
3 | import android.os.Bundle;
4 | import android.view.MenuItem;
5 |
6 | import java.util.List;
7 |
8 | public class SettingsActivity extends AppCompatPreferenceActivity {
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 |
13 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
14 | }
15 |
16 | @Override
17 | public void onBuildHeaders(List target) {
18 | loadHeadersFromResource(R.xml.preference_headers, target);
19 | }
20 |
21 | @Override
22 | protected boolean isValidFragment(String fragmentName) {
23 | return true;
24 | }
25 |
26 |
27 | @Override
28 | public boolean onOptionsItemSelected(MenuItem item) {
29 | switch (item.getItemId()) {
30 | case android.R.id.home:
31 | onBackPressed();
32 | return true;
33 | }
34 |
35 | return super.onOptionsItemSelected(item);
36 | }
37 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/receivers/NetworkReceiver.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.receivers;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.net.ConnectivityManager;
7 |
8 | import com.mstr.letschat.service.MessageService;
9 | import com.mstr.letschat.utils.NetworkUtils;
10 |
11 | public class NetworkReceiver extends BroadcastReceiver {
12 | public static final String EXTRA_DATA_NAME_NETWORK_CONNECTED = "com.mstr.letschat.NetworkConnected";
13 |
14 | @Override
15 | public void onReceive(Context context, Intent intent) {
16 | String action = intent.getAction();
17 | if (ConnectivityManager.CONNECTIVITY_ACTION.equals(action)) {
18 | Intent serviceIntent = new Intent(MessageService.ACTION_NETWORK_STATUS, null, context, MessageService.class);
19 | serviceIntent.putExtra(EXTRA_DATA_NAME_NETWORK_CONNECTED, NetworkUtils.isNetworkConnected(context));
20 | context.startService(serviceIntent);
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/tasks/LoadStatusTask.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.tasks;
2 |
3 | import android.content.Context;
4 |
5 | import com.mstr.letschat.SmackInvocationException;
6 | import com.mstr.letschat.tasks.Response.Listener;
7 | import com.mstr.letschat.utils.AppLog;
8 | import com.mstr.letschat.xmpp.SmackHelper;
9 |
10 | public class LoadStatusTask extends BaseAsyncTask {
11 | public LoadStatusTask(Listener listener, Context context) {
12 | super(listener, context);
13 | }
14 |
15 | @Override
16 | protected Response doInBackground(Void... params) {
17 | Context context = getContext();
18 | if (context != null) {
19 | try {
20 | return Response.success(SmackHelper.getInstance(context).loadStatus());
21 | } catch (SmackInvocationException e) {
22 | AppLog.e(String.format("get login user status error %s", e.toString()), e);
23 |
24 | return Response.error(e);
25 | }
26 | } else {
27 | return null;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/library/memorizingTrustManager/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Accept Unknown Certificate?
4 | The server certificate is not signed by a known Certificate Authority.
5 | The server certificate is expired.
6 | Accept Mismatching Server Name?
7 | Server could not authenticate as \"%s\". The certificate is only valid for:
8 |
9 | Do you want to connect anyway?
10 | Certificate details:
11 |
12 | Always
13 | Once
14 | Abort
15 |
16 | Certificate Verification
17 |
18 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/location_text_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
18 |
19 |
25 |
--------------------------------------------------------------------------------
/library/memorizingTrustManager/src/main/res/values-de/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Unbekanntes Zertifikat akzeptieren?
4 | Das Serverzertifikat stammt nicht von einer bekannten Ausstellungsstelle (CA).
5 | Das Serverzertifikat ist abgelaufen.
6 | Abweichenden Servernamen akzeptieren?
7 | Der Server konnte sich nicht als »%s« ausweisen. Das Zertifikat gilt nur für:
8 |
9 | Verbindung trotzdem aufbauen?
10 | Zertifikatdetails:
11 |
12 | Immer
13 | Einmal
14 | Abbrechen
15 |
16 | Zertifikatsüberprüfung
17 |
18 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/menu/conversation_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/utils/NotificationUtils.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.utils;
2 |
3 | import android.app.Notification;
4 | import android.app.NotificationManager;
5 | import android.app.PendingIntent;
6 | import android.content.Context;
7 | import android.support.v4.app.NotificationCompat;
8 |
9 | import com.mstr.letschat.R;
10 |
11 | public class NotificationUtils {
12 | public static void notify(Context context, String title, String text, int id, PendingIntent pendingIntent) {
13 | NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
14 | .setSmallIcon(R.drawable.ic_notification)
15 | .setContentTitle(title)
16 | .setContentText(text)
17 | .setContentIntent(pendingIntent)
18 | .setAutoCancel(true);
19 |
20 | Notification notification = builder.build();
21 | notification.defaults = Notification.DEFAULT_ALL;
22 | NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
23 | notificationManager.notify(id, notification);
24 | }
25 | }
--------------------------------------------------------------------------------
/library/memorizingTrustManager/src/main/res/values-tr/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Bilinmeyen Sertifikayı Kabul Ediyor musunuz?
4 | Sunucu Sertifikası bilinen bir Sertifika Otoritesi tarafından imzalanmamıştır.
5 | The server certificate is expired.
6 | Eşleşmeyen Sunucu İsmi Kabul Edilsin mi?
7 | Sunucu \"%s\" olarak kimliğini teyit edemedi. Sertifika sadece şunun için geçerlidir:
8 |
9 | Gene de bağlanmak istiyor musunuz?
10 | Sertifika detayları:
11 |
12 | Daima
13 | Bir defa
14 | İptal
15 |
16 | Sertifika Teyidi
17 |
18 |
--------------------------------------------------------------------------------
/letsChat/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion '23.0.0'
6 |
7 | defaultConfig {
8 | applicationId "com.mstr.letschat"
9 | minSdkVersion 14
10 | targetSdkVersion 21
11 | }
12 |
13 | buildTypes {
14 | release {
15 | minifyEnabled true
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile project(':library:memorizingTrustManager')
23 | compile project(':library:cropImage')
24 | compile files('libs/asmack-android-8-4.0.6.jar')
25 | compile files('libs/dnsjava-2.1.6.jar')
26 | compile 'com.google.android.gms:play-services-maps:8.3.0'
27 | compile 'com.google.android.gms:play-services-location:8.3.0'
28 | compile 'com.android.support:cardview-v7:23.1.0'
29 | compile 'com.android.support:design:23.1.0'
30 | compile 'com.android.support:appcompat-v7:23.1.0'
31 | compile 'com.android.support:support-v13:23.1.0'
32 | }
--------------------------------------------------------------------------------
/library/memorizingTrustManager/src/main/res/values-es/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ¿Aceptar certicado desconocido?
4 | El certificado del servidor no está firmado por una Autoridad Conocida (CA).
5 | The server certificate is expired.
6 | ¿Aceptar discordancia en nombre del servidor?
7 | El servidor no ha podido autenticarte como \"%s\". El certificado es solo válido para:
8 |
9 | ¿Quieres conectar de todas formas?
10 | Detalle del certificado:
11 |
12 | Siempre
13 | Una vez
14 | Abortar
15 |
16 | Verificación de Certificado
17 |
18 |
--------------------------------------------------------------------------------
/library/memorizingTrustManager/src/main/res/values-eu/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Ziurtagiri ezezaguna onartu?
4 | Zerbitzariaren ziurtagiria ez dago Ziurtagiri-emaile Autoritate ezagun batez sinatuta.
5 | Zerbitzariaren ziurtagiria iraungi da.
6 | Zerbitzariaren izeneko desadostasuna onartu?
7 | Zerbitzaria ezin izan da \"%s\" bezala autentifikatu. Ziurtagiria soilik honetarako baliagarria da:
8 |
9 | Konektatu hala ere?
10 | Ziurtagiriaren xehetasunak:
11 |
12 | Beti
13 | Behin
14 | Utzi
15 |
16 | Ziurtagiriaren egiaztapena
17 |
18 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/tasks/DeleteContactTask.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.tasks;
2 |
3 | import android.content.Context;
4 |
5 | import com.mstr.letschat.SmackInvocationException;
6 | import com.mstr.letschat.tasks.Response.Listener;
7 | import com.mstr.letschat.xmpp.SmackHelper;
8 |
9 | public class DeleteContactTask extends BaseAsyncTask {
10 | private String jid;
11 |
12 | public DeleteContactTask(Listener listener, Context context, String jid) {
13 | super(listener, context);
14 |
15 | this.jid = jid;
16 | }
17 |
18 | @Override
19 | protected Response doInBackground(Void... params) {
20 | Context context = getContext();
21 |
22 | if (context != null) {
23 | try {
24 | SmackHelper.getInstance(context).delete(jid);
25 |
26 | //ContactTableHelper.getInstance(context).delete(jid);
27 |
28 | return Response.success(true);
29 | } catch(SmackInvocationException e) {
30 | return Response.error(e);
31 | }
32 | } else {
33 | return null;
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/views/OutgoingPlainTextView.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.views;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 | import android.widget.ProgressBar;
7 |
8 | import com.mstr.letschat.R;
9 |
10 | public class OutgoingPlainTextView extends PlainTextView {
11 | private ProgressBar progressBar;
12 |
13 | public OutgoingPlainTextView(Context context) {
14 | this(context, null);
15 | }
16 |
17 | public OutgoingPlainTextView(Context context, AttributeSet attrs) {
18 | super(context, attrs);
19 | }
20 |
21 | @Override
22 | public void init(Context context) {
23 | super.init(context);
24 |
25 | progressBar = (ProgressBar)findViewById(R.id.sending_progress);
26 | }
27 |
28 |
29 | protected int getLayoutResource() {
30 | return R.layout.outgoing_plain_text_view;
31 | }
32 |
33 | @Override
34 | public void showProgress(boolean sent) {
35 | if (sent) {
36 | progressBar.setVisibility(View.INVISIBLE);
37 | } else {
38 | progressBar.setVisibility(View.VISIBLE);
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/incoming_plain_text_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/library/memorizingTrustManager/src/main/res/values-fi/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hyväksytäänkö palvelimen antama tuntematon varmenne?
4 | Palvelimen varmenne ei ole tunnetun varmentajan (CA) allekirjoittama.
5 | The server certificate is expired.
6 | Sallitaanko palvelimen nimi, joka ei vastaa varmeenteessa olevaa nimeä?
7 | Palvelimella ei ole varmennetta nimelle \"%s\". Varmenteen sisältämät nimet:
8 |
9 | Haluatko jatkaa yhteyden muodostamista?
10 | Sertifikaatin tiedot:
11 |
12 | Aina
13 | Kerran
14 | Keskeytä
15 |
16 | Varmenteen tarkistus
17 |
18 |
--------------------------------------------------------------------------------
/library/memorizingTrustManager/src/main/res/values-fr/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Accepter les certificats inconnus ?
4 | Le certificat du serveur n’est pas signé par une Autorité de Certification reconnue.
5 | Le certificat a expiré.
6 | Accepter le nom de serveur qui ne concorde pas ?
7 | Le serveur n\'a pas pu s\'authentifier comme « %s ». Le certificat est valide uniquement pour :
8 |
9 | Voulez-vous vous connecter quand même ?
10 | Détails du certificat :
11 |
12 | Toujours
13 | Une seule fois
14 | Annuler
15 |
16 | Vérification du certificat
17 |
18 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/ServerSettingsActivity.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat;
2 |
3 | import android.os.Bundle;
4 | import android.preference.PreferenceFragment;
5 |
6 | /**
7 | * Created by dilli on 7/10/2015.
8 | */
9 | public class ServerSettingsActivity extends AppCompatPreferenceActivity {
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 |
14 | if (savedInstanceState == null) {
15 | // Display the fragment as the main content.
16 | getFragmentManager().beginTransaction().replace(android.R.id.content,
17 | new ServerPreferenceFragment()).commit();
18 | }
19 | }
20 |
21 | public static class ServerPreferenceFragment extends PreferenceFragment {
22 |
23 | @Override
24 | public void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 |
27 | // Load the preferences from an XML resource
28 | addPreferencesFromResource(R.xml.server_preference);
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout-v21/preference_user_avatar.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
20 |
26 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/preference_user_avatar.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
20 |
26 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
21 |
22 |
30 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/views/OutgoingLocationView.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.views;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 | import android.widget.ProgressBar;
7 |
8 | import com.mstr.letschat.R;
9 |
10 | /**
11 | * Created by dilli on 12/2/2015.
12 | */
13 | public class OutgoingLocationView extends LocationView {
14 | private ProgressBar progressBar;
15 |
16 | public OutgoingLocationView(Context context) {
17 | this(context, null);
18 | }
19 |
20 | public OutgoingLocationView(Context context, AttributeSet attrs) {
21 | super(context, attrs);
22 | }
23 |
24 | @Override
25 | protected void init(Context context) {
26 | super.init(context);
27 |
28 | progressBar = (ProgressBar)findViewById(R.id.sending_progress);
29 | }
30 |
31 | public void showProgress(boolean sent) {
32 | if (sent) {
33 | progressBar.setVisibility(View.INVISIBLE);
34 | } else {
35 | progressBar.setVisibility(View.VISIBLE);
36 | }
37 | }
38 |
39 | @Override
40 | protected int getLayoutResource() {
41 | return R.layout.outgoing_location_view;
42 | }
43 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout-v21/preference_username.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
20 |
28 |
--------------------------------------------------------------------------------
/library/library.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/preference_username.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
20 |
28 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/fragments/ProfileFragment.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.fragments;
2 |
3 | import android.graphics.drawable.BitmapDrawable;
4 | import android.os.Bundle;
5 | import android.preference.PreferenceFragment;
6 |
7 | import com.mstr.letschat.R;
8 | import com.mstr.letschat.model.LoginUserProfile;
9 | import com.mstr.letschat.tasks.LoadProfileTask;
10 | import com.mstr.letschat.tasks.Response.Listener;
11 | import com.mstr.letschat.utils.PreferenceUtils;
12 |
13 | public class ProfileFragment extends PreferenceFragment implements Listener {
14 | @Override
15 | public void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 |
18 | addPreferencesFromResource(R.xml.profile_preferences);
19 |
20 | new LoadProfileTask(this, getActivity()).execute();
21 | }
22 |
23 | @Override
24 | public void onResponse(LoginUserProfile profile) {
25 | if (profile != null) {
26 | findPreference(PreferenceUtils.AVATAR).setIcon(new BitmapDrawable(getResources(), profile.getAvatar()));
27 | findPreference(PreferenceUtils.NICKNAME).setSummary(profile.getNickname());
28 | }
29 | }
30 |
31 | @Override
32 | public void onErrorResponse(Exception exception) {}
33 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/views/OutgoingImageMessageView.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.views;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 | import android.widget.ProgressBar;
7 |
8 | import com.mstr.letschat.R;
9 |
10 | /**
11 | * Created by dilli on 1/29/2016.
12 | */
13 | public class OutgoingImageMessageView extends ImageMessageView {
14 | private ProgressBar progressBar;
15 |
16 | public OutgoingImageMessageView(Context context) {
17 | super(context);
18 | }
19 |
20 | public OutgoingImageMessageView(Context context, AttributeSet attrs) {
21 | super(context, attrs);
22 | }
23 |
24 | @Override
25 | protected void init(Context context) {
26 | super.init(context);
27 |
28 | progressBar = (ProgressBar)findViewById(R.id.sending_progress);
29 | }
30 |
31 | @Override
32 | protected int getLayoutResource() {
33 | return R.layout.outgoing_image_view;
34 | }
35 |
36 | @Override
37 | public void showProgress(boolean sent) {
38 | if (sent) {
39 | progressBar.setVisibility(View.INVISIBLE);
40 | } else {
41 | progressBar.setVisibility(View.VISIBLE);
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/tasks/BaseAsyncTask.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.tasks;
2 |
3 | import java.lang.ref.WeakReference;
4 |
5 | import android.content.Context;
6 | import android.os.AsyncTask;
7 |
8 | import com.mstr.letschat.tasks.Response.Listener;
9 |
10 | public abstract class BaseAsyncTask extends AsyncTask> {
11 | private WeakReference> listenerWrapper;
12 | private WeakReference contextWrapper;
13 |
14 | public BaseAsyncTask(Listener listener, Context context) {
15 | listenerWrapper = new WeakReference>(listener);
16 | contextWrapper = new WeakReference(context);
17 | }
18 |
19 | protected Listener getListener() {
20 | return listenerWrapper.get();
21 | }
22 |
23 | protected Context getContext() {
24 | return contextWrapper.get();
25 | }
26 |
27 | @Override
28 | protected void onPostExecute(Response response) {
29 | Listener listener = getListener();
30 |
31 | if (listener != null && response != null) {
32 | if (response.isSuccess()) {
33 | listener.onResponse(response.getResult());
34 | } else {
35 | listener.onErrorResponse(response.getException());
36 | }
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/fragments/NetworkUsageFragment.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.fragments;
2 |
3 | import android.os.Bundle;
4 | import android.preference.PreferenceFragment;
5 |
6 | import com.mstr.letschat.R;
7 | import com.mstr.letschat.utils.NetworkUtils;
8 | import com.mstr.letschat.utils.NetworkUtils.RxTxBytes;
9 | import com.mstr.letschat.utils.PreferenceUtils;
10 |
11 | /**
12 | * Created by dilli on 7/8/2015.
13 | */
14 | public class NetworkUsageFragment extends PreferenceFragment {
15 | public static final long KB_IN_BYTES = 1024;
16 |
17 | @Override
18 | public void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 |
21 | addPreferencesFromResource(R.xml.network_traffic_preferences);
22 |
23 | populateStatsFields();
24 | }
25 |
26 | private void populateStatsFields() {
27 | RxTxBytes rxTxBytes = NetworkUtils.getTotalRxTxBytes(getActivity());
28 | if (rxTxBytes != null) {
29 | String unit = " " + getString(R.string.traffic_unit);
30 | findPreference(PreferenceUtils.TRAFFIC_TRANSMITTED).setSummary(Long.toString(rxTxBytes.txBytes / KB_IN_BYTES) + unit);
31 | findPreference(PreferenceUtils.TRAFFIC_RECEIVED).setSummary(Long.toString(rxTxBytes.rxBytes / KB_IN_BYTES) + unit);
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/tasks/SendLocationTask.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.tasks;
2 |
3 | import android.content.ContentValues;
4 | import android.content.Context;
5 |
6 | import com.mstr.letschat.SmackInvocationException;
7 | import com.mstr.letschat.databases.ChatMessageTableHelper;
8 | import com.mstr.letschat.xmpp.SmackHelper;
9 | import com.mstr.letschat.xmpp.UserLocation;
10 |
11 | import org.jivesoftware.smack.packet.PacketExtension;
12 |
13 | /**
14 | * Created by dilli on 11/27/2015.
15 | */
16 | public class SendLocationTask extends SendMessageTask {
17 | private UserLocation location;
18 | protected PacketExtension packetExtension;
19 |
20 | public SendLocationTask(Response.Listener listener, Context context, String to, String nickname, UserLocation location) {
21 | super(listener, context, to, nickname, location.getName());
22 |
23 | this.location = location;
24 | packetExtension = location;
25 | }
26 |
27 | @Override
28 | protected ContentValues newMessage(long timeMillis) {
29 | return ChatMessageTableHelper.newLocationMessage(to, body, timeMillis, location, true);
30 | }
31 |
32 | @Override
33 | protected void doSend(Context context) throws SmackInvocationException {
34 | SmackHelper.getInstance(context).sendChatMessage(to, body, packetExtension);
35 | }
36 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/contact_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
15 |
16 |
20 |
21 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/xmpp/PresencePacketListener.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.xmpp;
2 |
3 | import org.jivesoftware.smack.PacketListener;
4 | import org.jivesoftware.smack.packet.Packet;
5 | import org.jivesoftware.smack.packet.Presence;
6 | import org.jivesoftware.smack.util.StringUtils;
7 |
8 | import android.content.Context;
9 | import android.content.Intent;
10 |
11 | import com.mstr.letschat.service.MessageService;
12 |
13 | public class PresencePacketListener implements PacketListener {
14 | public static final String EXTRA_DATA_NAME_TYPE = "com.mstr.letschat.Type";
15 | public static final String EXTRA_DATA_NAME_STATUS = "com.mstr.letschat.Status";
16 |
17 | private Context context;
18 |
19 | public PresencePacketListener(Context context) {
20 | this.context = context;
21 | }
22 |
23 | @Override
24 | public void processPacket(Packet packet){
25 | Presence presence = (Presence)packet;
26 | Presence.Type presenceType = presence.getType();
27 |
28 | Intent intent = new Intent(MessageService.ACTION_PRESENCE_RECEIVED, null, context, MessageService.class);
29 | intent.putExtra(MessageService.EXTRA_DATA_NAME_FROM, StringUtils.parseBareAddress(presence.getFrom()));
30 | intent.putExtra(EXTRA_DATA_NAME_TYPE, presenceType.ordinal());
31 | String status = presence.getStatus();
32 | if (status != null) {
33 | intent.putExtra(EXTRA_DATA_NAME_STATUS, presence.getStatus());
34 | }
35 | context.startService(intent);
36 | }
37 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/tasks/SendContactRequestTask.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.tasks;
2 |
3 | import java.lang.ref.WeakReference;
4 |
5 | import android.content.Context;
6 |
7 | import com.mstr.letschat.SmackInvocationException;
8 | import com.mstr.letschat.model.UserProfile;
9 | import com.mstr.letschat.tasks.Response.Listener;
10 | import com.mstr.letschat.utils.AppLog;
11 | import com.mstr.letschat.xmpp.SmackHelper;
12 |
13 | public class SendContactRequestTask extends BaseAsyncTask {
14 | private WeakReference userProfileWrapper;
15 |
16 | public SendContactRequestTask(Listener listener, Context context, UserProfile userProfile) {
17 | super(listener, context);
18 |
19 | userProfileWrapper = new WeakReference(userProfile);
20 | }
21 |
22 | @Override
23 | protected Response doInBackground(Void... params) {
24 | Context context = getContext();
25 | UserProfile userProfile = userProfileWrapper.get();
26 | if (context != null && userProfile != null) {
27 | try {
28 | SmackHelper.getInstance(context).requestSubscription(userProfile.getJid(), userProfile.getNickname());
29 |
30 | return Response.success(true);
31 | } catch (SmackInvocationException e) {
32 | AppLog.e(String.format("send contact request to %s error", userProfile.getJid()), e);
33 |
34 | return Response.error(e);
35 | }
36 | } else {
37 | return null;
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/receivers/IncomingContactRequestReceiver.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.receivers;
2 |
3 | import android.app.PendingIntent;
4 | import android.content.BroadcastReceiver;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.support.v4.app.TaskStackBuilder;
8 |
9 | import com.mstr.letschat.ContactRequestListActivity;
10 | import com.mstr.letschat.R;
11 | import com.mstr.letschat.service.MessageService;
12 | import com.mstr.letschat.utils.NotificationUtils;
13 |
14 | public class IncomingContactRequestReceiver extends BroadcastReceiver {
15 | public static int INCOMING_CONTACT_REQUEST_NOTIFICATION_ID = 1;
16 |
17 | @Override
18 | public void onReceive(Context context, Intent intent) {
19 | String action = intent.getAction();
20 | if (action != null && action.equals(MessageService.ACTION_CONTACT_REQUEST_RECEIVED)) {
21 | TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
22 | stackBuilder.addParentStack(ContactRequestListActivity.class);
23 | stackBuilder.addNextIntent(new Intent(context, ContactRequestListActivity.class));
24 |
25 | PendingIntent pendingIntent = stackBuilder.getPendingIntent(1, PendingIntent.FLAG_UPDATE_CURRENT);
26 |
27 | NotificationUtils.notify(context, context.getString(R.string.app_name),
28 | intent.getStringExtra(MessageService.EXTRA_DATA_NAME_NOTIFICATION_TEXT),
29 | INCOMING_CONTACT_REQUEST_NOTIFICATION_ID, pendingIntent);
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
27 |
28 |
29 |
34 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/activity_startup.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
23 |
24 |
31 |
32 |
37 |
38 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/contact_request_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
15 |
16 |
21 |
22 |
26 |
27 |
28 |
43 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/databases/ChatDbHelper.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.databases;
2 |
3 | import android.content.Context;
4 | import android.database.sqlite.SQLiteDatabase;
5 | import android.database.sqlite.SQLiteOpenHelper;
6 |
7 | public class ChatDbHelper extends SQLiteOpenHelper {
8 | public static final int DATABASE_VERSION = 2;
9 | public static final String DATABASE_NAME = "chat.db";
10 |
11 | public static final String TEXT_TYPE = " TEXT";
12 | public static final String INTEGER_TYPE = " INTEGER";
13 | public static final String COMMA_SEP = ",";
14 |
15 | private static ChatDbHelper instance;
16 |
17 | public static synchronized ChatDbHelper getInstance(Context context) {
18 | if (instance == null) {
19 | instance = new ChatDbHelper(context.getApplicationContext());
20 | }
21 |
22 | return instance;
23 | }
24 |
25 | public ChatDbHelper(Context context) {
26 | super(context, DATABASE_NAME, null, DATABASE_VERSION);
27 | }
28 |
29 | @Override
30 | public void onCreate(SQLiteDatabase db) {
31 | ContactTableHelper.onCreate(db);
32 | ChatMessageTableHelper.onCreate(db);
33 | ContactRequestTableHelper.onCreate(db);
34 | ConversationTableHelper.onCreate(db);
35 | }
36 |
37 | @Override
38 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
39 | if (newVersion == 2) {
40 | updateToVersion2(db);
41 | return;
42 | }
43 | }
44 |
45 | private void updateToVersion2(SQLiteDatabase db) {
46 | ChatMessageTableHelper.updateToVersion2(db);
47 | }
48 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/outgoing_plain_text_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
16 |
17 |
23 |
24 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/adapters/StatusListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.adapters;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.ArrayAdapter;
8 | import android.widget.TextView;
9 |
10 | import com.mstr.letschat.R;
11 |
12 | public class StatusListAdapter extends ArrayAdapter {
13 | private int primaryTextColor;
14 | private int selectedTextColor;
15 |
16 | private int selectedPosition = -1;
17 |
18 | public StatusListAdapter(Context context, String[] statusItems) {
19 | super(context, android.R.layout.simple_list_item_1, statusItems);
20 |
21 | TypedArray a = context.obtainStyledAttributes(new int[] {android.R.attr.textColorPrimary});
22 | primaryTextColor = a.getColor(0, 0);
23 | a.recycle();
24 |
25 | selectedTextColor = context.getResources().getColor(R.color.selected_status);
26 | }
27 |
28 | @Override
29 | public View getView(int position, View convertView, ViewGroup parent) {
30 | TextView textView = (TextView)super.getView(position, convertView, parent);
31 |
32 | textView.setTextColor(position == selectedPosition ? selectedTextColor : primaryTextColor);
33 |
34 | return textView;
35 | }
36 |
37 | public void setSelection(int position) {
38 | if (selectedPosition != position) {
39 | selectedPosition = position;
40 |
41 | notifyDataSetChanged();
42 | }
43 | }
44 |
45 | public void setSelection(String status) {
46 | int position = getPosition(status);
47 |
48 | setSelection(position);
49 | }
50 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/incoming_location_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
12 |
13 |
23 |
24 |
29 |
30 |
31 |
32 |
33 |
37 |
38 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/model/Contact.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.model;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | public class Contact implements Parcelable {
7 | private int id;
8 | private String jid;
9 | private String nickname;
10 |
11 | public Contact() {}
12 |
13 | public Contact(int id, String jid, String nickname) {
14 | this.id = id;
15 | this.nickname = nickname;
16 | this.jid = jid;
17 | }
18 |
19 | public Contact(Parcel source) {
20 | id = source.readInt();
21 | jid = source.readString();
22 | nickname = source.readString();
23 | }
24 |
25 | public int getId() {
26 | return id;
27 | }
28 |
29 | public void setId(int id) {
30 | this.id = id;
31 | }
32 |
33 | public String getNickname() {
34 | return nickname;
35 | }
36 |
37 | public void setNickname(String name) {
38 | this.nickname = name;
39 | }
40 |
41 | public String getJid() {
42 | return jid;
43 | }
44 |
45 | public void setJid(String jid) {
46 | this.jid = jid;
47 | }
48 |
49 | @Override
50 | public int describeContents() {
51 | return 0;
52 | }
53 |
54 | @Override
55 | public void writeToParcel(Parcel dest, int flags) {
56 | dest.writeInt(id);
57 | dest.writeString(jid);
58 | dest.writeString(nickname);
59 | }
60 |
61 | public static final Parcelable.Creator CREATOR = new Creator() {
62 |
63 | @Override
64 | public Contact createFromParcel(Parcel source) {
65 | return new Contact(source);
66 | }
67 |
68 | @Override
69 | public Contact[] newArray(int size) {
70 | return new Contact[size];
71 | }
72 | };
73 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/utils/ProviderUtils.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.utils;
2 |
3 | import android.content.ContentProviderOperation;
4 | import android.content.ContentProviderResult;
5 | import android.content.Context;
6 | import android.database.SQLException;
7 |
8 | import com.mstr.letschat.databases.ChatContract.ContactRequestTable;
9 | import com.mstr.letschat.databases.ChatContract.ContactTable;
10 | import com.mstr.letschat.databases.ContactRequestTableHelper;
11 | import com.mstr.letschat.databases.ContactTableHelper;
12 | import com.mstr.letschat.providers.DatabaseContentProvider;
13 |
14 | import java.util.ArrayList;
15 |
16 | public class ProviderUtils {
17 | /**
18 | * Save new contact to db, and update request status as accepted
19 | *
20 | * @param context
21 | * @param jid
22 | * @param nickname
23 | * @return
24 | */
25 | public static ContentProviderResult[] addNewContact(Context context, String jid, String nickname, String status) {
26 | ArrayList operations = new ArrayList();
27 | operations.add(ContentProviderOperation.newInsert(ContactTable.CONTENT_URI).
28 | withValues(ContactTableHelper.newContentValues(jid, nickname, status)).build());
29 | operations.add(ContentProviderOperation.newUpdate(ContactRequestTable.CONTENT_URI).
30 | withValues(ContactRequestTableHelper.newContentValuesWithAcceptedStatus()).
31 | withSelection(ContactRequestTable.COLUMN_NAME_JID + " = ?", new String[]{jid}).build());
32 | try {
33 | return context.getContentResolver().applyBatch(DatabaseContentProvider.AUTHORITY, operations);
34 | } catch (Exception e) {
35 | throw new SQLException("Failed to add contact");
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/library/memorizingTrustManager/src/main/java/de/duenndns/ssl/MTMDecision.java:
--------------------------------------------------------------------------------
1 | /* MemorizingTrustManager - a TrustManager which asks the user about invalid
2 | * certificates and memorizes their decision.
3 | *
4 | * Copyright (c) 2010 Georg Lukas
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | package de.duenndns.ssl;
25 |
26 | class MTMDecision {
27 | public final static int DECISION_INVALID = 0;
28 | public final static int DECISION_ABORT = 1;
29 | public final static int DECISION_ONCE = 2;
30 | public final static int DECISION_ALWAYS = 3;
31 |
32 | int state = DECISION_INVALID;
33 | }
34 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/databases/ContactTableHelper.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.databases;
2 |
3 | import android.content.ContentValues;
4 | import android.database.sqlite.SQLiteDatabase;
5 |
6 | import com.mstr.letschat.databases.ChatContract.ContactTable;
7 |
8 | public class ContactTableHelper {
9 | private static final String SQL_CREATE_ENTRIES =
10 | "CREATE TABLE " + ContactTable.TABLE_NAME + " (" +
11 | ContactTable._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
12 | ContactTable.COLUMN_NAME_JID + ChatDbHelper.TEXT_TYPE + ChatDbHelper.COMMA_SEP +
13 | ContactTable.COLUMN_NAME_NICKNAME + ChatDbHelper.TEXT_TYPE + ChatDbHelper.COMMA_SEP +
14 | ContactTable.COLUMN_NAME_STATUS + ChatDbHelper.TEXT_TYPE +
15 | " )";
16 |
17 | private static final String SQL_DELETE_ENTRIES =
18 | "DROP TABLE IF EXISTS " + ContactTable.TABLE_NAME;
19 |
20 | public static void onCreate(SQLiteDatabase database) {
21 | database.execSQL(SQL_CREATE_ENTRIES);
22 | }
23 |
24 | public static void onUpgrade(SQLiteDatabase database) {
25 | database.execSQL(SQL_DELETE_ENTRIES);
26 | }
27 |
28 | public static ContentValues newContentValues(String jid, String nickname, String status) {
29 | ContentValues values = new ContentValues();
30 | values.put(ContactTable.COLUMN_NAME_JID, jid);
31 | values.put(ContactTable.COLUMN_NAME_NICKNAME, nickname);
32 | values.put(ContactTable.COLUMN_NAME_STATUS, status);
33 |
34 | return values;
35 | }
36 |
37 | public static ContentValues newUpdateStatusContentValues(String status) {
38 | ContentValues values = new ContentValues();
39 | values.put(ContactTable.COLUMN_NAME_STATUS, status);
40 |
41 | return values;
42 | }
43 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/incoming_image_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
21 |
22 |
27 |
28 |
34 |
35 |
36 |
40 |
41 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/user_search_result_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
17 |
18 |
22 |
23 |
28 |
29 |
33 |
34 |
35 |
49 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/tasks/SearchUserTask.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.tasks;
2 |
3 | import android.content.Context;
4 | import android.database.Cursor;
5 |
6 | import com.mstr.letschat.SmackInvocationException;
7 | import com.mstr.letschat.databases.ChatContract.ContactTable;
8 | import com.mstr.letschat.model.UserProfile;
9 | import com.mstr.letschat.tasks.Response.Listener;
10 | import com.mstr.letschat.utils.AppLog;
11 | import com.mstr.letschat.utils.PreferenceUtils;
12 | import com.mstr.letschat.xmpp.SmackHelper;
13 |
14 | public class SearchUserTask extends BaseAsyncTask {
15 | private String username;
16 |
17 | public SearchUserTask(Listener listener, Context context, String username) {
18 | super(listener,context);
19 |
20 | this.username = username;
21 | }
22 |
23 | @Override
24 | protected Response doInBackground(Void... params) {
25 | Context context = getContext();
26 | if (context != null) {
27 | try {
28 | UserProfile user = SmackHelper.getInstance(context).search(username);
29 | if (user != null) {
30 | if (user.getUserName().equals(PreferenceUtils.getUser(context))) {
31 | user.setType(UserProfile.TYPE_MYSELF);
32 | } else {
33 | Cursor c = context.getContentResolver().query(ContactTable.CONTENT_URI, new String[]{ContactTable._ID},
34 | ContactTable.COLUMN_NAME_JID + " = ?", new String[] {user.getJid()}, null);
35 | if (c.moveToFirst()) {
36 | user.setType(UserProfile.TYPE_CONTACT);
37 | } else {
38 | user.setType(UserProfile.TYPE_NOT_CONTACT);
39 | }
40 | }
41 | }
42 |
43 | return Response.success(user);
44 | } catch(SmackInvocationException e) {
45 | AppLog.e(String.format("search user error %s", e.toString()), e);
46 |
47 | return Response.error(e);
48 | }
49 | } else {
50 | return null;
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/utils/Utils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.mstr.letschat.utils;
18 |
19 | import android.os.Build;
20 | import android.os.Build.VERSION_CODES;
21 |
22 | /**
23 | * Class containing some static utility methods.
24 | */
25 | public class Utils {
26 | private Utils() {};
27 |
28 | public static boolean hasFroyo() {
29 | // Can use static final constants like FROYO, declared in later versions
30 | // of the OS since they are inlined at compile time. This is guaranteed behavior.
31 | return Build.VERSION.SDK_INT >= VERSION_CODES.FROYO;
32 | }
33 |
34 | public static boolean hasGingerbread() {
35 | return Build.VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD;
36 | }
37 |
38 | public static boolean hasHoneycomb() {
39 | return Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB;
40 | }
41 |
42 | public static boolean hasHoneycombMR1() {
43 | return Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1;
44 | }
45 |
46 | public static boolean hasJellyBean() {
47 | return Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN;
48 | }
49 |
50 | public static boolean hasKitKat() {
51 | return Build.VERSION.SDK_INT >= VERSION_CODES.KITKAT;
52 | }
53 |
54 | public static boolean hasLollipop() {
55 | return Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP;
56 | }
57 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/adapters/ContactCursorAdapter.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.adapters;
2 |
3 | import android.content.Context;
4 | import android.database.Cursor;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.ImageView;
8 | import android.widget.ResourceCursorAdapter;
9 | import android.widget.TextView;
10 |
11 | import com.mstr.letschat.R;
12 | import com.mstr.letschat.bitmapcache.AvatarImageFetcher;
13 | import com.mstr.letschat.databases.ChatContract.ContactTable;
14 |
15 | public class ContactCursorAdapter extends ResourceCursorAdapter {
16 | private AvatarImageFetcher imageFetcher;
17 |
18 | public ContactCursorAdapter(Context context, Cursor c, AvatarImageFetcher imageFetcher) {
19 | super(context, R.layout.contact_list_item, c, 0);
20 |
21 | this.imageFetcher = imageFetcher;
22 | }
23 |
24 | @Override
25 | public void bindView(View view, Context context, Cursor cursor) {
26 | ViewHolder viewHolder = (ViewHolder)view.getTag();
27 |
28 | imageFetcher.loadImage(cursor.getString(cursor.getColumnIndex(ContactTable.COLUMN_NAME_JID)), viewHolder.avatar);
29 | viewHolder.nameText.setText(cursor.getString(cursor.getColumnIndex(ContactTable.COLUMN_NAME_NICKNAME)));
30 | viewHolder.statusText.setText(cursor.getString(cursor.getColumnIndex(ContactTable.COLUMN_NAME_STATUS)));
31 | }
32 |
33 | @Override
34 | public View newView(Context context, Cursor cursor, ViewGroup parent) {
35 | View view = super.newView(context, cursor, parent);
36 |
37 | ViewHolder viewHolder = new ViewHolder();
38 | viewHolder.nameText = (TextView)view.findViewById(R.id.tv_nickname);
39 | viewHolder.statusText = (TextView)view.findViewById(R.id.tv_status);
40 | viewHolder.avatar = (ImageView)view.findViewById(R.id.avatar);
41 | view.setTag(viewHolder);
42 |
43 | return view;
44 | }
45 |
46 | static class ViewHolder {
47 | TextView nameText;
48 | TextView statusText;
49 | ImageView avatar;
50 | }
51 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/activity_signup.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
20 |
21 |
28 |
29 |
30 |
36 |
37 |
43 |
44 |
52 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/tasks/LoadProfileTask.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.tasks;
2 |
3 | import org.jivesoftware.smackx.vcardtemp.packet.VCard;
4 |
5 | import android.content.Context;
6 | import android.graphics.Bitmap;
7 |
8 | import com.mstr.letschat.SmackInvocationException;
9 | import com.mstr.letschat.bitmapcache.BitmapUtils;
10 | import com.mstr.letschat.bitmapcache.ImageCache;
11 | import com.mstr.letschat.model.LoginUserProfile;
12 | import com.mstr.letschat.tasks.Response.Listener;
13 | import com.mstr.letschat.utils.PreferenceUtils;
14 | import com.mstr.letschat.xmpp.SmackHelper;
15 |
16 | public class LoadProfileTask extends BaseAsyncTask {
17 | public LoadProfileTask(Listener listener, Context context) {
18 | super(listener, context);
19 | }
20 |
21 | @Override
22 | protected Response doInBackground(Void... params) {
23 | Context context = getContext();
24 | if (context != null) {
25 | try {
26 | String user = PreferenceUtils.getUser(context);
27 |
28 | // first check cache file to find avatar, and if not existing, load vcard from server
29 | Bitmap avatar = ImageCache.getAvatarFromFile(context, user);
30 | if (avatar == null) {
31 | VCard vcard = SmackHelper.getInstance(context).loadVCard();
32 | if (vcard != null) {
33 | byte[] data = vcard.getAvatar();
34 | if (data != null) {
35 | avatar = BitmapUtils.decodeSampledBitmapFromByteArray(data, Integer.MAX_VALUE, Integer.MAX_VALUE, null);
36 | }
37 | }
38 |
39 | if (avatar != null) {
40 | ImageCache.addAvatarToFile(context, user, avatar);
41 | }
42 | }
43 |
44 | LoginUserProfile result = new LoginUserProfile();
45 | result.setAvatar(avatar);
46 | result.setNickname(PreferenceUtils.getNickname(context));
47 |
48 | return Response.success(result);
49 | } catch (SmackInvocationException e) {
50 | return Response.error(e);
51 | }
52 | }
53 |
54 | return null;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/xmpp/MessagePacketListener.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.xmpp;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 |
6 | import com.mstr.letschat.databases.ChatMessageTableHelper;
7 | import com.mstr.letschat.service.MessageService;
8 |
9 | import org.jivesoftware.smack.PacketListener;
10 | import org.jivesoftware.smack.packet.Message;
11 | import org.jivesoftware.smack.packet.Packet;
12 | import org.jivesoftware.smack.packet.PacketExtension;
13 | import org.jivesoftware.smack.util.StringUtils;
14 |
15 | import java.util.Collection;
16 | import java.util.Iterator;
17 |
18 | public class MessagePacketListener implements PacketListener {
19 | private Context context;
20 |
21 | public MessagePacketListener(Context context) {
22 | this.context = context;
23 | }
24 |
25 | @Override
26 | public void processPacket(Packet packet) {
27 | Message msg = (Message)packet;
28 |
29 | Intent intent = new Intent(MessageService.ACTION_MESSAGE_RECEIVED, null, context, MessageService.class);
30 | intent.putExtra(MessageService.EXTRA_DATA_NAME_FROM, StringUtils.parseBareAddress(msg.getFrom()));
31 | intent.putExtra(MessageService.EXTRA_DATA_NAME_MESSAGE_BODY, msg.getBody());
32 | intent.putExtra(MessageService.EXTRA_DATA_NAME_TYPE, ChatMessageTableHelper.TYPE_INCOMING_PLAIN_TEXT);
33 | processPacketExtension(intent, msg);
34 |
35 | context.startService(intent);
36 | }
37 |
38 | private void processPacketExtension(Intent intent, Message msg) {
39 | Collection extensions = msg.getExtensions();
40 | if (extensions != null) {
41 | Iterator iterator = extensions.iterator();
42 | if (iterator.hasNext()) {
43 | PacketExtension extension = iterator.next();
44 | if (extension instanceof UserLocation) {
45 | intent.putExtra(MessageService.EXTRA_DATA_NAME_LOCATION, (UserLocation)extension);
46 | intent.putExtra(MessageService.EXTRA_DATA_NAME_TYPE, ChatMessageTableHelper.TYPE_INCOMING_LOCATION);
47 | }
48 | }
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/xmpp/SmackVCardHelper.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.xmpp;
2 |
3 | import org.jivesoftware.smack.XMPPConnection;
4 | import org.jivesoftware.smackx.vcardtemp.packet.VCard;
5 |
6 | import android.content.Context;
7 |
8 | import com.mstr.letschat.R;
9 | import com.mstr.letschat.SmackInvocationException;
10 |
11 | public class SmackVCardHelper {
12 | public static final String FIELD_STATUS = "status";
13 |
14 | private Context context;
15 | private XMPPConnection con;
16 |
17 | public SmackVCardHelper(Context context, XMPPConnection con) {
18 | this.context = context;
19 | this.con = con;
20 | }
21 |
22 | public void save(String nickname, byte[] avatar) throws SmackInvocationException {
23 | VCard vCard = new VCard();
24 | try {
25 | vCard.setNickName(nickname);
26 | if (avatar != null) {
27 | vCard.setAvatar(avatar);
28 | }
29 | vCard.setField(FIELD_STATUS, context.getString(R.string.default_status));
30 | vCard.save(con);
31 | } catch (Exception e) {
32 | throw new SmackInvocationException(e);
33 | }
34 | }
35 |
36 | public void saveStatus(String status) throws SmackInvocationException {
37 | VCard vCard = loadVCard();
38 | vCard.setField(FIELD_STATUS, status);
39 |
40 | try {
41 | vCard.save(con);
42 | } catch (Exception e) {
43 | throw new SmackInvocationException(e);
44 | }
45 | }
46 |
47 | public String loadStatus() throws SmackInvocationException {
48 | return loadVCard().getField(FIELD_STATUS);
49 | }
50 |
51 | public VCard loadVCard(String jid) throws SmackInvocationException {
52 | VCard vCard = new VCard();
53 | try {
54 | vCard.load(con, jid);
55 |
56 | return vCard;
57 | } catch (Exception e) {
58 | throw new SmackInvocationException(e);
59 | }
60 | }
61 |
62 | public VCard loadVCard() throws SmackInvocationException {
63 | VCard vCard = new VCard();
64 | try {
65 | vCard.load(con);
66 | return vCard;
67 | } catch (Exception e) {
68 | throw new SmackInvocationException(e);
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/xmpp/LocationMessageProvider.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.xmpp;
2 |
3 | import org.jivesoftware.smack.packet.PacketExtension;
4 | import org.jivesoftware.smack.provider.PacketExtensionProvider;
5 | import org.xmlpull.v1.XmlPullParser;
6 |
7 | /**
8 | * Created by dilli on 11/27/2015.
9 | */
10 | public class LocationMessageProvider implements PacketExtensionProvider {
11 | @Override
12 | public PacketExtension parseExtension(org.xmlpull.v1.XmlPullParser parser) throws java.lang.Exception {
13 | UserLocation location = new UserLocation();
14 |
15 | boolean done = false;
16 | String tag = null;
17 | while (!done) {
18 | int eventType = parser.next();
19 | switch (eventType) {
20 | case XmlPullParser.START_TAG:
21 | tag = parser.getName();
22 | break;
23 |
24 | case XmlPullParser.TEXT:
25 | if (UserLocation.TAG_NAME_LATITUDE.equals(tag)) {
26 | try {
27 | location.setLatitude(Double.parseDouble(parser.getText()));
28 | } catch (NumberFormatException ex) {}
29 | } else if (UserLocation.TAG_NAME_LONGITUDE.equals(tag)) {
30 | try {
31 | location.setLongitude(Double.parseDouble(parser.getText()));
32 | } catch (NumberFormatException ex) {}
33 | } else if (UserLocation.TAG_NAME_NAME.equals(tag)) {
34 | location.setName(parser.getText());
35 | } else if(UserLocation.TAG_NAME_ADDRESS.equals(tag)) {
36 | location.setAddress(parser.getText());
37 | }
38 | break;
39 |
40 | case XmlPullParser.END_TAG:
41 | // Stop parsing when we hit
42 | done = UserLocation.TAG_NAME_ADDRESS.equals(parser.getName());
43 | break;
44 | }
45 | }
46 |
47 | return location;
48 | }
49 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/attach_options_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
21 |
30 |
31 |
40 |
41 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/databases/ContactRequestTableHelper.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.databases;
2 |
3 | import android.content.ContentValues;
4 | import android.database.sqlite.SQLiteDatabase;
5 |
6 | import com.mstr.letschat.databases.ChatContract.ContactRequestTable;
7 |
8 | public class ContactRequestTableHelper {
9 | private static final String SQL_CREATE_ENTRIES =
10 | "CREATE TABLE " + ContactRequestTable.TABLE_NAME + " (" +
11 | ContactRequestTable._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
12 | ContactRequestTable.COLUMN_NAME_JID + ChatDbHelper.TEXT_TYPE + ChatDbHelper.COMMA_SEP +
13 | ContactRequestTable.COLUMN_NAME_NICKNAME + ChatDbHelper.TEXT_TYPE + ChatDbHelper.COMMA_SEP +
14 | ContactRequestTable.COLUMN_NAME_STATUS + ChatDbHelper.INTEGER_TYPE +
15 | " )";
16 |
17 | private static final String SQL_DELETE_ENTRIES =
18 | "DROP TABLE IF EXISTS " + ContactRequestTable.TABLE_NAME;
19 |
20 | public static final int CONTACT_REQUEST_STATUS_PENDING = 1;
21 | public static final int CONTACT_REQUEST_STATUS_ACCPTED = 2;
22 |
23 | public static void onCreate(SQLiteDatabase database) {
24 | database.execSQL(SQL_CREATE_ENTRIES);
25 | }
26 |
27 | public static void onUpgrade(SQLiteDatabase database) {
28 | database.execSQL(SQL_DELETE_ENTRIES);
29 | }
30 |
31 | public static ContentValues newContentValues(String jid, String nickname) {
32 | ContentValues values = new ContentValues();
33 | values.put(ContactRequestTable.COLUMN_NAME_JID, jid);
34 | values.put(ContactRequestTable.COLUMN_NAME_NICKNAME, nickname);
35 | values.put(ContactRequestTable.COLUMN_NAME_STATUS, CONTACT_REQUEST_STATUS_PENDING);
36 |
37 | return values;
38 | }
39 |
40 | public static ContentValues newContentValuesWithAcceptedStatus() {
41 | ContentValues values = new ContentValues();
42 | values.put(ContactRequestTable.COLUMN_NAME_STATUS, CONTACT_REQUEST_STATUS_ACCPTED);
43 |
44 | return values;
45 | }
46 |
47 | public static boolean isAcceptedStatus(int status) {
48 | return status == ContactRequestTableHelper.CONTACT_REQUEST_STATUS_ACCPTED;
49 | }
50 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/fragment_profile.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
13 |
14 |
20 |
21 |
27 |
28 |
34 |
35 |
36 |
40 |
41 |
47 |
48 |
54 |
55 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/tasks/LoginTask.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.tasks;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.Context;
5 |
6 | import com.mstr.letschat.R;
7 | import com.mstr.letschat.SmackInvocationException;
8 | import com.mstr.letschat.tasks.Response.Listener;
9 | import com.mstr.letschat.utils.AppLog;
10 | import com.mstr.letschat.utils.PreferenceUtils;
11 | import com.mstr.letschat.xmpp.SmackHelper;
12 |
13 | public class LoginTask extends BaseAsyncTask {
14 | private String username;
15 | private String password;
16 |
17 | private ProgressDialog dialog;
18 |
19 | public LoginTask(Listener listener, Context context, String username, String password) {
20 | super(listener, context);
21 |
22 | this.username = username;
23 | this.password = password;
24 |
25 | dialog = ProgressDialog.show(context, null, context.getResources().getString(R.string.login));
26 | }
27 |
28 | @Override
29 | public Response doInBackground(Void... params) {
30 | Context context = getContext();
31 | if (context != null) {
32 | try {
33 | SmackHelper smackHelper = SmackHelper.getInstance(context);
34 |
35 | smackHelper.login(username, password);
36 |
37 | PreferenceUtils.setLoginUser(context, username, password, smackHelper.getLoginUserNickname());
38 |
39 | return Response.success(true);
40 | } catch(SmackInvocationException e) {
41 | AppLog.e(String.format("login error %s", username), e);
42 |
43 | return Response.error(e);
44 | }
45 | } else {
46 | return null;
47 | }
48 | }
49 |
50 | @Override
51 | protected void onPostExecute(Response response) {
52 | dialog.dismiss();
53 |
54 | super.onPostExecute(response);
55 | }
56 |
57 | @Override
58 | protected void onCancelled() {
59 | super.onCancelled();
60 |
61 | dismissDialog();
62 | }
63 |
64 | public void dismissDialog() {
65 | if (dialog != null && dialog.isShowing()) {
66 | dialog.dismiss();
67 | }
68 | }
69 |
70 | public void dismissDialogAndCancel() {
71 | dismissDialog();
72 | cancel(false);
73 | }
74 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/utils/PreferenceUtils.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.utils;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import android.preference.PreferenceManager;
6 |
7 | public class PreferenceUtils {
8 | public static final String USERNAME = "user";
9 | public static final String PASSWORD = "password";
10 | public static final String NICKNAME = "nickname";
11 | public static final String AVATAR = "avatar";
12 | public static final String TRAFFIC_TRANSMITTED = "traffic_transmitted";
13 | public static final String TRAFFIC_RECEIVED = "traffic_received";
14 | public static final String SERVER_ADDRESS = "server_address";
15 | public static final String SECRET_KEY = "secret_key";
16 |
17 | public static final String AWS_SERVER_IP = "52.32.181.170";
18 |
19 | public static void setLoginUser(Context context, String user, String password, String nickname) {
20 | String encryptedUser = AESEncryption.encrypt(context, user);
21 | String encryptedPassword = AESEncryption.encrypt(context, password);
22 | getSharedPreferences(context).edit().putString(USERNAME, encryptedUser).putString(PASSWORD, encryptedPassword)
23 | .putString(NICKNAME, nickname).commit();
24 | }
25 |
26 | public static String getUser(Context context) {
27 | String encryptedUser = getSharedPreferences(context).getString(USERNAME, null);
28 | return encryptedUser != null ? AESEncryption.decrypt(context, encryptedUser) : null;
29 | }
30 |
31 | public static String getPassword(Context context) {
32 | String encryptedPassword = getSharedPreferences(context).getString(PASSWORD, null);
33 | return encryptedPassword != null ? AESEncryption.decrypt(context, encryptedPassword) : null;
34 | }
35 |
36 | public static String getNickname(Context context) {
37 | return getSharedPreferences(context).getString(NICKNAME, null);
38 | }
39 |
40 | public static String getServerHost(Context context) {
41 | String serverHost = getSharedPreferences(context).getString(SERVER_ADDRESS, null);
42 | return serverHost == null ? AWS_SERVER_IP : serverHost;
43 | }
44 |
45 | public static SharedPreferences getSharedPreferences(Context context) {
46 | return PreferenceManager.getDefaultSharedPreferences(context);
47 | }
48 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/outgoing_location_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
12 |
13 |
17 |
18 |
22 |
31 |
32 |
38 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/databases/ConversationTableHelper.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.databases;
2 |
3 | import android.content.ContentValues;
4 | import android.database.sqlite.SQLiteDatabase;
5 |
6 | import com.mstr.letschat.databases.ChatContract.ConversationTable;
7 |
8 | public class ConversationTableHelper {
9 | private static final String SQL_CREATE_ENTRIES =
10 | "CREATE TABLE " + ConversationTable.TABLE_NAME + " (" +
11 | ConversationTable._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
12 | ConversationTable.COLUMN_NAME_NAME + ChatDbHelper.TEXT_TYPE + ChatDbHelper.COMMA_SEP +
13 | ConversationTable.COLUMN_NAME_NICKNAME + ChatDbHelper.TEXT_TYPE + ChatDbHelper.COMMA_SEP +
14 | ConversationTable.COLUMN_NAME_LATEST_MESSAGE + ChatDbHelper.TEXT_TYPE + ChatDbHelper.COMMA_SEP +
15 | ConversationTable.COLUMN_NAME_UNREAD + ChatDbHelper.INTEGER_TYPE + ChatDbHelper.COMMA_SEP +
16 | ConversationTable.COLUMN_NAME_TIME + " LONG" +
17 | " )";
18 |
19 | private static final String SQL_DELETE_ENTRIES =
20 | "DROP TABLE IF EXISTS " + ConversationTable.TABLE_NAME;
21 |
22 | public static void onCreate(SQLiteDatabase database) {
23 | database.execSQL(SQL_CREATE_ENTRIES);
24 | }
25 |
26 | public static void onUpgrade(SQLiteDatabase database) {
27 | database.execSQL(SQL_DELETE_ENTRIES);
28 | }
29 |
30 | public static ContentValues newUpdateContentValues(String message, long timeMillis) {
31 | ContentValues values = new ContentValues();
32 | values.put(ConversationTable.COLUMN_NAME_LATEST_MESSAGE, message);
33 | values.put(ConversationTable.COLUMN_NAME_TIME, timeMillis);
34 |
35 | return values;
36 | }
37 |
38 | public static ContentValues newInsertContentValues(String name, String nickname, String message, long timeMillis, int unread) {
39 | ContentValues values = new ContentValues();
40 | values.put(ConversationTable.COLUMN_NAME_NAME, name);
41 | values.put(ConversationTable.COLUMN_NAME_NICKNAME, nickname);
42 | values.put(ConversationTable.COLUMN_NAME_LATEST_MESSAGE, message);
43 | values.put(ConversationTable.COLUMN_NAME_TIME, timeMillis);
44 | values.put(ConversationTable.COLUMN_NAME_UNREAD, unread);
45 |
46 | return values;
47 | }
48 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/StartupActivity.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.Menu;
7 | import android.view.MenuItem;
8 | import android.view.View;
9 | import android.view.View.OnClickListener;
10 |
11 | import com.mstr.letschat.utils.PreferenceUtils;
12 |
13 | public class StartupActivity extends AppCompatActivity implements OnClickListener {
14 | private static final int REQUEST_CODE_LOGIN = 1;
15 | private static final int REQUEST_CODE_SIGNUP = 2;
16 |
17 | public void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 |
20 | setContentView(R.layout.activity_startup);
21 |
22 | if (PreferenceUtils.getUser(this) != null) {
23 | startMainActivity();
24 | return;
25 | } else {
26 | findViewById(R.id.ll_buttons_container).setVisibility(View.VISIBLE);
27 | }
28 |
29 | findViewById(R.id.btn_login).setOnClickListener(this);
30 | findViewById(R.id.btn_signup).setOnClickListener(this);
31 | }
32 |
33 | @Override
34 | public boolean onCreateOptionsMenu(Menu menu) {
35 | getMenuInflater().inflate(R.menu.connectivity_menu, menu);
36 | return true;
37 | }
38 |
39 | @Override
40 | public boolean onOptionsItemSelected(MenuItem item) {
41 | if (item.getItemId() == R.id.action_server) {
42 | startActivity(new Intent(this, ServerSettingsActivity.class));
43 | return true;
44 | }
45 |
46 | return super.onOptionsItemSelected(item);
47 | }
48 |
49 | @Override
50 | public void onClick(View v) {
51 | switch (v.getId()) {
52 | case R.id.btn_login:
53 | startActivityForResult(new Intent(this, LoginActivity.class), REQUEST_CODE_LOGIN);
54 | break;
55 |
56 | case R.id.btn_signup:
57 | startActivityForResult(new Intent(this, SignupActivity.class), REQUEST_CODE_SIGNUP);
58 | break;
59 | }
60 | }
61 |
62 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
63 | if (resultCode == RESULT_OK) {
64 | finish();
65 | }
66 | }
67 |
68 | private void startMainActivity() {
69 | startActivity(new Intent(this, MainActivity.class));
70 | finish();
71 | }
72 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/xmpp/SmackContactHelper.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.xmpp;
2 |
3 | import org.jivesoftware.smack.Roster;
4 | import org.jivesoftware.smack.RosterEntry;
5 | import org.jivesoftware.smack.SmackException.NotConnectedException;
6 | import org.jivesoftware.smack.XMPPConnection;
7 | import org.jivesoftware.smack.packet.Presence;
8 |
9 | import android.content.Context;
10 |
11 | import com.mstr.letschat.SmackInvocationException;
12 |
13 | public class SmackContactHelper {
14 | private XMPPConnection con;
15 |
16 | private Roster roster;
17 |
18 | public SmackContactHelper(Context context, XMPPConnection con) {
19 | this.con = con;
20 | }
21 |
22 | private Roster getRoster() {
23 | if (roster == null) {
24 | roster = con.getRoster();
25 | }
26 |
27 | return roster;
28 | }
29 |
30 | public void requestSubscription(String to, String nickname) throws SmackInvocationException {
31 | try {
32 | getRoster().createEntry(to, nickname, null);
33 | } catch (Exception e) {
34 | throw new SmackInvocationException(e);
35 | }
36 | }
37 |
38 | public void approveSubscription(String to) throws SmackInvocationException {
39 | sendPresence(to, new Presence(Presence.Type.subscribed));
40 | }
41 |
42 | private void sendPresence(String to, Presence presence) throws SmackInvocationException {
43 | if (to != null) {
44 | presence.setTo(to);
45 | }
46 |
47 | try {
48 | con.sendPacket(presence);
49 | } catch (NotConnectedException e) {
50 | throw new SmackInvocationException(e);
51 | }
52 | }
53 |
54 | public void delete(String jid) throws SmackInvocationException {
55 | RosterEntry rosterEntry = roster.getEntry(jid);
56 | if (rosterEntry != null) {
57 | try {
58 | getRoster().removeEntry(rosterEntry);
59 | } catch (Exception e) {
60 | throw new SmackInvocationException(e);
61 | }
62 | }
63 | }
64 |
65 | public RosterEntry getRosterEntry(String from) {
66 | return getRoster().getEntry(from);
67 | }
68 |
69 | public void broadcastStatus(String status) throws SmackInvocationException {
70 | Presence presence = new Presence(Presence.Type.available);
71 | presence.setStatus(status);
72 | sendPresence(null, presence);
73 | }
74 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/activity_chat.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
20 |
21 |
24 |
25 |
31 |
39 |
40 |
47 |
48 |
49 |
50 |
54 |
--------------------------------------------------------------------------------
/library/cropImage/src/main/java/com/android/camera/gallery/SingleImageList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2009 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.camera.gallery;
18 |
19 | import android.content.ContentResolver;
20 | import android.net.Uri;
21 |
22 | import java.util.HashMap;
23 |
24 | /**
25 | * An implementation of interface IImageList which contains only
26 | * one image.
27 | */
28 | public class SingleImageList implements IImageList {
29 |
30 | @SuppressWarnings("unused")
31 | private static final String TAG = "BaseImageList";
32 |
33 | private IImage mSingleImage;
34 | private Uri mUri;
35 |
36 | public SingleImageList(ContentResolver resolver, Uri uri) {
37 | mUri = uri;
38 | mSingleImage = new UriImage(this, resolver, uri);
39 | }
40 |
41 | public HashMap getBucketIds() {
42 | throw new UnsupportedOperationException();
43 | }
44 |
45 | public int getCount() {
46 | return 1;
47 | }
48 |
49 | public boolean isEmpty() {
50 | return false;
51 | }
52 |
53 | public int getImageIndex(IImage image) {
54 | return image == mSingleImage ? 0 : -1;
55 | }
56 |
57 | public IImage getImageAt(int i) {
58 | return i == 0 ? mSingleImage : null;
59 | }
60 |
61 | public boolean removeImage(IImage image) {
62 | return false;
63 | }
64 |
65 | public boolean removeImageAt(int index) {
66 | return false;
67 | }
68 |
69 | public IImage getImageForUri(Uri uri) {
70 | return uri.equals(mUri) ? mSingleImage : null;
71 | }
72 |
73 | public void close() {
74 | mSingleImage = null;
75 | mUri = null;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/outgoing_image_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
15 |
16 |
20 |
29 |
30 |
35 |
36 |
42 |
43 |
44 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/tasks/SendImageTask.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.tasks;
2 |
3 | import android.content.ContentValues;
4 | import android.content.Context;
5 | import android.graphics.Bitmap;
6 | import android.net.Uri;
7 |
8 | import com.mstr.letschat.R;
9 | import com.mstr.letschat.bitmapcache.BitmapUtils;
10 | import com.mstr.letschat.databases.ChatMessageTableHelper;
11 | import com.mstr.letschat.utils.FileUtils;
12 | import com.mstr.letschat.xmpp.SmackHelper;
13 |
14 | import java.io.File;
15 | import java.io.FileNotFoundException;
16 | import java.io.FileOutputStream;
17 | import java.io.IOException;
18 |
19 | /**
20 | * Created by dilli on 1/28/2016.
21 | */
22 | public class SendImageTask extends SendMessageTask {
23 | private String fileName;
24 | private Uri uri;
25 | private File file;
26 |
27 | public SendImageTask(Response.Listener listener, Context context, String to, String nickname, String body, Uri uri, String fileName) {
28 | super(listener, context, to, nickname, body);
29 |
30 | this.uri = uri;
31 | this.fileName = fileName;
32 | }
33 |
34 | private File createSentImageFile(Context context, String fileName, Bitmap bitmap) throws IOException {
35 | file = new File(FileUtils.getSentImagesDir(context), fileName + FileUtils.IMAGE_EXTENSION);
36 | FileOutputStream outputStream = new FileOutputStream(file);
37 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
38 | outputStream.flush();
39 | outputStream.close();
40 |
41 | return file;
42 | }
43 |
44 | @Override
45 | protected ContentValues newMessage(long sendTimeMillis) throws IOException {
46 | Context context = getContext();
47 | int size = context.getResources().getDimensionPixelSize(R.dimen.sent_image_size);
48 | Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromStream(context, uri, size, size);
49 | file = createSentImageFile(context, fileName, bitmap);
50 |
51 | return ChatMessageTableHelper.newImageMessage(to, body, sendTimeMillis, file.getAbsolutePath(), true);
52 | }
53 |
54 | @Override
55 | protected void doSend(Context context) throws Exception {
56 | if (file != null) {
57 | SmackHelper.getInstance(context).sendImage(file, to);
58 | } else {
59 | throw new FileNotFoundException(fileName);
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/tasks/SignupTask.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.tasks;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.Context;
5 | import android.graphics.BitmapFactory;
6 |
7 | import com.mstr.letschat.R;
8 | import com.mstr.letschat.SmackInvocationException;
9 | import com.mstr.letschat.bitmapcache.ImageCache;
10 | import com.mstr.letschat.tasks.Response.Listener;
11 | import com.mstr.letschat.utils.AppLog;
12 | import com.mstr.letschat.utils.PreferenceUtils;
13 | import com.mstr.letschat.xmpp.SmackHelper;
14 |
15 | public class SignupTask extends BaseAsyncTask {
16 | private String user;
17 | private String name;
18 | private String password;
19 | private byte[] avatar;
20 |
21 | private ProgressDialog dialog;
22 |
23 | public SignupTask(Listener listener, Context context, String user, String password, String name, byte[] avatar) {
24 | super(listener, context);
25 |
26 | this.user = user;
27 | this.name = name;
28 | this.password = password;
29 | this.avatar = avatar;
30 |
31 | dialog = ProgressDialog.show(context, null, context.getResources().getString(R.string.signup));
32 | }
33 |
34 | @Override
35 | public Response doInBackground(Void... params) {
36 | Context context = getContext();
37 | if (context != null) {
38 | try {
39 | SmackHelper.getInstance(context).signupAndLogin(user, password, name, avatar);
40 |
41 | if (avatar != null) {
42 | ImageCache.addAvatarToFile(context, user, BitmapFactory.decodeByteArray(avatar, 0, avatar.length));
43 | }
44 |
45 | PreferenceUtils.setLoginUser(context, user, password, name);
46 |
47 | return Response.success(true);
48 | } catch(SmackInvocationException e) {
49 | AppLog.e(String.format("sign up error %s", e.toString()), e);
50 |
51 | return Response.error(e);
52 | }
53 | }
54 |
55 | return null;
56 | }
57 |
58 | @Override
59 | protected void onPostExecute(Response response) {
60 | dismissDialog();
61 |
62 | super.onPostExecute(response);
63 | }
64 |
65 | @Override
66 | protected void onCancelled() {
67 | super.onCancelled();
68 |
69 | dismissDialog();
70 | }
71 |
72 | public void dismissDialog() {
73 | if (dialog != null && dialog.isShowing()) {
74 | dialog.dismiss();
75 | }
76 | }
77 |
78 | public void dismissDialogAndCancel() {
79 | dismissDialog();
80 | cancel(false);
81 | }
82 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/activity_user_profile.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
20 |
21 |
27 |
28 |
29 |
30 |
37 |
38 |
45 |
46 |
51 |
52 |
53 |
63 |
64 |
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/conversation_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
15 |
16 |
21 |
22 |
26 |
33 |
34 |
41 |
42 |
43 |
47 |
56 |
57 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/LoginActivity.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.MenuItem;
7 | import android.view.View;
8 | import android.view.View.OnClickListener;
9 | import android.widget.Button;
10 | import android.widget.EditText;
11 | import android.widget.Toast;
12 |
13 | import com.mstr.letschat.tasks.LoginTask;
14 | import com.mstr.letschat.tasks.Response.Listener;
15 |
16 | public class LoginActivity extends AppCompatActivity implements Listener, OnClickListener {
17 | private EditText phoneNumberText;
18 | private EditText passwordText;
19 | private Button loginButton;
20 |
21 | private LoginTask loginTask;
22 |
23 | @Override
24 | public void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 |
27 | setContentView(R.layout.activity_login);
28 |
29 | phoneNumberText = (EditText)findViewById(R.id.et_phone_number);
30 | passwordText = (EditText)findViewById(R.id.et_password);
31 | loginButton = (Button)findViewById(R.id.btn_login);
32 |
33 | loginButton.setOnClickListener(this);
34 |
35 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
36 | }
37 |
38 | @Override
39 | public boolean onOptionsItemSelected(MenuItem item) {
40 | switch (item.getItemId()) {
41 | case android.R.id.home:
42 | finish();
43 | return true;
44 | }
45 |
46 | return super.onOptionsItemSelected(item);
47 | }
48 |
49 | @Override
50 | public void onClick(View v) {
51 | if (v == loginButton) {
52 | loginTask = new LoginTask(this, this, phoneNumberText.getText().toString(), passwordText.getText().toString());
53 | loginTask.execute();
54 | }
55 | }
56 |
57 | @Override
58 | public void onResponse(Boolean response) {
59 | if (response) {
60 | startActivity(new Intent(this, MainActivity.class));
61 |
62 | setResult(RESULT_OK);
63 | finish();
64 | }
65 | }
66 |
67 | @Override
68 | public void onErrorResponse(Exception exception) {
69 | if (((SmackInvocationException)exception).isCausedBySASLError()) {
70 | Toast.makeText(this, R.string.invalid_credentials, Toast.LENGTH_SHORT).show();
71 | } else {
72 | Toast.makeText(this, R.string.login_error, Toast.LENGTH_SHORT).show();
73 | }
74 | }
75 |
76 | @Override
77 | protected void onDestroy() {
78 | super.onDestroy();
79 |
80 | if (loginTask != null) {
81 | loginTask.dismissDialogAndCancel();
82 | }
83 | }
84 | }
--------------------------------------------------------------------------------
/library/cropImage/src/main/res/layout/cropimage.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
20 |
21 |
25 |
26 |
33 |
40 |
47 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/letsChat/src/androidTest/java/com/mstr/letschat/ChatActivityTest.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat;
2 |
3 | import android.content.ContentValues;
4 | import android.content.Intent;
5 | import android.database.sqlite.SQLiteDatabase;
6 | import android.database.sqlite.SQLiteException;
7 | import android.test.ActivityInstrumentationTestCase2;
8 | import android.test.suitebuilder.annotation.MediumTest;
9 | import android.util.Log;
10 |
11 | import com.mstr.letschat.databases.ChatContract;
12 | import com.mstr.letschat.databases.ChatDbHelper;
13 | import com.mstr.letschat.databases.ChatMessageTableHelper;
14 |
15 | /**
16 | * Created by dilli on 7/26/2015.
17 | */
18 | public class ChatActivityTest extends ActivityInstrumentationTestCase2 {
19 | private static final String to = "11@chn-dilli2";
20 | private static final String nickname = "11";
21 |
22 | private ChatActivity activity;
23 | private ChatDbHelper dbHelper;
24 |
25 | public ChatActivityTest() {
26 | super(ChatActivity.class);
27 | }
28 |
29 | @Override
30 | protected void setUp() throws Exception {
31 | super.setUp();
32 |
33 | Intent intent = new Intent();
34 | intent.putExtra(ChatActivity.EXTRA_DATA_NAME_TO, to);
35 | intent.putExtra(ChatActivity.EXTRA_DATA_NAME_NICKNAME, nickname);
36 | setActivityIntent(intent);
37 |
38 | activity = getActivity();
39 | dbHelper = ChatDbHelper.getInstance(activity);
40 | prepareTestData();
41 | }
42 |
43 | @MediumTest
44 | public void testPreconditions() {
45 | assertNotNull("activity is null", activity);
46 | assertNotNull("dbHelper is null", dbHelper);
47 | }
48 |
49 | private void prepareTestData() {
50 | SQLiteDatabase database = dbHelper.getWritableDatabase();
51 | try {
52 | database.beginTransaction();
53 |
54 | for (int j = 0; j < 500000; j++) {
55 | String body = String.valueOf(j);
56 |
57 | ContentValues messageValues = ChatMessageTableHelper.newPlainTextMessage(to, body, System.currentTimeMillis(), true);
58 | messageValues.put(ChatContract.ChatMessageTable.COLUMN_NAME_STATUS, ChatMessageTableHelper.STATUS_SUCCESS);
59 |
60 | dbHelper.getWritableDatabase().insert(ChatContract.ChatMessageTable.TABLE_NAME, null, messageValues);
61 | }
62 | database.setTransactionSuccessful();
63 | } catch(SQLiteException e) {}
64 | finally {
65 | database.endTransaction();
66 | }
67 |
68 | Log.d("ChatActivityTest", "insert 500000 messages complete");
69 | }
70 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/tasks/AcceptContactRequestTask.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.tasks;
2 |
3 | import java.lang.ref.WeakReference;
4 |
5 | import org.jivesoftware.smackx.vcardtemp.packet.VCard;
6 |
7 | import android.content.Context;
8 | import android.database.Cursor;
9 | import android.net.Uri;
10 |
11 | import com.mstr.letschat.SmackInvocationException;
12 | import com.mstr.letschat.databases.ChatContract.ContactRequestTable;
13 | import com.mstr.letschat.model.UserProfile;
14 | import com.mstr.letschat.tasks.Response.Listener;
15 | import com.mstr.letschat.utils.AppLog;
16 | import com.mstr.letschat.utils.ProviderUtils;
17 | import com.mstr.letschat.xmpp.SmackHelper;
18 | import com.mstr.letschat.xmpp.SmackVCardHelper;
19 |
20 | public class AcceptContactRequestTask extends BaseAsyncTask {
21 | private WeakReference uriWrapper;
22 |
23 | public AcceptContactRequestTask(Listener listener, Context context, Uri uri) {
24 | super(listener, context);
25 | uriWrapper = new WeakReference(uri);
26 | }
27 |
28 | @Override
29 | protected Response doInBackground(Void... params) {
30 | Uri requestUri = uriWrapper.get();
31 | Context context = getContext();
32 | if (requestUri != null && context != null) {
33 | Cursor cursor = context.getContentResolver().query(requestUri,
34 | new String[]{ContactRequestTable.COLUMN_NAME_NICKNAME, ContactRequestTable.COLUMN_NAME_JID},
35 | null, null, null);
36 | try {
37 | if (cursor.moveToFirst()) {
38 | String jid = cursor.getString(cursor.getColumnIndex(ContactRequestTable.COLUMN_NAME_JID));
39 | String nickname = cursor.getString(cursor.getColumnIndex(ContactRequestTable.COLUMN_NAME_NICKNAME));
40 |
41 | SmackHelper smackHelper = SmackHelper.getInstance(context);
42 | // 1. grant subscription to initiator, and request subscription afterwards
43 | smackHelper.approveSubscription(jid, nickname, true);
44 |
45 | // 2. load VCard
46 | VCard vCard = smackHelper.loadVCard(jid);
47 |
48 | // 3. save new contact into db
49 | ProviderUtils.addNewContact(context, jid, nickname, vCard.getField(SmackVCardHelper.FIELD_STATUS));
50 |
51 | return Response.success(new UserProfile(jid, vCard, UserProfile.TYPE_CONTACT));
52 | }
53 | } catch(SmackInvocationException e) {
54 | AppLog.e(String.format("accept contact request error %s", e.toString()), e);
55 |
56 | return Response.error(e);
57 | } finally {
58 | cursor.close();
59 | }
60 | }
61 |
62 | return null;
63 | }
64 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
22 |
23 |
28 |
29 |
30 |
31 |
32 |
35 |
36 |
41 |
42 |
48 |
49 |
52 |
53 |
58 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/views/MessageView.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.views;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.LinearLayout;
9 | import android.widget.TextView;
10 |
11 | import com.mstr.letschat.R;
12 | import com.mstr.letschat.databases.ChatMessageTableHelper;
13 |
14 | public abstract class MessageView extends LinearLayout {
15 | protected TextView time;
16 | protected TextView dateSeparator;
17 |
18 | public MessageView(Context context) {
19 | this(context, null);
20 | }
21 |
22 | public MessageView(Context context, AttributeSet attrs) {
23 | super(context, attrs, R.attr.messageViewStyle);
24 | init(context);
25 | }
26 |
27 | protected void init(Context context) {
28 | LayoutInflater.from(context).inflate(getLayoutResource(), this);
29 | time = (TextView)findViewById(R.id.tv_time);
30 | dateSeparator = (TextView)findViewById(R.id.tv_date);
31 | }
32 |
33 | public void setTimeText(String text) {
34 | time.setText(text);
35 | }
36 |
37 | public void displayDateSeparator(String text) {
38 | dateSeparator.setVisibility(View.VISIBLE);
39 | dateSeparator.setText(text);
40 | }
41 |
42 | public void hideDateSeparator() {
43 | dateSeparator.setVisibility(View.GONE);
44 | }
45 |
46 | public abstract void showProgress(boolean sent);
47 |
48 | public static MessageView newView(int type, Context context) {
49 | MessageView view = null;
50 | switch (type) {
51 | case ChatMessageTableHelper.TYPE_INCOMING_PLAIN_TEXT:
52 | view = new IncomingPlainTextView(context);
53 | break;
54 |
55 | case ChatMessageTableHelper.TYPE_OUTGOING_PLAIN_TEXT:
56 | view = new OutgoingPlainTextView(context);
57 | break;
58 |
59 | case ChatMessageTableHelper.TYPE_INCOMING_LOCATION:
60 | view = new IncomingLocationView(context);
61 | ((LocationView)view).initializeMapView();
62 | break;
63 |
64 | case ChatMessageTableHelper.TYPE_OUTGOING_LOCATION:
65 | view = new OutgoingLocationView(context);
66 | ((LocationView)view).initializeMapView();
67 | break;
68 |
69 | case ChatMessageTableHelper.TYPE_INCOMING_IMAGE:
70 | view = new IncomingImageMessageView(context);
71 | break;
72 |
73 | case ChatMessageTableHelper.TYPE_OUTGOING_IMAGE:
74 | view = new OutgoingImageMessageView(context);
75 | break;
76 | }
77 |
78 | if (view != null) {
79 | view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
80 | }
81 |
82 | return view;
83 | }
84 |
85 | protected abstract int getLayoutResource();
86 | }
--------------------------------------------------------------------------------
/library/cropImage/src/main/java/com/android/camera/gallery/IImageList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2009 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.camera.gallery;
18 |
19 | import android.net.Uri;
20 |
21 | import java.util.HashMap;
22 |
23 | //
24 | // ImageList and Image classes have one-to-one correspondence.
25 | // The class hierarchy (* = abstract class):
26 | //
27 | // IImageList
28 | // - BaseImageList (*)
29 | // - VideoList
30 | // - ImageList
31 | // - DrmImageList
32 | // - SingleImageList (contains UriImage)
33 | // - ImageListUber
34 | //
35 | // IImage
36 | // - BaseImage (*)
37 | // - VideoObject
38 | // - Image
39 | // - DrmImage
40 | // - UriImage
41 | //
42 |
43 | /**
44 | * The interface of all image collections used in gallery.
45 | */
46 | public interface IImageList {
47 | public HashMap getBucketIds();
48 |
49 | /**
50 | * Returns the count of image objects.
51 | *
52 | * @return the number of images
53 | */
54 | public int getCount();
55 |
56 | /**
57 | * @return true if the count of image objects is zero.
58 | */
59 | public boolean isEmpty();
60 |
61 | /**
62 | * Returns the image at the ith position.
63 | *
64 | * @param i the position
65 | * @return the image at the ith position
66 | */
67 | public IImage getImageAt(int i);
68 |
69 | /**
70 | * Returns the image with a particular Uri.
71 | *
72 | * @param uri
73 | * @return the image with a particular Uri. null if not found.
74 | */
75 | public IImage getImageForUri(Uri uri);
76 |
77 | /**
78 | *
79 | * @param image
80 | * @return true if the image was removed.
81 | */
82 | public boolean removeImage(IImage image);
83 |
84 | /**
85 | * Removes the image at the ith position.
86 | * @param i the position
87 | */
88 | public boolean removeImageAt(int i);
89 |
90 | public int getImageIndex(IImage image);
91 |
92 | /**
93 | * Closes this list to release resources, no further operation is allowed.
94 | */
95 | public void close();
96 | }
97 |
--------------------------------------------------------------------------------
/library/cropImage/src/main/java/com/android/camera/gallery/LruCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2009 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.camera.gallery;
18 |
19 | import java.lang.ref.ReferenceQueue;
20 | import java.lang.ref.WeakReference;
21 | import java.util.HashMap;
22 | import java.util.LinkedHashMap;
23 | import java.util.Map;
24 |
25 | public class LruCache {
26 |
27 | private final HashMap mLruMap;
28 | private final HashMap> mWeakMap =
29 | new HashMap>();
30 | private ReferenceQueue mQueue = new ReferenceQueue();
31 |
32 | @SuppressWarnings("serial")
33 | public LruCache(final int capacity) {
34 | mLruMap = new LinkedHashMap(16, 0.75f, true) {
35 | @Override
36 | protected boolean removeEldestEntry(Map.Entry eldest) {
37 | return size() > capacity;
38 | }
39 | };
40 | }
41 |
42 | private static class Entry extends WeakReference {
43 | K mKey;
44 |
45 | public Entry(K key, V value, ReferenceQueue queue) {
46 | super(value, queue);
47 | mKey = key;
48 | }
49 | }
50 |
51 | @SuppressWarnings("unchecked")
52 | private void cleanUpWeakMap() {
53 | Entry entry = (Entry) mQueue.poll();
54 | while (entry != null) {
55 | mWeakMap.remove(entry.mKey);
56 | entry = (Entry) mQueue.poll();
57 | }
58 | }
59 |
60 | public synchronized V put(K key, V value) {
61 | cleanUpWeakMap();
62 | mLruMap.put(key, value);
63 | Entry entry = mWeakMap.put(
64 | key, new Entry(key, value, mQueue));
65 | return entry == null ? null : entry.get();
66 | }
67 |
68 | public synchronized V get(K key) {
69 | cleanUpWeakMap();
70 | V value = mLruMap.get(key);
71 | if (value != null) return value;
72 | Entry entry = mWeakMap.get(key);
73 | return entry == null ? null : entry.get();
74 | }
75 |
76 | public synchronized void clear() {
77 | mLruMap.clear();
78 | mWeakMap.clear();
79 | mQueue = new ReferenceQueue();
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/utils/NetworkUtils.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.utils;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import android.content.pm.ApplicationInfo;
6 | import android.content.pm.PackageManager;
7 | import android.net.ConnectivityManager;
8 | import android.net.NetworkInfo;
9 | import android.net.TrafficStats;
10 |
11 | /**
12 | * Created by dilli on 1/21/2016.
13 | */
14 | public class NetworkUtils {
15 | public static boolean isNetworkConnected(Context context) {
16 | ConnectivityManager conn = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
17 | NetworkInfo networkInfo = conn.getActiveNetworkInfo();
18 |
19 | return networkInfo != null && networkInfo.isConnected();
20 | }
21 |
22 | private static RxTxBytes getRxTxBytesSinceBoot(Context context) {
23 | ApplicationInfo applicationInfo = null;
24 | try {
25 | applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), 0);
26 | } catch (PackageManager.NameNotFoundException e) {}
27 |
28 | if (applicationInfo != null) {
29 | int uid = applicationInfo.uid;
30 | long rxBytes = TrafficStats.getUidRxBytes(uid);
31 | long txBytes = TrafficStats.getUidTxBytes(uid);
32 | return new RxTxBytes(rxBytes, txBytes);
33 | } else {
34 | return null;
35 | }
36 | }
37 |
38 | public static void saveNetworkUsageOnShutDown(Context context) {
39 | RxTxBytes rxTxBytes = getTotalRxTxBytes(context);
40 | if (rxTxBytes != null) {
41 | SharedPreferences sharedPreferences = PreferenceUtils.getSharedPreferences(context);
42 | sharedPreferences.edit().putLong(PreferenceUtils.TRAFFIC_RECEIVED, rxTxBytes.rxBytes)
43 | .putLong(PreferenceUtils.TRAFFIC_TRANSMITTED, rxTxBytes.txBytes).apply();
44 | }
45 | }
46 |
47 | public static RxTxBytes getTotalRxTxBytes(Context context) {
48 | RxTxBytes rxTxBytes = getRxTxBytesSinceBoot(context);
49 | if (rxTxBytes != null) {
50 | SharedPreferences sharedPreferences = PreferenceUtils.getSharedPreferences(context);
51 | long rxBytes = sharedPreferences.getLong(PreferenceUtils.TRAFFIC_RECEIVED, 0);
52 | long txBytes = sharedPreferences.getLong(PreferenceUtils.TRAFFIC_TRANSMITTED, 0);
53 | return new RxTxBytes(rxBytes + rxTxBytes.rxBytes, txBytes + rxTxBytes.txBytes);
54 | } else {
55 | return null;
56 | }
57 | }
58 |
59 | public static class RxTxBytes {
60 | public long rxBytes;
61 | public long txBytes;
62 |
63 | public RxTxBytes(long rxBytes, long txBytes) {
64 | this.rxBytes = rxBytes;
65 | this.txBytes = txBytes;
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/letsChat/src/main/java/com/mstr/letschat/tasks/SaveStatusTask.java:
--------------------------------------------------------------------------------
1 | package com.mstr.letschat.tasks;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.Context;
5 | import android.widget.TextView;
6 |
7 | import com.mstr.letschat.R;
8 | import com.mstr.letschat.SmackInvocationException;
9 | import com.mstr.letschat.adapters.StatusListAdapter;
10 | import com.mstr.letschat.tasks.Response.Listener;
11 | import com.mstr.letschat.utils.AppLog;
12 | import com.mstr.letschat.xmpp.SmackHelper;
13 |
14 | import java.lang.ref.WeakReference;
15 |
16 | public class SaveStatusTask extends BaseAsyncTask {
17 | private int position;
18 | private WeakReference adapterWrapper;
19 | private WeakReference statusTextWrapper;
20 |
21 | private ProgressDialog dialog;
22 |
23 | public SaveStatusTask(Listener listener, Context context, StatusListAdapter adapter, TextView statusText, int position) {
24 | super(listener, context);
25 |
26 | adapterWrapper = new WeakReference(adapter);
27 | statusTextWrapper = new WeakReference(statusText);
28 | this.position = position;
29 |
30 | dialog = ProgressDialog.show(context, null, context.getResources().getString(R.string.update_status_text));
31 | }
32 |
33 | @Override
34 | protected Response doInBackground(Void... params) {
35 | Context context = getContext();
36 | StatusListAdapter adapter = adapterWrapper.get();
37 | if (context != null && adapter != null) {
38 | try {
39 | SmackHelper.getInstance(context).saveStatus(adapter.getItem(position));
40 |
41 | return Response.success(true);
42 | } catch (SmackInvocationException e) {
43 | AppLog.e("set status error", e);
44 | return Response.error(e);
45 | }
46 | }
47 |
48 | return null;
49 | }
50 |
51 | @Override
52 | protected void onPostExecute(Response response) {
53 | dismissDialog();
54 |
55 | Listener listener = getListener();
56 | if (listener != null && response != null) {
57 | if (response.isSuccess()) {
58 | StatusListAdapter adapter = adapterWrapper.get();
59 | if (adapter != null) {
60 | adapter.setSelection(position);
61 |
62 | TextView statusText = statusTextWrapper.get();
63 | if (statusText != null) {
64 | statusText.setText(adapter.getItem(position));
65 | }
66 | }
67 | }
68 | }
69 |
70 | super.onPostExecute(response);
71 | }
72 |
73 | @Override
74 | protected void onCancelled() {
75 | super.onCancelled();
76 | dismissDialog();
77 | }
78 |
79 | public void dismissDialog() {
80 | if (dialog != null && dialog.isShowing()) {
81 | dialog.dismiss();
82 | }
83 | }
84 |
85 | public void dismissDialogAndCancel() {
86 | dismissDialog();
87 | cancel(false);
88 | }
89 | }
--------------------------------------------------------------------------------
/letsChat/src/main/res/layout/activity_set_status.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
23 |
24 |
28 |
29 |
34 |
35 |
42 |
43 |
48 |
49 |
50 |
51 |
59 |
60 |
66 |
67 |
71 |
72 |
75 |
76 |
--------------------------------------------------------------------------------