Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AndroidFundamentalsMai2021">
<activity android:name=".ConstraintLayoutSampleActivity"></activity>
<activity android:name=".MainActivity" />
<activity android:name=".EmailsActivity" />
<activity android:name=".StartActivity">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,131 +1,13 @@
package com.magdamiu.androidfundamentalsmai2021;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.WebView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
private static final String ANDROID_URL = "https://developer.android.com/";

private EditText editTextName;
private Button buttonDisplayGreetings;
private TextView textViewGreetings;

private WebView webView;

private Spinner spinnerAndroidVersions;
private List<String> androidVersions;
private ArrayAdapter<String> spinnerAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*setContentView(R.layout.activity_main);*/
/*setContentView(R.layout.sample);*/
// setContentView(R.layout.scrollview_sample);
// setContentView(R.layout.webview_sample);
setContentView(R.layout.week3_code_challenge_2);

/* setAndroidVersions();
initialiseSpinnerAdapter();
setSpinnerAdapter();
handlingSpinnerListener();*/

//loadUrl();

// initViews();
displayLogs();
}

// step 1: data source for our spinner
private void setAndroidVersions() {
androidVersions = new ArrayList<>();
androidVersions.add("cupcake");
androidVersions.add("eclair");
androidVersions.add("pie");
androidVersions.add("donut");
androidVersions.add("kitkat");
}

// step 2: initialise adapter for our spinner
// ArrayAdapter is a default adapter
private void initialiseSpinnerAdapter() {
spinnerAdapter = new ArrayAdapter<>(MainActivity.this,
android.R.layout.simple_spinner_item,
androidVersions);
}

// step 3: set the adapter to our spinner
private void setSpinnerAdapter() {
spinnerAndroidVersions = findViewById(R.id.spinnerAndroidVersions);
spinnerAndroidVersions.setAdapter(spinnerAdapter);
}

private void handlingSpinnerListener() {
spinnerAndroidVersions.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
String selectedAndroidVersion = androidVersions.get(i);
Toast.makeText(MainActivity.this, selectedAndroidVersion, Toast.LENGTH_LONG).show();
}

@Override
public void onNothingSelected(AdapterView<?> adapterView) {

}
});
}

// webview load url
private void loadUrl() {
webView = findViewById(R.id.webViewSample);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(ANDROID_URL);
}

// init views for implementing a first simple form
private void initViews() {
editTextName = findViewById(R.id.editTextName);
buttonDisplayGreetings = findViewById(R.id.buttonDisplayGreetings);
textViewGreetings = findViewById(R.id.textViewGreetings);
}

private void displayLogs() {
Log.e("tag-error", "my first error log");
Log.v("tag-verbose", "my first verbose log");
Log.w("tag-warning", "my first warning log");
}

private void clickOnDisplayGreetingsButton() {
buttonDisplayGreetings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

}
});
}

public void displayGreetingsOnClick(View view) {
textViewGreetings.setText("");
String inputName = editTextName.getText().toString();
if (inputName.length() > 0) {
textViewGreetings.setText(inputName);
} else {
editTextName.setError(getString(R.string.error_insert_name));
Toast.makeText(MainActivity.this, getString(R.string.error_insert_name), Toast.LENGTH_LONG).show();
}
setContentView(R.layout.course4_code_challenge_1);
}
}
Binary file added app/src/main/res/drawable/android_1.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 app/src/main/res/drawable/android_2.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 app/src/main/res/drawable/android_3.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 modified app/src/main/res/drawable/android_logo.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 modified app/src/main/res/drawable/robot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions app/src/main/res/layout/course4_code_challenge_1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/light_beige">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:src="@drawable/android_1" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_margin="8dp"
android:src="@drawable/android_2" />

</RelativeLayout>

<View
android:layout_width="match_parent"
android:layout_height="@dimen/space_2"
android:background="@color/black" />

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@color/light_green" />

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="@dimen/space_16"
android:background="@color/dark_green" />

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="@dimen/space_32"
android:background="@color/dark_pink" />

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="@dimen/space_48"
android:background="@color/light_beige" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/android_3" />
</FrameLayout>

</LinearLayout>
4 changes: 4 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="light_green">#90ee90</color>
<color name="dark_green">#006400</color>
<color name="dark_pink">#c30082</color>
<color name="light_beige">#F5F5DD</color>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
<dimen name="medium_space">16dp</dimen>
<dimen name="space_128">128dp</dimen>
<dimen name="space_64">64dp</dimen>
<dimen name="space_2">2dp</dimen>
<dimen name="space_16">16dp</dimen>
<dimen name="space_32">32dp</dimen>
<dimen name="space_48">48dp</dimen>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>
<string name="app_name">Curs Android Fundamentals</string>
<string name="app_name">ViewGroups Example</string>
<string name="hello_world_from_android">Hello World from Android!</string>
<string name="this_is_my_first_textview">This is my first TextView</string>
<string name="i_am_a_button">I am a button</string>
Expand Down