Skip to content

Commit f2d2be3

Browse files
committed
Initial commit
0 parents  commit f2d2be3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1199
-0
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WORKSPACE.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
android_sdk_repository(name = "androidsdk")
2+
3+
android_sdk_repository(
4+
name = "androidsdk",
5+
path = "/path/to/Android/sdk",
6+
api_level = 25,
7+
build_tools_version = "30.0.3"
8+
)

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'org.jetbrains.kotlin.android'
4+
}
5+
6+
android {
7+
compileSdk 32
8+
9+
defaultConfig {
10+
applicationId "com.example.helloworldkotlin"
11+
minSdk 21
12+
targetSdk 32
13+
versionCode 1
14+
versionName "1.0"
15+
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
compileOptions {
26+
sourceCompatibility JavaVersion.VERSION_1_8
27+
targetCompatibility JavaVersion.VERSION_1_8
28+
}
29+
kotlinOptions {
30+
jvmTarget = '1.8'
31+
}
32+
buildFeatures {
33+
viewBinding true
34+
}
35+
}
36+
37+
dependencies {
38+
39+
implementation 'androidx.core:core-ktx:1.7.0'
40+
implementation 'androidx.appcompat:appcompat:1.4.1'
41+
implementation 'com.google.android.material:material:1.5.0'
42+
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
43+
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.1'
44+
implementation 'androidx.navigation:navigation-ui-ktx:2.4.1'
45+
testImplementation 'junit:junit:4.13.2'
46+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
47+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
48+
49+
// android room kotlin config
50+
// unable to resolve class val
51+
52+
// Groovy config https://developer.android.com/training/data-storage/room#groovy
53+
def room_version = "2.4.1"
54+
55+
implementation "androidx.room:room-runtime:$room_version"
56+
annotationProcessor "androidx.room:room-compiler:$room_version"
57+
58+
// optional - RxJava2 support for Room
59+
implementation "androidx.room:room-rxjava2:$room_version"
60+
61+
// optional - RxJava3 support for Room
62+
implementation "androidx.room:room-rxjava3:$room_version"
63+
64+
// optional - Guava support for Room, including Optional and ListenableFuture
65+
implementation "androidx.room:room-guava:$room_version"
66+
67+
// optional - Test helpers
68+
testImplementation "androidx.room:room-testing:$room_version"
69+
70+
// optional - Paging 3 Integration
71+
implementation "androidx.room:room-paging:2.4.1"
72+
73+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example.helloworldkotlin
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.example.helloworldkotlin", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.example.helloworldkotlin">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/Theme.HelloWorldKotlin">
12+
<activity
13+
android:name=".MainActivity"
14+
android:exported="true"
15+
android:label="@string/app_name"
16+
android:theme="@style/Theme.HelloWorldKotlin.NoActionBar">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
19+
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
</application>
24+
25+
</manifest>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.example.helloworldkotlin
2+
3+
import android.os.Bundle
4+
import androidx.fragment.app.Fragment
5+
import android.view.LayoutInflater
6+
import android.view.View
7+
import android.view.ViewGroup
8+
import androidx.navigation.fragment.findNavController
9+
import com.example.helloworldkotlin.databinding.FragmentFirstBinding
10+
11+
/**
12+
* A simple [Fragment] subclass as the default destination in the navigation.
13+
*/
14+
class FirstFragment : Fragment() {
15+
16+
private var _binding: FragmentFirstBinding? = null
17+
18+
// This property is only valid between onCreateView and
19+
// onDestroyView.
20+
private val binding get() = _binding!!
21+
22+
override fun onCreateView(
23+
inflater: LayoutInflater, container: ViewGroup?,
24+
savedInstanceState: Bundle?
25+
): View? {
26+
27+
_binding = FragmentFirstBinding.inflate(inflater, container, false)
28+
return binding.root
29+
30+
}
31+
32+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
33+
super.onViewCreated(view, savedInstanceState)
34+
35+
binding.buttonFirst.setOnClickListener {
36+
findNavController().navigate(R.id.action_FirstFragment_to_SecondFragment)
37+
}
38+
}
39+
40+
override fun onDestroyView() {
41+
super.onDestroyView()
42+
_binding = null
43+
}
44+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.example.helloworldkotlin
2+
3+
import android.os.Bundle
4+
import com.google.android.material.snackbar.Snackbar
5+
import androidx.appcompat.app.AppCompatActivity
6+
import androidx.navigation.findNavController
7+
import androidx.navigation.ui.AppBarConfiguration
8+
import androidx.navigation.ui.navigateUp
9+
import androidx.navigation.ui.setupActionBarWithNavController
10+
import android.view.Menu
11+
import android.view.MenuItem
12+
import com.example.helloworldkotlin.databinding.ActivityMainBinding
13+
14+
class MainActivity : AppCompatActivity() {
15+
16+
private lateinit var appBarConfiguration: AppBarConfiguration
17+
private lateinit var binding: ActivityMainBinding
18+
19+
override fun onCreate(savedInstanceState: Bundle?) {
20+
super.onCreate(savedInstanceState)
21+
22+
binding = ActivityMainBinding.inflate(layoutInflater)
23+
setContentView(binding.root)
24+
25+
setSupportActionBar(binding.toolbar)
26+
27+
val navController = findNavController(R.id.nav_host_fragment_content_main)
28+
appBarConfiguration = AppBarConfiguration(navController.graph)
29+
setupActionBarWithNavController(navController, appBarConfiguration)
30+
31+
binding.fab.setOnClickListener { view ->
32+
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
33+
.setAction("Action", null).show()
34+
}
35+
}
36+
37+
override fun onCreateOptionsMenu(menu: Menu): Boolean {
38+
// Inflate the menu; this adds items to the action bar if it is present.
39+
menuInflater.inflate(R.menu.menu_main, menu)
40+
return true
41+
}
42+
43+
override fun onOptionsItemSelected(item: MenuItem): Boolean {
44+
// Handle action bar item clicks here. The action bar will
45+
// automatically handle clicks on the Home/Up button, so long
46+
// as you specify a parent activity in AndroidManifest.xml.
47+
return when (item.itemId) {
48+
R.id.action_settings -> true
49+
else -> super.onOptionsItemSelected(item)
50+
}
51+
}
52+
53+
override fun onSupportNavigateUp(): Boolean {
54+
val navController = findNavController(R.id.nav_host_fragment_content_main)
55+
return navController.navigateUp(appBarConfiguration)
56+
|| super.onSupportNavigateUp()
57+
}
58+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.example.helloworldkotlin
2+
3+
import android.os.Bundle
4+
import androidx.fragment.app.Fragment
5+
import android.view.LayoutInflater
6+
import android.view.View
7+
import android.view.ViewGroup
8+
import androidx.navigation.fragment.findNavController
9+
import com.example.helloworldkotlin.databinding.FragmentSecondBinding
10+
11+
/**
12+
* A simple [Fragment] subclass as the second destination in the navigation.
13+
*/
14+
class SecondFragment : Fragment() {
15+
16+
private var _binding: FragmentSecondBinding? = null
17+
18+
// This property is only valid between onCreateView and
19+
// onDestroyView.
20+
private val binding get() = _binding!!
21+
22+
override fun onCreateView(
23+
inflater: LayoutInflater, container: ViewGroup?,
24+
savedInstanceState: Bundle?
25+
): View? {
26+
27+
_binding = FragmentSecondBinding.inflate(inflater, container, false)
28+
return binding.root
29+
30+
}
31+
32+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
33+
super.onViewCreated(view, savedInstanceState)
34+
35+
binding.buttonSecond.setOnClickListener {
36+
findNavController().navigate(R.id.action_SecondFragment_to_FirstFragment)
37+
}
38+
}
39+
40+
override fun onDestroyView() {
41+
super.onDestroyView()
42+
_binding = null
43+
}
44+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package(
2+
default_visibility = ["//src:__subpackages__"],
3+
)
4+
5+
android_library(
6+
name = "greeter_activity",
7+
srcs = [
8+
"Greeter.java",
9+
"MainActivity.java",
10+
],
11+
manifest = "AndroidManifest.xml",
12+
resource_files = glob(["res/**"]),
13+
)

0 commit comments

Comments
 (0)