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

@@ -16,6 +16,7 @@ android {
targetSdkVersion 29
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@@ -40,6 +41,8 @@ dependencies {
implementation 'com.journeyapps:zxing-android-embedded:4.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.wear:wear:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

View File

@@ -6,12 +6,16 @@
<uses-sdk tools:overrideLibrary="com.google.zxing.client.android" />
<application
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:hardwareAccelerated="true"
android:theme="@style/AppTheme">
<activity
android:name=".CreateActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:screenOrientation="portrait" />
<activity
android:name=".MainActivity"
android:screenOrientation="portrait">
@@ -21,6 +25,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />

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,22 +25,23 @@ 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()
}
} else {
super.onActivityResult(requestCode, resultCode, data)
}
}
}

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)
}
}
}
}

View File

@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="#fff"
android:pathData="M18,2h-8L4.02,8 4,20c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,4c0,-1.1 -0.9,-2 -2,-2zM12,8h-2L10,4h2v4zM15,8h-2L13,4h2v4zM18,8h-2L16,4h2v4z" />
</vector>

View File

@@ -0,0 +1,10 @@
<!-- drawable/zip_box_outline.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="48dp"
android:width="48dp"
android:viewportWidth="26"
android:viewportHeight="26">
<path
android:fillColor="#fff"
android:pathData="M12 17V15H14V17H12M14 13V11H12V13H14M14 9V7H12V9H14M10 11H12V9H10V11M10 15H12V13H10V15M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H12V7H10V5H5V19H19V5Z" />
</vector>

View File

@@ -0,0 +1,10 @@
<!-- drawable/printer.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#000"
android:pathData="M18,3H6V7H18M19,12A1,1 0 0,1 18,11A1,1 0 0,1 19,10A1,1 0 0,1 20,11A1,1 0 0,1 19,12M16,19H8V14H16M19,8H5A3,3 0 0,0 2,11V17H6V21H18V17H22V11A3,3 0 0,0 19,8Z" />
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 627 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 627 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z"/>
</vector>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TextInput">
<!-- TODO: Update blank fragment layout -->
<TextView
android:id="@+id/head"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/colorPrimaryDark"
android:text="@string/text_input_head_undefined" />
<EditText
android:id="@+id/editTextTextPersonName"
style="@style/Widget.AppCompat.EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:ems="15"
android:inputType="textPersonName"
android:singleLine="true"
android:textFontWeight="600"
android:textSize="30sp"
android:background="@color/colorPrimary"
android:hint="@string/text_input_title_undefined" />
</FrameLayout>

View File

@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
style="@style/AppTheme"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CreateActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryDark"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:title="Create">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/textView4"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="86dp"
android:layout_height="50dp"
android:layout_margin="0dp"
android:backgroundTint="#F8F8F8"
android:padding="0dp"
android:src="@drawable/printer"
android:textColor="@color/colorPrimary"
android:textSize="24sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/back"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="56dp"
android:layout_height="50dp"
android:layout_marginEnd="6dp"
android:src="@drawable/baseline_arrow_forward_white_36"
android:text=""
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/settings"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="56dp"
android:layout_height="50dp"
android:layout_marginEnd="60dp"
android:scaleX="1"
android:scaleY="1"
android:src="@drawable/baseline_settings_white_36"
android:text=""
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/settings2"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="54dp"
android:layout_height="37dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="116dp"
android:src="@drawable/ic_compress"
android:text=""
android:textColor="#000000"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.Toolbar>
<FrameLayout
android:id="@+id/title"
android:name="com.github.mondei1.offpass.TextInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar" />
<FrameLayout
android:id="@+id/username"
android:name="com.github.mondei1.offpass.TextInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="10dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -66,7 +66,7 @@
app:srcCompat="@android:drawable/ic_menu_set_as" />
<Button
android:id="@+id/imageButton2"
android:id="@+id/add_button"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_height="120dp"
android:layout_weight="1"
@@ -90,12 +90,13 @@
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp"
android:fontFamily="@font/righteous"
android:text="ALPHA"
android:textColor="@color/colorPrimary"
android:textSize="36sp"
app:layout_constraintBottom_toBottomOf="parent"
tools:layout_editor_absoluteX="291dp" />
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorPrimaryDark"
app:title="Create">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/back"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="47dp"
android:layout_height="50dp"
android:layout_marginEnd="6dp"
android:drawableTop="@drawable/baseline_arrow_forward_white_36"
android:text=""
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/settings"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="56dp"
android:layout_height="50dp"
android:layout_marginEnd="52dp"
android:drawableTop="@drawable/baseline_settings_white_36"
android:scaleX="1"
android:scaleY="1"
android:text=""
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/settings2"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="56dp"
android:layout_height="50dp"
android:layout_marginEnd="108dp"
android:drawableTop="@drawable/baseline_sd_storage_24"
android:scaleX="1"
android:scaleY="1"
android:text=""
android:textColor="#000000"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Create"
android:textColor="@color/colorPrimary"
android:textSize="24sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.Toolbar>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TextInput">
<TextView
android:id="@+id/head"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/text_input_head_undefined"
android:textAllCaps="false"
android:textColor="@color/colorPrimaryDark"
android:textSize="20sp" />
<EditText
android:id="@+id/title"
style="@style/Widget.AppCompat.EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:ems="15"
android:inputType="textPersonName"
android:singleLine="true"
android:textStyle="bold"
android:textSize="30sp"
android:hint="@string/text_input_title_undefined" />
</FrameLayout>

View File

@@ -0,0 +1,3 @@
<resources>
<string name="hello_world">Hello Round World!</string>
</resources>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
Because the window insets on round devices are larger than 15dp, this padding only applies
to square screens.
-->
<dimen name="box_inset_layout_padding">0dp</dimen>
<!--
This padding applies to both square and round screens. The total padding between the buttons
and the window insets is box_inset_layout_padding (above variable) on square screens and
inner_frame_layout_padding (below variable) on round screens.
-->
<dimen name="inner_frame_layout_padding">5dp</dimen>
</resources>

View File

@@ -1,3 +1,11 @@
<resources>
<string name="app_name">OffPass</string>
<string name="title_activity_create">CreateActivity</string>
<!--
This string is used for square devices and overridden by hello_world in
values-round/strings.xml for round devices.
-->
<string name="text_input_head_undefined">HEAD UNDEFINED</string>
<string name="text_input_title_undefined">TITLE UNDEFINED</string>
</resources>

View File

@@ -1,10 +1,17 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:actionBarStyle">@style/OffPassActionbar</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">#fff</item>
<item name="android:statusBarColor">@color/colorPrimaryDark</item>
</style>
<style name="OffPassActionbar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="background">@color/colorPrimaryDark</item>
<item name="android:foreground">@color/colorPrimary</item>
</style>
</resources>

View File

@@ -2,3 +2,4 @@ Credits
===================================
Icons made by photo3idea_studio (https://www.flaticon.com/de/autoren/photo3idea-studio) from www.flaticon.com
Icons made by xnimrodx (https://www.flaticon.com/de/autoren/xnimrodx) from www.flaticon.com
Icons made by Michael Irigoyen (http://twitter.com/mririgo)