Android Open Source - TATupload Parameters






From Project

Back to project page TATupload.

License

The source code is released under:

GNU General Public License

If you think the Android project TATupload 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 uk.org.sucu.tatupload.parse;
// w  w w .  jav  a 2  s. c om
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;

import org.apache.pig.impl.util.ObjectSerializer;

import uk.org.sucu.tatupload.R;
import android.content.Context;

public class Parameters {

  public static final String FLAVOUR_PARAMETER = "uk.org.sucu.tatupload.FLAVOUR_PARAMETER";
  public static final String LOCATION_PARAMETER = "uk.org.sucu.tatupload.LOCATION_PARAMETER";
  public static final String QUESTION_PARAMETER = "uk.org.sucu.tatupload.QUESTION_PARAMETER";
  public static final String PARAMETER = "uk.org.sucu.tatupload.PARAMETER"; //identifies a parameter being passed in an intent extra
  
  public static final ArrayList<String> flavourParameter = new ArrayList<String>();
  public static final ArrayList<String> locationParameter = new ArrayList<String>();
  public static final ArrayList<String> questionParameter = new ArrayList<String>();

  public static void restoreDefaults(Context context){
    loadParameters(getDefaultList(FLAVOUR_PARAMETER, context), getDefaultList(LOCATION_PARAMETER, context), getDefaultList(QUESTION_PARAMETER, context));
  }
  
  public static void loadParameters(ArrayList<String> flavour, ArrayList<String> location, ArrayList<String> question){
    loadParameter(FLAVOUR_PARAMETER, flavour);
    loadParameter(QUESTION_PARAMETER, question);
    loadParameter(LOCATION_PARAMETER, location);
  }
  
  public static void loadParameter(String identifier, ArrayList<String> values){
    if(isValidIdentifier(identifier)){
      ArrayList<String> param = getList(identifier);
      param.clear();
      for(String s : values){
        param.add(s);
      }
    }
  }
  
  public static ArrayList<String> getDefaultList(String identifier, Context context){
    if(identifier.equals(FLAVOUR_PARAMETER)){
      String[] defaults = context.getResources().getStringArray(R.array.default_flavours);
      return new ArrayList<String>(Arrays.asList(defaults));
    } else if(identifier.equals(LOCATION_PARAMETER)){
      String[] defaults = context.getResources().getStringArray(R.array.default_locations);
      return new ArrayList<String>(Arrays.asList(defaults));
    } else if(identifier.equals(QUESTION_PARAMETER)){
      String[] defaults = context.getResources().getStringArray(R.array.default_questions);
      return new ArrayList<String>(Arrays.asList(defaults));
    }
    return null;
  }
  
  public static ArrayList<String> getList(String identifier){
    if(identifier.equals(FLAVOUR_PARAMETER)){
      return flavourParameter;
    } else if(identifier.equals(LOCATION_PARAMETER)){
      return locationParameter;
    } else if(identifier.equals(QUESTION_PARAMETER)){
      return questionParameter;
    }
    return null;
  }
  
  public static String getParamHeading(String identifier, Context c){
    
    if(isValidIdentifier(identifier)){
      if(identifier.equals(FLAVOUR_PARAMETER)){
        return c.getString(R.string.flavour_heading);
      }
      if(identifier.equals(LOCATION_PARAMETER)){
        return c.getString(R.string.location_heading);
      }
      if(identifier.equals(QUESTION_PARAMETER)){
        return c.getString(R.string.question_heading);
      }
    }
    
    return c.getString(R.string.invalid_heading);
        
  }
  
  public static String getParamExplanation(String identifier, Context c){
    if(isValidIdentifier(identifier)){
      if(identifier.equals(FLAVOUR_PARAMETER)){
        return c.getString(R.string.flavour_explanation);
      }
      if(identifier.equals(LOCATION_PARAMETER)){
        return c.getString(R.string.location_explanation);
      }
      if(identifier.equals(QUESTION_PARAMETER)){
        return c.getString(R.string.question_explanation);
      }
    }
    
    return c.getString(R.string.invalid_heading);
      
  }
  
  public static String getAsSerialString(String identifier)throws IOException{
    ArrayList<String> list = getList(identifier);
    
    return ObjectSerializer.serialize(list);
  }
  
  public static boolean isValidIdentifier(String identifier){
    if(getList(identifier) == null){
      return false;
    } else {
      return true;
    }
  }

}




Java Source Code List

org.apache.pig.impl.util.ObjectSerializer.java
uk.org.sucu.tatupload.BrowserAccessor.java
uk.org.sucu.tatupload.MessageArrayAdapter.java
uk.org.sucu.tatupload.NetCaller.java
uk.org.sucu.tatupload.Notifications.java
uk.org.sucu.tatupload.ParameterArrayAdapter.java
uk.org.sucu.tatupload.ResolveInfoArrayAdapter.java
uk.org.sucu.tatupload.Settings.java
uk.org.sucu.tatupload.TabContent.java
uk.org.sucu.tatupload.TabManager.java
uk.org.sucu.tatupload.TatUploadApplication.java
uk.org.sucu.tatupload.activity.MainActivity.java
uk.org.sucu.tatupload.activity.OptionActivity.java
uk.org.sucu.tatupload.activity.ParameterViewActivity.java
uk.org.sucu.tatupload.activity.SmsReviewActivity.java
uk.org.sucu.tatupload.activity.TutorialActivity.java
uk.org.sucu.tatupload.message.SmsList.java
uk.org.sucu.tatupload.message.SmsReceiver.java
uk.org.sucu.tatupload.message.Text.java
uk.org.sucu.tatupload.parse.Parameters.java
uk.org.sucu.tatupload.parse.Parser.java
uk.org.sucu.tatupload.parse.Property.java