1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 14:47:29 +00:00
This commit is contained in:
Austin Huang 2021-05-23 21:34:19 -04:00
parent 2395b3b892
commit 7e00dcc1b7
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
8 changed files with 29 additions and 32 deletions

View File

@ -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 // @TypeConverter
public static Date fromTimestamp(Long value) { // public static Date fromTimestamp(Long value) {
return value == null ? null : new Date(value); // return value == null ? null : new Date(value);
} // }
//
@TypeConverter // @TypeConverter
public static Long dateToTimestamp(Date date) { // public static Long dateToTimestamp(Date date) {
return date == null ? null : date.getTime(); // return date == null ? null : date.getTime();
} // }
@TypeConverter @TypeConverter
public static FavoriteType fromFavoriteTypeString(String value) { public static FavoriteType fromFavoriteTypeString(String value) {

View File

@ -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.time.format.DateTimeFormatter;
import java.util.Date; 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", LocalDateTime.now().format(BACKUP_FILE_DATE_TIME_FORMAT)));
final File file = new File(path, String.format("barinsta_%s.backup", BACKUP_FILE_DATE_TIME_FORMAT.format(now)));
int flags = 0; int flags = 0;
if (binding.cbExportFavorites.isChecked()) { if (binding.cbExportFavorites.isChecked()) {
flags |= ExportImportUtils.FLAG_FAVORITES; flags |= ExportImportUtils.FLAG_FAVORITES;

View File

@ -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;

View File

@ -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 {

View File

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

View File

@ -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);
} }

View File

@ -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);

View File

@ -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)