From 1e30d249eeb1571a134c5aa734681c212777ba70 Mon Sep 17 00:00:00 2001 From: Jay Date: Fri, 10 Jan 2020 23:50:02 -0800 Subject: [PATCH] Revert "Merge remote-tracking branch 'upstream/master'" This reverts commit 93e4b9104bbaee9b17969ad2b2322523943613f7, reversing changes made to 3c81f60041b0aaf638ea9a128bfeb00cd818c18b. --- .../ui/base/activity/BaseActivity.kt | 16 --- .../tachiyomi/ui/webview/WebViewActivity.kt | 115 ------------------ app/src/main/res/layout/main_activity.xml | 1 + 3 files changed, 1 insertion(+), 131 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt index 80e7f2c7ed..f9f867fae2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt @@ -1,29 +1,13 @@ package eu.kanade.tachiyomi.ui.base.activity -import android.os.Bundle import androidx.appcompat.app.AppCompatActivity -import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.util.LocaleHelper -import uy.kohesive.injekt.injectLazy abstract class BaseActivity : AppCompatActivity() { - val preferences: PreferencesHelper by injectLazy() - init { @Suppress("LeakingThis") LocaleHelper.updateConfiguration(this) } - override fun onCreate(savedInstanceState: Bundle?) { - setTheme(when (preferences.theme()) { - 2 -> R.style.Theme_Tachiyomi_Dark - 3 -> R.style.Theme_Tachiyomi_Amoled - 4 -> R.style.Theme_Tachiyomi_DarkBlue - else -> R.style.Theme_Tachiyomi - }) - super.onCreate(savedInstanceState) - } - } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt deleted file mode 100644 index c3f394e1c9..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt +++ /dev/null @@ -1,115 +0,0 @@ -package eu.kanade.tachiyomi.ui.webview - -import android.content.Context -import android.content.Intent -import android.graphics.Bitmap -import android.graphics.Color -import android.os.Bundle -import android.view.Menu -import android.view.MenuItem -import android.webkit.WebView -import androidx.core.graphics.ColorUtils -import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.source.SourceManager -import eu.kanade.tachiyomi.source.online.HttpSource -import eu.kanade.tachiyomi.ui.base.activity.BaseActivity -import eu.kanade.tachiyomi.util.WebViewClientCompat -import kotlinx.android.synthetic.main.webview_activity.toolbar -import kotlinx.android.synthetic.main.webview_activity.webview -import uy.kohesive.injekt.injectLazy - - -class WebViewActivity : BaseActivity() { - - private val sourceManager by injectLazy() - - private var bundle: Bundle? = null - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.webview_activity) - - title = intent.extras?.getString(TITLE_KEY) - setSupportActionBar(toolbar) - supportActionBar?.setDisplayHomeAsUpEnabled(true) - toolbar.setNavigationOnClickListener { - super.onBackPressed() - } - - if (bundle == null) { - val source = sourceManager.get(intent.extras!!.getLong(SOURCE_KEY)) as? HttpSource ?: return - val url = intent.extras!!.getString(URL_KEY) ?: return - val headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" } - - webview.webViewClient = object : WebViewClientCompat() { - override fun shouldOverrideUrlCompat(view: WebView, url: String): Boolean { - view.loadUrl(url) - return true - } - - override fun onPageFinished(view: WebView?, url: String?) { - super.onPageFinished(view, url) - invalidateOptionsMenu() - title = view?.title - } - - override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) { - super.onPageStarted(view, url, favicon) - invalidateOptionsMenu() - } - } - webview.settings.javaScriptEnabled = true - webview.settings.userAgentString = source.headers["User-Agent"] - webview.loadUrl(url, headers) - } else { - webview.restoreState(bundle) - } - } - - override fun onCreateOptionsMenu(menu: Menu): Boolean { - menuInflater.inflate(R.menu.webview, menu) - return true - } - - override fun onPrepareOptionsMenu(menu: Menu?): Boolean { - val backItem = toolbar.menu.findItem(R.id.action_web_back) - val forwardItem = toolbar.menu.findItem(R.id.action_web_forward) - backItem?.isEnabled = webview.canGoBack() - forwardItem?.isEnabled = webview.canGoForward() - - val translucentWhite = ColorUtils.setAlphaComponent(Color.WHITE, 127) - backItem.icon?.setTint(if (webview.canGoBack()) Color.WHITE else translucentWhite) - forwardItem?.icon?.setTint(if (webview.canGoForward()) Color.WHITE else translucentWhite) - - return super.onPrepareOptionsMenu(menu) - } - - override fun onBackPressed() { - if (webview.canGoBack()) webview.goBack() - else super.onBackPressed() - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - when (item.itemId) { - R.id.action_web_back -> webview.goBack() - R.id.action_web_forward -> webview.goForward() - R.id.action_web_refresh -> webview.reload() - } - return super.onOptionsItemSelected(item) - } - - companion object { - private const val SOURCE_KEY = "source_key" - private const val URL_KEY = "url_key" - private const val TITLE_KEY = "title_key" - - fun newIntent(context: Context, sourceId: Long, url: String, title: String?): Intent { - val intent = Intent(context, WebViewActivity::class.java) - intent.putExtra(SOURCE_KEY, sourceId) - intent.putExtra(URL_KEY, url) - intent.putExtra(TITLE_KEY, title) - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) - return intent - } - } -} diff --git a/app/src/main/res/layout/main_activity.xml b/app/src/main/res/layout/main_activity.xml index 9ced7fd009..54f1f22952 100644 --- a/app/src/main/res/layout/main_activity.xml +++ b/app/src/main/res/layout/main_activity.xml @@ -27,6 +27,7 @@