Latest changes

上级 81ae4231
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
...@@ -64,4 +64,5 @@ dependencies { ...@@ -64,4 +64,5 @@ dependencies {
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1' androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.android.support:support-compat:28.0.0'
} }
File mode changed from 100755 to 100644
...@@ -6,10 +6,21 @@ ...@@ -6,10 +6,21 @@
additional functionality it is fine to subclass or reimplement additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. --> FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application <application
android:name="io.flutter.app.FlutterApplication" android:name="io.flutter.app.FlutterApplication"
android:label="afri_shop" android:label="afri_shop"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/ic_launcher">
<provider
android:name=".GenericFileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
</provider>
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:launchMode="singleTask" android:launchMode="singleTask"
......
File mode changed from 100755 to 100644
package net.afrix.afri_shop;
import androidx.core.content.FileProvider;
public class GenericFileProvider extends FileProvider {
}
\ No newline at end of file
package net.afrix.afri_shop package net.afrix.afri_shop
import android.annotation.TargetApi
import android.content.ContentValues
import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.widget.Toast import android.widget.Toast
...@@ -8,6 +11,12 @@ import io.flutter.embedding.android.FlutterActivity ...@@ -8,6 +11,12 @@ import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel
import io.flutter.plugins.GeneratedPluginRegistrant import io.flutter.plugins.GeneratedPluginRegistrant
import android.net.Uri
import android.os.Build
import android.provider.MediaStore
import androidx.core.content.FileProvider
import java.io.File
import java.io.FileNotFoundException
class MainActivity: FlutterActivity() { class MainActivity: FlutterActivity() {
...@@ -28,7 +37,66 @@ class MainActivity: FlutterActivity() { ...@@ -28,7 +37,66 @@ class MainActivity: FlutterActivity() {
runInt(intent) runInt(intent)
} }
var url: String? = null; var url: String? = null
fun addImageToGallery(filePath: String, context: Context) : Uri? {
val values = ContentValues()
values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis())
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg")
values.put(MediaStore.MediaColumns.DATA, filePath)
return context.contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values)
}
@TargetApi(Build.VERSION_CODES.DONUT)
private fun shareFile(path: String,type: String) {
var intent = packageManager.getLaunchIntentForPackage("com.instagram.android")
if (intent != null) {
val shareIntent = Intent()
shareIntent.putExtra(Intent.EXTRA_TEXT, "AFRISHOP HERE")
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "AFRISHOP HERE")
shareIntent.putExtra(Intent.EXTRA_TITLE, "AFRISHOP HERE")
shareIntent.action = Intent.ACTION_SEND
shareIntent.setPackage("com.instagram.android")
val imageFile = File(path)
//val contentUri = FileProvider.getUriForFile(this, applicationContext.packageName + ".provider", imageFile)
// val contentUri = imageFile.toURI()
try {
shareIntent.putExtra(Intent.EXTRA_STREAM, addImageToGallery(imageFile.path,this))
} catch (e: FileNotFoundException) {
// TODO Auto-generated catch block
e.printStackTrace()
}
shareIntent.type = type
startActivity(shareIntent)
} else {
// bring user to the market to download the app.
// or let them choose an app?
intent = Intent(Intent.ACTION_VIEW)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.data = Uri.parse("market://details?id=" + "com.instagram.android")
startActivity(intent)
}
// val shareIntent = Intent(Intent.ACTION_SEND)
// shareIntent.type = "image/*"
// val files = ArrayList<Uri>()
// for(path in paths){
// val imageFile = File(path)
// val contentUri = FileProvider.getUriForFile(this, applicationContext.packageName + ".provider", imageFile)
// toast(path)
// files.add(contentUri)
// shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri)
// }
// this.startActivity(Intent.createChooser(shareIntent, "Share to"))
}
private fun runInt(intent: Intent?) { private fun runInt(intent: Intent?) {
if (channel == null) { if (channel == null) {
...@@ -41,6 +109,10 @@ class MainActivity: FlutterActivity() { ...@@ -41,6 +109,10 @@ class MainActivity: FlutterActivity() {
}else if(call.method == "deep-link"){ }else if(call.method == "deep-link"){
result.success(url) result.success(url)
url = null url = null
}else if(call.method == "shareFile"){
call.argument<String>("file")?.let { shareFile(it, call.argument("type")!!) }
result.success("done")
url = null
} }
} }
} }
......
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-files-path name="external_files" path="."/>
</paths>
\ No newline at end of file
File mode changed from 100755 to 100644
...@@ -6,7 +6,7 @@ buildscript { ...@@ -6,7 +6,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.0' classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
} }
...@@ -29,3 +29,4 @@ subprojects { ...@@ -29,3 +29,4 @@ subprojects {
task clean(type: Delete) { task clean(type: Delete) {
delete rootProject.buildDir delete rootProject.buildDir
} }
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
差异被折叠。
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
差异被折叠。
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
差异被折叠。
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
差异被折叠。
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
差异被折叠。
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
File mode changed from 100755 to 100644
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
File mode changed from 100755 to 100644
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论