From 973a00007f23f01355d91ce4b2a76309d547dea9 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 2 Jun 2019 20:29:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/main/MainActivity.kt | 44 +------------------ app/src/main/res/layout/activity_main.xml | 35 ++++++++------- app/src/main/res/layout/app_bar_main.xml | 26 ----------- app/src/main/res/layout/content_main.xml | 2 +- 4 files changed, 20 insertions(+), 87 deletions(-) delete mode 100644 app/src/main/res/layout/app_bar_main.xml diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index b147d44df..4a602e66b 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -4,24 +4,16 @@ import android.content.Intent import android.os.Bundle import android.view.Menu import android.view.MenuItem -import androidx.appcompat.app.ActionBarDrawerToggle -import androidx.core.view.GravityCompat -import androidx.drawerlayout.widget.DrawerLayout -import com.google.android.material.navigation.NavigationView import io.legado.app.R import io.legado.app.base.BaseActivity import io.legado.app.help.permission.Permissions import io.legado.app.help.permission.PermissionsCompat -import io.legado.app.help.storage.Backup import io.legado.app.help.storage.Restore -import io.legado.app.ui.replacerule.ReplaceRuleActivity import io.legado.app.ui.search.SearchActivity import io.legado.app.utils.getViewModel import kotlinx.android.synthetic.main.activity_main.* -import kotlinx.android.synthetic.main.app_bar_main.* -import org.jetbrains.anko.startActivity -class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedListener { +class MainActivity : BaseActivity() { override val viewModel: MainViewModel get() = getViewModel(MainViewModel::class.java) @@ -31,24 +23,7 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationI override fun onViewModelCreated(viewModel: MainViewModel, savedInstanceState: Bundle?) { fab.setOnClickListener { startActivity(Intent(this, SearchActivity::class.java)) } - val toggle = ActionBarDrawerToggle( - this, drawer_layout, title_bar.toolbar, - R.string.navigation_drawer_open, - R.string.navigation_drawer_close - ) - drawer_layout.addDrawerListener(toggle) - toggle.syncState() - nav_view.setNavigationItemSelectedListener(this) - } - - override fun onBackPressed() { - val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout) - if (drawerLayout.isDrawerOpen(GravityCompat.START)) { - drawerLayout.closeDrawer(GravityCompat.START) - } else { - super.onBackPressed() - } } override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { @@ -60,23 +35,6 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationI return super.onCompatOptionsItemSelected(item) } - override fun onNavigationItemSelected(item: MenuItem): Boolean { - // Handle navigation view item clicks here. - when (item.itemId) { - R.id.nav_backup -> Backup.backup() - R.id.nav_restore -> Restore.restore() - R.id.nav_import_old -> importYueDu() - R.id.nav_import_github -> Restore.importFromGithub() - R.id.nav_replace_rule -> startActivity() - R.id.nav_send -> { - - } - } - val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout) - drawerLayout.closeDrawer(GravityCompat.START) - return true - } - private fun importYueDu() { PermissionsCompat.Builder(this) .addPermissions(*Permissions.Group.STORAGE) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 405e13f17..6791f4943 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,25 +1,26 @@ - + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".ui.main.MainActivity"> - + android:fitsSystemWindows="true" + android:layout_height="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"/> - + diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml deleted file mode 100644 index 9de695516..000000000 --- a/app/src/main/res/layout/app_bar_main.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index 10ee1e73e..1e7c273e2 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -6,7 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" - tools:showIn="@layout/app_bar_main" + tools:showIn="@layout/activity_main" tools:context=".ui.main.MainActivity">