release 0.5.0 #35
@ -35,6 +35,19 @@ android {
 | 
				
			|||||||
        sourceCompatibility JavaVersion.VERSION_1_8
 | 
					        sourceCompatibility JavaVersion.VERSION_1_8
 | 
				
			||||||
        targetCompatibility JavaVersion.VERSION_1_8
 | 
					        targetCompatibility JavaVersion.VERSION_1_8
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    sourceSets {
 | 
				
			||||||
 | 
					        main {
 | 
				
			||||||
 | 
					            res.srcDirs =
 | 
				
			||||||
 | 
					                    [
 | 
				
			||||||
 | 
					                            'src/main/res/layouts/activities',
 | 
				
			||||||
 | 
					                            'src/main/res/layouts/dialogs',
 | 
				
			||||||
 | 
					                            'src/main/res/layouts/fragments',
 | 
				
			||||||
 | 
					                            'src/main/res/layouts',
 | 
				
			||||||
 | 
					                            'src/main/res'
 | 
				
			||||||
 | 
					                    ]
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dependencies {
 | 
					dependencies {
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,6 @@ package com.codebutler.farebot.card.desfire
 | 
				
			|||||||
 * Created by Jakob Wenzel on 16.11.13.
 | 
					 * Created by Jakob Wenzel on 16.11.13.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
class DesfireException : Exception {
 | 
					class DesfireException : Exception {
 | 
				
			||||||
    constructor(message: String) : super(message) {}
 | 
					    constructor(message: String) : super(message)
 | 
				
			||||||
    constructor(cause: Throwable) : super(cause) {}
 | 
					    constructor(cause: Throwable) : super(cause)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -27,16 +27,20 @@ import android.content.Intent
 | 
				
			|||||||
import android.nfc.NfcAdapter
 | 
					import android.nfc.NfcAdapter
 | 
				
			||||||
import android.nfc.Tag
 | 
					import android.nfc.Tag
 | 
				
			||||||
import android.nfc.tech.IsoDep
 | 
					import android.nfc.tech.IsoDep
 | 
				
			||||||
 | 
					import android.util.Log
 | 
				
			||||||
import com.afollestad.materialdialogs.MaterialDialog
 | 
					import com.afollestad.materialdialogs.MaterialDialog
 | 
				
			||||||
 | 
					import com.afollestad.materialdialogs.customview.customView
 | 
				
			||||||
import com.codebutler.farebot.Utils
 | 
					import com.codebutler.farebot.Utils
 | 
				
			||||||
import com.codebutler.farebot.card.desfire.DesfireFileSettings
 | 
					import com.codebutler.farebot.card.desfire.DesfireFileSettings
 | 
				
			||||||
import com.codebutler.farebot.card.desfire.DesfireProtocol
 | 
					import com.codebutler.farebot.card.desfire.DesfireProtocol
 | 
				
			||||||
 | 
					import kotlinx.android.synthetic.main.dialog_mensa_credit.*
 | 
				
			||||||
import org.mosad.seil0.projectlaogai.R
 | 
					import org.mosad.seil0.projectlaogai.R
 | 
				
			||||||
import java.lang.Exception
 | 
					import java.lang.Exception
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class NFCMensaCard {
 | 
					class NFCMensaCard {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    companion object {
 | 
					    companion object {
 | 
				
			||||||
 | 
					        private const val className = "NFCMensaCard"
 | 
				
			||||||
        private const val appId = 0x5F8415
 | 
					        private const val appId = 0x5F8415
 | 
				
			||||||
        private const val fileId = 1
 | 
					        private const val fileId = 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -48,6 +52,7 @@ class NFCMensaCard {
 | 
				
			|||||||
        fun readBalance(intent: Intent, context: Context) {
 | 
					        fun readBalance(intent: Intent, context: Context) {
 | 
				
			||||||
            val tag: Tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG)
 | 
					            val tag: Tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG)
 | 
				
			||||||
            val isoDep = IsoDep.get(tag)
 | 
					            val isoDep = IsoDep.get(tag)
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
                isoDep.connect()
 | 
					                isoDep.connect()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                val card = DesfireProtocol(isoDep)
 | 
					                val card = DesfireProtocol(isoDep)
 | 
				
			||||||
@ -58,11 +63,12 @@ class NFCMensaCard {
 | 
				
			|||||||
                        card.readValue(fileId)
 | 
					                        card.readValue(fileId)
 | 
				
			||||||
                    } catch (ex: Exception) { 0 }
 | 
					                    } catch (ex: Exception) { 0 }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                MaterialDialog(context)
 | 
					                    lookAtMe(context, data, settings.value).show()
 | 
				
			||||||
                    .title(R.string.mensa_credit)
 | 
					 | 
				
			||||||
                    .message(text = lookAtMe(context, data, settings.value))
 | 
					 | 
				
			||||||
                    .show()
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					            } catch (ex: Exception) {
 | 
				
			||||||
 | 
					                Log.i(className,"could not connect to tag", ex)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /**
 | 
					        /**
 | 
				
			||||||
@ -74,7 +80,10 @@ class NFCMensaCard {
 | 
				
			|||||||
         * @param lastRaw the raw card value of the last payment
 | 
					         * @param lastRaw the raw card value of the last payment
 | 
				
			||||||
         * @return the message containing all values
 | 
					         * @return the message containing all values
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        private fun lookAtMe(context: Context, currentRaw: Int, lastRaw: Int): String {
 | 
					        private fun lookAtMe(context: Context, currentRaw: Int, lastRaw: Int): MaterialDialog {
 | 
				
			||||||
 | 
					            val dialog = MaterialDialog(context)
 | 
				
			||||||
 | 
					                .customView(R.layout.dialog_mensa_credit)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            val current = if (!PreferencesController.oGiants) {
 | 
					            val current = if (!PreferencesController.oGiants) {
 | 
				
			||||||
                String.format("%.2f €", (currentRaw.toFloat() / 1000))
 | 
					                String.format("%.2f €", (currentRaw.toFloat() / 1000))
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
@ -87,7 +96,10 @@ class NFCMensaCard {
 | 
				
			|||||||
                String.format("%.4f shm", (lastRaw.toFloat() * 0.0000075))
 | 
					                String.format("%.4f shm", (lastRaw.toFloat() * 0.0000075))
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return context.resources.getString(R.string.mensa_current, current) + context.resources.getString(R.string.mensa_last, last)
 | 
					            dialog.txtView_current.text = current
 | 
				
			||||||
 | 
					            dialog.txtView_last.text = context.resources.getString(R.string.mensa_last, last)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return dialog
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -24,6 +24,7 @@ package org.mosad.seil0.projectlaogai.fragments
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import android.graphics.Typeface
 | 
					import android.graphics.Typeface
 | 
				
			||||||
import android.os.Bundle
 | 
					import android.os.Bundle
 | 
				
			||||||
 | 
					import android.util.Log
 | 
				
			||||||
import android.view.LayoutInflater
 | 
					import android.view.LayoutInflater
 | 
				
			||||||
import android.view.View
 | 
					import android.view.View
 | 
				
			||||||
import android.view.ViewGroup
 | 
					import android.view.ViewGroup
 | 
				
			||||||
@ -52,6 +53,7 @@ import java.util.*
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class HomeFragment : Fragment() {
 | 
					class HomeFragment : Fragment() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private val className = "MyActivity"
 | 
				
			||||||
    private val formatter = SimpleDateFormat("E dd.MM", Locale.getDefault())
 | 
					    private val formatter = SimpleDateFormat("E dd.MM", Locale.getDefault())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
 | 
					    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
 | 
				
			||||||
@ -146,7 +148,7 @@ class HomeFragment : Fragment() {
 | 
				
			|||||||
                        .title(R.string.error)
 | 
					                        .title(R.string.error)
 | 
				
			||||||
                        .message(R.string.timetable_error)
 | 
					                        .message(R.string.timetable_error)
 | 
				
			||||||
                        .show()
 | 
					                        .show()
 | 
				
			||||||
                    // TODO log the error and send feedback
 | 
					                    Log.e(className, "could not load timetable") // TODO send feedback
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,34 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 | 
				
			||||||
 | 
					        android:id="@+id/linLayout_mensacredit"
 | 
				
			||||||
 | 
					        android:layout_width="wrap_content"
 | 
				
			||||||
 | 
					        android:layout_height="match_parent"
 | 
				
			||||||
 | 
					        android:orientation="vertical">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <TextView
 | 
				
			||||||
 | 
					            android:id="@+id/txtView_Heading"
 | 
				
			||||||
 | 
					            android:layout_width="match_parent"
 | 
				
			||||||
 | 
					            android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					            android:text="@string/mensa_credit"
 | 
				
			||||||
 | 
					            android:textAlignment="center"
 | 
				
			||||||
 | 
					            android:textSize="24sp"
 | 
				
			||||||
 | 
					            android:textStyle="bold" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <TextView
 | 
				
			||||||
 | 
					            android:id="@+id/txtView_current"
 | 
				
			||||||
 | 
					            android:layout_width="match_parent"
 | 
				
			||||||
 | 
					            android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					            android:layout_marginTop="7dp"
 | 
				
			||||||
 | 
					            android:layout_marginBottom="7dp"
 | 
				
			||||||
 | 
					            android:text="16,95 €"
 | 
				
			||||||
 | 
					            android:textAlignment="center"
 | 
				
			||||||
 | 
					            android:textSize="20sp" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <TextView
 | 
				
			||||||
 | 
					            android:id="@+id/txtView_last"
 | 
				
			||||||
 | 
					            android:layout_width="match_parent"
 | 
				
			||||||
 | 
					            android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					            android:text="@string/mensa_last"
 | 
				
			||||||
 | 
					            android:textAlignment="center"
 | 
				
			||||||
 | 
					            android:textSize="16sp" />
 | 
				
			||||||
 | 
					</LinearLayout>
 | 
				
			||||||
@ -1,13 +1,13 @@
 | 
				
			|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
 | 
					// Top-level build file where you can add configuration options common to all sub-projects/modules.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
buildscript {
 | 
					buildscript {
 | 
				
			||||||
    ext.kotlin_version = '1.3.40'
 | 
					    ext.kotlin_version = '1.3.50'
 | 
				
			||||||
    repositories {
 | 
					    repositories {
 | 
				
			||||||
        google()
 | 
					        google()
 | 
				
			||||||
        jcenter()
 | 
					        jcenter()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    dependencies {
 | 
					    dependencies {
 | 
				
			||||||
        classpath 'com.android.tools.build:gradle:3.4.2'
 | 
					        classpath 'com.android.tools.build:gradle:3.5.0'
 | 
				
			||||||
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
 | 
					        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // NOTE: Do not place your application dependencies here; they belong
 | 
					        // NOTE: Do not place your application dependencies here; they belong
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user