More styling

This commit is contained in:
Philipp Heckel 2021-10-28 08:28:22 -04:00
parent d2f04323f9
commit 8727558069
12 changed files with 26 additions and 105 deletions

View file

@ -11,7 +11,9 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name="io.heckel.ntfy.ui.MainActivity"> <activity android:name="io.heckel.ntfy.ui.MainActivity"
android:icon="@drawable/ntfy"
android:label="@string/main_action_bar_label">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />

View file

@ -19,7 +19,7 @@ class AddFragment(private val listener: Listener) : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return activity?.let { return activity?.let {
// Build root view // Build root view
val view = requireActivity().layoutInflater.inflate(R.layout.fragment_add, null) val view = requireActivity().layoutInflater.inflate(R.layout.add_dialog_fragment, null)
val topicNameText = view.findViewById(R.id.add_dialog_topic_text) as TextInputEditText val topicNameText = view.findViewById(R.id.add_dialog_topic_text) as TextInputEditText
val baseUrlText = view.findViewById(R.id.add_dialog_base_url_text) as TextInputEditText val baseUrlText = view.findViewById(R.id.add_dialog_base_url_text) as TextInputEditText
val useAnotherServerCheckbox = view.findViewById(R.id.add_dialog_use_another_server_checkbox) as CheckBox val useAnotherServerCheckbox = view.findViewById(R.id.add_dialog_use_another_server_checkbox) as CheckBox
@ -72,7 +72,7 @@ class AddFragment(private val listener: Listener) : DialogFragment() {
} }
topicNameText.addTextChangedListener(textWatcher) topicNameText.addTextChangedListener(textWatcher)
baseUrlText.addTextChangedListener(textWatcher) baseUrlText.addTextChangedListener(textWatcher)
useAnotherServerCheckbox.setOnCheckedChangeListener { buttonView, isChecked -> useAnotherServerCheckbox.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) baseUrlText.visibility = View.VISIBLE if (isChecked) baseUrlText.visibility = View.VISIBLE
else baseUrlText.visibility = View.GONE else baseUrlText.visibility = View.GONE
validateInput() validateInput()

View file

@ -31,7 +31,7 @@ class DetailActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.topic_detail_activity) setContentView(R.layout.detail_activity)
var subscriptionId: Long? = null var subscriptionId: Long? = null

View file

@ -31,7 +31,7 @@ class MainActivity : AppCompatActivity(), AddFragment.Listener {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) setContentView(R.layout.main_activity)
// Floating action button ("+") // Floating action button ("+")
val fab: View = findViewById(R.id.fab) val fab: View = findViewById(R.id.fab)
@ -63,11 +63,11 @@ class MainActivity : AppCompatActivity(), AddFragment.Listener {
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) { return when (item.itemId) {
R.id.menu_action_source -> { R.id.menu_action_source -> {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.menu_source_url)))) startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.main_menu_source_url))))
true true
} }
R.id.menu_action_website -> { R.id.menu_action_website -> {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.menu_website_url)))) startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.main_menu_website_url))))
true true
} }
else -> super.onOptionsItemSelected(item) else -> super.onOptionsItemSelected(item)

View file

@ -51,7 +51,7 @@ class TopicsAdapter(private val onClick: (Subscription) -> Unit) :
/* Creates and inflates view and return TopicViewHolder. */ /* Creates and inflates view and return TopicViewHolder. */
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TopicViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TopicViewHolder {
val view = LayoutInflater.from(parent.context) val view = LayoutInflater.from(parent.context)
.inflate(R.layout.topic_item, parent, false) .inflate(R.layout.main_fragment_item, parent, false)
return TopicViewHolder(view, onClick) return TopicViewHolder(view, onClick)
} }

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"

View file

@ -1,67 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2020 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:text="@string/add_topic"
android:textAlignment="center"
android:textAppearance="?attr/textAppearanceHeadline4"/>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:hint="@string/topic_name_edit_text"
android:paddingTop="16dp"
android:paddingBottom="16dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/add_topic_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:hint="@string/add_dialog_base_url_layout"
android:paddingTop="16dp"
android:paddingBottom="16dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/add_topic_base_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/subscribe_button"
style="?attr/materialButtonOutlinedStyle"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/subscribe_button_text" />
</LinearLayout>

View file

@ -1,16 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2020 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="80dp" android:layout_height="80dp"

View file

@ -1,5 +1,5 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/menu_action_source" <item android:id="@+id/menu_action_source"
android:title="@string/menu_source_title"/> android:title="@string/main_menu_source_title"/>
<item android:title="@string/menu_website_title" android:id="@+id/menu_action_website"/> <item android:title="@string/main_menu_website_title" android:id="@+id/menu_action_website"/>
</menu> </menu>

View file

@ -1,29 +1,27 @@
<resources> <resources>
<string name="app_name">Ntfy</string> <string name="app_name">Ntfy</string>
<string name="add_topic">Add Topic</string>
<!-- Notifications -->
<string name="notification_channel_name">Ntfy</string>
<string name="notification_channel_id">ntfy</string>
<string name="topic_name_edit_text">Topic Name</string> <!-- Main activity: Action bar -->
<string name="add_dialog_base_url_layout">Service URL</string> <string name="main_action_bar_label">Subscribed topics</string>
<string name="topic_base_url_default_value">https://ntfy.sh</string> <string name="main_menu_source_title">Show source &amp; license</string>
<string name="subscribe_button_text">Subscribe</string> <string name="main_menu_source_url">https://heckel.io/ntfy-android</string>
<string name="main_menu_website_title">Visit ntfy.sh</string>
<string name="main_menu_website_url">https://ntfy.sh</string>
<!-- Main activity: List and such -->
<string name="status_connected">Connected</string> <string name="status_connected">Connected</string>
<string name="status_connecting">Connecting</string> <string name="status_connecting">Connecting</string>
<string name="status_text_one">%1$s, %2$d notification</string> <string name="status_text_one">%1$s, %2$d notification</string>
<string name="status_text_not_one">%1$s, %2$d notifications</string> <string name="status_text_not_one">%1$s, %2$d notifications</string>
<string name="fab_content_description">fab</string> <string name="fab_content_description">fab</string>
<!-- Detail activity -->
<string name="remove_topic">Unsubscribe</string> <string name="remove_topic">Unsubscribe</string>
<!-- Menu -->
<string name="menu_source_title">Show source &amp; license</string>
<string name="menu_source_url">https://heckel.io/ntfy-android</string>
<string name="menu_website_title">Visit ntfy.sh</string>
<string name="menu_website_url">https://ntfy.sh</string>
<!-- Notifications -->
<string name="notification_channel_name">Ntfy</string>
<string name="notification_channel_id">ntfy</string>
<!-- Add dialog --> <!-- Add dialog -->
<string name="add_dialog_title">Subscribe to topic</string> <string name="add_dialog_title">Subscribe to topic</string>
<string name="add_dialog_topic_name_hint">Topic name, e.g. phils_alerts</string> <string name="add_dialog_topic_name_hint">Topic name, e.g. phils_alerts</string>