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:
@@ -30,6 +30,8 @@
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
||||
<action android:name="android.intent.action.CREATE_SHORTCUT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
@@ -88,7 +90,7 @@
|
||||
android:process=":PassiveLocationChangedReceiver" />
|
||||
|
||||
<activity
|
||||
android:name=".ui.LauncherShortcuts"
|
||||
android:name=".ui.CheckLocationShortcut"
|
||||
android:theme="@android:style/Theme.Translucent" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.CREATE_SHORTCUT" />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* LauncherShortcuts.java
|
||||
* CheckLocationShortcut.java
|
||||
* @date May 22, 2012
|
||||
* @author ricky barrette
|
||||
* @author Twenty Codes, LLC
|
||||
@@ -21,7 +21,6 @@
|
||||
package com.TwentyCodes.android.LocationRinger.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
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
|
||||
* or start a particular operation.
|
||||
*/
|
||||
public class LauncherShortcuts extends Activity {
|
||||
public class CheckLocationShortcut extends Activity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
@@ -18,6 +18,7 @@ import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Parcelable;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
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_EDIT = 4;
|
||||
private static final String KEY_ROWID = "key_row_id";
|
||||
public static final String ACTION_NEW_RINGER = "action_new_ringer";
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
@@ -119,7 +121,7 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
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
|
||||
public void onCreate(Bundle 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);
|
||||
this.setTitle(R.string.app_name);
|
||||
this.mDb = new RingerDatabase(this, this);
|
||||
@@ -167,9 +181,12 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
|
||||
if(!this.getIntent().hasExtra(NO_SPLASH))
|
||||
showSplashScreen();
|
||||
|
||||
if(action.equals(ACTION_NEW_RINGER))
|
||||
startActivityForResult(new Intent(this, RingerInformationActivity.class), ACTIVITY_CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* called when the activity is first created, creates a context menu
|
||||
* @param menu
|
||||
* @param v
|
||||
@@ -182,8 +199,8 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.ringer_list_context_menu, menu);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* called when the activity is first created, creates options menu
|
||||
* (non-Javadoc)
|
||||
* @see android.app.Activity#onCreateOptionsMenu(android.view.Menu)
|
||||
@@ -196,8 +213,8 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Called when a database is being upgraded
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@@ -205,8 +222,8 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
public void onDatabaseUpgrade() {
|
||||
this.mProgress = ProgressDialog.show(this, "", this.getText(R.string.upgrading), true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* called when a database upgrade is finished
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@@ -280,7 +297,7 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* called when an option is selected form the menu
|
||||
* (non-Javadoc)
|
||||
@@ -307,7 +324,7 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.app.Activity#onPause()
|
||||
*/
|
||||
@@ -333,7 +350,7 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
populate();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* populates the list view from the data base
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@@ -342,7 +359,7 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
mListView.setAdapter(new RingerListAdapter(this, mDb));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Removes the Dialog that displays the splash screen
|
||||
*/
|
||||
protected void removeSplashScreen() {
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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.FeatureListFragment;
|
||||
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.TitledFragmentAdapter;
|
||||
|
||||
@@ -69,6 +70,10 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
@Override
|
||||
protected void onCreate(Bundle arg0) {
|
||||
super.onCreate(arg0);
|
||||
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
|
||||
|
||||
final Intent intent = getIntent();
|
||||
|
||||
setContentView(R.layout.ringer_information_activity);
|
||||
|
||||
/*
|
||||
@@ -77,7 +82,7 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
if(Debug.SUPPORTS_HONEYCOMB)
|
||||
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.mInfo = this.mData.getParcelableExtra(ListActivity.KEY_INFO);
|
||||
|
||||
Reference in New Issue
Block a user