-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
6 changed files
with
143 additions
and
46 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
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 |
---|---|---|
@@ -1,11 +1,67 @@ | ||
package com.example.aboutme | ||
|
||
import android.content.Context | ||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import android.view.View | ||
import android.view.inputmethod.InputMethodManager | ||
import android.widget.Button | ||
import android.widget.EditText | ||
import android.widget.TextView | ||
import androidx.databinding.DataBindingUtil | ||
import com.example.aboutme.databinding.ActivityMainBinding | ||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
private lateinit var binding: ActivityMainBinding | ||
|
||
private val myName: MyName = MyName() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
//setContentView(R.layout.activity_main) | ||
binding = DataBindingUtil.setContentView(this, R.layout.activity_main) | ||
binding.myName = myName | ||
|
||
//findViewById<Button>(R.id.done_button).setOnClickListener { | ||
// addNickname(it) | ||
//} | ||
binding.doneButton.setOnClickListener { | ||
addNickname(it) | ||
} | ||
} | ||
|
||
private fun addNickname(view: View) { | ||
//val editText = findViewById<EditText>(R.id.nickname_edit) | ||
//val nicknameTextView = findViewById<TextView>(R.id.nickname_text) | ||
|
||
//nicknameTextView.text = editText.text | ||
//editText.visibility = View.GONE | ||
//view.visibility = View.GONE | ||
//nicknameTextView.visibility = View.VISIBLE | ||
binding.apply { | ||
//nicknameText.text = binding.nicknameEdit.text | ||
myName?.fullname = fullnameEdit.text.toString() | ||
myName?.firstname = fullnameEdit.text.split(" ")[0].toString() | ||
myName?.bio = "Hi, my name is "+ myName?.firstname +".\n\nI love fish." + | ||
"\n\nThe kind that is alive and swims around in an aquarium or river, or a lake, and definitely the ocean." + | ||
"\nFun fact is that I have several aquariums and also a river." + | ||
"\nI like eating fish too. Raw fish. Grilled fish. Smoked fish. Poached fish - not so mush." + | ||
"\nAnd sometimes I even go fishing.\n" + | ||
"\nAnd even less sometimes, I actually catch something." + | ||
"\n\nOnce, when I was camping in Canada, and very hungry, I even caught a large salmon with my hand." + | ||
"\n\nI\'ll be happy to teach you how to make your own aquarium." + | ||
"\nYou should ask someone else\n" | ||
invalidateAll() | ||
fullnameEdit.visibility = View.GONE | ||
doneButton.visibility = View.GONE | ||
firstnameText.visibility = View.VISIBLE | ||
starImage.visibility = View.VISIBLE | ||
bioScroll.visibility = View.VISIBLE | ||
} | ||
|
||
// Hide the keyboard | ||
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | ||
imm.hideSoftInputFromWindow(view.windowToken, 0) | ||
} | ||
} |
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,8 @@ | ||
package com.example.aboutme | ||
|
||
|
||
data class MyName( | ||
var fullname: String ="", | ||
var firstname: String ="", | ||
var bio: String ="" | ||
) |
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 |
---|---|---|
@@ -1,42 +1,81 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
android:paddingStart="@dimen/padding" | ||
android:paddingEnd="@dimen/padding"> | ||
|
||
<TextView | ||
android:id="@+id/name_text" | ||
style="@style/NameStyle" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/name" | ||
android:textAlignment="center" /> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<data> | ||
<variable | ||
name="myName" | ||
type="com.example.aboutme.MyName" /> | ||
</data> | ||
|
||
<ImageView | ||
android:id="@+id/star_image" | ||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:contentDescription="@string/yellow_star" | ||
app:srcCompat="@android:drawable/btn_star_big_on" /> | ||
android:orientation="vertical" | ||
android:paddingStart="@dimen/padding" | ||
android:paddingEnd="@dimen/padding"> | ||
|
||
<ScrollView | ||
android:id="@+id/bio_scroll" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
<TextView | ||
android:id="@+id/fullname_text" | ||
style="@style/NameStyle" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@={myName.fullname}" | ||
android:textAlignment="center" /> | ||
|
||
<EditText | ||
android:id="@+id/fullname_edit" | ||
style="@style/NameStyle" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:ems="10" | ||
android:hint="@string/what_is_your_fullname" | ||
android:inputType="textPersonName" | ||
android:textAlignment="center" /> | ||
|
||
<Button | ||
android:id="@+id/done_button" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:layout_marginTop="@dimen/layout_margin" | ||
android:fontFamily="@font/roboto" | ||
android:text="@string/done" /> | ||
|
||
<TextView | ||
android:id="@+id/bio_text" | ||
android:id="@+id/firstname_text" | ||
style="@style/NameStyle" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:lineSpacingMultiplier="1.2" | ||
android:text="@string/bio" /> | ||
</ScrollView> | ||
android:textAlignment="center" | ||
android:text="@={myName.firstname}" | ||
android:visibility="gone" /> | ||
|
||
<ImageView | ||
android:id="@+id/star_image" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:contentDescription="@string/yellow_star" | ||
android:visibility="invisible" | ||
app:srcCompat="@android:drawable/btn_star_big_on" /> | ||
|
||
<ScrollView | ||
android:id="@+id/bio_scroll" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:visibility="invisible"> | ||
|
||
<TextView | ||
android:id="@+id/bio_text" | ||
style="@style/NameStyle" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:lineSpacingMultiplier="1.4" | ||
android:paddingStart="@dimen/padding" | ||
android:paddingEnd="@dimen/padding" | ||
android:text="@={myName.bio}" /> | ||
</ScrollView> | ||
|
||
</LinearLayout> | ||
</LinearLayout> | ||
</layout> |
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
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 |
---|---|---|
@@ -1,20 +1,8 @@ | ||
<resources> | ||
<string name="app_name">AboutMe</string> | ||
<string name="name">Adamou Nchange Kouotou</string> | ||
<string name="name">Fullname</string> | ||
<string name="yellow_star">Yellow star</string> | ||
|
||
<string name="bio"> | ||
Le lorem ipsum est, en imprimerie, une suite de mots sans | ||
signification utilisée à titre provisoire pour calibrer une mise en page. | ||
|
||
\n\n Le texte définitif venant remplacer le faux-texte dès qu\'il | ||
est prêt ou que la mise en page est achevée. Généralement, | ||
on utilise un texte en faux latin, le Lorem ipsum ou Lipsum. | ||
|
||
\n\n Le lorem ipsum est, en imprimerie, une suite de mots sans signification | ||
utilisée à titre provisoire pour calibrer une mise en page, le | ||
texte définitif venant remplacer le faux-texte dès qu\'il est prêt. | ||
\n\n Ou que la mise en page est achevée. Généralement, on utilise | ||
un texte en faux latin, le Lorem ipsum ou Lipsum.\n\n | ||
</string> | ||
<string name="what_is_your_fullname">What is your Fullname?</string> | ||
<string name="done">Submit</string> | ||
</resources> |