<commit_before>/*
 *  Copyright (C) 2012-2013 <NAME> (Akvo Foundation)
 *
 *  This file is part of Akvo RSR.
 *
 *  Akvo RSR is free software: you can redistribute it and modify it under the terms of
 *  the GNU Affero General Public License (AGPL) as published by the Free Software Foundation,
 *  either version 3 of the License or any later version.
 *
 *  Akvo RSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *  See the GNU Affero General Public License included below for more details.
 *
 *  The full license text can also be seen at <http://www.gnu.org/licenses/agpl.html>.
 */

package org.akvo.rsr.android;

import org.akvo.rsr.android.dao.RsrDbAdapter;
import org.akvo.rsr.android.domain.Project;
import org.akvo.rsr.android.util.ConstantUtil;
import org.akvo.rsr.android.util.FileUtil;
import org.akvo.rsr.android.util.SettingsUtil;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.content.Intent;
import android.content.res.Resources;

public class ProjectDetailActivity extends Activity {

	private String projId = null;
	private Project project = null;
	private TextView projTitleLabel;
	private TextView projSummaryText;
	private TextView projLocationText;
	private TextView publishedCountView;
	private TextView draftCountView;
	private ImageView projImage;
	private Button btnUpdates;
	private Button btnAddUpdate;
	private boolean debug;

	private RsrDbAdapter dba;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		debug = SettingsUtil.ReadBoolean(this, "setting_debug", false);

		//find which project we will be showing
		Bundle extras = getIntent().getExtras();
		projId = extras != null ? extras.getString(ConstantUtil.PROJECT_ID_KEY)
				: null;
		if (projId == null) {
			projId = savedInstanceState != null ? savedInstanceState
					.getString(ConstantUtil.PROJECT_ID_KEY) : null;
		}

		//get the look
		setContentView(R.layout.activity_project_detail);
		//find the fields
		projTitleLabel		= (TextView) findViewById(R.id.text_proj_detail_title);
		projLocationText 	= (TextView) findViewById(R.id.text_proj_location);
		projSummaryText		= (TextView) findViewById(R.id.text_proj_summary);
		projImage 			= (ImageView) findViewById(R.id.image_proj_detail);
		publishedCountView 	= (TextView) findViewById(R.id.text_proj_detail_published_count);
		draftCountView 		= (TextView) findViewById(R.id.text_proj_detail_draft_count);

		//Activate buttons
		btnUpdates = (Button) findViewById(R.id.btn_view_updates);
		btnUpdates.setOnClickListener( new View.OnClickListener() {
			public void onClick(View view) {
				Intent i = new Intent(view.getContext(), UpdateListActivity.class);
				i.putExtra(ConstantUtil.PROJECT_ID_KEY, projId);
				startActivity(i);
			}
		});
		btnAddUpdate = (Button) findViewById(R.id.btn_add_update);
		btnAddUpdate.setOnClickListener( new View.OnClickListener() {
			public void onClick(View view) {
				Intent i = new Intent(view.getContext(), UpdateEditorActivity.class);
				i.putExtra(ConstantUtil.PROJECT_ID_KEY, projId);
				startActivity(i);
			}
		});
 

		
		dba = new RsrDbAdapter(this);
		
		// Show the Up button in the action bar.
		//		setupActionBar();
	}

	@Override
	protected void onResume() {
		super.onResume();
		dba.open();
		project = dba.findProject(projId);
		
		if (debug) {
			projTitleLabel.setText("["+ projId + "] "+project.getTitle());
		} else {
			projTitleLabel.setText(project.getTitle());
		}

		String loc = "";
		if (project.getCity() != null) {
			loc += project.getCity() + ", ";
		}
		if (project.getState() != null) {
			loc += project.getState() + ", ";			
		}
		if (project.getCountry() != null) {
			loc += project.getCountry() + ", ";			
		}
		if (loc.length() > 1) {
			loc = loc.substring(0, loc.length()-2);
		}

		//TODO check against 0,0 too?
		if (project.getLatitude() != null &&
			project.getLongitude() != null ) {
			loc += "\nLatitude " + project.getLatitude() +
			" Longitude " + project.getLongitude();
			projLocationText.setOnClickListener(<commit_msg>[#94]Remove extra commas when for empty location fields<commit_after>/*
 *  Copyright (C) 2012-2013 <NAME> (Akvo Foundation)
 *
 *  This file is part of Akvo RSR.
 *
 *  Akvo RSR is free software: you can redistribute it and modify it under the terms of
 *  the GNU Affero General Public License (AGPL) as published by the Free Software Foundation,
 *  either version 3 of the License or any later version.
 *
 *  Akvo RSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *  See the GNU Affero General Public License included below for more details.
 *
 *  The full license text can also be seen at <http://www.gnu.org/licenses/agpl.html>.
 */

package org.akvo.rsr.android;

import org.akvo.rsr.android.dao.RsrDbAdapter;
import org.akvo.rsr.android.domain.Project;
import org.akvo.rsr.android.util.ConstantUtil;
import org.akvo.rsr.android.util.FileUtil;
import org.akvo.rsr.android.util.SettingsUtil;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.content.Intent;
import android.content.res.Resources;

public class ProjectDetailActivity extends Activity {

	private String projId = null;
	private Project project = null;
	private TextView projTitleLabel;
	private TextView projSummaryText;
	private TextView projLocationText;
	private TextView publishedCountView;
	private TextView draftCountView;
	private ImageView projImage;
	private Button btnUpdates;
	private Button btnAddUpdate;
	private boolean debug;

	private RsrDbAdapter dba;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		debug = SettingsUtil.ReadBoolean(this, "setting_debug", false);

		//find which project we will be showing
		Bundle extras = getIntent().getExtras();
		projId = extras != null ? extras.getString(ConstantUtil.PROJECT_ID_KEY)
				: null;
		if (projId == null) {
			projId = savedInstanceState != null ? savedInstanceState
					.getString(ConstantUtil.PROJECT_ID_KEY) : null;
		}

		//get the look
		setContentView(R.layout.activity_project_detail);
		//find the fields
		projTitleLabel		= (TextView) findViewById(R.id.text_proj_detail_title);
		projLocationText 	= (TextView) findViewById(R.id.text_proj_location);
		projSummaryText		= (TextView) findViewById(R.id.text_proj_summary);
		projImage 			= (ImageView) findViewById(R.id.image_proj_detail);
		publishedCountView 	= (TextView) findViewById(R.id.text_proj_detail_published_count);
		draftCountView 		= (TextView) findViewById(R.id.text_proj_detail_draft_count);

		//Activate buttons
		btnUpdates = (Button) findViewById(R.id.btn_view_updates);
		btnUpdates.setOnClickListener( new View.OnClickListener() {
			public void onClick(View view) {
				Intent i = new Intent(view.getContext(), UpdateListActivity.class);
				i.putExtra(ConstantUtil.PROJECT_ID_KEY, projId);
				startActivity(i);
			}
		});
		btnAddUpdate = (Button) findViewById(R.id.btn_add_update);
		btnAddUpdate.setOnClickListener( new View.OnClickListener() {
			public void onClick(View view) {
				Intent i = new Intent(view.getContext(), UpdateEditorActivity.class);
				i.putExtra(ConstantUtil.PROJECT_ID_KEY, projId);
				startActivity(i);
			}
		});
 

		
		dba = new RsrDbAdapter(this);
		
		// Show the Up button in the action bar.
		//		setupActionBar();
	}

	@Override
	protected void onResume() {
		super.onResume();
		dba.open();
		project = dba.findProject(projId);
		
		if (debug) {
			projTitleLabel.setText("["+ projId + "] "+project.getTitle());
		} else {
			projTitleLabel.setText(project.getTitle());
		}

		String loc = "";
		if (project.getCity() != null && project.getCity().length() > 0) {
			loc += project.getCity() + ", ";
		}
		if (project.getState() != null && project.getState().length() > 0) {
			loc += project.getState() + ", ";			
		}
		if (project.getCountry() != null && project.getCountry().length() > 0) {
			loc += project.getCountry() + ", ";			
		}
		if (loc.length() > 1) {
			loc = loc.substring(0, loc.length()-2);
		}

		//TODO check against 0,0 too?
		if (project.getLatitude() != null &&
			project.getLongitude() != null ) {
			loc += "\nLatitude " + project.getLatitude() +
			        " Longitude " + project.getLongitude();
			projLocationText.setOnClickListener(
{'fraction_non_alphanumeric': 0.11446988219604357, 'fraction_numerical': 0.003667481662591687, 'mean_word_length': 4.25642523364486, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4824084', 'n_tokens_mistral': 3120, 'n_tokens_neox': 2760, 'n_words': 706}