/**
   * Provide default implementation to return a simple list view. Subclasses can override to replace
   * with their own layout. If doing so, the returned view hierarchy <em>must</em> have a ListView
   * whose id is {@link android.R.id#list android.R.id.list} and can optionally have a sibling view
   * id {@link android.R.id#empty android.R.id.empty} that is to be shown when the list is empty.
   *
   * <p>If you are overriding this method with your own custom content, consider including the
   * standard layout {@link android.R.layout#list_content} in your layout file, so that you continue
   * to retain all of the standard behavior of ListFragment. In particular, this is currently the
   * only way to have the built-in indeterminant progress state be shown.
   */
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FrameLayout root = new FrameLayout(getActivity());

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    root.addView(
        tv,
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    root.addView(
        lv,
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    ListView.LayoutParams lp =
        new ListView.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    root.setLayoutParams(lp);

    return root;
  }
 @Override
 public void setDrawSelectorOnTop(boolean onTop) {
   super.setDrawSelectorOnTop(onTop);
   drawSelectorOnTop = onTop;
   if (frame != null) {
     frame.setDrawSelectorOnTop(drawSelectorOnTop);
   }
 }
  @Override
  public Dialog onCreateDialog(final Bundle savedInstanceState) {
    FrameLayout lframe = new FrameLayout(getActivity());

    ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(
        lv,
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    lframe.setBackgroundColor(getResources().getColor(android.R.color.background_light));

    ArrayAdapter<Parcelable> adapter =
        new SoftwareArrayAdapter(getActivity(), R.layout.item_open_source_licenses);
    if (getArguments() != null && getArguments().containsKey(EXTRA_OSS)) {
      adapter.addAll(getArguments().getParcelableArrayList(EXTRA_OSS));
    }

    ListView listView = (ListView) lframe.findViewById(android.R.id.list);
    listView.setAdapter(adapter);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.activity_settings_open_source_licenses);
    builder.setView(lframe);
    builder.setPositiveButton(
        R.string.activity_settings_close,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(final DialogInterface dialog, final int which) {
            dialog.dismiss();
          }
        });

    return builder.create();
  }
Example #4
0
  @Override
  public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("Stickers", R.string.Stickers));
    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              finishFragment();
            }
          }
        });

    listAdapter = new ListAdapter(context);

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(0xfff0f0f0);

    ListView listView = new ListView(context);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setVerticalScrollBarEnabled(false);
    listView.setDrawSelectorOnTop(true);
    frameLayout.addView(
        listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    listView.setAdapter(listAdapter);
    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
            if (i >= stickersStartRow && i < stickersEndRow && getParentActivity() != null) {
              final TLRPC.TL_messages_stickerSet stickerSet = StickersQuery.getStickerSets().get(i);
              ArrayList<TLRPC.Document> stickers = stickerSet.documents;
              if (stickers == null || stickers.isEmpty()) {
                return;
              }
              StickersAlert alert = new StickersAlert(getParentActivity(), stickerSet);
              alert.setButton(
                  AlertDialog.BUTTON_NEGATIVE,
                  LocaleController.getString("Close", R.string.Close),
                  (Message) null);
              if ((stickerSet.set.flags & 4) == 0) {
                alert.setButton(
                    AlertDialog.BUTTON_NEUTRAL,
                    LocaleController.getString("StickersRemove", R.string.StickersRemove),
                    new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                        StickersQuery.removeStickersSet(getParentActivity(), stickerSet.set, 0);
                      }
                    });
              }
              setVisibleDialog(alert);
              alert.show();
            }
          }
        });

    return fragmentView;
  }
Example #5
0
  @SuppressLint("ResourceAsColor")
  @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
  @Override
  public boolean onTouch(final View view, MotionEvent event) {
    if (mViewWidth < 2) {
      mViewWidth = mListView.getWidth();
      smallWidth = mViewWidth / 7;
      textwidth2 = mViewWidth / 3;
      textwidth = textwidth2;
      //            原版
      //            largewidth	=	textwidth+textwidth2;
      //           自己修改
      largewidth = textwidth;
    }

    int tempwidth = 0;
    if (SwipeType == 1) tempwidth = smallWidth;
    else tempwidth = textwidth2 / 2;

    switch (event.getActionMasked()) {
      case MotionEvent.ACTION_DOWN:
        {
          if (mPaused) {
            return false;
          }
          Rect rect = new Rect();
          int childCount = mListView.getChildCount();
          int[] listViewCoords = new int[2];
          mListView.getLocationOnScreen(listViewCoords);
          int x = (int) event.getRawX() - listViewCoords[0];
          int y = (int) event.getRawY() - listViewCoords[1];
          ViewGroup child;
          for (int i = 0; i < childCount; i++) {
            child = (ViewGroup) mListView.getChildAt(i);
            child.getHitRect(rect);
            if (rect.contains(x, y)) {
              mDownView_parent = child;
              mDownView = (ViewGroup) child.findViewById(R.id.list_display_view_container);
              if (mDownView_parent.getChildCount() == 1) {
                textheight = mDownView_parent.getHeight();
                if (SwipeType == Dismiss) {
                  HalfColor = singleColor;
                  //                                HalfDrawable	=
                  //	activity.getResources().getDrawable(R.drawable.content_discard);
                }
                SetBackGroundforList();
              }

              if (old_mDownView != null && mDownView != old_mDownView) {
                ResetListItem(old_mDownView);
                old_mDownView = null;
                return false;
              }
              break;
            }
          }

          if (mDownView != null) {
            mDownX = event.getRawX();
            mDownY = event.getRawY();
            mDownPosition = mListView.getPositionForView(mDownView);
            mVelocityTracker = VelocityTracker.obtain();
            mVelocityTracker.addMovement(event);
          } else {
            mDownView = null;
          }

          // mSwipeDetected              =   false;
          temp_position = mListView.pointToPosition((int) event.getX(), (int) event.getY());
          view.onTouchEvent(event);
          return true;
        }

      case MotionEvent.ACTION_UP:
        {
          if (mVelocityTracker == null) {
            break;
          }
          float deltaX = event.getRawX() - mDownX;
          // 在OnItemClick事件中判断如果Deltax!=0则表示不是点击事件
          DeltaX = deltaX;
          mVelocityTracker.addMovement(event);
          mVelocityTracker.computeCurrentVelocity(1000); // 1000 by defaut but
          float velocityX = mVelocityTracker.getXVelocity(); // it was too much
          float absVelocityX = Math.abs(velocityX);
          float absVelocityY = Math.abs(mVelocityTracker.getYVelocity());
          boolean swipe = false;
          boolean swipeRight = false;

          if (Math.abs(deltaX) > tempwidth) {
            swipe = true;
            swipeRight = deltaX > 0;

          } else if (mMinFlingVelocity <= absVelocityX
              && absVelocityX <= mMaxFlingVelocity
              && absVelocityY < absVelocityX) {
            // dismiss only if flinging in the same direction as dragging
            swipe = (velocityX < 0) == (deltaX < 0);
            swipeRight = mVelocityTracker.getXVelocity() > 0;
          }
          if (deltaX < 0 && swipe) {
            mListView.setDrawSelectorOnTop(false);
            // && Math.abs(DeltaY)<30
            if (swipe && !swipeRight && deltaX <= -tempwidth && Math.abs(DeltaY) < 100) {
              FullSwipeTrigger();
            } else if (deltaX >= -textwidth && SwipeType == Double) {
              ResetListItem(mDownView);
            } else {
              ResetListItem(mDownView);
            }
          } else if (deltaX != 0) {
            ResetListItem(mDownView);
          }

          mVelocityTracker.recycle();
          mVelocityTracker = null;
          mDownX = 0;
          mDownView = null;
          mDownPosition = ListView.INVALID_POSITION;
          mSwiping = false;
          break;
        }

        // 根据手势滑动方向滑出滑入

      case MotionEvent.ACTION_MOVE:
        {
          float deltaX = event.getRawX() - mDownX;
          float deltaY = event.getRawY() - mDownY;
          DeltaY = deltaY;
          if (mVelocityTracker == null || mPaused || deltaX > 0) {
            break;
          }

          mVelocityTracker.addMovement(event);

          // && Math.abs(deltaY)<30
          if (Math.abs(deltaX) > (mSlop * 5) && Math.abs(deltaY) < 50) {
            mSwiping = true;
            mListView.requestDisallowInterceptTouchEvent(true);

            // Cancel ListView's touch (un-highlighting the item)
            MotionEvent cancelEvent = MotionEvent.obtain(event);
            cancelEvent.setAction(
                MotionEvent.ACTION_CANCEL
                    | (event.getActionIndex() << MotionEvent.ACTION_POINTER_INDEX_SHIFT));
            mListView.onTouchEvent(cancelEvent);
            cancelEvent.recycle();
          } else if (Math.abs(deltaY) > 50) {
            mSwiping = false;
            //                     ResetListItem(mDownView);
          }
          System.out.println(
              "<<<<<<<<<" + deltaY + "<<<<<<" + deltaX + "<<<<" + mSwiping + "<<<<<" + mSlop * 10);
          if (mSwiping && deltaX < 0) {
            int width;
            //                     if(SwipeType==1){
            width = textwidth2;
            //                     }
            //                     else{
            //                         width	=	largewidth;
            //                     }

            if (-deltaX < width) {

              mDownView.setTranslationX(deltaX);
              return false;
            }
            return false;
          } else if (mSwiping) {
            ResetListItem(mDownView);
          }
          break;
        }
    }
    return false;
  }
  /**
   * Provide default implementation to return a simple list view. Subclasses can override to replace
   * with their own layout. If doing so, the returned view hierarchy <em>must</em> have a ListView
   * whose id is {@link android.R.id#list android.R.id.list} and can optionally have a sibling view
   * id {@link android.R.id#empty android.R.id.empty} that is to be shown when the list is empty.
   *
   * <p>If you are overriding this method with your own custom content, consider including the
   * standard layout {@link android.R.layout#list_content} in your layout file, so that you continue
   * to retain all of the standard behavior of ListFragment. In particular, this is currently the
   * only way to have the built-in indeterminant progress state be shown.
   *
   * @param inflater the inflater
   * @param container the container
   * @param savedInstanceState the saved instance state
   * @return the view´
   * @author RayBa
   * @date 07.04.2013
   */
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    if (layoutRessource > 0) {
      View v = getLayoutInflater(savedInstanceState).inflate(layoutRessource, null);
      return v;
    } else {
      FrameLayout root = new FrameLayout(context);

      // ------------------------------------------------------------------

      LinearLayout pframe = new LinearLayout(context);
      pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
      pframe.setOrientation(LinearLayout.VERTICAL);
      pframe.setVisibility(View.GONE);
      pframe.setGravity(Gravity.CENTER);

      ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyle);
      pframe.addView(
          progress,
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

      root.addView(
          pframe,
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

      // ------------------------------------------------------------------

      FrameLayout lframe = new FrameLayout(context);
      lframe.setId(INTERNAL_LIST_CONTAINER_ID);

      TextView tv = new TextView(getActivity());
      tv.setId(INTERNAL_EMPTY_ID);
      tv.setGravity(Gravity.CENTER);
      tv.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium);
      lframe.addView(
          tv,
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

      ListView lv = new ListView(getActivity());
      lv.setId(android.R.id.list);
      lv.setDrawSelectorOnTop(false);
      lframe.addView(
          lv,
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

      root.addView(
          lframe,
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

      // ------------------------------------------------------------------

      root.setLayoutParams(
          new FrameLayout.LayoutParams(
              ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

      return root;
    }
  }
  /** Set the ContentView to be either the grid of thumbnails or the vertical list. */
  private void switchViewMode(BookmarkViewMode viewMode) {
    if (mViewMode == viewMode) {
      return;
    }

    mViewMode = viewMode;

    // Update the preferences to make the new view mode sticky.
    Editor ed = getPreferences(MODE_PRIVATE).edit();
    if (mMostVisited) {
      ed.putInt(PREF_MOST_VISITED_VIEW_MODE, mViewMode.ordinal());
    } else {
      ed.putInt(PREF_BOOKMARK_VIEW_MODE, mViewMode.ordinal());
    }
    ed.apply();

    if (mBookmarksAdapter != null) {
      mBookmarksAdapter.switchViewMode(viewMode);
    }
    if (mViewMode == BookmarkViewMode.GRID) {
      if (mGridPage == null) {
        mGridPage = new GridView(this);
        if (mBookmarksAdapter != null) {
          mGridPage.setAdapter(mBookmarksAdapter);
        }
        mGridPage.setOnItemClickListener(mListener);
        mGridPage.setNumColumns(GridView.AUTO_FIT);
        mGridPage.setColumnWidth(BrowserActivity.getDesiredThumbnailWidth(this));
        mGridPage.setFocusable(true);
        mGridPage.setFocusableInTouchMode(true);
        mGridPage.setSelector(android.R.drawable.gallery_thumb);
        float density = getResources().getDisplayMetrics().density;
        mGridPage.setVerticalSpacing((int) (14 * density));
        mGridPage.setHorizontalSpacing((int) (8 * density));
        mGridPage.setStretchMode(GridView.STRETCH_SPACING);
        mGridPage.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
        mGridPage.setDrawSelectorOnTop(true);
        if (mMostVisited) {
          mGridPage.setEmptyView(mEmptyView);
        }
        if (!mCreateShortcut) {
          mGridPage.setOnCreateContextMenuListener(this);
        }
      }
      addContentView(mGridPage, FULL_SCREEN_PARAMS);
      if (mVerticalList != null) {
        ViewGroup parent = (ViewGroup) mVerticalList.getParent();
        if (parent != null) {
          parent.removeView(mVerticalList);
        }
      }
    } else {
      if (null == mVerticalList) {
        ListView listView = new ListView(this);
        if (mBookmarksAdapter != null) {
          listView.setAdapter(mBookmarksAdapter);
        }
        listView.setDrawSelectorOnTop(false);
        listView.setVerticalScrollBarEnabled(true);
        listView.setOnItemClickListener(mListener);
        if (mMostVisited) {
          listView.setEmptyView(mEmptyView);
        }
        if (!mCreateShortcut) {
          listView.setOnCreateContextMenuListener(this);
        }
        mVerticalList = listView;
      }
      addContentView(mVerticalList, FULL_SCREEN_PARAMS);
      if (mGridPage != null) {
        ViewGroup parent = (ViewGroup) mGridPage.getParent();
        if (parent != null) {
          parent.removeView(mGridPage);
        }
      }
    }
  }
Example #8
0
  @Override
  public void onCreate(Bundle bundle) {
    setTheme(GGApp.GG_APP.school.getTheme());
    super.onCreate(bundle);
    setContentView(R.layout.activity_filter);

    if (GGApp.GG_APP.preferences.getBoolean("first_use_filter", true)) {
      AlertDialog.Builder builder = new AlertDialog.Builder(FilterActivity.this);
      builder.setTitle(getApplication().getString(R.string.explanation));
      builder.setMessage(getApplication().getString(R.string.filter_help));
      builder.setPositiveButton(
          getApplication().getString(R.string.ok),
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
              dialog.dismiss();
            }
          });
      builder.create().show();
    }

    sv = (ScrollView) findViewById(R.id.scrollView);

    GGApp.GG_APP.preferences.edit().putBoolean("first_use_filter", false).apply();

    final String[] main_filterStrings =
        new String[] {
          getApplication().getString(R.string.school_class),
          getApplication().getString(R.string.teacher)
        };

    listView = (ListView) findViewById(R.id.filter_list);
    adapter = new FilterListAdapter(this, GGApp.GG_APP.filters);
    listView.setAdapter(adapter);
    listView.setDrawSelectorOnTop(true);
    setListViewHeightBasedOnChildren(listView);

    if (bundle != null) changed = bundle.getBoolean("changed", false);

    TextView tv = (TextView) findViewById(R.id.filter_sep_1);
    tv.setTextColor(GGApp.GG_APP.school.getAccentColor());
    TextView tv2 = (TextView) findViewById(R.id.filter_sep_2);
    tv2.setTextColor(GGApp.GG_APP.school.getAccentColor());

    Filter.FilterList list = GGApp.GG_APP.filters;
    mainFilterCategory = (TextView) findViewById(R.id.filter_main_category);
    mainFilterCategory.setText(
        list.mainFilter.type == Filter.FilterType.CLASS
            ? getApplication().getString(R.string.school_class)
            : getApplication().getString(R.string.teacher));
    mainFilterContent = (TextView) findViewById(R.id.filter_main_content);
    mainFilterContent.setText(list.mainFilter.filter);

    LinearLayout l_mode = (LinearLayout) findViewById(R.id.mainfilter_mode_layout);
    l_mode.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View viewIn) {
            Filter.FilterList list = GGApp.GG_APP.filters;
            selectedMode =
                list.mainFilter.type == Filter.FilterType.CLASS
                    ? 0
                    : list.mainFilter.type == Filter.FilterType.TEACHER ? 1 : 2;
            AlertDialog.Builder builder = new AlertDialog.Builder(FilterActivity.this);
            builder
                .setTitle(getApplication().getString(R.string.set_main_filter_mode))
                .setSingleChoiceItems(
                    main_filterStrings,
                    selectedMode,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int which) {
                        changed = true;
                        mainModePosition = which == 0 ? 0 : 1;
                        Filter.FilterList list = GGApp.GG_APP.filters;
                        list.mainFilter.type = Filter.FilterType.values()[mainModePosition];
                        mainFilterCategory.setText(
                            list.mainFilter.type == Filter.FilterType.CLASS
                                ? getApplication().getString(R.string.school_class)
                                : getApplication().getString(R.string.teacher));
                        FilterActivity.saveFilter(GGApp.GG_APP.filters);
                        dialog.dismiss();
                      }
                    });
            builder.setNegativeButton(
                getApplication().getString(R.string.abort),
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                  }
                });
            AlertDialog d = builder.create();
            d.show();
          }
        });

    LinearLayout l_content = (LinearLayout) findViewById(R.id.mainfilter_content_layout);
    l_content.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View viewIn) {
            AlertDialog.Builder builder = new AlertDialog.Builder(FilterActivity.this);
            builder.setTitle(getApplication().getString(R.string.set_main_filter));
            builder.setView(View.inflate(FilterActivity.this, R.layout.filter_dialog, null));
            builder.setPositiveButton(
                getApplication().getString(R.string.ok),
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    changed = true;
                    EditText ed = (EditText) ((Dialog) dialog).findViewById(R.id.filter_text);
                    String filtertext = ed.getText().toString().trim();
                    if (filtertext.isEmpty())
                      Snackbar.make(
                              getWindow().getDecorView().findViewById(R.id.coordinator_layout),
                              getString(R.string.invalid_filter),
                              Snackbar.LENGTH_LONG)
                          .show();
                    else {
                      Filter.FilterList list = GGApp.GG_APP.filters;
                      list.mainFilter.filter = filtertext;
                      mainFilterContent.setText(list.mainFilter.filter);
                      FilterActivity.saveFilter(GGApp.GG_APP.filters);
                    }
                    dialog.dismiss();
                  }
                });
            builder.setNegativeButton(
                getApplication().getString(R.string.abort),
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                  }
                });
            AlertDialog d = builder.create();
            d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
            d.show();
            Filter.FilterList list = GGApp.GG_APP.filters;
            EditText ed = (EditText) d.findViewById(R.id.filter_text);
            ed.setHint(
                list.mainFilter.type == Filter.FilterType.CLASS
                    ? getApplication().getString(R.string.school_class_name)
                    : getApplication().getString(R.string.teacher_shortcut));
            ed.setText(list.mainFilter.filter);
            ed.setSelectAllOnFocus(true);
          }
        });

    mToolBar = (Toolbar) findViewById(R.id.toolbar);
    mToolBar.setTitleTextColor(Color.WHITE);
    mToolBar.setBackgroundColor(GGApp.GG_APP.school.getColor());
    mToolBar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
    mToolBar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });
    mToolBar.inflateMenu(R.menu.filter_menu);
    mToolBar.setTitle(getTitle());

    mToolBar.setOnMenuItemClickListener(
        new Toolbar.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem menuItem) {
            if (menuItem.getItemId() == R.id.action_help) {
              AlertDialog.Builder builder = new AlertDialog.Builder(FilterActivity.this);
              builder.setTitle(getApplication().getString(R.string.help));
              builder.setMessage(getApplication().getString(R.string.filter_help));
              builder.setPositiveButton(
                  getApplication().getString(R.string.close),
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      dialog.dismiss();
                    }
                  });
              builder.create().show();
            }
            return false;
          }
        });

    mAddFilterButton = (FloatingActionButton) findViewById(R.id.addfilter_button);
    mAddFilterButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View viewIn) {
            AlertDialog.Builder builder = new AlertDialog.Builder(FilterActivity.this);
            builder.setTitle(getApplication().getString(R.string.hide_subject));
            builder.setView(View.inflate(FilterActivity.this, R.layout.filter_dialog, null));
            builder.setPositiveButton(
                getApplication().getString(R.string.hide),
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    changed = true;
                    EditText ed = (EditText) ((Dialog) dialog).findViewById(R.id.filter_text);
                    Filter f = new Filter();
                    f.type = Filter.FilterType.SUBJECT;
                    f.filter = ed.getText().toString().trim();
                    if (f.filter.isEmpty())
                      Snackbar.make(
                              getWindow().getDecorView().findViewById(R.id.coordinator_layout),
                              getString(R.string.invalid_filter),
                              Snackbar.LENGTH_LONG)
                          .show();
                    else {
                      GGApp.GG_APP.filters.add(f);
                      adapter.notifyDataSetChanged();
                      FilterActivity.saveFilter(GGApp.GG_APP.filters);
                      setListViewHeightBasedOnChildren(listView);
                    }
                    dialog.dismiss();
                  }
                });
            builder.setNegativeButton(
                getApplication().getString(R.string.abort),
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                  }
                }); //
            AlertDialog d = builder.create();
            d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
            d.show();
            EditText ed = (EditText) d.findViewById(R.id.filter_text);
            ed.setHint(getApplication().getString(R.string.subject_course_name));
          }
        });
  }