From 9559ad90e9e5542518602f2f5cffd64cb6a96974 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 30 Aug 2018 00:12:53 +0200 Subject: Renamed project to Texx --- app/src/main/java/me/texx/Texx/MainActivity.kt | 67 ++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 app/src/main/java/me/texx/Texx/MainActivity.kt (limited to 'app/src/main/java/me/texx/Texx/MainActivity.kt') diff --git a/app/src/main/java/me/texx/Texx/MainActivity.kt b/app/src/main/java/me/texx/Texx/MainActivity.kt new file mode 100644 index 0000000..e428708 --- /dev/null +++ b/app/src/main/java/me/texx/Texx/MainActivity.kt @@ -0,0 +1,67 @@ +package me.texx.Texx + +import android.os.Bundle +import android.support.v7.app.AppCompatActivity +import android.view.Menu +import android.view.MenuItem +import daio.io.dresscode.dressCodeName +import daio.io.dresscode.matchDressCode +import kotlinx.android.synthetic.main.activity_main.* +import me.texx.Texx.util.ThemeUtil.getThemeName +import org.jetbrains.anko.alert +import org.jetbrains.anko.longToast +import org.jetbrains.anko.startActivity + +/** + * Main activity aka home screen of app + */ +class MainActivity : AppCompatActivity() { + /** + * Set initial configuration + */ + override fun onCreate(savedInstanceState: Bundle?) { + matchDressCode() + super.onCreate(savedInstanceState) + dressCodeName = getThemeName(this) + setContentView(R.layout.activity_main) + setSupportActionBar(toolbar) + + if (intent.getBooleanExtra("serverDown", false)) { + alert("We are sorry, but our servers do not seem to be working at the moment. Please wait a few minutes before you try again.", "Sorry") { + positiveButton("Okay") { + finishAffinity() // TODO: Loading activity will somehow still be opened after close + System.exit(0) + } + }.show() + } + + if (intent.getBooleanExtra("notConnected", false)) + longToast("No internet connection!") + + fab.setOnClickListener { view -> + // TODO: Add camera support + } + } + + + /** + * Inflate the [menu]; this adds items to the action bar if it is present + */ + override fun onCreateOptionsMenu(menu: Menu): Boolean { + menuInflater.inflate(R.menu.menu_main, menu) + return true + } + + /** + * Handling action bar [item] clicks + */ + override fun onOptionsItemSelected(item: MenuItem): Boolean { + return when (item.itemId) { + R.id.action_settings -> { + startActivity() + true + } + else -> super.onOptionsItemSelected(item) + } + } +} -- cgit v1.2.3