This repository has been archived by the owner on Dec 8, 2019. It is now read-only.
/
MainActivity.kt
62 lines (55 loc) · 2.21 KB
/
MainActivity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Licensed under Apache-2.0
*
* Designed and developed by Aidan Follestad (@afollestad)
*/
package com.afollestad.aestheticsample
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import androidx.appcompat.widget.SearchView
import com.afollestad.aesthetic.Aesthetic
import com.afollestad.aesthetic.AestheticActivity
import com.afollestad.aesthetic.BottomNavBgMode
import com.afollestad.aesthetic.BottomNavIconTextMode
import com.afollestad.aesthetic.NavigationViewMode
import kotlinx.android.synthetic.main.activity_main.pager
import kotlinx.android.synthetic.main.activity_main.tabs
import kotlinx.android.synthetic.main.activity_main.toolbar
/** @author Aidan Follestad (afollestad) */
class MainActivity : AestheticActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
toolbar.inflateMenu(R.menu.main)
toolbar.setOnMenuItemClickListener {
if (it.itemId == R.id.settings) {
startActivity(Intent(this@MainActivity, SettingsActivity::class.java))
}
true
}
val searchItem = toolbar.menu.findItem(R.id.search)
val searchView = searchItem.actionView as SearchView
searchView.queryHint = getString(R.string.search_view_example)
// If we haven't set any defaults, do that now
if (Aesthetic.isFirstTime) {
Aesthetic.config {
activityTheme(R.style.AppTheme)
textColorPrimary(res = R.color.text_color_primary)
textColorSecondary(res = R.color.text_color_secondary)
colorPrimary(res = R.color.md_white)
colorAccent(res = R.color.md_blue)
colorStatusBarAuto()
colorNavigationBarAuto()
textColorPrimary(Color.BLACK)
navigationViewMode(NavigationViewMode.SELECTED_ACCENT)
bottomNavigationBackgroundMode(BottomNavBgMode.PRIMARY)
bottomNavigationIconTextMode(BottomNavIconTextMode.SELECTED_ACCENT)
swipeRefreshLayoutColorsRes(R.color.md_blue, R.color.md_blue_grey, R.color.md_green)
attribute(R.attr.my_custom_attr, res = R.color.md_red)
}
}
pager.adapter = MainPagerAdapter(this, supportFragmentManager)
tabs.setupWithViewPager(pager)
}
}