Android Open Source - Android-Cloud-Storage-Application User Functions






From Project

Back to project page Android-Cloud-Storage-Application.

License

The source code is released under:

MIT License

If you think the Android project Android-Cloud-Storage-Application listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.cloudaltas.library;
// w w w  . ja  va  2  s.co m
import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;

import android.content.Context;

public class UserFunctions {
  
  private JSONParser jsonParser;
  
  private static String loginURL = "http://www.visitit.hostei.com/";
  private static String registerURL = "http://www.visitit.hostei.com/index.php";
  
  private static String login_tag = "login";
  private static String register_tag = "register";
  
  // constructor
  public UserFunctions(){
    jsonParser = new JSONParser();
  }
  
  /**
   * function make Login Request
   * @param email
   * @param password
   * */
  public JSONObject loginUser(String email, String password){
    // Building Parameters
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("tag", login_tag));
    params.add(new BasicNameValuePair("email", email));
    params.add(new BasicNameValuePair("password", password));
    JSONObject json = jsonParser.getJSONFromUrl(loginURL, params);
    // return json
    // Log.e("JSON", json.toString());
    return json;
  }
  
  /**
   * function make Login Request
   * @param name
   * @param email
   * @param password
   * */
  public JSONObject registerUser(String name, String email, String password){
    // Building Parameters
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("tag", register_tag));
    params.add(new BasicNameValuePair("name", name));
    params.add(new BasicNameValuePair("email", email));
    params.add(new BasicNameValuePair("password", password));
    
    // getting JSON Object
    JSONObject json = jsonParser.getJSONFromUrl(registerURL, params);
    // return json
    return json;
  }
  
  /**
   * Function get Login status
   * */
  public boolean isUserLoggedIn(Context context){
    DatabaseHandler db = new DatabaseHandler(context);
    int count = db.getRowCount();
    if(count > 0){
      // user logged in
      return true;
    }
    return false;
  }
  
  /**
   * Function to logout user
   * Reset Database
   * */
  public boolean logoutUser(Context context){
    DatabaseHandler db = new DatabaseHandler(context);
    db.resetTables();
    return true;
  }
  
}




Java Source Code List

com.example.cloudaltas.Base64.java
com.example.cloudaltas.DashboardActivity.java
com.example.cloudaltas.FullscreenActivity.java
com.example.cloudaltas.LoginActivity.java
com.example.cloudaltas.RegisterActivity.java
com.example.cloudaltas.UploadImage.java
com.example.cloudaltas.library.DatabaseHandler.java
com.example.cloudaltas.library.JSONParser.java
com.example.cloudaltas.library.UserFunctions.java
com.example.cloudaltas.util.SystemUiHiderBase.java
com.example.cloudaltas.util.SystemUiHiderHoneycomb.java
com.example.cloudaltas.util.SystemUiHider.java
com.example.cloudaltas.first.java
com.example.cloudaltas.hello.java