diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/de/blinkt/openvpn/ConfigParser.java | 2 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/FileSelect.java | 5 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/FileSelectLayout.java | 1 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/FileSelectionFragment.java | 65 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/FragmentGeneralSettings.java | 12 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/MainActivity.java | 102 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/OpenVPN.java | 5 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/SendDumpFragment.java (renamed from src/de/blinkt/openvpn/SendDumpActivity.java) | 44 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/VPNProfileList.java | 9 |
9 files changed, 168 insertions, 77 deletions
diff --git a/src/de/blinkt/openvpn/ConfigParser.java b/src/de/blinkt/openvpn/ConfigParser.java index e5713c3f..57649547 100644 --- a/src/de/blinkt/openvpn/ConfigParser.java +++ b/src/de/blinkt/openvpn/ConfigParser.java @@ -7,8 +7,6 @@ import java.util.HashMap; import java.util.Locale; import java.util.Vector; -import android.text.TextUtils; - //! Openvpn Config FIle Parser, probably not 100% accurate but close enough // And rember, this is valid :) diff --git a/src/de/blinkt/openvpn/FileSelect.java b/src/de/blinkt/openvpn/FileSelect.java index 18448706..e1a89b87 100644 --- a/src/de/blinkt/openvpn/FileSelect.java +++ b/src/de/blinkt/openvpn/FileSelect.java @@ -130,8 +130,11 @@ public class FileSelect extends Activity { data += new String(filedata); mData =data; + + /* mInlineFragment.setData(data); - getActionBar().selectTab(inlineFileTab); + getActionBar().selectTab(inlineFileTab); */ + saveInlineData(data); } catch (FileNotFoundException e) { fe = e; } catch (IOException e) { diff --git a/src/de/blinkt/openvpn/FileSelectLayout.java b/src/de/blinkt/openvpn/FileSelectLayout.java index 93e438fc..b7e28b5c 100644 --- a/src/de/blinkt/openvpn/FileSelectLayout.java +++ b/src/de/blinkt/openvpn/FileSelectLayout.java @@ -38,6 +38,7 @@ public class FileSelectLayout extends LinearLayout implements OnClickListener { mSelectButton = (Button) findViewById(R.id.file_select_button); mSelectButton.setOnClickListener(this); + ta.recycle(); } public void setFragment(Fragment fragment, int i) diff --git a/src/de/blinkt/openvpn/FileSelectionFragment.java b/src/de/blinkt/openvpn/FileSelectionFragment.java index 5badc6e0..f750d91a 100644 --- a/src/de/blinkt/openvpn/FileSelectionFragment.java +++ b/src/de/blinkt/openvpn/FileSelectionFragment.java @@ -15,6 +15,7 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; +import android.widget.CheckBox; import android.widget.ListView; import android.widget.SimpleAdapter; import android.widget.TextView; @@ -30,8 +31,8 @@ public class FileSelectionFragment extends ListFragment { private static final String ITEM_KEY = "key"; private static final String ITEM_IMAGE = "image"; private static final String ROOT = "/"; - - + + private List<String> path = null; private TextView myPath; private ArrayList<HashMap<String, Object>> mList; @@ -48,18 +49,28 @@ public class FileSelectionFragment extends ListFragment { private File selectedFile; private HashMap<String, Integer> lastPositions = new HashMap<String, Integer>(); private String mStartPath; - private Button mImportFile; + private CheckBox mInlineImport; private Button mClearButton; private boolean mHideImport=false; - + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.file_dialog_main, container,false); - + myPath = (TextView) v.findViewById(R.id.path); + mInlineImport = (CheckBox) v.findViewById(R.id.doinline); + mInlineImport.setEnabled(false); + + if(mHideImport== true) { + mInlineImport.setVisibility(View.GONE); + mInlineImport.setChecked(false); + } + + + selectButton = (Button) v.findViewById(R.id.fdButtonSelect); selectButton.setEnabled(false); selectButton.setOnClickListener(new OnClickListener() { @@ -67,15 +78,18 @@ public class FileSelectionFragment extends ListFragment { @Override public void onClick(View v) { if (selectedFile != null) { - ((FileSelect) getActivity()).setFile(selectedFile.getPath()); - + if(mInlineImport.isChecked()) + + ((FileSelect) getActivity()).importFile(selectedFile.getPath()); + else + ((FileSelect) getActivity()).setFile(selectedFile.getPath()); } } }); mClearButton = (Button) v.findViewById(R.id.fdClear); mClearButton.setOnClickListener(new OnClickListener() { - + @Override public void onClick(View v) { ((FileSelect) getActivity()).clearData(); @@ -85,35 +99,21 @@ public class FileSelectionFragment extends ListFragment { mClearButton.setVisibility(View.GONE); mClearButton.setEnabled(false); } - - - mImportFile = (Button) v.findViewById(R.id.importfile); - mImportFile.setEnabled(false); - mImportFile.setOnClickListener(new OnClickListener() { - - @Override - public void onClick(View v) { - ((FileSelect) getActivity()).importFile(selectedFile.getPath()); - } - }); - if(mHideImport== true) { - mImportFile.setVisibility(View.GONE); - } - + return v; } - + @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - + mStartPath = ((FileSelect) getActivity()).getSelectPath(); getDir(mStartPath); } - + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -154,7 +154,7 @@ public class FileSelectionFragment extends ListFragment { f = new File(currentPath); files = f.listFiles(); } - + myPath.setText(getText(R.string.location) + ": " + currentPath); if (!currentPath.equals(ROOT)) { @@ -209,7 +209,7 @@ public class FileSelectionFragment extends ListFragment { path.addAll(filesPathMap.tailMap("").values()); SimpleAdapter fileList = new SimpleAdapter(getActivity(), mList, R.layout.file_dialog_row, new String[] { - ITEM_KEY, ITEM_IMAGE }, new int[] { R.id.fdrowtext, R.id.fdrowimage }); + ITEM_KEY, ITEM_IMAGE }, new int[] { R.id.fdrowtext, R.id.fdrowimage }); for (String dir : dirsMap.tailMap("").values()) { addItem(dir, R.drawable.folder); @@ -240,26 +240,25 @@ public class FileSelectionFragment extends ListFragment { if (file.isDirectory()) { selectButton.setEnabled(false); - mImportFile.setEnabled(false); - + if (file.canRead()) { lastPositions.put(currentPath, position); getDir(path.get(position)); } else { new AlertDialog.Builder(getActivity()).setIcon(R.drawable.icon) - .setTitle("[" + file.getName() + "] " + getText(R.string.cant_read_folder)) - .setPositiveButton("OK", null).show(); + .setTitle("[" + file.getName() + "] " + getText(R.string.cant_read_folder)) + .setPositiveButton("OK", null).show(); } } else { selectedFile = file; v.setSelected(true); selectButton.setEnabled(true); - mImportFile.setEnabled(true); } } public void setNoInLine() { mHideImport=true; + } } diff --git a/src/de/blinkt/openvpn/FragmentGeneralSettings.java b/src/de/blinkt/openvpn/FragmentGeneralSettings.java new file mode 100644 index 00000000..800fb82a --- /dev/null +++ b/src/de/blinkt/openvpn/FragmentGeneralSettings.java @@ -0,0 +1,12 @@ +package de.blinkt.openvpn; + +import android.os.Bundle; +import android.preference.PreferenceFragment; + +public class FragmentGeneralSettings extends PreferenceFragment { +@Override +public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.general_settings); +} +} diff --git a/src/de/blinkt/openvpn/MainActivity.java b/src/de/blinkt/openvpn/MainActivity.java index 57506c4f..c5ae21c8 100644 --- a/src/de/blinkt/openvpn/MainActivity.java +++ b/src/de/blinkt/openvpn/MainActivity.java @@ -1,42 +1,94 @@ package de.blinkt.openvpn; -import java.util.List; - +import android.app.ActionBar; +import android.app.ActionBar.Tab; +import android.app.Activity; +import android.app.Fragment; +import android.app.FragmentTransaction; import android.content.Intent; -import android.preference.PreferenceActivity; -public class MainActivity extends PreferenceActivity { - @Override - public void onBuildHeaders(List<Header> target) { - loadHeadersFromResource(R.xml.main_headers, target); - +public class MainActivity extends Activity { + + protected void onCreate(android.os.Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + ActionBar bar = getActionBar(); + bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); + + Tab vpnListTab = bar.newTab().setText(R.string.vpn_list_title); + Tab generalTab = bar.newTab().setText(R.string.generalsettings); + Tab faqtab = bar.newTab().setText(R.string.faq); + Tab abouttab = bar.newTab().setText(R.string.about); + + vpnListTab.setTabListener(new TabListener<VPNProfileList>("profiles", VPNProfileList.class)); + generalTab.setTabListener(new TabListener<FragmentGeneralSettings>("settings", FragmentGeneralSettings.class)); + faqtab.setTabListener(new TabListener<FaqFragment>("faq", FaqFragment.class)); + abouttab.setTabListener(new TabListener<AboutFragment>("about", AboutFragment.class)); - String translatedby = getString(R.string.translationby); - if(!translatedby.equals("") && !translatedby.contains("Arne Schwabe")) { - Header translation = new Header(); - translation.title = getString(R.string.translation); - translation.summary = translatedby; - target.add(translation); + bar.addTab(vpnListTab); + bar.addTab(generalTab); + bar.addTab(faqtab); + bar.addTab(abouttab); + + if(SendDumpFragment.getLastestDump(this)!=null) { + Tab sendDump = bar.newTab().setText(R.string.crashdump); + sendDump.setTabListener(new TabListener<SendDumpFragment>("crashdump",SendDumpFragment.class)); + bar.addTab(sendDump); } - if(SendDumpActivity.getLastestDump(this)!=null) { - Header sendDump = new Header(); - sendDump.titleRes = R.string.send_minidump; - sendDump.summaryRes = R.string.send_minidump_summary; - sendDump.intent = new Intent(this,SendDumpActivity.class); - target.add(sendDump); + }; + + protected class TabListener<T extends Fragment> implements ActionBar.TabListener + { + private Fragment mFragment; + private String mTag; + private Class<T> mClass; + + + public TabListener(String tag, Class<T> clz) { + mTag = tag; + mClass = clz; + + // Check to see if we already have a fragment for this tab, probably + // from a previously saved state. If so, deactivate it, because our + // initial state is that a tab isn't shown. + mFragment = getFragmentManager().findFragmentByTag(mTag); + if (mFragment != null && !mFragment.isDetached()) { + FragmentTransaction ft = getFragmentManager().beginTransaction(); + ft.detach(mFragment); + ft.commit(); + } + } + + public void onTabSelected(Tab tab, FragmentTransaction ft) { + if (mFragment == null) { + mFragment = Fragment.instantiate(MainActivity.this, mClass.getName()); + ft.add(android.R.id.content, mFragment, mTag); + } else { + ft.attach(mFragment); + } + } + + public void onTabUnselected(Tab tab, FragmentTransaction ft) { + if (mFragment != null) { + ft.detach(mFragment); + } + } + + + @Override + public void onTabReselected(Tab tab, FragmentTransaction ft) { + } - } - + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); - + System.out.println(data); - - + + } diff --git a/src/de/blinkt/openvpn/OpenVPN.java b/src/de/blinkt/openvpn/OpenVPN.java index 4d5ae269..da25b8a5 100644 --- a/src/de/blinkt/openvpn/OpenVPN.java +++ b/src/de/blinkt/openvpn/OpenVPN.java @@ -11,6 +11,7 @@ import java.util.LinkedList; import java.util.Locale; import java.util.Vector; +import android.annotation.SuppressLint; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; @@ -165,7 +166,9 @@ public class OpenVPN { } } } - + + // The lint is wrong here + @SuppressLint("StringFormatMatches") private String getMobileInfoString(Context c) { c.getPackageManager(); String apksign="error getting package signature"; diff --git a/src/de/blinkt/openvpn/SendDumpActivity.java b/src/de/blinkt/openvpn/SendDumpFragment.java index 74d1a2f8..0ff7f48f 100644 --- a/src/de/blinkt/openvpn/SendDumpActivity.java +++ b/src/de/blinkt/openvpn/SendDumpFragment.java @@ -3,20 +3,34 @@ package de.blinkt.openvpn; import java.io.File; import java.util.ArrayList; -import android.app.Activity; +import android.app.Fragment; import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.net.Uri; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; -public class SendDumpActivity extends Activity { +public class SendDumpFragment extends Fragment implements OnClickListener { - protected void onStart() { - super.onStart(); - emailMiniDumps(); - finish(); - }; + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + + View v = inflater.inflate(R.layout.fragment_senddump, container, false); + v.findViewById(R.id.senddump).setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + emailMiniDumps(); + } + }); + return v; + } public void emailMiniDumps() { @@ -29,7 +43,7 @@ public class SendDumpActivity extends Activity { String version; String name="ics-openvpn"; try { - PackageInfo packageinfo = getPackageManager().getPackageInfo(getPackageName(), 0); + PackageInfo packageinfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0); version = packageinfo.versionName; name = packageinfo.applicationInfo.name; } catch (NameNotFoundException e) { @@ -43,7 +57,7 @@ public class SendDumpActivity extends Activity { ArrayList<Uri> uris = new ArrayList<Uri>(); - File ldump = getLastestDump(this); + File ldump = getLastestDump(getActivity()); if(ldump==null) { OpenVPN.logError("No Minidump found!"); } @@ -69,6 +83,18 @@ public class SendDumpActivity extends Activity { newestDumpFile=f; } } + // Ignore old dumps + //if(System.currentTimeMillis() - 48 * 60 * 1000 > newestDumpTime ) + //return null; + return newestDumpFile; } + + + + @Override + public void onClick(View v) { + // TODO Auto-generated method stub + + } } diff --git a/src/de/blinkt/openvpn/VPNProfileList.java b/src/de/blinkt/openvpn/VPNProfileList.java index 1e24bfe7..6c10e736 100644 --- a/src/de/blinkt/openvpn/VPNProfileList.java +++ b/src/de/blinkt/openvpn/VPNProfileList.java @@ -92,8 +92,6 @@ public class VPNProfileList extends ListFragment { super.onCreate(savedInstanceState); setHasOptionsMenu(true); - // Debug load JNI - //OpenVPN.foo(); } @@ -172,15 +170,14 @@ public class VPNProfileList extends ListFragment { menu.add(0, MENU_ADD_PROFILE, 0, R.string.menu_add_profile) .setIcon(android.R.drawable.ic_menu_add) .setAlphabeticShortcut('a') - .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM - | MenuItem.SHOW_AS_ACTION_WITH_TEXT); + .setTitleCondensed(getActivity().getString(R.string.add)) + .setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT); menu.add(0, MENU_IMPORT_PROFILE, 0, R.string.menu_import) .setIcon(R.drawable.ic_menu_archive) .setAlphabeticShortcut('i') .setTitleCondensed(getActivity().getString(R.string.menu_import_short)) - .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM - | MenuItem.SHOW_AS_ACTION_WITH_TEXT ); + .setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT ); } |