diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..94a25f7f4 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/androidTest/java/io/legado/app/ExampleInstrumentedTest.kt b/app/src/androidTest/java/io/legado/app/ExampleInstrumentedTest.kt new file mode 100644 index 000000000..86b312778 --- /dev/null +++ b/app/src/androidTest/java/io/legado/app/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package io.legado.app + +import androidx.test.InstrumentationRegistry +import androidx.test.runner.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getTargetContext() + assertEquals("cn.legado.book", appContext.packageName) + } +} diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt new file mode 100644 index 000000000..e6fcf2122 --- /dev/null +++ b/app/src/main/java/io/legado/app/App.kt @@ -0,0 +1,11 @@ +package io.legado.app + +import android.app.Application + +class App : Application() { + + + override fun onCreate() { + super.onCreate() + } +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/view/MainActivity.kt b/app/src/main/java/io/legado/app/view/MainActivity.kt new file mode 100644 index 000000000..8a6f64c65 --- /dev/null +++ b/app/src/main/java/io/legado/app/view/MainActivity.kt @@ -0,0 +1,94 @@ +package io.legado.app.view + +import android.os.Bundle +import com.google.android.material.floatingactionbutton.FloatingActionButton +import com.google.android.material.snackbar.Snackbar +import androidx.core.view.GravityCompat +import androidx.appcompat.app.ActionBarDrawerToggle +import android.view.MenuItem +import androidx.drawerlayout.widget.DrawerLayout +import com.google.android.material.navigation.NavigationView +import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.widget.Toolbar +import android.view.Menu +import io.legado.app.R + +class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener { + + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + val toolbar: Toolbar = findViewById(R.id.toolbar) + setSupportActionBar(toolbar) + + val fab: FloatingActionButton = findViewById(R.id.fab) + fab.setOnClickListener { view -> + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show() + } + val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout) + val navView: NavigationView = findViewById(R.id.nav_view) + val toggle = ActionBarDrawerToggle( + this, drawerLayout, toolbar, + R.string.navigation_drawer_open, + R.string.navigation_drawer_close + ) + drawerLayout.addDrawerListener(toggle) + toggle.syncState() + + navView.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 onCreateOptionsMenu(menu: Menu): Boolean { + // Inflate the menu; this adds items to the action bar if it is present. + menuInflater.inflate(R.menu.main, menu) + return true + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + return when (item.itemId) { + R.id.action_settings -> true + else -> super.onOptionsItemSelected(item) + } + } + + override fun onNavigationItemSelected(item: MenuItem): Boolean { + // Handle navigation view item clicks here. + when (item.itemId) { + R.id.nav_home -> { + // Handle the camera action + } + R.id.nav_gallery -> { + + } + R.id.nav_slideshow -> { + + } + R.id.nav_tools -> { + + } + R.id.nav_share -> { + + } + R.id.nav_send -> { + + } + } + val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout) + drawerLayout.closeDrawer(GravityCompat.START) + return true + } +} diff --git a/app/src/test/java/io/legado/app/ExampleUnitTest.kt b/app/src/test/java/io/legado/app/ExampleUnitTest.kt new file mode 100644 index 000000000..57609f92a --- /dev/null +++ b/app/src/test/java/io/legado/app/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package io.legado.app + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +}