Browse Source

[공통][New] 다이나믹 링크 처리 액티비티 변경
- Splash -> ContentGate

hyodong.min 6 years ago
parent
commit
773344a7de

+ 15 - 15
app/src/main/AndroidManifest.xml

@@ -35,21 +35,6 @@
 
         <category android:name="android.intent.category.LAUNCHER"/>
       </intent-filter>
-      <intent-filter>
-        <action android:name="android.intent.action.VIEW"/>
-
-        <category android:name="android.intent.category.DEFAULT"/>
-        <category android:name="android.intent.category.BROWSABLE"/>
-
-        <!-- firebase dynamic links -->
-        <data
-          android:host="www.zumo.co.kr"
-          android:scheme="http"/>
-        <data
-          android:host="www.zumo.co.kr"
-          android:scheme="https"/>
-
-      </intent-filter>
     </activity>
 
     <!-- Activity -->
@@ -68,6 +53,21 @@
           android:scheme="@string/kakao_scheme"/>
 
       </intent-filter>
+      <intent-filter>
+        <action android:name="android.intent.action.VIEW"/>
+
+        <category android:name="android.intent.category.DEFAULT"/>
+        <category android:name="android.intent.category.BROWSABLE"/>
+
+        <!-- firebase dynamic links -->
+        <data
+          android:host="www.zumo.co.kr"
+          android:scheme="http"/>
+        <data
+          android:host="www.zumo.co.kr"
+          android:scheme="https"/>
+
+      </intent-filter>
     </activity>
     <activity
       android:name=".lifeplus.activity.MainActivity"

+ 3 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/activity/AppInitializer.java

@@ -4,6 +4,7 @@
 package kr.co.zumo.app.lifeplus.activity;
 
 import android.content.Context;
+import android.util.Log;
 
 import kr.co.zumo.app.lifeplus.helper.FirebaseHelper;
 import kr.co.zumo.app.lifeplus.model.SuperModel;
@@ -78,5 +79,7 @@ public class AppInitializer {
     ActivityDeliveryHelper.getInstance().dispose();
     ActivityDeliveryResultHelper.getInstance().dispose();
     ActivityScreenIDDeliveryHelper.getInstance().dispose();
+
+    Log.d("APP# AppInitializer | disposeHelpers", "|" + " ******************************************************************** disposed *");
   }
 }

+ 44 - 6
app/src/main/java/kr/co/zumo/app/lifeplus/activity/ContentsGateActivity.java

@@ -4,6 +4,8 @@ import android.content.Intent;
 import android.net.Uri;
 import android.util.Log;
 
+import com.google.firebase.dynamiclinks.FirebaseDynamicLinks;
+
 import kr.co.zumo.app.lifeplus.model.SuperModel;
 import kr.co.zumo.app.lifeplus.view.IWaiterCallable;
 import kr.co.zumo.app.lifeplus.view.animation.LoadingDriver;
@@ -26,16 +28,54 @@ public class ContentsGateActivity extends ActivityBaseSetup {
   @Override
   protected void setup() {
 
-    Uri uri = getIntent().getData();
+    // 카카오 링크, 위젯 데이터와 다이나믹 링크를 구분
+
+    FirebaseDynamicLinks.getInstance()
+      .getDynamicLink(getIntent())
+      .addOnSuccessListener(this, pendingDynamicLinkData -> {
+        Log.d("APP# ContentsGateActivity | setup", "|" + "========== pendingDynamicLinkData .............. ");
+
+        // Get deep link from result (may be null if no link is found)
+        Uri uri;
+        if (pendingDynamicLinkData != null) {
+          /**
+           * 다이나믹 링크
+           */
+          uri = pendingDynamicLinkData.getLink();
+          Log.i("APP# ContentsGateActivity | setup", "| dynamic -> " + uri.toString());
+          parse(uri, () -> next());
+        }
+        else {
+          /**
+           * 카카오/위젯
+           */
+          uri = getIntent().getData();
+          Log.i("APP# ContentsGateActivity | setup", "| uri -> " + uri.toString());
+          parse(uri, () -> next());
+
+          getIntent().setData(null);
+        }
+      })
+      .addOnFailureListener(this, e -> {
+        Log.e("APP#  ContentsGateActivity | onFailure", "|" + "e -> " + e);
+        next();
+      });
+
+  }
+
+  private void parse(Uri uri, Runnable nextRunnable) {
     if (null != uri) {
       Log.i("APP# ContentsGateActivity | onCreate", "|" + uri.toString());
 
-      /**
+      /*
        * 데이터만 준비한다.
        *
        * 모든 예외 사항들( 잠금 화면 등)을 넘어서 메인 컨텐츠 를 표시 할 수 있을 때 데이터를 이용해서 컨텐츠를 표시한다.
        */
 
+      // 카카오 링크, 위젯 데이터와 다이나믹 링크를 구분
+
+
       LoadingDriver loadingDriver = new LoadingDriver();
       deepLinkParser = new DeepLinkParser();
       deepLinkParser.parse(getApplicationContext(), uri, new IWaiterCallable() {
@@ -49,15 +89,13 @@ public class ContentsGateActivity extends ActivityBaseSetup {
           loadingDriver.remove();
         }
       }, () -> {
-        next();
+        nextRunnable.run();
       });
     }
     else {
+      // 데이터 없음.
       finish();
     }
-
-    getIntent().setData(null);
-
   }
 
   private void next() {

+ 2 - 54
app/src/main/java/kr/co/zumo/app/lifeplus/activity/SplashActivity.java

@@ -2,14 +2,11 @@ package kr.co.zumo.app.lifeplus.activity;
 
 import android.content.Context;
 import android.content.Intent;
-import android.net.Uri;
 import android.support.annotation.NonNull;
 import android.support.v4.app.ActivityCompat;
 import android.support.v4.app.FragmentActivity;
 import android.util.Log;
 
-import com.google.firebase.dynamiclinks.FirebaseDynamicLinks;
-
 import java.util.Arrays;
 
 import io.reactivex.android.schedulers.AndroidSchedulers;
@@ -22,8 +19,6 @@ import kr.co.zumo.app.lifeplus.helper.FirebaseHelper;
 import kr.co.zumo.app.lifeplus.model.SuperModel;
 import kr.co.zumo.app.lifeplus.model.SuperModelInit;
 import kr.co.zumo.app.lifeplus.network.NetworkWatcher;
-import kr.co.zumo.app.lifeplus.view.IWaiterCallable;
-import kr.co.zumo.app.lifeplus.view.animation.LoadingDriver;
 
 /**
  * Splash 화면
@@ -39,7 +34,6 @@ public class SplashActivity extends ActivityBaseSetup implements ISplashContract
 
   CompositeDisposable disposable = new CompositeDisposable();
   ScreenStarter starter;
-  DeepLinkParser deepLinkParser;
 
   ISplashContract.Presenter presenter;
 
@@ -60,48 +54,6 @@ public class SplashActivity extends ActivityBaseSetup implements ISplashContract
     presenter.onResume();
   }
 
-  private void controlDynamicLink() {
-    Log.d("APP# SplashActivity | controlDynamicLink", "|" + "..");
-    /**
-     * 다이나믹 링크가 지정한 액티비티로 연계되지 않고 항상 런쳐 액티비티로 전달된다.
-     * 어쩔 수 없이 런쳐에 해당 코드를 삽입
-     * -> 수정 가능하다면 ContentsGateActivity 로 통일하는 것이 좋음
-     */
-    FirebaseDynamicLinks.getInstance()
-      .getDynamicLink(getIntent())
-      .addOnSuccessListener(this, pendingDynamicLinkData -> {
-        Log.d("APP# SplashActivity | setup", "|" + "========== pendingDynamicLinkData ..............");
-
-        // Get deep link from result (may be null if no link is found)
-        Uri uri = null;
-        if (pendingDynamicLinkData != null) {
-          uri = pendingDynamicLinkData.getLink();
-
-          LoadingDriver loadingDriver = new LoadingDriver();
-          deepLinkParser = new DeepLinkParser();
-          deepLinkParser.parse(getApplicationContext(), uri, new IWaiterCallable() {
-            @Override
-            public void showWaiter() {
-              loadingDriver.create(SplashActivity.this, 100);
-            }
-
-            @Override
-            public void hideWaiter() {
-              loadingDriver.remove();
-            }
-          }, () -> {
-            next();
-          });
-        }
-        else {
-          next();
-        }
-      })
-      .addOnFailureListener(this, e -> {
-        Log.e("APP#  SplashActivity | onFailure", "|" + "e -> " + e);
-        next();
-      });
-  }
 
   private void next() {
     setupInternal();
@@ -175,10 +127,6 @@ public class SplashActivity extends ActivityBaseSetup implements ISplashContract
 
   @Override
   protected void onBeforeDestroy() {
-    if (null != deepLinkParser) {
-      deepLinkParser.dispose();
-      deepLinkParser = null;
-    }
   }
 
   @Override
@@ -214,8 +162,8 @@ public class SplashActivity extends ActivityBaseSetup implements ISplashContract
 
   @Override
   public void onPermissionCompleted() {
-    // 권한 처리 종료
-    controlDynamicLink();
+    // 권한 처리 종료 -> 앱 시작
+    next();
   }
 
   @Override