示例#1
0
    @Override
    protected void onFinishInflate() {
      super.onFinishInflate();

      bChangeBook = V.get(this, R.id.bChangeBook);
      bChangeCode = V.get(this, R.id.bChangeCode);

      bOk = V.get(this, R.id.bOk);
      bDigitA = V.get(this, R.id.bDigitA);
      bDigitB = V.get(this, R.id.bDigitB);
      bDigitC = V.get(this, R.id.bDigitC);

      bChangeBook.setOnClickListener(
          v -> {
            final PopupMenu popupChangeBook =
                SongBookUtil.getSongBookPopupMenu(activity, false, true, bChangeBook);
            popupChangeBook.setOnMenuItemClickListener(
                SongBookUtil.getSongBookOnMenuItemClickListener(
                    new SongBookUtil.DefaultOnSongBookSelectedListener() {
                      @Override
                      public void onSongBookSelected(final String name) {
                        listener.songBookSelected(name);
                      }

                      @Override
                      public void onMoreSelected() {
                        listener.moreSelected();
                      }
                    }));

            popupChangeBook.show();
          });

      // all buttons
      for (int buttonId :
          new int[] {
            R.id.bDigit0,
            R.id.bDigit1,
            R.id.bDigit2,
            R.id.bDigit3,
            R.id.bDigit4,
            R.id.bDigit5,
            R.id.bDigit6,
            R.id.bDigit7,
            R.id.bDigit8,
            R.id.bDigit9,
            R.id.bDigitA,
            R.id.bDigitB,
            R.id.bDigitC,
            R.id.bOk,
            R.id.bBackspace,
          }) {
        V.get(this, buttonId).setOnClickListener(button_click);
      }
    }
示例#2
0
        @Override
        public void onSongBookSelected(boolean all, SongBookInfo songBookInfo) {
          if (all) return; // should not happen

          Song song = S.getSongDb().getFirstSongFromBook(songBookInfo.bookName);

          if (song != null) {
            displaySong(songBookInfo.bookName, song);
          } else {
            SongBookUtil.downloadSongBook(
                SongViewActivity.this,
                songBookInfo,
                new OnDownloadSongBookListener() {
                  @Override
                  public void onFailedOrCancelled(SongBookInfo songBookInfo, Exception e) {
                    if (e != null) {
                      new AlertDialog.Builder(SongViewActivity.this)
                          .setMessage(e.getClass().getSimpleName() + ' ' + e.getMessage())
                          .setPositiveButton(R.string.ok, null)
                          .show();
                    }
                  }

                  @Override
                  public void onDownloadedAndInserted(SongBookInfo songBookInfo) {
                    Song song = S.getSongDb().getFirstSongFromBook(songBookInfo.bookName);
                    displaySong(songBookInfo.bookName, song);
                  }
                });
          }
        }
示例#3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_song_view);

    setTitle(R.string.sn_songs_activity_title);

    song_container = V.get(this, R.id.song_container);
    no_song_data_container = V.get(this, R.id.no_song_data_container);
    bChangeBook = V.get(this, R.id.bChangeBook);
    bChangeCode = V.get(this, R.id.bChangeCode);
    bSearch = V.get(this, R.id.bSearch);
    bDownload = V.get(this, R.id.bDownload);

    qaChangeBook = SongBookUtil.getSongBookQuickAction(this, false);
    qaChangeBook.setOnActionItemClickListener(
        SongBookUtil.getOnActionItemConverter(songBookSelected));

    codeKeypad = new SongCodePopup(this);

    bChangeBook.setOnClickListener(bChangeBook_click);
    bChangeCode.setOnClickListener(bChangeCode_click);
    bSearch.setOnClickListener(bSearch_click);
    bDownload.setOnClickListener(bDownload_click);

    // for colors of bg, text, etc
    V.get(this, android.R.id.content).setBackgroundColor(S.applied.backgroundColor);

    templateCustomVars = new Bundle();
    templateCustomVars.putString(
        "background_color",
        String.format("#%06x", S.applied.backgroundColor & 0xffffff)); // $NON-NLS-1$ //$NON-NLS-2$
    templateCustomVars.putString(
        "text_color",
        String.format("#%06x", S.applied.fontColor & 0xffffff)); // $NON-NLS-1$ //$NON-NLS-2$
    templateCustomVars.putString(
        "verse_number_color",
        String.format("#%06x", S.applied.verseNumberColor & 0xffffff)); // $NON-NLS-1$ //$NON-NLS-2$
    templateCustomVars.putString(
        "text_size",
        S.applied.fontSize2dp
            + "px"); // somehow this is automatically scaled to dp. //$NON-NLS-1$ //$NON-NLS-2$
    templateCustomVars.putString(
        "line_spacing_mult", String.valueOf(S.applied.lineSpacingMult)); // $NON-NLS-1$

    {
      String fontName = Preferences.getString(getString(R.string.pref_jenisHuruf_key), null);
      if (FontManager.isCustomFont(fontName)) {
        templateCustomVars.putString(
            "custom_font_loader",
            String.format(
                "@font-face{ font-family: '%s'; src: url('%s'); }",
                fontName, FontManager.getCustomFontUri(fontName))); // $NON-NLS-1$ //$NON-NLS-2$
      } else {
        templateCustomVars.putString("custom_font_loader", ""); // $NON-NLS-1$ //$NON-NLS-2$
      }
      templateCustomVars.putString("text_font", fontName); // $NON-NLS-1$
    }

    { // show latest viewed song
      String bookName =
          Preferences.getString(Prefkey.song_last_bookName, null); // let KJ become the default.
      String code = Preferences.getString(Prefkey.song_last_code, null);

      if (bookName == null || code == null) {
        displaySong(null, null);
      } else {
        displaySong(bookName, S.getSongDb().getSong(bookName, code));
      }
    }
  }