Merge pull request #804 from SamWhited/server-info

Server info
This commit is contained in:
Daniel Gultsch 2014-12-23 18:55:22 +01:00
commit 45ef112b0c
4 changed files with 151 additions and 7 deletions

View File

@ -19,6 +19,7 @@ import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast;
@ -42,10 +43,15 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
private CheckBox mRegisterNew;
private Button mCancelButton;
private Button mSaveButton;
private TableLayout mMoreTable;
private LinearLayout mStats;
private TextView mServerInfoSm;
private TextView mServerInfoRosterVersion;
private TextView mServerInfoCarbons;
private TextView mServerInfoMam;
private TextView mServerInfoCSI;
private TextView mServerInfoBlocking;
private TextView mServerInfoPep;
private TextView mSessionEst;
private TextView mOtrFingerprint;
@ -292,7 +298,11 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
this.mRegisterNew = (CheckBox) findViewById(R.id.account_register_new);
this.mStats = (LinearLayout) findViewById(R.id.stats);
this.mSessionEst = (TextView) findViewById(R.id.session_est);
this.mServerInfoRosterVersion = (TextView) findViewById(R.id.server_info_roster_version);
this.mServerInfoCarbons = (TextView) findViewById(R.id.server_info_carbons);
this.mServerInfoMam = (TextView) findViewById(R.id.server_info_mam);
this.mServerInfoCSI = (TextView) findViewById(R.id.server_info_csi);
this.mServerInfoBlocking = (TextView) findViewById(R.id.server_info_blocking);
this.mServerInfoSm = (TextView) findViewById(R.id.server_info_sm);
this.mServerInfoPep = (TextView) findViewById(R.id.server_info_pep);
this.mOtrFingerprint = (TextView) findViewById(R.id.otr_fingerprint);
@ -302,6 +312,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
this.mCancelButton = (Button) findViewById(R.id.cancel_button);
this.mSaveButton.setOnClickListener(this.mSaveButtonClickListener);
this.mCancelButton.setOnClickListener(this.mCancelButtonClickListener);
this.mMoreTable = (TableLayout) findViewById(R.id.server_info_more);
this.mRegisterNew
.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@ -384,6 +395,9 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
intent.putExtra("account", mAccount.getJid().toString());
startActivity(intent);
break;
case R.id.action_server_info_show_more:
mMoreTable.setVisibility(item.isChecked() ? View.GONE : View.VISIBLE);
item.setChecked(!item.isChecked());
}
return super.onOptionsItemSelected(item);
}
@ -406,16 +420,36 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
if (this.mAccount.getStatus() == Account.State.ONLINE
&& !this.mFetchingAvatar) {
this.mStats.setVisibility(View.VISIBLE);
this.mSessionEst.setText(UIHelper.readableTimeDifferenceFull(
this.mSessionEst.setText(UIHelper.readableTimeDifference(
getApplicationContext(), this.mAccount.getXmppConnection()
.getLastSessionEstablished()));
final Features features = this.mAccount.getXmppConnection().getFeatures();
Features features = this.mAccount.getXmppConnection().getFeatures();
if (features.rosterVersioning()) {
this.mServerInfoRosterVersion.setText(R.string.server_info_available);
} else {
this.mServerInfoRosterVersion.setText(R.string.server_info_unavailable);
}
if (features.carbons()) {
this.mServerInfoCarbons.setText(R.string.server_info_available);
} else {
this.mServerInfoCarbons
.setText(R.string.server_info_unavailable);
}
if (features.mam()) {
this.mServerInfoMam.setText(R.string.server_info_available);
} else {
this.mServerInfoMam.setText(R.string.server_info_unavailable);
}
if (features.csi()) {
this.mServerInfoCSI.setText(R.string.server_info_available);
} else {
this.mServerInfoCSI.setText(R.string.server_info_unavailable);
}
if (features.blocking()) {
this.mServerInfoBlocking.setText(R.string.server_info_available);
} else {
this.mServerInfoBlocking.setText(R.string.server_info_unavailable);
}
if (features.sm()) {
this.mServerInfoSm.setText(R.string.server_info_available);
} else {

View File

@ -1,5 +1,6 @@
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/secondarybackground" >
@ -118,7 +119,8 @@
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
android:layout_height="wrap_content"
tools:ignore="UselessParent">
<TextView
android:layout_width="wrap_content"
@ -133,9 +135,18 @@
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/primarytext"
android:textSize="?attr/TextSizeBody" />
android:textSize="?attr/TextSizeBody"
tools:ignore="RtlHardcoded"/>
</TableRow>
</TableLayout>
<TableLayout
android:id="@+id/server_info_more"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="1"
android:visibility="gone" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
@ -153,7 +164,29 @@
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/primarytext"
android:textSize="?attr/TextSizeBody"
tools:ignore="RtlHardcoded"/>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_info_blocking"
android:textColor="@color/primarytext"
android:textSize="?attr/TextSizeBody" />
<TextView
android:id="@+id/server_info_blocking"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/primarytext"
android:textSize="?attr/TextSizeBody"
tools:ignore="RtlHardcoded"/>
</TableRow>
<TableRow
@ -173,7 +206,29 @@
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/primarytext"
android:textSize="?attr/TextSizeBody"
tools:ignore="RtlHardcoded"/>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_info_roster_version"
android:textColor="@color/primarytext"
android:textSize="?attr/TextSizeBody" />
<TextView
android:id="@+id/server_info_roster_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/primarytext"
android:textSize="?attr/TextSizeBody"
tools:ignore="RtlHardcoded"/>
</TableRow>
<TableRow
@ -193,12 +248,53 @@
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/primarytext"
android:textSize="?attr/TextSizeBody"
tools:ignore="RtlHardcoded"/>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_info_mam"
android:textColor="@color/primarytext"
android:textSize="?attr/TextSizeBody" />
<TextView
android:id="@+id/server_info_mam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/primarytext"
android:textSize="?attr/TextSizeBody"
tools:ignore="RtlHardcoded"/>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_info_csi"
android:textColor="@color/primarytext"
android:textSize="?attr/TextSizeBody" />
<TextView
android:id="@+id/server_info_csi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/primarytext"
android:textSize="?attr/TextSizeBody"
tools:ignore="RtlHardcoded"/>
</TableRow>
</TableLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
@ -251,6 +347,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" >
@ -281,4 +379,4 @@
android:textColor="@color/secondarytext" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>

View File

@ -4,9 +4,16 @@
android:id="@+id/action_show_qr_code"
android:title="@string/show_qr_code"
android:showAsAction="never" />
<item
android:id="@+id/action_show_block_list"
android:title="@string/show_block_list"
android:showAsAction="never" />
<item
android:id="@+id/action_server_info_show_more"
android:title="@string/server_info_show_more"
android:checkable="true"
android:checked="false"
android:showAsAction="never" />
</menu>

View File

@ -186,7 +186,12 @@
<string name="contact_status_offline">offline</string>
<string name="muc_details_conference">Conference</string>
<string name="muc_details_other_members">Other Members</string>
<string name="server_info_show_more">Server info</string>
<string name="server_info_mam">XEP-0313: MAM</string>
<string name="server_info_carbon_messages">XEP-0280: Message Carbons</string>
<string name="server_info_csi">XEP-0352: Client State Indication</string>
<string name="server_info_blocking">XEP-0191: Blocking Command</string>
<string name="server_info_roster_version">XEP-0237: Roster Versioning</string>
<string name="server_info_stream_management">XEP-0198: Stream Management</string>
<string name="server_info_pep">XEP-0163: PEP (Avatars)</string>
<string name="server_info_available">available</string>