Пример #1
0
  void displaySong(String bookName, Song song) {
    song_container.setVisibility(song != null ? View.VISIBLE : View.GONE);
    no_song_data_container.setVisibility(song != null ? View.GONE : View.VISIBLE);

    if (song != null) {
      bChangeBook.setText(bookName);
      bChangeCode.setText(song.code);

      // construct rendition of scripture references
      String scripture_references = renderScriptureReferences(PROTOCOL, song.scriptureReferences);
      templateCustomVars.putString("scripture_references", scripture_references); // $NON-NLS-1$

      FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
      ft.replace(
          R.id.song_container,
          SongFragment.create(song, "templates/song.html", templateCustomVars)); // $NON-NLS-1$
      ft.commitAllowingStateLoss();

      currentBookName = bookName;
      currentSong = song;

      { // save latest viewed song TODO optimize using new preferences fw
        Preferences.setString(Prefkey.song_last_bookName, bookName);
        Preferences.setString(Prefkey.song_last_code, song.code);
      }
    }
  }
Пример #2
0
 /**
  * The reason we use an installation id instead of just the simpleToken for sync to identify
  * originating device, is so that the GCM messages does not contain simpleToken, which is
  * sensitive.
  */
 public static synchronized String getInstallationId() {
   String res = Preferences.getString(Prefkey.installation_id, null);
   if (res == null) {
     res = "i1:" + UUID.randomUUID().toString();
     Preferences.setString(Prefkey.installation_id, res);
   }
   return res;
 }
Пример #3
0
 public static String getNotificationText() {
   String notificationText = Preferences.getString(REMINDER_TEXT);
   if (TextUtils.isEmpty(notificationText)) {
     notificationText = App.context.getString(R.string.dr_notification_text);
   }
   return notificationText;
 }
Пример #4
0
  @Override
  public void onGotoFinished(int gotoTabUsed, int bookId, int chapter_1, int verse_1) {
    // store goto tab used for next time
    Preferences.setInt(Prefkey.goto_last_tab, gotoTabUsed);

    Intent data = new Intent();
    data.putExtra(EXTRA_bookId, bookId);
    data.putExtra(EXTRA_chapter, chapter_1);
    data.putExtra(EXTRA_verse, verse_1);
    setResult(RESULT_OK, data);
    finish();
  }
Пример #5
0
 public static void scheduleAlarm(Context context) {
   String reminder_time = Preferences.getString(REMINDER_TIME);
   setAlarm(context, reminder_time);
 }
Пример #6
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));
      }
    }
  }
Пример #7
0
    @Override
    protected void onFinishInflate() {
      super.onFinishInflate();

      bMarkers = V.get(this, R.id.bMarkers);
      bDisplay = V.get(this, R.id.bDisplay);
      cFullScreen = V.get(this, R.id.cFullScreen);
      cNightMode = V.get(this, R.id.cNightMode);
      cSplitVersion = V.get(this, R.id.cSplitVersion);

      bProgressMarkList = V.get(this, R.id.bProgressMarkList);
      bProgress1 = V.get(this, R.id.bProgress1);
      bProgress2 = V.get(this, R.id.bProgress2);
      bProgress3 = V.get(this, R.id.bProgress3);
      bProgress4 = V.get(this, R.id.bProgress4);
      bProgress5 = V.get(this, R.id.bProgress5);

      panelCurrentReadingHeader = V.get(this, R.id.panelCurrentReadingHeader);
      bCurrentReadingClose = V.get(this, R.id.bCurrentReadingClose);
      bCurrentReadingReference = V.get(this, R.id.bCurrentReadingReference);

      cNightMode.setChecked(
          !isInEditMode() && Preferences.getBoolean(Prefkey.is_night_mode, false));

      bProgressMarkList.setOnClickListener(v -> listener.bProgressMarkList_click());

      final View[] views = new View[] {bProgress1, bProgress2, bProgress3, bProgress4, bProgress5};
      for (int i = 0; i < views.length; i++) {
        final View b = views[i];
        final int preset_id = i;
        b.setOnClickListener(
            v -> {
              listener.bProgress_click(preset_id);
              closeDrawer();
            });
        b.setOnLongClickListener(
            v -> {
              final ClipData dragData =
                  new ClipData(
                      "progress_mark",
                      new String[] {VerseItem.PROGRESS_MARK_DRAG_MIME_TYPE},
                      new ClipData.Item("" + preset_id));
              b.setPressed(false);
              final DragShadowBuilder dragShadowBuilder = new DragShadowBuilder(b);
              performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
              closeDrawer();
              v.startDrag(dragData, dragShadowBuilder, null, 0);

              return true;
            });
      }

      bMarkers.setOnClickListener(
          v -> {
            listener.bMarkers_click();
            closeDrawer();
          });

      bDisplay.setOnClickListener(
          v -> {
            listener.bDisplay_click();
            closeDrawer();
          });

      cFullScreen.setOnCheckedChangeListener(cFullScreen_checkedChange);

      cNightMode.setOnCheckedChangeListener(cNightMode_checkedChange);

      cSplitVersion.setOnCheckedChangeListener(cSplitVersion_checkedChange);

      bCurrentReadingClose.setOnClickListener(v -> listener.bCurrentReadingClose_click());
      bCurrentReadingReference.setOnClickListener(v -> listener.bCurrentReadingReference_click());

      displayCurrentReading();

      // The following is not in onAttachedFromWindow, because we need to listen to
      // ACTION_ACTIVE_VERSION_CHANGED as early as possible, so we do not end up with
      // a verse reference from a version that was not actually selected during app startup.
      final IntentFilter filter = new IntentFilter();
      filter.addAction(CurrentReading.ACTION_CURRENT_READING_CHANGED);
      filter.addAction(IsiActivity.ACTION_ACTIVE_VERSION_CHANGED);
      App.getLbm().registerReceiver(currentReadingChangeReceiver, filter);
    }
Пример #8
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    bookId = getIntent().getIntExtra(EXTRA_bookId, -1);
    chapter_1 = getIntent().getIntExtra(EXTRA_chapter, 0);
    verse_1 = getIntent().getIntExtra(EXTRA_verse, 0);

    ActionBar actionBar = getSupportActionBar();

    if (getResources().getBoolean(R.bool.screen_sw_check_min_600dp) == false) {
      // The following two options trigger the collapsing of the main action bar view.
      actionBar.setDisplayShowHomeEnabled(false);
      actionBar.setDisplayShowTitleEnabled(false);
    }

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.addTab(
        actionBar
            .newTab()
            .setTag(tab_dialer)
            .setText(R.string.goto_tab_dialer_label)
            .setTabListener(
                new TabListener<GotoDialerFragment>(
                    this,
                    "dialer",
                    GotoDialerFragment.class,
                    GotoDialerFragment.createArgs(bookId, chapter_1, verse_1)))); // $NON-NLS-1$
    actionBar.addTab(
        actionBar
            .newTab()
            .setTag(tab_direct)
            .setText(R.string.goto_tab_direct_label)
            .setTabListener(
                new TabListener<GotoDirectFragment>(
                    this,
                    "direct",
                    GotoDirectFragment.class,
                    GotoDirectFragment.createArgs(bookId, chapter_1, verse_1)))); // $NON-NLS-1$
    actionBar.addTab(
        actionBar
            .newTab()
            .setTag(tab_grid)
            .setText(R.string.goto_tab_grid_label)
            .setTabListener(
                new TabListener<GotoGridFragment>(
                    this,
                    "grid",
                    GotoGridFragment.class,
                    GotoGridFragment.createArgs(bookId, chapter_1, verse_1)))); // $NON-NLS-1$

    if (savedInstanceState == null) {
      // get from preferences
      int tabUsed = Preferences.getInt(Prefkey.goto_last_tab, 0);
      if (tabUsed >= 1 && tabUsed <= 3) {
        actionBar.setSelectedNavigationItem(tabUsed - 1 /* to make it 0-based */);
      }
    } else {
      actionBar.setSelectedNavigationItem(savedInstanceState.getInt(INSTANCE_STATE_tab, 0));
    }
  }