<commit_before>package org.pocketcampus.plugin.mainscreen;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Vector;

import org.pocketcampus.R;
import org.pocketcampus.core.plugin.Core;
import org.pocketcampus.core.plugin.PluginBase;
import org.pocketcampus.core.plugin.PluginInfo;
import org.pocketcampus.core.plugin.PluginPreference;
import org.pocketcampus.core.ui.ActionBar;
import org.pocketcampus.core.ui.ActionBar.Action;
import org.pocketcampus.plugin.logging.Tracker;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.SlidingDrawer;

public class MainscreenPlugin extends PluginBase {
	private Context ctx_;
	private Core core_;
	private Vector<PluginBase> plugins_;
	private Tracker tracker_;
	
	private static ActionBar actionBar_;
	private SlidingDrawer quickView_;
	
	private static List<Class> readyNews_;
	
	public final static String PACKAGE = "org.pocketcampus.plugin.";
	
	private MainscreenAdapter adapter_;
	
	private static List<MainscreenNews> news_;
	
	private PluginsAdapter pluginsAdapter_;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mainscreen_main);
		
		setupActionBar(false);

		quickView_ = (SlidingDrawer) findViewById(R.id.SlidingDrawer);
		
		readyNews_ = new ArrayList<Class>();
		news_ = new ArrayList<MainscreenNews>();
		
		tracker_ = Tracker.getInstance();
		tracker_.start(this);
		tracker_.trackPageView("mainscreen/home");
		
		ctx_ = this.getApplicationContext();
		core_ = Core.getInstance();
		plugins_ = core_.getAvailablePlugins();
			
		refresh();

		GridView gv = (GridView) findViewById(R.id.gridview);
		
		pluginsAdapter_ = new PluginsAdapter(this, plugins_);
		gv.setAdapter(pluginsAdapter_);
		gv.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				core_.displayPlugin(ctx_, pluginsAdapter_.getItem(position));
			}
		});

	}

	/**
	 * Closes the drawer when coming back from another plugin.
	 */
	@Override
	public void onRestart(){
		super.onRestart();
		
		if(quickView_.isOpened()) {
			quickView_.animateClose();
		}
		
		refresh();
	}

	/**
	 * Closes the drawer on back pressed if it is open.
	 */
	@Override
	public void onBackPressed() {
		if(quickView_.isOpened()) {
			quickView_.animateClose();
		} else {
			super.onBackPressed();
		}
	}
	
	/**
	 * Shows a dialog with informations about the application.
	 * TODO add text for the licenses!
	 */
	private void showAbout() {
		AlertDialog.Builder builder = new AlertDialog.Builder(this);

		builder.setTitle(R.string.mainscreen_menu_about);
<commit_msg><mainscreen> re-oops, didn't test on landscape mode...<commit_after>package org.pocketcampus.plugin.mainscreen;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Vector;

import org.pocketcampus.R;
import org.pocketcampus.core.plugin.Core;
import org.pocketcampus.core.plugin.PluginBase;
import org.pocketcampus.core.plugin.PluginInfo;
import org.pocketcampus.core.plugin.PluginPreference;
import org.pocketcampus.core.ui.ActionBar;
import org.pocketcampus.core.ui.ActionBar.Action;
import org.pocketcampus.plugin.logging.Tracker;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.SlidingDrawer;

public class MainscreenPlugin extends PluginBase {
	private Context ctx_;
	private Core core_;
	private Vector<PluginBase> plugins_;
	private Tracker tracker_;
	
	private static ActionBar actionBar_;
	private SlidingDrawer quickView_;
	
	private static List<Class> readyNews_;
	
	public final static String PACKAGE = "org.pocketcampus.plugin.";
	
	private MainscreenAdapter adapter_;
	
	private static List<MainscreenNews> news_;
	
	private PluginsAdapter pluginsAdapter_;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mainscreen_main);
		
		setupActionBar(false);

		quickView_ = (SlidingDrawer) findViewById(R.id.SlidingDrawer);
		
		readyNews_ = new ArrayList<Class>();
		news_ = new ArrayList<MainscreenNews>();
		
		tracker_ = Tracker.getInstance();
		tracker_.start(this);
		tracker_.trackPageView("mainscreen/home");
		
		ctx_ = this.getApplicationContext();
		core_ = Core.getInstance();
		plugins_ = core_.getAvailablePlugins();
			
		refresh();

		GridView gv = (GridView) findViewById(R.id.gridview);
		
		pluginsAdapter_ = new PluginsAdapter(this, plugins_);
		gv.setAdapter(pluginsAdapter_);
		gv.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				core_.displayPlugin(ctx_, pluginsAdapter_.getItem(position));
			}
		});

	}

	/**
	 * Closes the drawer when coming back from another plugin.
	 */
	@Override
	public void onRestart(){
		super.onRestart();
		
		if(quickView_!=null && quickView_.isOpened()) {
			quickView_.animateClose();
		}
		
		refresh();
	}

	/**
	 * Closes the drawer on back pressed if it is open.
	 */
	@Override
	public void onBackPressed() {
		if(quickView_!=null && quickView_.isOpened()) {
			quickView_.animateClose();
		} else {
			super.onBackPressed();
		}
	}
	
	/**
	 * Shows a dialog with informations about the application.
	 * TODO add text for the licenses!
	 */
	private void showAbout() {
		AlertDialog.Builder builder = new AlertDialog.Builder(this);

		builder.setTitle(R.string.mainscreen_menu_about);

{'fraction_non_alphanumeric': 0.10487007935273067, 'fraction_numerical': 0.0, 'mean_word_length': 4.97953488372093, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, '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': '378037', 'n_tokens_mistral': 2110, 'n_tokens_neox': 1883, 'n_words': 430}