Android Open Source - GroupSmart-Android Feedback






From Project

Back to project page GroupSmart-Android.

License

The source code is released under:

Copyright (C) <2014> <Derek Argueta - Hunter Kehoe> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), ...

If you think the Android project GroupSmart-Android 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.dargueta.groupsmart;
/*  w  w w.  ja  v  a 2  s  . c om*/
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.google.analytics.tracking.android.EasyTracker;

/**
 * 
 * @author Hunter Kehoe
 * 
 * Creates and controls the view for the page where the user can type up feedback that will be sent
 * to us.
 *
 */
public class Feedback extends Activity {
  
  String message = "";
  String feedbackURL = "";
  EditText etMessage;
  Button submit;
  
  public void onCreate(Bundle savedInstanceState) {
    
    super.onCreate(savedInstanceState);
    setContentView(R.layout.feedback);
    
    etMessage = (EditText) findViewById(R.id.etMessage);
    submit = (Button) findViewById(R.id.btnSubmit);
    
    submit.setOnClickListener(new OnClickListener() {
      
      public void onClick(View v) {
        
        message = etMessage.getText().toString();
        
        if (message.length() == 0) {
          
          Toast.makeText(getApplicationContext(), "Please provide a message", Toast.LENGTH_SHORT).show();
          return;
          
        } else {
          
          message = message.replaceAll(Constants.NORMAL_SPACE, Constants.URL_SPACE);
          
          SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
          String userId = String.valueOf(prefs.getInt(Constants.ID_KEY, -1));
          
          feedbackURL = Constants.BASE_URL+"mode=guf&m="+message+"&id="+userId;
          new SendFeedback().execute();
        }
      }
    });
  }
  
  /**
   * 
   * @author Hunter Kehoe
   * 
   * Asynchronously send the results to the remote database
   *
   */
  private class SendFeedback extends AsyncTask<Void, Void, Void> {  
    
    boolean successful = false;
    
    ProgressDialog pDialog;
    
    protected void onPreExecute() {
      
      super.onPreExecute();
      pDialog = new ProgressDialog(Feedback.this);
      pDialog.setMessage(getString(R.string.pleaseWait));
      pDialog.setCancelable(false);
      pDialog.show();
    }
    
    protected Void doInBackground(Void... arg0) {
      
      ServiceHandler sh = new ServiceHandler();
      String jsonStr = sh.makeServiceCall(feedbackURL, ServiceHandler.GET);
      
      if (jsonStr.equals("SUCCESSFUL")) {
        
        successful = true;
      }
          
      return null;
    }
    
    protected void onPostExecute(Void result) {
      
      super.onPostExecute(result);
      
      if(pDialog.isShowing()) {
        
        pDialog.dismiss();
      }
      
      if (successful) {
        
        Toast.makeText(getApplicationContext(), "Thank you for your comments", Toast.LENGTH_SHORT).show();
        finish();
      }
    }
  }
  
  // Google Analytics
  public void onStart() {
    
    super.onStart();
    EasyTracker.getInstance(this).activityStart(this);
  }
  
  public void onStop() {
    
    super.onStop();
    EasyTracker.getInstance(this).activityStop(this);
  }
}




Java Source Code List

com.dargueta.groupsmart.ChangePassword.java
com.dargueta.groupsmart.Constants.java
com.dargueta.groupsmart.CourseSelect.java
com.dargueta.groupsmart.CreateGroup.java
com.dargueta.groupsmart.Feedback.java
com.dargueta.groupsmart.FindGroup.java
com.dargueta.groupsmart.GroupInfo.java
com.dargueta.groupsmart.Login.java
com.dargueta.groupsmart.Main.java
com.dargueta.groupsmart.MajorSelect.java
com.dargueta.groupsmart.Profile.java
com.dargueta.groupsmart.Register.java
com.dargueta.groupsmart.ServiceHandler.java
com.dargueta.groupsmart.Settings.java
com.dargueta.groupsmart.UpdateGroup.java
com.dargueta.groupsmart.UpdateProfile.java