Skip to content

Commit b1ebdde

Browse files
committed
Initial commit
0 parents  commit b1ebdde

33 files changed

+728
-0
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild

.idea/compiler.xml

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copyright/profiles_settings.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+43
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 24
5+
buildToolsVersion "25.0.1"
6+
defaultConfig {
7+
applicationId "com.example.android.justjava"
8+
minSdkVersion 15
9+
targetSdkVersion 24
10+
versionCode 1
11+
versionName "1.0"
12+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25+
exclude group: 'com.android.support', module: 'support-annotations'
26+
})
27+
compile 'com.android.support:appcompat-v7:24.2.1'
28+
testCompile 'junit:junit:4.12'
29+
}

app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in C:\Users\arunk\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.example.android.justjava;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.example.android.justjava", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.example.android.justjava">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:supportsRtl="true"
10+
android:theme="@style/AppTheme">
11+
<activity android:name=".MainActivity">
12+
<intent-filter>
13+
<action android:name="android.intent.action.MAIN" />
14+
15+
<category android:name="android.intent.category.LAUNCHER" />
16+
</intent-filter>
17+
</activity>
18+
</application>
19+
20+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* Add your package below. Package name can be found in the project's AndroidManifest.xml file.
3+
* This is the package name our example uses:
4+
*/
5+
package com.example.android.justjava;
6+
7+
8+
import android.os.Bundle;
9+
import android.support.v7.app.AppCompatActivity;
10+
import android.view.View;
11+
import android.widget.TextView;
12+
13+
import java.text.NumberFormat;
14+
15+
/**
16+
* This app displays an order form to order coffee.
17+
*/
18+
public class MainActivity extends AppCompatActivity {
19+
20+
int quantity = 2;
21+
22+
@Override
23+
protected void onCreate(Bundle savedInstanceState) {
24+
super.onCreate(savedInstanceState);
25+
setContentView(R.layout.activity_main);
26+
}
27+
28+
/**
29+
* This method is called when the order button is clicked.
30+
*/
31+
public void submitOrder(View view) {
32+
String priceMessage = createOrderSummary(5);
33+
displayMessage(priceMessage);
34+
}
35+
36+
/*
37+
The next two method increment / decrements the order size
38+
*/
39+
public void increment(View view) {
40+
quantity = quantity + 1;
41+
displayQuantity(quantity);
42+
}
43+
44+
public void decrement(View view) {
45+
quantity = quantity - 1;
46+
displayQuantity(quantity);
47+
}
48+
49+
50+
/**
51+
* This method displays the given quantity value on the screen.
52+
*/
53+
private void displayQuantity(int number) {
54+
TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view);
55+
quantityTextView.setText("" + number);
56+
}
57+
58+
/**
59+
* This method calculates the price of the order
60+
*
61+
*/
62+
private String createOrderSummary(int price){
63+
String orderSummary = "Name: Kaptain Kunal\n" + "Quantity:" + quantity + "\nTotal: " + quantity * price + "\nThank you!";
64+
return orderSummary;
65+
}
66+
67+
/**
68+
* This method displays the given text on the screen.
69+
*/
70+
private void displayMessage(String message) {
71+
TextView orderSummaryTextView = (TextView) findViewById(R.id.order_summary_text_view);
72+
orderSummaryTextView.setText(message);
73+
}
74+
75+
}

0 commit comments

Comments
 (0)