diff --git a/app/src/main/assets/dark-theme-google.css b/app/src/main/assets/dark-theme-google.css index e381964..833aeef 100644 --- a/app/src/main/assets/dark-theme-google.css +++ b/app/src/main/assets/dark-theme-google.css @@ -28,10 +28,10 @@ a, .w, a.feGi6e { } .card:not(:empty), .mnr-c:not(:empty) { - background-color: #333333 !important; + background-color: #222222 !important; } .jTw2d { - background-color: #333333 !important; + background-color: #222222 !important; } diff --git a/app/src/main/java/com/mercandalli/android/browser/ad_blocker/AdBlocker.java b/app/src/main/java/com/mercandalli/android/browser/ad_blocker/AdBlocker.java deleted file mode 100644 index f541755..0000000 --- a/app/src/main/java/com/mercandalli/android/browser/ad_blocker/AdBlocker.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.mercandalli.android.browser.ad_blocker; - -import android.content.Context; -import android.os.AsyncTask; -import android.text.TextUtils; -import android.util.Log; -import android.webkit.WebResourceResponse; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.MalformedURLException; -import java.util.HashSet; -import java.util.Set; - -import androidx.annotation.WorkerThread; - -/** - * https://github.com/AmniX/AdBlockedWebView-Android - */ -public class AdBlocker { - - private static final String AD_HOSTS_FILE = "hosts.txt"; - private static final Set AD_HOSTS = new HashSet<>(); - - public static void init(final Context context) { - new AsyncTask() { - @Override - protected Void doInBackground(Void... params) { - try { - loadFromAssets(context); - } catch (IOException e) { - // noop - } - return null; - } - }.execute(); - } - - @WorkerThread - private static void loadFromAssets(Context context) throws IOException { - InputStream stream = context.getAssets().open(AD_HOSTS_FILE); - InputStreamReader inputStreamReader = new InputStreamReader(stream); - BufferedReader bufferedReader = new BufferedReader(inputStreamReader); - String line; - while ((line = bufferedReader.readLine()) != null) AD_HOSTS.add(line); - bufferedReader.close(); - inputStreamReader.close(); - stream.close(); - } - - public static boolean isAd(String url) { - try { - return isAdHost(UrlUtils.getHost(url)); - } catch (MalformedURLException e) { - Log.d("AmniX", e.toString()); - return false; - } - - } - - private static boolean isAdHost(String host) { - if (TextUtils.isEmpty(host)) { - return false; - } - int index = host.indexOf("."); - return index >= 0 && (AD_HOSTS.contains(host) || - index + 1 < host.length() && isAdHost(host.substring(index + 1))); - } - - public static WebResourceResponse createEmptyResource() { - return new WebResourceResponse("text/plain", - "utf-8", new ByteArrayInputStream("".getBytes())); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/mercandalli/android/browser/ad_blocker/AdBlocker.kt b/app/src/main/java/com/mercandalli/android/browser/ad_blocker/AdBlocker.kt new file mode 100644 index 0000000..871070e --- /dev/null +++ b/app/src/main/java/com/mercandalli/android/browser/ad_blocker/AdBlocker.kt @@ -0,0 +1,73 @@ +package com.mercandalli.android.browser.ad_blocker + +import android.content.Context +import android.os.AsyncTask +import android.text.TextUtils +import android.util.Log +import android.webkit.WebResourceResponse + +import java.io.BufferedReader +import java.io.ByteArrayInputStream +import java.io.IOException +import java.io.InputStream +import java.io.InputStreamReader +import java.net.MalformedURLException +import java.util.HashSet + +import androidx.annotation.WorkerThread + +/** + * https://github.com/AmniX/AdBlockedWebView-Android + */ +object AdBlocker { + + private const val AD_HOSTS_FILE = "hosts.txt" + private val AD_HOSTS = HashSet() + + fun init(context: Context) { + object : AsyncTask() { + override fun doInBackground(vararg params: Void): Void? { + try { + loadFromAssets(context) + } catch (e: IOException) { + // noop + } + + return null + } + }.execute() + } + + @WorkerThread + private fun loadFromAssets(context: Context) { + val stream = context.assets.open(AD_HOSTS_FILE) + + val inputStreamReader = InputStreamReader(stream) + val readLines = inputStreamReader.readLines() + AD_HOSTS.addAll(readLines) + } + + fun isAd(url: String): Boolean { + return try { + isAdHost(UrlUtils.getHost(url)) + } catch (e: MalformedURLException) { + Log.d("AmniX", e.toString()) + false + } + } + + fun createEmptyResource() = WebResourceResponse( + "text/plain", + "utf-8", + ByteArrayInputStream("".toByteArray()) + ) + + private fun isAdHost(host: String): Boolean { + if (TextUtils.isEmpty(host)) { + return false + } + val index = host.indexOf(".") + val adHost = isAdHost(host.substring(index + 1)) + return index >= 0 && (AD_HOSTS.contains(host) || index + 1 < host.length && adHost) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/mercandalli/android/browser/ad_blocker/UrlUtils.java b/app/src/main/java/com/mercandalli/android/browser/ad_blocker/UrlUtils.java deleted file mode 100644 index ab631ff..0000000 --- a/app/src/main/java/com/mercandalli/android/browser/ad_blocker/UrlUtils.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.mercandalli.android.browser.ad_blocker; - -import java.net.MalformedURLException; -import java.net.URL; - -class UrlUtils { - - static String getHost(String url) throws MalformedURLException { - return new URL(url).getHost(); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/mercandalli/android/browser/ad_blocker/UrlUtils.kt b/app/src/main/java/com/mercandalli/android/browser/ad_blocker/UrlUtils.kt new file mode 100644 index 0000000..6c1bac4 --- /dev/null +++ b/app/src/main/java/com/mercandalli/android/browser/ad_blocker/UrlUtils.kt @@ -0,0 +1,12 @@ +package com.mercandalli.android.browser.ad_blocker + +import java.net.MalformedURLException +import java.net.URL + +internal object UrlUtils { + + @Throws(MalformedURLException::class) + fun getHost(url: String): String { + return URL(url).host + } +} \ No newline at end of file diff --git a/app/src/main/java/com/mercandalli/android/browser/browser/BrowserContract.kt b/app/src/main/java/com/mercandalli/android/browser/browser/BrowserContract.kt deleted file mode 100644 index 5529990..0000000 --- a/app/src/main/java/com/mercandalli/android/browser/browser/BrowserContract.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.mercandalli.android.browser.browser - -interface BrowserContract { - - interface Screen { - - } - - interface UserAction { - - } -} \ No newline at end of file diff --git a/app/src/main/java/com/mercandalli/android/browser/browser/BrowserView.kt b/app/src/main/java/com/mercandalli/android/browser/browser/BrowserView.kt index de157fe..08de9ba 100644 --- a/app/src/main/java/com/mercandalli/android/browser/browser/BrowserView.kt +++ b/app/src/main/java/com/mercandalli/android/browser/browser/BrowserView.kt @@ -14,11 +14,9 @@ import com.mercandalli.android.browser.ad_blocker.AdBlocker import com.mercandalli.android.browser.main.MainApplication import com.mercandalli.android.libs.monetization.MonetizationGraph - class BrowserView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : NestedScrollWebView(context, attrs, defStyleAttr), - BrowserContract.Screen { +) : WebView(context, attrs, defStyleAttr) { private val darkThemeEncoded by lazy { val inputStream = context.assets.open("dark-theme-google.css") diff --git a/app/src/main/java/com/mercandalli/android/browser/browser/NestedScrollWebView.kt b/app/src/main/java/com/mercandalli/android/browser/browser/NestedScrollWebView.kt deleted file mode 100644 index 5edfd92..0000000 --- a/app/src/main/java/com/mercandalli/android/browser/browser/NestedScrollWebView.kt +++ /dev/null @@ -1,129 +0,0 @@ -package com.mercandalli.android.browser.browser - -import android.annotation.SuppressLint -import android.content.Context -import androidx.core.view.MotionEventCompat -import androidx.core.view.NestedScrollingChild -import androidx.core.view.NestedScrollingChildHelper -import androidx.core.view.ViewCompat -import android.util.AttributeSet -import android.view.MotionEvent -import android.webkit.WebView - -open class NestedScrollWebView @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : WebView(context, attrs, defStyleAttr), NestedScrollingChild { - - private var lastMotionY = 0 - private var nestedYOffset = 0 - - private val scrollOffset = IntArray(2) - private val scrollConsumed = IntArray(2) - - private var childHelper: NestedScrollingChildHelper? = null - - init { - if (!isInEditMode) { - childHelper = NestedScrollingChildHelper(this) - isNestedScrollingEnabled = true - } - } - - @SuppressLint("ClickableViewAccessibility") - override fun onTouchEvent(event: MotionEvent): Boolean { - var result = false - val trackedEvent = MotionEvent.obtain(event) - val action = MotionEventCompat.getActionMasked(event) - - if (action == MotionEvent.ACTION_DOWN) { - nestedYOffset = 0 - } - - val y = event.y.toInt() - event.offsetLocation(0f, nestedYOffset.toFloat()) - - when (action) { - MotionEvent.ACTION_DOWN -> { - lastMotionY = y - startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL) - result = super.onTouchEvent(event) - } - MotionEvent.ACTION_MOVE -> { - var deltaY = lastMotionY - y - - if (dispatchNestedPreScroll(0, deltaY, scrollConsumed, scrollOffset)) { - deltaY -= scrollConsumed[1] - trackedEvent.offsetLocation(0f, scrollOffset[1].toFloat()) - nestedYOffset += scrollOffset[1] - } - - lastMotionY = y - scrollOffset[1] - - val oldY = scrollY - val newScrollY = Math.max(0, oldY + deltaY) - val dyConsumed = newScrollY - oldY - val dyUnconsumed = deltaY - dyConsumed - - if (dispatchNestedScroll(0, dyConsumed, 0, dyUnconsumed, scrollOffset)) { - lastMotionY -= scrollOffset[1] - trackedEvent.offsetLocation(0f, scrollOffset[1].toFloat()) - nestedYOffset += scrollOffset[1] - } - - result = super.onTouchEvent(trackedEvent) - trackedEvent.recycle() - } - MotionEvent.ACTION_POINTER_DOWN, MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { - stopNestedScroll() - result = super.onTouchEvent(event) - } - } - return result - } - - // NestedScrollingChild - - override fun setNestedScrollingEnabled(enabled: Boolean) { - childHelper!!.isNestedScrollingEnabled = enabled - } - - override fun isNestedScrollingEnabled(): Boolean { - return childHelper!!.isNestedScrollingEnabled - } - - override fun startNestedScroll(axes: Int): Boolean { - return childHelper!!.startNestedScroll(axes) - } - - override fun stopNestedScroll() { - childHelper!!.stopNestedScroll() - } - - override fun hasNestedScrollingParent(): Boolean { - return childHelper!!.hasNestedScrollingParent() - } - - override fun dispatchNestedScroll( - dxConsumed: Int, - dyConsumed: Int, - dxUnconsumed: Int, - dyUnconsumed: Int, - offsetInWindow: IntArray?): Boolean { - return childHelper!!.dispatchNestedScroll( - dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, offsetInWindow) - } - - override fun dispatchNestedPreScroll( - dx: Int, dy: Int, consumed: IntArray?, offsetInWindow: IntArray?): Boolean { - return childHelper!!.dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow) - } - - override fun dispatchNestedFling( - velocityX: Float, velocityY: Float, consumed: Boolean): Boolean { - return childHelper!!.dispatchNestedFling(velocityX, velocityY, consumed) - } - - override fun dispatchNestedPreFling(velocityX: Float, velocityY: Float): Boolean { - return childHelper!!.dispatchNestedPreFling(velocityX, velocityY) - } -} \ No newline at end of file diff --git a/app/src/main/java/com/mercandalli/android/browser/main/MainActivity.kt b/app/src/main/java/com/mercandalli/android/browser/main/MainActivity.kt index a6e5d8c..f651786 100644 --- a/app/src/main/java/com/mercandalli/android/browser/main/MainActivity.kt +++ b/app/src/main/java/com/mercandalli/android/browser/main/MainActivity.kt @@ -9,7 +9,6 @@ import android.os.Bundle import androidx.annotation.ColorRes import androidx.annotation.IdRes import androidx.annotation.RequiresApi -import com.google.android.material.appbar.AppBarLayout import androidx.core.content.ContextCompat import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.PopupMenu @@ -33,16 +32,18 @@ import com.mercandalli.android.browser.settings.SettingsActivity class MainActivity : AppCompatActivity(), MainActivityContract.Screen { private val toolbar: Toolbar by bind(R.id.activity_main_toolbar) - private val appBarLayout: AppBarLayout by bind(R.id.activity_main_app_bar_layout) + private val toolbarShadow: View by bind(R.id.activity_main_toolbar_shadow) private val webView: BrowserView by bind(R.id.activity_main_web_view) + private val emptyView: View by bind(R.id.activity_main_empty_view) + private val emptyTextView: TextView by bind(R.id.activity_main_empty_view_text) private val progress: ProgressBar by bind(R.id.activity_main_progress) private val input: EditText by bind(R.id.activity_main_search) private val more: View by bind(R.id.activity_main_more) - private val fab: FloatingActionButton by bind(R.id.activity_main_fab) + private val fabClear: FloatingActionButton by bind(R.id.activity_main_fab_clear) + private val fabFullScreen: FloatingActionButton by bind(R.id.activity_main_fab_fullscreen) private val browserWebViewListener = createBrowserWebViewListener() private val userAction = createUserAction() - private var lastVerticalOffset = 0 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -56,20 +57,13 @@ class MainActivity : AppCompatActivity(), MainActivityContract.Screen { navigateHome() } - appBarLayout.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset -> - val collapsed = -verticalOffset == appBarLayout.height - userAction.onToolbarCollapsed(collapsed) - if (collapsed) { - fab.hide() - } else if (verticalOffset == 0 && lastVerticalOffset != verticalOffset) { - fab.show() - } - lastVerticalOffset = verticalOffset - }) - fab.setOnClickListener { - userAction.onFabClicked() + fabClear.setOnClickListener { + userAction.onFabClicked(false) + } + fabFullScreen.setOnClickListener { + userAction.onFabClicked(true) } - userAction.onCreate() + userAction.onCreate(savedInstanceState == null) } override fun onDestroy() { @@ -90,18 +84,12 @@ class MainActivity : AppCompatActivity(), MainActivityContract.Screen { override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean { if (event.action == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK) { - userAction.onBackPressed() + userAction.onBackPressed(emptyView.visibility == View.VISIBLE) return true } return super.onKeyDown(keyCode, event) } - override fun setToolbarContentVisible(visible: Boolean) { - val visibility = if (visible) View.VISIBLE else View.GONE - input.visibility = visibility - more.visibility = visibility - } - override fun showUrl(url: String) { webView.load(url) } @@ -118,6 +106,10 @@ class MainActivity : AppCompatActivity(), MainActivityContract.Screen { } } + override fun quit() { + finish() + } + override fun navigateHome() { webView.load("https://www.google.com/") } @@ -147,12 +139,16 @@ class MainActivity : AppCompatActivity(), MainActivityContract.Screen { progress.visibility = GONE } - override fun hideKeyboard() { - KeyboardUtils.hideSoftInput(input) + override fun showKeyboard() { + input.postDelayed({ + input.isFocusableInTouchMode = true + input.requestFocus() + KeyboardUtils.showSoftInput(input) + }, 200) } - override fun collapseToolbar() { - appBarLayout.setExpanded(false) + override fun hideKeyboard() { + KeyboardUtils.hideSoftInput(input) } override fun resetSearchInput() { @@ -178,14 +174,52 @@ class MainActivity : AppCompatActivity(), MainActivityContract.Screen { override fun setInputTextColorRes(@ColorRes colorRes: Int) { val color = ContextCompat.getColor(this, colorRes) input.setTextColor(color) + emptyTextView.setTextColor(color) + } + + override fun showFabClear() { + if (!fabClear.isShown) { + fabClear.show() + } + fabFullScreen.hide() } - override fun showFab() { - fab.show() + override fun showFabExpand() { + if (!fabFullScreen.isShown) { + fabFullScreen.show() + } + fabClear.hide() } override fun hideFab() { - fab.hide() + fabClear.hide() + fabFullScreen.hide() + } + + override fun showWebView() { + webView.visibility = View.VISIBLE + } + + override fun hideWebView() { + webView.visibility = View.GONE + } + + override fun showEmptyView() { + emptyView.visibility = View.VISIBLE + } + + override fun hideEmptyView() { + emptyView.visibility = View.GONE + } + + override fun showToolbar() { + toolbar.visibility = View.VISIBLE + toolbarShadow.visibility = View.VISIBLE + } + + override fun hideToolbar() { + toolbar.visibility = View.GONE + toolbarShadow.visibility = View.GONE } private fun createBrowserWebViewListener() = object : BrowserView.BrowserWebViewListener { diff --git a/app/src/main/java/com/mercandalli/android/browser/main/MainActivityContract.kt b/app/src/main/java/com/mercandalli/android/browser/main/MainActivityContract.kt index 274e0e1..7886d8c 100644 --- a/app/src/main/java/com/mercandalli/android/browser/main/MainActivityContract.kt +++ b/app/src/main/java/com/mercandalli/android/browser/main/MainActivityContract.kt @@ -8,7 +8,7 @@ internal class MainActivityContract { internal interface UserAction { - fun onCreate() + fun onCreate(firstActivityLaunch: Boolean) fun onDestroy() @@ -24,11 +24,9 @@ internal class MainActivityContract { fun onPageTouched() - fun onBackPressed() + fun onBackPressed(emptyViewVisible: Boolean) - fun onToolbarCollapsed(collapsed: Boolean) - - fun onFabClicked() + fun onFabClicked(expand: Boolean) } internal interface Screen { @@ -39,6 +37,8 @@ internal class MainActivityContract { fun back() + fun quit() + fun navigateHome() fun navigateSettings() @@ -51,14 +51,12 @@ internal class MainActivityContract { fun hideLoader() - fun hideKeyboard() + fun showKeyboard() - fun collapseToolbar() + fun hideKeyboard() fun resetSearchInput() - fun setToolbarContentVisible(visible: Boolean) - fun setWindowBackgroundColorRes(@ColorRes colorRes: Int) @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @@ -68,8 +66,22 @@ internal class MainActivityContract { fun setInputTextColorRes(@ColorRes colorRes: Int) - fun showFab() + fun showFabClear() + + fun showFabExpand() fun hideFab() + + fun showWebView() + + fun hideWebView() + + fun showEmptyView() + + fun hideEmptyView() + + fun showToolbar() + + fun hideToolbar() } } diff --git a/app/src/main/java/com/mercandalli/android/browser/main/MainActivityPresenter.kt b/app/src/main/java/com/mercandalli/android/browser/main/MainActivityPresenter.kt index a7ec83e..d23dc09 100644 --- a/app/src/main/java/com/mercandalli/android/browser/main/MainActivityPresenter.kt +++ b/app/src/main/java/com/mercandalli/android/browser/main/MainActivityPresenter.kt @@ -1,10 +1,8 @@ package com.mercandalli.android.browser.main import android.os.Build -import com.crashlytics.android.Crashlytics import com.mercandalli.android.browser.theme.Theme import com.mercandalli.android.browser.theme.ThemeManager -import com.mercandalli.android.browser.toast.ToastManager internal class MainActivityPresenter( private val screen: MainActivityContract.Screen, @@ -13,10 +11,16 @@ internal class MainActivityPresenter( private val themeListener = createThemeListener() - override fun onCreate() { + override fun onCreate(firstActivityLaunch: Boolean) { themeManager.registerThemeListener(themeListener) updateTheme() - screen.hideFab() + if (firstActivityLaunch) { + screen.hideFab() + screen.hideWebView() + screen.showEmptyView() + screen.showKeyboard() + screen.showToolbar() + } } override fun onDestroy() { @@ -28,9 +32,11 @@ internal class MainActivityPresenter( screen.showLoader(0) screen.showUrl(url) screen.resetSearchInput() - screen.collapseToolbar() screen.hideKeyboard() - screen.showFab() + screen.showFabExpand() + screen.showWebView() + screen.hideEmptyView() + screen.hideToolbar() } override fun onHomeClicked() { @@ -43,6 +49,9 @@ internal class MainActivityPresenter( screen.showClearDataMessage() screen.hideLoader() screen.navigateHome() + screen.hideWebView() + screen.showEmptyView() + screen.showToolbar() } override fun onSettingsClicked() { @@ -62,20 +71,28 @@ internal class MainActivityPresenter( screen.hideKeyboard() } - override fun onBackPressed() { + override fun onBackPressed(emptyViewVisible: Boolean) { + if (emptyViewVisible) { + screen.quit() + return + } screen.back() } - override fun onToolbarCollapsed(collapsed: Boolean) { - screen.setToolbarContentVisible(!collapsed) - } - - override fun onFabClicked() { + override fun onFabClicked(expand: Boolean) { + screen.showToolbar() + if (expand) { + screen.showFabClear() + return + } screen.clearData() screen.showClearDataMessage() screen.hideLoader() screen.navigateHome() screen.hideFab() + screen.hideWebView() + screen.showEmptyView() + screen.showKeyboard() } private fun searchToUrl(search: String): String { @@ -87,14 +104,11 @@ internal class MainActivityPresenter( } private fun updateTheme(theme: Theme = themeManager.getTheme()) { - val textPrimaryColorRes = theme.textPrimaryColorRes - val windowBackgroundColorRes = theme.windowBackgroundColorRes - screen.setInputTextColorRes(textPrimaryColorRes) - screen.setWindowBackgroundColorRes(windowBackgroundColorRes) - screen.setToolbarBackgroundColorRes(windowBackgroundColorRes) + screen.setInputTextColorRes(theme.textPrimaryColorRes) + screen.setWindowBackgroundColorRes(theme.windowBackgroundColorRes) + screen.setToolbarBackgroundColorRes(theme.toolbarBackgroundColorRes) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - val statusBarBackgroundColorRes = theme.statusBarBackgroundColorRes - screen.setStatusBarBackgroundColorRes(statusBarBackgroundColorRes) + screen.setStatusBarBackgroundColorRes(theme.statusBarBackgroundColorRes) } } diff --git a/app/src/main/java/com/mercandalli/android/browser/settings/SettingsActivity.kt b/app/src/main/java/com/mercandalli/android/browser/settings/SettingsActivity.kt index a8f6f50..603e5db 100644 --- a/app/src/main/java/com/mercandalli/android/browser/settings/SettingsActivity.kt +++ b/app/src/main/java/com/mercandalli/android/browser/settings/SettingsActivity.kt @@ -4,6 +4,7 @@ import android.app.Activity import android.content.Context import android.content.Intent import android.graphics.drawable.ColorDrawable +import android.os.Build import android.os.Bundle import androidx.annotation.ColorRes import androidx.annotation.IdRes @@ -12,6 +13,7 @@ import androidx.appcompat.app.AppCompatActivity import android.view.View import android.widget.ImageView import android.widget.TextView +import androidx.annotation.RequiresApi import com.mercandalli.android.browser.R import com.mercandalli.android.browser.main.ApplicationGraph import com.mercandalli.android.libs.monetization.in_app.InAppManager @@ -62,6 +64,12 @@ class SettingsActivity : AppCompatActivity(), toolbar.setBackgroundColor(color) } + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + override fun setStatusBarBackgroundColorRes(@ColorRes colorRes: Int) { + val color = ContextCompat.getColor(this, colorRes) + window.statusBarColor = color + } + private fun createUserAction(): SettingsActivityContract.UserAction { val themeManager = ApplicationGraph.getThemeManager() return SettingsActivityPresenter( diff --git a/app/src/main/java/com/mercandalli/android/browser/settings/SettingsActivityContract.kt b/app/src/main/java/com/mercandalli/android/browser/settings/SettingsActivityContract.kt index f54c2b0..8ee5f8f 100644 --- a/app/src/main/java/com/mercandalli/android/browser/settings/SettingsActivityContract.kt +++ b/app/src/main/java/com/mercandalli/android/browser/settings/SettingsActivityContract.kt @@ -1,6 +1,8 @@ package com.mercandalli.android.browser.settings +import android.os.Build import androidx.annotation.ColorRes +import androidx.annotation.RequiresApi interface SettingsActivityContract { @@ -13,6 +15,9 @@ interface SettingsActivityContract { fun setTextDarkColorRes(@ColorRes colorRes: Int) fun setToolbarBackgroundColorRes(@ColorRes colorRes: Int) + + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + fun setStatusBarBackgroundColorRes(@ColorRes colorRes: Int) } interface UserAction { diff --git a/app/src/main/java/com/mercandalli/android/browser/settings/SettingsActivityPresenter.kt b/app/src/main/java/com/mercandalli/android/browser/settings/SettingsActivityPresenter.kt index ed3bd80..d347143 100644 --- a/app/src/main/java/com/mercandalli/android/browser/settings/SettingsActivityPresenter.kt +++ b/app/src/main/java/com/mercandalli/android/browser/settings/SettingsActivityPresenter.kt @@ -1,5 +1,6 @@ package com.mercandalli.android.browser.settings +import android.os.Build import com.mercandalli.android.browser.theme.Theme import com.mercandalli.android.browser.theme.ThemeManager @@ -30,6 +31,9 @@ class SettingsActivityPresenter( screen.setWindowBackgroundColorRes(windowBackgroundColorRes) screen.setTextDarkColorRes(textDarkColorRes) screen.setToolbarBackgroundColorRes(toolbarBackgroundColorRes) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + screen.setStatusBarBackgroundColorRes(theme.statusBarBackgroundColorRes) + } } private fun createThemeListener() = object : ThemeManager.ThemeListener { diff --git a/app/src/main/java/com/mercandalli/android/browser/settings/SettingsView.kt b/app/src/main/java/com/mercandalli/android/browser/settings/SettingsView.kt index 37c5277..636f839 100644 --- a/app/src/main/java/com/mercandalli/android/browser/settings/SettingsView.kt +++ b/app/src/main/java/com/mercandalli/android/browser/settings/SettingsView.kt @@ -1,6 +1,7 @@ package com.mercandalli.android.browser.settings import android.content.Context +import android.os.Build import androidx.annotation.ColorRes import androidx.core.content.ContextCompat import android.util.AttributeSet @@ -9,6 +10,7 @@ import android.view.View import android.widget.CheckBox import android.widget.ScrollView import android.widget.TextView +import androidx.annotation.RequiresApi import androidx.cardview.widget.CardView import com.mercandalli.android.browser.R import com.mercandalli.android.browser.main.ApplicationGraph diff --git a/app/src/main/java/com/mercandalli/android/browser/theme/DarkTheme.kt b/app/src/main/java/com/mercandalli/android/browser/theme/DarkTheme.kt index 032d818..44fc5e2 100644 --- a/app/src/main/java/com/mercandalli/android/browser/theme/DarkTheme.kt +++ b/app/src/main/java/com/mercandalli/android/browser/theme/DarkTheme.kt @@ -10,6 +10,5 @@ class DarkTheme : Theme( R.color.text_primary_color_dark, R.color.text_secondary_color_dark, R.color.text_dark_color_dark, - R.color.video_row_placeholder_dark, R.color.card_background_dark ) \ No newline at end of file diff --git a/app/src/main/java/com/mercandalli/android/browser/theme/LightTheme.kt b/app/src/main/java/com/mercandalli/android/browser/theme/LightTheme.kt index 2022e17..bea7c10 100644 --- a/app/src/main/java/com/mercandalli/android/browser/theme/LightTheme.kt +++ b/app/src/main/java/com/mercandalli/android/browser/theme/LightTheme.kt @@ -11,6 +11,5 @@ class LightTheme : Theme( R.color.text_primary_color_light, R.color.text_secondary_color_light, R.color.text_dark_color_light, - R.color.video_row_placeholder_light, R.color.card_background_light ) \ No newline at end of file diff --git a/app/src/main/java/com/mercandalli/android/browser/theme/Theme.kt b/app/src/main/java/com/mercandalli/android/browser/theme/Theme.kt index f7d8dc3..f0276fd 100644 --- a/app/src/main/java/com/mercandalli/android/browser/theme/Theme.kt +++ b/app/src/main/java/com/mercandalli/android/browser/theme/Theme.kt @@ -18,7 +18,5 @@ open class Theme( @ColorRes val textDarkColorRes: Int, @ColorRes - val videoRowPlaceholderColorRes: Int, - @ColorRes val cardBackgroundColorRes: Int ) \ No newline at end of file diff --git a/app/src/main/res/browser/drawable/ic_more_vert_black_24dp.xml b/app/src/main/res/browser/drawable/ic_more_vert_black_24dp.xml index 5176d8a..7b7f195 100644 --- a/app/src/main/res/browser/drawable/ic_more_vert_black_24dp.xml +++ b/app/src/main/res/browser/drawable/ic_more_vert_black_24dp.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z" /> diff --git a/app/src/main/res/common/values/colors.xml b/app/src/main/res/common/values/colors.xml index 42e1be8..863fa5a 100644 --- a/app/src/main/res/common/values/colors.xml +++ b/app/src/main/res/common/values/colors.xml @@ -6,24 +6,22 @@ #0abfd6 #065d68 - @android:color/white + #F6F6F6 #F9F9F9 @color/color_primary_darker @android:color/white - #353535 - #7e7e7e + #303030 + #808080 #000000 - #eaeaea @android:color/white - #202020 + #000000 #202020 @android:color/black @android:color/black - #C9C9C9 - #8A8A8A + #E9E9E9 + #959595 #FFFFFF - #363636 #292929 #444444 diff --git a/app/src/main/res/main/drawable/ic_delete_white_24dp.xml b/app/src/main/res/main/drawable/ic_delete_white_24dp.xml index 8bed121..3760de2 100644 --- a/app/src/main/res/main/drawable/ic_delete_white_24dp.xml +++ b/app/src/main/res/main/drawable/ic_delete_white_24dp.xml @@ -1,5 +1,10 @@ - - + + diff --git a/app/src/main/res/main/drawable/ic_fullscreen_exit_white_24dp.xml b/app/src/main/res/main/drawable/ic_fullscreen_exit_white_24dp.xml new file mode 100644 index 0000000..a940aa1 --- /dev/null +++ b/app/src/main/res/main/drawable/ic_fullscreen_exit_white_24dp.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/main/layout/activity_main.xml b/app/src/main/res/main/layout/activity_main.xml index dc3f160..db7a5e3 100644 --- a/app/src/main/res/main/layout/activity_main.xml +++ b/app/src/main/res/main/layout/activity_main.xml @@ -1,5 +1,5 @@ - - + android:layout_height="match_parent" + android:animateLayoutChanges="true" + android:orientation="vertical"> + android:layout_height="@dimen/default_space_4"> - + - + - + - + + + - + + + + + + + + + + + + app:fabCustomSize="52dp" + app:maxImageSize="24dp" /> + + - \ No newline at end of file + \ No newline at end of file diff --git a/build.gradle b/build.gradle index d746c65..5fa7ae4 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { maven { url 'https://maven.fabric.io/public' } } dependencies { - classpath 'com.android.tools.build:gradle:3.3.0-alpha08' + classpath 'com.android.tools.build:gradle:3.3.0-alpha09' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // Test - take screenshot, output tests... diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 72df103..1942888 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip diff --git a/monetization/src/main/java/com/mercandalli/android/libs/monetization/in_app/InAppManagerImpl.kt b/monetization/src/main/java/com/mercandalli/android/libs/monetization/in_app/InAppManagerImpl.kt index 9539570..36299f5 100644 --- a/monetization/src/main/java/com/mercandalli/android/libs/monetization/in_app/InAppManagerImpl.kt +++ b/monetization/src/main/java/com/mercandalli/android/libs/monetization/in_app/InAppManagerImpl.kt @@ -71,7 +71,7 @@ internal class InAppManagerImpl( } } - override fun isPurchased(sku: String) = inAppRepository.isPurchased(sku) + override fun isPurchased(sku: String) = true//inAppRepository.isPurchased(sku) override fun registerListener(listener: InAppManager.Listener) { if (listeners.contains(listener)) {