Search in sources :

Example 16 with IconicsDrawable

use of com.mikepenz.iconics.IconicsDrawable in project LollipopShowcase by mikepenz.

the class DetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);
    mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.container);
    mRowContainer = (LinearLayout) findViewById(R.id.row_container);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("");
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // Handle Back Navigation :D
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DetailActivity.this.onBackPressed();
        }
    });
    // Fab Button
    FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.fab_normal);
    floatingActionButton.setImageDrawable(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_file_upload).color(Color.WHITE).actionBar());
    floatingActionButton.setOnClickListener(fabClickListener);
    for (int i = 1; i < mRowContainer.getChildCount(); i++) {
        View rowView = mRowContainer.getChildAt(i);
        rowView.animate().setStartDelay(100 + i * SCALE_DELAY).scaleX(1).scaleY(1);
    }
    ComponentName componentName = null;
    if (savedInstanceState != null) {
        componentName = savedInstanceState.getParcelable("appInfo");
    } else if (getIntent() != null && getIntent().getExtras() != null) {
        componentName = (ComponentName) getIntent().getExtras().get("appInfo");
    }
    if (componentName != null) {
        Intent intent = new Intent();
        intent.setComponent(componentName);
        ResolveInfo app = getPackageManager().resolveActivity(intent, 0);
        mAppInfo = new AppInfo(this, app);
    }
    if (mAppInfo != null) {
        //toolbar.setLogo(mAppInfo.getIcon());
        toolbar.setTitle(mAppInfo.getName());
        View view = mRowContainer.findViewById(R.id.row_name);
        fillRow(view, "Application Name", mAppInfo.getName());
        ((ImageView) view.findViewById(R.id.appIcon)).setImageDrawable(mAppInfo.getIcon());
        view = mRowContainer.findViewById(R.id.row_package_name);
        fillRow(view, "Package Name", mAppInfo.getPackageName());
        view = mRowContainer.findViewById(R.id.row_activity);
        fillRow(view, "Activity", mAppInfo.getActivityName());
        view = mRowContainer.findViewById(R.id.row_component_info);
        fillRow(view, "ComponentInfo", mAppInfo.getComponentInfo());
        view = mRowContainer.findViewById(R.id.row_version);
        fillRow(view, "Version", mAppInfo.getVersionName() + " (" + mAppInfo.getVersionCode() + ")");
        view = mRowContainer.findViewById(R.id.row_moments);
        fillRow(view, "Moments", "First installed: " + new Date(mAppInfo.getFirstInstallTime()) + "\nLast updated: " + new Date(mAppInfo.getLastUpdateTime()));
    }
}
Also used : Intent(android.content.Intent) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Date(java.util.Date) AppInfo(com.mikepenz.lollipopshowcase.entity.AppInfo) ResolveInfo(android.content.pm.ResolveInfo) FloatingActionButton(android.support.design.widget.FloatingActionButton) ComponentName(android.content.ComponentName) ImageView(android.widget.ImageView) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) Toolbar(android.support.v7.widget.Toolbar)

Example 17 with IconicsDrawable

use of com.mikepenz.iconics.IconicsDrawable in project LollipopShowcase by mikepenz.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    final SharedPreferences pref = getSharedPreferences("com.mikepenz.applicationreader", 0);
    drawer = new DrawerBuilder(this).withToolbar(toolbar).addDrawerItems(new SwitchDrawerItem().withOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(IDrawerItem drawerItem, CompoundButton compoundButton, boolean b) {
            SharedPreferences.Editor editor = pref.edit();
            editor.putBoolean("autouploadenabled", b);
            editor.apply();
        }
    }).withName(R.string.drawer_switch).withChecked(pref.getBoolean("autouploadenabled", false))).addStickyDrawerItems(new SecondaryDrawerItem().withName(R.string.drawer_opensource).withIdentifier(DRAWER_ITEM_OPEN_SOURCE).withIcon(FontAwesome.Icon.faw_github).withSelectable(false)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {

        @Override
        public boolean onItemClick(View view, int i, IDrawerItem drawerItem) {
            if (drawerItem.getIdentifier() == DRAWER_ITEM_OPEN_SOURCE) {
                new LibsBuilder().withFields(R.string.class.getFields()).withVersionShown(true).withLicenseShown(true).withActivityTitle(getString(R.string.drawer_opensource)).withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR).start(MainActivity.this);
            }
            return false;
        }
    }).withSelectedItem(-1).withSavedInstance(savedInstanceState).build();
    // Handle ProgressBar
    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    // Fab Button
    mFabButton = (FloatingActionButton) findViewById(R.id.fab_normal);
    mFabButton.setImageDrawable(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_file_upload).color(Color.WHITE).actionBar());
    mFabButton.setOnClickListener(fabClickListener);
    mRecyclerView = (RecyclerView) findViewById(R.id.list);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setItemAnimator(new CustomItemAnimator());
    //mRecyclerView.setItemAnimator(new ReboundItemAnimator());
    mAdapter = new ApplicationAdapter(new ArrayList<AppInfo>(), R.layout.row_application, MainActivity.this);
    mRecyclerView.setAdapter(mAdapter);
    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
    mSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.theme_accent));
    mSwipeRefreshLayout.setRefreshing(true);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            new InitializeApplicationsTask().execute();
        }
    });
    new InitializeApplicationsTask().execute();
    if (savedInstanceState != null) {
        if (uploadComponentInfoTask != null) {
            if (uploadComponentInfoTask.isRunning) {
                uploadComponentInfoTask.showProgress(this);
            }
        }
    }
    //show progress
    mRecyclerView.setVisibility(View.GONE);
    mProgressBar.setVisibility(View.VISIBLE);
}
Also used : IDrawerItem(com.mikepenz.materialdrawer.model.interfaces.IDrawerItem) OnCheckedChangeListener(com.mikepenz.materialdrawer.interfaces.OnCheckedChangeListener) SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList) SwitchDrawerItem(com.mikepenz.materialdrawer.model.SwitchDrawerItem) Drawer(com.mikepenz.materialdrawer.Drawer) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SecondaryDrawerItem(com.mikepenz.materialdrawer.model.SecondaryDrawerItem) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) LibsBuilder(com.mikepenz.aboutlibraries.LibsBuilder) CustomItemAnimator(com.mikepenz.lollipopshowcase.itemanimator.CustomItemAnimator) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) ApplicationAdapter(com.mikepenz.lollipopshowcase.adapter.ApplicationAdapter) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) CompoundButton(android.widget.CompoundButton) Toolbar(android.support.v7.widget.Toolbar)

Example 18 with IconicsDrawable

use of com.mikepenz.iconics.IconicsDrawable in project LeafPic by HoraApps.

the class MainActivity method initUI.

private void initUI() {
    /**** TOOLBAR ****/
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    /**** RECYCLER VIEW ****/
    rvAlbums = (RecyclerView) findViewById(R.id.grid_albums);
    rvMedia = ((RecyclerView) findViewById(R.id.grid_photos));
    rvAlbums.setHasFixedSize(true);
    rvAlbums.setItemAnimator(new DefaultItemAnimator());
    rvMedia.setHasFixedSize(true);
    rvMedia.setItemAnimator(new DefaultItemAnimator());
    albumsAdapter = new AlbumsAdapter(getAlbums().dispAlbums, MainActivity.this);
    albumsAdapter.setOnClickListener(albumOnClickListener);
    albumsAdapter.setOnLongClickListener(albumOnLongCLickListener);
    rvAlbums.setAdapter(albumsAdapter);
    mediaAdapter = new MediaAdapter(getAlbum().getMedia(), MainActivity.this);
    mediaAdapter.setOnClickListener(photosOnClickListener);
    mediaAdapter.setOnLongClickListener(photosOnLongClickListener);
    rvMedia.setAdapter(mediaAdapter);
    int spanCount = SP.getInt("n_columns_folders", 2);
    rvAlbumsDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
    rvAlbums.addItemDecoration(rvAlbumsDecoration);
    rvAlbums.setLayoutManager(new GridLayoutManager(this, spanCount));
    spanCount = SP.getInt("n_columns_media", 3);
    rvMediaDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
    rvMedia.setLayoutManager(new GridLayoutManager(getApplicationContext(), spanCount));
    rvMedia.addItemDecoration(rvMediaDecoration);
    /**** SWIPE TO REFRESH ****/
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setColorSchemeColors(getAccentColor());
    swipeRefreshLayout.setProgressBackgroundColorSchemeColor(getBackgroundColor());
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            if (albumsMode) {
                getAlbums().clearSelectedAlbums();
                new PrepareAlbumTask().execute();
            } else {
                getAlbum().clearSelectedPhotos();
                new PreparePhotosTask().execute();
            }
        }
    });
    /**** DRAWER ****/
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.addDrawerListener(new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) {

        public void onDrawerClosed(View view) {
        //Put your code here
        // materialMenu.animateIconState(MaterialMenuDrawable.IconState.BURGER);
        }

        public void onDrawerOpened(View drawerView) {
        //Put your code here
        //materialMenu.animateIconState(MaterialMenuDrawable.IconState.ARROW);
        }
    });
    /**** FAB ***/
    fabCamera = (FloatingActionButton) findViewById(R.id.fab_camera);
    fabCamera.setImageDrawable(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_camera_alt).color(Color.WHITE));
    fabCamera.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA));
        }
    });
    //region TESTING
    fabCamera.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            // NOTE: this is used to acquire write permission on sd with api 21
            // TODO call this one when unable to write on sd
            requestSdCardPermissions();
            return false;
        }
    });
    //endregion
    setRecentApp(getString(R.string.app_name));
    setupUI();
}
Also used : AlbumsAdapter(org.horaapps.leafpic.adapters.AlbumsAdapter) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) MediaAdapter(org.horaapps.leafpic.adapters.MediaAdapter) Intent(android.content.Intent) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) SearchView(android.support.v7.widget.SearchView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) GridSpacingItemDecoration(org.horaapps.leafpic.views.GridSpacingItemDecoration)

Example 19 with IconicsDrawable

use of com.mikepenz.iconics.IconicsDrawable in project MaterialDrawer by mikepenz.

the class ImageHolder method decideIcon.

/**
     * this only handles Drawables
     *
     * @param ctx
     * @param iconColor
     * @param tint
     * @return
     */
public Drawable decideIcon(Context ctx, int iconColor, boolean tint, int paddingDp) {
    Drawable icon = getIcon();
    if (mIIcon != null) {
        icon = new IconicsDrawable(ctx, mIIcon).color(iconColor).sizeDp(24).paddingDp(paddingDp);
    } else if (getIconRes() != -1) {
        icon = ContextCompat.getDrawable(ctx, getIconRes());
    } else if (getUri() != null) {
        try {
            InputStream inputStream = ctx.getContentResolver().openInputStream(getUri());
            icon = Drawable.createFromStream(inputStream, getUri().toString());
        } catch (FileNotFoundException e) {
        //no need to handle this
        }
    }
    //if we got an icon AND we have auto tinting enabled AND it is no IIcon, tint it ;)
    if (icon != null && tint && mIIcon == null) {
        icon = icon.mutate();
        icon.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN);
    }
    return icon;
}
Also used : InputStream(java.io.InputStream) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) Drawable(android.graphics.drawable.Drawable) FileNotFoundException(java.io.FileNotFoundException) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Example 20 with IconicsDrawable

use of com.mikepenz.iconics.IconicsDrawable in project MaterialDrawer by mikepenz.

the class PersistentDrawerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_persistent_drawer);
    //Remove line to test RTL support
    // getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
    //example how to implement a persistentDrawer as shown in the google material design guidelines
    //https://material-design.storage.googleapis.com/publish/material_v_4/material_ext_publish/0Bx4BSt6jniD7YVdKQlF3TEo2S3M/patterns_navdrawer_behavior_persistent2.png
    //https://www.google.com/design/spec/patterns/navigation-drawer.html#navigation-drawer-behavior
    // Handle Toolbar
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.drawer_item_persistent_compact_header);
    // Create a few sample profile
    final IProfile profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("mikepenz@gmail.com").withIcon(R.drawable.profile);
    final IProfile profile2 = new ProfileDrawerItem().withName("Max Muster").withEmail("max.mustermann@gmail.com").withIcon(R.drawable.profile2);
    final IProfile profile3 = new ProfileDrawerItem().withName("Felix House").withEmail("felix.house@gmail.com").withIcon(R.drawable.profile3);
    final IProfile profile4 = new ProfileDrawerItem().withName("Mr. X").withEmail("mister.x.super@gmail.com").withIcon(R.drawable.profile4);
    final IProfile profile5 = new ProfileDrawerItem().withName("Batman").withEmail("batman@gmail.com").withIcon(R.drawable.profile5);
    // Create the AccountHeader
    headerResult = new AccountHeaderBuilder().withActivity(this).withCompactStyle(true).withTranslucentStatusBar(true).withHeaderBackground(new ColorDrawable(Color.parseColor("#FDFDFD"))).withHeightPx(UIUtils.getActionBarHeight(this)).withAccountHeader(R.layout.material_drawer_compact_persistent_header).withTextColor(Color.BLACK).addProfiles(profile, profile2, profile3, profile4, profile5).withSavedInstance(savedInstanceState).build();
    //Create the drawer
    result = new DrawerBuilder().withActivity(this).withTranslucentStatusBar(true).withAccountHeader(//set the AccountHeader we created earlier for the header
    headerResult).addDrawerItems(new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home).withIdentifier(1), new PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad), new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye), new SectionDrawerItem().withName(R.string.drawer_item_section_header), new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog), new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question).withEnabled(false), new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github), new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withIcon(FontAwesome.Icon.faw_bullhorn)).withGenerateMiniDrawer(true).withSavedInstance(savedInstanceState).buildView();
    // create the MiniDrawer and define the drawer and header to be used (it will automatically use the items from them)
    miniResult = result.getMiniDrawer().withIncludeSecondaryDrawerItems(true);
    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
    //get the widths in px for the first and second panel
    int firstWidth = (int) com.mikepenz.crossfader.util.UIUtils.convertDpToPixel(300, this);
    int secondWidth = (int) com.mikepenz.crossfader.util.UIUtils.convertDpToPixel(72, this);
    //create and build our crossfader (see the MiniDrawer is also builded in here, as the build method returns the view to be used in the crossfader)
    crossFader = new Crossfader().withContent(findViewById(R.id.crossfade_content)).withFirst(result.getSlider(), firstWidth).withSecond(miniResult.build(this), secondWidth).withSavedInstance(savedInstanceState).build();
    //define the crossfader to be used with the miniDrawer. This is required to be able to automatically toggle open / close
    miniResult.withCrossFader(new CrossfadeWrapper(crossFader));
    //define and create the arrow ;)
    ImageView toggle = (ImageView) headerResult.getView().findViewById(R.id.material_drawer_account_header_toggle);
    //for RTL you would have to define the other arrow
    toggle.setImageDrawable(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_chevron_left).sizeDp(16).color(Color.BLACK));
    toggle.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            crossFader.crossFade();
        }
    });
}
Also used : PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) ProfileDrawerItem(com.mikepenz.materialdrawer.model.ProfileDrawerItem) AccountHeaderBuilder(com.mikepenz.materialdrawer.AccountHeaderBuilder) SecondaryDrawerItem(com.mikepenz.materialdrawer.model.SecondaryDrawerItem) ImageView(android.widget.ImageView) View(android.view.View) SectionDrawerItem(com.mikepenz.materialdrawer.model.SectionDrawerItem) ColorDrawable(android.graphics.drawable.ColorDrawable) CrossfadeWrapper(com.mikepenz.materialdrawer.app.utils.CrossfadeWrapper) ImageView(android.widget.ImageView) IProfile(com.mikepenz.materialdrawer.model.interfaces.IProfile) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) Toolbar(android.support.v7.widget.Toolbar) Crossfader(com.mikepenz.crossfader.Crossfader)

Aggregations

IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)28 View (android.view.View)13 MenuInflater (android.view.MenuInflater)9 Toolbar (android.support.v7.widget.Toolbar)7 SearchView (android.support.v7.widget.SearchView)6 DrawerBuilder (com.mikepenz.materialdrawer.DrawerBuilder)6 SecondaryDrawerItem (com.mikepenz.materialdrawer.model.SecondaryDrawerItem)6 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 ProfileDrawerItem (com.mikepenz.materialdrawer.model.ProfileDrawerItem)5 Context (android.content.Context)4 Intent (android.content.Intent)4 RecyclerView (android.support.v7.widget.RecyclerView)4 AccountHeaderBuilder (com.mikepenz.materialdrawer.AccountHeaderBuilder)4 Drawer (com.mikepenz.materialdrawer.Drawer)4 PrimaryDrawerItem (com.mikepenz.materialdrawer.model.PrimaryDrawerItem)4 SectionDrawerItem (com.mikepenz.materialdrawer.model.SectionDrawerItem)4 IDrawerItem (com.mikepenz.materialdrawer.model.interfaces.IDrawerItem)4 IProfile (com.mikepenz.materialdrawer.model.interfaces.IProfile)4 Drawable (android.graphics.drawable.Drawable)3