forked from hush/SilentDragonAndroid-old
![nickas.gehlen@gmail.com](/assets/img/avatar_default.png)
19 changed files with 413 additions and 231 deletions
@ -1,26 +1,67 @@ |
|||
package org.myhush.silentdragon.chat |
|||
|
|||
import android.content.Intent |
|||
import android.os.Bundle |
|||
import android.support.design.widget.BottomNavigationView |
|||
import android.support.v4.app.FragmentTransaction |
|||
import android.support.v7.app.AppCompatActivity |
|||
import kotlinx.android.synthetic.main.activity_chat.* |
|||
import org.myhush.silentdragon.MainActivity |
|||
import org.myhush.silentdragon.R |
|||
import org.myhush.silentdragon.ReceiveActivity |
|||
import org.myhush.silentdragon.SendActivity |
|||
|
|||
class ChatActivity : AppCompatActivity() { |
|||
|
|||
override fun onCreate(savedInstanceState: Bundle?) { |
|||
super.onCreate(savedInstanceState) |
|||
setContentView(R.layout.activity_chat) |
|||
val navView: BottomNavigationView = findViewById(R.id.nav_view) |
|||
|
|||
/*val navController = findNavController(R.id.nav) |
|||
// Passing each menu ID as a set of Ids because each |
|||
// menu should be considered as top level destinations. |
|||
val appBarConfiguration = AppBarConfiguration( |
|||
setOf( |
|||
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications |
|||
) |
|||
) |
|||
setupActionBarWithNavController(navController, appBarConfiguration) |
|||
navView.setupWithNavController(navController)*/ |
|||
|
|||
initListener() |
|||
restoreSoonChats() |
|||
//TODO: restoreSoonChats() |
|||
//TODO: restoreSoonChats() |
|||
} |
|||
|
|||
private fun restoreSoonChats() { |
|||
addChat("Nil", "Armstrong") |
|||
addChat("Peter", "Parker") |
|||
addChat("Mark", "Zuckerberg") |
|||
} |
|||
|
|||
private fun initListener(){ |
|||
nav_view.setOnNavigationItemSelectedListener { |
|||
when(it.itemId) { |
|||
R.id.action_send -> { |
|||
val intent = Intent(this, SendActivity::class.java) |
|||
startActivity(intent) |
|||
return@setOnNavigationItemSelectedListener true |
|||
} |
|||
R.id.action_bal -> { |
|||
val intent = Intent(this, MainActivity::class.java) |
|||
startActivity(intent) |
|||
return@setOnNavigationItemSelectedListener true |
|||
} |
|||
R.id.action_chat -> true |
|||
R.id.action_recieve -> { |
|||
val intent = Intent(this, ReceiveActivity::class.java) |
|||
startActivity(intent) |
|||
return@setOnNavigationItemSelectedListener true |
|||
} |
|||
else -> { |
|||
return@setOnNavigationItemSelectedListener false |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
fun addChat(firstName: String, lastName: String){ |
|||
val fragment = ChatItemFragment() |
|||
val fragTx: FragmentTransaction = supportFragmentManager.beginTransaction() |
|||
|
|||
fragment.firstName = firstName |
|||
fragment.lastName = lastName |
|||
|
|||
fragTx.add(R.id.ChatTable, fragment) |
|||
fragTx.commit() |
|||
} |
|||
} |
|||
|
@ -0,0 +1,40 @@ |
|||
package org.myhush.silentdragon.chat |
|||
|
|||
import android.content.Intent |
|||
import android.os.Bundle |
|||
import android.support.v4.app.Fragment |
|||
import android.view.LayoutInflater |
|||
import android.view.View |
|||
import android.view.ViewGroup |
|||
import android.widget.TextView |
|||
import org.myhush.silentdragon.R |
|||
|
|||
class ChatItemFragment : Fragment() { |
|||
var firstName: String = "" |
|||
var lastName: String = "" |
|||
var lastMessage: String = "No messages..." |
|||
var v: View? = null |
|||
|
|||
override fun onCreateView (inflater: LayoutInflater, container: ViewGroup?, |
|||
savedInstanceState: Bundle?): View { |
|||
v = inflater.inflate(R.layout.fragment_chat_item, container, false) |
|||
|
|||
updateData() |
|||
initListener() |
|||
return v!! |
|||
} |
|||
|
|||
private fun initListener() { |
|||
v?.setOnClickListener { |
|||
val intent = Intent(activity, ConversationActivity::class.java) |
|||
startActivity(intent) |
|||
} |
|||
} |
|||
|
|||
fun updateData(){ |
|||
v!!.findViewById<TextView>(R.id.textViewContactName).text = "$firstName $lastName" |
|||
v!!.findViewById<TextView>(R.id.textViewLastMessage).text = lastMessage |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,45 @@ |
|||
package org.myhush.silentdragon.chat |
|||
|
|||
import android.support.v7.app.AppCompatActivity |
|||
import android.os.Bundle |
|||
import android.support.v4.app.FragmentTransaction |
|||
import android.widget.TextView |
|||
import org.myhush.silentdragon.R |
|||
import org.myhush.silentdragon.conversation_item_recive |
|||
import org.myhush.silentdragon.conversation_item_send |
|||
|
|||
class ConversationActivity : AppCompatActivity() { |
|||
var displayName = "Peter Parker" |
|||
var messages = HashMap<Boolean, String>() |
|||
|
|||
override fun onCreate(savedInstanceState: Bundle?) { |
|||
super.onCreate(savedInstanceState) |
|||
setContentView(R.layout.activity_conversation) |
|||
findViewById<TextView>(R.id.textViewContactName2) |
|||
|
|||
//restoreChat() |
|||
} |
|||
|
|||
private fun restoreChat(){ |
|||
addMessage("Lorem Ipsum", true) |
|||
addMessage("Lorem Ipsum", true) |
|||
addMessage("Lorem Ipsum", true) |
|||
addMessage("Lorem Ipsum", true) |
|||
} |
|||
|
|||
|
|||
|
|||
fun addMessage(message: String, recived: Boolean){ |
|||
val fragTx: FragmentTransaction = supportFragmentManager.beginTransaction() |
|||
|
|||
if(recived){ |
|||
val fragment = conversation_item_recive() |
|||
fragTx.add(R.id.MessageList, fragment) |
|||
|
|||
}else{ |
|||
val fragment = conversation_item_send() |
|||
fragTx.add(R.id.MessageList, fragment) |
|||
} |
|||
fragTx.commit() |
|||
} |
|||
} |
@ -0,0 +1,17 @@ |
|||
package org.myhush.silentdragon |
|||
|
|||
import android.os.Bundle |
|||
import android.support.v4.app.Fragment |
|||
import android.view.LayoutInflater |
|||
import android.view.View |
|||
import android.view.ViewGroup |
|||
|
|||
class conversation_item_recive : Fragment() { |
|||
|
|||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, |
|||
savedInstanceState: Bundle?): View? { |
|||
// Inflate the layout for this fragment |
|||
var v: View = inflater.inflate(R.layout.fragment_conversation_item_recive, container, false) |
|||
return v |
|||
} |
|||
} |
@ -0,0 +1,17 @@ |
|||
package org.myhush.silentdragon |
|||
|
|||
import android.os.Bundle |
|||
import android.support.v4.app.Fragment |
|||
import android.view.LayoutInflater |
|||
import android.view.View |
|||
import android.view.ViewGroup |
|||
|
|||
class conversation_item_send : Fragment() { |
|||
|
|||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, |
|||
savedInstanceState: Bundle?): View? { |
|||
// Inflate the layout for this fragment |
|||
var v: View = inflater.inflate(R.layout.fragment_conversation_item_send, container, false) |
|||
return v |
|||
} |
|||
} |
@ -0,0 +1,10 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:shape="rectangle" android:padding="10dp"> |
|||
<solid android:color="@color/message_recive"/> |
|||
<corners |
|||
android:bottomRightRadius="15dp" |
|||
android:bottomLeftRadius="15dp" |
|||
android:topLeftRadius="15dp" |
|||
android:topRightRadius="15dp"/> |
|||
</shape> |
@ -0,0 +1,10 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:shape="rectangle" android:padding="10dp"> |
|||
<solid android:color="@color/message_send"/> |
|||
<corners |
|||
android:bottomRightRadius="15dp" |
|||
android:bottomLeftRadius="15dp" |
|||
android:topLeftRadius="15dp" |
|||
android:topRightRadius="15dp"/> |
|||
</shape> |
@ -0,0 +1,108 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:app="http://schemas.android.com/apk/res-auto" |
|||
xmlns:tools="http://schemas.android.com/tools" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
tools:context=".conversation_item_recive" > |
|||
|
|||
<android.support.constraint.ConstraintLayout |
|||
android:id="@+id/constraintLayout4" |
|||
android:layout_width="0dp" |
|||
android:layout_height="76dp" |
|||
android:background="#2d2d2d" |
|||
app:layout_constraintEnd_toEndOf="parent" |
|||
app:layout_constraintStart_toStartOf="parent" |
|||
app:layout_constraintTop_toTopOf="parent"> |
|||
|
|||
<TextView |
|||
android:id="@+id/textViewContactName2" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginStart="18dp" |
|||
android:text="Peter Parker" |
|||
android:textColor="#ffffff" |
|||
android:textSize="20sp" |
|||
android:textStyle="bold" |
|||
app:layout_constraintBottom_toBottomOf="parent" |
|||
app:layout_constraintStart_toEndOf="@+id/imageProfilePicture2" |
|||
app:layout_constraintTop_toTopOf="parent" /> |
|||
|
|||
<ImageView |
|||
android:id="@+id/imageProfilePicture2" |
|||
android:layout_width="56dp" |
|||
android:layout_height="56dp" |
|||
android:layout_marginStart="16dp" |
|||
android:background="@drawable/profile_image" |
|||
android:visibility="visible" |
|||
app:layout_constraintBottom_toBottomOf="parent" |
|||
app:layout_constraintStart_toStartOf="parent" |
|||
app:layout_constraintTop_toTopOf="parent" |
|||
tools:visibility="visible" /> |
|||
</android.support.constraint.ConstraintLayout> |
|||
|
|||
<ScrollView |
|||
android:layout_width="0dp" |
|||
android:layout_height="0dp" |
|||
android:layout_marginBottom="10dp" |
|||
app:layout_constraintBottom_toTopOf="@+id/constraintLayout3" |
|||
app:layout_constraintEnd_toEndOf="parent" |
|||
app:layout_constraintStart_toStartOf="parent" |
|||
app:layout_constraintTop_toBottomOf="@+id/constraintLayout4"> |
|||
|
|||
<LinearLayout |
|||
android:id="@+id/MessageList" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:orientation="vertical"> |
|||
|
|||
<fragment |
|||
android:id="@+id/fragment2" |
|||
android:name="org.myhush.silentdragon.conversation_item_send" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
tools:layout="@layout/fragment_conversation_item_send" /> |
|||
|
|||
<fragment |
|||
android:id="@+id/fragment" |
|||
android:name="org.myhush.silentdragon.conversation_item_recive" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
tools:layout="@layout/fragment_conversation_item_recive" /> |
|||
</LinearLayout> |
|||
</ScrollView> |
|||
|
|||
<android.support.constraint.ConstraintLayout |
|||
android:id="@+id/constraintLayout3" |
|||
android:layout_width="0dp" |
|||
android:layout_height="50dp" |
|||
android:background="@drawable/rounded_corner" |
|||
app:layout_constraintBottom_toBottomOf="parent" |
|||
app:layout_constraintEnd_toEndOf="parent" |
|||
app:layout_constraintStart_toStartOf="parent"> |
|||
|
|||
<ImageButton |
|||
android:id="@+id/buttonSend" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="0dp" |
|||
android:layout_marginEnd="5dp" |
|||
android:src="@drawable/send_selector" |
|||
app:layout_constraintBottom_toBottomOf="parent" |
|||
app:layout_constraintEnd_toEndOf="parent" |
|||
app:layout_constraintTop_toTopOf="parent" /> |
|||
|
|||
<EditText |
|||
android:id="@+id/UserInput" |
|||
android:layout_width="0dp" |
|||
android:layout_height="0dp" |
|||
android:layout_marginStart="10dp" |
|||
android:ems="10" |
|||
android:inputType="textPersonName" |
|||
android:text="Send a message...." |
|||
app:layout_constraintBottom_toBottomOf="parent" |
|||
app:layout_constraintEnd_toStartOf="@+id/buttonSend" |
|||
app:layout_constraintStart_toStartOf="parent" |
|||
app:layout_constraintTop_toTopOf="parent" /> |
|||
</android.support.constraint.ConstraintLayout> |
|||
|
|||
</android.support.constraint.ConstraintLayout> |
@ -0,0 +1,20 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:app="http://schemas.android.com/apk/res-auto" |
|||
xmlns:tools="http://schemas.android.com/tools" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
tools:context=".conversation_item_send" > |
|||
|
|||
<TextView |
|||
android:id="@+id/message" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginTop="2dp" |
|||
android:background="@drawable/chat_background_recive" |
|||
android:maxWidth="260sp" |
|||
android:padding="10sp" |
|||
android:text="Lorem ipsum dolor sit amet, consetetur sadipscing elitr" |
|||
app:layout_constraintStart_toStartOf="parent" |
|||
app:layout_constraintTop_toTopOf="parent" /> |
|||
</android.support.constraint.ConstraintLayout> |
@ -0,0 +1,21 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:app="http://schemas.android.com/apk/res-auto" |
|||
xmlns:tools="http://schemas.android.com/tools" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
tools:context=".conversation_item_send" > |
|||
|
|||
<TextView |
|||
android:id="@+id/message" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginTop="2dp" |
|||
android:layout_marginEnd="9dp" |
|||
android:background="@drawable/chat_background_send" |
|||
android:maxWidth="260sp" |
|||
android:padding="10sp" |
|||
android:text="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." |
|||
app:layout_constraintEnd_toEndOf="parent" |
|||
app:layout_constraintTop_toTopOf="parent" /> |
|||
</android.support.constraint.ConstraintLayout> |
@ -1,30 +1,28 @@ |
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:app="http://schemas.android.com/apk/res-auto" |
|||
xmlns:tools="http://schemas.android.com/tools" |
|||
tools:context="org.myhush.silentdragon.MainActivity"> |
|||
|
|||
<item android:id="@+id/action_send" |
|||
android:title="Send" |
|||
android:orderInCategory="300" |
|||
android:iconTint="@color/white_unselected" |
|||
app:showAsAction="never" |
|||
android:icon="@drawable/send_selector"/> |
|||
<item android:title="Send" |
|||
android:id="@+id/action_send" |
|||
android:icon="@drawable/send_selector" |
|||
android:tint="@color/white_unselected" |
|||
android:orderInCategory="300"/> |
|||
|
|||
<item android:title="Balance" |
|||
android:id="@+id/action_bal" |
|||
android:icon="@drawable/balance_selector" |
|||
android:iconTint="@color/white_unselected" |
|||
android:tint="@color/white_unselected" |
|||
android:orderInCategory="200"/> |
|||
|
|||
<item android:title="Receive" |
|||
android:id="@+id/action_recieve" |
|||
android:icon="@drawable/receive_selector" |
|||
android:iconTint="@color/white_unselected" |
|||
android:tint="@color/white_unselected" |
|||
android:orderInCategory="100"/> |
|||
|
|||
<item android:title="Chat" |
|||
android:id="@+id/action_chat" |
|||
android:icon="@drawable/ic_keyboard_icon" |
|||
android:iconTint="@color/white_unselected" |
|||
android:tint="@color/white_unselected" |
|||
android:orderInCategory="100"/> |
|||
</menu> |
|||
|
Loading…
Reference in new issue