Search in sources :

Example 81 with ActionBar

use of android.support.v7.app.ActionBar in project WordPress-Android by wordpress-mobile.

the class MediaGalleryPickerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((WordPress) getApplication()).component().inject(this);
    ArrayList<Integer> selectedItems = new ArrayList<>();
    mIsSelectOneItem = getIntent().getBooleanExtra(PARAM_SELECT_ONE_ITEM, false);
    ArrayList<Integer> prevSelectedItems = ListUtils.fromIntArray(getIntent().getIntArrayExtra(PARAM_SELECTED_IDS));
    if (prevSelectedItems != null) {
        selectedItems.addAll(prevSelectedItems);
    }
    if (savedInstanceState != null) {
        mSite = (SiteModel) savedInstanceState.getSerializable(WordPress.SITE);
        mIsSelectOneItem = savedInstanceState.getBoolean(STATE_IS_SELECT_ONE_ITEM, mIsSelectOneItem);
        if (savedInstanceState.containsKey(STATE_SELECTED_ITEMS)) {
            ArrayList<Integer> list = ListUtils.fromIntArray(savedInstanceState.getIntArray(STATE_SELECTED_ITEMS));
            selectedItems.addAll(list);
        }
        if (savedInstanceState.containsKey(STATE_FILTERED_ITEMS)) {
            mFilteredItems = ListUtils.fromLongArray(savedInstanceState.getLongArray(STATE_FILTERED_ITEMS));
        }
    } else {
        mSite = (SiteModel) getIntent().getSerializableExtra(WordPress.SITE);
    }
    if (mSite == null) {
        ToastUtils.showToast(this, R.string.blog_not_found, ToastUtils.Duration.SHORT);
        finish();
        return;
    }
    setContentView(R.layout.media_gallery_picker_layout);
    mRecycler = (RecyclerView) findViewById(R.id.recycler);
    int numColumns = MediaGridAdapter.getColumnCount(this);
    mGridManager = new GridLayoutManager(this, numColumns);
    mRecycler.setLayoutManager(mGridManager);
    mGridAdapter = new MediaGridAdapter(this, mSite, mImageLoader);
    mGridAdapter.setCallback(this);
    mRecycler.setAdapter(mGridAdapter);
    if (mIsSelectOneItem) {
        mGridAdapter.setAllowMultiselect(false);
        setTitle(R.string.select_from_media_library);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
    } else {
        mGridAdapter.setAllowMultiselect(true);
        mGridAdapter.setInMultiSelect(true);
        mGridAdapter.setSelectedItems(selectedItems);
    }
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) ArrayList(java.util.ArrayList) ActionBar(android.support.v7.app.ActionBar)

Example 82 with ActionBar

use of android.support.v7.app.ActionBar in project WordPress-Android by wordpress-mobile.

the class NotificationsDetailActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((WordPress) getApplication()).component().inject(this);
    AppLog.i(AppLog.T.NOTIFS, "Creating NotificationsDetailActivity");
    setContentView(R.layout.notifications_detail_activity);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    if (savedInstanceState == null) {
        mNoteId = getIntent().getStringExtra(NotificationsListFragment.NOTE_ID_EXTRA);
    } else {
        if (savedInstanceState.containsKey(ARG_TITLE) && getSupportActionBar() != null) {
            getSupportActionBar().setTitle(StringUtils.notNullStr(savedInstanceState.getString(ARG_TITLE)));
        }
        mNoteId = savedInstanceState.getString(NotificationsListFragment.NOTE_ID_EXTRA);
    }
    if (mNoteId == null) {
        showErrorToastAndFinish();
        return;
    }
    final Note note = NotificationsTable.getNoteById(mNoteId);
    if (note == null) {
        showErrorToastAndFinish();
        return;
    }
    // If `note.getTimestamp()` is not the most recent seen note, the server will discard the value.
    NotificationsActions.updateSeenTimestamp(note);
    Map<String, String> properties = new HashMap<>();
    properties.put("notification_type", note.getType());
    AnalyticsTracker.track(AnalyticsTracker.Stat.NOTIFICATIONS_OPENED_NOTIFICATION_DETAILS, properties);
    //set up the viewpager and adapter for lateral navigation
    mViewPager = (WPViewPager) findViewById(R.id.viewpager);
    mViewPager.setPageTransformer(false, new WPViewPagerTransformer(WPViewPagerTransformer.TransformType.SLIDE_OVER));
    NotesAdapter.FILTERS filter = NotesAdapter.FILTERS.FILTER_ALL;
    if (getIntent().hasExtra(NotificationsListFragment.NOTE_CURRENT_LIST_FILTER_EXTRA)) {
        filter = (NotesAdapter.FILTERS) getIntent().getSerializableExtra(NotificationsListFragment.NOTE_CURRENT_LIST_FILTER_EXTRA);
    }
    mAdapter = buildNoteListAdapterAndSetPosition(note, filter);
    //set title
    setActionBarTitleForNote(note);
    markNoteAsRead(note);
    mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            AnalyticsTracker.track(AnalyticsTracker.Stat.NOTIFICATION_SWIPE_PAGE_CHANGED);
            AppPrefs.setNotificationsSwipeToNavigateShown(true);
            //change the action bar title for the current note
            Note currentNote = mAdapter.getNoteAtPosition(position);
            if (currentNote != null) {
                setActionBarTitleForNote(currentNote);
                markNoteAsRead(currentNote);
            }
        }
    });
    // Hide the keyboard, unless we arrived here from the 'Reply' action in a push notification
    if (!getIntent().getBooleanExtra(NotificationsListFragment.NOTE_INSTANT_REPLY_EXTRA, false)) {
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
    }
}
Also used : NotesAdapter(org.wordpress.android.ui.notifications.adapters.NotesAdapter) WPViewPagerTransformer(org.wordpress.android.widgets.WPViewPagerTransformer) HashMap(java.util.HashMap) Note(org.wordpress.android.models.Note) ViewPager(android.support.v4.view.ViewPager) WPViewPager(org.wordpress.android.widgets.WPViewPager) ActionBar(android.support.v7.app.ActionBar)

Example 83 with ActionBar

use of android.support.v7.app.ActionBar in project WordPress-Android by wordpress-mobile.

the class MediaBrowserActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((WordPress) getApplication()).component().inject(this);
    if (savedInstanceState == null) {
        mSite = (SiteModel) getIntent().getSerializableExtra(WordPress.SITE);
    } else {
        mSite = (SiteModel) savedInstanceState.getSerializable(WordPress.SITE);
    }
    if (mSite == null) {
        ToastUtils.showToast(this, R.string.blog_not_found, ToastUtils.Duration.SHORT);
        finish();
        return;
    }
    setContentView(R.layout.media_browser_activity);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(R.string.media);
    }
    FragmentManager fm = getFragmentManager();
    fm.addOnBackStackChangedListener(mOnBackStackChangedListener);
    mMediaGridFragment = (MediaGridFragment) fm.findFragmentById(R.id.mediaGridFragment);
    mMediaItemFragment = (MediaItemFragment) fm.findFragmentByTag(MediaItemFragment.TAG);
    mMediaEditFragment = (MediaEditFragment) fm.findFragmentByTag(MediaEditFragment.TAG);
    FragmentTransaction ft = fm.beginTransaction();
    if (mMediaItemFragment != null) {
        ft.hide(mMediaGridFragment);
    }
    if (mMediaEditFragment != null && !mMediaEditFragment.isInLayout()) {
        ft.hide(mMediaItemFragment);
    }
    ft.commitAllowingStateLoss();
    setupAddMenuPopup();
    // if media was shared add it to the library
    handleSharedMedia();
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction) ActionBar(android.support.v7.app.ActionBar)

Example 84 with ActionBar

use of android.support.v7.app.ActionBar in project WordPress-Android by wordpress-mobile.

the class PeopleManagementActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((WordPress) getApplication()).component().inject(this);
    setContentView(R.layout.people_management_activity);
    if (savedInstanceState == null) {
        mSite = (SiteModel) getIntent().getSerializableExtra(WordPress.SITE);
    } else {
        mSite = (SiteModel) savedInstanceState.getSerializable(WordPress.SITE);
    }
    if (mSite == null) {
        ToastUtils.showToast(this, R.string.blog_not_found, ToastUtils.Duration.SHORT);
        finish();
        return;
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setElevation(0);
    }
    FragmentManager fragmentManager = getFragmentManager();
    if (savedInstanceState == null) {
        // only delete cached people if there is a connection
        if (NetworkUtils.isNetworkAvailable(this)) {
            PeopleTable.deletePeopleExceptForFirstPage(mSite.getId());
        }
        if (actionBar != null) {
            actionBar.setTitle(R.string.people);
        }
        PeopleListFragment peopleListFragment = PeopleListFragment.newInstance(mSite);
        peopleListFragment.setOnPersonSelectedListener(this);
        peopleListFragment.setOnFetchPeopleListener(this);
        mUsersEndOfListReached = false;
        mFollowersEndOfListReached = false;
        mEmailFollowersEndOfListReached = false;
        mViewersEndOfListReached = false;
        mHasRefreshedUsers = false;
        mHasRefreshedFollowers = false;
        mHasRefreshedEmailFollowers = false;
        mHasRefreshedViewers = false;
        mUsersFetchRequestInProgress = false;
        mFollowersFetchRequestInProgress = false;
        mEmailFollowersFetchRequestInProgress = false;
        mViewersFetchRequestInProgress = false;
        mFollowersLastFetchedPage = 0;
        mEmailFollowersLastFetchedPage = 0;
        fragmentManager.beginTransaction().add(R.id.fragment_container, peopleListFragment, KEY_PEOPLE_LIST_FRAGMENT).commit();
    } else {
        mUsersEndOfListReached = savedInstanceState.getBoolean(KEY_USERS_END_OF_LIST_REACHED);
        mFollowersEndOfListReached = savedInstanceState.getBoolean(KEY_FOLLOWERS_END_OF_LIST_REACHED);
        mEmailFollowersEndOfListReached = savedInstanceState.getBoolean(KEY_EMAIL_FOLLOWERS_END_OF_LIST_REACHED);
        mViewersEndOfListReached = savedInstanceState.getBoolean(KEY_VIEWERS_END_OF_LIST_REACHED);
        mHasRefreshedUsers = savedInstanceState.getBoolean(KEY_HAS_REFRESHED_USERS);
        mHasRefreshedFollowers = savedInstanceState.getBoolean(KEY_HAS_REFRESHED_FOLLOWERS);
        mHasRefreshedEmailFollowers = savedInstanceState.getBoolean(KEY_HAS_REFRESHED_EMAIL_FOLLOWERS);
        mHasRefreshedViewers = savedInstanceState.getBoolean(KEY_HAS_REFRESHED_VIEWERS);
        mUsersFetchRequestInProgress = savedInstanceState.getBoolean(KEY_USERS_FETCH_REQUEST_IN_PROGRESS);
        mFollowersFetchRequestInProgress = savedInstanceState.getBoolean(KEY_FOLLOWERS_FETCH_REQUEST_IN_PROGRESS);
        mEmailFollowersFetchRequestInProgress = savedInstanceState.getBoolean(KEY_EMAIL_FOLLOWERS_FETCH_REQUEST_IN_PROGRESS);
        mViewersFetchRequestInProgress = savedInstanceState.getBoolean(KEY_VIEWERS_FETCH_REQUEST_IN_PROGRESS);
        mFollowersLastFetchedPage = savedInstanceState.getInt(KEY_FOLLOWERS_LAST_FETCHED_PAGE);
        mEmailFollowersLastFetchedPage = savedInstanceState.getInt(KEY_EMAIL_FOLLOWERS_LAST_FETCHED_PAGE);
        CharSequence title = savedInstanceState.getCharSequence(KEY_TITLE);
        if (actionBar != null && title != null) {
            actionBar.setTitle(title);
        }
        PeopleListFragment peopleListFragment = getListFragment();
        if (peopleListFragment != null) {
            peopleListFragment.setOnPersonSelectedListener(this);
            peopleListFragment.setOnFetchPeopleListener(this);
        }
    }
}
Also used : FragmentManager(android.app.FragmentManager) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 85 with ActionBar

use of android.support.v7.app.ActionBar in project WordPress-Android by wordpress-mobile.

the class PostsListActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((WordPress) getApplication()).component().inject(this);
    setContentView(R.layout.post_list_activity);
    mIsPage = getIntent().getBooleanExtra(EXTRA_VIEW_PAGES, false);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle(getString(mIsPage ? R.string.pages : R.string.posts));
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    FragmentManager fm = getFragmentManager();
    if (savedInstanceState == null) {
        mSite = (SiteModel) getIntent().getSerializableExtra(WordPress.SITE);
    } else {
        mSite = (SiteModel) savedInstanceState.getSerializable(WordPress.SITE);
    }
    if (mSite == null) {
        ToastUtils.showToast(this, R.string.blog_not_found, ToastUtils.Duration.SHORT);
        finish();
        return;
    }
    mPostList = (PostsListFragment) fm.findFragmentById(R.id.postList);
    showErrorDialogIfNeeded(getIntent().getExtras());
}
Also used : FragmentManager(android.app.FragmentManager) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

ActionBar (android.support.v7.app.ActionBar)784 View (android.view.View)248 Toolbar (android.support.v7.widget.Toolbar)214 TextView (android.widget.TextView)160 Intent (android.content.Intent)118 ImageView (android.widget.ImageView)76 AppCompatActivity (android.support.v7.app.AppCompatActivity)66 RecyclerView (android.support.v7.widget.RecyclerView)57 AdapterView (android.widget.AdapterView)52 Bundle (android.os.Bundle)49 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)49 ListView (android.widget.ListView)44 ColorDrawable (android.graphics.drawable.ColorDrawable)33 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)32 ViewPager (android.support.v4.view.ViewPager)29 ArrayList (java.util.ArrayList)29 SharedPreferences (android.content.SharedPreferences)28 Fragment (android.support.v4.app.Fragment)28 MenuItem (android.view.MenuItem)28 BindView (butterknife.BindView)28