type of variable

var lightSwitchOn: Bool = true
var dimmer: Int = 7
var dimmerWithDecimals: Float = 3.14
var veryPreciseDimmer: Double = 3.14159265359

print(type(of: lightSwitchOn))
print(type(of: veryPreciseDimmer))
Bool
Double

Double, Bool, String, Float

use let to declare a constant when we expect its value to remain the same
we expect let not change

let encouragement = "You can do it!"

var personalizedEncouragement = "You can do it, Stephanie!"
personalizedEncouragement = personalizedEncouragement.replacingOccurrences(of: "Stephanie", with: "Ryder")

let birthYear = 2008
var currentYear = 2016
var age = currentYear - birthYear
age = currentYear - birthYear

Method

var word = "fortunate"
word.contains("tuna")

var password = "Mary had a little loris"
var newPassword = password.replacingOccurences(of: "a" with "A")
import Foundation

var didYouKnowString = "Did you know that the Swift String class comes with lots of useful methods?"
var whisperString = "pass" + ", " + "\(didYouKnowString.lowercased())"
var shoutString = "TODO: Make the shoutString here!"
import Foundation

var forwardString = "stressed"

var lottaLikes = "If like, you wanna learn Swift like, you should build lots of small apps, cuz it's like, a good way to practice."

string interpolation

import Glibc

var nounArray = ["puppy", "laptop", "ocean", "app", "cow", "skateboard", "developer", "coffee", "moon"]

var index1 = Int(random() % 9)
var index2 = Int(random() % 9)

var sentence = "The \(nounarray[6]) spilled her \(nounArray[7])."

var sillySentence = "The \(nounArray[index1]) jumped over the \(nounArray[index2])."

print(sentence)
print(sillySentence)
var eString = "Meet me in St. Louis"
for character in eString.characters {
	if character == "e" {
		print("found an e!")
	} else {
	
	}
}
var eString = "Meet me in St. Louis"
for character in eString.characters {
	if character == "e" {
		print("found an e!")
	} else {	
	}
}

var theTruth = "Mony can buy me love."
var characterCount = theTruth.characters.count

var forwardString = "spoons"
var charactersReversed = forwardString.characters.reversed()
var backwardsString = String(charactersReversed)

print(backwardsString)
found an e!
found an e!
found an e!
snoops

swift string

var exitement: Character = "!"

var myFirstString: String = "In wine, there is wisdom."
var mySecondString: String = "In water, there is Giardia."

var characterPoorString = ""

var stringWithPotential = String()

var theTruth = myFirstString + " " + mySecondString

print(theTruth)
// Plain string
var doggyDiet = "Mia eats 10lbs of dog food per month"

// define variables
var dogName = "Mia"
var lbsPerMonth: Double = 10

// Same string, this time with the variable inserted
doggyDiet = "\(dogName) eats \(lbsPerMonth)lbs of dog food per month"
print(doggyDiet)

let kilosInALb = 0.45
lbsPerMonth = 25
var metricDoggyDiet = "\(dogName) eats \(kilosInAlb * lbsPerMonth)kilos of dog food per month"

print(metricDoggyDiet)

dogName = "Mia"
lbsPerMonth = 10
metricDoggyDiet = "\(dogName) eats \(kilosInALb * lbsPerMonth)kilos of dog food per month"

print(metricDoggyDiet)

sandbox

print((200 * 7)/2)
print("Hello from the ios team")

variable function

var name = "jack"
var introduction = "I'm \(name),"

var nobleGoal = "skill up"
var yourDream = " and I used to dream of building an app that could \(nobleGoal)."

print(introduction + yourDream)

try again

var language = "swift"
var epiphany = " Then, one day, I discovered \(language)."

print(epiphany)

concatenate variable each other

var language = "java"
var nobleGoal = "AR"

var condition = "Then I knew that, programming in \(language). "
var result = "I could make my dream of \(nobleGoal) a realilty."

var end = condition + result
print(end)

style

<TextView
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:layout_marginBottom="16dp"
	android:layout_marginTop="16dp"
	android:text="@string/toppings"
	style="@style/CustomText"
	android:textAllCaps="true" />

Themes of App
https://material.io/guidelines/style/color.html

-color primary
-color primary dark
-color account

email intent android

commont intent
https://developer.android.com/guide/components/intents-common.html

public void addEvent(String title, String location, Calendar begin, Calendar end) {
    Intent intent = new Intent(Intent.ACTION_INSERT)
            .setData(Events.CONTENT_URI)
            .putExtra(Events.TITLE, title)
            .putExtra(Events.EVENT_LOCATION, location)
            .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, begin)
            .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, end);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}
public void composeEmail(String[] addresses, String subject) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:")); // only email apps should handle this
    intent.putExtra(Intent.EXTRA_EMAIL, addresses);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}

support localization
https://developer.android.com/guide/topics/resources/localization.html

What’s inside an Intent?

Action, data uri, category, component, extras

Example mas intent
ACTION_VIEW
geo:47.6, -122.3

Example dial intent
ACTION_DIAL
tel:2125551212

Common intent guide
https://developer.android.com/guide/components/intents-common.html?utm_source=udacity&utm_medium=course&utm_campaign=android_basics

static final int REQUEST_IMAGE_CAPTURE = 1;
static final Uri mLocationForPhotos;

public void capturePhoto(String targetFilename) {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.withAppendedPath(mLocationForPhotos, targetFilename));
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
        Bitmap thumbnail = data.getParcelable("data");
        // Do other work with full size photo saved in mLocationForPhotos
        ...
    }
}
 public void submitOrder(View view){

 	Intent intent = new Intent(Intent.ACTION_VIEW);
 	intent.setData(Uri.parse("geo:47.6, 122.3"));
 	if (intent.resolveActivity(getPackageManager()) != null){
 		startActivity(intent);
 	}
 }

check box

	public void decrement(View view){
		quantity = quantity - 1;
		displayQuantity(quantity);
	}

	public void submitOrder(View view){
		CheckBox = whippedCreamCheckBox = (CheckBox) findViewById(R.id.whipped_cream_checkbox);
		boolean hasWhippedCream = whippedCreamCheckBox.isChecked();
		Log.v("MainActivity", "Has whipped cream; " + hasWhippedCream);

		int price = calculatePrice();
		String priceMessage = createOrderSummary(price, hasWhippedCream);
		displayMessage(priceMEssage);
	}

	private int calculatePrice(){ return quantity * 5; }

	private String createOrderSummary(int price, boolean addWhippedCream){
		String priceMessage = "Name: Lyla the Labyrinth";
		priceMessage += "\nQuantity: " + quantity;
		priceMessage += "\nTotal: $" + price;
		priceMessage += "\nThank you!";
		return priceMessage;
	}