Example usage for android.content Intent addCategory

List of usage examples for android.content Intent addCategory

Introduction

In this page you can find the example usage for android.content Intent addCategory.

Prototype

public @NonNull Intent addCategory(String category) 

Source Link

Document

Add a new category to the intent.

Usage

From source file:com.android.mms.ui.MessageUtils.java

private static List<String> getHomes(Context context) {
    MmsLog.d(TAG, "DialogModeActivity.getHomes");

    List<String> names = new ArrayList<String>();
    PackageManager packageManager = context.getPackageManager();
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent,
            PackageManager.MATCH_DEFAULT_ONLY);

    for (ResolveInfo ri : resolveInfo) {
        names.add(ri.activityInfo.packageName);
        MmsLog.d(TAG, "package name=" + ri.activityInfo.packageName + " class name=" + ri.activityInfo.name);
    }/*  w  w  w.  j av  a2s .  c  o  m*/
    return names;
}

From source file:com.android.mms.ui.MessageUtils.java

public static void selectAudio(Activity activity, int requestCode) {
    // / M: Code analyze 027, new feature, to improve the performance of
    // Mms. @{//from   w w  w . j a  v a 2  s  .c o  m
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType(MmsContentType.AUDIO_UNSPECIFIED);
    String[] mimeTypess = new String[] { MmsContentType.AUDIO_UNSPECIFIED, MmsContentType.AUDIO_OGG,
            "application/x-ogg" };
    intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypess);
    if (FeatureOption.MTK_DRM_APP) {
        intent.putExtra(OmaDrmStore.DrmIntentExtra.EXTRA_DRM_LEVEL, OmaDrmStore.DrmIntentExtra.LEVEL_SD);
    }
    /// @}
    activity.startActivityForResult(intent, requestCode);
}

From source file:com.custom.music.MusicBrowserActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Cursor cursor;/*ww w .jav  a2s .  c o  m*/
    Intent intent;
    switch (item.getItemId()) {
    case PLAY_ALL:
        String sortOrder_play_all = MediaStore.Audio.Media.DEFAULT_SORT_ORDER;
        if (MusicUtils.isMediaTitlePinyinKeyExist()) {
            sortOrder_play_all = "title_pinyin_key";
        }
        cursor = MusicUtils.query(this, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                new String[] { MediaStore.Audio.Media._ID }, MediaStore.Audio.Media.IS_MUSIC + "=1", null,
                /// M: add for chinese sorting
                sortOrder_play_all);
        if (cursor != null) {
            MusicUtils.playAll(this, cursor);
            cursor.close();
        }
        return true;
    case SHUFFLE_ALL:
        String sortOrder_shuffle_all = MediaStore.Audio.Media.DEFAULT_SORT_ORDER;
        if (MusicUtils.isMediaTitlePinyinKeyExist()) {
            sortOrder_shuffle_all = "title_pinyin_key";
        }
        cursor = MusicUtils.query(this, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                new String[] { MediaStore.Audio.Media._ID }, MediaStore.Audio.Media.IS_MUSIC + "=1", null,
                /// M: add for chinese sorting
                sortOrder_shuffle_all);
        if (cursor != null) {
            MusicUtils.shuffleAll(this, cursor);
            cursor.close();
        }
        return true;

    case EFFECTS_PANEL:
        return MusicUtils.startEffectPanel(this);

    case R.id.search:
        onSearchRequested();
        return true;

    case TrackBrowserActivity.ADD_FOLDER_TO_PLAY:
        intent = new Intent("com.mediatek.filemanager.DOWNLOAD_LOCATION");
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        this.startActivityForResult(intent, TrackBrowserActivity.ADD_FOLDER_TO_PLAY);
        return true;

    case PlaylistBrowserActivity.ADD_FOLDER_AS_PLAYLIST:
        intent = new Intent("com.mediatek.filemanager.DOWNLOAD_LOCATION");
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        this.startActivityForResult(intent, PlaylistBrowserActivity.ADD_FOLDER_AS_PLAYLIST);
        return true;

    case TrackBrowserActivity.ADD_SONG_TO_PLAY:
        intent = new Intent("com.mediatek.filemanager.ADD_FILE");
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        this.startActivityForResult(intent, TrackBrowserActivity.ADD_SONG_TO_PLAY);
        return true;

    default:
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.aliyun.homeshell.Folder.java

public void onDropCompleted(View target, DragObject d, boolean isFlingToDelete, boolean success) {
    mDropAccepted = success;//  w  w w  .  ja  v a2  s  .c o m
    Log.d(TAG,
            "sxsexe---------> onDropCompleted dragInfo " + d.dragInfo + " success " + success
                    + " mDeleteFolderOnDropCompleted " + mDeleteFolderOnDropCompleted
                    + " mItemAddedBackToSelfViaIcon " + mItemAddedBackToSelfViaIcon + " item count "
                    + getItemCount() + " mHasDirtyData " + mHasDirtyData);
    /*YUNOS BEGIN*/
    //##module(component name)
    //##date:2014/03/28 ##author:jun.dongj@alibaba-inc.com##BugID:105531
    //there is a cellayout outline when drag icon in folder, otherwise, hide it
    showDragOutline(false);
    /*YUNOS END*/
    mShortcutInfoCache = (ShortcutInfo) d.dragInfo;
    mLauncher.setCurrentFolder(this);
    if (success) {
        if (target instanceof DeleteDropTarget
                && mShortcutInfoCache.itemType == Favorites.ITEM_TYPE_APPLICATION) {
            /* YUNOS BEGIN PB*/
            //##modules(HomeShell): ##author:guoshuai.lgs
            //##BugID:(5221896) ##date:2014/09/03
            //##decrpition: support mainmenu feature, cancel drop feature, page management feature, and so on
            if (!LauncherApplication.isMainmenuMode()) {
                //go to uninstall or remove, 
                Log.d(TAG, "sxsexe---------> onDropCompleted do not need to replaceFolderWithFinalItem");
                mHasDirtyData = true;

                /*YUNOS BEGIN*/
                //##date:2014/01/18 ##author:hao.liuhaolh ##BugID:83464
                //app icon remove issue in folder
                if ((mShortcutInfoCache.intent != null) && (mShortcutInfoCache.intent.getComponent() != null)
                        && (mShortcutInfoCache.intent.getComponent().getPackageName() != null)) {
                    boolean storgeMount = Environment.getExternalStorageState()
                            .equals(Environment.MEDIA_MOUNTED);

                    String packageName = mShortcutInfoCache.intent.getComponent().getPackageName();
                    final PackageManager packageManager = ((Context) mLauncher).getPackageManager();

                    final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
                    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                    mainIntent.setPackage(packageName);
                    final List<ResolveInfo> apps = packageManager.queryIntentActivities(mainIntent, 0);
                    if ((apps == null || apps.size() == 0) && (storgeMount == true)) {
                        Log.d(TAG, "no app info, so it need to be cleaned");
                        mHasDirtyData = false;
                    }
                }
            }
            /*YUNOS END PB*/
            /*YUNOS END*/
        }
        /*YUNOS BEGIN*/
        //##date:2014/7/2 ##author:yangshan.ys##BugID:134407
        //if the target is workspace or hotseat when drag or fling icon ,call this method
        mDeleteFolderOnDropCompleted = mInfo.count() <= 1;
        if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelfViaIcon
                && !(target instanceof DeleteDropTarget)) {
            /*YUNOS END*/
            if (!mHasDirtyData) {
                //drag to workspace or hotseat
                replaceFolderWithFinalItem();
                this.setNeedReplaceFolderWithFinalItemFlase();
            }
        }
    } else {
        Log.d(TAG, "sxsexe---------> onDropCompleted drag failed need to get the item back ");
        /*YUNOS BEGIN*/
        //##date:2014/06/18 ##author:guoshuai.lgs ##BugID:
        //support the folder feature in mainmenu
        if (LauncherApplication.isMainmenuMode() && (mInfo.isMainmenuFolder())) {
            // Exit spring loaded mode if we have not successfully dropped or have not handled the
            // drop in Workspace
            //Delete the dragview
            d.deferDragViewCleanupPostAnimation = false;
            mLauncher.exitSpringLoadedDragMode();
        } else {
            // The drag failed, we need to return the item to the folder
            mFolderIcon.onDrop(d);
        }
        /*YUNOS END*/

        // We're going to trigger a "closeFolder" which may occur before this item has
        // been added back to the folder -- this could cause the folder to be deleted
        if (mOnExitAlarm.alarmPending()) {
            mSuppressFolderDeletion = true;
        }
    }

    if (target != this) {
        if (mOnExitAlarm.alarmPending()) {
            mOnExitAlarm.cancelAlarm();
            completeDragExit();
        }
    }
    mDeleteFolderOnDropCompleted = false;
    mDragInProgress = false;
    mItemAddedBackToSelfViaIcon = false;
    mCurrentDragInfo = null;
    mCurrentDragView = null;
    mSuppressOnAdd = false;
    /* YUNOS BEGIN */
    // ##date:2014/07/04 ##author:yangshan.ys##BugID:135044
    // prevent the position of editfoldericon moving in folder
    if (target == this && mInfo.isEditFolderInContents() && mEditFolderTempView != null) {
        int childId = mEditFolderTempView.getId();
        CellLayout.LayoutParams params = (CellLayout.LayoutParams) mEditFolderTempView.getLayoutParams();
        mContentList.get(mInfo.getmEditFolderShortcutInfo().screen).addViewToCellLayout(mEditFolderTempView, -1,
                childId, params, true);
        mEditFolderHidden = false;
    }
    /* YUNOS END */
    // Reordering may have occured, and we need to save the new item locations. We do this once
    // at the end to prevent unnecessary database operations.
    /*YUNOS BEGIN*/
    //##date:2014/06/10 ##author:guoshuai.lgs ##BugID:
    //support the folder feature in mainmenu
    if (mInfo.isMainmenuFolder() && (LauncherApplication.isMainmenuMode())) {
        // TODO: do nothing?
    } else {
        updateItemLocationsInDatabase();
    }
    /*YUNOS END*/
    mLauncher.getWorkspace().cleanDragInfoFromFolder();
    mLauncher.getWorkspace().checkAndRemoveEmptyCell();
}

From source file:com.android.tv.MainActivity.java

@Override
public void onBackPressed() {
    // The activity should be returned to the caller of this activity
    // when the mSource is not null.
    if (!mOverlayManager.getSideFragmentManager().isActive() && isPlaying() && mSource == null) {
        // If back key would exit TV app,
        // show McLauncher instead so we can get benefit of McLauncher's shyMode.
        Intent startMain = new Intent(Intent.ACTION_MAIN);
        startMain.addCategory(Intent.CATEGORY_HOME);
        startActivity(startMain);/*from  w w  w. j a  v  a  2  s .  c  o m*/
    } else {
        super.onBackPressed();
    }
}

From source file:com.filemanager.free.activities.MainActivity.java

@SuppressLint("InflateParams")
private void initialiseViews() {
    mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_frame);
    appBarLayout = (AppBarLayout) findViewById(R.id.lin);
    if (!ImageLoader.getInstance().isInited()) {
        ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this));
    }//  w ww  .j  a v a 2  s  .c o  m
    if (displayImageOptions != null) {
        displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header)
                .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header)
                .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true)
                .bitmapConfig(Bitmap.Config.RGB_565).build();
    }

    buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe);
    buttonBarFrame.setBackgroundColor(Color.parseColor(skin));
    drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null);
    drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent);
    drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header);
    drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Intent intent;
            if (Build.VERSION.SDK_INT < 19) {
                intent = new Intent();
                intent.setAction(Intent.ACTION_GET_CONTENT);
            } else {
                intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

            }
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("image/*");
            startActivityForResult(intent, image_selector_request_code);
            return false;
        }
    });
    drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic);
    mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name);
    mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email);
    toolbar = (Toolbar) findViewById(R.id.action_bar);
    setSupportActionBar(toolbar);
    frameLayout = (FrameLayout) findViewById(R.id.content_frame);
    indicator_layout = findViewById(R.id.indicator_layout);
    mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer);
    if (theme1 == 1)
        mDrawerLinear.setBackgroundColor(Color.parseColor("#303030"));
    else {
        assert mDrawerLinear != null;
        mDrawerLinear.setBackgroundColor(Color.WHITE);
    }
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin));
    mDrawerList = (ListView) findViewById(R.id.menu_drawer);
    drawerHeaderView.setBackgroundResource(R.drawable.amaze_header);
    drawerHeaderParent.setBackgroundColor(Color.parseColor(skin));
    if (findViewById(R.id.tab_frame) != null) {
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear);
        mDrawerLayout.setScrimColor(Color.TRANSPARENT);
        isDrawerLocked = true;
    }
    mDrawerList.addHeaderView(drawerHeaderLayout);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayShowTitleEnabled(false);
    }

    View v = findViewById(R.id.fab_bg);
    if (theme1 == 1) {
        assert v != null;
        v.setBackgroundColor(Color.parseColor("#a6ffffff"));
    }

    assert v != null;
    v.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            floatingActionButton.close(true);
            utils.revealShow(view, false);
        }
    });

    pathbar = (LinearLayout) findViewById(R.id.pathbar);
    buttons = (LinearLayout) findViewById(R.id.buttons);
    scroll = (HorizontalScrollView) findViewById(R.id.scroll);
    scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1);
    scroll.setSmoothScrollingEnabled(true);
    scroll1.setSmoothScrollingEnabled(true);
    ImageView divider = (ImageView) findViewById(R.id.divider1);
    if (theme1 == 0) {
        assert divider != null;
        divider.setImageResource(R.color.divider);
    } else {
        assert divider != null;
        divider.setImageResource(R.color.divider_dark);
    }

    setDrawerHeaderBackground();
    View settingsbutton = findViewById(R.id.settingsbutton);
    if (theme1 == 1) {
        assert settingsbutton != null;
        settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) settingsbutton.findViewById(R.id.settingicon))
                .setImageResource(R.drawable.ic_settings_white_48dp);
        ((TextView) settingsbutton.findViewById(R.id.settingtext))
                .setTextColor(ContextCompat.getColor(con, android.R.color.white));
    }
    assert settingsbutton != null;
    settingsbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent in = new Intent(MainActivity.this, Preferences.class);
            finish();
            final int enter_anim = android.R.anim.fade_in;
            final int exit_anim = android.R.anim.fade_out;
            Activity s = MainActivity.this;
            s.overridePendingTransition(exit_anim, enter_anim);
            s.finish();
            s.overridePendingTransition(enter_anim, exit_anim);
            s.startActivity(in);
        }

    });
    View appbutton = findViewById(R.id.appbutton);
    if (theme1 == 1) {
        assert appbutton != null;
        appbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white);
        ((TextView) appbutton.findViewById(R.id.apptext))
                .setTextColor(ContextCompat.getColor(con, android.R.color.white));
    }
    assert appbutton != null;
    appbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager()
                    .beginTransaction();
            transaction2.replace(R.id.content_frame, new AppsList());
            findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2))
                    .start();
            pending_fragmentTransaction = transaction2;
            if (!isDrawerLocked)
                mDrawerLayout.closeDrawer(mDrawerLinear);
            else
                onDrawerClosed();
            select = -2;
            adapter.toggleChecked(false);
        }
    });
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));

    // status bar0
    sdk = Build.VERSION.SDK_INT;

    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        if (!isDrawerLocked)
            p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        colourednavigation = Sp.getBoolean("colorednavigation", true);

        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (isDrawerLocked) {
            window.setStatusBarColor((skinStatusBar));
        } else
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (colourednavigation)
            window.setNavigationBarColor(skinStatusBar);

    }
    //admob
    mAdView = (View) findViewById(R.id.ads);
}

From source file:com.amaze.filemanager.activities.MainActivity.java

void initialiseViews() {
    appBarLayout = (AppBarLayout) findViewById(R.id.lin);

    if (!ImageLoader.getInstance().isInited()) {

        ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this));
    }/*  w  ww.  java  2  s  .c  o m*/
    displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header)
            .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header)
            .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565)
            .build();

    buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe);
    buttonBarFrame.setBackgroundColor(Color.parseColor(skin));
    drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null);
    drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent);
    drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header);
    drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Intent intent;
            if (Build.VERSION.SDK_INT < 19) {
                intent = new Intent();
                intent.setAction(Intent.ACTION_GET_CONTENT);
            } else {
                intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

            }
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("image/*");
            startActivityForResult(intent, image_selector_request_code);
            return false;
        }
    });
    drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic);
    mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name);
    mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email);
    toolbar = (Toolbar) findViewById(R.id.action_bar);
    setSupportActionBar(toolbar);
    frameLayout = (FrameLayout) findViewById(R.id.content_frame);
    indicator_layout = findViewById(R.id.indicator_layout);
    mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer);
    if (theme1 == 1)
        mDrawerLinear.setBackgroundColor(Color.parseColor("#303030"));
    else
        mDrawerLinear.setBackgroundColor(Color.WHITE);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin));
    mDrawerList = (ListView) findViewById(R.id.menu_drawer);
    drawerHeaderView.setBackgroundResource(R.drawable.amaze_header);
    drawerHeaderParent.setBackgroundColor(Color.parseColor(skin));
    if (findViewById(R.id.tab_frame) != null) {
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear);
        mDrawerLayout.setScrimColor(Color.TRANSPARENT);
        isDrawerLocked = true;
    }
    mDrawerList.addHeaderView(drawerHeaderLayout);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    View v = findViewById(R.id.fab_bg);
    if (theme1 == 1)
        v.setBackgroundColor(Color.parseColor("#a6ffffff"));
    v.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            floatingActionButton.close(true);
            revealShow(view, false);
        }
    });

    pathbar = (LinearLayout) findViewById(R.id.pathbar);
    buttons = (LinearLayout) findViewById(R.id.buttons);
    scroll = (HorizontalScrollView) findViewById(R.id.scroll);
    scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1);
    scroll.setSmoothScrollingEnabled(true);
    scroll1.setSmoothScrollingEnabled(true);
    ImageView divider = (ImageView) findViewById(R.id.divider1);
    if (theme1 == 0)
        divider.setImageResource(R.color.divider);
    else
        divider.setImageResource(R.color.divider_dark);

    setDrawerHeaderBackground();
    View settingsbutton = findViewById(R.id.settingsbutton);
    if (theme1 == 1) {
        settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) settingsbutton.findViewById(R.id.settingicon))
                .setImageResource(R.drawable.ic_settings_white_48dp);
        ((TextView) settingsbutton.findViewById(R.id.settingtext))
                .setTextColor(getResources().getColor(android.R.color.white));
    }
    settingsbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent in = new Intent(MainActivity.this, Preferences.class);
            finish();
            final int enter_anim = android.R.anim.fade_in;
            final int exit_anim = android.R.anim.fade_out;
            Activity s = MainActivity.this;
            s.overridePendingTransition(exit_anim, enter_anim);
            s.finish();
            s.overridePendingTransition(enter_anim, exit_anim);
            s.startActivity(in);
        }

    });
    View appbutton = findViewById(R.id.appbutton);
    if (theme1 == 1) {
        appbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white);
        ((TextView) appbutton.findViewById(R.id.apptext))
                .setTextColor(getResources().getColor(android.R.color.white));
    }
    appbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager()
                    .beginTransaction();
            transaction2.replace(R.id.content_frame, new AppsList());
            findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2))
                    .start();
            pending_fragmentTransaction = transaction2;
            if (!isDrawerLocked)
                mDrawerLayout.closeDrawer(mDrawerLinear);
            else
                onDrawerClosed();
            select = -2;
            adapter.toggleChecked(false);
        }
    });
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));

    // status bar0
    sdk = Build.VERSION.SDK_INT;

    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        if (!isDrawerLocked)
            p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        colourednavigation = Sp.getBoolean("colorednavigation", true);

        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (isDrawerLocked) {
            window.setStatusBarColor((skinStatusBar));
        } else
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (colourednavigation)
            window.setNavigationBarColor(skinStatusBar);

    }
}

From source file:com.aujur.ebookreader.activity.ReadingFragment.java

private void launchFileManager() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("file/*");

    intent.addCategory(Intent.CATEGORY_OPENABLE);

    try {//from  w  ww.  j  a v a2 s .co  m
        startActivityForResult(intent, REQUEST_CODE_GET_CONTENT);
    } catch (ActivityNotFoundException e) {
        // No compatible file manager was found.
        Toast.makeText(context, getString(R.string.install_oi), Toast.LENGTH_SHORT).show();
    }
}

From source file:com.aujur.ebookreader.activity.ReadingFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {

    SherlockFragmentActivity activity = getSherlockActivity();

    if (activity == null) {
        return;/*from   ww w .j  av  a 2 s . c om*/
    }

    MenuItem nightMode = menu.findItem(R.id.profile_night);
    MenuItem dayMode = menu.findItem(R.id.profile_day);

    MenuItem tts = menu.findItem(R.id.text_to_speech);
    tts.setEnabled(ttsAvailable);

    activity.getSupportActionBar().show();

    if (config.getColourProfile() == ColourProfile.DAY) {
        dayMode.setVisible(false);
        nightMode.setVisible(true);
    } else {
        dayMode.setVisible(true);
        nightMode.setVisible(false);
    }

    // Only show open file item if we have a file manager installed
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("file/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    if (!isIntentAvailable(context, intent)) {
        menu.findItem(R.id.open_file).setVisible(false);
    }

    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

From source file:com.ichi2.anki2.DeckPicker.java

/** Called when the activity is first created. */
@Override//from   www.j  av  a2s.  c  o m
protected void onCreate(Bundle savedInstanceState) throws SQLException {
    Log.i(AnkiDroidApp.TAG, "DeckPicker - onCreate");
    Intent intent = getIntent();
    if (!isTaskRoot()) {
        Log.i(AnkiDroidApp.TAG,
                "DeckPicker - onCreate: Detected multiple instance of this activity, closing it and return to root activity");
        Intent reloadIntent = new Intent(DeckPicker.this, DeckPicker.class);
        reloadIntent.setAction(Intent.ACTION_MAIN);
        if (intent != null && intent.getExtras() != null) {
            reloadIntent.putExtras(intent.getExtras());
        }
        if (intent != null && intent.getData() != null) {
            reloadIntent.setData(intent.getData());
        }
        reloadIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        reloadIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        finish();
        startActivityIfNeeded(reloadIntent, 0);
    }
    if (intent.getData() != null) {
        mImportPath = getIntent().getData().getEncodedPath();
    }

    // need to start this here in order to avoid showing deckpicker before splashscreen
    if (AnkiDroidApp.colIsOpen()) {
        setTitle(getResources().getString(R.string.app_name));
    } else {
        setTitle("");
        mOpenCollectionHandler.onPreExecute();
    }

    Themes.applyTheme(this);
    super.onCreate(savedInstanceState);

    // mStartedByBigWidget = intent.getIntExtra(EXTRA_START, EXTRA_START_NOTHING);

    SharedPreferences preferences = restorePreferences();

    // activate broadcast messages if first start of a day
    if (mLastTimeOpened < UIUtils.getDayStart()) {
        preferences.edit().putBoolean("showBroadcastMessageToday", true).commit();
    }
    preferences.edit().putLong("lastTimeOpened", System.currentTimeMillis()).commit();

    // if (intent != null && intent.hasExtra(EXTRA_DECK_ID)) {
    // openStudyOptions(intent.getLongExtra(EXTRA_DECK_ID, 1));
    // }

    BroadcastMessages.checkForNewMessages(this);

    View mainView = getLayoutInflater().inflate(R.layout.deck_picker, null);
    setContentView(mainView);

    // check, if tablet layout
    View studyoptionsFrame = findViewById(R.id.studyoptions_fragment);
    mFragmented = studyoptionsFrame != null && studyoptionsFrame.getVisibility() == View.VISIBLE;

    Themes.setContentStyle(mFragmented ? mainView : mainView.findViewById(R.id.deckpicker_view),
            Themes.CALLER_DECKPICKER);

    registerExternalStorageListener();

    if (!mFragmented) {
        mAddButton = (ImageButton) findViewById(R.id.deckpicker_add);
        mAddButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                addNote();
            }
        });

        mCardsButton = (ImageButton) findViewById(R.id.deckpicker_card_browser);
        mCardsButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                openCardBrowser();
            }
        });

        mStatsButton = (ImageButton) findViewById(R.id.statistics_all_button);
        mStatsButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                showDialog(DIALOG_SELECT_STATISTICS_TYPE);
            }
        });

        mSyncButton = (ImageButton) findViewById(R.id.sync_all_button);
        mSyncButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                sync();
            }
        });
    }

    mInvalidateMenu = false;
    mDeckList = new ArrayList<HashMap<String, String>>();
    mDeckListView = (ListView) findViewById(R.id.files);
    mDeckListAdapter = new SimpleAdapter(this, mDeckList, R.layout.deck_item,
            new String[] { "name", "new", "lrn", "rev", // "complMat", "complAll",
                    "sep", "dyn" },
            new int[] { R.id.DeckPickerName, R.id.deckpicker_new, R.id.deckpicker_lrn, R.id.deckpicker_rev, // R.id.deckpicker_bar_mat, R.id.deckpicker_bar_all,
                    R.id.deckpicker_deck, R.id.DeckPickerName });
    mDeckListAdapter.setViewBinder(new SimpleAdapter.ViewBinder() {
        @Override
        public boolean setViewValue(View view, Object data, String text) {
            if (view.getId() == R.id.deckpicker_deck) {
                if (text.equals("top")) {
                    view.setBackgroundResource(R.drawable.white_deckpicker_top);
                    return true;
                } else if (text.equals("bot")) {
                    view.setBackgroundResource(R.drawable.white_deckpicker_bottom);
                    return true;
                } else if (text.equals("ful")) {
                    view.setBackgroundResource(R.drawable.white_deckpicker_full);
                    return true;
                } else if (text.equals("cen")) {
                    view.setBackgroundResource(R.drawable.white_deckpicker_center);
                    return true;
                }
            } else if (view.getId() == R.id.DeckPickerName) {
                if (text.equals("d0")) {
                    ((TextView) view).setTextColor(getResources().getColor(R.color.non_dyn_deck));
                    return true;
                } else if (text.equals("d1")) {
                    ((TextView) view).setTextColor(getResources().getColor(R.color.dyn_deck));
                    return true;
                }
            }
            // } else if (view.getId() == R.id.deckpicker_bar_mat || view.getId() == R.id.deckpicker_bar_all) {
            // if (text.length() > 0 && !text.equals("-1.0")) {
            // View parent = (View)view.getParent().getParent();
            // if (text.equals("-2")) {
            // parent.setVisibility(View.GONE);
            // } else {
            // Utils.updateProgressBars(view, (int) UIUtils.getDensityAdjustedValue(DeckPicker.this, 3.4f),
            // (int) (Double.parseDouble(text) * ((View)view.getParent().getParent().getParent()).getHeight()));
            // if (parent.getVisibility() == View.INVISIBLE) {
            // parent.setVisibility(View.VISIBLE);
            // parent.setAnimation(ViewAnimation.fade(ViewAnimation.FADE_IN, 500, 0));
            // }
            // }
            // }
            // return true;
            // } else if (view.getVisibility() == View.INVISIBLE) {
            // if (!text.equals("-1")) {
            // view.setVisibility(View.VISIBLE);
            // view.setAnimation(ViewAnimation.fade(ViewAnimation.FADE_IN, 500, 0));
            // return false;
            // }
            // } else if (text.equals("-1")){
            // view.setVisibility(View.INVISIBLE);
            // return false;
            return false;
        }
    });
    mDeckListView.setOnItemClickListener(mDeckSelHandler);
    mDeckListView.setAdapter(mDeckListAdapter);

    if (mFragmented) {
        mDeckListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    }

    registerForContextMenu(mDeckListView);

    showStartupScreensAndDialogs(preferences, 0);

    if (mSwipeEnabled) {
        gestureDetector = new GestureDetector(new MyGestureDetector());
        mDeckListView.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        });
    }
}