mirror of
				https://github.com/pierre42100/ComunicAndroid
				synced 2025-11-04 03:24:04 +00:00 
			
		
		
		
	Can search users.
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
			
		||||
package org.communiquons.android.comunic.client.ui.activities;
 | 
			
		||||
 | 
			
		||||
import android.app.Activity;
 | 
			
		||||
import android.app.AlertDialog;
 | 
			
		||||
import android.app.FragmentTransaction;
 | 
			
		||||
import android.content.DialogInterface;
 | 
			
		||||
@@ -59,6 +60,11 @@ public class MainActivity extends AppCompatActivity implements openConversationL
 | 
			
		||||
     */
 | 
			
		||||
    private static final String TAG = "MainActivity";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Intent code : search a user
 | 
			
		||||
     */
 | 
			
		||||
    private static final int SEARCH_USER_INTENT = 3;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Account object
 | 
			
		||||
     */
 | 
			
		||||
@@ -184,6 +190,12 @@ public class MainActivity extends AppCompatActivity implements openConversationL
 | 
			
		||||
        //Get action id
 | 
			
		||||
        int id = item.getItemId();
 | 
			
		||||
 | 
			
		||||
        //To search a user
 | 
			
		||||
        if(id == R.id.action_search_user){
 | 
			
		||||
            searchUser();
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //To display the personal page of the user
 | 
			
		||||
        if(id == R.id.action_open_user_page){
 | 
			
		||||
            openUserPage(AccountUtils.getID(MainActivity.this));
 | 
			
		||||
@@ -218,6 +230,28 @@ public class MainActivity extends AppCompatActivity implements openConversationL
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
 | 
			
		||||
 | 
			
		||||
        //Parent level
 | 
			
		||||
        super.onActivityResult(requestCode, resultCode, data);
 | 
			
		||||
 | 
			
		||||
        //Check if the request was to search a user
 | 
			
		||||
        if(resultCode == Activity.RESULT_OK){
 | 
			
		||||
 | 
			
		||||
            switch (requestCode){
 | 
			
		||||
 | 
			
		||||
                case SEARCH_USER_INTENT:
 | 
			
		||||
                    assert data.getData() != null;
 | 
			
		||||
                    openUserPage(Integer.decode(data.getData().getQueryParameter("userID")));
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Bottom menu creation
 | 
			
		||||
     */
 | 
			
		||||
@@ -537,4 +571,15 @@ public class MainActivity extends AppCompatActivity implements openConversationL
 | 
			
		||||
            Toast.makeText(this, R.string.success_clear_local_db, Toast.LENGTH_SHORT).show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Open a search activity to find a user
 | 
			
		||||
     */
 | 
			
		||||
    private void searchUser(){
 | 
			
		||||
 | 
			
		||||
        //Make intent
 | 
			
		||||
        Intent intent = new Intent(this, SearchUserActivity.class);
 | 
			
		||||
        startActivityForResult(intent, SEARCH_USER_INTENT);
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,11 @@
 | 
			
		||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
 | 
			
		||||
    xmlns:app="http://schemas.android.com/apk/res-auto">
 | 
			
		||||
 | 
			
		||||
    <!-- Search user -->
 | 
			
		||||
    <item
 | 
			
		||||
        android:id="@+id/action_search_user"
 | 
			
		||||
        android:title="@string/main_menu_search_user"/>
 | 
			
		||||
 | 
			
		||||
    <!-- Open user page -->
 | 
			
		||||
    <item
 | 
			
		||||
        android:id="@+id/action_open_user_page"
 | 
			
		||||
 
 | 
			
		||||
@@ -189,4 +189,5 @@
 | 
			
		||||
    <string name="fragment_latestposts_title">Latest posts</string>
 | 
			
		||||
    <string name="err_get_latest_posts">An error occurred while trying to retrieve the list of latest posts!</string>
 | 
			
		||||
    <string name="notice_no_latest_posts">You do not have any latest posts to display here.</string>
 | 
			
		||||
    <string name="main_menu_search_user">Search user</string>
 | 
			
		||||
</resources>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user