Skip to content

Commit

Permalink
Merge pull request #11 from mehdiyari/dev
Browse files Browse the repository at this point in the history
Version 2.1.0
  • Loading branch information
mehdiyari authored Aug 12, 2022
2 parents c77d129 + bdc2f94 commit c4b1421
Show file tree
Hide file tree
Showing 45 changed files with 869 additions and 247 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## 2.1.0

1. Redesign the media page
2. Fix some bugs
3. Add support for deleting single and delete groups of selected media
4. Separate videos and photos folder in the encrypted gallery
5. Some improvements in video player like preventing sleep while watching video and rotation of the
player based on device sensor
6. Add flavors for development and production
7. Some UI/UX improvements

## 2.0.2

1. Fix bug of rotate device on krypt gallery

## Version 2.0.1

1. Implement video player for encrypted videos
Expand Down
38 changes: 18 additions & 20 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ plugins {
id 'androidx.navigation.safeargs'
}

apply from: "${rootProject.projectDir}/flavors.gradle"

android {
compileSdk 32

defaultConfig {
applicationId "ir.mehdiyari.krypt"
minSdk 23
targetSdk 32
versionCode 12
versionName "2.0.1"
versionCode 14
versionName "2.1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -55,36 +57,31 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

def lifecycle_version = "2.4.1"
def lifecycle_version = "2.5.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"


def nav_version = "2.4.2"
def nav_version = "2.5.1"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

def room_version = "2.4.2"
def room_version = "2.4.3"
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"

def camerax_version = "1.2.0-alpha01"
implementation "androidx.camera:camera-camera2:$camerax_version"
implementation "androidx.camera:camera-lifecycle:$camerax_version"
implementation "androidx.camera:camera-view:1.2.0-alpha01"

def hilt_version = "2.38.1"
implementation "com.google.dagger:hilt-android:${hilt_version}"
kapt "com.google.dagger:hilt-compiler:${hilt_version}"

implementation 'androidx.activity:activity-compose:1.5.0'
implementation 'androidx.compose.material:material:1.1.1'
implementation 'androidx.compose.animation:animation:1.1.1'
implementation 'androidx.compose.ui:ui-tooling:1.1.1'
implementation 'androidx.activity:activity-compose:1.5.1'
implementation 'androidx.compose.material:material:1.2.0'
implementation 'androidx.compose.animation:animation:1.2.0'
implementation 'androidx.compose.ui:ui-tooling:1.2.0'
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
androidTestImplementation 'androidx.compose.ui:ui-test-junit4:1.1.1'
implementation "androidx.navigation:navigation-compose:2.5.0"
androidTestImplementation 'androidx.compose.ui:ui-test-junit4:1.2.0'
implementation "androidx.navigation:navigation-compose:2.5.1"
implementation "androidx.constraintlayout:constraintlayout-compose:1.1.0-alpha03"


Expand All @@ -96,12 +93,13 @@ dependencies {
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.recyclerview:recyclerview-selection:1.1.0"

implementation 'com.github.mehdiyari:Fallery:1.0.1'
implementation 'com.github.mehdiyari:Fallery:1.0.2'

implementation 'com.github.bumptech.glide:glide:4.12.0'
kapt 'com.github.bumptech.glide:compiler:4.12.0'
implementation 'com.github.bumptech.glide:glide:4.13.2'
kapt 'com.github.bumptech.glide:compiler:4.13.2'
implementation "com.github.skydoves:landscapist-glide:1.6.1"

implementation "com.squareup.moshi:moshi-kotlin:1.13.0"
implementation 'com.jakewharton:process-phoenix:2.1.2'
implementation 'com.google.android.exoplayer:exoplayer:2.18.0'
implementation 'com.google.android.exoplayer:exoplayer:2.18.1'
}
5 changes: 5 additions & 0 deletions app/src/Development/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/white" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/src/Development/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Krypt [Dev]</string>
</resources>
4 changes: 4 additions & 0 deletions app/src/Production/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Krypt</string>
</resources>
23 changes: 17 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
android:name=".ui.media.player.PlayerActivity"
android:exported="false"
android:launchMode="singleInstancePerTask"
android:screenOrientation="sensor"
android:theme="@style/Theme.Krypt" />

<activity
Expand All @@ -37,32 +38,42 @@
android:launchMode="singleTask"
android:theme="@style/Theme.Krypt"
android:windowSoftInputMode="stateHidden|adjustResize">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.SEND" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="text/plain" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.SEND" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="image/*" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="video/*" />
</intent-filter>

<data android:mimeType="image/*" />
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="video/*" />
</intent-filter>

</activity>

<provider
Expand Down
14 changes: 8 additions & 6 deletions app/src/main/java/ir/mehdiyari/krypt/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,20 @@ class MainActivity : AppCompatActivity(), AppLockerStopApi {
shareDataViewModel.handleSharedText(
intent.getStringExtra(Intent.EXTRA_TEXT)
)
} else if (intent.type?.startsWith("image/") == true) {
} else if (intent.type?.startsWith("image/") == true || intent.type?.startsWith("video/") == true) {
(intent.getParcelableExtra<Parcelable>(Intent.EXTRA_STREAM) as? Uri)?.let {
shareDataViewModel.handleSharedImages(it)
shareDataViewModel.handleSharedMedias(it)
}
}
} else if (intent?.action == Intent.ACTION_SEND_MULTIPLE) {
if (intent.type?.startsWith("image/") == true) {
if (intent.type?.startsWith("image/") == true
|| intent.type?.startsWith("video/") == true || intent.type?.startsWith("*/*") == true
) {
intent.getParcelableArrayListExtra<Parcelable>(Intent.EXTRA_STREAM)?.let {
shareDataViewModel.handleSharedImages(*it.mapNotNull { image -> image as? Uri }
.toTypedArray())
shareDataViewModel.handleSharedMedias(
*it.mapNotNull { image -> image as? Uri }
.toTypedArray())
}

}
}
}
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/ir/mehdiyari/krypt/data/file/FilesDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface FilesDao {
@Query("select * from files where id = :id and accountName = :accountName LIMIT 1")
suspend fun getFileById(accountName: String, id: Long): FileEntity?

@Query("select * from files where accountName = :accountName and type in (:mediaType)")
@Query("select * from files where accountName = :accountName and type in (:mediaType) order by id DESC")
suspend fun getAllMedia(
accountName: String,
mediaType: List<FileTypeEnum> = listOf(FileTypeEnum.Photo, FileTypeEnum.Video)
Expand All @@ -50,4 +50,11 @@ interface FilesDao {

@Query("select filePath from files where accountName = :accountName")
suspend fun getAllFilesPath(accountName: String): List<String>?

@Query("select * from files where accountName = :accountName and type in (:mediaType) and metaData like :thumbFileName LIMIT 1")
suspend fun getMediaFileByPath(
accountName: String,
thumbFileName: String,
mediaType: List<FileTypeEnum> = listOf(FileTypeEnum.Photo, FileTypeEnum.Video)
): FileEntity?
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,37 @@ class FilesRepository @Inject constructor(
FileTypeEnum.Video
)

suspend fun getLastEncryptedMediaThumbnail(): String? =
internalGetLastThumb(FileTypeEnum.Photo, FileTypeEnum.Video)

suspend fun getLastEncryptedPhotoThumbnail(): String? =
filedDao.getAllFilesOfCurrentAccountBasedOnType(
currentUser.accountName!!,
FileTypeEnum.Photo, FileTypeEnum.Video
).lastOrNull {
it.metaData.isNotBlank()
}?.metaData
internalGetLastThumb(FileTypeEnum.Photo)

suspend fun getLastEncryptedVideoThumbnail(): String? =
internalGetLastThumb(FileTypeEnum.Video)

private suspend fun internalGetLastThumb(
vararg types: FileTypeEnum
): String? = filedDao.getAllFilesOfCurrentAccountBasedOnType(
currentUser.accountName!!,
*types
).lastOrNull {
it.metaData.isNotBlank()
}?.metaData

suspend fun getAllEncryptedMedia(): List<FileEntity> =
filedDao.getAllMedia(
currentUser.accountName!!
)

suspend fun mapThumbnailsAndNameToFileEntity(photos: Array<String>): List<FileEntity> =
suspend fun mapThumbnailsAndNameToFileEntity(medias: Array<String>): List<FileEntity> =
mutableListOf<FileEntity>().apply {
getAllEncryptedMedia().filter {
photos.any { currentPhoto ->
if (!currentPhoto.contains("/")) {
it.filePath.contains(currentPhoto)
medias.any { currentMedia ->
if (!currentMedia.contains("/")) {
it.filePath.contains(currentMedia)
} else {
val nameOfFile = filesUtilities.getNameOfFile(currentPhoto)
val nameOfFile = filesUtilities.getNameOfFileWithExtension(currentMedia)
it.metaData.contains(nameOfFile) || it.filePath.contains(nameOfFile)
}
}
Expand Down Expand Up @@ -118,4 +128,27 @@ class FilesRepository @Inject constructor(

return total
}

suspend fun getAllImages(): List<FileEntity> = filedDao.getAllMedia(
currentUser.accountName!!, listOf(FileTypeEnum.Photo)
)

suspend fun getAllVideos(): List<FileEntity> = filedDao.getAllMedia(
currentUser.accountName!!, listOf(FileTypeEnum.Video)
)

suspend fun getPhotosCount(): Long = filedDao.getFilesCountBasedOnType(
currentUser.accountName!!,
FileTypeEnum.Photo
)

suspend fun getVideosCount(): Long = filedDao.getFilesCountBasedOnType(
currentUser.accountName!!,
FileTypeEnum.Video
)

suspend fun getFileByThumbPath(thumbFileName: String): FileEntity? =
filedDao.getMediaFileByPath(
currentUser.accountName!!, thumbFileName
)
}
24 changes: 1 addition & 23 deletions app/src/main/java/ir/mehdiyari/krypt/ui/data/DataViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ir.mehdiyari.krypt.data.repositories.backup.BackupRepository
import ir.mehdiyari.krypt.di.qualifiers.DispatcherIO
import ir.mehdiyari.krypt.utils.FilesUtilities
import ir.mehdiyari.krypt.utils.MediaStoreManager
import ir.mehdiyari.krypt.utils.formatSize
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Job
Expand Down Expand Up @@ -148,28 +149,6 @@ class DataViewModel @Inject constructor(
}
}

private fun formatSize(size: Long): String {
var internalSize = size
var suffix: String?
if (internalSize >= 1024) {
suffix = "KB"
internalSize /= 1024
if (internalSize >= 1024) {
suffix = "MB"
internalSize /= 1024
if (internalSize >= 1024) {
suffix = "GB"
internalSize /= 1024

}
}
} else {
suffix = "Bytes"
}

return "$internalSize $suffix"
}

fun cancelBackup() {
backupJob?.cancel()
backupJob = null
Expand All @@ -181,4 +160,3 @@ class DataViewModel @Inject constructor(
backupJob = null
}
}

17 changes: 9 additions & 8 deletions app/src/main/java/ir/mehdiyari/krypt/ui/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ir.mehdiyari.krypt.app.MainActivity
import ir.mehdiyari.krypt.data.file.FileTypeEnum
import ir.mehdiyari.krypt.ui.media.MediaFragmentAction
import ir.mehdiyari.krypt.ui.media.MediaFragmentArgs
import ir.mehdiyari.krypt.ui.media.SharedImagesListModel
import ir.mehdiyari.krypt.ui.media.SharedMediaListModel
import ir.mehdiyari.krypt.ui.text.add.AddTextFragmentArgs
import ir.mehdiyari.krypt.utils.APP_DOMAIN
import ir.mehdiyari.krypt.utils.openBrowser
Expand Down Expand Up @@ -65,10 +65,10 @@ class HomeFragment : Fragment() {
if (sharedDataState != null) {
if (sharedDataState is SharedDataState.SharedText) {
navigateToNewTextFragment(sharedDataState.text)
} else if (sharedDataState is SharedDataState.SharedImages) {
} else if (sharedDataState is SharedDataState.SharedMedias) {
navigateToMediasFragment(
MediaFragmentAction.ENCRYPT_MEDIA,
SharedImagesListModel(sharedDataState.images)
SharedMediaListModel(sharedDataState.medias)
)
}
}
Expand Down Expand Up @@ -106,15 +106,16 @@ class HomeFragment : Fragment() {

private fun navigateToMediasFragment(
photosAction: MediaFragmentAction,
sharedImageList: SharedImagesListModel? = null
sharedImageList: SharedMediaListModel? = null
) {
try {
findNavController().navigate(
R.id.photosFragment,
MediaFragmentArgs.Builder().apply {
action = photosAction
sharedImages = sharedImageList
}.build().toBundle(),
MediaFragmentArgs.Builder(sharedImageList)
.apply {
action = photosAction
sharedMedias = sharedImageList
}.build().toBundle(),
navOptions {
this.anim {
this.enter = android.R.anim.slide_in_left
Expand Down
Loading

0 comments on commit c4b1421

Please sign in to comment.