Some fixes

This commit is contained in:
tom79 2019-11-16 12:06:05 +01:00
parent 8cef86270a
commit cf5a254b6b
3 changed files with 138 additions and 118 deletions

View File

@ -140,11 +140,13 @@ public class InstanceProfileActivity extends BaseActivity {
SpannableString descriptionSpan;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
descriptionSpan = new SpannableString(Html.fromHtml(instanceNodeInfo.getNodeDescription(), FROM_HTML_MODE_LEGACY));
else
descriptionSpan = new SpannableString(Html.fromHtml(instanceNodeInfo.getNodeDescription()));
description.setText(descriptionSpan, TextView.BufferType.SPANNABLE);
if( instanceNodeInfo.getNodeDescription() != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
descriptionSpan = new SpannableString(Html.fromHtml(instanceNodeInfo.getNodeDescription(), FROM_HTML_MODE_LEGACY));
else
descriptionSpan = new SpannableString(Html.fromHtml(instanceNodeInfo.getNodeDescription()));
description.setText(descriptionSpan, TextView.BufferType.SPANNABLE);
}
userCount.setText(Helper.withSuffix((instanceNodeInfo.getNumberOfUsers())));
statusCount.setText(Helper.withSuffix((instanceNodeInfo.getNumberOfPosts())));
instanceCount.setText(Helper.withSuffix((instanceNodeInfo.getNumberOfInstance())));

View File

@ -1942,6 +1942,18 @@ public class API {
if( metadata.has("staffAccounts")){
instanceNodeInfo.setStaffAccountStr(metadata.getString("staffAccounts"));
}
if( metadata.has("nodeName")){
instanceNodeInfo.setNodeName(metadata.getString("nodeName"));
}
}
if( resobj.has("usage")){
JSONObject usage = resobj.getJSONObject("usage");
if( usage.has("users") && usage.getJSONObject("users").has("total")){
instanceNodeInfo.setNumberOfUsers(usage.getJSONObject("users").getInt("total"));
}
if( usage.has("localPosts") ){
instanceNodeInfo.setNumberOfPosts(usage.getInt("localPosts"));
}
}
if( instanceNodeInfo.getStaffAccountStr() != null && instanceNodeInfo.getStaffAccount() == null){
APIResponse search = searchAccounts(instanceNodeInfo.getStaffAccountStr(), 1);

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
@ -6,7 +7,7 @@
android:layout_height="450dp"
android:layout_margin="@dimen/fab_margin"
android:fitsSystemWindows="true"
tools:context="app.fedilab.android.activities.InstanceHealthActivity">
tools:context="app.fedilab.android.activities.InstanceProfileActivity">
<RelativeLayout
android:layout_width="match_parent"
@ -21,129 +22,134 @@
android:scaleType="centerCrop" />
</RelativeLayout>
<LinearLayout
android:id="@+id/instance_container"
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/fab_margin"
android:layout_marginEnd="@dimen/fab_margin"
android:orientation="vertical"
android:visibility="gone"
>
<TextView
android:background="@drawable/blue_border"
android:id="@+id/name"
android:textColor="@color/mastodonC4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:layout_margin="10dp"
android:textSize="20sp" />
<TextView
android:layout_margin="5dp"
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:autoLink="web"
android:gravity="center"
android:textSize="14sp" />
android:layout_height="wrap_content">
<LinearLayout
android:layout_marginTop="20dp"
android:id="@+id/instance_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/user_count"/>
<TextView
android:id="@+id/user_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/status_count"/>
<TextView
android:id="@+id/status_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/instance_count"/>
<TextView
android:id="@+id/instance_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="end">
android:layout_marginStart="@dimen/fab_margin"
android:layout_marginEnd="@dimen/fab_margin"
android:orientation="vertical"
android:visibility="gone"
>
<TextView
android:background="@drawable/blue_border"
android:id="@+id/name"
android:textColor="@color/mastodonC4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="italic"
android:textSize="12sp"
android:id="@+id/software"/>
android:layout_gravity="center"
android:gravity="center"
android:layout_margin="10dp"
android:textSize="20sp" />
<TextView
android:layout_margin="5dp"
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="italic"
android:textSize="12sp"
android:id="@+id/version"/>
android:layout_gravity="center"
android:autoLink="web"
android:gravity="center"
android:textSize="14sp" />
<LinearLayout
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/user_count"/>
<TextView
android:id="@+id/user_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/status_count"/>
<TextView
android:id="@+id/status_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/instance_count"/>
<TextView
android:id="@+id/instance_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="end">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="italic"
android:textSize="12sp"
android:id="@+id/software"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="italic"
android:textSize="12sp"
android:id="@+id/version"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_marginTop="20dp"
android:id="@+id/lv_accounts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@null"
android:scrollbars="none" />
<Button
android:id="@+id/close"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="@string/close"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_marginTop="20dp"
android:id="@+id/lv_accounts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@null"
android:scrollbars="none" />
<Button
android:id="@+id/close"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="@string/close"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="@+id/loader"