Search in sources :

Example 41 with Intent

use of android.content.Intent in project UltimateAndroid by cymcsg.

the class MaterialRippleActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.switch_list) {
        startActivity(new Intent(this, MaterialRippleListActivity.class));
        finish();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : Intent(android.content.Intent)

Example 42 with Intent

use of android.content.Intent in project UltimateAndroid by cymcsg.

the class MaterialRippleListActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.switch_button) {
        startActivity(new Intent(this, MaterialRippleActivity.class));
        finish();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : Intent(android.content.Intent)

Example 43 with Intent

use of android.content.Intent in project Launcher3 by chislon.

the class LauncherTransitionable method updateVoiceSearchIcon.

protected boolean updateVoiceSearchIcon(boolean searchVisible) {
    final View voiceButtonContainer = findViewById(R.id.voice_button_container);
    final View voiceButton = findViewById(R.id.voice_button);
    // We only show/update the voice search icon if the search icon is enabled as well
    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity();
    ComponentName activityName = null;
    if (globalSearchActivity != null) {
        // Check if the global search activity handles voice search
        Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
        intent.setPackage(globalSearchActivity.getPackageName());
        activityName = intent.resolveActivity(getPackageManager());
    }
    if (activityName == null) {
        // Fallback: check if an activity other than the global search activity
        // resolves this
        Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
        activityName = intent.resolveActivity(getPackageManager());
    }
    if (searchVisible && activityName != null) {
        int coi = getCurrentOrientationIndexForGlobalIcons();
        sVoiceSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.voice_button, activityName, R.drawable.ic_home_voice_search_holo, TOOLBAR_VOICE_SEARCH_ICON_METADATA_NAME);
        if (sVoiceSearchIcon[coi] == null) {
            sVoiceSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.voice_button, activityName, R.drawable.ic_home_voice_search_holo, TOOLBAR_ICON_METADATA_NAME);
        }
        if (voiceButtonContainer != null)
            voiceButtonContainer.setVisibility(View.VISIBLE);
        voiceButton.setVisibility(View.VISIBLE);
        updateVoiceButtonProxyVisible(false);
        invalidatePressedFocusedStates(voiceButtonContainer, voiceButton);
        return true;
    } else {
        if (voiceButtonContainer != null)
            voiceButtonContainer.setVisibility(View.GONE);
        if (voiceButton != null)
            voiceButton.setVisibility(View.GONE);
        updateVoiceButtonProxyVisible(false);
        return false;
    }
}
Also used : SearchManager(android.app.SearchManager) ComponentName(android.content.ComponentName) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) AppWidgetHostView(android.appwidget.AppWidgetHostView) Point(android.graphics.Point)

Example 44 with Intent

use of android.content.Intent in project Launcher3 by chislon.

the class LauncherTransitionable method onClick.

/**
     * Launches the intent referred by the clicked shortcut.
     *
     * @param v The view representing the clicked shortcut.
     */
public void onClick(View v) {
    // view has detached (it's possible for this to happen if the view is removed mid touch).
    if (v.getWindowToken() == null) {
        return;
    }
    if (!mWorkspace.isFinishedSwitchingState()) {
        return;
    }
    if (v instanceof Workspace) {
        if (mWorkspace.isInOverviewMode()) {
            mWorkspace.exitOverviewMode(true);
        }
        return;
    }
    if (v instanceof CellLayout) {
        if (mWorkspace.isInOverviewMode()) {
            mWorkspace.exitOverviewMode(mWorkspace.indexOfChild(v), true);
        }
    }
    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
        // Open shortcut
        final ShortcutInfo shortcut = (ShortcutInfo) tag;
        final Intent intent = shortcut.intent;
        // Check for special shortcuts
        if (intent.getComponent() != null) {
            final String shortcutClass = intent.getComponent().getClassName();
            if (shortcutClass.equals(WidgetAdder.class.getName())) {
                showAllApps(true, AppsCustomizePagedView.ContentType.Widgets, true);
                return;
            } else if (shortcutClass.equals(MemoryDumpActivity.class.getName())) {
                MemoryDumpActivity.startDump(this);
                return;
            } else if (shortcutClass.equals(ToggleWeightWatcher.class.getName())) {
                toggleShowWeightWatcher();
                return;
            }
        }
        // Start activities
        int[] pos = new int[2];
        v.getLocationOnScreen(pos);
        intent.setSourceBounds(new Rect(pos[0], pos[1], pos[0] + v.getWidth(), pos[1] + v.getHeight()));
        boolean success = startActivitySafely(v, intent, tag);
        mStats.recordLaunch(intent, shortcut);
        if (success && v instanceof BubbleTextView) {
            mWaitingForResume = (BubbleTextView) v;
            mWaitingForResume.setStayPressed(true);
        }
    } else if (tag instanceof FolderInfo) {
        if (v instanceof FolderIcon) {
            FolderIcon fi = (FolderIcon) v;
            handleFolderClick(fi);
        }
    } else if (v == mAllAppsButton) {
        if (isAllAppsVisible()) {
            showWorkspace(true);
        } else {
            onClickAllAppsButton(v);
        }
    }
}
Also used : Rect(android.graphics.Rect) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent) DragObject(com.android.launcher3.DropTarget.DragObject)

Example 45 with Intent

use of android.content.Intent in project Launcher3 by chislon.

the class LauncherTransitionable method processShortcut.

void processShortcut(Intent intent) {
    // Handle case where user selected "Applications"
    String applicationName = getResources().getString(R.string.group_applications);
    String shortcutName = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
    if (applicationName != null && applicationName.equals(shortcutName)) {
        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY);
        pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent);
        pickIntent.putExtra(Intent.EXTRA_TITLE, getText(R.string.title_select_application));
        Utilities.startActivityForResultSafely(this, pickIntent, REQUEST_PICK_APPLICATION);
    } else {
        Utilities.startActivityForResultSafely(this, intent, REQUEST_CREATE_SHORTCUT);
    }
}
Also used : Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent)

Aggregations

Intent (android.content.Intent)13686 PendingIntent (android.app.PendingIntent)2730 View (android.view.View)1004 ComponentName (android.content.ComponentName)943 Bundle (android.os.Bundle)841 ResolveInfo (android.content.pm.ResolveInfo)743 Uri (android.net.Uri)707 Context (android.content.Context)663 RemoteException (android.os.RemoteException)657 TextView (android.widget.TextView)624 PackageManager (android.content.pm.PackageManager)524 Test (org.junit.Test)509 IntentFilter (android.content.IntentFilter)496 ArrayList (java.util.ArrayList)465 ActivityNotFoundException (android.content.ActivityNotFoundException)376 ImageView (android.widget.ImageView)375 BroadcastReceiver (android.content.BroadcastReceiver)354 IOException (java.io.IOException)353 File (java.io.File)337 Notification (android.app.Notification)283