Skip to content

Commit

Permalink
It now works on the command line, and I've taken further steps toward…
Browse files Browse the repository at this point in the history
… a stable Android app.
  • Loading branch information
Romulus10 committed Oct 5, 2018
1 parent 67b714b commit 058a347
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 211 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import android.os.AsyncTask
import android.os.Build
import android.os.Bundle
import android.provider.ContactsContract
import android.text.TextUtils
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.ArrayAdapter
Expand Down Expand Up @@ -132,11 +131,6 @@ class LoginActivity : AppCompatActivity(), LoaderCallbacks<Cursor> {
return email.contains("@")
}

private fun isPasswordValid(password: String): Boolean {
//TODO: Replace this with your own logic
return password.length > 4
}

/**
* Shows the progress UI and hides the login form.
*/
Expand Down Expand Up @@ -237,14 +231,7 @@ class LoginActivity : AppCompatActivity(), LoaderCallbacks<Cursor> {
return false
}

return DUMMY_CREDENTIALS
.map { it.split(":") }
.firstOrNull { it[0] == mEmail }
?.let {
// Account exists, return true if the password matches.
it[1] == mPassword
}
?: true
return true
}

override fun onPostExecute(success: Boolean?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,16 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)

fab.setOnClickListener { view ->
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
fab.setOnClickListener { _ ->
Log.d("MainActivity", "New Message")
val fragmentManager = supportFragmentManager
val fragmentTransaction = fragmentManager.beginTransaction()
val fragment = NewMessage()
val b = Bundle()
fragment.arguments = b
fragmentTransaction.replace(R.id.fragment_container, fragment)
.addToBackStack("New Message").commit()
title = "New Message"
}

val toggle = ActionBarDrawerToggle(
Expand All @@ -66,6 +73,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
fragment.arguments = b
fragmentTransaction.replace(R.id.fragment_container, fragment)
.addToBackStack("Messages").commit()
title = "Messages"
}

override fun onBackPressed() {
Expand Down Expand Up @@ -104,6 +112,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
fragment.arguments = b
fragmentTransaction.replace(R.id.fragment_container, fragment)
.addToBackStack("Messages").commit()
title = "Messages"
}
R.id.nav_contacts -> {
Log.d("MainActivity", "Contacts")
Expand All @@ -114,6 +123,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
fragment.arguments = b
fragmentTransaction.replace(R.id.fragment_container, fragment)
.addToBackStack("Contacts").commit()
title = "Contacts"
}
R.id.nav_keys -> {
Log.d("MainActivity", "Keys")
Expand All @@ -124,6 +134,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
fragment.arguments = b
fragmentTransaction.replace(R.id.fragment_container, fragment)
.addToBackStack("Keys").commit()
title = "Keys"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MyContactRecyclerViewAdapter(
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val item = mValues[position]
holder.mIdView.text = item.id
holder.mContentView.text = item.content
holder.mContentView.text = item.uname

with(holder.mView) {
tag = item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MyListKeysRecyclerViewAdapter(
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val item = mValues[position]
holder.mIdView.text = item.id
holder.mContentView.text = item.content
holder.mContentView.text = item.user.uname

with(holder.mView) {
tag = item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ import io.github.romulus10.blckchnmsg.blckchnmsg.data.Message

import kotlinx.android.synthetic.main.fragment_message.view.*

/**
* [RecyclerView.Adapter] that can display a [Message] and makes a call to the
* specified [OnListFragmentInteractionListener].
* TODO: Replace the implementation with code for your data type.
*/
class MyMessageRecyclerViewAdapter(
private val mValues: MutableList<Message.Message>,
private val mListener: OnListFragmentInteractionListener?)
Expand All @@ -27,8 +22,6 @@ class MyMessageRecyclerViewAdapter(
init {
mOnClickListener = View.OnClickListener { v ->
val item = v.tag as Message.Message
// Notify the active callbacks interface (the activity, if the fragment is attached to
// one) that an item has been selected.
mListener?.onListFragmentInteraction(item)
}
}
Expand All @@ -41,8 +34,8 @@ class MyMessageRecyclerViewAdapter(

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val item = mValues[position]
holder.mIdView.text = item.id
holder.mContentView.text = item.content
holder.mIdView.text = item.from.uname
holder.mContentView.text = item.message

with(holder.mView) {
tag = item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,11 @@ class NewContact : Fragment() {
listener = null
}

/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
*
*
* See the Android Training lesson [Communicating with Other Fragments]
* (http://developer.android.com/training/basics/fragments/communicating.html)
* for more information.
*/
interface OnFragmentInteractionListener {
// TODO: Update argument type and name
fun onFragmentInteraction(uri: Uri)
}

companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment NewContact.
*/
// TODO: Rename and change types and number of parameters
@JvmStatic
fun newInstance(param1: String, param2: String) =
NewContact().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ object Key {
ITEM_MAP[item.id] = item
}

private fun createKey(id: String, user: Contact, key: String): Key {
private fun createKey(id: String, user: Contact.Contact, key: String): Key {
return Key(id, user, key)
}

data class Key(val id: String, val user: Contact, val key: String) {
data class Key(val id: String, val user: Contact.Contact, val key: String) {
override fun toString(): String = id
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ object Message {
ITEM_MAP[item.id] = item
}

private fun createMessage(id: String, to: Contact, from: Contact, message: String, signature: String): Message {
return Message(id, to, from, message, signature)
private fun createMessage(id: String, to: Contact.Contact, from: Contact.Contact, message: String, signature: String): Message {
return Message(id, to, from, message, signature, false)
}

data class Message(val id: String, val to: Contact, val from: Contact, val message: String, val signature: String) {
data class Message(val id: String, val to: Contact.Contact, val from: Contact.Contact, val message: String, val signature: String, val verified: Boolean) {
override fun toString(): String = message
}
}
14 changes: 0 additions & 14 deletions BlckchnMsg/app/src/main/res/layout/fragment_add_contact.xml

This file was deleted.

7 changes: 4 additions & 3 deletions BlckchnMsg/app/src/main/res/layout/fragment_new_contact.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
tools:context=".NewContact">

<!-- TODO: Update blank fragment layout -->
<TextView
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
android:layout_height="wrap_content"
android:text="@string/hello_blank_fragment"
android:inputType="text" />

</FrameLayout>
4 changes: 2 additions & 2 deletions BlckchnMsg/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<string name="title_activity_main">MainActivity</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="nav_header_title">Android Studio</string>
<string name="nav_header_subtitle">android.studio@android.com</string>
<string name="nav_header_title">Romulus10</string>
<string name="nav_header_subtitle">romulus108@protonmail.com</string>
<string name="nav_header_desc">Navigation header</string>
<string name="action_settings">Settings</string>

Expand Down
3 changes: 2 additions & 1 deletion blckchnmsg
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

source ./venv/bin/activate
export PYTHONPATH="./blockchain_message/src"
pushd ./client
python -m cli
python3 -m cli
popd
deactivate
2 changes: 1 addition & 1 deletion install
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ pip install urllib3
pip install web3
pip install websockets

deactivates
deactivate
Loading

0 comments on commit 058a347

Please sign in to comment.