mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-11 08:27:50 -04:00
Changes after review
This commit is contained in:
parent
5630f96951
commit
b305ef0905
@ -32,6 +32,7 @@ import android.view.MenuInflater
|
|||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.view.ActionMode
|
import androidx.appcompat.view.ActionMode
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
@ -163,7 +164,7 @@ class LocalLibraryFragment : BaseFragment() {
|
|||||||
FILE_SELECT_CODE
|
FILE_SELECT_CODE
|
||||||
)
|
)
|
||||||
} catch (ex: ActivityNotFoundException) {
|
} catch (ex: ActivityNotFoundException) {
|
||||||
ex.printStackTrace()
|
activity.toast(resources.getString(R.string.no_app_found_to_open), Toast.LENGTH_SHORT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,4 +6,5 @@
|
|||||||
<string name="cannot_open_file">Failed to open file\nPlease try looking for this file in the Device Tab of your Library</string>
|
<string name="cannot_open_file">Failed to open file\nPlease try looking for this file in the Device Tab of your Library</string>
|
||||||
<string name="send_files_title">Send Files</string>
|
<string name="send_files_title">Send Files</string>
|
||||||
<string name="receive_files_title">Receive Files</string>
|
<string name="receive_files_title">Receive Files</string>
|
||||||
|
<string name="no_app_found_to_open" translatable="false">No app found to select zim file!</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Kiwix Android
|
||||||
|
* Copyright (c) 2022 Kiwix <android.kiwix.org>
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.kiwix.kiwixmobile.core.extensions
|
||||||
|
|
||||||
|
fun String.getStringBefore(suffix: String): String =
|
||||||
|
this.substringBefore(suffix)
|
@ -27,6 +27,7 @@ import org.kiwix.kiwixmobile.core.R
|
|||||||
import org.kiwix.kiwixmobile.core.downloader.ChunkUtils
|
import org.kiwix.kiwixmobile.core.downloader.ChunkUtils
|
||||||
import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity.Book
|
import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity.Book
|
||||||
import org.kiwix.kiwixmobile.core.extensions.get
|
import org.kiwix.kiwixmobile.core.extensions.get
|
||||||
|
import org.kiwix.kiwixmobile.core.extensions.getStringBefore
|
||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@ -103,7 +104,7 @@ object FileUtils {
|
|||||||
}
|
}
|
||||||
return try {
|
return try {
|
||||||
"${getSdCardMainPath(context)}/${documentId[1]}"
|
"${getSdCardMainPath(context)}/${documentId[1]}"
|
||||||
} catch (e: Exception) {
|
} catch (ignore: Exception) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
} else if ("com.android.providers.downloads.documents" == uri.authority)
|
} else if ("com.android.providers.downloads.documents" == uri.authority)
|
||||||
@ -243,13 +244,7 @@ object FileUtils {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic fun getSdCardMainPath(context: Context): String {
|
@JvmStatic fun getSdCardMainPath(context: Context): String =
|
||||||
var path = "${context.getExternalFilesDirs("")[1]}"
|
"${context.getExternalFilesDirs("")[1]}"
|
||||||
val separator: String = context.getString(R.string.android_directory_seperator)
|
.getStringBefore(context.getString(R.string.android_directory_seperator))
|
||||||
val sepPos = path.indexOf(separator)
|
|
||||||
if (sepPos != -1) {
|
|
||||||
path = path.substring(0, sepPos)
|
|
||||||
}
|
|
||||||
return path
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user