Browse Source

提交类型 处理问题反馈
提交内容 处理设备管理的问题反馈

Bitliker 7 years ago
parent
commit
5ed69078d2

+ 3 - 3
WeiChat/version.properties

@@ -1,5 +1,5 @@
-#Wed Aug 29 11:33:49 CST 2018
+#Thu Aug 30 12:25:43 CST 2018
 debugName=579
-versionName=645
+versionName=648
 debugCode=579
-versionCode=187
+versionCode=190

+ 24 - 3
app_modular/apptasks/src/main/java/com/modular/apptasks/presenter/SchedulePresenter.java

@@ -3,6 +3,7 @@ package com.modular.apptasks.presenter;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.common.LogUtil;
 import com.common.data.DateFormatUtil;
 import com.common.data.JSONUtil;
 import com.common.data.ListUtils;
@@ -13,6 +14,12 @@ import com.me.network.app.http.rx.Result2Listener;
 import com.me.network.app.http.rx.ResultSubscriber;
 import com.modular.apptasks.util.AlarmUtil;
 import com.uas.appworks.model.Schedule;
+import com.uas.appworks.utils.ScheduleUtils;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.TimeZone;
 
 /**
  * 日程后台计算控制器
@@ -48,7 +55,7 @@ public class SchedulePresenter {
 
     public void startSchedule() {
         getHttpClient().Api().send(new HttpClient.Builder()
-                .url("schedule/getByDaySchedule")
+                .url("schedule/byDaySchedule")
                 .add("imid", MyApplication.getInstance().getLoginUserId())
                 .add("day", DateFormatUtil.long2Str(DateFormatUtil.YMD))
                 .build(), new ResultSubscriber<>(new Result2Listener<Object>() {
@@ -71,6 +78,20 @@ public class SchedulePresenter {
 
     private void handlerDay(JSONArray jsonArray) throws Exception {
         if (!ListUtils.isEmpty(jsonArray)) {
+            Date date = new Date();
+            Calendar cal = Calendar.getInstance();
+            cal.setTimeZone(TimeZone.getTimeZone("UTC+8"));
+            cal.setTime(date);
+            cal.set(Calendar.HOUR, 0);
+            cal.set(Calendar.SECOND, 1);
+            cal.set(Calendar.MINUTE, 0);
+            cal.set(Calendar.MILLISECOND, 0);
+            long startTime = cal.getTimeInMillis();
+            long endTime = cal.getTimeInMillis() + 24 * 60 * 60 * 1000;
+            List<Schedule> systemSchedule = ScheduleUtils.getSystemCalendar(MyApplication.getInstance(), startTime, endTime);
+            for (Schedule e : systemSchedule) {
+                LogUtil.i("gong", "e=" + JSON.toJSONString(e));
+            }
             long thisTime = System.currentTimeMillis();
             int needIndex = -1;
             long needTime = -1;
@@ -87,8 +108,8 @@ public class SchedulePresenter {
             if (needIndex >= 0 && needIndex < jsonArray.size()) {
                 Schedule mSchedule = getScheduleByObject(jsonArray.getJSONObject(needIndex));
                 //获取到符合提醒的日程
-                AlarmUtil.cancelAlarm(AlarmUtil.ID_SCHEDULE,AlarmUtil.ACTION_SCHEDULE);
-                AlarmUtil.startAlarm(AlarmUtil.ID_SCHEDULE,AlarmUtil.ACTION_SCHEDULE,mSchedule.getWarnRealTime(),mSchedule);
+                AlarmUtil.cancelAlarm(AlarmUtil.ID_SCHEDULE, AlarmUtil.ACTION_SCHEDULE);
+                AlarmUtil.startAlarm(AlarmUtil.ID_SCHEDULE, AlarmUtil.ACTION_SCHEDULE, mSchedule.getWarnRealTime(), mSchedule);
             }
         }
     }

+ 4 - 5
app_modular/apptasks/src/main/java/com/modular/apptasks/util/AlarmUtil.java

@@ -60,15 +60,14 @@ public class AlarmUtil {
             manager.setExact(AlarmManager.RTC_WAKEUP
                     , nextAlarmTimeMillis
                     , getPendingIntent(id, action,mParcelable));
-        } else {
-            manager.set(AlarmManager.RTC_WAKEUP
-                    , nextAlarmTimeMillis
-                    , getPendingIntent(id, action,mParcelable));
+//        } else {
+//            manager.set(AlarmManager.RTC_WAKEUP
+//                    , nextAlarmTimeMillis
+//                    , getPendingIntent(id, action,mParcelable));
         }
     }
 
     public static void cancelAlarm(int id, String action) {
-        LogUtil.i("cancelAlarm");
         AlarmManager manager = (AlarmManager) BaseConfig.getContext().getSystemService(Context.ALARM_SERVICE);
         manager.cancel(getPendingIntent(id, action, null));
     }

+ 17 - 0
app_modular/appworks/src/main/java/com/uas/appworks/activity/ScheduleActivity.java

@@ -16,6 +16,7 @@ import android.widget.TextView;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.common.LogUtil;
 import com.common.data.DateFormatUtil;
 import com.common.data.JSONUtil;
 import com.common.data.ListUtils;
@@ -31,6 +32,7 @@ import com.modular.apputils.widget.compactcalender.domain.Event;
 import com.uas.appworks.R;
 import com.uas.appworks.datainquiry.Constants;
 import com.uas.appworks.model.Schedule;
+import com.uas.appworks.utils.ScheduleUtils;
 
 import java.util.ArrayList;
 import java.util.Calendar;
@@ -99,6 +101,7 @@ public class ScheduleActivity extends BaseNetActivity {
         compactCalendarView.setLocale(TimeZone.getDefault(), Locale.CHINESE);
         compactCalendarView.setUseThreeLetterAbbreviation(true);
         mRecyclerView.setLayoutManager(new LinearLayoutManager(ct));
+        setAdapter(null);
         changeDate(mCurrentDate);
         newDayTv.setOnClickListener(new View.OnClickListener() {
             @Override
@@ -184,6 +187,20 @@ public class ScheduleActivity extends BaseNetActivity {
 
     private void handlerDay(JSONArray jsonArray) throws Exception {
         List<Schedule> schedules = null;
+        Date date = new Date();
+        Calendar cal = Calendar.getInstance();
+        cal.setTimeZone(TimeZone.getTimeZone("UTC+8"));
+        cal.setTime(date);
+        cal.set(Calendar.HOUR, 0);
+        cal.set(Calendar.SECOND, 1);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        long startTime = cal.getTimeInMillis();
+        long endTime = cal.getTimeInMillis() + 24 * 60 * 60 * 1000;
+        List<Schedule> systemSchedule = ScheduleUtils.getSystemCalendar(MyApplication.getInstance(), startTime, endTime);
+        for (Schedule e : systemSchedule) {
+            LogUtil.i("gong", "e=" + JSON.toJSONString(e));
+        }
         if (!ListUtils.isEmpty(jsonArray)) {
             schedules = new ArrayList<>();
             Schedule chche = null;

+ 2 - 2
app_modular/appworks/src/main/java/com/uas/appworks/activity/ScheduleSettingActivity.java

@@ -15,7 +15,7 @@ import com.uas.appworks.R;
 import java.util.ArrayList;
 
 public class ScheduleSettingActivity extends BaseActivity {
-    private final String[] warns = {"不提醒", "开始时", "提前5分钟", "提前15分钟", "提前30分钟", "提前1小时", "提前一天"};
+    private final String[] warns = {"不提醒", "开始时", "提前5分钟", "提前15分钟", "提前30分钟", "提前1小时", "提前一天"};
     private final String[] repeats = {"不重复(默认)", "每天重复", "每周重复", "每月重复"};
 
     private TextView warmTimeTv;
@@ -35,7 +35,7 @@ public class ScheduleSettingActivity extends BaseActivity {
         repeatTv = (TextView) findViewById(R.id.repeatTv);
         findViewById(R.id.warmTimeRl).setOnClickListener(mOnClickListener);
         findViewById(R.id.repeatRl).setOnClickListener(mOnClickListener);
-        saveSystemSv.setClickable(PreferenceUtils.getBoolean(PreferenceUtils.Constants.SAVE_SYSTEM_SCHEDULE, true));
+        saveSystemSv.setChecked(PreferenceUtils.getBoolean(PreferenceUtils.Constants.SAVE_SYSTEM_SCHEDULE, true));
         saveSystemSv.setOnCheckedChangeListener(new SwitchView.OnCheckedChangeListener() {
             @Override
             public void onCheckedChanged(View view, boolean isChecked) {

+ 16 - 0
app_modular/appworks/src/main/java/com/uas/appworks/activity/SchedulerCreateActivity.java

@@ -23,6 +23,7 @@ import com.common.preferences.PreferenceUtils;
 import com.common.system.DisplayUtil;
 import com.core.app.MyApplication;
 import com.core.model.SelectBean;
+import com.core.utils.CommonUtil;
 import com.core.utils.time.wheel.DateTimePicker;
 import com.core.widget.view.Activity.SelectActivity;
 import com.core.widget.view.SwitchView;
@@ -235,10 +236,17 @@ public class SchedulerCreateActivity extends BaseNetActivity {
         }
         contentEd.setEnabled(isEnable);
         contentEd.setFocusable(isEnable);
+
         allDaySv.setEnabled(isEnable);
         allDaySv.setClickable(isEnable);
         allDaySv.setFocusable(isEnable);
         allDaySv.setOnCheckedChangeListener(isEnable ? mOnCheckedChangeListener : null);
+        if (isEnable){
+            contentEd.setFocusableInTouchMode(true);
+            contentEd.requestFocus();
+            contentEd.setSelection(contentEd.getText().length());
+            CommonUtil.openKeybord(contentEd,this);
+        }
     }
 
     private SwitchView.OnCheckedChangeListener mOnCheckedChangeListener = new SwitchView.OnCheckedChangeListener() {
@@ -377,6 +385,14 @@ public class SchedulerCreateActivity extends BaseNetActivity {
     }
 
     private void submit() {
+       if ( mSchedule.getStartTime()>= mSchedule.getEndTime()){
+           showToast("结束时间必须大于开始时间!!");
+           submiting=false;
+           return;
+       }
+
+
+
         showProgress();
         String url = isUpdate ? "schedule/updateSchedule" : "schedule/saveSchedule";
         mSchedule.setRemarks(contentEd.getText().toString());

+ 80 - 16
app_modular/appworks/src/main/java/com/uas/appworks/utils/ScheduleUtils.java

@@ -10,7 +10,9 @@ import android.graphics.Color;
 import android.net.Uri;
 import android.provider.CalendarContract;
 import android.support.v4.app.ActivityCompat;
+import android.util.Log;
 
+import com.alibaba.fastjson.JSON;
 import com.uas.appworks.model.Schedule;
 
 import java.util.ArrayList;
@@ -102,7 +104,9 @@ public class ScheduleUtils {
         int calId = checkCalendarAccount(context);
         if (calId < 0) {
             // 获取账户id失败直接返回,添加日历事件失败
-            return -1;
+            if (addCalendarAccount(context)==-1 ) {
+                return -1;
+            }
         }
         //开始添加日程事件
         ContentValues event = new ContentValues();
@@ -111,9 +115,10 @@ public class ScheduleUtils {
         event.put(CalendarContract.Events.TITLE, mSchedule.getTitle());//添加标题
         event.put(CalendarContract.Events.DESCRIPTION, mSchedule.getRemarks());//添加描述|备注
         event.put(CalendarContract.Events.EVENT_LOCATION, mSchedule.getAddress());//事件地点
-        event.put(CalendarContract.Events.EVENT_COLOR, Color.GREEN);//颜色
+        event.put(CalendarContract.Events.RDATE, mSchedule.getRepeat());//标签
+        event.put(CalendarContract.Events.EXDATE, mSchedule.getTag());//标签
 //        event.put(CalendarContract.Events.DISPLAY_COLOR, Color.GREEN);//显示颜色
-//        event.put(CalendarContract.Events.RDATE,"TODO");//事件重复日期
+        event.put(CalendarContract.Events.EVENT_COLOR, Color.GREEN);//颜色
         event.put(CalendarContract.Events.ORGANIZER, DEF_EMAIL);//事件所有者的名称
         event.put(CalendarContract.Events.LAST_DATE, System.currentTimeMillis() + 365 * 24 * 60 * 60 * 1000);//事件重复日期
         event.put(CalendarContract.Events.DTSTART, mSchedule.getStartTime());//日程开始时间
@@ -156,29 +161,57 @@ public class ScheduleUtils {
      * @return
      */
     public static List<Schedule> getSystemCalendar(Context context) {
-        List<Schedule> mSchedules = null;
         if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED) {
-            return mSchedules;
+            //TODO 没有权限
+            return null;
         }
         String selection = CalendarContract.Events.ORGANIZER + " =? ";
         String[] selectionArgs = new String[]{DEF_EMAIL};
+        Cursor userCursor = context.getContentResolver().query(CalendarContract.Events.CONTENT_URI,
+                null, selection, selectionArgs, null);
+        try {
+            if (userCursor == null)//查询返回空值
+                return null;
+            List<Schedule> mSchedules = new ArrayList<>();
+            while (userCursor.moveToNext()) {
+                mSchedules.add(getSchedule(userCursor));
+            }
+
+        } finally {
+            if (userCursor != null) {
+                userCursor.close();
+            }
+        }
+        return null;
+    }
+
+    public static List<Schedule> getSystemCalendar(Context context, long startTime, long endTime) {
+        List<Schedule> mSchedules = null;
+        if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_CALENDAR) != PackageManager.PERMISSION_GRANTED) {
+            return mSchedules;
+        }
+        String selection = CalendarContract.Events.CAN_PARTIALLY_UPDATE + " =? "
+                +"and ( ("
+                + CalendarContract.Events.DTSTART + " >=? and " + CalendarContract.Events.DTSTART + " <=? ) or ("
+                + CalendarContract.Events.DTEND + " >=? and " + CalendarContract.Events.DTEND + " <=? ) or ( "
+                + CalendarContract.Events.DTSTART + " <? and " + CalendarContract.Events.DTEND + " >?"
+                + " ))";
+        String[] selectionArgs = new String[]{String.valueOf(0)
+                , String.valueOf(startTime), String.valueOf(endTime)
+                , String.valueOf(startTime), String.valueOf(endTime)
+                , String.valueOf(startTime), String.valueOf(endTime)
+        };
+//        Log.i("gong", "selection=" + selection);
+//        Log.i("gong", "startTime=" + startTime);
+//        Log.i("gong", "endTime=" + endTime);
         Cursor userCursor = context.getContentResolver().query(CalendarContract.Events.CONTENT_URI,
                 null, selection, selectionArgs, null);
         try {
             if (userCursor == null)//查询返回空值
                 return null;
             mSchedules = new ArrayList<>();
-            Schedule mSchedule = null;
             while (userCursor.moveToNext()) {
-                mSchedule = new Schedule();
-                mSchedule.setId(userCursor.getInt(userCursor.getColumnIndex(CalendarContract.Events.SELF_ATTENDEE_STATUS)));
-                mSchedule.setTitle(userCursor.getString(userCursor.getColumnIndex(CalendarContract.Events.TITLE)));
-                mSchedule.setRemarks(userCursor.getString(userCursor.getColumnIndex(CalendarContract.Events.DESCRIPTION)));
-                mSchedule.setAddress(userCursor.getString(userCursor.getColumnIndex(CalendarContract.Events.EVENT_LOCATION)));
-                mSchedule.setStartTime(userCursor.getLong(userCursor.getColumnIndex(CalendarContract.Events.DTSTART)));
-                mSchedule.setEndTime(userCursor.getLong(userCursor.getColumnIndex(CalendarContract.Events.DTEND)));
-                mSchedule.setAllDay(userCursor.getInt(userCursor.getColumnIndex(CalendarContract.Events.ORIGINAL_ALL_DAY)));
-                mSchedules.add(mSchedule);
+                mSchedules.add(getSchedule(userCursor));
             }
 
         } finally {
@@ -189,7 +222,6 @@ public class ScheduleUtils {
         }
     }
 
-
     /**
      * 删除对应的日程
      *
@@ -222,4 +254,36 @@ public class ScheduleUtils {
         deleteSystemCalendar(context, mSchedule.getId());
         return addCalendarEvent(context, mSchedule);
     }
+    private static Schedule getSchedule(Cursor cursor) {
+        int calendar_id = cursor.getInt(cursor.getColumnIndex(CalendarContract.Events.CALENDAR_ID));
+        int _id = cursor.getInt(cursor.getColumnIndex(CalendarContract.Events.SELF_ATTENDEE_STATUS));
+        int event_color = cursor.getInt(cursor.getColumnIndex(CalendarContract.Events.EVENT_COLOR));
+        int has_alarm = cursor.getInt(cursor.getColumnIndex(CalendarContract.Events.HAS_ALARM));
+        int allDay = cursor.getInt(cursor.getColumnIndex(CalendarContract.Events.ORIGINAL_ALL_DAY));
+
+        long last_date = cursor.getLong(cursor.getColumnIndex(CalendarContract.Events.LAST_DATE));
+        long startTime = cursor.getLong(cursor.getColumnIndex(CalendarContract.Events.DTSTART));
+        long endTime = cursor.getLong(cursor.getColumnIndex(CalendarContract.Events.DTEND));
+
+        String title = cursor.getString(cursor.getColumnIndex(CalendarContract.Events.TITLE));
+        String remarks = cursor.getString(cursor.getColumnIndex(CalendarContract.Events.DESCRIPTION));
+        String address = cursor.getString(cursor.getColumnIndex(CalendarContract.Events.EVENT_LOCATION));
+        String rdate = cursor.getString(cursor.getColumnIndex(CalendarContract.Events.RDATE));
+        String organizer = cursor.getString(cursor.getColumnIndex(CalendarContract.Events.ORGANIZER));
+        String tag = cursor.getString(cursor.getColumnIndex(CalendarContract.Events.EXDATE));
+        Schedule mSchedule = new Schedule();
+        mSchedule.setId(_id);
+        mSchedule.setAllDay(allDay);
+        mSchedule.setStartTime(startTime);
+        mSchedule.setEndTime(endTime);
+        mSchedule.setTitle(title);
+        mSchedule.setRemarks(remarks);
+        mSchedule.setRemarks(address);
+        mSchedule.setRepeat(rdate);
+        mSchedule.setStatus(organizer);
+        mSchedule.setTag(tag);
+        Log.i("gong", JSON.toJSONString(mSchedule));
+        Log.i("gong", "_________________________________");
+        return mSchedule;
+    }
 }

+ 9 - 3
app_modular/appworks/src/main/res/layout/activity_scheduler_create.xml

@@ -152,12 +152,14 @@
 
     <TextView
         android:id="@+id/warnTimeTv"
-        android:layout_width="wrap_content"
+        android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:drawablePadding="@dimen/paddingMin"
+        android:padding="@dimen/padding"
         android:drawableRight="@drawable/oa_next"
         android:textColor="#FF909090"
         android:textSize="11sp"
+        app:layout_constraintLeft_toRightOf="@id/warnTag"
         app:layout_constraintBottom_toBottomOf="@id/warnTag"
         app:layout_constraintRight_toRightOf="@id/contentEd"
         app:layout_constraintTop_toTopOf="@id/warnTag" />
@@ -187,12 +189,14 @@
 
     <TextView
         android:id="@+id/repeatTv"
-        android:layout_width="wrap_content"
+        android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:drawablePadding="@dimen/paddingMin"
         android:drawableRight="@drawable/oa_next"
         android:textColor="#FF909090"
         android:textSize="11sp"
+        android:padding="@dimen/padding"
+        app:layout_constraintLeft_toRightOf="@id/repeatTag"
         app:layout_constraintBottom_toBottomOf="@id/repeatTag"
         app:layout_constraintRight_toRightOf="@id/contentEd"
         app:layout_constraintTop_toTopOf="@id/repeatTag" />
@@ -222,12 +226,14 @@
 
     <TextView
         android:id="@+id/typeTv"
-        android:layout_width="wrap_content"
+        android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:drawablePadding="@dimen/paddingMin"
         android:drawableRight="@drawable/oa_next"
         android:textColor="#FF909090"
         android:textSize="11sp"
+        android:padding="@dimen/padding"
+        app:layout_constraintLeft_toRightOf="@id/typeTag"
         app:layout_constraintBottom_toBottomOf="@id/typeTag"
         app:layout_constraintRight_toRightOf="@id/contentEd"
         app:layout_constraintTop_toTopOf="@id/typeTag" />