Added a new ringer shortcut

and I renamed LauncherShortCuts to CheckLocationShortcut

closes #93

Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-06-04 10:37:12 -04:00
parent 22722a578b
commit 62bb65afd8
4 changed files with 58 additions and 18 deletions

View File

@@ -30,6 +30,8 @@
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.CREATE_SHORTCUT" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
@@ -88,7 +90,7 @@
android:process=":PassiveLocationChangedReceiver" /> android:process=":PassiveLocationChangedReceiver" />
<activity <activity
android:name=".ui.LauncherShortcuts" android:name=".ui.CheckLocationShortcut"
android:theme="@android:style/Theme.Translucent" > android:theme="@android:style/Theme.Translucent" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" /> <action android:name="android.intent.action.CREATE_SHORTCUT" />

View File

@@ -1,5 +1,5 @@
/** /**
* LauncherShortcuts.java * CheckLocationShortcut.java
* @date May 22, 2012 * @date May 22, 2012
* @author ricky barrette * @author ricky barrette
* @author Twenty Codes, LLC * @author Twenty Codes, LLC
@@ -21,7 +21,6 @@
package com.TwentyCodes.android.LocationRinger.ui; package com.TwentyCodes.android.LocationRinger.ui;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcelable; import android.os.Parcelable;
@@ -56,7 +55,7 @@ import com.TwentyCodes.android.debug.LocationLibraryConstants;
* In a real application, you would probably use the shortcut intent to display specific content * In a real application, you would probably use the shortcut intent to display specific content
* or start a particular operation. * or start a particular operation.
*/ */
public class LauncherShortcuts extends Activity { public class CheckLocationShortcut extends Activity {
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {

View File

@@ -18,6 +18,7 @@ import android.database.Cursor;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.Parcelable;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu; import android.view.Menu;
@@ -60,6 +61,7 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
private static final int ACTIVITY_CREATE = 3; private static final int ACTIVITY_CREATE = 3;
private static final int ACTIVITY_EDIT = 4; private static final int ACTIVITY_EDIT = 4;
private static final String KEY_ROWID = "key_row_id"; private static final String KEY_ROWID = "key_row_id";
public static final String ACTION_NEW_RINGER = "action_new_ringer";
@Override @Override
public void done() { public void done() {
@@ -119,7 +121,7 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent i = new Intent(this, RingerInformationActivity.class); Intent i = new Intent(this, RingerInformationActivity.class);
startActivityForResult(i, ACTIVITY_CREATE ); startActivityForResult(i, ACTIVITY_CREATE);
} }
/** /**
@@ -147,6 +149,18 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
final Intent intent = getIntent();
final String action = intent.getAction();
// If the intent is a request to create a shortcut, we'll do that and exit
if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) {
setupShortcut();
finish();
return;
}
setContentView(R.layout.ringer_list); setContentView(R.layout.ringer_list);
this.setTitle(R.string.app_name); this.setTitle(R.string.app_name);
this.mDb = new RingerDatabase(this, this); this.mDb = new RingerDatabase(this, this);
@@ -167,6 +181,9 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
if(!this.getIntent().hasExtra(NO_SPLASH)) if(!this.getIntent().hasExtra(NO_SPLASH))
showSplashScreen(); showSplashScreen();
if(action.equals(ACTION_NEW_RINGER))
startActivityForResult(new Intent(this, RingerInformationActivity.class), ACTIVITY_CREATE);
} }
/** /**
@@ -369,6 +386,23 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
} }
} }
/**
* Creates a shortcut for the launcher
* @author ricky barrette
*/
private void setupShortcut() {
Intent shortcutIntent = new Intent(this, this.getClass());
shortcutIntent.setAction(ACTION_NEW_RINGER);
//set up the container intent and return to the launcher
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.new_ringer));
Parcelable iconResource = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
setResult(RESULT_OK, intent);
}
/** /**
* Shows the splash screen over the full Activity * Shows the splash screen over the full Activity
*/ */

View File

@@ -35,6 +35,7 @@ import com.TwentyCodes.android.LocationRinger.debug.Debug;
import com.TwentyCodes.android.LocationRinger.ui.fragments.AboutRingerFragment; import com.TwentyCodes.android.LocationRinger.ui.fragments.AboutRingerFragment;
import com.TwentyCodes.android.LocationRinger.ui.fragments.FeatureListFragment; import com.TwentyCodes.android.LocationRinger.ui.fragments.FeatureListFragment;
import com.TwentyCodes.android.LocationRinger.ui.fragments.LocationInfomationFragment; import com.TwentyCodes.android.LocationRinger.ui.fragments.LocationInfomationFragment;
import com.TwentyCodes.android.exception.ExceptionHandler;
import com.jakewharton.android.viewpagerindicator.TitlePageIndicator; import com.jakewharton.android.viewpagerindicator.TitlePageIndicator;
import com.jakewharton.android.viewpagerindicator.TitledFragmentAdapter; import com.jakewharton.android.viewpagerindicator.TitledFragmentAdapter;
@@ -69,6 +70,10 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
@Override @Override
protected void onCreate(Bundle arg0) { protected void onCreate(Bundle arg0) {
super.onCreate(arg0); super.onCreate(arg0);
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
final Intent intent = getIntent();
setContentView(R.layout.ringer_information_activity); setContentView(R.layout.ringer_information_activity);
/* /*
@@ -77,7 +82,7 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
if(Debug.SUPPORTS_HONEYCOMB) if(Debug.SUPPORTS_HONEYCOMB)
getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true);
this.mData = new Intent().putExtras(RingerInformationActivity.this.getIntent()); this.mData = new Intent().putExtras(intent);
this.mRinger = this.mData.getParcelableExtra(ListActivity.KEY_RINGER); this.mRinger = this.mData.getParcelableExtra(ListActivity.KEY_RINGER);
this.mInfo = this.mData.getParcelableExtra(ListActivity.KEY_INFO); this.mInfo = this.mData.getParcelableExtra(ListActivity.KEY_INFO);