Ejemplo n.º 1
0
  /**
   * ***************************************************
   *
   * <p>Called with the current top-most fragment.
   *
   * <p>***************************************************
   */
  protected void onNotifyTop(AKiteFragment topFragment) {
    ActionBar actionBar = getActionBar();

    // Determine which fragment is top-most

    String tag = topFragment.getTag();

    if (tag != null && tag.equals(ChooseProductGroupFragment.TAG)) {
      ///// Home page /////

      // We only enable the menu on the home page
      mDrawerToggle.setDrawerIndicatorEnabled(true);
      mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);

      // We display the logo on the home page
      actionBar.setDisplayShowTitleEnabled(false);
      actionBar.setDisplayShowCustomEnabled(true);
    } else {
      mDrawerToggle.setDrawerIndicatorEnabled(false);
      mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

      // On other pages we show a title
      actionBar.setDisplayShowTitleEnabled(true);
      actionBar.setDisplayShowCustomEnabled(false);
    }

    super.onNotifyTop(topFragment);
  }
 public void setFullScreen(boolean fullScreen) {
   if (fullScreen) {
     getSupportActionBar().hide();
     mDrawerRootLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
   } else {
     getSupportActionBar().show();
     mDrawerRootLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
   }
 }
Ejemplo n.º 3
0
 @Override
 public void onDetach() {
   super.onDetach();
   DrawerLayout drawer = ButterKnife.findById(getActivity(), R.id.drawer_container);
   drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
   setupToolbar(false);
 }
 public void setDrawerState(boolean isEnabled) {
   if (isEnabled) {
     _mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
     getActionBarDrawerToggle().setDrawerIndicatorEnabled(true);
     if (getSupportActionBar() != null) {
       getSupportActionBar().setDisplayHomeAsUpEnabled(true);
     }
     getActionBarDrawerToggle().syncState();
   } else {
     _mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
     getActionBarDrawerToggle().setDrawerIndicatorEnabled(false);
     if (getSupportActionBar() != null) {
       getSupportActionBar().setDisplayHomeAsUpEnabled(false);
     }
     getActionBarDrawerToggle().syncState();
   }
 }
Ejemplo n.º 5
0
 public void setDrawableLockMode(boolean unlock) {
   mDrawerToggle.setDrawerIndicatorEnabled(unlock);
   mDrawerLayout.setDrawerLockMode(
       unlock ? DrawerLayout.LOCK_MODE_UNLOCKED : DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
 }
 public void enableDrawer(boolean enable) {
   mDrawerLayout.setDrawerLockMode(
       enable ? DrawerLayout.LOCK_MODE_UNLOCKED : DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
 }
Ejemplo n.º 7
0
 void setupParent() {
   DrawerLayout drawer = ButterKnife.findById(getActivity(), R.id.drawer_container);
   drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
   drawer.closeDrawer(GravityCompat.START);
 }
 public void lockFilterDrawer(boolean lock) {
   mDrawerLayout.setDrawerLockMode(
       lock ? DrawerLayout.LOCK_MODE_LOCKED_CLOSED : DrawerLayout.LOCK_MODE_UNLOCKED,
       Gravity.RIGHT);
 }
Ejemplo n.º 9
0
 public void drawerDisable() {
   drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
   toolbarLeftIcon.setText(R.string.icon_chevron_left);
   toolbarRightIcon.setVisibility(View.INVISIBLE);
 }
Ejemplo n.º 10
0
 public void drawerEnable() {
   drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
   toolbarLeftIcon.setText(R.string.icon_menu);
   toolbarRightIcon.setVisibility(View.VISIBLE);
 }
Ejemplo n.º 11
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    mRoots = DocumentsApplication.getRootsCache(this);

    setResult(Activity.RESULT_CANCELED);
    setContentView(R.layout.activity);

    final Context context = this;
    final Resources res = getResources();
    mShowAsDialog = res.getBoolean(R.bool.show_as_dialog);

    if (mShowAsDialog) {
      // Strongly define our horizontal dimension; we leave vertical as
      // WRAP_CONTENT so that system resizes us when IME is showing.
      final WindowManager.LayoutParams a = getWindow().getAttributes();

      final Point size = new Point();
      getWindowManager().getDefaultDisplay().getSize(size);
      a.width = (int) res.getFraction(R.dimen.dialog_width, size.x, size.x);

      getWindow().setAttributes(a);

    } else {
      // Non-dialog means we have a drawer
      mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

      mDrawerToggle =
          new ActionBarDrawerToggle(
              this,
              mDrawerLayout,
              R.drawable.ic_hamburger,
              R.string.drawer_open,
              R.string.drawer_close);

      mDrawerLayout.setDrawerListener(mDrawerListener);

      mRootsDrawer = findViewById(R.id.drawer_roots);
    }

    mDirectoryContainer = (DirectoryContainerView) findViewById(R.id.container_directory);

    if (icicle != null) {
      mState = icicle.getParcelable(EXTRA_STATE);
    } else {
      buildDefaultState();
    }

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setTitleTextAppearance(
        context, android.R.style.TextAppearance_DeviceDefault_Widget_ActionBar_Title);
    /// M: add log to print intent info
    Intent intent = getIntent();
    Log.d(
        TAG,
        "onCreate: intent = "
            + intent
            + ", extra = "
            + (intent != null ? intent.getExtras() : null));

    mToolbarStack = (Spinner) findViewById(R.id.stack);
    mToolbarStack.setOnItemSelectedListener(mStackListener);

    mRootsToolbar = (Toolbar) findViewById(R.id.roots_toolbar);
    if (mRootsToolbar != null) {
      mRootsToolbar.setTitleTextAppearance(
          context, android.R.style.TextAppearance_DeviceDefault_Widget_ActionBar_Title);
    }

    setActionBar(mToolbar);

    // Hide roots when we're managing a specific root
    if (mState.action == ACTION_MANAGE) {
      if (mShowAsDialog) {
        findViewById(R.id.container_roots).setVisibility(View.GONE);
      } else {
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
      }
    }

    if (mState.action == ACTION_CREATE) {
      final String mimeType = getIntent().getType();
      final String title = getIntent().getStringExtra(Intent.EXTRA_TITLE);
      SaveFragment.show(getFragmentManager(), mimeType, title);
    } else if (mState.action == ACTION_OPEN_TREE) {
      PickFragment.show(getFragmentManager());
    }

    if (mState.action == ACTION_GET_CONTENT) {
      final Intent moreApps = new Intent(getIntent());
      moreApps.setComponent(null);
      moreApps.setPackage(null);
      RootsFragment.show(getFragmentManager(), moreApps);
    } else if (mState.action == ACTION_OPEN
        || mState.action == ACTION_CREATE
        || mState.action == ACTION_OPEN_TREE) {
      RootsFragment.show(getFragmentManager(), null);
    }

    if (!mState.restored) {
      /// M: If show ad ACTION_MANAGE, hide default title to avoid show to user
      setTitle(null);
      if (mState.action == ACTION_MANAGE) {
        final Uri rootUri = getIntent().getData();
        new RestoreRootTask(rootUri).executeOnExecutor(getCurrentExecutor());
      } else {
        new RestoreStackTask().execute();
      }
    } else {
      onCurrentDirectoryChanged(ANIM_NONE);
    }
    /// M: update action bar when roots are reloaded @{
    mRoots.addCallback(mRootUpdatedListener);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.task_addtask_view, container, false);

    // OPEN DATABASE
    prof_dataSource = new ProfessorDataSource(getActivity());
    task_dataSource = new TaskDataSource(getActivity());
    courseDataSource = new CourseDataSource(getActivity());
    try {
      prof_dataSource.open();
      task_dataSource.open();
      courseDataSource.open();
    } catch (SQLException e) {
      e.printStackTrace();
    }

    task = new Task();
    prof = new Professor();

    // TO PREVENT VIEWS FROM OVERLAYING EACH OTHER WHEN
    // KEYPAD IS CALLED, CALL THIS METHOD
    getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

    // DRAWER HAS TO BE DISABLED IN OTHER TO PREVENT CHILD FRAGMENTS FROM OVERLAYING PARENT FRAGMENT
    parent_drawer = (DrawerLayout) getActivity().findViewById(R.id.drawer_layout);
    parent_drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

    // INFLATE VIEWS HERE
    task_title_spinner = (Spinner) view.findViewById(R.id.task_title);
    task_location = (EditText) view.findViewById(R.id.task_location_et);
    task_note = (AutoCompleteTextView) view.findViewById(R.id.task_note_et);
    task_day = (Spinner) view.findViewById(R.id.task_dateView);
    task_time = (TextView) view.findViewById(R.id.task_timeView);
    // save_btn = (TextView) view.findViewById(R.id.task_savebtn);
    // cancel_btn = (TextView) view.findViewById(R.id.task_cancelbtn);

    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter =
        ArrayAdapter.createFromResource(
            getActivity(), R.array.task_spinner, android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    task_title_spinner.setAdapter(adapter);

    // DAY SPINNER ADAPER
    ArrayAdapter<CharSequence> day_adapter =
        ArrayAdapter.createFromResource(
            getActivity(), R.array.day_spinner, android.R.layout.simple_spinner_item);
    day_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    task_day.setAdapter(day_adapter);

    // PUT LISTENERS HERE
    // task_day.setOnClickListener(new DatePickerListener());
    task_time.setOnClickListener(new TimePickerListener());

    // TASK TITLE LISTENER
    task_title_spinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            current_title_position = parent.getItemAtPosition(position).toString();
            if (current_title_position.equalsIgnoreCase("meeting")) {
              task_note.setHint("professor");
              final ArrayList<String> list = new ArrayList<String>();
              new android.os.Handler()
                  .post(
                      new Runnable() {
                        @Override
                        public void run() {
                          final Cursor cursor = prof_dataSource.getAllProfessors();
                          if (cursor.moveToFirst()) {
                            do {
                              list.add(
                                  cursor.getString(
                                      cursor.getColumnIndex(DB_ABSTRACTS.DBProfessor.NAME_COLUMN)));
                            } while (cursor.moveToNext());
                          }
                          ArrayAdapter<String> ad =
                              new ArrayAdapter<String>(
                                  getActivity(), android.R.layout.simple_list_item_1, list);
                          task_note.setAdapter(ad);
                        }
                      });
            }
            if (current_title_position.equalsIgnoreCase("lesson")) {
              task_note.setHint("course");
              task_location.setHint("room");
              // ADD AUTOCOMLETE TO THE COURSE TEXTFIELD
              final ArrayList<String> list = new ArrayList<String>();
              new android.os.Handler()
                  .post(
                      new Runnable() {
                        @Override
                        public void run() {
                          final Cursor cursor = courseDataSource.getAllCourses();
                          if (cursor.moveToFirst()) {
                            do {
                              list.add(
                                  cursor.getString(
                                      cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.NAME_COLUMN)));
                            } while (cursor.moveToNext());
                          }
                          ArrayAdapter<String> ad =
                              new ArrayAdapter<String>(
                                  getActivity(), android.R.layout.simple_list_item_1, list);
                          task_note.setAdapter(ad);
                        }
                      });
            }
            if (current_title_position.equalsIgnoreCase("todo")) {
              task_note.setHint("task");
              task_location.setHint("location");
              // Restore default empty adapter
              ArrayList<String> list = new ArrayList<String>();
              task_note.setAdapter(
                  new ArrayAdapter<String>(
                      getActivity(), android.R.layout.simple_list_item_1, list));
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> adapterView) {}
        });

    // TASK DAY LISTENER
    task_day.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            current_day_position = parent.getItemAtPosition(position).toString();
          }

          @Override
          public void onNothingSelected(AdapterView<?> adapterView) {}
        });

    /*
    save_btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            //ASSURE THAT TEXTFIELDS ARE NOT EMPTY

            if (task_note.getText().toString().equals("")) {
                task_note.post(new Runnable() {
                    public void run() {
                        task_note.requestFocusFromTouch();
                        InputMethodManager lManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                        lManager.showSoftInput(task_note, 0);
                        toast_empty_field(task_note.getHint() + " FIELD CANNOT BE EMPTY");
                    }
                });

            } else if (task_location.getText().toString().equals("")) {
                task_location.post(new Runnable() {
                    public void run() {
                        task_location.requestFocusFromTouch();
                        InputMethodManager lManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                        lManager.showSoftInput(task_note, 0);
                        toast_empty_field(task_location.getHint() + " FIELD CANNOT BE EMPTY");
                    }
                });
            } else {

                if (time_format == null || task_time.getText().toString().equalsIgnoreCase("Now")) {
                    //GET CURRENT TIME
                    getCurrentTime();
                }

                if (current_title_position.equalsIgnoreCase("meeting")) {
                    prof.setProfessor_name(task_note.getText().toString());
                    task.setTime(time_format);
                    task.setTitle(current_title_position);
                    task.setNote("Meeting with " + prof.getProfessor_name());
                    task.setDay(current_day_position);
                    task.setLocation(task_location.getText().toString());
                } else {
                    task.setTime(time_format);
                    task.setTitle(current_title_position);
                    task.setNote(task_note.getText().toString());
                    task.setDay(current_day_position);
                    task.setLocation(task_location.getText().toString());
                    prof.setProfessor_name(" ");
                }

                task_dataSource.createTask(task, prof);

                Log.e("includes", task_dataSource.getTaskCount() + " tasks");

                //GO BACK TO PARENT FRAGMENT
                getActivity().onBackPressed();
            }
        }
    });

    */

    /*
    cancel_btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            //GO BACK TO PARENT FRAGMENT
            getActivity().onBackPressed();
        }
    });
    */

    prof_dataSource.close();
    task_dataSource.close();
    courseDataSource.close();
    return view;
  }