Exemplo n.º 1
0
  @Override
  public void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    Thread.setDefaultUncaughtExceptionHandler(
        new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    final SearchManager manager = (SearchManager) getSystemService(SEARCH_SERVICE);
    manager.setOnCancelListener(null);

    final TabHost host = getTabHost();
    LayoutInflater.from(this).inflate(R.layout.bookmarks, host.getTabContentView(), true);

    myBook = SerializerUtil.deserializeBook(getIntent().getStringExtra(FBReader.BOOK_KEY));
  }
Exemplo n.º 2
0
  @Override
  public void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    Thread.setDefaultUncaughtExceptionHandler(
        new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));

    // requestWindowFeature(Window.FEATURE_NO_TITLE);
    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    final TabHost host = getTabHost();
    LayoutInflater.from(this).inflate(R.layout.bookmarks, host.getTabContentView(), true);

    AllBooksBookmarks = Bookmark.bookmarks();
    Collections.sort(AllBooksBookmarks, new Bookmark.ByTimeComparator());
    final FBReader fbreader = (FBReader) FBReader.Instance();

    if (fbreader.Model != null) {
      final long bookId = fbreader.Model.Book.getId();
      for (Bookmark bookmark : AllBooksBookmarks) {
        if (bookmark.getBookId() == bookId) {
          myThisBookBookmarks.add(bookmark);
        }
      }

      myThisBookView = createTab("thisBook", R.id.this_book);
      new BookmarksAdapter(myThisBookView, myThisBookBookmarks, true);
    } else {
      findViewById(R.id.this_book).setVisibility(View.GONE);
    }

    myAllBooksView = createTab("allBooks", R.id.all_books);
    new BookmarksAdapter(myAllBooksView, AllBooksBookmarks, false);

    findViewById(R.id.search_results).setVisibility(View.GONE);
  }
Exemplo n.º 3
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Thread.setDefaultUncaughtExceptionHandler(
        new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));
    setContentView(R.layout.authentication);

    final Intent intent = getIntent();

    final String host = intent.getStringExtra(HOST_KEY);
    final String area = intent.getStringExtra(AREA_KEY);
    final String username = intent.getStringExtra(USERNAME_KEY);
    final String error = intent.getStringExtra(ERROR_KEY);
    myCustomAuthentication = intent.getBooleanExtra(CUSTOM_AUTH_KEY, false);

    if (myCustomAuthentication) {
      myLink = NetworkLibrary.Instance().getLinkByUrl(String.valueOf(intent.getData()));
      if (myLink == null) {
        finish();
        return;
      }
      setResult(RESULT_CANCELED, Util.intentByLink(new Intent(), myLink));
    } else {
      myLink = null;
      setResult(RESULT_CANCELED);
    }

    myOnSuccessRunnable = ourOnSuccessRunnableMap.remove(intent.getLongExtra(RUNNABLE_KEY, -1));

    myResource = ZLResource.resource("dialog").getResource("AuthenticationDialog");

    setTitle(host != null ? host : myResource.getResource("title").getValue());

    if (area != null && !"".equals(area)) {
      findTextView(R.id.authentication_subtitle).setText(area);
    } else {
      findTextView(R.id.authentication_subtitle).setVisibility(View.GONE);
    }
    final TextView warningView = findTextView(R.id.authentication_unencrypted_warning);
    if ("https".equalsIgnoreCase(intent.getStringExtra(SCHEME_KEY))) {
      warningView.setVisibility(View.GONE);
    } else {
      warningView.setText(myResource.getResource("unencryptedWarning").getValue());
    }
    findTextView(R.id.authentication_username_label)
        .setText(myResource.getResource("login").getValue());
    findTextView(R.id.authentication_password_label)
        .setText(myResource.getResource("password").getValue());

    myUsernameView = findTextView(R.id.authentication_username);
    myUsernameView.setText(username);

    setError(error);

    final ZLResource buttonResource = ZLResource.resource("dialog").getResource("button");

    final View buttonsView = findViewById(R.id.authentication_buttons);
    myOkButton = (Button) buttonsView.findViewById(R.id.ok_button);
    myOkButton.setText(buttonResource.getResource("ok").getValue());
    myOkButton.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            final String username = myUsernameView.getText().toString();
            final String password = findTextView(R.id.authentication_password).getText().toString();
            if (myCustomAuthentication) {
              runCustomAuthentication(username, password);
            } else {
              finishOk(username, password);
            }
          }
        });

    final Button cancelButton = (Button) buttonsView.findViewById(R.id.cancel_button);
    cancelButton.setText(buttonResource.getResource("cancel").getValue());
    cancelButton.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            runOnUiThread(
                new Runnable() {
                  public void run() {
                    if (myLink != null) {
                      final NetworkAuthenticationManager mgr = myLink.authenticationManager();
                      if (mgr.mayBeAuthorised(false)) {
                        mgr.logOut();
                      }
                    }
                    final NetworkLibrary library = NetworkLibrary.Instance();
                    library.invalidateVisibility();
                    library.synchronize();
                  }
                });
            finish();
          }
        });
  }