parent
9107bcf15e
commit
b2d6f3f365
@ -0,0 +1,6 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project version="4"> |
||||||
|
<component name="VcsDirectoryMappings"> |
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" /> |
||||||
|
</component> |
||||||
|
</project> |
@ -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) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
package io.legado.app |
||||||
|
|
||||||
|
import android.app.Application |
||||||
|
|
||||||
|
class App : Application() { |
||||||
|
|
||||||
|
|
||||||
|
override fun onCreate() { |
||||||
|
super.onCreate() |
||||||
|
} |
||||||
|
} |
@ -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 |
||||||
|
} |
||||||
|
} |
@ -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) |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue