Various UI enhancements.

- Add information (link to documentation) when no messages are present
- Add example URL in LoginActivity to indicate the expected format
- Fix capitalization in UI
This commit is contained in:
leopoldsedev
2020-02-09 19:34:40 +01:00
committed by Jannis Mattheis
parent 15f4e8647f
commit 737ad194e9
3 changed files with 89 additions and 14 deletions

View File

@@ -6,6 +6,7 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
@@ -15,6 +16,7 @@ import android.widget.AbsListView;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.ViewFlipper;
import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
@@ -24,6 +26,7 @@ import androidx.drawerlayout.widget.DrawerLayout;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick;
import com.github.gotify.BuildConfig; import com.github.gotify.BuildConfig;
import com.github.gotify.MissedMessageUtil; import com.github.gotify.MissedMessageUtil;
import com.github.gotify.R; import com.github.gotify.R;
@@ -92,6 +95,9 @@ public class MessagesActivity extends AppCompatActivity
@BindView(R.id.swipe_refresh) @BindView(R.id.swipe_refresh)
SwipeRefreshLayout swipeRefreshLayout; SwipeRefreshLayout swipeRefreshLayout;
@BindView(R.id.flipper)
ViewFlipper flipper;
private MessageFacade messages; private MessageFacade messages;
private ApiClient client; private ApiClient client;
@@ -166,6 +172,13 @@ public class MessagesActivity extends AppCompatActivity
new LoadMore().execute(appId); new LoadMore().execute(appId);
} }
@OnClick(R.id.learn_gotify)
public void openDocumentation() {
Intent browserIntent =
new Intent(Intent.ACTION_VIEW, Uri.parse("https://gotify.net/docs/pushmsg"));
startActivity(browserIntent);
}
public void delete(Message message) { public void delete(Message message) {
new DeleteMessage().execute(message); new DeleteMessage().execute(message);
} }
@@ -494,6 +507,13 @@ public class MessagesActivity extends AppCompatActivity
private void updateMessagesAndStopLoading(List<MessageWithImage> messageWithImages) { private void updateMessagesAndStopLoading(List<MessageWithImage> messageWithImages) {
isLoadMore = false; isLoadMore = false;
stopLoading(); stopLoading();
if (messageWithImages.isEmpty()) {
flipper.setDisplayedChild(1);
} else {
flipper.setDisplayedChild(0);
}
ListMessageAdapter adapter = (ListMessageAdapter) messagesView.getAdapter(); ListMessageAdapter adapter = (ListMessageAdapter) messagesView.getAdapter();
adapter.items(messageWithImages); adapter.items(messageWithImages);
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();

View File

@@ -15,14 +15,68 @@
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh" android:id="@+id/swipe_refresh"
android:layout_width="match_parent" android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" android:layout_height="match_parent"
android:layout_height="match_parent"> app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
<ViewFlipper
android:id="@+id/flipper"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView <ListView
android:id="@+id/messages_view" android:id="@+id/messages_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:scrollbars="vertical" android:scrollbars="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> app:layout_behavior="@string/appbar_scrolling_view_behavior">
</ListView>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/no_messages"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:orientation="vertical">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web"
android:text="@string/no_messages_yet"
android:textAlignment="center"
android:textColor="#BDBDBD"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.3" />
<Button
android:id="@+id/learn_gotify"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="Learn how to send messages"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ViewFlipper>
</LinearLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<include <include

View File

@@ -8,7 +8,7 @@
<string name="version_failed">Request to \'%s\' failed. %s.</string> <string name="version_failed">Request to \'%s\' failed. %s.</string>
<string name="wronguserpw">There is no user with this username and password</string> <string name="wronguserpw">There is no user with this username and password</string>
<string name="create_client_title">Client Name</string> <string name="create_client_title">Client Name</string>
<string name="create_client_message">Chose a name for your session</string> <string name="create_client_message">Choose a name for your session</string>
<string name="create">Create</string> <string name="create">Create</string>
<string name="cancel">Cancel</string> <string name="cancel">Cancel</string>
<string name="create_client_failed">Create client failed</string> <string name="create_client_failed">Create client failed</string>
@@ -23,13 +23,13 @@
<string name="websocket_failed">Connection failed, trying again in %d minutes</string> <string name="websocket_failed">Connection failed, trying again in %d minutes</string>
<string name="websocket_closed">WebSocket closed; The client-token could be invalidated, please re-login</string> <string name="websocket_closed">WebSocket closed; The client-token could be invalidated, please re-login</string>
<string name="grouped_message">Received %d messages while being disconnected</string> <string name="grouped_message">Received %d messages while being disconnected</string>
<string name="delete_all">delete all</string> <string name="delete_all">Delete all</string>
<string name="delete_logs">delete logs</string> <string name="delete_logs">Delete logs</string>
<string name="all_messages">All Messages</string> <string name="all_messages">All Messages</string>
<string name="logs">Logs</string> <string name="logs">Logs</string>
<string name="message_image_desc">the image of a message</string> <string name="message_image_desc">The image of a message</string>
<string name="delete_message">delete message</string> <string name="delete_message">Delete message</string>
<string name="gotify_url">Gotify URL</string> <string name="gotify_url">https://push.example.com</string>
<string name="username">Username</string> <string name="username">Username</string>
<string name="password">Password</string> <string name="password">Password</string>
<string name="show_advanced">Show Advanced Options</string> <string name="show_advanced">Show Advanced Options</string>
@@ -40,8 +40,8 @@
<string name="select_ca_failed">Failed to read CA: %s</string> <string name="select_ca_failed">Failed to read CA: %s</string>
<string name="login">Login</string> <string name="login">Login</string>
<string name="check_url">Check URL</string> <string name="check_url">Check URL</string>
<string name="gotify_logo">gotify logo</string> <string name="gotify_logo">Gotify logo</string>
<string name="refresh_all">refresh all</string> <string name="refresh_all">Refresh all</string>
<string name="logout_confirm">Do you really want to logout?</string> <string name="logout_confirm">Do you really want to logout?</string>
<string name="yes">Yes</string> <string name="yes">Yes</string>
<string name="missed_messages">Missed messages</string> <string name="missed_messages">Missed messages</string>
@@ -59,4 +59,5 @@
<string name="i_understand">I Understand</string> <string name="i_understand">I Understand</string>
<string name="websocket_no_network">Waiting for network</string> <string name="websocket_no_network">Waiting for network</string>
<string name="connection">%s@%s</string> <string name="connection">%s@%s</string>
<string name="no_messages_yet">There are no messages, yet.\nSend a message to Gotify\nand it will appear here.</string>
</resources> </resources>