This repository has been archived by the owner on Nov 6, 2022. It is now read-only.
forked from starfish23/mangafeed
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/inorichi/tachiyomi
# Conflicts: # README.md # app/build.gradle # app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt # app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt # app/src/main/res/layout/manga_info_controller.xml # app/src/main/res/raw/changelog_release.xml
- Loading branch information
Showing
45 changed files
with
2,419 additions
and
1,085 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
52 changes: 52 additions & 0 deletions
52
app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallActivity.kt
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,52 @@ | ||
package eu.kanade.tachiyomi.extension.util | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import eu.kanade.tachiyomi.extension.ExtensionManager | ||
import eu.kanade.tachiyomi.util.toast | ||
import uy.kohesive.injekt.Injekt | ||
import uy.kohesive.injekt.api.get | ||
|
||
/** | ||
* Activity used to install extensions, because we can only receive the result of the installation | ||
* with [startActivityForResult], which we need to update the UI. | ||
*/ | ||
class ExtensionInstallActivity : Activity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
val installIntent = Intent(Intent.ACTION_INSTALL_PACKAGE) | ||
.setDataAndType(intent.data, intent.type) | ||
.putExtra(Intent.EXTRA_RETURN_RESULT, true) | ||
.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) | ||
|
||
try { | ||
startActivityForResult(installIntent, INSTALL_REQUEST_CODE) | ||
} catch (error: Exception) { | ||
// Either install package can't be found (probably bots) or there's a security exception | ||
// with the download manager. Nothing we can workaround. | ||
toast(error.message) | ||
} | ||
} | ||
|
||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | ||
if (requestCode == INSTALL_REQUEST_CODE) { | ||
checkInstallationResult(resultCode) | ||
} | ||
finish() | ||
} | ||
|
||
private fun checkInstallationResult(resultCode: Int) { | ||
val downloadId = intent.extras.getLong(ExtensionInstaller.EXTRA_DOWNLOAD_ID) | ||
val success = resultCode == RESULT_OK | ||
|
||
val extensionManager = Injekt.get<ExtensionManager>() | ||
extensionManager.setInstallationResult(downloadId, success) | ||
} | ||
|
||
private companion object { | ||
const val INSTALL_REQUEST_CODE = 500 | ||
} | ||
} |
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
Oops, something went wrong.