Prepares statistics #274

This commit is contained in:
tom79 2019-08-25 18:31:14 +02:00
parent c6c943236c
commit f3cb4ede15
5 changed files with 280 additions and 6 deletions

View File

@ -157,7 +157,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetrie
if (theme == Helper.THEME_LIGHT){
Helper.colorizeToolbar(actionBar.getCustomView().findViewById(R.id.toolbar), R.color.black, OwnerNotificationActivity.this);
}
toolbarTitle.setText(getString(R.string.owner_cached_toots));
toolbarTitle.setText(getString(R.string.owner_cached_notifications));
}
notifications = new ArrayList<>();
RecyclerView lv_notifications = findViewById(R.id.lv_notifications);
@ -307,7 +307,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetrie
}
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(OwnerNotificationActivity.this, style);
LayoutInflater inflater = this.getLayoutInflater();
statsDialogView = inflater.inflate(R.layout.stats_owner_toots, null);
statsDialogView = inflater.inflate(R.layout.stats_owner_notifications, null);
dialogBuilder.setView(statsDialogView);
dialogBuilder
.setTitle(R.string.action_stats)

View File

@ -21,7 +21,6 @@ import android.os.AsyncTask;
import java.lang.ref.WeakReference;
import java.util.List;
import app.fedilab.android.client.API;
import app.fedilab.android.client.APIResponse;
import app.fedilab.android.client.Entities.Notification;
import app.fedilab.android.helper.FilterNotifications;
@ -53,7 +52,6 @@ public class RetrieveNotificationsCacheAsyncTask extends AsyncTask<Void, Void, V
@Override
protected Void doInBackground(Void... params) {
API api;
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
List<Notification> notifications = new NotificationCacheDAO(contextReference.get(), db).getNotificationsFromID(filterNotifications, max_id);
apiResponse = new APIResponse();

View File

@ -116,7 +116,7 @@ public class NotificationCacheDAO {
if(filterNotifications.isBoost() || filterNotifications.isFavorite() || filterNotifications.isFollow() ||filterNotifications.isMention() || filterNotifications.isPoll() ){
selection.append(" AND ( ");
if (filterNotifications.isBoost() ) {
selection.append(Sqlite.COL_TYPE + "='boost' OR ");
selection.append(Sqlite.COL_TYPE + "='reblog' OR ");
}
if (filterNotifications.isPoll() ) {
selection.append(Sqlite.COL_TYPE + "='poll' OR ");
@ -128,7 +128,7 @@ public class NotificationCacheDAO {
selection.append(Sqlite.COL_TYPE + "='mention' OR ");
}
if (filterNotifications.isFavorite() ) {
selection.append(Sqlite.COL_TYPE + "='favorite' OR ");
selection.append(Sqlite.COL_TYPE + "='favourite' OR ");
}
String selectionStr = selection.toString().substring(0, selection.toString().length()-3);
selection = new StringBuilder(selectionStr);

View File

@ -0,0 +1,271 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019 Thomas Schneider
This file is a part of Fedilab
This program is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along with Fedilab; if not,
see <http://www.gnu.org/licenses>.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingLeft="@dimen/fab_margin"
android:paddingRight="@dimen/fab_margin"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/stats_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:paddingStart="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_vertical_margin"
android:paddingEnd="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_vertical_margin"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_gravity="center_vertical"
android:textSize="16sp"
android:text="@string/display_charts"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageButton
android:id="@+id/charts"
android:layout_marginStart="15dp"
style="@style/Widget.AppCompat.Button.Colored"
android:src="@drawable/ic_insert_chart"
android:scaleType="centerCrop"
android:layout_width="40dp"
android:layout_height="40dp"
android:contentDescription="@string/validate" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="?colorAccent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/date_range"
android:textColor="?colorAccent"
android:textSize="16sp" />
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="?colorAccent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_weight="2"
android:text="@string/first_toot_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_weight="1"
android:textAlignment="textEnd"
android:id="@+id/first_toot_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_weight="2"
android:text="@string/last_toot_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_weight="1"
android:textAlignment="textEnd"
android:id="@+id/last_toot_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_weight="2"
android:text="@string/frequency"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_weight="1"
android:textAlignment="textEnd"
android:id="@+id/frequency"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<!-- NOTIFICATIONS -->
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="?colorAccent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/notifications"
android:textColor="?colorAccent"
android:textSize="16sp" />
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="?colorAccent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_weight="2"
android:text="@string/total_notifications"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_weight="1"
android:textAlignment="textEnd"
android:id="@+id/total_statuses"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_weight="2"
android:text="@string/number_boosts"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_weight="1"
android:textAlignment="textEnd"
android:id="@+id/number_boosts"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_weight="2"
android:text="@string/number_favourites"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_weight="1"
android:textAlignment="textEnd"
android:id="@+id/number_favourites"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_weight="2"
android:text="@string/number_mentions"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_weight="1"
android:textAlignment="textEnd"
android:id="@+id/number_mentions"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_weight="2"
android:text="@string/number_follows"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_weight="1"
android:textAlignment="textEnd"
android:id="@+id/number_follows"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_weight="2"
android:text="@string/number_polls"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_weight="1"
android:id="@+id/number_polls"
android:textAlignment="textEnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<!-- Main Loader -->
<RelativeLayout
android:id="@+id/loader"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" />
</RelativeLayout>
</RelativeLayout>

View File

@ -1128,6 +1128,10 @@
<string name="action_stats">Statistics</string>
<string name="total_statuses">Total statuses</string>
<string name="number_boosts">Number of boosts</string>
<string name="number_favourites">Number of favourites</string>
<string name="number_mentions">Number of mentions</string>
<string name="number_follows">Number of follows</string>
<string name="number_polls">Number of polls</string>
<string name="number_replies">Number of replies</string>
<string name="number_statuses">Number of statuses</string>
<string name="statuses">Statuses</string>
@ -1188,4 +1192,5 @@
<string name="cache_owntoots_clear">Clear your cached statuses</string>
<string name="cache_bookmarks_clear">Clear your bookmarks</string>
<string name="file_cache">Files in cache</string>
<string name="total_notifications">Total notifications</string>
</resources>