浏览代码

[설정][New] 추천인 코드 공유: 이메일

hyodong.min 7 年之前
父节点
当前提交
e010d300c5

+ 19 - 6
app/src/main/java/kr/co/zumo/app/lifeplus/view/command/EmailSendingCommand.java

@@ -5,7 +5,9 @@ package kr.co.zumo.app.lifeplus.view.command;
 
 import android.content.Intent;
 
+import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.model.Model;
+import kr.co.zumo.app.lifeplus.util.ResourceUtil;
 import kr.co.zumo.app.lifeplus.view.IView;
 import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
 
@@ -20,10 +22,18 @@ import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
  * @since 2018-10-08
  */
 public class EmailSendingCommand extends Command<Model, IView, Presenter> {
-  String email;
+  private String email;
+  private String subject;
+  private String text;
 
-  public EmailSendingCommand(String email) {
+  public EmailSendingCommand(String emailTo) {
+    this.email = emailTo;
+  }
+
+  public EmailSendingCommand(String email, String subject, String text) {
     this.email = email;
+    this.subject = subject;
+    this.text = text;
   }
 
   @Override
@@ -33,12 +43,15 @@ public class EmailSendingCommand extends Command<Model, IView, Presenter> {
 
   @Override
   public void execute(Model model, IView view, Presenter presenter) {
-    Intent email = new Intent(Intent.ACTION_SEND);
-    email.setType("plain/text");
+    Intent emailIntent = new Intent(Intent.ACTION_SEND);
+    emailIntent.setType("plain/text");
     // email setting 배열로 해놔서 복수 발송 가능
     String[] address = {this.email};
-    email.putExtra(Intent.EXTRA_EMAIL, address);
-    view.getActivity().startActivity(email);
+    emailIntent.putExtra(Intent.EXTRA_EMAIL, address);
+
+    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
+    emailIntent.putExtra(Intent.EXTRA_TEXT, text);
+    view.getActivity().startActivity(Intent.createChooser(emailIntent, ResourceUtil.getString(R.string.sending_email)));
   }
 
   @Override

+ 6 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/dialog/CurrentPageShareDialog.java

@@ -71,6 +71,12 @@ public class CurrentPageShareDialog extends DialogBase {
       }
     });
 
+    getView().findViewById(R.id.image_view_email).setOnClickListener(view -> {
+      if (null != getCustomListener()) {
+        getCustomListener().onDialogResult(CurrentPageShareDialog.this, new Event.Builder(Event.EMAIL_CLICK).build());
+      }
+    });
+
 
   }
 

+ 7 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/setting/SettingModel.java

@@ -199,9 +199,14 @@ public class SettingModel extends Model {
     return StringUtil.isFull(settingBean.getAppVersion()) ? StringUtil.getPureVersionString(newVersionString) : "0";
   }
 
-  public String getMyRecommendCode(){
+  /**
+   * 내 추천 코드 반환
+   *
+   * @return
+   */
+  public String getMyRecommendCode() {
     String recommendCode = settingBean.getMyRecommendCode();
-      return recommendCode;
+    return recommendCode;
   }
 
   /**

+ 22 - 18
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/setting/SettingPresenter.java

@@ -40,6 +40,7 @@ import kr.co.zumo.app.lifeplus.util.ResourceUtil;
 import kr.co.zumo.app.lifeplus.util.StringUtil;
 import kr.co.zumo.app.lifeplus.view.Event;
 import kr.co.zumo.app.lifeplus.view.command.AppUpdateCommand;
+import kr.co.zumo.app.lifeplus.view.command.EmailSendingCommand;
 import kr.co.zumo.app.lifeplus.view.command.NotificationSettingCommand;
 import kr.co.zumo.app.lifeplus.view.dialog.CurrentPageShareDialog;
 import kr.co.zumo.app.lifeplus.view.dialog.DialogBase;
@@ -203,24 +204,17 @@ public class SettingPresenter extends Presenter<SettingModel, ISettingView> {
                         break;
                       case Event.KAKAO_TALK:
                         //카카오링크
-                        try {
-//                          KakaoLink kakaoLink = KakaoLink.getKakaoLink(view.getActivity());
-//                          KakaoTalkLinkMessageBuilder messageBuilder = kakaoLink.createKakaoTalkLinkMessageBuilder();
-//                          messageBuilder.addText("카카오톡으로 공유해요.");
-//                          kakaoLink.sendMessage(messageBuilder, view.getActivity());
-
-                          sendKakaoLink();
-                        } catch (Throwable e) {
-                          e.printStackTrace();
-                        }
+                        sendKakaoLink();
                         break;
                       case Event.FACE_BOOK:
-                        Log.e("APP#  SettingPresenter | onDialogResult", "|" + "facebook");
                         sendFaceBook();
                         break;
                       case Event.CODE_COPY:
                         sendClipBoardCopy();
                         break;
+                      case Event.EMAIL_CLICK:
+                        sendEmail();
+                        break;
                       default:
                         break;
                     }
@@ -275,6 +269,12 @@ public class SettingPresenter extends Presenter<SettingModel, ISettingView> {
 
   }
 
+  private void sendEmail() {
+    String subject = ResourceUtil.getString(R.string.share_title, ResourceUtil.getString(R.string.share_recommend_code_subject));
+    String contents = ResourceUtil.getString(R.string.share_recommend_code_contents, model.getMyRecommendCode());
+    onCommand(new EmailSendingCommand("", subject, contents));
+  }
+
   private void sendKakaoLink() {
     FeedTemplate params = FeedTemplate
       .newBuilder(ContentObject.newBuilder("디저트 사진",
@@ -341,11 +341,14 @@ public class SettingPresenter extends Presenter<SettingModel, ISettingView> {
 
   private void sendClipBoardCopy() {
 
-    ClipboardManager clipboardManager =  (ClipboardManager) view.getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
+    ClipboardManager clipboardManager = (ClipboardManager) view.getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
     ClipData clipData = ClipData.newPlainText("code", model.getMyRecommendCode());
-    clipboardManager.setPrimaryClip(clipData);
-    Log.i("APP# SettingPresenter | sendClipBoardCopy", "|" + model.getMyRecommendCode());
-    showToast("", "URL이 복사되었습니다", 1);
+    try {
+      clipboardManager.setPrimaryClip(clipData);
+      showToast("", "URL이 복사되었습니다", 1);
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
 
   }
 
@@ -415,7 +418,7 @@ public class SettingPresenter extends Presenter<SettingModel, ISettingView> {
     }
   }
 
-  private void showToast(String title, String detail , @Nullable int copyToastFlag) {
+  private void showToast(String title, String detail, @Nullable int copyToastFlag) {
 
     Context context = App.getInstance().getContext();
     Toast toast = new Toast(context);
@@ -423,9 +426,10 @@ public class SettingPresenter extends Presenter<SettingModel, ISettingView> {
     toast.setGravity(Gravity.FILL, 0, 0);
     LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     View view;
-    if(copyToastFlag!=0){
+    if (copyToastFlag != 0) {
       view = inflater.inflate(R.layout.setting_toast_url_copy_pop_up, null);
-    }else{
+    }
+    else {
       view = inflater.inflate(R.layout.setting_toast_pop_up, null);
       ((TextView) view.findViewById(R.id.setting_toast_title)).setText(title);
       ((TextView) view.findViewById(R.id.setting_toast_detail)).setText(detail);

+ 11 - 0
app/src/main/res/values/strings.xml

@@ -617,5 +617,16 @@
   <string name="month_week">%1$d월 %2$d주차</string>
 
   <string name="url_copy_message">URL이 복사되었습니다</string>
+  <string name="share_title">[Lifeplus] %s</string>
+  <string name="share_recommend_code_subject">추천인 코드 공유</string>
+  <string name="share_recommend_code_contents">"[Lifeplus] 추천인 코드 공유\n\n
+추천인 코드: %s
+\n\n
+Lifeplus에서 더 다양한 컨텐츠를 확인하세요!
+\n\n
+아직 Lifeplus App이 없으시다면 아래 경로에서 다운로드 받으세요!
+\n\n
+App 다운로드 : http://www.lifeplus.co.kr"</string>
+  <string name="sending_email">"이메일 보내기"</string>
 
 </resources>