@Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
      Fragment fragment =
          (FileBrowser) getSupportFragmentManager().findFragmentByTag("MAIN_BROWSER");
      if (fragment != null && fragment.isVisible()) {
        boolean readyToQuit = true;
        if (fragment.getArguments() != null) {
          readyToQuit = fragment.getArguments().getBoolean("ImgBrowse", true);
        }
        if (readyToQuit) {
          MainActivity.this.finish();
        } else {
          launchMainFragment(fragment);
        }
        return true;
      } else {
        launchMainFragment(fragment);
        return true;
      }
    }
    if (keyCode == KeyEvent.KEYCODE_MENU) {
      sm.toggle(true);
    }

    return super.onKeyDown(keyCode, event);
  }
Example #2
0
  @Override
  public void onBackPressed() {
    boolean handled = false;
    try {
      FragmentManager fm = getSupportFragmentManager();
      Fragment frag = fm.findFragmentById(R.id.fragment_content);
      if (!(frag instanceof FragUtils.BackPressedHandler)) {
        Log.d(TAG, "frag type was: " + (frag == null ? "null" : frag.getClass().getSimpleName()));
        return;
      }

      if (!frag.isVisible()) {
        Log.d(TAG, "frag was not visible!");
        return;
      }

      handled = ((FragUtils.BackPressedHandler) frag).handleBackPressed();
      //      Log.w(TAG, "handleBackPressed returned: " + handled);
    } catch (Exception e) {
      Log.e(TAG, "Could not check onBackPressed", e);
    } finally {
      if (!handled) {
        super.onBackPressed();
      }
    }
  }
Example #3
0
 @SuppressLint("WorldReadableFiles")
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   getMenuInflater().inflate(R.menu.toolbar_menu, menu);
   SwitchCompat master_switch =
       (SwitchCompat) MenuItemCompat.getActionView(menu.findItem(R.id.toolbar_master_switch));
   //noinspection deprecation
   master_switch.setChecked(
       getSharedPreferences(Common.PREFS_APPS, Context.MODE_WORLD_READABLE)
           .getBoolean(Common.MASTER_SWITCH_ON, true));
   master_switch.setOnCheckedChangeListener(
       new CompoundButton.OnCheckedChangeListener() {
         @SuppressLint({"CommitPrefEdits"})
         @Override
         public void onCheckedChanged(CompoundButton button, boolean b) {
           MLPreferences.getPrefsApps(SettingsActivity.this)
               .edit()
               .putBoolean(Common.MASTER_SWITCH_ON, b)
               .commit();
         }
       });
   Fragment lockScreen = getSupportFragmentManager().findFragmentByTag(TAG_LOCK_FRAGMENT);
   if (getSupportActionBar() != null
       && !getSupportActionBar().isShowing()
       && (lockScreen == null || !lockScreen.isVisible())) {
     getSupportActionBar().show();
   }
   return super.onCreateOptionsMenu(menu);
 }
 private boolean shouldShowSelectAll() {
   final Fragment imageThumbnailFragment =
       getSupportFragmentManager().findFragmentByTag(ImagesThumbnailFragment.TAG);
   return imageThumbnailFragment != null
       && imageThumbnailFragment.isVisible()
       && !mPickOptions.pickMode.equals(Picker.PickMode.SINGLE_IMAGE);
 }
  public int onMessageSent(String to, String message) {
    getChatStorage().deleteDraft(to);
    if (messageListFragment != null && messageListFragment.isVisible()) {
      ((ChatListFragment) messageListFragment).refresh();
    }

    return getChatStorage().saveTextMessage("", to, message, System.currentTimeMillis());
  }
 public Fragment getVisibleFragment() {
   FragmentManager fragmentManager = MenuEstudiante.this.getSupportFragmentManager();
   List<Fragment> fragments = fragmentManager.getFragments();
   for (Fragment fragment : fragments) {
     if (fragment != null && fragment.isVisible()) return fragment;
   }
   return null;
 }
 private FragmentTransaction _addHideAllVisibleFragmentsToFragmentTransaction(
     HashMap<String, Fragment> stringFragmentHashMap, FragmentTransaction fragmentTransaction) {
   Collection<Fragment> fragmentCollection = stringFragmentHashMap.values();
   for (Fragment fragment : fragmentCollection) {
     if (fragment != null && fragment.isVisible()) {
       fragmentTransaction = fragmentTransaction.hide(fragment);
     }
   }
   return fragmentTransaction;
 }
  @Override
  public void onBackPressed() {
    super.onBackPressed();

    Fragment tagFrag = getSupportFragmentManager().findFragmentById(R.id.tagcontent);
    View panelBtn = findViewById(R.id.panel_collapse_button);

    if (tagFrag != null && panelBtn != null) {
      if (tagFrag.isVisible()) findViewById(R.id.panel_collapse_button).setVisibility(View.GONE);
      else findViewById(R.id.panel_collapse_button).setVisibility(View.VISIBLE);
    }
  }
 public void displayContact(Contact contact, boolean chatOnly) {
   Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
   if (fragment2 != null
       && fragment2.isVisible()
       && currentFragment == FragmentsAvailable.CONTACT) {
     ContactFragment contactFragment = (ContactFragment) fragment2;
     contactFragment.changeDisplayedContact(contact);
   } else {
     Bundle extras = new Bundle();
     extras.putSerializable("Contact", contact);
     extras.putBoolean("ChatAddressOnly", chatOnly);
     changeCurrentFragment(FragmentsAvailable.CONTACT, extras);
   }
 }
  public void displayHistoryDetail(String sipUri, LinphoneCallLog log) {
    LinphoneAddress lAddress;
    try {
      lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
    } catch (LinphoneCoreException e) {
      Log.e("Cannot display history details", e);
      return;
    }
    Contact c =
        ContactsManager.getInstance().findContactWithAddress(getContentResolver(), lAddress);

    String displayName = c != null ? c.getName() : null;
    String pictureUri = c != null && c.getPhotoUri() != null ? c.getPhotoUri().toString() : null;

    String status;
    if (log.getDirection() == CallDirection.Outgoing) {
      status = "Outgoing";
    } else {
      if (log.getStatus() == CallStatus.Missed) {
        status = "Missed";
      } else {
        status = "Incoming";
      }
    }

    String callTime = secondsToDisplayableString(log.getCallDuration());
    String callDate = String.valueOf(log.getTimestamp());

    Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
    if (fragment2 != null
        && fragment2.isVisible()
        && currentFragment == FragmentsAvailable.HISTORY_DETAIL) {
      HistoryDetailFragment historyDetailFragment = (HistoryDetailFragment) fragment2;
      historyDetailFragment.changeDisplayedHistory(
          sipUri, displayName, pictureUri, status, callTime, callDate);
    } else {
      Bundle extras = new Bundle();
      extras.putString("SipUri", sipUri);
      if (displayName != null) {
        extras.putString("DisplayName", displayName);
        extras.putString("PictureUri", pictureUri);
      }
      extras.putString("CallStatus", status);
      extras.putString("CallTime", callTime);
      extras.putString("CallDate", callDate);

      changeCurrentFragment(FragmentsAvailable.HISTORY_DETAIL, extras);
    }
  }
Example #11
0
 private void toggleSettings() {
   FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
   Fragment fragment = getSupportFragmentManager().findFragmentByTag("settings");
   if (fragment.isVisible()) {
     transaction
         .setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
         .hide(fragment)
         .commit();
   } else {
     transaction
         .setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
         .show(fragment)
         .addToBackStack("settings")
         .commit();
     hide_keyboard(this);
   }
 }
Example #12
0
  private void setFragment(Fragment fragment) {
    if (fragments == null) {
      return;
    }

    FragmentManager fragmentManager = this.getSupportFragmentManager();
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    if (fragment.isAdded() && fragment.isVisible()) {
      return;
    }
    if (fragment.isAdded()) {
      transaction.show(fragment);
    } else {
      transaction.replace(R.id.content, fragment);
    }
    transaction.commit();
  }
  private boolean shouldShowDeselectAll() {

    if (mSelectedAlbum == null) {
      return false;
    }

    boolean isAllImagesSelected = true;
    for (final ImageEntry albumChildImage : mSelectedAlbum.imageList) {

      if (!sCheckedImages.contains(albumChildImage)) {
        isAllImagesSelected = false;
        break;
      }
    }

    final Fragment imageThumbnailFragment =
        getSupportFragmentManager().findFragmentByTag(ImagesThumbnailFragment.TAG);

    return isAllImagesSelected
        && imageThumbnailFragment != null
        && imageThumbnailFragment.isVisible();
  }
  public void displayChat(String sipUri) {
    if (getResources().getBoolean(R.bool.disable_chat)) {
      return;
    }

    LinphoneAddress lAddress;
    try {
      lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
    } catch (LinphoneCoreException e) {
      Log.e("Cannot display chat", e);
      return;
    }
    Contact contact =
        ContactsManager.getInstance().findContactWithAddress(getContentResolver(), lAddress);
    String displayName = contact != null ? contact.getName() : null;

    String pictureUri = null;
    String thumbnailUri = null;
    if (contact != null && contact.getPhotoUri() != null) {
      pictureUri = contact.getPhotoUri().toString();
      thumbnailUri = contact.getThumbnailUri().toString();
    }

    if (isTablet()) {
      if (currentFragment == FragmentsAvailable.CHATLIST
          || currentFragment == FragmentsAvailable.CHAT) {
        Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
        if (fragment2 != null
            && fragment2.isVisible()
            && currentFragment == FragmentsAvailable.CHAT) {
          ChatFragment chatFragment = (ChatFragment) fragment2;
          chatFragment.changeDisplayedChat(sipUri, displayName, pictureUri);
        } else {
          Bundle extras = new Bundle();
          extras.putString("SipUri", sipUri);
          if (contact != null) {
            extras.putString("DisplayName", displayName);
            extras.putString("PictureUri", pictureUri);
            extras.putString("ThumbnailUri", thumbnailUri);
          }
          changeCurrentFragment(FragmentsAvailable.CHAT, extras);
        }
      } else {
        changeCurrentFragment(FragmentsAvailable.CHATLIST, null);
        displayChat(sipUri);
      }
      if (messageListFragment != null && messageListFragment.isVisible()) {
        ((ChatListFragment) messageListFragment).refresh();
      }
    } else {
      Intent intent = new Intent(this, ChatActivity.class);
      intent.putExtra("SipUri", sipUri);
      if (contact != null) {
        intent.putExtra("DisplayName", contact.getName());
        intent.putExtra("PictureUri", pictureUri);
        intent.putExtra("ThumbnailUri", thumbnailUri);
      }
      startOrientationSensor();
      startActivityForResult(intent, CHAT_ACTIVITY);
    }

    LinphoneService.instance().resetMessageNotifCount();
    LinphoneService.instance().removeMessageNotification();
    displayMissedChats(getChatStorage().getUnreadMessageCount());
  }
  private boolean isFragmentShown(final String tag) {

    final Fragment fragment = getSupportFragmentManager().findFragmentByTag(tag);

    return fragment != null && fragment.isVisible();
  }
Example #16
0
 public boolean isVisible() {
   return zzadh.isVisible();
 }