Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

DRAFT: #69 cpo picker #80

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Ladefuchs/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "app.ladefuchs.android"
minSdkVersion 28
targetSdkVersion 33
versionCode 207
versionName "2.0.7"
versionCode 210
versionName '2.1.0'

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ data class Operator(
val types: List<String>,
val updated: Long? = null,
val image: String? = null
){
) {
override fun toString(): String = displayName

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is Operator)
return false
if (this.displayName !== other.displayName) return false
if (this.identifier !== other.identifier) return false
if (this.types !== other.types) return false
if (this.updated !== other.updated) return false
if (this.image !== other.image) return false
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ fun retrieveOperatorList(context: Context): List<Operator> {
""
}
} else {
val sharedPreferences = context?.let {
val sharedPreferences = context.let {
PreferenceManager.getDefaultSharedPreferences(
it
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package app.ladefuchs.android.helper

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import app.ladefuchs.android.R
import app.ladefuchs.android.dataClasses.Operator

class BaseViewHolder(container: ViewGroup) : RecyclerView.ViewHolder(container)

class BaseItemCallback : DiffUtil.ItemCallback<Operator>() {
override fun areItemsTheSame(oldItem: Operator, newItem: Operator) = oldItem.toString() == newItem.toString()

override fun areContentsTheSame(oldItem: Operator, newItem: Operator) = oldItem == newItem
}

class OperatorListAdapter(private val dataSet: Array<Operator>) :
RecyclerView.Adapter<OperatorListAdapter.ViewHolder>() {

class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val textViewHeading: TextView
val textViewSubHeading: TextView

init {
// Define click listener for the ViewHolder's View
textViewHeading = view.findViewById(R.id.textViewHeading)
textViewSubHeading = view.findViewById(R.id.textViewSubHeading)
}
}
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
viewHolder.textViewHeading.text = dataSet[position].toString()
viewHolder.textViewHeading.text = dataSet[position].identifier
}

// Create new views (invoked by the layout manager)
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder {
// Create a new view, which defines the UI of the list item
val view = LayoutInflater.from(viewGroup.context)
.inflate(R.layout.cpo_emp_picker_item, viewGroup, false)

return ViewHolder(view)
}

override fun getItemCount() = dataSet.size

}

Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,10 @@ private fun createSingleCell(
return cell
}

fun createAboutPopup(context: Context, view: View) {
fun createSettingsPopup(context: Context, view: View) {
currentDialog?.dismiss()

val popUpView: View = LayoutInflater.from(context).inflate(R.layout.fragment_about, null)
val popUpView: View = LayoutInflater.from(context).inflate(R.layout.fragment_settings, null)
currentDialog = createDialog(popUpView, view)
currentDialog?.show()

Expand All @@ -360,7 +360,7 @@ fun createAboutPopup(context: Context, view: View) {
currentDialog?.dismiss()
}

aboutPopUpSetUp(popUpView)
settingsPopUpSetUp(popUpView)
}

@SuppressLint("SetTextI18n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,20 @@ import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.Resources
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Build
import android.renderscript.Allocation
import android.renderscript.RenderScript
import android.renderscript.ScriptIntrinsicBlur
import android.text.SpannableString
import android.text.TextPaint
import android.text.method.LinkMovementMethod
import android.text.style.URLSpan
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.*
import androidx.appcompat.content.res.AppCompatResources
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.WindowInsetsCompat
import androidx.navigation.NavController
import app.ladefuchs.android.BuildConfig
import app.ladefuchs.android.R
import app.ladefuchs.android.dataClasses.CardMetaData
import app.ladefuchs.android.dataClasses.ChargeCards
import app.ladefuchs.android.dataClasses.ChargeType
import app.ladefuchs.android.dataClasses.Operator
import com.beust.klaxon.Klaxon
import java.io.File
import java.net.URL
import java.text.DecimalFormat
Expand Down Expand Up @@ -160,7 +145,7 @@ private fun TextView.removeLinksUnderline() {


@SuppressLint("SetTextI18n")
fun aboutPopUpSetUp(view: View) {
fun settingsPopUpSetUp(view: View) {

val acknowledgementText = view.findViewById(R.id.acknowledgement_text) as TextView
acknowledgementText.movementMethod = LinkMovementMethod.getInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ class ChargeCardFragment : Fragment() {
nerdGlasses.visibility = VISIBLE
}

val aboutButton = view.findViewById<ImageButton>(R.id.aboutButton)
val settingsButton = view.findViewById<ImageButton>(R.id.settingsButton)

aboutButton.setOnClickListener {
context?.let { createAboutPopup(it, view) }
settingsButton.setOnClickListener {
context?.let { createSettingsPopup(it, view) }
}

// retrieve what shall be shown in the footer
Expand Down
10 changes: 10 additions & 0 deletions Ladefuchs/app/src/main/res/drawable/add_circle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="200dp"
android:viewportWidth="960"
android:viewportHeight="960"
>
<path
android:fillColor="@color/coloraddBtn"
android:pathData="M440,680L520,680L520,520L680,520L680,440L520,440L520,280L440,280L440,440L280,440L280,520L440,520L440,680ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q614,800 707,707Q800,614 800,480Q800,346 707,253Q614,160 480,160Q346,160 253,253Q160,346 160,480Q160,614 253,707Q346,800 480,800ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>
</vector>
10 changes: 10 additions & 0 deletions Ladefuchs/app/src/main/res/drawable/cancel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
>
<path
android:fillColor="@color/colorAccentIntense"
android:pathData="M336,680L480,536L624,680L680,624L536,480L680,336L624,280L480,424L336,280L280,336L424,480L280,624L336,680ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q614,800 707,707Q800,614 800,480Q800,346 707,253Q614,160 480,160Q346,160 253,253Q160,346 160,480Q160,614 253,707Q346,800 480,800ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>
</vector>
1 change: 0 additions & 1 deletion Ladefuchs/app/src/main/res/layout/card_detail_dialog.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/rounded_header_card">
Expand Down
50 changes: 50 additions & 0 deletions Ladefuchs/app/src/main/res/layout/cpo_emp_picker_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/list_item_height"
android:layout_marginLeft="@dimen/margin_medium"
android:layout_marginRight="@dimen/margin_medium"
android:background="@color/TableColorDark"
android:gravity="center_vertical">

<ImageButton
android:id="@+id/settingsButton"
android:layout_width="16dp"
android:layout_height="16dp"
android:background="transparent"
android:contentDescription="@string/settings_button"
android:scaleType="fitCenter"
android:layout_gravity="start|center"
android:src="@drawable/add_circle"
/>
<ImageView
android:id="@+id/cpo_logo"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="18dp"
android:layout_gravity="start|center"
android:src="@drawable/cpo_generic" />
<TextView
android:id="@+id/textViewHeading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/element_text"
android:layout_marginStart="52dp"
android:layout_marginTop="5dp"
android:textSize="10sp"
android:textStyle="bold"
android:textColor="@color/TextColorBlack"
android:layout_gravity="start|top"
/>

<TextView
android:id="@+id/textViewSubHeading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/element_text"
android:layout_marginStart="52dp"
android:layout_marginTop="6dp"
android:textSize="8sp"
android:textColor="@color/TextColorDisabled"
android:layout_gravity="start|center"
/>
</FrameLayout>
2 changes: 1 addition & 1 deletion Ladefuchs/app/src/main/res/layout/fragment_chargecards.xml
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
android:visibility="invisible" />

<ImageButton
android:id="@+id/aboutButton"
android:id="@+id/settingsButton"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="40dp"
Expand Down
60 changes: 60 additions & 0 deletions Ladefuchs/app/src/main/res/layout/fragment_picker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?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"
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/rounded_header_card">

<RelativeLayout
android:id="@+id/picker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryDark"
android:orientation="horizontal"
android:paddingTop="0dp"
app:layout_constraintBottom_toTopOf="@+id/scrollView"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<ImageButton
android:id="@+id/back_button"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignEnd="@+id/pickerHeaderText"
android:layout_gravity="end"
android:layout_marginTop="6dp"
android:layout_marginEnd="-6dp"
android:background="@color/colorPrimaryDark"
android:contentDescription="@string/zurueck"
app:srcCompat="@drawable/ic_baseline_cancel_24" />

<TextView
android:id="@+id/pickerHeaderText"
style="@style/PickerTopHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingBottom="8dp"
android:text="@string/picker" />
</RelativeLayout>


<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/PrimaryBackground"
app:layout_constraintHeight_default="percent"
app:layout_constraintHeight_percent="1.0"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="@+id/picker"
app:layout_constraintTop_toBottomOf="@+id/picker">


</ScrollView>


</androidx.constraintlayout.widget.ConstraintLayout>
Loading