-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adam A. Porter
committed
Aug 4, 2019
1 parent
58a1e19
commit 901f4f1
Showing
22 changed files
with
574 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Built application files | ||
*.apk | ||
*.ap_ | ||
*.aab | ||
|
||
# Files for the ART/Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
out/ | ||
release/ | ||
/*/build/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
|
||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# Android Studio Navigation editor temp files | ||
.navigation/ | ||
|
||
# Android Studio captures folder | ||
captures/ | ||
|
||
# IntelliJ | ||
*.iml | ||
.idea/workspace.xml | ||
.idea/tasks.xml | ||
.idea/gradle.xml | ||
.idea/assetWizardSettings.xml | ||
.idea/dictionaries | ||
.idea/libraries | ||
# Android Studio 3 in .gitignore file. | ||
.idea/caches | ||
.idea/modules.xml | ||
# Comment next line if keeping position of elements in Navigation Editor is relevant for you | ||
.idea/navEditor.xml | ||
|
||
# Keystore files | ||
# Uncomment the following lines if you do not want to check your keystore files in. | ||
#*.jks | ||
#*.keystore | ||
|
||
# External native build folder generated in Android Studio 2.2 and later | ||
.externalNativeBuild | ||
|
||
# Google Services (e.g. APIs or Firebase) | ||
# google-services.json | ||
|
||
# Freeline | ||
freeline.py | ||
freeline/ | ||
freeline_project_description.json | ||
|
||
# fastlane | ||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots | ||
fastlane/test_output | ||
fastlane/readme.md | ||
|
||
# Version control | ||
vcs.xml | ||
|
||
# lint | ||
lint/intermediates/ | ||
lint/generated/ | ||
lint/outputs/ | ||
lint/tmp/ | ||
# lint/reports/ | ||
|
||
# capture | ||
|
||
*.hprof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apply plugin: 'com.android.application' | ||
apply plugin: 'kotlin-android-extensions' | ||
apply plugin: 'kotlin-android' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
|
||
defaultConfig { | ||
applicationId "course.examples.helloandroidwithmenu" | ||
minSdkVersion 21 | ||
targetSdkVersion 28 | ||
|
||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' | ||
} | ||
} | ||
} | ||
repositories { | ||
mavenCentral() | ||
} | ||
dependencies { | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
} |
23 changes: 23 additions & 0 deletions
23
ExamplesKotlin/HelloAndroidWithMenus/app/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="course.examples.helloandroidwithmenu" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
|
||
<application | ||
android:allowBackup="false" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/MaterialTheme"> | ||
<activity | ||
android:name=".HelloAndroidWithMenuActivity" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
71 changes: 71 additions & 0 deletions
71
...us/app/src/main/java/course/examples/helloandroidwithmenu/HelloAndroidWithMenuActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package course.examples.helloandroidwithmenu | ||
|
||
import android.app.Activity | ||
import android.os.Bundle | ||
import android.view.ContextMenu | ||
import android.view.ContextMenu.ContextMenuInfo | ||
import android.view.Menu | ||
import android.view.MenuItem | ||
import android.view.View | ||
import android.widget.TextView | ||
import android.widget.Toast | ||
|
||
class HelloAndroidWithMenuActivity : Activity() { | ||
public override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
setContentView(R.layout.main) | ||
|
||
// Long presses on TextView invoke Context Menu | ||
registerForContextMenu(findViewById<TextView>(R.id.text_view)) | ||
|
||
} | ||
|
||
// Create Options Menu | ||
override fun onCreateOptionsMenu(menu: Menu): Boolean { | ||
val inflater = menuInflater | ||
inflater.inflate(R.menu.top_menu, menu) | ||
return true | ||
} | ||
|
||
// Process clicks on Options Menu items | ||
override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||
return when (item.itemId) { | ||
R.id.help -> { | ||
showToast(R.string.helped_string) | ||
true | ||
} | ||
R.id.more_help -> { | ||
showToast(R.string.helped_more_string) | ||
true | ||
} | ||
R.id.even_more_help -> true | ||
else -> false | ||
} | ||
} | ||
|
||
// Create Context Menu | ||
override fun onCreateContextMenu( | ||
menu: ContextMenu, v: View, | ||
menuInfo: ContextMenuInfo? | ||
) { | ||
super.onCreateContextMenu(menu, v, menuInfo) | ||
val inflater = menuInflater | ||
inflater.inflate(R.menu.context_menu, menu) | ||
} | ||
|
||
// Process clicks on Context Menu Items | ||
override fun onContextItemSelected(item: MenuItem): Boolean { | ||
return when (item.itemId) { | ||
R.id.help_guide -> { | ||
showToast(R.string.context_menu_shown_string) | ||
true | ||
} | ||
else -> false | ||
} | ||
} | ||
|
||
private fun showToast(msg: Int) { | ||
Toast.makeText(applicationContext, msg, Toast.LENGTH_SHORT).show() | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
ExamplesKotlin/HelloAndroidWithMenus/app/src/main/res/layout/main.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:padding="@dimen/activity_margin"> | ||
|
||
<TextView | ||
android:id="@+id/text_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center" | ||
android:text="@string/hello_android" | ||
android:textAppearance="@android:style/TextAppearance.Material.Display1" /> | ||
|
||
</RelativeLayout> |
7 changes: 7 additions & 0 deletions
7
ExamplesKotlin/HelloAndroidWithMenus/app/src/main/res/menu/context_menu.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" > | ||
|
||
<item | ||
android:id="@+id/help_guide" | ||
android:title="@string/guide"/> | ||
|
||
</menu> |
21 changes: 21 additions & 0 deletions
21
ExamplesKotlin/HelloAndroidWithMenus/app/src/main/res/menu/top_menu.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" > | ||
|
||
<item | ||
android:id="@+id/help" | ||
android:icon="@mipmap/ic_menu_help" | ||
android:title="@string/help"/> | ||
<item | ||
android:id="@+id/more_help" | ||
android:icon="@mipmap/ic_menu_help" | ||
android:title="@string/more_help"/> | ||
<item | ||
android:id="@+id/even_more_help" | ||
android:icon="@mipmap/ic_menu_help" | ||
android:title="@string/even_more_help"> | ||
<menu> | ||
<item | ||
android:title="@string/give_up"/> | ||
</menu> | ||
</item> | ||
|
||
</menu> |
Binary file added
BIN
+7.48 KB
ExamplesKotlin/HelloAndroidWithMenus/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.69 KB
ExamplesKotlin/HelloAndroidWithMenus/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+391 Bytes
...plesKotlin/HelloAndroidWithMenus/app/src/main/res/mipmap-nodpi/ic_menu_help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.2 KB
ExamplesKotlin/HelloAndroidWithMenus/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+24.2 KB
...plesKotlin/HelloAndroidWithMenus/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions
9
ExamplesKotlin/HelloAndroidWithMenus/app/src/main/res/values/colors.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="primary">#FF5722</color> | ||
<color name="primary_dark">#E64A19</color> | ||
<color name="accent">#CCE5FF</color> | ||
<color name="primary_text">#000000</color> | ||
<color name="secondary_text">#727272</color> | ||
<color name="edit_text">#202020</color> | ||
</resources> |
7 changes: 7 additions & 0 deletions
7
ExamplesKotlin/HelloAndroidWithMenus/app/src/main/res/values/dimens.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_margin">16dp</dimen> | ||
|
||
<!--Space between content areas: 8dp--> | ||
</resources> |
15 changes: 15 additions & 0 deletions
15
ExamplesKotlin/HelloAndroidWithMenus/app/src/main/res/values/strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<string name="app_name">HelloAndroidWithMenus</string> | ||
<string name="help">Help</string> | ||
<string name="more_help">Help!</string> | ||
<string name="even_more_help">Help!!</string> | ||
<string name="guide">Hit the Menu Button!</string> | ||
<string name="give_up">There is no more help!</string> | ||
<string name="hello_android">Hello Android!</string> | ||
<string name="helped_string">you\'ve been helped</string> | ||
<string name="helped_more_string">you\'ve been helped more</string> | ||
<string name="context_menu_shown_string">ContextMenu Shown</string> | ||
|
||
</resources> |
12 changes: 12 additions & 0 deletions
12
ExamplesKotlin/HelloAndroidWithMenus/app/src/main/res/values/styles.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<style name="MaterialTheme" parent="android:Theme.Material.Light.DarkActionBar"> | ||
<item name="android:colorPrimary">@color/primary</item> | ||
<item name="android:colorPrimaryDark">@color/primary_dark</item> | ||
<item name="android:colorAccent">@color/accent</item> | ||
<item name="android:textColorPrimary">@color/primary_text</item> | ||
<item name="android:textColorSecondary">@color/secondary_text</item> | ||
<item name="android:editTextColor">@color/edit_text</item> | ||
<item name="android:colorButtonNormal">@color/primary</item> | ||
</style> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
buildscript { | ||
ext.kotlin_version = '1.3.41' | ||
repositories { | ||
jcenter() | ||
google() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.4.2' | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
google() | ||
} | ||
} |
Binary file added
BIN
+48.7 KB
ExamplesKotlin/HelloAndroidWithMenus/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
ExamplesKotlin/HelloAndroidWithMenus/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Sun Aug 04 18:32:17 EDT 2019 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip |
Oops, something went wrong.