Skip to content

Commit

Permalink
Merge pull request #46 from roozbehzarei/dev
Browse files Browse the repository at this point in the history
Release v2.3.2
  • Loading branch information
roozbehzarei authored Apr 9, 2024
2 parents e3d2ce9 + 9670789 commit b1a8d5d
Show file tree
Hide file tree
Showing 16 changed files with 98 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Filester
</h1>
<p align="center">
A secure, accessible cloud sotrage app for android.
A secure, accessible cloud storage app for android.
</p>
<p align="center">
<a style="text-decoration:none" href="LICENSE">
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId = "com.roozbehzarei.filester"
minSdk = 21
targetSdk = 34
versionCode = 7
versionName = "2.3.1"
versionCode = 8
versionName = "2.3.2"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.roozbehzarei.filester.database

import com.roozbehzarei.filester.model.Version

data class MainUiState(
val appVersion: Version? = null,
val isFileDeleted: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.roozbehzarei.filester.domain

import android.util.Log
import com.roozbehzarei.filester.model.OshiResponse

class ParseOshiResponseUseCase() {

operator fun invoke(response: String): OshiResponse {
val lines = response.split("\n")
var manageUrl = ""
var downloadUrl = ""
for (line in lines) {
if (line.startsWith("MANAGE: ")) {
manageUrl = line.substring(8) // Skip "MANAGE: "
} else if (line.startsWith("DL: ")) {
downloadUrl = line.substring(4) // Skip "DL: "
}
}

return OshiResponse(manageUrl = manageUrl, downloadUrl = downloadUrl)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.roozbehzarei.filester.model

data class OshiResponse(
val manageUrl: String,
val downloadUrl: String
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.roozbehzarei.filester.database
package com.roozbehzarei.filester.model

import com.squareup.moshi.JsonClass

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.roozbehzarei.filester.network

import com.roozbehzarei.filester.database.Version
import com.roozbehzarei.filester.model.Version
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import retrofit2.Response
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.roozbehzarei.filester.network

import okhttp3.MultipartBody
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.scalars.ScalarsConverterFactory
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part

private const val OSHI_URL = "https://oshi.at"

/**
* The Retrofit object with the Scalars converter.
*/
private val retrofit: Retrofit = Retrofit.Builder()
.baseUrl(OSHI_URL)
.addConverterFactory(ScalarsConverterFactory.create())
.build()

/**
* A public interface that exposes the [sendFile] method
*/
interface OshiApiService {
@Multipart
@POST("/?expire=1800")
suspend fun sendFile(
@Part("f") filePart: MultipartBody.Part
): Response<String>
}

/**
* A public Api object that exposes the lazy-initialized Retrofit service
*/
object OshiApi {
val retrofitService:
TransferApiService by lazy { retrofit.create(TransferApiService::class.java) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part

private const val BASE_URL = "https://transfer.sh"
private const val TRANSFER_URL = "https://transfer.sh"

/**
* The Retrofit object with the Scalars converter.
*/
private val retrofit: Retrofit = Retrofit.Builder()
.baseUrl(BASE_URL)
.baseUrl(TRANSFER_URL)
.addConverterFactory(ScalarsConverterFactory.create())
.build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updatePadding
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.google.android.material.appbar.AppBarLayout
import com.roozbehzarei.filester.R
import com.roozbehzarei.filester.databinding.ActivityMainBinding
import kotlinx.coroutines.launch

/**
* Main Activity and entry point for the app.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ class SettingsFragment : PreferenceFragmentCompat() {
key = "file_hosting_service"
title = getString(R.string.file_hosting_service)
dialogTitle = getString(R.string.file_hosting_service)
entries = arrayOf(getString(R.string.link_transfer))
entryValues = arrayOf(getString(R.string.link_transfer))
setDefaultValue(getString(R.string.link_transfer))
summary = getString(R.string.link_transfer)
entries = arrayOf(getString(R.string.link_oshi))
entryValues = arrayOf(getString(R.string.link_oshi))
setDefaultValue(getString(R.string.link_oshi))
summary = getString(R.string.link_oshi)
}

val languagePreference = ListPreference(context)
with(languagePreference) {
key = "language"
title = getString(R.string.language)
dialogTitle = getString(R.string.language)
entries = arrayOf(getString(R.string.english), getString(R.string.persian))
entryValues = arrayOf("en-US", "fa-IR")
entries = arrayOf(getString(R.string.english),getString(R.string.turkish) ,getString(R.string.persian))
entryValues = arrayOf("en-US","tr" ,"fa-IR")
setDefaultValue("en-US")
summaryProvider = ListPreference.SimpleSummaryProvider.getInstance()
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.content.Intent
import android.content.pm.ServiceInfo
import android.net.Uri
import android.os.Build
import android.util.Log
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import androidx.work.CoroutineWorker
Expand All @@ -17,7 +18,8 @@ import androidx.work.workDataOf
import com.roozbehzarei.filester.BaseApplication
import com.roozbehzarei.filester.FilesterBroadcastReceiver
import com.roozbehzarei.filester.R
import com.roozbehzarei.filester.network.TransferApi
import com.roozbehzarei.filester.domain.ParseOshiResponseUseCase
import com.roozbehzarei.filester.network.OshiApi
import com.roozbehzarei.filester.ui.MainActivity
import com.roozbehzarei.filester.viewmodel.KEY_FILE_NAME
import com.roozbehzarei.filester.viewmodel.KEY_FILE_URI
Expand Down Expand Up @@ -66,13 +68,13 @@ class UploadWorker(private val context: Context, params: WorkerParameters) :
context.getString(R.string.notification_title_in_progress)
)
)
val apiResponse = TransferApi.retrofitService.sendFile(filePart)
val responseBody = apiResponse.body()
if (apiResponse.isSuccessful && !responseBody.isNullOrEmpty()) {
val outputData = workDataOf(KEY_FILE_URI to responseBody)
val apiResponse = OshiApi.retrofitService.sendFile(filePart)
if (apiResponse.isSuccessful && !apiResponse.body().isNullOrEmpty()) {
val oshiResponse = ParseOshiResponseUseCase().invoke(apiResponse.body()!!)
val outputData = workDataOf(KEY_FILE_URI to oshiResponse.downloadUrl)
val newFileEntry = com.roozbehzarei.filester.database.File(
fileName = file.name,
fileUrl = responseBody,
fileUrl = oshiResponse.downloadUrl,
fileSize = file.length() / 1024 / 1024
)
fileDao.insert(newFileEntry)
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-fa-rIR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<string name="link_website">وبسایت</string>
<string name="link_privacy_policy">سیاست حفظ حریم خصوصی</string>
<string name="title_upload_success">بارگذاری انجام شد</string>
<string name="message_upload_success">فایل آپلود شده برای 14 روز آینده در دسترس خواهد بود.</string>
<string name="message_upload_success">فایل آپلود شده برای 30 روز آینده در دسترس خواهد بود.</string>
<string name="dialog_button_copy">کپی نشانی</string>
<string name="dialog_button_close">بستن</string>
<string name="title_upload_error">بارگذاری انجام نشد</string>
Expand Down Expand Up @@ -53,5 +53,6 @@
<string name="send">ارسال</string>
<string name="crash_notification_title">برنامه با خطا مواجه شد</string>
<string name="crash_notification_text">لطفا گزارش خطا را به توسعه دهنده ارسال نمایید.</string>
<string name="turkish">ترکی</string>

</resources>
6 changes: 2 additions & 4 deletions app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
<string name="app_version">Sürüm %1$s</string>
<string name="app_copyleft">Copyleft © 2024, Roozbeh Zarei</string>
<string name="menu_about">Hakkında</string>
<string name="link_transfer" translatable="false">transfer.sh</string>
<string name="link_donate">Bağış Yapın</string>
<string name="link_website">Web sitesi</string>
<string name="link_privacy_policy">Gizlilik Politikası</string>
<string name="title_upload_success">Yükleme başarılı</string>
<string name="message_upload_success">Yüklediğiniz dosya önümüzdeki 14 gün boyunca kullanılabilir olacaktır.</string>
<string name="message_upload_success">Yüklediğiniz dosya önümüzdeki 30 gün boyunca kullanılabilir olacaktır.</string>
<string name="dialog_button_copy">Bağlantıyı Kopyala</string>
<string name="dialog_button_close">Kapat</string>
<string name="title_upload_error">Yükleme başarısız</string>
Expand All @@ -23,8 +22,6 @@
<string name="channel_description">Yükleme devam ederken, başarılı veya başarısız olduğunda bildir.</string>
<string name="fab_label">Dosya yükle</string>
<string name="settings">Ayarlar</string>
<string name="empty" translatable="false" />
<string name="notification_channel_id" translatable="false">filester_notification_id</string>
<string name="notification_title_start">Karşıya yükleme başlatılıyor...</string>
<string name="notification_title_in_progress">Yükleniyor...</string>
<string name="english">İngilizce</string>
Expand Down Expand Up @@ -55,4 +52,5 @@
<string name="send">Gönder</string>
<string name="crash_notification_title">Uygulama çöktü</string>
<string name="crash_notification_text">Lütfen geliştiriciye bir rapor gönderin.</string>
<string name="turkish">Türkçe</string>
</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
<string name="app_copyleft">Copyleft © 2024 by Roozbeh Zarei</string>
<string name="menu_about">About</string>
<string name="link_transfer" translatable="false">transfer.sh</string>
<string name="link_oshi" translatable="false">oshi.at</string>
<string name="link_donate">Donate</string>
<string name="link_website">Website</string>
<string name="link_privacy_policy">Privacy Policy</string>
<string name="title_upload_success">Upload successful</string>
<string name="message_upload_success">Your uploaded file will be available for the next 14 days.</string>
<string name="message_upload_success">Your uploaded file will be available for the next 30 days.</string>
<string name="dialog_button_copy">Copy Link</string>
<string name="dialog_button_close">Close</string>
<string name="title_upload_error">Upload failed</string>
Expand All @@ -29,6 +30,7 @@
<string name="notification_title_in_progress">Uploading…</string>
<string name="english">English</string>
<string name="persian">Persian</string>
<string name="turkish">Turkish</string>
<string name="dark">Dark</string>
<string name="light">Light</string>
<string name="system_default">System default</string>
Expand Down
2 changes: 2 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Replaced transfer.sh hosting service with oshi.at due to downtime issues
* Added Turkish translation

0 comments on commit b1a8d5d

Please sign in to comment.