Basic create activity implemented

This commit is contained in:
2020-06-26 18:35:14 +02:00
parent 099d4df53d
commit 1d020c5110
59 changed files with 418 additions and 14 deletions

View File

@@ -0,0 +1,31 @@
package com.github.mondei1.offpass
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_create.*
class CreateActivity : AppCompatActivity() {
private var fragment_title: TextInput? = null
private var fragment_username: TextInput? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
fragment_title = TextInput.newInstance("Title", "ENTER TITLE", "30dp")
fragment_username = TextInput.newInstance("Username", "ENTER USERNAME", "30dp")
supportFragmentManager.beginTransaction()
.replace(R.id.title, fragment_title!!)
.replace(R.id.username, fragment_username!!)
.commit()
setSupportActionBar(findViewById(R.id.toolbar))
setContentView(R.layout.activity_create)
back.setOnClickListener {
Log.i("CREATE", "Back got clicked!")
finish()
}
}
}

View File

@@ -25,21 +25,22 @@ class MainActivity : AppCompatActivity() {
.initiateScan()
Log.i("Main", "Clicked on text")
}
add_button.setOnClickListener {
val intent: Intent = Intent(this, CreateActivity::class.java)
startActivity(intent)
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
var result: IntentResult =
IntentIntegrator.parseActivityResult(requestCode, resultCode, data)
if (result != null) {
if (result.contents == null) {
Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show()
} else {
Log.i("SCANNER", "Scanned: " + result.contents)
Toast.makeText(this, "Scanned: " + result.contents, Toast.LENGTH_LONG).show()
}
if (result.contents == null) {
Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show()
} else {
super.onActivityResult(requestCode, resultCode, data)
Log.i("SCANNER", "Scanned: " + result.contents)
Toast.makeText(this, "Scanned: " + result.contents, Toast.LENGTH_LONG).show()
}
}

View File

@@ -0,0 +1,67 @@
package com.github.mondei1.offpass
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.fragment_text_input.*
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_HEAD = "param1"
private const val ARG_TITLE = "param2"
private const val ARG_TITLE_SIZE = "param3"
/**
* A simple [Fragment] subclass.
* Use the [TextInput.newInstance] factory method to
* create an instance of this fragment.
*/
class TextInput : Fragment() {
// TODO: Rename and change types of parameters
private var arg_head: String? = null
private var arg_title: String? = null
private var arg_title_size: String? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
arg_title = it.getString(ARG_TITLE)
arg_head = it.getString(ARG_HEAD)
arg_title_size = it.getString(ARG_TITLE_SIZE)
}
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_text_input, container, false)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
head.text = arg_head
title.background = null
title.hint = arg_title
}
companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*/
// TODO: Rename and change types and number of parameters
@JvmStatic
fun newInstance(head: String, title: String, title_size: String) =
TextInput().apply {
arguments = Bundle().apply {
putString(ARG_HEAD, head)
putString(ARG_TITLE, title)
putString(ARG_TITLE_SIZE, title_size)
}
}
}
}