Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: receive share 커스텀 공유 시트 #18

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.3"
}
compileSdkVersion flutter.compileSdkVersion

compileOptions {
Expand Down Expand Up @@ -98,5 +104,15 @@ flutter {
}

dependencies {
def composeBom = platform('androidx.compose:compose-bom:2023.01.00')
implementation composeBom
androidTestImplementation composeBom

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.activity:activity-compose:1.7.2'
implementation "androidx.appcompat:appcompat:1.6.1"
implementation "androidx.compose.ui:ui:1.4.3"
implementation "androidx.compose.runtime:runtime:1.4.3"
implementation "androidx.compose.material:material:1.4.3"
implementation "androidx.compose.ui:ui-tooling-preview:1.4.3"
}
53 changes: 33 additions & 20 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
package="com.beside.moa">

<!-- Permissions options for the `storage` group -->
<uses-feature
android:name="android.hardware.camera"
android:required="false" />

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
Expand Down Expand Up @@ -39,7 +43,35 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
>
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- 카카오톡 로그린 URL 스킴 설정 -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<!-- "kakao${YOUR_NATIVE_APP_KEY}://${PRODUCT_NAME}" 형식의 앱 실행 스킴 설정 -->
<!-- 카카오로그인 -->
<data android:scheme="kakao425f4fa4567f8679a573604ddf734236" android:host="oauth"/>
</intent-filter>
</activity>

<activity
android:name=".share.ShareActivity"
android:label="@string/title_activity_share"
android:theme="@style/Theme.Share.Transparent"
>

<intent-filter>
<action android:name="android.intent.action.SEND" />
Expand Down Expand Up @@ -83,26 +115,7 @@
<data android:mimeType="*/*" />
</intent-filter>

<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- 카카오톡 로그린 URL 스킴 설정 -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<!-- "kakao${YOUR_NATIVE_APP_KEY}://${PRODUCT_NAME}" 형식의 앱 실행 스킴 설정 -->
<!-- 카카오로그인 -->
<data android:scheme="kakao425f4fa4567f8679a573604ddf734236" android:host="oauth"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
Expand Down
18 changes: 17 additions & 1 deletion android/app/src/main/kotlin/com/beside/moa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,30 @@ package com.beside.moa
import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import androidx.annotation.NonNull
import io.flutter.FlutterInjector
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.embedding.engine.FlutterEngineCache
import io.flutter.embedding.engine.dart.DartExecutor
import io.flutter.embedding.engine.dart.DartExecutor.DartEntrypoint
import io.flutter.plugin.common.MethodChannel

class MainActivity: FlutterActivity() {
private val CHANNEL = "com.beside.moa/share"

override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler {
call, result ->
result.success("mainScreen")
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (intent.getIntExtra("org.chromium.chrome.extra.TASK_ID", -1) == this.taskId) {
this.finish()
intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
super.onCreate(savedInstanceState)
}
}
25 changes: 25 additions & 0 deletions android/app/src/main/kotlin/com/beside/moa/share/ShareActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.beside.moa.share

import android.os.Bundle
import androidx.annotation.NonNull
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel


class ShareActivity: FlutterActivity() {
private val CHANNEL = "com.beside.moa/share"

override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler {
call, result ->
if(call.method == "shareSheet"){
result.success("shareSheet")
}
else{
result.success("")
}
}
}
}
13 changes: 13 additions & 0 deletions android/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
14 changes: 14 additions & 0 deletions android/app/src/main/res/layout/flutter_view_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<io.flutter.embedding.android.FlutterView
android:id="@+id/flutter_view"
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_weight="1"
/>
</LinearLayout>
1 change: 1 addition & 0 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<string name="client_id">K10uUCEMBAnAY0ZtJMeo</string>
<string name="client_secret">qtCW1qORKI</string>
<string name="client_name">Moa-app</string>
<string name="title_activity_share">Moa</string>
</resources>
15 changes: 15 additions & 0 deletions android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,19 @@
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>

<style name="Share.Window" parent="android:Theme">
<item name="android:windowEnterAnimation">@null</item>
<item name="android:windowExitAnimation">@null</item>
</style>

<style name="Theme.Share.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowAnimationStyle">@style/Share.Window</item>
</style>
</resources>
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.8.20'
ext.kotlin_version = '1.8.10'
repositories {
google()
mavenCentral()
Expand Down
8 changes: 4 additions & 4 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ PODS:
- Firebase/Messaging (10.9.0):
- Firebase/CoreOnly
- FirebaseMessaging (~> 10.9.0)
- firebase_core (2.13.0):
- firebase_core (2.13.1):
- Firebase/CoreOnly (= 10.9.0)
- Flutter
- firebase_messaging (14.6.1):
- firebase_messaging (14.6.2):
- Firebase/Messaging (= 10.9.0)
- firebase_core
- Flutter
Expand Down Expand Up @@ -187,8 +187,8 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570
Firebase: bd152f0f3d278c4060c5c71359db08ebcfd5a3e2
firebase_core: fc68c0f9eec4e800b9418deff14a7e0a504016f3
firebase_messaging: ffb4e7c95d4daca8cef4eca0283f0ddd2b365d40
firebase_core: ce64b0941c6d87c6ef5022ae9116a158236c8c94
firebase_messaging: 42912365e62efc1ea3e00724e5eecba6068ddb88
FirebaseCore: b68d3616526ec02e4d155166bbafb8eca64af557
FirebaseCoreInternal: d2b4acb827908e72eca47a9fd896767c3053921e
FirebaseInstallations: c58489c9caacdbf27d1da60891a87318e20218e0
Expand Down
18 changes: 18 additions & 0 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,28 @@ import NaverThirdPartyLogin

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
let flutterEngine = FlutterEngine(name: "my flutter engine")

override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {

// !! how to know ShareMedia url(CFBundleURLSchemes)
// flutterEngine.run();x
// let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
// let shareChannel = FlutterMethodChannel(name: "com.beside.moa/share",
// binaryMessenger: controller.binaryMessenger)
// shareChannel.setMethodCallHandler({
// (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
// switch call.method {
// case "mainScreen":
// result("mainScreen")
// default:
// break
// }
// })

GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
Expand Down
35 changes: 22 additions & 13 deletions ios/Share Extension/ShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Social
import MobileCoreServices
import Photos

class ShareViewController: SLComposeServiceViewController {
class ShareViewController: UIViewController {
let hostAppBundleIdentifier = "com.beside.moa"
let sharedKey = "ShareKey"
var sharedMedia: [SharedMediaFile] = []
Expand All @@ -14,12 +14,21 @@ class ShareViewController: SLComposeServiceViewController {
let urlContentType = kUTTypeURL as String
let fileURLType = kUTTypeFileURL as String;

override func isContentValid() -> Bool {
return true
}
// override func isContentValid() -> Bool {
// return true
// }

override func viewDidLoad() {
super.viewDidLoad();
// view.backgroundColor = .clear

// let blurEffect = UIBlurEffect(style: .dark)
// let blurEffectView = UIVisualEffectView(effect: blurEffect)
// //always fill the view
// blurEffectView.frame = self.view.bounds
// blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

// view.insertSubview(blurEffectView, at: 0)
}

override func viewDidAppear(_ animated: Bool) {
Expand All @@ -45,14 +54,14 @@ class ShareViewController: SLComposeServiceViewController {
}
}

override func didSelectPost() {
print("didSelectPost");
}

override func configurationItems() -> [Any]! {
// To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here.
return []
}
// override func didSelectPost() {
// print("didSelectPost");
// }
//
// override func configurationItems() -> [Any]! {
// // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here.
// return []
// }

private func handleText (content: NSExtensionItem, attachment: NSItemProvider, index: Int) {
attachment.loadItem(forTypeIdentifier: textContentType, options: nil) { [weak self] data, error in
Expand Down Expand Up @@ -331,4 +340,4 @@ extension Array {
subscript (safe index: UInt) -> Element? {
return Int(index) < count ? self[Int(index)] : nil
}
}
}
Loading