package cgeo.geocaching;

import java.util.Locale;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import cgeo.geocaching.activity.AbstractActivity;

public class cgeohelpers extends AbstractActivity {

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

		// init
		setTheme();
		setContentView(R.layout.helpers);
		setTitle(res.getString(R.string.helpers));
	}

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

		settings.load();
	}

	public void installManual(View view) {
		final Locale loc = Locale.getDefault();
		final String lng = loc.getLanguage();

		try {
			if (lng.equalsIgnoreCase("de")) {
				startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:gnu.android.app.cgeomanual.de")));
			} else {
				startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:gnu.android.app.cgeomanual.en")));
			}
		} catch (Exception e) {
			// market not available in standard emulator
		}


		finish();
	}

	public void installLocus(View view) {
		try {
			startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:menion.android.locus")));
		} catch (Exception e) {
			// market not available in standard emulator
		}


		finish();
	}

	public void installGpsStatus(View view) {
		try {
			startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:com.eclipsim.gpsstatus2")));
		} catch (Exception e) {
			// market not available in standard emulator
		}

		finish();
	}

	public void installBluetoothGps(View view) {
		try {
			startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:googoo.android.btgps")));
		} catch (Exception e) {
			// market not available in standard emulator
		}

		finish();
	}
}

@@ -541,37 +541,38 @@
 s.load();%0A%09%7D%0A%0A%09p
-ublic
+rivate
  void installMan
@@ -572,157 +572,46 @@
 tall
-Manual(View view) %7B%0A%09%09final Locale loc = Locale.getDefault();%0A%09%09final String lng = loc.getLanguage();%0A%0A%09%09try
+FromMarket(String marketId)
  %7B%0A%09%09
-%09
-if (lng.equalsIgnoreCase(%22de%22))
+try
  %7B%0A
-%09
 %09%09%09s
@@ -693,178 +693,24 @@
 ame:
-gnu.android.app.cgeomanual.de%22)));%0A%09%09%09%7D else %7B%0A%09%09%09%09startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(%22market://search?q=pname:gnu.android.app.cgeomanual.en%22)));%0A%09%09%09%7D
+%22 + marketId)));
 %0A%09%09%7D
@@ -777,33 +777,32 @@
 d emulator%0A%09%09%7D%0A%0A
-%0A
 %09%09finish();%0A%09%7D%0A%0A
@@ -825,13 +825,14 @@
 tall
-Locus
+Manual
 (Vie
@@ -847,728 +847,537 @@
 %7B%0A%09%09
-try %7B%0A%09%09%09startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(%22market://search?q=pname:menion.android.locus%22)));%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09// market not available in standard emulator
+final Locale loc = Locale.getDefault();%0A%09%09final String language = loc.getLanguage();%0A%0A%09%09if (%22de%22.equalsIgnoreCase(language)) %7B%0A%09%09%09installFromMarket(%22gnu.android.app.cgeomanual.de%22);%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09installFromMarket(%22gnu.android.app.cgeomanual.en%22);
 %0A%09%09%7D%0A
+%09%7D
 %0A%0A%09
-%09finish();%0A%09%7D%0A%0A%09public void installGpsStatus(View view) %7B%0A%09%09try %7B%0A%09%09%09startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(%22market://search?q=pname:com.eclipsim.gpsstatus2%22)));%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09// market not available in standard emulator%0A%09%09%7D%0A%0A%09%09finish();%0A%09%7D%0A%0A%09public void installBluetoothGps(View view) %7B%0A%09%09try %7B%0A%09%09%09startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(%22market://search?q=pname:googoo.android.btgps%22)));%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09// market not available in standard emulator%0A%09%09%7D%0A%0A%09%09finish(
+public void installLocus(View view) %7B%0A%09%09installFromMarket(%22menion.android.locus%22);%0A%09%7D%0A%0A%09public void installGpsStatus(View view) %7B%0A%09%09installFromMarket(%22com.eclipsim.gpsstatus2%22);%0A%09%7D%0A%0A%09public void installBluetoothGps(View view) %7B%0A%09%09installFromMarket(%22googoo.android.btgps%22
 );%0A%09

remove duplicate code