Merge remote-tracking branch 'origin/master' into desirepath

pull/32/head
Invinciblelee 6 years ago
commit c817dd8c14
  1. 34
      app/build.gradle
  2. 7
      app/src/main/java/io/legado/app/ui/main/BookSourceFragment.kt
  3. 7
      app/src/main/java/io/legado/app/ui/main/BookshelfFragment.kt
  4. 7
      app/src/main/java/io/legado/app/ui/main/FindBookFragment.kt
  5. 62
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  6. 7
      app/src/main/java/io/legado/app/ui/main/MyFragment.kt
  7. 14
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  8. 13
      app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt
  9. 13
      app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt
  10. 13
      app/src/main/java/io/legado/app/ui/main/myconfig/MyConfigFragment.kt
  11. 32
      app/src/main/res/layout/activity_main.xml
  12. 21
      app/src/main/res/layout/content_main.xml
  13. 15
      app/src/main/res/layout/fragment_book_source.xml
  14. 15
      app/src/main/res/layout/fragment_bookshelf.xml
  15. 15
      app/src/main/res/layout/fragment_find_book.xml
  16. 15
      app/src/main/res/layout/fragment_my_config.xml
  17. 23
      app/src/main/res/menu/activity_main_bnv.xml
  18. 38
      app/src/main/res/menu/activity_main_drawer.xml
  19. 4
      app/src/main/res/values/ids.xml
  20. 1
      app/src/main/res/values/strings.xml

@ -7,21 +7,51 @@ androidExtensions {
experimental = true experimental = true
} }
static def releaseTime() {
return new Date().format("yy.MMddHH", TimeZone.getTimeZone("GMT+8"))
}
def name = "legado"
def version = "0." + releaseTime()
def gitCommits = Integer.parseInt('git rev-list --count HEAD'.execute([], project.rootDir).text.trim())
android { android {
compileSdkVersion 28 compileSdkVersion 28
signingConfigs {
myConfig {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_KEY_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_STORE_PASSWORD
}
}
defaultConfig { defaultConfig {
applicationId "io.legado.app" applicationId "io.legado.app"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 28 targetSdkVersion 28
versionCode 1 versionCode gitCommits
versionName "1.0" versionName version
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
project.ext.set("archivesBaseName", name + "_" + version)
} }
buildTypes { buildTypes {
release { release {
signingConfig signingConfigs.myConfig
minifyEnabled false minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
debug {
signingConfig signingConfigs.myConfig
applicationIdSuffix '.debug'
versionNameSuffix 'debug'
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${name}_${defaultConfig.versionName}.apk"
}
}
} }
compileOptions { compileOptions {

@ -1,7 +0,0 @@
package io.legado.app.ui.main
import androidx.fragment.app.Fragment
class BookSourceFragment : Fragment() {
}

@ -1,7 +0,0 @@
package io.legado.app.ui.main
import androidx.fragment.app.Fragment
class BookshelfFragment : Fragment() {
}

@ -1,7 +0,0 @@
package io.legado.app.ui.main
import androidx.fragment.app.Fragment
class FindBookFragment : Fragment() {
}

@ -1,19 +1,29 @@
package io.legado.app.ui.main package io.legado.app.ui.main
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import androidx.viewpager.widget.ViewPager
import com.google.android.material.bottomnavigation.BottomNavigationView
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseActivity import io.legado.app.base.BaseActivity
import io.legado.app.help.permission.Permissions import io.legado.app.help.permission.Permissions
import io.legado.app.help.permission.PermissionsCompat import io.legado.app.help.permission.PermissionsCompat
import io.legado.app.help.storage.Restore import io.legado.app.help.storage.Restore
import io.legado.app.ui.search.SearchActivity import io.legado.app.ui.main.bookshelf.BookshelfFragment
import io.legado.app.ui.main.booksource.BookSourceFragment
import io.legado.app.ui.main.findbook.FindBookFragment
import io.legado.app.ui.main.myconfig.MyConfigFragment
import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModel
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : BaseActivity<MainViewModel>() { class MainActivity : BaseActivity<MainViewModel>(), BottomNavigationView.OnNavigationItemSelectedListener,
ViewPager.OnPageChangeListener {
private val mFragmentList: ArrayList<Fragment> = ArrayList()
override val viewModel: MainViewModel override val viewModel: MainViewModel
get() = getViewModel(MainViewModel::class.java) get() = getViewModel(MainViewModel::class.java)
@ -21,9 +31,24 @@ class MainActivity : BaseActivity<MainViewModel>() {
get() = R.layout.activity_main get() = R.layout.activity_main
override fun onViewModelCreated(viewModel: MainViewModel, savedInstanceState: Bundle?) { override fun onViewModelCreated(viewModel: MainViewModel, savedInstanceState: Bundle?) {
fab.setOnClickListener { startActivity(Intent(this, SearchActivity::class.java)) } mFragmentList.add(BookshelfFragment(R.layout.fragment_bookshelf))
mFragmentList.add(FindBookFragment(R.layout.fragment_find_book))
mFragmentList.add(BookSourceFragment(R.layout.fragment_book_source))
mFragmentList.add(MyConfigFragment(R.layout.fragment_my_config))
view_pager_main.adapter =
TabFragmentPageAdapter(supportFragmentManager, FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT)
view_pager_main.addOnPageChangeListener(this)
bottom_navigation_view.setOnNavigationItemSelectedListener(this)
}
override fun onNavigationItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.menu_bookshelf -> view_pager_main.currentItem = 0
R.id.menu_find_book -> view_pager_main.currentItem = 1
R.id.menu_book_source -> view_pager_main.currentItem = 2
R.id.menu_my_config -> view_pager_main.currentItem = 3
}
return false
} }
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
@ -42,4 +67,31 @@ class MainActivity : BaseActivity<MainViewModel>() {
.onGranted { Restore.importYueDuData(this) }.request() .onGranted { Restore.importYueDuData(this) }.request()
} }
override fun onPageScrollStateChanged(state: Int) {
}
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
}
override fun onPageSelected(position: Int) {
bottom_navigation_view.menu.getItem(position).isChecked = true
}
inner class TabFragmentPageAdapter internal constructor(fm: FragmentManager, behavior: Int) :
FragmentPagerAdapter(fm, behavior) {
override fun getItem(position: Int): Fragment {
return mFragmentList[position]
}
override fun getCount(): Int {
return mFragmentList.size
}
}
} }

@ -1,7 +0,0 @@
package io.legado.app.ui.main
import androidx.fragment.app.Fragment
class MyFragment : Fragment() {
}

@ -0,0 +1,14 @@
package io.legado.app.ui.main.bookshelf
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
class BookshelfFragment(contentLayoutId: Int) : Fragment(contentLayoutId) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}

@ -0,0 +1,13 @@
package io.legado.app.ui.main.booksource
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
class BookSourceFragment(contentLayoutId: Int) : Fragment(contentLayoutId) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}

@ -0,0 +1,13 @@
package io.legado.app.ui.main.findbook
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
class FindBookFragment(contentLayoutId: Int) : Fragment(contentLayoutId) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}

@ -0,0 +1,13 @@
package io.legado.app.ui.main.myconfig
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
class MyConfigFragment(contentLayoutId: Int) : Fragment(contentLayoutId) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}

@ -1,26 +1,26 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout <androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ui.main.MainActivity"> android:fitsSystemWindows="true">
<io.legado.app.ui.widget.TitleBar <com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/title_bar" android:id="@+id/bottom_navigation_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:fitsSystemWindows="true" android:layout_height="wrap_content"
android:layout_height="wrap_content"/> android:background="@color/background"
app:labelVisibilityMode="labeled"
app:menu="@menu/activity_main_bnv"
app:layout_constraintBottom_toBottomOf="parent"/>
<include layout="@layout/content_main"/> <androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager_main"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation_view"
app:layout_constraintTop_toTopOf="parent"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton </androidx.constraintlayout.widget.ConstraintLayout>
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_main"
tools:context=".ui.main.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<io.legado.app.ui.widget.TitleBar
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:title="@string/book_source"/>
</LinearLayout>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<io.legado.app.ui.widget.TitleBar
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:title="@string/bookshelf"/>
</LinearLayout>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<io.legado.app.ui.widget.TitleBar
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:title="@string/find"/>
</LinearLayout>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<io.legado.app.ui.widget.TitleBar
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:title="我的"/>
</LinearLayout>

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="bottom_navigation_view">
<item
android:id="@+id/menu_bookshelf"
android:icon="@drawable/ic_menu_camera"
android:title="书架"/>
<item
android:id="@+id/menu_find_book"
android:icon="@drawable/ic_menu_gallery"
android:title="发现"/>
<item
android:id="@+id/menu_book_source"
android:icon="@drawable/ic_menu_slideshow"
android:title="书源"/>
<item
android:id="@+id/menu_my_config"
android:icon="@drawable/ic_menu_manage"
android:title="我的"/>
</menu>

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="navigation_view">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_backup"
android:icon="@drawable/ic_menu_camera"
android:title="@string/menu_backup"/>
<item
android:id="@+id/nav_restore"
android:icon="@drawable/ic_menu_gallery"
android:title="@string/menu_restore"/>
<item
android:id="@+id/nav_import_old"
android:icon="@drawable/ic_menu_slideshow"
android:title="@string/menu_import_old"/>
<item
android:id="@+id/nav_import_github"
android:icon="@drawable/ic_menu_manage"
android:title="@string/menu_import_github"/>
</group>
<item android:title="Communicate">
<menu>
<item
android:id="@+id/nav_replace_rule"
android:icon="@drawable/ic_menu_share"
android:title="@string/menu_replace_rule"/>
<item
android:id="@+id/nav_send"
android:icon="@drawable/ic_menu_send"
android:title="@string/menu_send"/>
</menu>
</item>
</menu>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>

@ -45,6 +45,7 @@
<string name="action_list_grid">列表/网格</string> <string name="action_list_grid">列表/网格</string>
<string name="book_library">书城</string> <string name="book_library">书城</string>
<string name="book_local">添加本地</string> <string name="book_local">添加本地</string>
<string name="book_source">书源</string>
<string name="book_source_manage">书源管理</string> <string name="book_source_manage">书源管理</string>
<string name="setting">设置</string> <string name="setting">设置</string>
<string name="theme_setting">主题设置</string> <string name="theme_setting">主题设置</string>

Loading…
Cancel
Save