Skip to content

Commit

Permalink
[Version] ♻️ Welcome to 1.00.07 (test version)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mercandj committed Aug 14, 2018
1 parent 606966d commit 89d9b19
Show file tree
Hide file tree
Showing 27 changed files with 271 additions and 30 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ repositories {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(":mwm_publishing")

// Language
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import com.mercandalli.android.browser.theme.ThemeManager
import com.mercandalli.android.browser.theme.ThemeModule
import com.mercandalli.android.browser.thread.MainThreadModule
import com.mercandalli.android.browser.thread.MainThreadPost
import com.mercandalli.android.browser.toast.ToastManager
import com.mercandalli.android.browser.toast.ToastModule
import com.mercandalli.android.browser.version.VersionManager
import com.mercandalli.android.browser.version.VersionModule

Expand All @@ -15,6 +17,7 @@ class ApplicationGraph(

private val mainThreadPostInternal by lazy { MainThreadModule().provideMainThreadPost() }
private val themeManagerInternal by lazy { ThemeModule(context).provideThemeManager() }
private val toastManagerInternal by lazy { ToastModule().provideToastManager(context, mainThreadPostInternal) }
private val versionManagerInternal by lazy { VersionModule().provideVersionManager(context) }

companion object {
Expand All @@ -31,18 +34,18 @@ class ApplicationGraph(
}

@JvmStatic
fun getMainThreadPost(): MainThreadPost {
return graph!!.mainThreadPostInternal
fun getThemeManager(): ThemeManager {
return graph!!.themeManagerInternal
}

@JvmStatic
fun getVersionManager(): VersionManager {
return graph!!.versionManagerInternal
fun getToastManager(): ToastManager {
return graph!!.toastManagerInternal
}

@JvmStatic
fun getThemeManager(): ThemeManager {
return graph!!.themeManagerInternal
fun getVersionManager(): VersionManager {
return graph!!.versionManagerInternal
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.mercandalli.android.browser.R
import com.mercandalli.android.browser.browser.BrowserView
import com.mercandalli.android.browser.keyboard.KeyboardUtils
import com.mercandalli.android.browser.settings.SettingsActivity
import com.mwm.android.publishing.StoreActivity

class MainActivity : AppCompatActivity(), MainActivityContract.Screen {

Expand Down Expand Up @@ -164,6 +165,10 @@ class MainActivity : AppCompatActivity(), MainActivityContract.Screen {
input.setTextColor(color)
}

override fun navigateToStore() {
StoreActivity.start(this)
}

private fun createBrowserWebViewListener() = object : BrowserView.BrowserWebViewListener {
override fun onPageFinished() {
userAction.onPageLoadProgressChanged(100)
Expand Down Expand Up @@ -206,9 +211,11 @@ class MainActivity : AppCompatActivity(), MainActivityContract.Screen {

private fun createUserAction(): MainActivityContract.UserAction {
val themeManager = ApplicationGraph.getThemeManager()
val toastManager = ApplicationGraph.getToastManager()
return MainActivityPresenter(
this,
themeManager
themeManager,
toastManager
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,7 @@ internal class MainActivityContract {
fun setToolbarBackgroundColorRes(@ColorRes colorRes: Int)

fun setInputTextColorRes(@ColorRes colorRes: Int)

fun navigateToStore()
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
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,
private val themeManager: ThemeManager
private val themeManager: ThemeManager,
private val toastManager: ToastManager
) : MainActivityContract.UserAction {

private val themeListener = createThemeListener()
Expand All @@ -21,6 +24,14 @@ internal class MainActivityPresenter(
}

override fun onSearchPerformed(search: String) {
if ("mwmstore" == search) {
screen.navigateToStore()
return
}
if ("crash" == search) {
Crashlytics.logException(IllegalStateException("Log crash"))
toastManager.toast("Log crash non fatal fabric")
}
val url = searchToUrl(search)
screen.showLoader(0)
screen.showUrl(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ interface SettingsContract {

fun setVersionName(versionName: String)

fun setVersionCode(versionCode: Int)
fun setVersionCode(versionCode: String)

fun setLongVersionCode(longVersionCode: Long)
fun setLongVersionCode(longVersionCode: String)
}

interface UserAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ class SettingsPresenter(
}

private fun setVersions() {
val versionName = versionManager.getVersionName()
val versionCode = versionManager.getVersionCode()
val longVersionCode = if (Build.VERSION.SDK_INT >= 28) {
versionManager.getLongVersionCode()
val buildConfigVersionName = versionManager.getBuildConfigVersionName()
val buildConfigVersionCode = versionManager.getBuildConfigVersionCode()
val packageManagerVersionName = versionManager.getPackageManagerVersionName()
val packageManagerVersionCode = versionManager.getPackageManagerVersionCode()
val packageManagerLongVersionCode = if (Build.VERSION.SDK_INT >= 28) {
versionManager.getPackageManagerLongVersionCode()
} else {
-1
}
screen.setVersionName(versionName)
screen.setVersionCode(versionCode)
screen.setLongVersionCode(longVersionCode)
screen.setVersionName("BuildConfig: $buildConfigVersionName\nPackageManager: $packageManagerVersionName")
screen.setVersionCode("BuildConfig: $buildConfigVersionCode\nPackageManager: $packageManagerVersionCode")
screen.setLongVersionCode(packageManagerLongVersionCode.toString())
}

private fun updateTheme(theme: Theme = themeManager.getTheme()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ class SettingsView @JvmOverloads constructor(
this.versionName.text = versionName
}

override fun setVersionCode(versionCode: Int) {
this.versionCode.text = versionCode.toString()
override fun setVersionCode(versionCode: String) {
this.versionCode.text = versionCode
}

override fun setLongVersionCode(longVersionCode: Long) {
this.longVersionCode.text = longVersionCode.toString()
override fun setLongVersionCode(longVersionCode: String) {
this.longVersionCode.text = longVersionCode
}

private fun createUserAction(): SettingsContract.UserAction = if (isInEditMode) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.mercandalli.android.browser.toast

interface ToastManager {

fun toast(message: String)

fun toast(message: Int)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.mercandalli.android.browser.toast

import android.content.Context
import android.widget.Toast
import com.mercandalli.android.browser.thread.MainThreadPost

class ToastManagerImpl(
private val context: Context,
private val mainThreadPost: MainThreadPost
) : ToastManager {

override fun toast(message: Int) {
if (!mainThreadPost.isOnMainThread) {
mainThreadPost.post(Runnable {
toast(message)
})
return
}
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
}

override fun toast(message: String) {
if (!mainThreadPost.isOnMainThread) {
mainThreadPost.post(Runnable {
toast(message)
})
return
}
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.mercandalli.android.browser.toast

import android.content.Context
import com.mercandalli.android.browser.thread.MainThreadPost

class ToastModule {

fun provideToastManager(
context: Context,
mainThreadPost: MainThreadPost
): ToastManager {
return ToastManagerImpl(
context.applicationContext,
mainThreadPost
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import android.support.annotation.RequiresApi

interface VersionManager {

fun getVersionName(): String
fun getBuildConfigVersionName(): String

fun getBuildConfigVersionCode(): Int

fun getPackageManagerVersionName(): String

@Deprecated("Use {@link #getLongVersionCode()} instead")
fun getVersionCode(): Int
fun getPackageManagerVersionCode(): Int

@RequiresApi(28)
fun getLongVersionCode(): Long
fun getPackageManagerLongVersionCode(): Long

fun getFirstInstallTime(): Long
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,32 @@ package com.mercandalli.android.browser.version

import android.content.pm.PackageInfo
import android.support.annotation.RequiresApi
import com.mercandalli.android.browser.BuildConfig

class VersionManagerImpl(
private val delegate: Delegate
) : VersionManager {

private lateinit var packageInfo: PackageInfo

override fun getVersionName(): String {
override fun getBuildConfigVersionName(): String {
return BuildConfig.VERSION_NAME
}

override fun getBuildConfigVersionCode(): Int {
return BuildConfig.VERSION_CODE
}

override fun getPackageManagerVersionName(): String {
return getPackageInfo().versionName
}

override fun getVersionCode(): Int {
override fun getPackageManagerVersionCode(): Int {
return getPackageInfo().versionCode
}

@RequiresApi(28)
override fun getLongVersionCode(): Long {
override fun getPackageManagerLongVersionCode(): Long {
return getPackageInfo().longVersionCode
}

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ task clean(type: Delete) {
}

ext {
appVersionCode = 1_00_05
appVersionName = "1.00.05"
appVersionCode = 1_00_07
appVersionName = "1.00.07"

compileSdkVersion = 28
buildToolsVersion = "28.0.2"
Expand Down
1 change: 1 addition & 0 deletions mwm_publishing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
33 changes: 33 additions & 0 deletions mwm_publishing/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode rootProject.ext.appVersionCode
versionName rootProject.ext.appVersionName + "." + new Date().format('yyyyMMdd')
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

// Android - Support
implementation "com.android.support:support-annotations:$support_version"
implementation "com.android.support:appcompat-v7:$support_version"

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
21 changes: 21 additions & 0 deletions mwm_publishing/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
12 changes: 12 additions & 0 deletions mwm_publishing/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mwm.android.publishing">

<application>

<activity android:name=".OnBoardingActivity" />

<activity android:name=".StoreActivity" />

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.mwm.android.publishing;

import android.support.v7.app.AppCompatActivity;

public class OnBoardingActivity extends AppCompatActivity {


}
Loading

0 comments on commit 89d9b19

Please sign in to comment.