text:
using System;
using System.Linq;
using Telerik.Data.Core;
using Telerik.UI.Xaml.Controls.Grid.Primitives;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Telerik.UI.Xaml.Controls.Grid
{
    internal class XamlGridRowGenerator : IUIContainerGenerator<GridRowModel, RowGenerationContext>
    {
        private const int MaxGroupCount = 20;

        private static Type loadingDataControlType = typeof(DataGridLoadDataControl);
        private static Type groupHeaderType = typeof(DataGridGroupHeader);
        private static object frozenHeader = new object();
        private static Type placeholderModelType = typeof(PlaceholderInfo);

        private RadDataGrid owner;

        public XamlGridRowGenerator(RadDataGrid owner)
        {
            this.owner = owner;
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")]
        public void PrepareContainerForItem(GridRowModel decorator)
        {
            DataGridLoadDataControl control = decorator.Container as DataGridLoadDataControl;

            if (control != null)
            {
                control.Owner = this.owner;
                this.owner.visualStateService.RegisterDataLoadingListener((IDataStatusListener)control);
            }

            this.PrepareGroupRow(decorator, decorator.Container as DataGridGroupHeader);
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")]
        public void ClearContainerForItem(GridRowModel decorator)
        {
            DataGridLoadDataControl control = decorator.Container as DataGridLoadDataControl;

            if (control != null)
            {
                control.Owner = null;
                this.owner.visualStateService.UnregisterDataLoadingListener((IDataStatusListener)control);
            }

            DataGridGroupHeader groupHeader = decorator.Container as DataGridGroupHeader;
            if (groupHeader != null)
            {
                groupHeader.Owner = null;
            }
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")]
        public object GetContainerTypeForItem(RowGenerationContext context)
        {
            var item = context.Info;
            bool isFrozen = context.IsFrozen;

            if (item.IsCollapsible)
            {
                if (isFrozen)
                {
                    return frozenHeader;
                }

                return groupHeaderType;
            }

            if (item.Item.GetType() == placeholderModelType)
            {
                return loadingDataControlType;
            }

            return typeof(object);
        }

        public object GenerateContainerForItem(RowGenerationContext info, object containerType)
        {
            DataGridGroupHeader groupHeader = null;
            //  DataGridGroupHeader frozenGroupHeader = null;

            object generatedContent = null;

            if (groupHeaderType.Equals(containerType))
            {
                groupHeader = new DataGridGroupHeader();
            }
            else if (object.Equals(frozenHeader, containerType))
            {
                // Frozen Headers are placed in different panel (not in cells panel).
                groupHeader = new DataGridGroupHeader(true);
            }

            if (groupHeader != null)
            {
                if (groupHeader.IsFrozen)
                {
                    this.owner.FrozenGroupHeadersHost.Children.Add(groupHeader);
                }
                else
                {
                    var contentLayer = this.owner.GroupHeadersContentLayer;
                    if (contentLayer != null)
                    {
                        contentLayer.AddVisualChild(groupHeader);
                    }
                }

                generatedContent = groupHeader;
            }

            if (containerType != null && containerType.Equals(loadingDataControlType))
            {
                var control = new DataGridLoadDataControl();

                var contentLayer = this.owner.GetContentLayerForColumn(null);
                if (contentLayer != null)
                {
                    contentLayer.AddVisualChild(control);
                }

                generatedContent = control;
            }

            return generatedContent;
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")]
        public void MakeVisible(GridRowModel decorator)
        {
            MakeVisibleCore(decorator.Container as UIElement);
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")]
        public void MakeHidden(GridRowModel decorator)
        {
            MakeHiddenCore(decorator.Container as UIElement);
        }

        public void SetOpacity(GridRowModel decorator, byte opacity)
        {
            if (decorator != null)
            {
                UIElement container = decorator.Container as UIElement;
                if (container != null)
                {
                    container.Opacity = opacity;
                }
            }
        }

        private static void MakeVisibleCore(UIElement container)
        {
            if (container != null)
            {
                container.ClearValue(UIElement.VisibilityProperty);
            }
        }

        private static void MakeHiddenCore(UIElement container)
        {
            if (container != null)
            {
                container.Visibility = Visibility.Collapsed;
                container.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            }
        }

        private void PrepareGroupRow(GridRowModel decorator, DataGridGroupHeader groupHeader)
        {
            if (groupHeader != null)
            {
                groupHeader.Owner = this.owner;

                var context = new GroupHeaderContext()
                {
                    Level = decorator.ItemInfo.Level,
                    Descriptor = this.owner.GroupDescriptors[decorator.ItemInfo.Level],
                    Group = decorator.ItemInfo.Item as IDataGroup,
                    IsExpanded = !decorator.ItemInfo.IsCollapsed,
                    Grid = this.owner
                };
                groupHeader.DataContext = context;
                groupHeader.IsExpanded = context.IsExpanded;

                this.UpdateGroupHeaderStyleAndTemplate(groupHeader, context);

                groupHeader.IndentWidth = this.owner.IndentWidth * decorator.ItemInfo.Level;

                if (groupHeader.IsFrozen)
                {
                    // We assume that no more that 20 GroupDescriptions will be added.
                    // If needed this number can be increased.
                    Canvas.SetZIndex(groupHeader, MaxGroupCount - decorator.ItemInfo.Level);
                }
            }
        }

        private void UpdateGroupHeaderStyleAndTemplate(DataGridGroupHeader groupHeader, GroupHeaderContext context)
        {
            var style = this.owner.GroupHeaderStyle;
            if (style == null)
            {
                if (this.owner.GroupHeaderStyleSelector != null)
                {
                    style = this.owner.GroupHeaderStyleSelector.SelectStyle(context, groupHeader);
                }
            }

            if (style != null)
            {
                groupHeader.Style = style;
            }
            else
            {
                groupHeader.ClearValue(DataGridGroupHeader.StyleProperty);
            }

            var dataTemplate = this.owner.GroupHeaderTemplate;
            if (dataTemplate == null)
            {
                if (this.owner.GroupHeaderTemplateSelector != null)
                {
                    dataTemplate = this.owner.GroupHeaderTemplateSelector.SelectTemplate(context, groupHeader);
                }
            }

            if (dataTemplate != null)
            {
                groupHeader.ContentTemplate = dataTemplate;
            }
            else
            {
                groupHeader.ClearValue(DataGridGroupHeader.ContentTemplateProperty);
            }
        }
    }
}


text:
/*
 * © 2014 by Intellectual Reserve, Inc. All rights reserved.
 */

package org.sonar.plugins.xquery.checks;

import org.apache.commons.lang.StringUtils;
import org.sonar.api.rule.RuleKey;
import org.sonar.check.Priority;
import org.sonar.check.Rule;
import org.sonar.plugins.xquery.parser.XQueryParser;
import org.sonar.plugins.xquery.parser.XQueryTree;
import org.sonar.plugins.xquery.rules.CheckClasses;

/**
 * Checks for usage of text() XPath steps.
 *
 * @since 1.0
 */
@Rule(
    key = OperationsInPredicateCheck.RULE_KEY,
    name = "Avoid Operations in Predicates",
    description = "Instead of calling functions or performing operations in predicates " +
            "try assigning the results to a variable before the predicate.",
    priority = Priority.MAJOR
)
public class OperationsInPredicateCheck extends AbstractPredicateCheck {
    // TODO: Either create a new check for or add to this checks for operations in xdmp:directory()
    // TODO: Support for fn:local-name(), fn:name(), fn:node-name()?

    public static final String RULE_KEY = "OperationsInPredicate";
    private static final RuleKey RULE = RuleKey.of(CheckClasses.REPOSITORY_KEY, RULE_KEY);

    private static final String[] FUNCTIONS = new String[] { "data", "last", "not", "exists", "xs:integer", "string", "xs:decimal", "xs:double", "xs:float", "xs:date", "xs:dateTime", "xs:time", "xs:dayTimeDuration", "xs:yearMonthDuration", "xs:duration" };
    private static final String[] EXPRESSIONS = new String[] { "UnaryExpr +", "UnaryExpr -", "UnaryExpr div", "UnaryExpr *", "UnaryExpr mod" };

    @Override
    public void enterExpression(XQueryTree node) {
        super.enterExpression(node);

        if (XQueryParser.Predicate == node.getType()) {
            // Save the state of being in a predicate
            enterPredicate();

            // Operators in predicates are invalid, create violations for any
            String value = node.getValue();
            for (String expression : EXPRESSIONS) {
                if (StringUtils.contains(value, expression)) {
                    createIssue(RULE, node.getLine());
                }
            }
        }

        // Function calls in predicates are invalid
        if (inPredicate() && XQueryParser.FunctionCall == node.getType()) {
            boolean valid = false;

            // Look to see if the function is one of the "valid" ones
            String functionName = node.getTextValue("FunctionName.QName");
            for (String function : FUNCTIONS) {
                if (StringUtils.endsWith(functionName, function)) {
                    valid = true;
                }
            }

            // If the function call is not "valid" then create a violation
            if (!valid) {
                createIssue(RULE, node.getLine());
            }

        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
package com.mql4j.examples;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.UUID;

import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Codec {
	private final static String ENCODING = "UTF-8";
	private final static Logger log = LoggerFactory.getLogger(Codec.class);

	public static String md5(final String str) throws UnsupportedEncodingException, NoSuchAlgorithmException {
		log.info(String.format("Calculate md5 hash for %d bytes", str.length()));
		return DigestUtils.md5Hex(str);
	}

	public static String sha2(final String str) throws UnsupportedEncodingException, NoSuchAlgorithmException {
		log.info(String.format("Calculate sha2 hash for %d bytes", str.length()));
		return DigestUtils.sha256Hex(str);
	}

	public static String uuid(final String str) throws UnsupportedEncodingException {
		log.info(String.format("Calculate UUID for %d bytes", str.length()));
		UUID u = UUID.nameUUIDFromBytes(str.getBytes(ENCODING));
		return u.toString();
	}
}


text:
body {
  font-family: "Open Sans", sans-serif;
  margin: 0;
  padding: 0;
  height: 100%;
  font-size: 14px;
  background-color: #233056;
  color: lightcyan;
  text-align: center;
}

h1 {
  margin: 42px;
  font-size: 34px;
  font-weight: 300;
  line-height: 46px;
  padding-bottom: 21px;
  border-bottom: 1px solid orangered;
  text-transform: uppercase
}

label {
  border: 1px solid greenyellow;
  color: lightcyan;
  padding: 15px;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

label[disabled] {
  border: 1px solid red;
}

#input {
  display: none;
}

#imgContainer img {
  padding-top: 50px;
  max-width: calc(100% - 50px);
  height: auto;
}


text:
from distutils.core import setup
setup(
    name = 'smasherstats',
    packages = ['smasherstats'],
    version = '1.3.7',
    description = 'Library for stats gathering on smash players using web scrapers',
    author = 'Michael Krasnitski',
    author_email = 'michael.krasnitski@gmail.com',
    license='MIT',
    url = 'https://github.com/PolarBearITS/smasherstats',
    download_url = 'https://github.com/PolarBearITS/smasherstats/tarball/1.3.7',
    install_requires = [
        'requests',
        'beautifulsoup4',
        'pysmash'
    ]
)


text:
package com.consol.citrus.dsl;

import java.util.LinkedHashMap;
import java.util.Map;

import com.consol.citrus.builder.PathExpressionAdapter;
import com.consol.citrus.builder.WithExpressions;
import com.consol.citrus.message.MessageProcessor;
import com.consol.citrus.validation.context.ValidationContext;
import com.consol.citrus.validation.json.JsonPathMessageProcessor;
import com.consol.citrus.validation.json.JsonPathMessageValidationContext;
import com.consol.citrus.validation.json.JsonPathVariableExtractor;
import com.consol.citrus.variable.VariableExtractor;

/**
 * @author Christoph Deppisch
 */
public class JsonPathSupport implements WithExpressions<JsonPathSupport>, PathExpressionAdapter {

    private final Map<String, Object> expressions = new LinkedHashMap<>();

    /**
     * Static entrance for all JsonPath related Java DSL functionalities.
     * @return
     */
    public static JsonPathSupport jsonPath() {
        return new JsonPathSupport();
    }

    @Override
    public MessageProcessor asProcessor() {
        return new JsonPathMessageProcessor.Builder()
                .expressions(expressions)
                .build();
    }

    @Override
    public VariableExtractor asExtractor() {
        return new JsonPathVariableExtractor.Builder()
                .expressions(expressions)
                .build();
    }

    @Override
    public ValidationContext asValidationContext() {
        return new JsonPathMessageValidationContext.Builder()
                .expressions(expressions)
                .build();
    }

    @Override
    public JsonPathSupport expressions(Map<String, Object> expressions) {
        this.expressions.putAll(expressions);
        return this;
    }

    @Override
    public JsonPathSupport expression(String expression, Object value) {
        expressions.put(expression, value);
        return this;
    }
}


text:
<?php

namespace Enhavo\Bundle\ShopBundle\Document\PDFHelper;

use Enhavo\Bundle\ShopBundle\Document\PDF;

class SubjectHelper implements PDFHelperInterface
{
    use PDFHelperTrait;

    public function __construct(
        private string $subject,
    )
    {
    }

    public function render(PDF $pdf, $options = [])
    {
        $this->reset($pdf, $options);

        $this->setStyle($pdf, $options, Style::STYLE_HEADER);

        $pdf->MultiCell($options['subject_width'],0, $this->subject,0,"L",false,1, $options['margin_left'], $options['subject_margin_top']);
    }
}


text:
package org.odk.collect.android.activities;

import java.security.NoSuchAlgorithmException;
import java.util.Map;

import javax.crypto.NoSuchPaddingException;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.InputType;
import android.text.method.PasswordTransformationMethod;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import org.odk.collect.android.R;
import org.odk.collect.android.application.Collect;
import org.odk.collect.android.preferences.AdminPreferencesActivity;
import org.odk.collect.android.preferences.PreferencesActivity;

import edu.jhuapl.sages.mobile.lib.OdkSecuritySetupActivity;
import edu.jhuapl.sages.mobile.lib.SharedObjects;

/**
 * Responsible for displaying buttons to launch the major activities. Launches some activities based
 * on returns of others.
 *
 * @author Carl Hartung (carlhartung@gmail.com)
 * @author Yaw Anokwa (yanokwa@gmail.com)
 */
public class MainMenuActivity extends Activity {
    private static final String t = "MainMenuActivity";

    private static final int PASSWORD_DIALOG = 1;

    // menu options
    private static final int MENU_PREFERENCES = Menu.FIRST;
    private static final int MENU_ADMIN = Menu.FIRST + 1;

    // buttons
    private Button mEnterDataButton;
    private Button mManageFilesButton;
    private Button mReviewerFilesButton;
    private Button mSendDataButton;
    private Button mSendDataSmsButton;
    private Button mReviewDataButton;
    private Button mGetFormsButton;

    private View mReviewSpacer;
    private View mGetFormsSpacer;

    private AlertDialog mAlertDialog;
    private SharedPreferences mAdminPreferences;

    private static boolean EXIT = true;

    // private static boolean DO_NOT_EXIT = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // must be at the beginning of any activity that can be called from an
        // external intent
        Log.i(t, "Starting up, creating directories");
        try {
            Collect.createODKDirs();
        } catch (RuntimeException e) {
            createErrorDialog(e.getMessage(), EXIT);
            return;
        }

        setContentView(R.layout.main_menu);

        {
            // dynamically construct the "ODK Collect vA.B" string
            TextView mainMenuMessageLabel = (TextView) findViewById(R.id.main_menu_header);
            mainMenuMessageLabel.setText(Collect.getInstance().getVersionedAppName());
        }

        setTitle(getString(R.string.app_name) + " > " + getString(R.string.main_menu));

        mReviewSpacer = findViewById(R.id.review_spacer);
        mGetFormsSpacer = findViewById(R.id.get_forms_spacer);

        mAdminPreferences = this.getSharedPreferences(
                AdminPreferencesActivity.ADMIN_PREFERENCES, 0);

        SharedPreferences securityPreferences = this.getSharedPreferences(OdkSecuritySetupActivity.ODK_PREFS_FILE_NAME, 0);
        boolean isEncryptionOn = securityPreferences.getBoolean("ENCRYPTION_ON", false);
        String aesKey = securityPreferences.getString("KEY_AESKEY", "no key set");

        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(Collect.getInstance());
        settings.edit().putBoolean("ENCRYPTION_ON", isEncryptionOn).commit();

        /**
         * if prefs.isEncryptionOn = TRUE
         *   update CryptoEngine with the saved prefs.aeskey
         *
         * if prefs.isEncryptionOn = FALSE
         */

        if (isEncryptionOn){
        	 try {
                 SharedObjects.reinitCryptoEngine(aesKey);
             } catch (NoSuchAlgorithmException e) {
//                 aeskeyview.setText("Error re-initializing system KEY from saved preferences");
                 e.printStackTrace();
             } catch (NoSuchPaddingException e) {
//                 aeskeyview.setText("Error re-initializing system KEY from saved preferences");
                 e.printStackTrace();
             }
        }

        // enter data button. expects a result.
        mEnterDataButton = (Button) findViewById(R.id.enter_data);
        mEnterDataButton.setText(getString(R.string.enter_data_button));
        mEnterDataButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Collect.getInstance().getActivityLogger().logAction(this, "fillBlankForm", "click");
                Intent i = new Intent(getApplicationContext(), FormChooserList.class);
                startActivity(i);
            }
        });

        // review data button. expects a result.
        mReviewDataButton = (Button) findViewById(R.id.review_data);
        mReviewDataButton.setText(getString(R.string.review_data_button));
        mReviewDataButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Collect.getInstance().getActivityLogger().logAction(this, "editSavedForm", "click");
                Intent i = new Intent(getApplicationContext(), InstanceChooserList.class);
                startActivity(i);
            }
        });

        // send data button. expects a result.
        mSendDataButton = (Button) findViewById(R.id.send_data);
        mSendDataButton.setText(getString(R.string.send_data_button));
        mSendDataButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Collect.getInstance().getActivityLogger().logAction(this, "uploadForms", "click");
                Intent i = new Intent(getApplicationContext(), InstanceUploaderList.class);
                startActivity(i);
        	}
        });

        // send sms data button. expects a result.
        mSendDataSmsButton = (Button) findViewById(R.id.send_data_sms);
        mSendDataSmsButton.setText(getString(R.string.send_data_button_sms));
        mSendDataSmsButton.setOnClickListener(new OnClickListener() {
        	@Override
        	public void onClick(View v) {
                Intent i = new Intent(getApplicationContext(), InstanceSMSerList.class);
                startActivity(i);
        	}});

        // manage forms button. no result expected.
        mGetFormsButton = (Button) findViewById(R.id.get_forms);
        mGetFormsButton.setText(getString(R.string.get_forms));
        mGetFormsButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Collect.getInstance().getActivityLogger()
                        .logAction(this, "downloadBlankForms", "click");
                Intent i = new Intent(getApplicationContext(), FormDownloadList.class);
                startActivity(i);

            }
        });

        // manage forms button. no result expected.
        mManageFilesButton = (Button) findViewById(R.id.manage_forms);
        mManageFilesButton.setText(getString(R.string.manage_files));
        mManageFilesButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Collect.getInstance().getActivityLogger()
                        .logAction(this, "deleteSavedForms", "click");
                Intent i = new Intent(getApplicationContext(), FileManagerTabs.class);
                startActivity(i);
            }
        });

        // review forms button. no result expected.
        mReviewerFilesButton = (Button) findViewById(R.id.review_forms);
        mReviewerFilesButton.setText(getString(R.string.review_all_files));
        mReviewerFilesButton.setOnClickListener(new OnClickListener() {

/*            @Override
            public void onClick(View v) {
                Collect.getInstance().getActivityLogger().logAction(this, "editSavedForm", "click");
                Intent i = new Intent(getApplicationContext(), InstanceChooserList.class);
                startActivity(i);
            }
        });*/
	        @Override
	        public void onClick(View v) {
	        	Collect.getInstance().getActivityLogger().logAction(this, "chooseInstanceForm", "click");
	        	Intent i = new Intent(getApplicationContext(), InstanceChooserListSages.class);
	        	startActivity(i);
	        }
	    });
    }

    @Override
    protected void onResume() {
        super.onResume();

        SharedPreferences securityPreferences = this.getSharedPreferences(OdkSecuritySetupActivity.ODK_PREFS_FILE_NAME, 0);
        boolean isEncryptionOn = securityPreferences.getBoolean("ENCRYPTION_ON", false);
        String aesKey = securityPreferences.getString("KEY_AESKEY", "no key set");

        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(Collect.getInstance());
        settings.edit().putBoolean("ENCRYPTION_ON", isEncryptionOn).commit();

        if (isEncryptionOn){
       	 try {
                SharedObjects.reinitCryptoEngine(aesKey);
            } catch (NoSuchAlgorithmException e) {
//                aeskeyview.setText("Error re-initializing system KEY from saved preferences");
                e.printStackTrace();
            } catch (NoSuchPaddingException e) {
//                aeskeyview.setText("Error re-initializing system KEY from saved preferences");
                e.printStackTrace();
            }
       }

        SharedPreferences sharedPreferences = this.getSharedPreferences(
                AdminPreferencesActivity.ADMIN_PREFERENCES, 0);

        boolean edit = sharedPreferences.getBoolean(AdminPreferencesActivity.KEY_EDIT_SAVED, true);
        if (!edit) {
            mReviewDataButton.setVisibility(View.GONE);
            mReviewSpacer.setVisibility(View.GONE);
        } else {
            mReviewDataButton.setVisibility(View.VISIBLE);
            mReviewSpacer.setVisibility(View.VISIBLE);
        }

        boolean send = sharedPreferences.getBoolean(AdminPreferencesActivity.KEY_SEND_FINALIZED,
                true);
        if (!send) {
            mSendDataButton.setVisibility(View.GONE);
            mReviewSpacer.setVisibility(View.GONE);
        } else {
            mSendDataButton.setVisibility(View.VISIBLE);
            mReviewSpacer.setVisibility(View.VISIBLE);
        }

        boolean get_blank = sharedPreferences.getBoolean(
                AdminPreferencesActivity.KEY_GET_BLANK, true);
        if (!get_blank) {
            mGetFormsButton.setVisibility(View.GONE);
            mGetFormsSpacer.setVisibility(View.GONE);
        } else {
            mGetFormsButton.setVisibility(View.VISIBLE);
            mGetFormsSpacer.setVisibility(View.VISIBLE);
        }

        boolean delete_saved = sharedPreferences.getBoolean(
                AdminPreferencesActivity.KEY_DELETE_SAVED, true);
        if (!delete_saved) {
            mManageFilesButton.setVisibility(View.GONE);
        } else {
            mManageFilesButton.setVisibility(View.VISIBLE);
        }

        boolean review_all_saved = sharedPreferences.getBoolean(AdminPreferencesActivity.KEY_REVIEW_ALL_SAVED, true);
        if (!review_all_saved) {
        	mReviewerFilesButton.setVisibility(View.GONE);
        } else {
        	mReviewerFilesButton.setVisibility(View.VISIBLE);
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        if (mAlertDialog != null && mAlertDialog.isShowing()) {
            mAlertDialog.dismiss();
        }
    }

    @Override
    protected void onStart() {
        super.onStart();
        Collect.getInstance().getActivityLogger().logOnStart(this);
    }

    @Override
    protected void onStop() {
        Collect.getInstance().getActivityLogger().logOnStop(this);
        super.onStop();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        Collect.getInstance().getActivityLogger().logAction(this, "onCreateOptionsMenu", "show");
        super.onCreateOptionsMenu(menu);
        menu.add(0, MENU_PREFERENCES, 0, getString(R.string.general_preferences)).setIcon(
                android.R.drawable.ic_menu_preferences);
        menu.add(0, MENU_ADMIN, 0, getString(R.string.admin_preferences)).setIcon(
                R.drawable.ic_menu_login);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case MENU_PREFERENCES:
                Collect.getInstance()
                        .getActivityLogger()
                        .logAction(this, "onOptionsItemSelected",
                                "MENU_PREFERENCES");
                Intent ig = new Intent(this, PreferencesActivity.class);
                startActivity(ig);
                return true;
            case MENU_ADMIN:
                Collect.getInstance().getActivityLogger()
                        .logAction(this, "onOptionsItemSelected", "MENU_ADMIN");
                String pw = mAdminPreferences.getString(AdminPreferencesActivity.KEY_ADMIN_PW, "");
                if ("".equalsIgnoreCase(pw)) {
                    Intent i = new Intent(getApplicationContext(), AdminPreferencesActivity.class);
                    startActivity(i);
                } else {
                    showDialog(PASSWORD_DIALOG);
                    Collect.getInstance().getActivityLogger()
                            .logAction(this, "createAdminPasswordDialog", "show");
                }
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

    private void createErrorDialog(String errorMsg, final boolean shouldExit) {
        Collect.getInstance().getActivityLogger().logAction(this, "createErrorDialog", "show");
        mAlertDialog = new AlertDialog.Builder(this).create();
        mAlertDialog.setIcon(android.R.drawable.ic_dialog_info);
        mAlertDialog.setMessage(errorMsg);
        DialogInterface.OnClickListener errorListener = new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int i) {
                switch (i) {
                    case DialogInterface.BUTTON1:
                        Collect.getInstance()
                                .getActivityLogger()
                                .logAction(this, "createErrorDialog",
                                        shouldExit ? "exitApplication" : "OK");
                        if (shouldExit) {
                            finish();
                        }
                        break;
                }
            }
        };
        mAlertDialog.setCancelable(false);
        mAlertDialog.setButton(getString(R.string.ok), errorListener);
        mAlertDialog.show();
    }

    @Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
            case PASSWORD_DIALOG:

                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                final AlertDialog passwordDialog = builder.create();

                passwordDialog.setTitle(getString(R.string.enter_admin_password));
                final EditText input = new EditText(this);
                input.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
                input.setTransformationMethod(PasswordTransformationMethod.getInstance());
                passwordDialog.setView(input, 20, 10, 20, 10);

                passwordDialog.setButton(AlertDialog.BUTTON_POSITIVE,
                        getString(R.string.ok),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                String value = input.getText().toString();
                                String pw = mAdminPreferences.getString(
                                        AdminPreferencesActivity.KEY_ADMIN_PW, "");
                                if (pw.compareTo(value) == 0) {
                                    Intent i = new Intent(getApplicationContext(),
                                            AdminPreferencesActivity.class);
                                    startActivity(i);
                                    input.setText("");
                                    passwordDialog.dismiss();
                                } else {
                                    Toast.makeText(
                                            MainMenuActivity.this,
                                            getString(R.string.admin_password_incorrect),
                                            Toast.LENGTH_SHORT).show();
                                    Collect.getInstance()
                                            .getActivityLogger()
                                            .logAction(this, "adminPasswordDialog",
                                                    "PASSWORD_INCORRECT");
                                }
                            }
                        });

                passwordDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.cancel),
                        new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog, int which) {
                                Collect.getInstance()
                                        .getActivityLogger()
                                        .logAction(this, "adminPasswordDialog",
                                                "cancel");
                                input.setText("");
                                return;
                            }
                        });

                passwordDialog.getWindow().setSoftInputMode(
                        WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
                return passwordDialog;

        }
        return null;
    }

}