public ActionBarWrapper(Activity activity) {
    mActivity = activity;
    mActionBar = activity.getActionBar();
    if (mActionBar != null) {
      mActionBar.addOnMenuVisibilityListener(this);

      // Fixes issue #746
      int displayOptions = mActionBar.getDisplayOptions();
      mActionBar.setHomeButtonEnabled((displayOptions & DISPLAY_HOME_AS_UP) != 0);
    }
  }
 @Override
 public int getDisplayOptions() {
   return mActionBar.getDisplayOptions();
 }
Example #3
0
  @SuppressLint("NewApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    // requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    super.onCreate(savedInstanceState);

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);

    setContentView(R.layout.activity_home);

    final ActionBar actionBar = getActionBar();
    //
    // if (android.os.Build.VERSION.SDK_INT < 11) {
    // requestWindowFeature(Window.FEATURE_NO_TITLE);
    // }
    actionBar.setHomeButtonEnabled(false);

    actionBar.setIcon(R.drawable.ic_list);

    actionBar.setDisplayOptions(actionBar.getDisplayOptions() | ActionBar.DISPLAY_SHOW_CUSTOM);
    ImageView imageView = new ImageView(actionBar.getThemedContext());
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    imageView.setImageResource(R.drawable.ic_list);
    ActionBar.LayoutParams layoutParams =
        new ActionBar.LayoutParams(
            ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.WRAP_CONTENT,
            Gravity.LEFT | Gravity.CENTER_VERTICAL);

    // actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    //
    // firstTab = actionBar.newTab().setIcon(R.drawable.ic_launcher)
    // .setText("First Tab");
    // secondTab = actionBar.newTab().setIcon(R.drawable.ic_launcher)
    // .setText("Second Tab");
    // thirdTab = actionBar.newTab().setIcon(R.drawable.ic_launcher)
    // .setText("Third Tab");
    //
    // /*
    // * firstTab.setTabListener(new TabListener(firstFragmentTab));
    // * secondTab.setTabListener(new TabListener(secondFragmentTab));
    // * thirdTab.setTabListener(new TabListener(thirdFragmentTab));
    // */
    //
    // actionBar.addTab(firstTab);
    // actionBar.addTab(secondTab);
    // actionBar.addTab(thirdTab);
    //
    // viewPager = (ViewPager) findViewById(R.id.pager);
    // List<Fragment> fragments = getFragments();
    //
    // obj_pagerAdapter = new TabsPagerAdapter(getSupportFragmentManager(),
    // fragments);
    //
    // ViewPager pager = (ViewPager) findViewById(R.id.pager);
    //
    // pager.setAdapter(obj_pagerAdapter);

    analytics = GoogleAnalytics.getInstance(this);
    analytics.setLocalDispatchPeriod(1800);

    tracker = analytics.newTracker("UA-66147419-1"); // Replace with actual
    // tracker/property
    // Id

    tracker.enableExceptionReporting(true);
    tracker.enableAdvertisingIdCollection(true);
    tracker.enableAutoActivityTracking(true);

    tracker.setScreenName("main screen");

    tracker.send(
        new HitBuilders.EventBuilder()
            .setCategory("UX")
            .setAction("click")
            .setLabel("submit")
            .build());

    viewPager = (ViewPager) findViewById(R.id.pager);
    // actionBar = getActionBar();
    mAdapter = new TabsPagerAdapter(getSupportFragmentManager());

    viewPager.setAdapter(mAdapter);
    // actionBar.setHomeButtonEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Adding Tabs
    for (String tab_name : tabs) {
      actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this));
    }

    viewPager.setOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {

          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
            easyTracker = EasyTracker.getInstance();
          }

          @Override
          public void onPageScrolled(int arg0, float arg1, int arg2) {}

          @Override
          public void onPageScrollStateChanged(int arg0) {}
        });

    imgBtnList = (ImageView) findViewById(R.id.imgBtn_list);
    arraylist_Drawer = new ArrayList<String>();
    drawer = (ListView) findViewById(R.id.left_drawer);
    mydrawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    ArrayAdapter<String> adpt =
        new ArrayAdapter<String>(
            HomeActivity.this, android.R.layout.simple_list_item_1, navMenuTitles);

    drawer.setAdapter(adpt);

    imgBtnList.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            mydrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

            if (mydrawer.isDrawerOpen(drawer)) {
              // Animation animation1 = AnimationUtils.loadAnimation(
              // getApplicationContext(), R.anim.clockwise);

              // imgBtnList.startAnimation(animation1);

              mydrawer.closeDrawer(drawer);
              // imgBtnList.setBackgroundResource(R.drawable.ic_list);

            } else {
              // Animation animation2 = AnimationUtils.loadAnimation(
              // getApplicationContext(), R.anim.clockwise);
              // imgBtnList.startAnimation(animation2);
              mydrawer.openDrawer(drawer);
              // imgBtnList.setBackgroundResource(R.drawable.img_back);
            }
          }
        });
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.project_picker);

    // Show action bar title only on large screens.
    final ActionBar actionBar = getActionBar();
    final DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    final int widthDip = (int) (displayMetrics.widthPixels / displayMetrics.scaledDensity);
    // Only show title on large screens (width >= 1000 dip).
    if (widthDip >= SHOW_TITLE_THRESHOLD_WIDTH_DIP) {
      actionBar.setDisplayOptions(actionBar.getDisplayOptions() | ActionBar.DISPLAY_SHOW_TITLE);
      actionBar.setTitle(R.string.full_app_name);
    }

    mGridView = (GridView) findViewById(R.id.projects);
    mGridView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // If user clicks on the last item, then create a new project.
            if (position == mProjects.size()) {
              showDialog(DIALOG_NEW_PROJECT_ID);
            } else {
              openProject(mProjects.get(position).getPath());
            }
          }
        });
    // Upon long press, pop up a menu with a removal option.
    mGridView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(
              AdapterView<?> parent, View view, final int position, long id) {
            // Open new project dialog when user clicks on the "create new project" card.
            if (position == mProjects.size()) {
              showDialog(DIALOG_NEW_PROJECT_ID);
              return true;
            }
            // Otherwise, pop up a menu with a project removal option.
            final PopupMenu popupMenu = new PopupMenu(ProjectsActivity.this, view);
            popupMenu.getMenuInflater().inflate(R.menu.project_menu, popupMenu.getMenu());
            popupMenu.setOnMenuItemClickListener(
                new PopupMenu.OnMenuItemClickListener() {
                  @Override
                  public boolean onMenuItemClick(MenuItem menuItem) {
                    switch (menuItem.getItemId()) {
                      case R.id.action_remove_project:
                        final Bundle bundle = new Bundle();
                        bundle.putString(PARAM_DIALOG_PATH_ID, mProjects.get(position).getPath());
                        showDialog(DIALOG_REMOVE_PROJECT_ID, bundle);
                        break;
                      default:
                        break;
                    }
                    return true;
                  }
                });
            popupMenu.show();
            return true;
          }
        });
  }
 @Override
 public boolean isNavigationVisible() {
   final ActionBar actionBar = mActivity.getActionBar();
   return actionBar != null
       && (actionBar.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) != 0;
 }