Compare commits
No commits in common. "e5ce2fcdb24d7628a86091170da09ac9c7c2f201" and "3e6fe310e096d7543d82358b04be4ff3b540afc3" have entirely different histories.
e5ce2fcdb2
...
3e6fe310e0
@ -1,5 +1,4 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("org.jetbrains.kotlin.android")
|
|
||||||
androidApplication
|
androidApplication
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7,7 +6,7 @@ val packageName = "ru.myitschool.work"
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = packageName
|
namespace = packageName
|
||||||
compileSdk = 35
|
compileSdk = Version.Android.Sdk.compile
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = packageName
|
applicationId = packageName
|
||||||
@ -25,12 +24,8 @@ android {
|
|||||||
sourceCompatibility = Version.Kotlin.javaSource
|
sourceCompatibility = Version.Kotlin.javaSource
|
||||||
targetCompatibility = Version.Kotlin.javaSource
|
targetCompatibility = Version.Kotlin.javaSource
|
||||||
}
|
}
|
||||||
kotlinOptions {
|
|
||||||
jvmTarget = "1.8"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("androidx.core:core-ktx:+")
|
|
||||||
defaultLibrary()
|
defaultLibrary()
|
||||||
}
|
}
|
||||||
|
@ -11,29 +11,6 @@
|
|||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.Default"
|
android:theme="@style/Theme.Default"
|
||||||
tools:targetApi="31" >
|
tools:targetApi="31" />
|
||||||
<activity
|
|
||||||
android:exported="true"
|
|
||||||
android:enabled="true"
|
|
||||||
android:name=".MainActivity"
|
|
||||||
android:screenOrientation="portrait">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity
|
|
||||||
android:exported="true"
|
|
||||||
android:enabled="true"
|
|
||||||
android:name=".GetActivity"
|
|
||||||
android:screenOrientation="portrait">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.SEND"/>
|
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
|
||||||
<!-- TODO ... Реализовать в xml возможность принятия изображений и текста для активити GetActivity -->
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
</application>
|
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -1,45 +0,0 @@
|
|||||||
package ru.myitschool.work
|
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.provider.MediaStore
|
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.TextView
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
|
|
||||||
|
|
||||||
class GetActivity : AppCompatActivity(){
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setContentView(R.layout.getter_activity)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
|
|
||||||
val intent = intent
|
|
||||||
|
|
||||||
// Figure out what to do based on the intent type
|
|
||||||
|
|
||||||
// Figure out what to do based on the intent type
|
|
||||||
if (intent.type!!.indexOf("image/") != -1) {
|
|
||||||
val imageView = findViewById<ImageView>(R.id.IV)
|
|
||||||
val bitmap = getBitmap(intent)
|
|
||||||
imageView.setImageBitmap(bitmap)
|
|
||||||
} else if (intent.type == "text/plain") {
|
|
||||||
val textView = findViewById<TextView>(R.id.TV)
|
|
||||||
val text = getText(intent)
|
|
||||||
textView.text = text
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getBitmap(intent: Intent):Bitmap{
|
|
||||||
TODO() //Реализовать получение картинки из Intent
|
|
||||||
}
|
|
||||||
private fun getText(intent: Intent):String{
|
|
||||||
TODO() //Реализовать получение текста из Intent
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
package ru.myitschool.work
|
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.os.Environment
|
|
||||||
import android.provider.MediaStore
|
|
||||||
import android.view.View
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.activity.result.ActivityResultCallback
|
|
||||||
import androidx.activity.result.PickVisualMediaRequest
|
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setContentView(R.layout.activity_main)
|
|
||||||
val handler: View.OnClickListener = View.OnClickListener { v ->
|
|
||||||
when (v.id) {
|
|
||||||
R.id.buttonShareTextUrl -> shareTextUrl()
|
|
||||||
R.id.buttonShareImage -> shareImage()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
findViewById<View>(R.id.buttonShareTextUrl).setOnClickListener(handler)
|
|
||||||
findViewById<View>(R.id.buttonShareImage).setOnClickListener(handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun shareTextUrl() {
|
|
||||||
val share = Intent(Intent.ACTION_SEND)
|
|
||||||
share.type = "text/plain"
|
|
||||||
share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
|
||||||
|
|
||||||
share.putExtra(Intent.EXTRA_SUBJECT, "Hello from my app")
|
|
||||||
share.putExtra(Intent.EXTRA_TEXT, "http://myitschool.ru")
|
|
||||||
startActivity(Intent.createChooser(share, "Share link!"))
|
|
||||||
Toast.makeText(applicationContext, "Text shared", Toast.LENGTH_LONG).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun shareImage() {
|
|
||||||
|
|
||||||
val request = PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)
|
|
||||||
requestPicker.launch(request)
|
|
||||||
}
|
|
||||||
|
|
||||||
val requestPicker = registerForActivityResult(ActivityResultContracts.PickMultipleVisualMedia()) { uris ->
|
|
||||||
|
|
||||||
|
|
||||||
TODO()//Реализовать requestPicker по выбору картинки и отправке в друго приложение с выбором
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:context=".MainActivity">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/buttonShareTextUrl"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:text="@string/share_text_or_url" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/buttonShareImage"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_below="@+id/buttonShareTextUrl"
|
|
||||||
android:text="@string/share_image" />
|
|
||||||
</RelativeLayout>
|
|
@ -1,20 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical">
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/IV"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
</ImageView>
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/TV"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
</TextView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -1,5 +1,3 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Work</string>
|
<string name="app_name">Work</string>
|
||||||
<string name="share_text_or_url">share_text_or_url</string>
|
|
||||||
<string name="share_image">share_image</string>
|
|
||||||
</resources>
|
</resources>
|
@ -2,5 +2,4 @@
|
|||||||
plugins {
|
plugins {
|
||||||
androidApplication version Version.gradle apply false
|
androidApplication version Version.gradle apply false
|
||||||
kotlinJvm version Version.Kotlin.language apply false
|
kotlinJvm version Version.Kotlin.language apply false
|
||||||
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user