Search in sources :

Example 1 with StandOutWindow

use of wei.mark.standout.StandOutWindow in project StandOut by pingpongboss.

the class MultiWindow method onReceiveData.

@Override
public void onReceiveData(int id, int requestCode, Bundle data, Class<? extends StandOutWindow> fromCls, int fromId) {
    // to show off the data sending framework
    switch(requestCode) {
        case WidgetsWindow.DATA_CHANGED_TEXT:
            Window window = getWindow(id);
            if (window == null) {
                String errorText = String.format(Locale.US, "%s received data but Window id: %d is not open.", getAppName(), id);
                Toast.makeText(this, errorText, Toast.LENGTH_SHORT).show();
                return;
            }
            String changedText = data.getString("changedText");
            TextView status = (TextView) window.findViewById(R.id.id);
            status.setTextSize(20);
            status.setText("Received data from WidgetsWindow: " + changedText);
            break;
        default:
            Log.d("MultiWindow", "Unexpected data received.");
            break;
    }
}
Also used : Window(wei.mark.standout.ui.Window) StandOutWindow(wei.mark.standout.StandOutWindow) TextView(android.widget.TextView)

Example 2 with StandOutWindow

use of wei.mark.standout.StandOutWindow in project StandOut by pingpongboss.

the class FloatingFolder method onReceiveData.

@Override
public void onReceiveData(int id, int requestCode, Bundle data, Class<? extends StandOutWindow> fromCls, int fromId) {
    switch(requestCode) {
        case APP_SELECTOR_CODE:
            if (APP_SELECTOR_ID == id) {
                // app selector receives data
                Window window = show(APP_SELECTOR_ID);
                window.data.putInt("fromId", fromId);
            }
            break;
        case APP_SELECTOR_FINISHED_CODE:
            final ActivityInfo app = data.getParcelable("app");
            Log.d("FloatingFolder", "Received app: " + app);
            Window window = getWindow(id);
            if (window == null) {
                return;
            }
            ViewGroup flow = (ViewGroup) window.findViewById(R.id.flow);
            addAppToFolder(id, app, flow);
            onUserAddApp(id, app);
            break;
        case STARTUP_CODE:
            loadAllFolders();
            if (mFolders.size() == 0) {
                mFolders.put(DEFAULT_ID, new FolderModel());
                show(DEFAULT_ID);
            } else {
                for (int i = 0; i < mFolders.size(); i++) {
                    FolderModel folder = mFolders.get(mFolders.keyAt(i));
                    if (folder.shown) {
                        show(folder.id);
                    }
                }
            }
            break;
    }
}
Also used : Window(wei.mark.standout.ui.Window) StandOutWindow(wei.mark.standout.StandOutWindow) ActivityInfo(android.content.pm.ActivityInfo) ViewGroup(android.view.ViewGroup)

Example 3 with StandOutWindow

use of wei.mark.standout.StandOutWindow in project Roundr by MohammadAdib.

the class Corner method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null) {
        String action = intent.getAction();
        int corner = intent.getIntExtra("id", DEFAULT_ID);
        if (corner == ONGOING_NOTIFICATION_ID) {
            throw new RuntimeException("ID cannot equals StandOutWindow.ONGOING_NOTIFICATION_ID");
        }
        if (ACTION_SHOW.equals(action) || ACTION_RESTORE.equals(action)) {
            show(corner);
        } else if (ACTION_SETTINGS.equals(action)) {
            try {
                Intent intentS = new Intent(this, SettingsActivity.class);
                intentS.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intentS);
            } catch (Exception e) {
            // Addressing this issue: http://i.imgur.com/Op9kfy8.png
            }
        } else if (ACTION_HIDE.equals(action)) {
            hide(corner);
        } else if (ACTION_CLOSE.equals(action)) {
            close(corner);
        } else if (ACTION_CLOSE_ALL.equals(action)) {
            closeAll();
        } else if (ACTION_SEND_DATA.equals(action)) {
            if (isExistingId(corner) || corner == DISREGARD_ID) {
                Bundle data = intent.getBundleExtra("wei.mark.standout.data");
                int requestCode = intent.getIntExtra("requestCode", 0);
                @SuppressWarnings("unchecked") Class<? extends StandOutWindow> fromCls = (Class<? extends StandOutWindow>) intent.getSerializableExtra("wei.mark.standout.fromCls");
                int fromId = intent.getIntExtra("fromId", DEFAULT_ID);
                onReceiveData(corner, requestCode, data, fromCls, fromId);
            }
        }
    }
    return START_NOT_STICKY;
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) SuppressLint(android.annotation.SuppressLint) StandOutWindow(wei.mark.standout.StandOutWindow)

Example 4 with StandOutWindow

use of wei.mark.standout.StandOutWindow in project Roundr by MohammadAdib.

the class Corner method onReceiveData.

@Override
public void onReceiveData(int corner, int requestCode, Bundle data, Class<? extends StandOutWindow> fromCls, int fromId) {
    Window window = getWindow(corner);
    if (requestCode == UPDATE_CODE) {
        // Update the corners when device is rotated
        updateViewLayout(3, getParams(3, window));
        updateViewLayout(2, getParams(2, window));
        updateViewLayout(1, getParams(1, window));
        updateViewLayout(0, getParams(0, window));
    } else if (requestCode == NOTIFICATION_CODE) {
        if (!prefs.getBoolean("notification", true)) {
            // Hide Notification Icon (for <= Gingerbread devices only)
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            Notification notification = getPersistentNotification(corner);
            notification.icon = wei.mark.standout.R.drawable.nothing;
            mNotificationManager.notify(getClass().hashCode() + ONGOING_NOTIFICATION_ID, notification);
            Log.d("Hello World", "");
        } else {
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            Notification notification = getPersistentNotification(corner);
            mNotificationManager.notify(getClass().hashCode() + ONGOING_NOTIFICATION_ID, notification);
        }
    }
}
Also used : Window(wei.mark.standout.ui.Window) StandOutWindow(wei.mark.standout.StandOutWindow) NotificationManager(android.app.NotificationManager) Notification(android.app.Notification)

Aggregations

StandOutWindow (wei.mark.standout.StandOutWindow)4 Window (wei.mark.standout.ui.Window)3 SuppressLint (android.annotation.SuppressLint)1 Notification (android.app.Notification)1 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 ActivityInfo (android.content.pm.ActivityInfo)1 Bundle (android.os.Bundle)1 ViewGroup (android.view.ViewGroup)1 TextView (android.widget.TextView)1