summaryrefslogtreecommitdiffstats
path: root/src/net/hoopajoo/android/SoftKeys/Keys.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/hoopajoo/android/SoftKeys/Keys.java')
-rw-r--r--src/net/hoopajoo/android/SoftKeys/Keys.java136
1 files changed, 4 insertions, 132 deletions
diff --git a/src/net/hoopajoo/android/SoftKeys/Keys.java b/src/net/hoopajoo/android/SoftKeys/Keys.java
index ddb87dc..fa25ba9 100644
--- a/src/net/hoopajoo/android/SoftKeys/Keys.java
+++ b/src/net/hoopajoo/android/SoftKeys/Keys.java
@@ -79,37 +79,6 @@ public class Keys extends Activity implements OnClickListener, OnLongClickListen
private String homeaction;
private int delayed_action_time;
-
- // simple typedef used to make the notifications a bit more generic
- private class NotificationButton {
- String mPrefKey;
- RemoteViews mView;
- int mIconId;
- Drawable mIcon;
- String mButtonText;
- String mAction;
- String mExtraString;
-
- NotificationButton( String text, String pref, RemoteViews view, Drawable d, int icon, String act, String extra ) {
- mButtonText = text;
- mPrefKey = pref;
- mView = view;
- mIconId = icon;
- mIcon = d;
- mAction = act;
- mExtraString = extra;
- }
-
- NotificationButton( String text, String pref, RemoteViews view, Drawable d, int icon, String act ) {
- this( text, pref, view, d, icon, act, null );
- }
-
- NotificationButton( String text, String pref, int icon, String act ) {
- this( text, pref, null, null, icon, act, null );
- }
-
- }
-
// For use by the service and this activity
public static void applyButtons( SharedPreferences settings, View v,
OnClickListener onClick, OnLongClickListener onLongClick ) {
@@ -239,7 +208,7 @@ public class Keys extends Activity implements OnClickListener, OnLongClickListen
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- PreferenceManager.setDefaultValues( this, R.xml.prefs, true );
+ ((Globals)getApplication()).bootup();
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences( this );
setContentView( R.layout.main );
@@ -276,106 +245,6 @@ public class Keys extends Activity implements OnClickListener, OnLongClickListen
}else{
findViewById( R.id.recent_apps ).setVisibility( View.GONE );
}
-
- // Add notification buttons
- Globals app = (Globals)getApplication();
- if( ! app.didInitNotifications ) {
- String ns = Context.NOTIFICATION_SERVICE;
- NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
- Context context = getApplicationContext();
-
- // note: notification theming is kind of weird because of the way the notification manager
- // handles icons, the icon in the bar itself when the status bar is closed HAS to come
- // from the package creating the notification. We can however use any custom layouts
- // for the actual notification when the bar is open. So if we are using custom notifications
- // I just make the icon empty in the status bar which looks odd, but if we don't it would
- // need to be an icon from this package and not from the theme which would mean the pull
- // down notification would look different from the icon in the status bar itself which would
- // be annoying.
- //
- // However is technically is possibly to theme these to an extent currently it's just
- // not very ideal.
- NotificationButton[] nb = new NotificationButton[ 5 ];
- Theme theme = new Theme( this, settings.getString( "theme", null ) );
- nb[ 0 ] = new NotificationButton( "SoftKeys", "nb_softkeys",
- R.drawable.icon,
- Intent.ACTION_MAIN );
- nb[ 1 ] = new NotificationButton( "Menu", "nb_menu",
- theme.getRemoteViews( new String[] { "notification_menu" } ),
- theme.getDrawable( new String[] { "notification_menu" } ),
- R.drawable.button_menu,
- ACTION_MENU );
- nb[ 2 ] = new NotificationButton( "Home", "nb_home",
- theme.getRemoteViews( new String[] { "notification_home" } ),
- theme.getDrawable( new String[] { "notification_home" } ),
- R.drawable.button_home,
- ACTION_HOME );
- nb[ 3 ] = new NotificationButton( "Back", "nb_back",
- theme.getRemoteViews( new String[] { "notification_back" } ),
- theme.getDrawable( new String[] { "notification_back" } ),
- R.drawable.button_back,
- ACTION_BACK );
- nb[ 4 ] = new NotificationButton( "Search", "nb_search",
- theme.getRemoteViews( new String[] { "notification_search" } ),
- theme.getDrawable( new String[] { "notification_search" } ),
- R.drawable.button_search,
- ACTION_SEARCH );
-
- for( NotificationButton b : nb ) {
- if( settings.getBoolean( b.mPrefKey, false ) ) {
- Notification n = new Notification( b.mIconId, null, 0 );
- Intent si = new Intent( b.mAction );
- si.putExtra( "keyname", b.mExtraString );
- if( b.mAction == Intent.ACTION_MAIN ) {
- si.setPackage( getPackageName() );
- }else{
- //si.setPackage( getPackageName() );
- si.setClass( this, Keys.class );
- }
- PendingIntent i = PendingIntent.getActivity( this, 0, si, 0 );
-
- // if we got a drawable but no view then set up our own remote view
- // and add in their drawable
- if( b.mView == null && b.mIcon != null ) {
- b.mView = new RemoteViews( getPackageName(), R.layout.notification_bar_shortcut );
- // we run the drawable through resizeimage because that will rasterize it if it's
- // not already a bitmapdrawable
- b.mView.setImageViewBitmap( R.id.nb_image,
- ((BitmapDrawable)Generator.resizeImage( b.mIcon, 48, 48 )).getBitmap()
- );
- b.mView.setTextViewText( R.id.nb_text, "Press SoftKeys " + b.mButtonText + " Button" );
- }
-
- if( b.mView != null ) {
- // discard icon, use the remote view instead
- n.icon = -1; // this will make it draw a blank, this kind of sucks
- // but looking through notificationmanager and statusbarservice
- // you have to post some kind of icon, that id is based on the calling
- // package, and that icon is always added to the bar
- n.contentView = b.mView;
- n.contentIntent = i;
- }else{
- n.setLatestEventInfo( context, b.mButtonText,
- b.mAction == Intent.ACTION_MAIN ? "Start SoftKeys" :
- "Press SoftKeys " + b.mButtonText + " Button", i
- );
- }
-
- //Notification n = new Notification();
- n.flags |= Notification.FLAG_NO_CLEAR;
-
- // we use the same icon id as the notification id since it should be unique,
- // note the first parm here is a notification id we can use to reference/remove stuff
- // we're not passing an icon here
- mNotificationManager.notify( b.mIconId, n );
- }else{
- mNotificationManager.cancel( b.mIconId );
- }
- }
- // this way every time you click a notification soft key it doesn't readd them all making
- // them jump around as they are re-inserted
- app.didInitNotifications = true;
- }
return_after_back = settings.getBoolean( "return_home_after_back", false );
delayed_action = new Runnable() {
@@ -420,6 +289,8 @@ public class Keys extends Activity implements OnClickListener, OnLongClickListen
}
+ Globals app = ((Globals)getApplication());
+
//d( "Updating last version code: " + force_level );
if( settings.getInt( "last_intro_level", 0 ) < force_level ) {
Intent intent = new Intent( this, QuickDoc.class );
@@ -730,6 +601,7 @@ public class Keys extends Activity implements OnClickListener, OnLongClickListen
// redo notification buttons
((Globals)getApplication()).didInitNotifications = false;
((Globals)getApplication()).restartService();
+ ((Globals)getApplication()).initNotifications();
startActivity( new Intent( this, Keys.class ) );
}