Exemplo n.º 1
0
 public static String getAppTitle() {
   try {
     return Localization.get("app.display.name");
   } catch (NoLocalizedTextException nlte) {
     return "CommCare";
   }
 }
Exemplo n.º 2
0
 public static String getStringRobust(Context c, int resId, String[] args) {
   String resourceName = c.getResources().getResourceEntryName(resId);
   try {
     return Localization.get("odk_" + resourceName, args);
   } catch (NoLocalizedTextException e) {
     return c.getString(resId, args);
   }
 }
Exemplo n.º 3
0
 public static Spannable getStringSpannableRobust(Context c, int resId, String args) {
   String resourceName = c.getResources().getResourceEntryName(resId);
   String ret = "";
   try {
     ret = Localization.get("odk_" + resourceName, new String[] {args});
   } catch (NoLocalizedTextException e) {
     ret = c.getString(resId, args);
   }
   return MarkupUtil.styleSpannable(c, ret);
 }
Exemplo n.º 4
0
    /*
     * (non-Javadoc)
     * @see org.commcare.android.tasks.templates.CommCareTask#doTaskBackground(java.lang.Object[])
     */
    @Override
    protected Boolean doTaskBackground(Void... params) {
        
        publishProgress(Localization.get("bulk.form.send.start"));

        //sanity check
        if(!(dumpDirectory.isDirectory())){
            return false;
        }
        
        File[] files = dumpDirectory.listFiles();
        int counter = 0;
        
        results = new Long [files.length];
        
        for(int i = 0; i < files.length ; ++i ) {
            //Assume failure
            results[i] = FormUploadUtil.FAILURE;
        }
        
        boolean allSuccessful = true;
        
        for(int i=0;i<files.length;i++){
            
            publishProgress(Localization.get("bulk.send.dialog.progress",new String[]{""+ (i+1)}));
            
            File f = files[i];
            
            if(!(f.isDirectory())){
                Log.e("send","Encountered non form entry in file dump folder at path: " + f.getAbsolutePath());
                CommCareApplication._().reportNotificationMessage(NotificationMessageFactory.message(StockMessages.Send_MalformedFile, new String[] {null, f.getName()}, MALFORMED_FILE_CATEGORY));
                continue;
            }
            try{
                User user = CommCareApplication._().getSession().getLoggedInUser();
                results[i] = FormUploadUtil.sendInstance(counter,f,url, user);
                
                if(results[i] == FormUploadUtil.FULL_SUCCESS){
                    FileUtil.deleteFile(f);
                }
                else if(results[i] == FormUploadUtil.TRANSPORT_FAILURE){
                    allSuccessful = false;
                    publishProgress(Localization.get("bulk.send.transport.error"));
                    return false;
                }
                else{
                    allSuccessful = false;
                    CommCareApplication._().reportNotificationMessage(NotificationMessageFactory.message(StockMessages.Send_MalformedFile, new String[] {null, f.getName()}, MALFORMED_FILE_CATEGORY));
                    publishProgress(Localization.get("bulk.send.file.error", new String[] {f.getAbsolutePath()}));
                }
                counter++;
            } catch(SessionUnavailableException | FileNotFoundException fe){
                Log.e("E", Localization.get("bulk.send.file.error", new String[] {f.getAbsolutePath()}), fe);
                publishProgress(Localization.get("bulk.send.file.error", new String[] {fe.getMessage()}));
            }
        }
        return allSuccessful;
    }
Exemplo n.º 5
0
  public static void setLocale(String locale) {
    if (locale == null || "".equals(locale.trim())) {
      return;
    }
    Localizer localizer = Localization.getGlobalLocalizerAdvanced();
    log.info("Setting locale to : " + locale + " available: " + localizer.getAvailableLocales());
    for (String availabile : localizer.getAvailableLocales()) {
      if (locale.equals(availabile)) {
        localizer.setLocale(locale);

        return;
      }
    }
  }
Exemplo n.º 6
0
  public void initWidget(FormEntryPrompt fep, Container c) {
    // #style container
    UiAccess.setStyle(
        c); // it is dubious whether this works properly; Chatterbox.babysitStyles() takes care of
            // this for now

    // #style questiontext
    fullPrompt = new Container(false);

    // #style prompttext
    prompt = new StringItem(null, null);
    fullPrompt.add(prompt);
    // #style button
    ok = new StringItem(null, Localization.get("button.Next"));
    scrHeight = J2MEDisplay.getScreenHeight(ExpandedWidget.fallback);
    scrWidth = J2MEDisplay.getScreenWidth(ExpandedWidget.fallback);

    c.add(fullPrompt);
    c.add(ok);
  }