summaryrefslogtreecommitdiff
path: root/src/se/leap/openvpn/ShowConfigFragment.java
blob: 9bce67a6dbf2ccd30140505a184285d573456a22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package se.leap.openvpn;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import se.leap.leapclient.R;


public class ShowConfigFragment extends Fragment {
	private String configtext;
	public android.view.View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
	{
		String profileUUID = getArguments().getString(getActivity().getPackageName() + ".profileUUID");
		VpnProfile vp = ProfileManager.get(profileUUID);
		View v=inflater.inflate(R.layout.viewconfig, container,false);
		TextView cv = (TextView) v.findViewById(R.id.configview);
		
		int check=vp.checkProfile(getActivity());
		if(check!=R.string.no_error_found) {
			cv.setText(check);
			configtext = getString(check);
		}
		else { 
			String cfg=vp.getConfigFile(getActivity());
			configtext= cfg;
			cv.setText(cfg);
		}
		return v;
	};

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setHasOptionsMenu(true);
	}
	
	@Override
	public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
		inflater.inflate(R.menu.configmenu, menu);
	}
	
	private void shareConfig() {
		Intent shareIntent = new Intent(Intent.ACTION_SEND);
		shareIntent.putExtra(Intent.EXTRA_TEXT, configtext);
		shareIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.export_config_title));
		shareIntent.setType("text/plain");
		startActivity(Intent.createChooser(shareIntent, "Export Configfile"));
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		final int itemId = item.getItemId();
		if (itemId == R.id.sendConfig) {
			shareConfig();
			return true;
		} else {
			return super.onOptionsItemSelected(item);
		}
	}
}