Skip to content

Commit 5c3b7aa

Browse files
committed
Create settings view
1 parent ea7d04f commit 5c3b7aa

File tree

10 files changed

+131
-22
lines changed

10 files changed

+131
-22
lines changed

android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
</activity>
4040
<activity android:name=".LoginActivity" android:screenOrientation="portrait"
4141
tools:ignore="LockedOrientationActivity" />
42+
<activity android:name=".SettingsActivity" android:screenOrientation="portrait"
43+
tools:ignore="LockedOrientationActivity" />
4244

4345
<service
4446
android:name=".services.StickyNotificationService"

android/app/src/main/java/com/httpsms/MainActivity.kt

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -183,26 +183,16 @@ class MainActivity : AppCompatActivity() {
183183
}
184184

185185
private fun registerListeners() {
186-
findViewById<MaterialButton>(R.id.mainLogoutButton).setOnClickListener { onLogoutClick() }
186+
findViewById<MaterialButton>(R.id.mainSettingsButton).setOnClickListener { onSettingsClick() }
187187
}
188188

189189
private fun registerReceivers() {
190190
registerReceiver(SimChangeReceiver(), IntentFilter("android.intent.action.SIM_STATE_CHANGED"))
191191
}
192-
private fun onLogoutClick() {
193-
Timber.d("logout button clicked")
194-
MaterialAlertDialogBuilder(this)
195-
.setTitle("Confirm")
196-
.setMessage("Are you sure you want to logout of the Http SMS App?")
197-
.setNeutralButton("Cancel"){ _, _ -> Timber.d("logout dialog canceled") }
198-
.setPositiveButton("Logout"){_, _ ->
199-
Timber.d("logging out user")
200-
Settings.setApiKeyAsync(this, null)
201-
Settings.setOwnerAsync(this, null)
202-
Settings.setFcmTokenLastUpdateTimestampAsync(this, 0)
203-
redirectToLogin()
204-
}
205-
.show()
192+
private fun onSettingsClick() {
193+
Timber.d("settings button clicked")
194+
val switchActivityIntent = Intent(this, SettingsActivity::class.java)
195+
startActivity(switchActivityIntent)
206196
}
207197

208198
private fun redirectToLogin():Boolean {
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.httpsms
2+
3+
import android.content.Intent
4+
import android.os.Bundle
5+
import androidx.appcompat.app.AppCompatActivity
6+
import androidx.appcompat.widget.Toolbar
7+
import com.google.android.material.appbar.MaterialToolbar
8+
import com.google.android.material.button.MaterialButton
9+
import com.google.android.material.dialog.MaterialAlertDialogBuilder
10+
import timber.log.Timber
11+
12+
class SettingsActivity : AppCompatActivity() {
13+
override fun onCreate(savedInstanceState: Bundle?) {
14+
super.onCreate(savedInstanceState)
15+
setContentView(R.layout.activity_settings)
16+
registerListeners()
17+
}
18+
19+
private fun registerListeners() {
20+
appToolbar().setOnClickListener { onBackClicked() }
21+
}
22+
23+
private fun onBackClicked() {
24+
Timber.e("back button clicked")
25+
redirectToMain()
26+
}
27+
28+
29+
private fun redirectToMain() {
30+
finish()
31+
val switchActivityIntent = Intent(this, MainActivity::class.java)
32+
startActivity(switchActivityIntent)
33+
}
34+
35+
private fun appToolbar(): MaterialToolbar {
36+
return findViewById(R.id.settings_toolbar)
37+
}
38+
39+
private fun onLogoutClick() {
40+
Timber.d("logout button clicked")
41+
MaterialAlertDialogBuilder(this)
42+
.setTitle("Confirm")
43+
.setMessage("Are you sure you want to logout of the Http SMS App?")
44+
.setNeutralButton("Cancel"){ _, _ -> Timber.d("logout dialog canceled") }
45+
.setPositiveButton("Logout"){_, _ ->
46+
Timber.d("logging out user")
47+
Settings.setApiKeyAsync(this, null)
48+
Settings.setOwnerAsync(this, null)
49+
Settings.setFcmTokenLastUpdateTimestampAsync(this, 0)
50+
redirectToLogin()
51+
}
52+
.show()
53+
}
54+
55+
private fun redirectToLogin():Boolean {
56+
if (Settings.isLoggedIn(this)) {
57+
return false
58+
}
59+
val switchActivityIntent = Intent(this, LoginActivity::class.java)
60+
startActivity(switchActivityIntent)
61+
return true
62+
}
63+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#FFFFFF"
2+
android:viewportHeight="24" android:viewportWidth="24"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M19.14,12.94c0.04,-0.3 0.06,-0.61 0.06,-0.94c0,-0.32 -0.02,-0.64 -0.07,-0.94l2.03,-1.58c0.18,-0.14 0.23,-0.41 0.12,-0.61l-1.92,-3.32c-0.12,-0.22 -0.37,-0.29 -0.59,-0.22l-2.39,0.96c-0.5,-0.38 -1.03,-0.7 -1.62,-0.94L14.4,2.81c-0.04,-0.24 -0.24,-0.41 -0.48,-0.41h-3.84c-0.24,0 -0.43,0.17 -0.47,0.41L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33c-0.22,-0.08 -0.47,0 -0.59,0.22L2.74,8.87C2.62,9.08 2.66,9.34 2.86,9.48l2.03,1.58C4.84,11.36 4.8,11.69 4.8,12s0.02,0.64 0.07,0.94l-2.03,1.58c-0.18,0.14 -0.23,0.41 -0.12,0.61l1.92,3.32c0.12,0.22 0.37,0.29 0.59,0.22l2.39,-0.96c0.5,0.38 1.03,0.7 1.62,0.94l0.36,2.54c0.05,0.24 0.24,0.41 0.48,0.41h3.84c0.24,0 0.44,-0.17 0.47,-0.41l0.36,-2.54c0.59,-0.24 1.13,-0.56 1.62,-0.94l2.39,0.96c0.22,0.08 0.47,0 0.59,-0.22l1.92,-3.32c0.12,-0.22 0.07,-0.47 -0.12,-0.61L19.14,12.94zM12,15.6c-1.98,0 -3.6,-1.62 -3.6,-3.6s1.62,-3.6 3.6,-3.6s3.6,1.62 3.6,3.6S13.98,15.6 12,15.6z"/>
5+
</vector>

android/app/src/main/res/layout/activity_main.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,18 @@
149149
</LinearLayout>
150150

151151
<com.google.android.material.button.MaterialButton
152-
android:id="@+id/mainLogoutButton"
152+
android:id="@+id/mainSettingsButton"
153153
style="@style/Widget.MaterialComponents.Button.Icon"
154154
android:layout_width="wrap_content"
155155
android:layout_height="wrap_content"
156156
android:layout_marginBottom="16dp"
157157
android:backgroundTint="@color/black"
158158
android:drawableTint="@color/white"
159159
android:padding="10dp"
160-
android:text="@string/main_log_out"
160+
android:text="@string/main_app_settings"
161161
android:textColor="@color/white"
162162
android:textSize="16sp"
163-
app:icon="@drawable/ic_login"
163+
app:icon="@drawable/baseline_settings_24"
164164
app:iconTint="@color/white"
165165
app:layout_constraintBottom_toBottomOf="parent"
166166
app:layout_constraintEnd_toEndOf="parent"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent">
7+
8+
<com.google.android.material.appbar.AppBarLayout
9+
android:id="@+id/settings_app_bar_layout"
10+
android:layout_width="match_parent"
11+
android:layout_height="?attr/actionBarSize"
12+
app:layout_constraintStart_toStartOf="parent"
13+
app:layout_constraintTop_toTopOf="parent">
14+
15+
<com.google.android.material.appbar.MaterialToolbar
16+
android:id="@+id/settings_toolbar"
17+
style="@style/Widget.MaterialComponents.Toolbar.Primary"
18+
android:layout_width="match_parent"
19+
android:layout_height="?attr/actionBarSize"
20+
android:layout_marginBottom="676dp"
21+
android:background="@color/black"
22+
app:layout_constraintTop_toTopOf="parent"
23+
app:layout_constraintHorizontal_bias="0.0"
24+
app:layout_constraintLeft_toLeftOf="parent"
25+
app:layout_constraintRight_toRightOf="parent"
26+
app:navigationIcon="?attr/homeAsUpIndicator"
27+
app:title="App Settings" />
28+
</com.google.android.material.appbar.AppBarLayout>
29+
30+
<com.google.android.material.button.MaterialButton
31+
android:id="@+id/settingsLogoutButton"
32+
style="@style/Widget.MaterialComponents.Button.Icon"
33+
android:layout_width="wrap_content"
34+
android:layout_height="wrap_content"
35+
android:layout_marginBottom="16dp"
36+
android:backgroundTint="@color/black"
37+
android:drawableTint="@color/white"
38+
android:padding="10dp"
39+
android:text="@string/main_log_out"
40+
android:textColor="@color/white"
41+
android:textSize="16sp"
42+
app:icon="@drawable/ic_login"
43+
app:iconTint="@color/white"
44+
app:layout_constraintBottom_toBottomOf="parent"
45+
app:layout_constraintEnd_toEndOf="parent"
46+
app:layout_constraintStart_toStartOf="parent"
47+
tools:ignore="TextContrastCheck" />
48+
</androidx.constraintlayout.widget.ConstraintLayout>

android/app/src/main/res/values-night/themes.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<item name="colorSecondaryVariant">@color/pink_A400</item>
1111
<item name="colorOnSecondary">@color/white</item>
1212
<!-- Status bar color. -->
13-
<item name="android:statusBarColor" tools:targetApi="l">#121212</item>
13+
<item name="android:statusBarColor">#121212</item>
1414
<!-- Customize your theme here. -->
1515
</style>
1616
</resources>

android/app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
<string name="default_server_url">https://api.httpsms.com</string>
1818
<string name="app_version">httpsms.com - %s</string>
1919
<string name="disable_battery_optimization">Disable Battery Optimization</string>
20+
<string name="main_app_settings">App Settings</string>
2021
</resources>

android/app/src/main/res/values/themes.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<item name="colorSecondaryVariant">@color/pink_A400</item>
1111
<item name="colorOnSecondary">@color/white</item>
1212
<!-- Status bar color. -->
13-
<item name="android:statusBarColor" tools:targetApi="l">#121212</item>
13+
<item name="android:statusBarColor">#121212</item>
1414
<!-- Customize your theme here. -->
1515
</style>
1616

android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ buildscript {
1212
}
1313

1414
plugins {
15-
id 'com.android.application' version '8.0.1' apply false
16-
id 'com.android.library' version '8.0.1' apply false
15+
id 'com.android.application' version '8.0.2' apply false
16+
id 'com.android.library' version '8.0.2' apply false
1717
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
1818
}
1919

0 commit comments

Comments
 (0)