Selaa lähdekoodia

added home screen w/ button to go to settings, which is a separate activity now

Tareef 4 vuotta sitten
vanhempi
commit
9572ff24ac

+ 8 - 2
app/src/main/AndroidManifest.xml

@@ -9,8 +9,14 @@
         android:roundIcon="@mipmap/ic_launcher_round"
         android:supportsRtl="true"
         android:theme="@style/Theme.PWM">
-        <activity
-            android:name=".MainActivity">
+        <activity android:name=".HomeActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+        <activity android:name=".ThemeActivity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 

+ 25 - 0
app/src/main/java/com/tarfeef101/pwm/HomeActivity.kt

@@ -0,0 +1,25 @@
+package com.tarfeef101.pwm
+
+import android.content.Intent
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import android.provider.AlarmClock.EXTRA_MESSAGE
+import android.view.View
+import kotlinx.android.synthetic.main.activity_home.*
+
+class HomeActivity : AppCompatActivity()
+{
+    override fun onCreate(savedInstanceState: Bundle?)
+    {
+        super.onCreate(savedInstanceState)
+        setContentView(R.layout.activity_home)
+
+        fun launchThemeSettings()
+        {
+            val intent = Intent(this, ThemeActivity::class.java)
+            startActivity(intent)
+        }
+        settingsButton.setText("Settings")
+        settingsButton.setOnClickListener { _ -> launchThemeSettings()}
+    }
+}

+ 3 - 3
app/src/main/java/com/tarfeef101/pwm/MainActivity.kt → app/src/main/java/com/tarfeef101/pwm/ThemeActivity.kt

@@ -10,15 +10,15 @@ import android.widget.RadioGroup
 import android.widget.TextClock
 import android.widget.TextView
 import androidx.appcompat.app.AppCompatDelegate
-import kotlinx.android.synthetic.main.activity_main.*
+import kotlinx.android.synthetic.main.activity_theme.*
 
 @SuppressLint("SetTextI18n")
-class MainActivity : AppCompatActivity()
+class ThemeActivity : AppCompatActivity()
 {
     override fun onCreate(savedInstanceState: Bundle?)
     {
         super.onCreate(savedInstanceState)
-        setContentView(R.layout.activity_main)
+        setContentView(R.layout.activity_theme)
 
         // load shared preferences file
         val pref = this.getPreferences(Context.MODE_PRIVATE)

+ 18 - 0
app/src/main/res/layout/activity_home.xml

@@ -0,0 +1,18 @@
+<?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"
+    tools:context=".HomeActivity">
+
+    <Button
+        android:id="@+id/settingsButton"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="16dp"
+        android:layout_marginEnd="16dp"
+        android:text="Button"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 1 - 1
app/src/main/res/layout/activity_main.xml → app/src/main/res/layout/activity_theme.xml

@@ -4,7 +4,7 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    tools:context=".MainActivity">
+    tools:context=".ThemeActivity">
 
     <RadioGroup
         android:id="@+id/themeRadioGroup"