Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.anko:anko-common:0.9'

implementation "androidx.appcompat:appcompat:1.0.0-rc02"
implementation "com.google.android.material:material:1.0.0-rc01"
implementation "androidx.cardview:cardview:1.0.0-rc02"
implementation "androidx.appcompat:appcompat:1.0.0"
implementation "com.google.android.material:material:1.0.0"
implementation "androidx.cardview:cardview:1.0.0"

implementation "androidx.constraintlayout:constraintlayout:1.1.3"

compileOnly files('libs/layoutlib.jar')
implementation 'eu.chainfire:libsuperuser:1.0.0.201704021214'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
androidTestImplementation 'androidx.test:runner:1.1.0-beta02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-beta02'
}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
<activity
android:name=".ui.home.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme.Launcher">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView
import com.github.simonpham.devtiles.BuildConfig
import com.github.simonpham.devtiles.R
import com.github.simonpham.devtiles.SingletonInstances
Expand All @@ -20,6 +21,7 @@ import org.jetbrains.anko.uiThread

class MainActivity : AppCompatActivity() {

private val context = SingletonInstances.getAppContext()
private val sharedPrefs = SingletonInstances.getSharedPrefs()
private val devSettings = SingletonInstances.getDevSettings()

Expand All @@ -31,50 +33,41 @@ class MainActivity : AppCompatActivity() {
}

override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.AppTheme)
super.onCreate(savedInstanceState)

val sharedPrefs = SingletonInstances.getSharedPrefs()
if (sharedPrefs.isFirstLaunch
|| sharedPrefs.lastKnownVersionCode < BuildConfig.VERSION_CODE) {
sharedPrefs.isFirstLaunch = false
showPermissionWizard(this)
}
showPermissionWizard()

setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)

recyclerView.adapter = adapter
refresh()

if (sharedPrefs.lastKnownVersionCode < BuildConfig.VERSION_CODE) {
viewChangelog(this)
sharedPrefs.lastKnownVersionCode = BuildConfig.VERSION_CODE
}
showChangeLog()

swiperefresh.setOnRefreshListener {
refresh()
}

recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
val scrollOffset = recyclerView.computeVerticalScrollOffset()
if (scrollOffset > 0) {
appbar.elevation = 4F
} else {
appbar.elevation = 0F
}
}
})
}

override fun onResume() {
super.onResume()
refresh()
}

private fun refresh() {
catchAll {
swiperefresh.isRefreshing = true
doAsync {
devSettings.checkCompatibility()
val data = makeAdapterData()
uiThread {
adapter.setData(data)
swiperefresh.isRefreshing = false
}
}
}
}

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_action, menu)
return true
Expand Down Expand Up @@ -103,6 +96,35 @@ class MainActivity : AppCompatActivity() {
}
}

private fun refresh() {
catchAll {
swiperefresh.isRefreshing = true
doAsync {
devSettings.checkCompatibility()
val data = makeAdapterData()
uiThread {
adapter.setData(data)
swiperefresh.isRefreshing = false
}
}
}
}

private fun showPermissionWizard() {
if (sharedPrefs.isFirstLaunch
|| sharedPrefs.lastKnownVersionCode < BuildConfig.VERSION_CODE) {
sharedPrefs.isFirstLaunch = false
showPermissionWizard(context)
}
}

private fun showChangeLog() {
if (sharedPrefs.lastKnownVersionCode < BuildConfig.VERSION_CODE) {
viewChangelog(context)
sharedPrefs.lastKnownVersionCode = BuildConfig.VERSION_CODE
}
}

private fun makeAdapterData(): List<AdapterModel> {
val adapterModels = mutableListOf<AdapterModel>()

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/launch_screen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<item android:drawable="@color/white" />
<item>
<bitmap
android:gravity="center"
android:src="@drawable/logo" />
</item>
</layer-list>
Binary file added app/src/main/res/drawable/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<item name="android:windowBackground">@color/white</item>
</style>

<style name="AppTheme.Launcher">
<item name="android:windowBackground">@drawable/launch_screen</item>
</style>

<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0-alpha08'
classpath 'com.android.tools.build:gradle:3.3.0-alpha13'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Aug 11 14:05:02 ICT 2018
#Mon Oct 15 19:28:38 ICT 2018
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