<commit_before>package org.osmdroid.forge.app;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import org.mapsforge.map.android.graphics.AndroidGraphicFactory;
import org.mapsforge.map.layer.renderer.MapWorkerPool;
import org.mapsforge.map.reader.MapFile;
import org.mapsforge.map.rendertheme.XmlRenderTheme;
import org.osmdroid.api.IGeoPoint;
import org.osmdroid.events.MapListener;
import org.osmdroid.events.ScrollEvent;
import org.osmdroid.events.ZoomEvent;
import org.osmdroid.mapsforge.MapsForgeTileProvider;
import org.osmdroid.mapsforge.MapsForgeTileSource;
import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants;
import org.osmdroid.tileprovider.tilesource.ITileSource;
import org.osmdroid.tileprovider.util.SimpleRegisterReceiver;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;

import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * A simple, sample application, to use MapsForge https://github.com/mapsforge/mapsforge
 * with osmdroid https://github.com/osmdroid/osmdroid map engine.
 * @author <NAME>
 */
public class MainActivity extends AppCompatActivity {

    TextView currentCenter;

    MapView mMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        /**
         * super important to configure some of the mapsforge settings first
         */
        AndroidGraphicFactory.createInstance(this.getApplication());
        /*
        not sure how important these are....
        MapFile.wayFilterEnabled = true;
        MapFile.wayFilterDistance = 20;
        MapWorkerPool.DEBUG_TIMING = true;
        MapWorkerPool.NUMBER_OF_THREADS = MapWorkerPool.DEFAULT_NUMBER_OF_THREADS;
*/


        //enable these for additioal log output
        //OpenStreetMapTileProviderConstants.DEBUG_TILE_PROVIDERS = true;
        //OpenStreetMapTileProviderConstants.DEBUGMODE = true;

        // Request permissions to support Android Marshmallow and above devices
        if (Build.VERSION.SDK_INT >= 23) {
            checkPermissions();
        }
        setContentView(R.layout.activity_main);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
                //this would be a good place for you to enable users to browse the local file system
                //for a set of mapsforge files
            }
        });



        mMap = (MapView) findViewById(R.id.mapview);
        currentCenter=(TextView) findViewById(R.id.currentCenter);


        //first let's up our map source, mapsforge needs you to explicitly specify which map files to load
        //this bit does some basic file system scanning
        Set<File> mapfiles = findMapFiles();
        //do a simple scan of local storage for .map files.
        File[] maps = new File[mapfiles.size()];
        maps = mapfiles.toArray(maps);

        //this creates the forge provider and tile sources
        //that's it!

        //note this example does not using caching yet, so each tile is rendered on the fly, every time
        //the user browses to an area. This needs to be updated to support sqlite raster image caches


        //null is ok here, uses the default rendering theme if it's not set
        XmlRenderTheme theme = null;

        MapsForgeTileProvider forge = new MapsForgeTileProvider(
                new SimpleRegisterReceiver(this),
                MapsForgeTileSource.createFromFile(maps,theme));

        mMap.setTileProvider(forge);
        mMap.setUseDataConnection(false);
        mMap.setMultiTouchControls(true);
        mMap.setBuiltInZoomControls(true);


    }

    @Override
    public void onResume() {
        super.onResume();
        mMap.getController().setCenter(new GeoPoint(47.0796d, 4.5827d));
        mMap.getController().setZoom(13);
        mMap.getController().zoomTo(13);
        mMap.setMapListener(new MapListener() {
            @Override
            public boolean onScroll(ScrollEvent event) {
                IGeoPoint mapCenter = mMap.getMapCenter();
                currentCenter.setText(mapCenter.getLatitude() + "," + mapCenter.getLongitude());
                return false;
            }

            @Override
            public boolean onZoom(ZoomEvent event) {
                return false;
            }
        });
    }

    /**<commit_msg>#245 adding some extra output for debugging purposes<commit_after>package org.osmdroid.forge.app;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import org.mapsforge.map.android.graphics.AndroidGraphicFactory;
import org.mapsforge.map.layer.renderer.MapWorkerPool;
import org.mapsforge.map.reader.MapFile;
import org.mapsforge.map.rendertheme.XmlRenderTheme;
import org.osmdroid.api.IGeoPoint;
import org.osmdroid.events.MapListener;
import org.osmdroid.events.ScrollEvent;
import org.osmdroid.events.ZoomEvent;
import org.osmdroid.mapsforge.MapsForgeTileProvider;
import org.osmdroid.mapsforge.MapsForgeTileSource;
import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants;
import org.osmdroid.tileprovider.tilesource.ITileSource;
import org.osmdroid.tileprovider.util.SimpleRegisterReceiver;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;

import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * A simple, sample application, to use MapsForge https://github.com/mapsforge/mapsforge
 * with osmdroid https://github.com/osmdroid/osmdroid map engine.
 * @author <NAME>
 */
public class MainActivity extends AppCompatActivity {

    TextView currentCenter;

    MapView mMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        /**
         * super important to configure some of the mapsforge settings first
         */
        AndroidGraphicFactory.createInstance(this.getApplication());
        /*
        not sure how important these are....
        MapFile.wayFilterEnabled = true;
        MapFile.wayFilterDistance = 20;
        MapWorkerPool.DEBUG_TIMING = true;
        MapWorkerPool.NUMBER_OF_THREADS = MapWorkerPool.DEFAULT_NUMBER_OF_THREADS;
*/


        //enable these for additioal log output
        //OpenStreetMapTileProviderConstants.DEBUG_TILE_PROVIDERS = true;
        //OpenStreetMapTileProviderConstants.DEBUGMODE = true;

        // Request permissions to support Android Marshmallow and above devices
        if (Build.VERSION.SDK_INT >= 23) {
            checkPermissions();
        }
        setContentView(R.layout.activity_main);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
                //this would be a good place for you to enable users to browse the local file system
                //for a set of mapsforge files
            }
        });



        mMap = (MapView) findViewById(R.id.mapview);
        currentCenter=(TextView) findViewById(R.id.currentCenter);


        //first let's up our map source, mapsforge needs you to explicitly specify which map files to load
        //this bit does some basic file system scanning
        Set<File> mapfiles = findMapFiles();
        //do a simple scan of local storage for .map files.
        File[] maps = new File[mapfiles.size()];
        maps = mapfiles.toArray(maps);
        Toast.makeText(this, "Loaded " + maps.length + " map files", Toast.LENGTH_LONG).show();

        //this creates the forge provider and tile sources
        //that's it!

        //note this example does not using caching yet, so each tile is rendered on the fly, every time
        //the user browses to an area. This needs to be updated to support sqlite raster image caches


        //null is ok here, uses the default rendering theme if it's not set
        XmlRenderTheme theme = null;

        MapsForgeTileProvider forge = new MapsForgeTileProvider(
                new SimpleRegisterReceiver(this),
                MapsForgeTileSource.createFromFile(maps,theme));

        mMap.setTileProvider(forge);
        mMap.setUseDataConnection(false);
        mMap.setMultiTouchControls(true);
        mMap.setBuiltInZoomControls(true);


    }

    @Override
    public void onResume() {
        super.onResume();
        mMap.getController().setCenter(new GeoPoint(47.0796d, 4.5827d));
        mMap.getController().setZoom(13);
        mMap.getController().zoomTo(13);
        mMap.setMapListener(new MapListener() {
            @Override
            public boolean onScroll(ScrollEvent event) {
                IGeoPoint mapCenter = mMap.getMapCenter();
                currentCenter.setText(mapCenter.getLatitude() + "," + mapCenter.getLongitude() + " " + mMap.getZoomLevel());
                return false;
            }

            @Override
            public boolean onZoom(ZoomEvent event) {
                return false;
            }
        });
    }

    /**
{'fraction_non_alphanumeric': 0.09114367339415722, 'fraction_numerical': 0.004331398027831536, 'mean_word_length': 2.929036929761043, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2894685', 'n_tokens_mistral': 3118, 'n_tokens_neox': 2945, 'n_words': 728}