diff --git a/.classpath b/.classpath index a4f1e40..d57ec02 100644 --- a/.classpath +++ b/.classpath @@ -1,8 +1,9 @@ - - - - - - - - + + + + + + + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b080d2d --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/project.properties b/project.properties index 732a548..16ee0fa 100644 --- a/project.properties +++ b/project.properties @@ -1,11 +1,12 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-10 +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "ant.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-19 +android.library.reference.1=../../workspace/gridlayout_v7 diff --git a/res/layout/settings_activity.xml b/res/layout/settings_activity.xml index f7e3bd0..5d7a97c 100644 --- a/res/layout/settings_activity.xml +++ b/res/layout/settings_activity.xml @@ -6,29 +6,22 @@ android:orientation="vertical"> + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/action_settings" + android:textAppearance="?android:attr/textAppearanceLarge" /> - + - - - - - + diff --git a/res/menu/menu.xml b/res/menu/menu.xml index 3b0cb6c..9c5b161 100644 --- a/res/menu/menu.xml +++ b/res/menu/menu.xml @@ -2,11 +2,9 @@ - - + + + + android:actionProviderClass="android.support.v7.widget.ShareActionProvider" /> + diff --git a/res/values/strings.xml b/res/values/strings.xml index d02c178..2b5e770 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -18,5 +18,8 @@ Refresh About Share + Settings + Select + Choose Source diff --git a/src/com/cmb/googledorks/MainActivity.java b/src/com/cmb/googledorks/MainActivity.java index 997d0f1..f278ee1 100644 --- a/src/com/cmb/googledorks/MainActivity.java +++ b/src/com/cmb/googledorks/MainActivity.java @@ -21,12 +21,16 @@ public class MainActivity extends Activity ArrayAdapter adapter; List list= null; private ShareActionProvider mShare; - + protected String dorkSelected = ""; @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflator = getMenuInflater(); inflator.inflate(R.menu.menu, menu); + // Set up shareactionprovider + MenuItem shareItem = menu.findItem(R.id.action_share); + mShare = (ShareActionProvider)shareItem.getActionProvider(); + mShare.setShareIntent(getShareItem()); return super.onCreateOptionsMenu(menu); } /** Called when the activity is first created. */ @@ -83,6 +87,17 @@ public class MainActivity extends Activity } }); + listV.setOnItemLongClickListener(new OnItemLongClickListener() { + + @Override + public boolean onItemLongClick(AdapterView arg0, View view, + int pos, long arg3) { + dorkSelected = list.get(pos).toString(); + return false; + } + + }); + listV.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int pos, long idt) { @@ -109,7 +124,7 @@ public class MainActivity extends Activity public boolean onOptionsItemSelected(MenuItem item) { // Take appropriate action for each action item click switch (item.getItemId()) { - case R.id.action_refresh: + case R.id.settings: // search action Intent intent_settings = new Intent(this, SettingsActivity.class); this.startActivity(intent_settings); @@ -120,9 +135,6 @@ public class MainActivity extends Activity sh.setTitle("About Google Dorks by CMB"); sh.show(); return true; - case R.id.action_share: - mShare = (ShareActionProvider)item.getActionProvider(); - return true; default: return super.onOptionsItemSelected(item); } @@ -135,4 +147,18 @@ public class MainActivity extends Activity Intent i = new Intent(MainActivity.this, ShowHelp.class); startActivity(i); } + + private void setShareIntent(Intent shareIntent) { + if (mShare != null) { + mShare.setShareIntent(shareIntent); + } + } + + private Intent getShareItem() { + Intent inten = new Intent(Intent.ACTION_SEND); + inten.putExtra(Intent.EXTRA_TEXT, dorkSelected); + inten.setType("text/plain"); + + return inten; + } }