From 08b336cf156a0394aa9fa05a34e73a049fa01bc9 Mon Sep 17 00:00:00 2001 From: bearacuda13 Date: Wed, 26 Dec 2018 12:14:05 -0600 Subject: [PATCH] Add files via upload --- apps/android/main/AndroidManifest.xml | 41 ++++ .../java/com/example/ian/titanscout/Match.kt | 31 +++ .../example/ian/titanscout/MatchAdapter.kt | 58 ++++++ .../ian/titanscout/MatchesTableView.kt | 188 ++++++++++++++++++ .../ian/titanscout/PrematchesActivity.kt | 56 ++++++ .../example/ian/titanscout/qrActivity.java | 164 +++++++++++++++ apps/android/main/res/drawable/qrcodeicon.png | Bin 0 -> 1916 bytes .../main/res/layout/activity_alias.xml | 38 ++++ .../main/res/layout/activity_main2.xml | 34 ++++ .../layout/activity_matches_table_view.xml | 38 ++++ .../main/res/layout/activity_prematches.xml | 34 ++++ .../res/layout/activity_qr_full_screen.xml | 34 ++++ .../main/res/layout/activity_scrolling.xml | 48 +++++ apps/android/main/res/layout/activityqr.xml | 58 ++++++ .../android/main/res/layout/content_main2.xml | 12 ++ .../res/layout/content_matches_table_view.xml | 43 ++++ .../main/res/layout/content_prematches.xml | 12 ++ .../res/layout/content_qr_full_screen.xml | 12 ++ .../main/res/layout/content_scrolling.xml | 18 ++ .../main/res/layout/dialog_new_category.xml | 27 +++ .../main/res/layout/fragment_layout.xml | 13 ++ apps/android/main/res/layout/list_item.xml | 41 ++++ .../main/res/layout/matches_fragment.xml | 9 + apps/android/main/res/layout/popup_layout.xml | 14 ++ apps/android/main/res/menu/menu_scrolling.xml | 9 + .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + .../main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4490 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 6895 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6387 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10413 bytes apps/android/main/res/values/colors.xml | 10 + apps/android/main/res/values/dimens.xml | 5 + apps/android/main/res/values/strings.xml | 98 +++++++++ apps/android/main/res/values/styles.xml | 17 ++ 35 files changed, 1172 insertions(+) create mode 100644 apps/android/main/AndroidManifest.xml create mode 100644 apps/android/main/java/com/example/ian/titanscout/Match.kt create mode 100644 apps/android/main/java/com/example/ian/titanscout/MatchAdapter.kt create mode 100644 apps/android/main/java/com/example/ian/titanscout/MatchesTableView.kt create mode 100644 apps/android/main/java/com/example/ian/titanscout/PrematchesActivity.kt create mode 100644 apps/android/main/java/com/example/ian/titanscout/qrActivity.java create mode 100644 apps/android/main/res/drawable/qrcodeicon.png create mode 100644 apps/android/main/res/layout/activity_alias.xml create mode 100644 apps/android/main/res/layout/activity_main2.xml create mode 100644 apps/android/main/res/layout/activity_matches_table_view.xml create mode 100644 apps/android/main/res/layout/activity_prematches.xml create mode 100644 apps/android/main/res/layout/activity_qr_full_screen.xml create mode 100644 apps/android/main/res/layout/activity_scrolling.xml create mode 100644 apps/android/main/res/layout/activityqr.xml create mode 100644 apps/android/main/res/layout/content_main2.xml create mode 100644 apps/android/main/res/layout/content_matches_table_view.xml create mode 100644 apps/android/main/res/layout/content_prematches.xml create mode 100644 apps/android/main/res/layout/content_qr_full_screen.xml create mode 100644 apps/android/main/res/layout/content_scrolling.xml create mode 100644 apps/android/main/res/layout/dialog_new_category.xml create mode 100644 apps/android/main/res/layout/fragment_layout.xml create mode 100644 apps/android/main/res/layout/list_item.xml create mode 100644 apps/android/main/res/layout/matches_fragment.xml create mode 100644 apps/android/main/res/layout/popup_layout.xml create mode 100644 apps/android/main/res/menu/menu_scrolling.xml create mode 100644 apps/android/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 apps/android/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 apps/android/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 apps/android/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 apps/android/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 apps/android/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 apps/android/main/res/values/colors.xml create mode 100644 apps/android/main/res/values/dimens.xml create mode 100644 apps/android/main/res/values/strings.xml create mode 100644 apps/android/main/res/values/styles.xml diff --git a/apps/android/main/AndroidManifest.xml b/apps/android/main/AndroidManifest.xml new file mode 100644 index 00000000..47609081 --- /dev/null +++ b/apps/android/main/AndroidManifest.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/apps/android/main/java/com/example/ian/titanscout/Match.kt b/apps/android/main/java/com/example/ian/titanscout/Match.kt new file mode 100644 index 00000000..de3a6614 --- /dev/null +++ b/apps/android/main/java/com/example/ian/titanscout/Match.kt @@ -0,0 +1,31 @@ +package com.example.ian.titanscout + + +class Match (var ind: Int, var redTeams: Array, var blueTeams: Array) { + // class body + + fun getScouts(): Int { + var x = 0 + for (red in redTeams) { + if (red.hasScouts()) { + x++ + } + } + for (blue in blueTeams) { + if (blue.hasScouts()) { + x++ + } + } + return x + } +} + +class Team (var num: String, var color:String, var scouts:Array) { + + fun hasScouts() : Boolean { + if (scouts.size > 0 && !scouts[0].equals("")) { + return true + } + return false + } +} \ No newline at end of file diff --git a/apps/android/main/java/com/example/ian/titanscout/MatchAdapter.kt b/apps/android/main/java/com/example/ian/titanscout/MatchAdapter.kt new file mode 100644 index 00000000..647917bb --- /dev/null +++ b/apps/android/main/java/com/example/ian/titanscout/MatchAdapter.kt @@ -0,0 +1,58 @@ +package com.example.ian.titanscout + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.BaseAdapter +import android.widget.ProgressBar +import android.widget.TextView + +class MatchAdapter(private val context: Context, + private val dataSource: Array) : BaseAdapter() { + + private val inflater: LayoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater + + //1 + override fun getCount(): Int { + return dataSource.size + } + + //2 + override fun getItem(position: Int): Any { + return dataSource[position] + } + + //3 + override fun getItemId(position: Int): Long { + return position.toLong() + } + + //4 + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + // Get view for row item + val rowView = inflater.inflate(R.layout.list_item, parent, false) + + + // Get title element + val titleTextView = rowView.findViewById(R.id.titleTV) as TextView + + // Get subtitle element + val subtitleTextView = rowView.findViewById(R.id.subtitle) as TextView + + // Get progressBar element + val progressBar = rowView.findViewById(R.id.progressBar) as ProgressBar + + val match = getItem(position) as Match + + val str = "Match " + match.ind + titleTextView.text = str + val str2 = match.getScouts().toString() + " of 6" + subtitleTextView.text = str2 + progressBar.progress = (1.0 * progressBar.max * match.getScouts() / (6.0)).toInt() + + return rowView + } + + +} \ No newline at end of file diff --git a/apps/android/main/java/com/example/ian/titanscout/MatchesTableView.kt b/apps/android/main/java/com/example/ian/titanscout/MatchesTableView.kt new file mode 100644 index 00000000..df7c58c7 --- /dev/null +++ b/apps/android/main/java/com/example/ian/titanscout/MatchesTableView.kt @@ -0,0 +1,188 @@ +package com.example.ian.titanscout + +import android.graphics.Color +import android.os.Bundle +import android.support.design.widget.FloatingActionButton +import android.support.v7.app.AlertDialog +import android.support.v7.app.AppCompatActivity; + +import com.google.firebase.firestore.FirebaseFirestore +import org.json.JSONObject +import com.google.zxing.WriterException +import android.graphics.Bitmap +import android.widget.* +import net.glxn.qrgen.android.QRCode + + +class MatchesTableView : AppCompatActivity() { + + + var shouldShow = true + // Reference the database to be used in the rest of the class. + val db = FirebaseFirestore.getInstance() + var alias = "" + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_matches_table_view) +// setSupportActionBar(toolbar) + + var matches = arrayOf() + val TAG = "MainActivity" + val docRef = db.collection("appBuilding").document("schedule") + docRef.get().addOnSuccessListener { documentSnapshot -> + val stringData = documentSnapshot.data.toString() + + // Get data from the database and process it into an array of Matches. + val schedule = Response(stringData).getJSONArray("matches") + for (i in 0..(schedule.length() - 1)) { + val item = schedule.getJSONObject(i) + val reds = Response(item["RED"].toString()) + val blues = Response(item["BLUE"].toString()) + val redTeams = getTeamArrayFromJSON(reds, "RED") + val blueTeams = getTeamArrayFromJSON(blues, "BLUE") + matches += Match(i+1, redTeams, blueTeams) + } + + // update the user's alias + alias = intent.getStringExtra("alias") + updateAlias(alias) + + + val listView = findViewById(R.id.match_list_view) + + val listItems = arrayOfNulls(matches.size) + + for (i in 0 until matches.size) { + val match = matches[i] + listItems[i] = "Match " + match.ind + } + + +// val adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, listItems) +// listView.adapter = adapter + + val adapter = MatchAdapter(this, matches) + listView.adapter = adapter + + } + + val fab = findViewById(R.id.fab) + fab.setImageResource(R.drawable.qrcodeicon) + fab.setColorFilter(Color.parseColor("#FFFFFF")) + + + fab.setOnClickListener { view -> + + // QR Button pressed + + if (shouldShow) { + try { + + val bitmap = TextToImageEncode(intent.getStringExtra("auth")) + + + findViewById(R.id.imageView).setImageBitmap(bitmap) + + } catch (e: WriterException) { + e.printStackTrace() + } + + } else { + findViewById(R.id.imageView).setImageResource(android.R.color.transparent) + } + + shouldShow = !shouldShow + } + + findViewById