mirror of
https://github.com/sismics/docs.git
synced 2024-11-25 15:17:57 +01:00
Closes #18: Android: Group profile
This commit is contained in:
parent
a81474b40a
commit
6598b585a2
@ -54,6 +54,9 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".activity.UserProfileActivity">
|
android:name=".activity.UserProfileActivity">
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".activity.GroupProfileActivity">
|
||||||
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.SettingsActivity"
|
android:name=".activity.SettingsActivity"
|
||||||
android:label="@string/settings">
|
android:label="@string/settings">
|
||||||
|
@ -659,6 +659,10 @@ public class DocumentViewActivity extends AppCompatActivity {
|
|||||||
Intent intent = new Intent(DocumentViewActivity.this, UserProfileActivity.class);
|
Intent intent = new Intent(DocumentViewActivity.this, UserProfileActivity.class);
|
||||||
intent.putExtra("username", acl.getName());
|
intent.putExtra("username", acl.getName());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
} else if (acl.getType().equals("GROUP")) {
|
||||||
|
Intent intent = new Intent(DocumentViewActivity.this, GroupProfileActivity.class);
|
||||||
|
intent.putExtra("name", acl.getName());
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,92 @@
|
|||||||
|
package com.sismics.docs.activity;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.sismics.docs.R;
|
||||||
|
import com.sismics.docs.listener.HttpCallback;
|
||||||
|
import com.sismics.docs.model.application.ApplicationContext;
|
||||||
|
import com.sismics.docs.resource.UserResource;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Group profile activity.
|
||||||
|
*
|
||||||
|
* @author bgamard.
|
||||||
|
*/
|
||||||
|
public class GroupProfileActivity extends AppCompatActivity {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// Check if logged in
|
||||||
|
if (!ApplicationContext.getInstance().isLoggedIn()) {
|
||||||
|
startActivity(new Intent(this, LoginActivity.class));
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle activity context
|
||||||
|
if (getIntent() == null) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Input name
|
||||||
|
final String name = getIntent().getStringExtra("name");
|
||||||
|
if (name == null) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup the activity
|
||||||
|
setTitle(name);
|
||||||
|
setContentView(R.layout.groupprofile_activity);
|
||||||
|
if (getSupportActionBar() != null) {
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
getSupportActionBar().setHomeButtonEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the group and populate the view
|
||||||
|
final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
|
||||||
|
final View layoutView = findViewById(R.id.layout);
|
||||||
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
layoutView.setVisibility(View.GONE);
|
||||||
|
UserResource.get(this, name, new HttpCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(JSONObject json) {
|
||||||
|
TextView membersTextView = (TextView) findViewById(R.id.membersTextView);
|
||||||
|
JSONArray members = json.optJSONArray("members");
|
||||||
|
String output = "";
|
||||||
|
for (int i = 0; i < members.length(); i++) {
|
||||||
|
output += members.optString(i) + "; ";
|
||||||
|
}
|
||||||
|
membersTextView.setText(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinish() {
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
layoutView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case android.R.id.home:
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
@ -30,7 +30,6 @@ import org.json.JSONObject;
|
|||||||
* @author bgamard
|
* @author bgamard
|
||||||
*/
|
*/
|
||||||
public class LoginActivity extends AppCompatActivity {
|
public class LoginActivity extends AppCompatActivity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User interface.
|
* User interface.
|
||||||
*/
|
*/
|
||||||
|
@ -42,7 +42,6 @@ import org.json.JSONObject;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private ActionBarDrawerToggle drawerToggle;
|
private ActionBarDrawerToggle drawerToggle;
|
||||||
private MenuItem searchItem;
|
private MenuItem searchItem;
|
||||||
private DrawerLayout drawerLayout;
|
private DrawerLayout drawerLayout;
|
||||||
|
@ -12,7 +12,6 @@ import com.sismics.docs.fragment.SettingsFragment;
|
|||||||
* @author bgamard.
|
* @author bgamard.
|
||||||
*/
|
*/
|
||||||
public class SettingsActivity extends AppCompatActivity {
|
public class SettingsActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -2,7 +2,6 @@ package com.sismics.docs.activity;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceGroup;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -22,7 +21,6 @@ import org.json.JSONObject;
|
|||||||
* @author bgamard.
|
* @author bgamard.
|
||||||
*/
|
*/
|
||||||
public class UserProfileActivity extends AppCompatActivity {
|
public class UserProfileActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/layout"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/membersTextView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
style="?android:attr/progressBarStyleLarge"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:indeterminate="true" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
Loading…
Reference in New Issue
Block a user