ActionBar ShareActionProvider debugging

master
Chris Baughman 2014-02-13 16:04:15 -05:00
parent 5d1d559c8a
commit 31c6171a9e
10 changed files with 47 additions and 41 deletions

View File

@ -2,15 +2,18 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cmb.googledorks" package="com.cmb.googledorks"
android:versionCode="1" android:versionCode="1"
android:versionName="1.0" > android:versionName="1.0"
android:installLocation="auto">
<uses-sdk <uses-sdk
android:minSdkVersion="8" android:minSdkVersion="11"
android:targetSdkVersion="11" /> android:targetSdkVersion="19" />
<application <application
android:icon="@drawable/ic_launcher" android:icon="@drawable/ic_launcher"
android:label="@string/app_name" > android:allowBackup="true"
android:label="@string/app_name"
android:logo="@drawable/cube">
<activity <activity
android:label="@string/app_name" android:label="@string/app_name"
android:name=".MainActivity" > android:name=".MainActivity" >

5
lint.xml Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="MissingTranslation" severity="informational" />
<issue id="Orientation" severity="warning" />
</lint>

View File

@ -10,4 +10,5 @@
# Project target. # Project target.
target=android-19 target=android-19
android.library.reference.1=../../workspace/gridlayout_v7 android.library.reference.1=../../workspace/gridlayout_v7
android.library.reference.1=/storage/emulated/0/Download/android-support-v7-appcompat-master/android-support-v7-appcompat-master android.library.reference.1=../../workspace/gridlayout_v7
android.library.reference.2=../../workspace/android-support-v7-appcompat

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:GoogleDorks="http://schemas.android.com/apk/res-auto"> xmlns:support="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_help" <item android:id="@+id/action_help"
android:icon="@drawable/ic_action_help" android:icon="@drawable/ic_action_help"
android:title="@string/action_help" android:title="@string/action_help"
android:showAsAction="ifRoom" /> support:showAsAction="ifRoom" />
<!-- Share / will display always --> <!-- Share / will display always -->
<item android:id="@+id/action_share" <item android:id="@+id/action_share"
android:icon="@drawable/ic_action_share" android:icon="@drawable/ic_action_share"
android:title="@string/action_share" android:title="@string/action_share"
GoogleDorks:showAsAction="always" support:showAsAction="always"
GoogleDorks:actionProviderClass="android.support.v7.widget.ShareActionProvider" /> support:actionProviderClass="android.support.v7.widget.ShareActionProvider" />
</menu> </menu>

View File

@ -2,7 +2,7 @@
<resources> <resources>
<string name="app_name">Google Dorks</string> <string name="app_name">Google Dorks</string>
<string name="rss_layout_urltext_text">http://rss.slashdot.org/Slashdot/slashdot</string> <string name="rss_layout_urltext_text">http://rss.slashdot.org/Slashdot/slashdot</string>
<string name="rss_layout_statustext_text">Updating...</string> <string name="rss_layout_statustext_text">Updating&#8230;</string>
<string name="rss_layout_download_text">Download</string> <string name="rss_layout_download_text">Download</string>
<string name="dork_items_prompt">Choose a category</string> <string name="dork_items_prompt">Choose a category</string>
<string-array name="dork_items"> <string-array name="dork_items">
@ -26,5 +26,5 @@
<string name="action_settings">Settings</string> <string name="action_settings">Settings</string>
<string name="spinner_prompt">Select</string> <string name="spinner_prompt">Select</string>
<string name="choose_source">Choose Source</string> <string name="choose_source">Choose Source</string>
</resources> </resources>

View File

@ -0,0 +1,7 @@
package com.cmb.googledorks;
public interface Constants {
final String LOG = "com.cmb.googledorks";
final int ABOUT = 0;
}

View File

@ -1,11 +1,6 @@
package com.cmb.googledorks; package com.cmb.googledorks;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*; import android.widget.*;
import org.xml.sax.*;
import android.content.*; import android.content.*;
import java.io.*; import java.io.*;
import android.content.res.*; import android.content.res.*;

View File

@ -2,32 +2,34 @@ package com.cmb.googledorks;
import android.app.*; import android.app.*;
import android.os.*; import android.os.*;
import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.*; import android.widget.*;
import android.view.View.*;
import java.util.*; import java.util.*;
import android.widget.AdapterView.*; import android.widget.AdapterView.*;
import java.io.UnsupportedEncodingException;
import java.net.*; import java.net.*;
import android.content.*; import android.content.*;
import android.net.*; import android.net.*;
import android.support.v4.view.*; import android.support.v4.view.*;
import android.support.v7.widget.ShareActionProvider; import android.support.v7.widget.ShareActionProvider;
public class MainActivity extends Activity public class MainActivity extends Activity implements Constants
{ {
Spinner catSpin; Spinner catSpin;
ListView listV; ListView listV;
final GetGoogleDorks dorks = new GetGoogleDorks(); final GetGoogleDorks dorks = new GetGoogleDorks();
final public int ABOUT = 0; public final String TAG = "MainActivity";
ArrayAdapter<String> adapter; ArrayAdapter<String> adapter;
List<String> list= null; List<String> list= null;
private ShareActionProvider mShare; private ShareActionProvider mShare;
protected String dorkSelected = ""; protected String dorkSelected = "";
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu); getMenuInflater().inflate(R.menu.menu, menu);
@ -43,6 +45,8 @@ public class MainActivity extends Activity
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.main); setContentView(R.layout.main);
if (BuildConfig.DEBUG) { Log.d(TAG, LOG + " onCreate Called"); }
listV = (ListView)findViewById(R.id.listBox); listV = (ListView)findViewById(R.id.listBox);
catSpin = (Spinner)findViewById(R.id.catSpin); catSpin = (Spinner)findViewById(R.id.catSpin);
@ -86,7 +90,7 @@ public class MainActivity extends Activity
@Override @Override
public void onNothingSelected(AdapterView<?> parent) { public void onNothingSelected(AdapterView<?> parent) {
//required implememt //required to implement
} }
}); });
@ -106,18 +110,22 @@ public class MainActivity extends Activity
listV.setOnItemClickListener(new OnItemClickListener() { listV.setOnItemClickListener(new OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int pos, long idt) { public void onItemClick(AdapterView<?> parent, View view, int pos, long idt) {
Uri uuri = null;
if(list.get(pos).toString().startsWith("http")) { if(list.get(pos).toString().startsWith("http")) {
startActivity(new Intent(Intent.ACTION_VIEW, uuri = Uri.parse(list.get(pos).toString());
Uri.parse(list.get(pos)))); startActivity(new Intent(Intent.ACTION_VIEW, uuri));
} }
else { else {
startActivity(new Intent(Intent.ACTION_VIEW, try {
Uri.parse("http://www.google.com/#q=" uuri = Uri.parse("http://www.google.com/#q=" + URLEncoder.encode(list.get(pos), "UTF-8"));
+ URLEncoder.encode(list.get(pos))))); }
catch(UnsupportedEncodingException uex) {
Log.e(TAG, LOG, uex);
}
startActivity(new Intent(Intent.ACTION_VIEW, uuri));
} }
Toast.makeText(getBaseContext() Toast.makeText(getBaseContext(), uuri.toString(), Toast.LENGTH_LONG).show();
, "Opening http://google.com/#q=" + URLEncoder.encode(list.get(pos)), Toast.LENGTH_LONG).show();
} }
}); });
} }
@ -139,14 +147,6 @@ public class MainActivity extends Activity
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
} }
/**
* Launching new activity
* */
private void ShowShare() {
Intent i = new Intent(MainActivity.this, ShowHelp.class);
startActivity(i);
}
private void setShareIntent(Intent shareIntent) { private void setShareIntent(Intent shareIntent) {
if (mShare != null) { if (mShare != null) {
@ -157,7 +157,6 @@ public class MainActivity extends Activity
private Intent getShareItem() { private Intent getShareItem() {
Intent inten = new Intent(Intent.ACTION_SEND); Intent inten = new Intent(Intent.ACTION_SEND);
inten.setType("image/*"); inten.setType("image/*");
return inten; return inten;
} }
} }

View File

@ -2,9 +2,6 @@ package com.cmb.googledorks;
import android.app.*; import android.app.*;
import android.os.*; import android.os.*;
import android.view.*;
import android.widget.*;
import android.view.View.*;
public class SettingsActivity extends Activity public class SettingsActivity extends Activity
{ {

View File

@ -11,7 +11,6 @@ import android.text.Html;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.graphics.Color; import android.graphics.Color;
import android.widget.TextView; import android.widget.TextView;
import android.content.res.*;
public class ShowHelp extends Dialog public class ShowHelp extends Dialog
{ {