Przeglądaj źródła

[설정][New] 알림 설정 Command 추가

hyodong.min 7 lat temu
rodzic
commit
27dfa53c17

+ 70 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/command/NotificationSettingCommand.java

@@ -0,0 +1,70 @@
+/*
+ * COPYRIGHT (c) 2018 All rights reserved by HANWHA LIFE.
+ */
+package kr.co.zumo.app.lifeplus.view.command;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Build;
+import android.provider.Settings;
+
+import kr.co.zumo.app.lifeplus.model.Model;
+import kr.co.zumo.app.lifeplus.view.IView;
+import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
+
+/**
+ * NotificationSettingCommand
+ * <pre>
+ * </pre>
+ *
+ * @author 민효동
+ * @version 1.0
+ * @history 민효동   [2018. 10. 29.]   [최초 작성]
+ * @since 2018. 10. 29.
+ */
+public class NotificationSettingCommand extends Command {
+  private String packageName;
+  private int uid;
+
+  public NotificationSettingCommand(String packageName, int uid) {
+    this.packageName = packageName;
+    this.uid = uid;
+  }
+
+  @Override
+  public void preExecute(Model model, IView view, Presenter presenter) {
+
+  }
+
+  @Override
+  public void execute(Model model, IView view, Presenter presenter) {
+    Intent intent = new Intent();
+    Context context = view.getActivity();
+    if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
+      intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
+      intent.putExtra("android.provider.extra.APP_PACKAGE", packageName);
+    }
+    else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+      intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
+      intent.putExtra("app_package", packageName);
+      intent.putExtra("app_uid", uid);
+    }
+    else {
+      intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
+      intent.addCategory(Intent.CATEGORY_DEFAULT);
+      intent.setData(Uri.parse("package:" + packageName));
+    }
+    context.startActivity(intent);
+  }
+
+  @Override
+  public void postExecute(Model model, IView view, Presenter presenter) {
+
+  }
+
+  @Override
+  public void dispose() {
+
+  }
+}

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

@@ -19,6 +19,7 @@ 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.FragmentBackStackChangeCommand;
+import kr.co.zumo.app.lifeplus.view.command.NotificationSettingCommand;
 import kr.co.zumo.app.lifeplus.view.command.TextShareCommand;
 import kr.co.zumo.app.lifeplus.view.dialog.DialogBase;
 import kr.co.zumo.app.lifeplus.view.dialog.DialogBuilder;
@@ -111,7 +112,7 @@ public class SettingPresenter extends Presenter<SettingModel, ISettingView> {
     if (false == isEnabled) {
       return;
     }
-    
+
     Log.i("APP# SettingPresenter | onEventInternal", "|" + event.toString());
     int index = event.getInteger();
     int id = event.getEventId();
@@ -171,9 +172,7 @@ public class SettingPresenter extends Presenter<SettingModel, ISettingView> {
 
         else if (event.getInteger() == SettingPresenter.SETTING_PUSH) {
           // 알림이 오지 않을 경우 여기를 눌러 알림 수신 허용...
-          // todo 앱 알림 세팅 처리하기
-
-
+          onCommand(new NotificationSettingCommand(AppUtil.getPackageName(), App.getInstance().getApplicationInfo().uid));
         }
         else if (event.getInteger() == SettingPresenter.SETTING_INFO) {
           // 약관/이용 안내