diff options
author | Allan Wang <me@allanwang.ca> | 2017-11-12 04:03:41 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-12 04:03:41 -0500 |
commit | 4aed05a8923a7f76799bbaa254f407f7e11fef0b (patch) | |
tree | badd20ad111989ce7bbeed3f7e9ed8df47b94331 /app/src/main/kotlin | |
parent | 2b51bc4bfa86863ed14b550fe3281840587ab038 (diff) | |
download | frost-4aed05a8923a7f76799bbaa254f407f7e11fef0b.tar.gz frost-4aed05a8923a7f76799bbaa254f407f7e11fef0b.tar.bz2 frost-4aed05a8923a7f76799bbaa254f407f7e11fef0b.zip |
Translations (#482)
* Update translators
* Remove translation for some other texts
* Update kau
* Fix build and optimize
* Add translations
* Update readme and changelog
* Clean unnecessary strings
* Fix translations
* Add korean translations for kau
Diffstat (limited to 'app/src/main/kotlin')
13 files changed, 53 insertions, 57 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt index 5de07b7a..8c70f5f2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt @@ -19,8 +19,7 @@ class StartActivity : KauBaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) FbCookie.switchBackUser { - loadFbCookiesAsync { - cookies -> + loadFbCookiesAsync { cookies -> L.d("Cookies loaded at time ${System.currentTimeMillis()}", cookies.toString()) if (cookies.isNotEmpty()) launchNewTask(if (Prefs.userId != -1L) MainActivity::class.java else SelectorActivity::class.java, ArrayList(cookies)) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt index ab08981f..803a9690 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt @@ -3,10 +3,11 @@ package com.pitchedapps.frost.activities import android.content.res.Configuration import android.os.Bundle import ca.allanwang.kau.internal.KauBaseActivity +import ca.allanwang.kau.searchview.SearchViewHolder import com.github.pwittchen.reactivenetwork.library.rx2.Connectivity import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork import com.pitchedapps.frost.R -import com.pitchedapps.frost.contracts.VideoViewerContract +import com.pitchedapps.frost.contracts.VideoViewHolder import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.Prefs import com.pitchedapps.frost.utils.materialDialogThemed @@ -20,8 +21,8 @@ import io.reactivex.schedulers.Schedulers */ abstract class BaseActivity : KauBaseActivity() { override fun onBackPressed() { - if (this is MainActivity && searchView?.onBackPressed() == true) return - if (this is VideoViewerContract && videoOnBackPress()) return + if (this is SearchViewHolder && searchViewOnBackPress()) return + if (this is VideoViewHolder && videoOnBackPress()) return if (this is MainActivity && currentFragment.onBackPressed()) return if (this !is WebOverlayActivityBase && isTaskRoot && Prefs.exitConfirmation) { materialDialogThemed { @@ -81,12 +82,12 @@ abstract class BaseActivity : KauBaseActivity() { override fun onStop() { - if (this is VideoViewerContract) videoOnStop() + if (this is VideoViewHolder) videoOnStop() super.onStop() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - if (this is VideoViewerContract) videoViewer?.updateLocation() + if (this is VideoViewHolder) videoViewer?.updateLocation() } }
\ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt index d4c30547..442d98d8 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt @@ -27,6 +27,7 @@ import android.webkit.WebChromeClient import android.widget.FrameLayout import ca.allanwang.kau.searchview.SearchItem import ca.allanwang.kau.searchview.SearchView +import ca.allanwang.kau.searchview.SearchViewHolder import ca.allanwang.kau.searchview.bindSearchView import ca.allanwang.kau.utils.* import co.zsmb.materialdrawerkt.builders.Builder @@ -47,7 +48,7 @@ import com.pitchedapps.frost.R import com.pitchedapps.frost.contracts.ActivityWebContract import com.pitchedapps.frost.contracts.FileChooserContract import com.pitchedapps.frost.contracts.FileChooserDelegate -import com.pitchedapps.frost.contracts.VideoViewerContract +import com.pitchedapps.frost.contracts.VideoViewHolder import com.pitchedapps.frost.dbflow.loadFbCookie import com.pitchedapps.frost.dbflow.loadFbTabs import com.pitchedapps.frost.enums.MainActivityLayout @@ -76,7 +77,7 @@ import java.util.concurrent.TimeUnit class MainActivity : BaseActivity(), ActivityWebContract, FileChooserContract by FileChooserDelegate(), - VideoViewerContract, + VideoViewHolder, SearchViewHolder, FrostBilling by IabMain() { lateinit var adapter: SectionsPagerAdapter @@ -99,7 +100,7 @@ class MainActivity : BaseActivity(), L.i("First fragment load has finished") field = value } - var searchView: SearchView? = null + override var searchView: SearchView? = null private val searchViewCache = mutableMapOf<String, List<SearchItem>>() companion object { @@ -340,27 +341,29 @@ class MainActivity : BaseActivity(), setMenuIcons(menu, Prefs.iconColor, R.id.action_settings to GoogleMaterial.Icon.gmd_settings, R.id.action_search to GoogleMaterial.Icon.gmd_search) - if (searchView == null) searchView = bindSearchView(menu, R.id.action_search, Prefs.iconColor) { - textCallback = { query, _ -> - val results = searchViewCache[query] - if (results != null) - runOnUiThread { searchView?.results = results } - else - doAsync { - val data = SearchParser.query(query) ?: return@doAsync - val items = data.map { SearchItem(it.href, it.title, it.description) }.toMutableList() - if (items.isNotEmpty()) - items.add(SearchItem("${FbItem._SEARCH.url}?q=$query", string(R.string.show_all_results), iicon = null)) - searchViewCache.put(query, items) - uiThread { searchView?.results = items } - } + searchViewBindIfNull { + bindSearchView(menu, R.id.action_search, Prefs.iconColor) { + textCallback = { query, _ -> + val results = searchViewCache[query] + if (results != null) + runOnUiThread { searchView?.results = results } + else + doAsync { + val data = SearchParser.query(query) ?: return@doAsync + val items = data.map { SearchItem(it.href, it.title, it.description) }.toMutableList() + if (items.isNotEmpty()) + items.add(SearchItem("${FbItem._SEARCH.url}?q=$query", string(R.string.show_all_results), iicon = null)) + searchViewCache.put(query, items) + uiThread { searchView?.results = items } + } + } + textDebounceInterval = 300 + searchCallback = { query, _ -> launchWebOverlay("${FbItem._SEARCH.url}/?q=$query"); true } + closeListener = { _ -> searchViewCache.clear() } + foregroundColor = Prefs.textColor + backgroundColor = Prefs.bgColor.withMinAlpha(200) + onItemClick = { _, key, _, _ -> launchWebOverlay(key) } } - textDebounceInterval = 300 - searchCallback = { query, _ -> launchWebOverlay("${FbItem._SEARCH.url}/?q=$query"); true } - closeListener = { _ -> searchViewCache.clear() } - foregroundColor = Prefs.textColor - backgroundColor = Prefs.bgColor.withMinAlpha(200) - onItemClick = { _, key, _, _ -> launchWebOverlay(key) } } return true } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt index e20cfbf2..ce4bffb5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt @@ -12,7 +12,6 @@ import android.view.MenuItem import android.webkit.ValueCallback import android.webkit.WebChromeClient import android.widget.FrameLayout -import ca.allanwang.kau.internal.KauBaseActivity import ca.allanwang.kau.swipe.kauSwipeOnCreate import ca.allanwang.kau.swipe.kauSwipeOnDestroy import ca.allanwang.kau.utils.* @@ -22,7 +21,7 @@ import com.pitchedapps.frost.R import com.pitchedapps.frost.contracts.ActivityWebContract import com.pitchedapps.frost.contracts.FileChooserContract import com.pitchedapps.frost.contracts.FileChooserDelegate -import com.pitchedapps.frost.contracts.VideoViewerContract +import com.pitchedapps.frost.contracts.VideoViewHolder import com.pitchedapps.frost.enums.OverlayContext import com.pitchedapps.frost.facebook.* import com.pitchedapps.frost.utils.* @@ -100,7 +99,7 @@ class WebOverlayBasicActivity : WebOverlayActivityBase(true) class WebOverlayActivity : WebOverlayActivityBase(false) open class WebOverlayActivityBase(private val forceBasicAgent: Boolean) : BaseActivity(), - ActivityWebContract, VideoViewerContract, FileChooserContract by FileChooserDelegate() { + ActivityWebContract, VideoViewHolder, FileChooserContract by FileChooserDelegate() { override val frameWrapper: FrameLayout by bindView(R.id.frame_wrapper) val toolbar: Toolbar by bindView(R.id.overlay_toolbar) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/contracts/VideoViewerContract.kt b/app/src/main/kotlin/com/pitchedapps/frost/contracts/VideoViewHolder.kt index 2e6ad04f..6440cbb2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/contracts/VideoViewerContract.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/contracts/VideoViewHolder.kt @@ -11,7 +11,7 @@ import com.pitchedapps.frost.views.FrostVideoViewer /** * Created by Allan Wang on 2017-11-10. */ -interface VideoViewerContract : FrameWrapper, FrostVideoContainerContract { +interface VideoViewHolder : FrameWrapper, FrostVideoContainerContract { var videoViewer: FrostVideoViewer? diff --git a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/FbTabsDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/FbTabsDb.kt index c68c9420..7fc56af0 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/FbTabsDb.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/FbTabsDb.kt @@ -1,6 +1,5 @@ package com.pitchedapps.frost.dbflow -import android.content.Context import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.facebook.defaultTabs import com.pitchedapps.frost.utils.L @@ -15,7 +14,7 @@ import com.raizlabs.android.dbflow.structure.BaseModel * Created by Allan Wang on 2017-05-30. */ -@Database( version = FbTabsDb.VERSION) +@Database(version = FbTabsDb.VERSION) object FbTabsDb { const val NAME = "FrostTabs" const val VERSION = 1 diff --git a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt index 37f93987..f91d77ea 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt @@ -37,8 +37,7 @@ class IntroFragmentTheme : BaseIntroFragment(R.layout.intro_theme) { } private fun View.setThemeClick(theme: Theme) { - setOnClickListener { - v -> + setOnClickListener { v -> Prefs.theme = theme.ordinal (activity as IntroActivity).apply { ripple.ripple(Prefs.bgColor, v.x + v.pivotX, v.y + v.pivotY) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt index 9a2eddb6..382b2dad 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt @@ -23,15 +23,13 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { header(R.string.theme_customization) text(R.string.theme, { Prefs.theme }, { Prefs.theme = it }) { - onClick = { - _, _, item -> + onClick = { _, _, item -> materialDialogThemed { title(R.string.theme) items(Theme.values() .map { if (it == Theme.CUSTOM && !IS_FROST_PRO) R.string.custom_pro else it.textRes } .map { string(it) }) - itemsCallbackSingleChoice(item.pref) { - _, _, which, _ -> + itemsCallbackSingleChoice(item.pref) { _, _, which, _ -> if (item.pref != which) { if (which == Theme.CUSTOM.ordinal && !IS_FROST_PRO) { purchasePro() @@ -121,13 +119,11 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { text(R.string.main_activity_layout, { Prefs.mainActivityLayoutType }, { Prefs.mainActivityLayoutType = it }) { textGetter = { string(Prefs.mainActivityLayout.titleRes) } - onClick = { - _, _, item -> + onClick = { _, _, item -> materialDialogThemed { title(R.string.set_main_activity_layout) items(MainActivityLayout.values.map { string(it.titleRes) }) - itemsCallbackSingleChoice(item.pref) { - _, _, which, _ -> + itemsCallbackSingleChoice(item.pref) { _, _, which, _ -> if (item.pref != which) { item.pref = which shouldRestartMain() diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt index a1b459fb..aad2fe9a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt @@ -25,7 +25,6 @@ fun SettingsActivity.getExperimentalPrefs(): KPrefAdapterBuilder.() -> Unit = { // Experimental content starts here ------------------ - // Experimental content ends here -------------------- checkbox(R.string.verbose_logging, { Prefs.verboseLogging }, { @@ -40,8 +39,7 @@ fun SettingsActivity.getExperimentalPrefs(): KPrefAdapterBuilder.() -> Unit = { plainText(R.string.restart_frost) { descRes = R.string.restart_frost_desc - onClick = { - _, _, _ -> + onClick = { _, _, _ -> setFrostResult(MainActivity.REQUEST_RESTART_APPLICATION) finish() true diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt index c814ad4d..6f137519 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt @@ -10,6 +10,7 @@ import org.jetbrains.anko.doAsync * Created by Allan Wang on 2017-09-24. */ object FrostAdBlock : AdBlocker("adblock.txt") + object FrostPglAdBlock : AdBlocker("pgl.yoyo.org.txt") /** diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Showcase.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Showcase.kt index a3812337..cafba223 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Showcase.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Showcase.kt @@ -18,7 +18,7 @@ object Showcase : KPref() { //not a showcase but cannot be in the same file as Prefs var experimentalDefault: Boolean by kpref("experimental_by_default", false) - + override fun deleteKeys() = arrayOf("shown_release") } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt index 71ceb4ca..9941c90c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt @@ -4,7 +4,7 @@ import android.content.Context import android.support.v4.widget.SwipeRefreshLayout import android.webkit.JavascriptInterface import com.pitchedapps.frost.activities.MainActivity -import com.pitchedapps.frost.contracts.VideoViewerContract +import com.pitchedapps.frost.contracts.VideoViewHolder import com.pitchedapps.frost.dbflow.CookieModel import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.utils.* @@ -39,8 +39,10 @@ class FrostJSI(val webView: FrostWebViewCore) { @JavascriptInterface fun loadVideo(url: String?, isGif: Boolean) { if (url != null) - webView.post { (context as? VideoViewerContract)?.showVideo(url, isGif) - ?: L.d("Could not load video; contract not implemented") } + webView.post { + (context as? VideoViewHolder)?.showVideo(url, isGif) + ?: L.d("Could not load video; contract not implemented") + } } @JavascriptInterface diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt index 334ef51b..ca88a23e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt @@ -3,8 +3,7 @@ package com.pitchedapps.frost.web import com.pitchedapps.frost.activities.WebOverlayActivity import com.pitchedapps.frost.activities.WebOverlayActivityBase import com.pitchedapps.frost.activities.WebOverlayBasicActivity -import com.pitchedapps.frost.contracts.VideoViewerContract -import com.pitchedapps.frost.facebook.FB_URL_BASE +import com.pitchedapps.frost.contracts.VideoViewHolder import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.facebook.USER_AGENT_BASIC import com.pitchedapps.frost.facebook.formattedFbUrl @@ -25,9 +24,9 @@ import com.pitchedapps.frost.utils.* */ fun FrostWebViewCore.requestWebOverlay(url: String): Boolean { if (url == "#") return false - if (url.isVideoUrl && context is VideoViewerContract) { + if (url.isVideoUrl && context is VideoViewHolder) { L.i("Found video", url) - (context as VideoViewerContract).showVideo(url) + (context as VideoViewHolder).showVideo(url) return true } if (!Prefs.overlayEnabled) return false |