Browse Source

more #1309

renovate/org.robolectric-robolectric-4.x
Austin Huang 4 years ago
parent
commit
7e00dcc1b7
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 20
      app/src/main/java/awais/instagrabber/db/Converters.java
  2. 9
      app/src/main/java/awais/instagrabber/dialogs/CreateBackupDialogFragment.java
  3. 1
      app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationArgs.java
  4. 3
      app/src/main/java/awais/instagrabber/utils/MediaUploadHelper.kt
  5. 5
      app/src/main/java/awais/instagrabber/utils/TextUtils.kt
  6. 8
      app/src/main/java/awais/instagrabber/utils/VoiceRecorder.java
  7. 8
      app/src/main/java/awais/instagrabber/viewmodels/ImageEditViewModel.java
  8. 7
      app/src/main/java/awaisomereport/CrashReporterHelper.java

20
app/src/main/java/awais/instagrabber/db/Converters.java

@ -6,20 +6,20 @@ import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZoneOffset; import java.time.ZoneOffset;
import java.util.Date;
//import java.util.Date;
import awais.instagrabber.models.enums.FavoriteType; import awais.instagrabber.models.enums.FavoriteType;
public class Converters { public class Converters {
@TypeConverter
public static Date fromTimestamp(Long value) {
return value == null ? null : new Date(value);
}
@TypeConverter
public static Long dateToTimestamp(Date date) {
return date == null ? null : date.getTime();
}
// @TypeConverter
// public static Date fromTimestamp(Long value) {
// return value == null ? null : new Date(value);
// }
//
// @TypeConverter
// public static Long dateToTimestamp(Date date) {
// return date == null ? null : date.getTime();
// }
@TypeConverter @TypeConverter
public static FavoriteType fromFavoriteTypeString(String value) { public static FavoriteType fromFavoriteTypeString(String value) {

9
app/src/main/java/awais/instagrabber/dialogs/CreateBackupDialogFragment.java

@ -19,8 +19,8 @@ import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import java.io.File; import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;
import java.util.Locale; import java.util.Locale;
import awais.instagrabber.databinding.DialogCreateBackupBinding; import awais.instagrabber.databinding.DialogCreateBackupBinding;
@ -34,7 +34,7 @@ import static awais.instagrabber.utils.DownloadUtils.PERMS;
public class CreateBackupDialogFragment extends DialogFragment { public class CreateBackupDialogFragment extends DialogFragment {
private static final int STORAGE_PERM_REQUEST_CODE = 8020; private static final int STORAGE_PERM_REQUEST_CODE = 8020;
private static final SimpleDateFormat BACKUP_FILE_DATE_TIME_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
private static final DateTimeFormatter BACKUP_FILE_DATE_TIME_FORMAT = DateTimeFormatter.ofPattern("yyyyMMddHHmmss", Locale.US);
private final OnResultListener onResultListener; private final OnResultListener onResultListener;
private DialogCreateBackupBinding binding; private DialogCreateBackupBinding binding;
@ -142,8 +142,7 @@ public class CreateBackupDialogFragment extends DialogFragment {
final DirectoryChooser directoryChooser = new DirectoryChooser() final DirectoryChooser directoryChooser = new DirectoryChooser()
.setInitialDirectory(folderPath) .setInitialDirectory(folderPath)
.setInteractionListener(path -> { .setInteractionListener(path -> {
final Date now = new Date();
final File file = new File(path, String.format("barinsta_%s.backup", BACKUP_FILE_DATE_TIME_FORMAT.format(now)));
final File file = new File(path, String.format("barinsta_%s.backup", LocalDateTime.now().format(BACKUP_FILE_DATE_TIME_FORMAT)));
int flags = 0; int flags = 0;
if (binding.cbExportFavorites.isChecked()) { if (binding.cbExportFavorites.isChecked()) {
flags |= ExportImportUtils.FLAG_FAVORITES; flags |= ExportImportUtils.FLAG_FAVORITES;

1
app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationArgs.java

@ -2,7 +2,6 @@ package awais.instagrabber.repositories.responses.notification;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;

3
app/src/main/java/awais/instagrabber/utils/MediaUploadHelper.kt

@ -6,6 +6,7 @@ import awais.instagrabber.models.UploadPhotoOptions
import awais.instagrabber.models.UploadVideoOptions import awais.instagrabber.models.UploadVideoOptions
import awais.instagrabber.models.enums.MediaItemType import awais.instagrabber.models.enums.MediaItemType
import org.json.JSONObject import org.json.JSONObject
import java.time.Instant
import java.util.* import java.util.*
import kotlin.random.Random import kotlin.random.Random
@ -106,7 +107,7 @@ fun createUploadDmVoiceOptions(
} }
fun generateUploadId(): String { fun generateUploadId(): String {
return (Date().time / 1000).toString()
return Instant.now().epochSecond.toString()
} }
fun generateName(uploadId: String): String { fun generateName(uploadId: String): String {

5
app/src/main/java/awais/instagrabber/utils/TextUtils.kt

@ -94,9 +94,6 @@ object TextUtils {
@JvmStatic @JvmStatic
fun nowToString(): String { fun nowToString(): String {
return LocalDateTime.ofInstant(
Instant.now(),
ZoneId.systemDefault()
).format(datetimeParser)
return LocalDateTime.now().format(datetimeParser)
} }
} }

8
app/src/main/java/awais/instagrabber/utils/VoiceRecorder.java

@ -9,9 +9,9 @@ import android.webkit.MimeTypeMap;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import java.io.File; import java.io.File;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -24,7 +24,7 @@ public class VoiceRecorder {
private static final int AUDIO_BIT_DEPTH = 16; private static final int AUDIO_BIT_DEPTH = 16;
private static final int AUDIO_BIT_RATE = AUDIO_SAMPLE_RATE * AUDIO_BIT_DEPTH; private static final int AUDIO_BIT_RATE = AUDIO_SAMPLE_RATE * AUDIO_BIT_DEPTH;
private static final String FILE_FORMAT = "yyyy-MM-dd-HH-mm-ss-SSS"; private static final String FILE_FORMAT = "yyyy-MM-dd-HH-mm-ss-SSS";
private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat(FILE_FORMAT, Locale.US);
private static final DateTimeFormatter SIMPLE_DATE_FORMAT = DateTimeFormatter.ofPattern(FILE_FORMAT, Locale.US);
private final List<Float> waveform = new ArrayList<>(); private final List<Float> waveform = new ArrayList<>();
private final File recordingsDir; private final File recordingsDir;
@ -141,7 +141,7 @@ public class VoiceRecorder {
@NonNull @NonNull
private File getAudioRecordFile() { private File getAudioRecordFile() {
final String name = String.format("%s-%s.%s", FILE_PREFIX, SIMPLE_DATE_FORMAT.format(new Date()), EXTENSION);
final String name = String.format("%s-%s.%s", FILE_PREFIX, LocalDateTime.now().format(SIMPLE_DATE_FORMAT), EXTENSION);
return new File(recordingsDir, name); return new File(recordingsDir, name);
} }

8
app/src/main/java/awais/instagrabber/viewmodels/ImageEditViewModel.java

@ -10,9 +10,9 @@ import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import java.io.File; import java.io.File;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -34,7 +34,7 @@ public class ImageEditViewModel extends AndroidViewModel {
private static final String CROP = "crop"; private static final String CROP = "crop";
private static final String RESULT = "result"; private static final String RESULT = "result";
private static final String FILE_FORMAT = "yyyyMMddHHmmssSSS"; private static final String FILE_FORMAT = "yyyyMMddHHmmssSSS";
private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat(FILE_FORMAT, Locale.US);
private static final DateTimeFormatter SIMPLE_DATE_FORMAT = DateTimeFormatter.ofPattern(FILE_FORMAT, Locale.US);
private Uri originalUri; private Uri originalUri;
private SavedImageEditState savedImageEditState; private SavedImageEditState savedImageEditState;
@ -55,7 +55,7 @@ public class ImageEditViewModel extends AndroidViewModel {
public ImageEditViewModel(final Application application) { public ImageEditViewModel(final Application application) {
super(application); super(application);
sessionId = SIMPLE_DATE_FORMAT.format(new Date());
sessionId = LocalDateTime.now().format(SIMPLE_DATE_FORMAT);
outputDir = DirectoryUtils.getOutputMediaDirectory(application, "Edit", sessionId); outputDir = DirectoryUtils.getOutputMediaDirectory(application, "Edit", sessionId);
destinationFile = new File(outputDir, RESULT + ".jpg"); destinationFile = new File(outputDir, RESULT + ".jpg");
destinationUri = Uri.fromFile(destinationFile); destinationUri = Uri.fromFile(destinationFile);

7
app/src/main/java/awaisomereport/CrashReporterHelper.java

@ -16,7 +16,7 @@ import java.io.FileReader;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.io.Writer; import java.io.Writer;
import java.util.Date;
import java.time.LocalDateTime;
import awais.instagrabber.BuildConfig; import awais.instagrabber.BuildConfig;
import awais.instagrabber.R; import awais.instagrabber.R;
@ -28,9 +28,10 @@ public final class CrashReporterHelper {
public static void startErrorReporterActivity(@NonNull final Application application, public static void startErrorReporterActivity(@NonNull final Application application,
@NonNull final Throwable exception) { @NonNull final Throwable exception) {
final StringBuilder reportBuilder = new StringBuilder(); final StringBuilder reportBuilder = new StringBuilder();
reportBuilder.append("IMPORTANT: If sending by email, your email address and the entire content will be made public on GitHub issues.")
reportBuilder.append("IMPORTANT: If sending by email, your email address and the entire content will be made public at")
.append("\r\nIMPORTANT: https://github.com/austinhuang0131/barinsta/issues")
.append("\r\nIMPORTANT: When possible, please describe the steps leading to this crash. Thank you for your cooperation.") .append("\r\nIMPORTANT: When possible, please describe the steps leading to this crash. Thank you for your cooperation.")
.append("\r\n\r\nError report collected on: ").append(new Date().toString())
.append("\r\n\r\nError report collected on: ").append(LocalDateTime.now().toString())
.append("\r\n\r\nInformation:\r\n==============") .append("\r\n\r\nInformation:\r\n==============")
.append("\r\nVERSION : ").append(BuildConfig.VERSION_NAME) .append("\r\nVERSION : ").append(BuildConfig.VERSION_NAME)
.append("\r\nVERSION_CODE : ").append(BuildConfig.VERSION_CODE) .append("\r\nVERSION_CODE : ").append(BuildConfig.VERSION_CODE)

Loading…
Cancel
Save