Пример #1
0
 public static String getLatestChangeLog() throws IOException {
   String toReturn =
       Jsoup.connect(URL_LATEST_CHANGE_LOG).followRedirects(false).execute().body().trim();
   Log.d(LOG_TAG, "getLatestChangeLog changeLog: " + toReturn);
   if (toReturn.toLowerCase().contains("<html>")) throw new IOException("Wrong page loaded");
   return toReturn;
 }
Пример #2
0
 public static Integer getLatestVersionCode() throws IOException, NumberFormatException {
   Integer toReturn =
       Integer.parseInt(
           Jsoup.connect(URL_LATEST_VERSION_CODE).followRedirects(false).execute().body().trim());
   Log.d(LOG_TAG, "getLatestVersionCode versionCode: " + toReturn);
   return toReturn;
 }
Пример #3
0
 public static String getLatestTerms(String languageShortcut) throws IOException {
   String toReturn =
       Jsoup.connect(URL_LATEST_TERMS + languageShortcut.toUpperCase(Locale.ENGLISH))
           .followRedirects(false)
           .execute()
           .body()
           .trim();
   Log.d(LOG_TAG, "getLatestTerms terms: " + toReturn);
   if (toReturn.toLowerCase().contains("<html>")) throw new IOException("Wrong page loaded");
   return toReturn;
 }
Пример #4
0
 public static String getLatestVersionName() throws IOException {
   String toReturn =
       Jsoup.connect(URL_LATEST_VERSION_NAME)
           .followRedirects(false)
           .execute()
           .body()
           .replace("\n", "");
   Log.d(LOG_TAG, "getLatestVersionName versionName: " + toReturn);
   if (toReturn.toLowerCase().contains("<html>")) throw new IOException("Wrong page loaded");
   return toReturn;
 }
  @Override
  public void onReceive(Context context, Intent intent) {
    Log.d(LOG_TAG, "onReceive");
    int day = intent.getIntExtra(TimetableScheduleReceiver.DAY, -1);
    int lessonIndex = intent.getIntExtra(TimetableScheduleReceiver.LESSON_INDEX, -1);
    if (day != -1
        && lessonIndex != -1
        && context
            .getSharedPreferences(Constants.SETTINGS_NAME_ATTENDANCE, Context.MODE_PRIVATE)
            .getBoolean(Constants.SETTING_NAME_DISPLAY_TEACHERS_ATTENDANCE_WARNINGS, true)) {
      testSupplementation(context, day, lessonIndex);
    }

    context.sendBroadcast(new Intent(context, TimetableScheduleReceiver.class));
  }
Пример #6
0
 public static void sendFeedback(String title, String text) throws IOException {
   Log.d(LOG_TAG, "sendFeedback title: " + title + " text: " + text);
   Jsoup.connect(URL_FEEDBACK)
       .followRedirects(false)
       .method(Connection.Method.POST)
       .data(
           "APP_VERSION_NAME",
           BuildConfig.VERSION_NAME,
           "APP_VERSION_CODE",
           String.valueOf(BuildConfig.VERSION_CODE),
           "NAME",
           title,
           "TEXT",
           text)
       .execute();
 }
  private void testSupplementation(final Context context, final int day, final int lessonIndex) {
    Log.d(LOG_TAG, "testSupplementation day: " + day + " lessonIndex: " + lessonIndex);
    if (TimetableSelectActivity.timetableManager == null)
      TimetableSelectActivity.timetableManager = new TimetableManager(context);
    final Timetable[] timetables = TimetableSelectActivity.timetableManager.getTimetables();
    final AttendanceConnector connector = new AttendanceConnector();

    ApplicationBase.WORKER.startWorker(
        new Runnable() {
          @Override
          public void run() {
            for (int i = 0, timetablesLength = timetables.length; i < timetablesLength; i++) {
              final Timetable timetable = timetables[i];
              final Lesson lesson = timetable.getLesson(day, lessonIndex);
              if (lesson == null) continue;

              final int finalI = i < 10 ? i : 9;
              try {
                String teacherName = lesson.getTeacher();
                if (teacherName.length() != 4) {
                  String[] name = teacherName.split(" ");
                  teacherName = name[name.length - 1];
                } else {
                  teacherName = teacherName.toLowerCase();
                  TeachersManager teachersManager = new TeachersManager(context);
                  for (Teacher teacher : teachersManager.get()) {
                    if (teacher.getShortcut().equals(teacherName)) {
                      teacherName = teacher.getSurname();
                      break;
                    }
                  }
                }
                List<Man> mans = Mans.parseMans(connector.getSupElements(teacherName, 1));
                Man man = null;
                for (int j = 0; j < mans.size(); j++) {
                  man = mans.get(j);
                  if (man.getClassString().length() > 4) break;
                  else man = null;
                }
                if (man != null && Man.IsInSchoolState.NOT_IN_SCHOOL.equals(man.isInSchool())) {
                  Notification n =
                      new NotificationCompat.Builder(context)
                          .setContentTitle(
                              Utils.getFormattedText(
                                  context,
                                  R.string.notify_title_substitution,
                                  lesson.getShortName()))
                          .setContentText(
                              Utils.getFormattedText(
                                  context, R.string.notify_text_teacher_is_not_here, man.getName()))
                          .setSmallIcon(R.mipmap.ic_launcher_t)
                          .setContentIntent(
                              PendingIntent.getActivity(
                                  context,
                                  0,
                                  new Intent(context, TimetableManageActivity.class)
                                      .putExtra(
                                          TimetableManageActivity.EXTRA_TIMETABLE_NAME,
                                          timetable.getName()),
                                  0))
                          .setAutoCancel(true)
                          .setDefaults(Notification.DEFAULT_ALL)
                          // .addAction(R.mipmap.ic_launcher, "And more", pIntent)
                          .build();

                  int notificationId = Constants.NOTIFICATION_ID_TEACHERS_ATTENDANCE + finalI;
                  ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE))
                      .notify(notificationId, n);

                  PostNotificationCanceler.postNotificationCancel(
                      context, notificationId, Constants.WAIT_TIME_TEACHERS_ATTENDANCE);
                }
              } catch (IOException | IndexOutOfBoundsException e) {
                Log.d("TeacherAttendanceReceiver", "testSupplementation", e);
              }
            }
          }
        },
        Build.VERSION.SDK_INT >= 11 ? goAsync() : null);
  }