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
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

20 changes: 0 additions & 20 deletions .idea/gradle.xml

This file was deleted.

30 changes: 0 additions & 30 deletions .idea/jarRepositories.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/misc.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/runConfigurations.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.magdamiu.androidfundamentalsmai2021">
<<<<<<< HEAD

<uses-permission android:name="android.permission.INTERNET" />

=======
<uses-permission android:name="android.permission.INTERNET"/>
>>>>>>> curs3_cc1
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import android.os.Bundle;
import android.util.Log;
import android.util.Patterns;
import android.view.View;
import android.webkit.WebView;
import android.widget.AdapterView;
Expand All @@ -16,24 +17,38 @@

import java.util.ArrayList;
import java.util.List;
<<<<<<< HEAD
=======
import java.util.regex.Pattern;
>>>>>>> curs3_cc1

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

private EditText phone;
private EditText email;
private EditText editTextName;
private Button buttonDisplayGreetings;
private TextView textViewGreetings;
<<<<<<< HEAD
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is necessary to resolve the conflicts before you commit the code


private WebView webView;

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

=======
private WebView webView;
private Spinner spinnerAndroidVersions;
private List<String> androidVersions;
private ArrayAdapter<String> spinnerAdapter;
>>>>>>> curs3_cc1
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*setContentView(R.layout.activity_main);*/
<<<<<<< HEAD
/*setContentView(R.layout.sample);*/
// setContentView(R.layout.scrollview_sample);
// setContentView(R.layout.webview_sample);
Expand All @@ -47,8 +62,57 @@ protected void onCreate(Bundle savedInstanceState) {
//loadUrl();

// initViews();
=======
// setContentView(R.layout.web_view_sample);
// load_url();
setContentView(R.layout.spinner_sample);
setAndroidVersions();
// initViews();
initializeSpinnerAdapter();
setSpinnerAdapter();
>>>>>>> curs3_cc1
displayLogs();
}
// step 1: data source for our spinner
private void setAndroidVersions() {
androidVersions = new ArrayList<>();
androidVersions.add("cupcake");
androidVersions.add("eclair");
androidVersions.add("donut");
androidVersions.add("pie");
}

private void initializeSpinnerAdapter() {
spinnerAdapter = new ArrayAdapter<>(MainActivity.this,
android.R.layout.simple_spinner_item,
androidVersions);
}

private void setSpinnerAdapter() {
spinnerAndroidVersions = findViewById(R.id.spinnerAndroidVersions);
spinnerAndroidVersions.setAdapter(spinnerAdapter);
}

private void handlingSpinnerListener() {
spinnerAndroidVersions.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, 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<?> parent) {

}
});
}

private void load_url() {
webView = findViewById(R.id.webViewSample);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(getString(R.string.ANDROID_URL));
}

// step 1: data source for our spinner
private void setAndroidVersions() {
Expand Down Expand Up @@ -128,4 +192,26 @@ public void displayGreetingsOnClick(View view) {
Toast.makeText(MainActivity.this, getString(R.string.error_insert_name), Toast.LENGTH_LONG).show();
}
}

boolean isPhoneNumber(String phoneNumber) {
return Patterns.PHONE.matcher(phoneNumber).matches();
}

boolean isEmail(String email) {
return Patterns.EMAIL_ADDRESS.matcher(email).matches();
}

public void submitInformation(View view) {

phone = findViewById(R.id.phone);
email = findViewById(R.id.email);
if (!isPhoneNumber(phone.toString())) {
Toast.makeText(MainActivity.this, getString(R.string.wrong_phone_pattern), Toast.LENGTH_LONG).show();
return;
}

if (!isEmail(email.toString())) {
Toast.makeText(MainActivity.this, getString(R.string.wrong_email_pattern), Toast.LENGTH_LONG).show();
}
}
}
15 changes: 15 additions & 0 deletions app/src/main/res/layout/frame_layout_sample.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="@dimen/space_128"
android:background="@color/purple_200"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="@dimen/space_256"
android:background="@color/purple_200"
/>
</FrameLayout>
16 changes: 16 additions & 0 deletions app/src/main/res/layout/realtive_layout_sample.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:id="@+id/textViewTop"
android:text="@string/text_on_the_right" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textViewTop"
android:text="@string/text_below" />
</RelativeLayout>
35 changes: 35 additions & 0 deletions app/src/main/res/layout/scroll_view_sample.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_space"
android:text="@string/long_text"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_space"
android:text="@string/long_text"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_space"
android:text="@string/long_text"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_space"
android:text="@string/long_text"
/>
</LinearLayout>
</ScrollView>
11 changes: 11 additions & 0 deletions app/src/main/res/layout/spinner_sample.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<<<<<<< HEAD
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/medium_space"
Expand All @@ -10,4 +11,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

=======
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinnerAndroidVersions" />
>>>>>>> curs3_cc1
</LinearLayout>
7 changes: 7 additions & 0 deletions app/src/main/res/layout/web_view_sample.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webViewSample">

</WebView>
43 changes: 43 additions & 0 deletions app/src/main/res/layout/week3_cc1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/login"
android:textColor="@color/orange"
android:textSize="@dimen/medium_text"
android:layout_marginLeft="@dimen/small_space"
android:layout_marginRight="@dimen/small_space"/>

<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/email"
android:autofillHints="@string/email"
android:inputType="textEmailAddress" />

<EditText
android:id="@+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/phone"
android:inputType="phone"
android:autofillHints="@string/phone" />

<CheckBox
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/i_accept_t_amp_c" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/submit"
android:onClick="submitInformation" />

</LinearLayout>
Loading