Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show remaining time on wave form view and cache wave form in database.
- Loading branch information
1 parent
e01838e
commit 3fec23f
Showing
33 changed files
with
355 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
app/src/main/java/org/thoughtcrime/securesms/audio/AudioHash.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.thoughtcrime.securesms.audio; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
import org.thoughtcrime.securesms.database.model.databaseprotos.AudioWaveFormData; | ||
import org.whispersystems.util.Base64; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* An AudioHash is a compact string representation of the wave form and duration for an audio file. | ||
*/ | ||
public final class AudioHash { | ||
|
||
@NonNull private final String hash; | ||
@NonNull private final AudioWaveFormData audioWaveForm; | ||
|
||
private AudioHash(@NonNull String hash, @NonNull AudioWaveFormData audioWaveForm) { | ||
this.hash = hash; | ||
this.audioWaveForm = audioWaveForm; | ||
} | ||
|
||
public AudioHash(@NonNull AudioWaveFormData audioWaveForm) { | ||
this(Base64.encodeBytes(audioWaveForm.toByteArray()), audioWaveForm); | ||
} | ||
|
||
public static @Nullable AudioHash parseOrNull(@Nullable String hash) { | ||
if (hash == null) return null; | ||
try { | ||
return new AudioHash(hash, AudioWaveFormData.parseFrom(Base64.decode(hash))); | ||
} catch (IOException e) { | ||
return null; | ||
} | ||
} | ||
|
||
@NonNull AudioWaveFormData getAudioWaveForm() { | ||
return audioWaveForm; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
AudioHash other = (AudioHash) o; | ||
return hash.equals(other.hash); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return hash.hashCode(); | ||
} | ||
|
||
public @NonNull String getHash() { | ||
return hash; | ||
} | ||
} |
Oops, something went wrong.