├── .gitignore ├── .idea ├── assetWizardSettings.xml ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── smartherd │ │ └── msgshareapp │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── ic_launcher_shareapp-web.png │ ├── java │ │ └── com │ │ │ └── smartherd │ │ │ └── msgshareapp │ │ │ ├── AppConstants.kt │ │ │ ├── Extensions.kt │ │ │ ├── activities │ │ │ ├── HobbiesActivity.kt │ │ │ ├── MainActivity.kt │ │ │ └── SecondActivity.kt │ │ │ ├── adapters │ │ │ └── HobbiesAdapter.kt │ │ │ └── models │ │ │ └── Model.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_hobbies.xml │ │ ├── activity_main.xml │ │ ├── activity_second.xml │ │ └── list_item.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ ├── ic_launcher_round.xml │ │ ├── ic_launcher_shareapp.xml │ │ └── ic_launcher_shareapp_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ ├── ic_launcher_round.png │ │ ├── ic_launcher_shareapp.png │ │ └── ic_launcher_shareapp_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ ├── ic_launcher_round.png │ │ ├── ic_launcher_shareapp.png │ │ └── ic_launcher_shareapp_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ ├── ic_launcher_round.png │ │ ├── ic_launcher_shareapp.png │ │ └── ic_launcher_shareapp_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ ├── ic_launcher_round.png │ │ ├── ic_launcher_shareapp.png │ │ └── ic_launcher_shareapp_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ ├── ic_launcher_round.png │ │ ├── ic_launcher_shareapp.png │ │ └── ic_launcher_shareapp_round.png │ │ ├── values-fr │ │ └── strings.xml │ │ └── values │ │ ├── colors.xml │ │ ├── ic_launcher_background.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── smartherd │ └── msgshareapp │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /.idea/assetWizardSettings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 70 | 71 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smartherd/MsgShareApp/cfab1ca2ab0e837e148e21d6fbe754bc1d7fbc91/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 27 9 | defaultConfig { 10 | applicationId "com.smartherd.msgshareapp" 11 | minSdkVersion 19 12 | targetSdkVersion 27 13 | versionCode 1 14 | versionName "1.0" 15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation fileTree(dir: 'libs', include: ['*.jar']) 27 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" 28 | implementation 'com.android.support:appcompat-v7:27.1.1' 29 | implementation 'com.android.support.constraint:constraint-layout:1.1.0' 30 | testImplementation 'junit:junit:4.12' 31 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 32 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 33 | implementation 'com.android.support:recyclerview-v7:27.1.1' 34 | implementation 'com.android.support:cardview-v7:27.1.1' 35 | } 36 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/smartherd/msgshareapp/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.smartherd.msgshareapp 2 | 3 | import android.support.test.InstrumentationRegistry 4 | import android.support.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getTargetContext() 22 | assertEquals("com.smartherd.msgshareapp", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher_shareapp-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smartherd/MsgShareApp/cfab1ca2ab0e837e148e21d6fbe754bc1d7fbc91/app/src/main/ic_launcher_shareapp-web.png -------------------------------------------------------------------------------- /app/src/main/java/com/smartherd/msgshareapp/AppConstants.kt: -------------------------------------------------------------------------------- 1 | package com.smartherd.msgshareapp 2 | 3 | object Constants { 4 | const val USER_MSG_KEY = "user_message" 5 | } 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/smartherd/msgshareapp/Extensions.kt: -------------------------------------------------------------------------------- 1 | package com.smartherd.msgshareapp 2 | 3 | import android.content.Context 4 | import android.widget.Toast 5 | 6 | fun Context.showToast(message: String, duration: Int = Toast.LENGTH_SHORT) { 7 | Toast.makeText(this, message, duration).show() 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/smartherd/msgshareapp/activities/HobbiesActivity.kt: -------------------------------------------------------------------------------- 1 | package com.smartherd.msgshareapp.activities 2 | 3 | import android.os.Bundle 4 | import android.support.v7.app.AppCompatActivity 5 | import android.support.v7.widget.LinearLayoutManager 6 | import com.smartherd.msgshareapp.R 7 | import com.smartherd.msgshareapp.adapters.HobbiesAdapter 8 | import com.smartherd.msgshareapp.models.Supplier 9 | import kotlinx.android.synthetic.main.activity_hobbies.* 10 | 11 | class HobbiesActivity : AppCompatActivity() { 12 | 13 | companion object { 14 | val TAG: String = HobbiesActivity::class.java.simpleName 15 | } 16 | 17 | override fun onCreate(savedInstanceState: Bundle?) { 18 | super.onCreate(savedInstanceState) 19 | setContentView(R.layout.activity_hobbies) 20 | 21 | setupRecyclerView() 22 | } 23 | 24 | private fun setupRecyclerView() { 25 | 26 | val layoutManager = LinearLayoutManager(this) 27 | layoutManager.orientation = LinearLayoutManager.VERTICAL 28 | recyclerView.layoutManager = layoutManager 29 | 30 | val adapter= HobbiesAdapter(this, Supplier.hobbies) 31 | recyclerView.adapter = adapter 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/smartherd/msgshareapp/activities/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.smartherd.msgshareapp.activities 2 | 3 | import android.content.Intent 4 | import android.os.Bundle 5 | import android.support.v7.app.AppCompatActivity 6 | import android.util.Log 7 | import android.widget.Toast 8 | import com.smartherd.msgshareapp.Constants 9 | import com.smartherd.msgshareapp.R 10 | import com.smartherd.msgshareapp.showToast 11 | import kotlinx.android.synthetic.main.activity_main.* 12 | 13 | class MainActivity : AppCompatActivity() { 14 | 15 | companion object { 16 | val TAG: String = MainActivity::class.java.simpleName 17 | } 18 | 19 | override fun onCreate(savedInstanceState: Bundle?) { 20 | super.onCreate(savedInstanceState) 21 | setContentView(R.layout.activity_main) 22 | 23 | btnShowToast.setOnClickListener { 24 | Log.i(TAG, "Button was clicked !") 25 | showToast(resources.getString(R.string.btn_was_clicked), Toast.LENGTH_LONG) 26 | } 27 | 28 | btnSendMsgToNextActivity.setOnClickListener { 29 | val message: String = etUserMessage.text.toString() 30 | val intent = Intent(this, SecondActivity::class.java) 31 | 32 | intent.putExtra(Constants.USER_MSG_KEY, message) 33 | 34 | startActivity(intent) 35 | } 36 | 37 | btnShareToOtherApps.setOnClickListener { 38 | 39 | val message: String = etUserMessage.text.toString() 40 | 41 | val intent = Intent() 42 | intent.action = Intent.ACTION_SEND 43 | intent.putExtra(Intent.EXTRA_TEXT, message) 44 | intent.type = "text/plain" 45 | 46 | startActivity(Intent.createChooser(intent, "Please select app: ")) 47 | } 48 | 49 | btnRecyclerViewDemo.setOnClickListener { 50 | 51 | val intent = Intent(this, HobbiesActivity::class.java) 52 | startActivity(intent) 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/smartherd/msgshareapp/activities/SecondActivity.kt: -------------------------------------------------------------------------------- 1 | package com.smartherd.msgshareapp.activities 2 | 3 | import android.os.Bundle 4 | import android.support.v7.app.AppCompatActivity 5 | import com.smartherd.msgshareapp.Constants 6 | import com.smartherd.msgshareapp.R 7 | import com.smartherd.msgshareapp.showToast 8 | import kotlinx.android.synthetic.main.activity_second.* 9 | 10 | class SecondActivity : AppCompatActivity() { 11 | 12 | companion object { 13 | val TAG: String = SecondActivity::class.java.simpleName 14 | } 15 | 16 | override fun onCreate(savedInstanceState: Bundle?) { 17 | super.onCreate(savedInstanceState) 18 | setContentView(R.layout.activity_second) 19 | 20 | // Safe Call ?. 21 | // Safe Call with let ?.let { } 22 | 23 | val bundle: Bundle? = intent.extras 24 | 25 | bundle?.let { 26 | val msg = bundle.getString(Constants.USER_MSG_KEY) 27 | showToast(msg) 28 | txvUserMessage.text = msg 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/smartherd/msgshareapp/adapters/HobbiesAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.smartherd.msgshareapp.adapters 2 | 3 | import android.content.Context 4 | import android.content.Intent 5 | import android.support.v7.widget.RecyclerView 6 | import android.view.LayoutInflater 7 | import android.view.View 8 | import android.view.ViewGroup 9 | import com.smartherd.msgshareapp.R 10 | import com.smartherd.msgshareapp.models.Hobby 11 | import com.smartherd.msgshareapp.showToast 12 | import kotlinx.android.synthetic.main.list_item.view.* 13 | 14 | class HobbiesAdapter(val context: Context, private val hobbies: List) : RecyclerView.Adapter() { 15 | 16 | companion object { 17 | val TAG: String = HobbiesAdapter::class.java.simpleName 18 | } 19 | 20 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { 21 | val view = LayoutInflater.from(context).inflate(R.layout.list_item, parent, false) 22 | return MyViewHolder(view) 23 | } 24 | 25 | override fun getItemCount(): Int { 26 | return hobbies.size 27 | } 28 | 29 | override fun onBindViewHolder(holder: MyViewHolder, position: Int) { 30 | val hobby = hobbies[position] 31 | holder.setData(hobby, position) 32 | } 33 | 34 | inner class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { 35 | 36 | var currentHobby: Hobby? = null 37 | var currentPosition: Int = 0 38 | 39 | init { 40 | itemView.setOnClickListener { 41 | currentHobby?.let { 42 | context.showToast(currentHobby!!.title + " Clicked !") 43 | } 44 | } 45 | 46 | itemView.imgShare.setOnClickListener { 47 | 48 | currentHobby?.let { 49 | val message: String = "My hobby is: " + currentHobby!!.title 50 | 51 | val intent = Intent() 52 | intent.action = Intent.ACTION_SEND 53 | intent.putExtra(Intent.EXTRA_TEXT, message) 54 | intent.type = "text/plain" 55 | 56 | context.startActivity(Intent.createChooser(intent, "Please select app: ")) 57 | } 58 | } 59 | } 60 | 61 | fun setData(hobby: Hobby?, pos: Int) { 62 | hobby?.let { 63 | itemView.txvTitle.text = hobby.title 64 | } 65 | 66 | this.currentHobby = hobby 67 | this.currentPosition = pos 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/smartherd/msgshareapp/models/Model.kt: -------------------------------------------------------------------------------- 1 | package com.smartherd.msgshareapp.models 2 | 3 | data class Hobby(var title: String) 4 | 5 | object Supplier { 6 | 7 | val hobbies = listOf( 8 | Hobby("Swimming"), 9 | Hobby("Reading"), 10 | Hobby("Walking"), 11 | Hobby("Sleeping"), 12 | Hobby("Gaming"), 13 | Hobby("Programming"), 14 | Hobby("Talking"), 15 | Hobby("Swimming"), 16 | Hobby("Reading"), 17 | Hobby("Walking"), 18 | Hobby("Sleeping"), 19 | Hobby("Gaming"), 20 | Hobby("Programming"), 21 | Hobby("Talking"), 22 | Hobby("Swimming"), 23 | Hobby("Reading"), 24 | Hobby("Walking"), 25 | Hobby("Sleeping"), 26 | Hobby("Gaming"), 27 | Hobby("Programming"), 28 | Hobby("Talking"), 29 | Hobby("Swimming"), 30 | Hobby("Reading"), 31 | Hobby("Walking"), 32 | Hobby("Sleeping"), 33 | Hobby("Gaming"), 34 | Hobby("Programming"), 35 | Hobby("Talking"), 36 | Hobby("Swimming"), 37 | Hobby("Reading"), 38 | Hobby("Walking"), 39 | Hobby("Sleeping"), 40 | Hobby("Gaming"), 41 | Hobby("Programming"), 42 | Hobby("Talking") 43 | ) 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 11 | 16 | 21 | 26 | 31 | 36 | 41 | 46 | 51 | 56 | 61 | 66 | 71 | 76 | 81 | 86 | 91 | 96 | 101 | 106 | 111 | 116 | 121 | 126 | 131 | 136 | 141 | 146 | 151 | 156 | 161 | 166 | 171 | 172 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_hobbies.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 |