mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
Android - People - Visit Online connections working
This commit is contained in:
parent
81e24bb28e
commit
3217f61a53
7 changed files with 72 additions and 2 deletions
|
@ -209,6 +209,11 @@ JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeGotoUr
|
||||||
DependencyManager::get<AddressManager>()->loadSettings(jniUrl.toString());
|
DependencyManager::get<AddressManager>()->loadSettings(jniUrl.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeGoToUser(JNIEnv* env, jobject obj, jstring username) {
|
||||||
|
QAndroidJniObject jniUsername("java/lang/String", "(Ljava/lang/String;)V", username);
|
||||||
|
DependencyManager::get<AddressManager>()->goToUser(jniUsername.toString(), false);
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnPause(JNIEnv* env, jobject obj) {
|
JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnPause(JNIEnv* env, jobject obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ import com.google.vr.ndk.base.GvrApi;*/
|
||||||
public class InterfaceActivity extends QtActivity implements WebViewFragment.OnWebViewInteractionListener {
|
public class InterfaceActivity extends QtActivity implements WebViewFragment.OnWebViewInteractionListener {
|
||||||
|
|
||||||
public static final String DOMAIN_URL = "url";
|
public static final String DOMAIN_URL = "url";
|
||||||
|
public static final String EXTRA_GOTO_USERNAME = "gotousername";
|
||||||
private static final String TAG = "Interface";
|
private static final String TAG = "Interface";
|
||||||
private static final int WEB_DRAWER_RIGHT_MARGIN = 262;
|
private static final int WEB_DRAWER_RIGHT_MARGIN = 262;
|
||||||
private static final int WEB_DRAWER_BOTTOM_MARGIN = 150;
|
private static final int WEB_DRAWER_BOTTOM_MARGIN = 150;
|
||||||
|
@ -59,6 +60,7 @@ public class InterfaceActivity extends QtActivity implements WebViewFragment.OnW
|
||||||
private native long nativeOnCreate(InterfaceActivity instance, AssetManager assetManager);
|
private native long nativeOnCreate(InterfaceActivity instance, AssetManager assetManager);
|
||||||
private native void nativeOnDestroy();
|
private native void nativeOnDestroy();
|
||||||
private native void nativeGotoUrl(String url);
|
private native void nativeGotoUrl(String url);
|
||||||
|
private native void nativeGoToUser(String username);
|
||||||
private native void nativeBeforeEnterBackground();
|
private native void nativeBeforeEnterBackground();
|
||||||
private native void nativeEnterBackground();
|
private native void nativeEnterBackground();
|
||||||
private native void nativeEnterForeground();
|
private native void nativeEnterForeground();
|
||||||
|
@ -280,6 +282,9 @@ public class InterfaceActivity extends QtActivity implements WebViewFragment.OnW
|
||||||
if (intent.hasExtra(DOMAIN_URL)) {
|
if (intent.hasExtra(DOMAIN_URL)) {
|
||||||
webSlidingDrawer.setVisibility(View.GONE);
|
webSlidingDrawer.setVisibility(View.GONE);
|
||||||
nativeGotoUrl(intent.getStringExtra(DOMAIN_URL));
|
nativeGotoUrl(intent.getStringExtra(DOMAIN_URL));
|
||||||
|
} else if (intent.hasExtra(EXTRA_GOTO_USERNAME)) {
|
||||||
|
webSlidingDrawer.setVisibility(View.GONE);
|
||||||
|
nativeGoToUser(intent.getStringExtra(EXTRA_GOTO_USERNAME));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,8 @@ import io.highfidelity.hifiinterface.task.DownloadProfileImageTask;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener,
|
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener,
|
||||||
LoginFragment.OnLoginInteractionListener,
|
LoginFragment.OnLoginInteractionListener,
|
||||||
HomeFragment.OnHomeInteractionListener {
|
HomeFragment.OnHomeInteractionListener,
|
||||||
|
FriendsFragment.OnHomeInteractionListener {
|
||||||
|
|
||||||
private static final int PROFILE_PICTURE_PLACEHOLDER = R.drawable.default_profile_avatar;
|
private static final int PROFILE_PICTURE_PLACEHOLDER = R.drawable.default_profile_avatar;
|
||||||
public static final String DEFAULT_FRAGMENT = "Home";
|
public static final String DEFAULT_FRAGMENT = "Home";
|
||||||
|
@ -251,6 +252,14 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void goToUser(String username) {
|
||||||
|
Intent intent = new Intent(this, InterfaceActivity.class);
|
||||||
|
intent.putExtra(InterfaceActivity.EXTRA_GOTO_USERNAME, username);
|
||||||
|
finish();
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoginCompleted() {
|
public void onLoginCompleted() {
|
||||||
loadHomeFragment();
|
loadHomeFragment();
|
||||||
|
@ -280,6 +289,11 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
loadPrivacyPolicyFragment();
|
loadPrivacyPolicyFragment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onVisitUserSelected(String username) {
|
||||||
|
goToUser(username);
|
||||||
|
}
|
||||||
|
|
||||||
private class RoundProfilePictureCallback implements Callback {
|
private class RoundProfilePictureCallback implements Callback {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.highfidelity.hifiinterface.fragment;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
@ -32,6 +33,8 @@ public class FriendsFragment extends Fragment {
|
||||||
private EndpointUsersProvider mUsersProvider;
|
private EndpointUsersProvider mUsersProvider;
|
||||||
private String mSelectedUsername;
|
private String mSelectedUsername;
|
||||||
|
|
||||||
|
private OnHomeInteractionListener mListener;
|
||||||
|
|
||||||
public FriendsFragment() {
|
public FriendsFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
}
|
}
|
||||||
|
@ -65,6 +68,15 @@ public class FriendsFragment extends Fragment {
|
||||||
|
|
||||||
rootView.findViewById(R.id.userActionDelete).setOnClickListener(view -> onRemoveConnectionClick());
|
rootView.findViewById(R.id.userActionDelete).setOnClickListener(view -> onRemoveConnectionClick());
|
||||||
|
|
||||||
|
rootView.findViewById(R.id.userActionVisit).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (mListener != null && mSelectedUsername != null) {
|
||||||
|
mListener.onVisitUserSelected(mSelectedUsername);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mUsersAdapter.setClickListener(new UserListAdapter.ItemClickListener() {
|
mUsersAdapter.setClickListener(new UserListAdapter.ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(View view, int position, UserListAdapter.User user) {
|
public void onItemClick(View view, int position, UserListAdapter.User user) {
|
||||||
|
@ -135,4 +147,19 @@ public class FriendsFragment extends Fragment {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
if (context instanceof OnHomeInteractionListener) {
|
||||||
|
mListener = (OnHomeInteractionListener) context;
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException(context.toString()
|
||||||
|
+ " must implement OnHomeInteractionListener");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnHomeInteractionListener {
|
||||||
|
void onVisitUserSelected(String username);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,10 @@ public class EndpointUsersProvider implements UsersProvider {
|
||||||
adapterUser.imageUrl = user.images.thumbnail;
|
adapterUser.imageUrl = user.images.thumbnail;
|
||||||
adapterUser.name = user.username;
|
adapterUser.name = user.username;
|
||||||
adapterUser.online = user.online;
|
adapterUser.online = user.online;
|
||||||
|
adapterUser.locationName = (user.location != null ?
|
||||||
|
(user.location.root != null ? user.location.root.name :
|
||||||
|
(user.location.domain != null ? user.location.domain.name : ""))
|
||||||
|
: "");
|
||||||
adapterUsers.add(adapterUser);
|
adapterUsers.add(adapterUser);
|
||||||
}
|
}
|
||||||
usersCallback.retrieveOk(adapterUsers);
|
usersCallback.retrieveOk(adapterUsers);
|
||||||
|
@ -199,6 +203,7 @@ public class EndpointUsersProvider implements UsersProvider {
|
||||||
boolean online;
|
boolean online;
|
||||||
String connection;
|
String connection;
|
||||||
Images images;
|
Images images;
|
||||||
|
LocationData location;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Images {
|
class Images {
|
||||||
|
@ -208,4 +213,13 @@ public class EndpointUsersProvider implements UsersProvider {
|
||||||
String tiny;
|
String tiny;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class LocationData {
|
||||||
|
public LocationData() {}
|
||||||
|
NameContainer root;
|
||||||
|
NameContainer domain;
|
||||||
|
}
|
||||||
|
class NameContainer {
|
||||||
|
String name;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,10 +70,12 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.ViewHo
|
||||||
public void onBindViewHolder(UserListAdapter.ViewHolder holder, int position) {
|
public void onBindViewHolder(UserListAdapter.ViewHolder holder, int position) {
|
||||||
User aUser = mUsers.get(position);
|
User aUser = mUsers.get(position);
|
||||||
holder.mUsername.setText(aUser.name);
|
holder.mUsername.setText(aUser.name);
|
||||||
|
|
||||||
holder.mOnlineInfo.setVisibility(aUser.online? View.VISIBLE : View.GONE);
|
holder.mOnlineInfo.setVisibility(aUser.online? View.VISIBLE : View.GONE);
|
||||||
|
holder.mLocation.setText("- " + aUser.locationName); // Bring info from the API and use it here
|
||||||
|
|
||||||
holder.mFriendStar.onBindSet(aUser.name, aUser.connection.equals(UsersProvider.CONNECTION_TYPE_FRIEND));
|
holder.mFriendStar.onBindSet(aUser.name, aUser.connection.equals(UsersProvider.CONNECTION_TYPE_FRIEND));
|
||||||
Uri uri = Uri.parse(aUser.imageUrl);
|
Uri uri = Uri.parse(aUser.imageUrl);
|
||||||
holder.mLocation.setText(" - unknown"); // Bring info from the API and use it here
|
|
||||||
Picasso.get().load(uri).into(holder.mImage, new RoundProfilePictureCallback(holder.mImage));
|
Picasso.get().load(uri).into(holder.mImage, new RoundProfilePictureCallback(holder.mImage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +215,8 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.ViewHo
|
||||||
public String connection;
|
public String connection;
|
||||||
public boolean online;
|
public boolean online;
|
||||||
|
|
||||||
|
public String locationName;
|
||||||
|
|
||||||
public User() {}
|
public User() {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
android:id="@+id/userLocation"
|
android:id="@+id/userLocation"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="3dp"
|
||||||
android:fontFamily="@font/raleway_italic"
|
android:fontFamily="@font/raleway_italic"
|
||||||
android:textColor="@color/menuOption"/>
|
android:textColor="@color/menuOption"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
Loading…
Reference in a new issue