public int onStartCommand(Intent intent, int flags, int startId) {
   path = intent.getStringExtra("path");
   if (path == null) {
     stopSelf();
     return Service.START_NOT_STICKY;
   }
   FileLog.e("tmessages", "start video service");
   if (builder == null) {
     builder = new NotificationCompat.Builder(ApplicationLoader.applicationContext);
     builder.setSmallIcon(android.R.drawable.stat_sys_upload);
     builder.setWhen(System.currentTimeMillis());
     builder.setContentTitle(LocaleController.getString("AppName", R.string.AppName));
     builder.setTicker(LocaleController.getString("SendingVideo", R.string.SendingVideo));
     builder.setContentText(LocaleController.getString("SendingVideo", R.string.SendingVideo));
   }
   currentProgress = 0;
   builder.setProgress(100, currentProgress, currentProgress == 0);
   startForeground(4, builder.build());
   NotificationManagerCompat.from(ApplicationLoader.applicationContext).notify(4, builder.build());
   return Service.START_NOT_STICKY;
 }
Esempio n. 2
0
  public static String formatDateOnline(long date) {
    Calendar rightNow = Calendar.getInstance();
    int day = rightNow.get(Calendar.DAY_OF_YEAR);
    int year = rightNow.get(Calendar.YEAR);
    rightNow.setTimeInMillis(date * 1000);
    int dateDay = rightNow.get(Calendar.DAY_OF_YEAR);
    int dateYear = rightNow.get(Calendar.YEAR);

    if (dateDay == day && year == dateYear) {
      return String.format(
          "%s %s %s",
          LocaleController.getString("LastSeen", R.string.LastSeen),
          LocaleController.getString("TodayAt", R.string.TodayAt),
          formatterDay.format(new Date(date * 1000)));
    } else if (dateDay + 1 == day && year == dateYear) {
      return String.format(
          "%s %s %s",
          LocaleController.getString("LastSeen", R.string.LastSeen),
          LocaleController.getString("YesterdayAt", R.string.YesterdayAt),
          formatterDay.format(new Date(date * 1000)));
    } else if (year == dateYear) {
      return String.format(
          "%s %s %s %s",
          LocaleController.getString("LastSeenDate", R.string.LastSeenDate),
          formatterMonth.format(new Date(date * 1000)),
          LocaleController.getString("OtherAt", R.string.OtherAt),
          formatterDay.format(new Date(date * 1000)));
    } else {
      return String.format(
          "%s %s %s %s",
          LocaleController.getString("LastSeenDate", R.string.LastSeenDate),
          formatterYear.format(new Date(date * 1000)),
          LocaleController.getString("OtherAt", R.string.OtherAt),
          formatterDay.format(new Date(date * 1000)));
    }
  }