private void loadSettings() { SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); // Now, we're going to check for the Text size variable and set the text // size bibleTextView.setTextSize( Float.parseFloat( appPreferences.getString(getActivity().getString(R.string.text_size_key), "18"))); int color = appPreferences.getInt(getActivity().getString(R.string.text_color_key), Color.BLACK); bibleTextView.setTextColor(color); try { // Set Custom font bibleTextView.setTypeface( Typeface.createFromAsset( getActivity().getAssets(), "fonts/" + appPreferences.getString( getActivity().getString(R.string.text_font_key), "Ubuntu-R.ttf")), Typeface.NORMAL); // this.setTypeface(Typeface.createFromAsset(ctx.getAssets(), "fonts/" + // "Ubuntu-B.ttf"), Typeface.BOLD); } catch (Exception e) { // Custom font not found Log.d(TAG, "Font not found!", e); } }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); BibleTextView bibleTextView = (BibleTextView) getActivity().findViewById(R.id.bible_text); if (bibleTextView != null && bibleTextView.getBibleText() != null) { // Prepare the loader. Either re-connect with an existing one, // or start a new one. Bundle bundle = new Bundle(); bundle.putParcelable("BibleText", bibleTextView.getBibleText()); getLoaderManager().initLoader(0, bundle, this); } notesEditText = ((NotesEditText) getActivity().findViewById(R.id.notes_edit_text)); notesLock = ((ImageButton) getActivity().findViewById(R.id.menu_button_notes_lock)); notesEditText.initialise((notesLock), bibleTextView); bibleTextView.post( new Runnable() { @Override public void run() { loadNotes(); } }); }
private void loadNotes() { BibleTextView bibleTextView = (BibleTextView) getActivity().findViewById(R.id.bible_text); if (bibleTextView != null && bibleTextView.getBibleText() != null) { // Prepare the loader. Either re-connect with an existing one, // or start a new one. Bundle bundle = new Bundle(); bundle.putParcelable("BibleText", bibleTextView.getBibleText()); getLoaderManager().initLoader(0, bundle, this); } }
public int getVerseNumber() { // Set the verseNumber to what is currently being viewed int verseNumber = bibleTextView.yToVerse( bibleScrollView.getScrollY(), getActivity().findViewById(R.id.prev_chapter_button).getHeight()); return verseNumber; }
/** Update bible text with new BibleText TODO: translation is current static */ public void updateBibleTextView(final BibleText bibleText) { if (bibleTextView != null) { loadSettings(); if (!bibleText.equals(bibleTextView.getBibleText())) { bibleTextView.setBibleText(bibleText); // String note = notesService.getNotes(bibleText.getKey()); // if (note != null) { // notesEditText.setText(note); // } else { // notesEditText.setText(""); // } // notesEditText.lock(); // Scroll to the required verse after reload, will be verse 1 if new chapter bibleTextView.post( new Runnable() { public void run() { try { getActivity().dismissDialog(LOADING_DIALOG); } catch (Exception e) { } // sermonBtn.requestFocus(); // only scroll to the verse if this thing is even visible if (getActivity().findViewById(R.id.prev_chapter_button) != null && bibleTextView.isShown() && bibleTextView.getBibleText() != null) { bibleTextView.scrollToVerse( bibleText.getVerse(), getActivity().findViewById(R.id.prev_chapter_button).getHeight()); } // do not give the editbox focus automatically when activity starts bibleTextView.clearFocus(); // grabFocus.requestFocus(); }; }); } } }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); bibleScrollView = (BibleTextScrollView) getActivity().findViewById(R.id.bibleScrollView); // Handler created on UI thread to handle updates to title updateTitleHandler = new Handler() { @Override public void handleMessage(Message msg) { final String verseText = msg.getData().getString("Verse_Text"); ((MainActivity) getActivity()) .updateHeaderText( bibleTextView.getBibleText().getDisplayReferenceBookChapter() + verseText); } }; bibleScrollView.setTitleHandler(updateTitleHandler); bibleTextView = (BibleTextView) getActivity().findViewById(R.id.bible_text); bibleTextView.setBibleSrcollView(bibleScrollView); loadSettings(); // Previous chapter button ((Button) getActivity().findViewById(R.id.prev_chapter_button)) .setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // Start thread to get verse getActivity().showDialog(LOADING_DIALOG); new SwordVerseTask().execute(bibleTextView.getBibleText().getPrevChapterRef()); } }); // Next chapter button ((Button) getActivity().findViewById(R.id.next_chapter_button)) .setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // Start thread to get verse getActivity().showDialog(LOADING_DIALOG); new SwordVerseTask().execute(bibleTextView.getBibleText().getNextChapterRef()); } }); // Go to windows view ((ImageButton) getActivity().findViewById(R.id.menu_button_windows)) .setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), WindowsActivity.class); // Set the verseNumber to what is currently being viewed int verseNumber = bibleTextView.yToVerse( bibleScrollView.getScrollY(), (getActivity().findViewById(R.id.prev_chapter_button)).getHeight()); Log.i("Main", "Set BibleTextView verse number " + verseNumber); bibleTextView.getBibleText().setVerse(verseNumber); Log.i( "Main", "BibleTextView sent " + bibleTextView.getBibleText().getReferenceBookChapterVerse()); // TODO: add string preview from existing rendered text probably just do a // substring of boundaries intent.putExtra("BibleText", bibleTextView.getBibleText()); intent.putExtra("WindowId", ((MainActivity) getActivity()).windowId); startActivityForResult(intent, MainActivity.WINDOW_SELECT_CODE); // overridePendingTransition(R.anim.zoom_enter, 0); } }); // Go to tabs view ((ImageButton) getActivity().findViewById(R.id.menu_button_tabs)) .setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), TabsActivity.class); // Set the verseNumber to what is currently being viewed int verseNumber = bibleTextView.yToVerse( bibleScrollView.getScrollY(), (getActivity().findViewById(R.id.prev_chapter_button)).getHeight()); Log.i("Main", "Set BibleTextView verse number " + verseNumber); bibleTextView.getBibleText().setVerse(verseNumber); Log.i( "Main", "BibleTextView sent " + bibleTextView.getBibleText().getReferenceBookChapterVerse()); // TODO: add string preview from existing rendered text probably just do a // substring of boundaries intent.putExtra("BibleText", bibleTextView.getBibleText()); intent.putExtra("WindowId", ((MainActivity) getActivity()).windowId); startActivityForResult(intent, MainActivity.WINDOW_SELECT_CODE); // overridePendingTransition(R.anim.zoom_enter, 0); } }); if (bibleTextView.getBibleText() == null) { // Load last opened verse String currentBook = getActivity() .getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE) .getString(SharedPreferencesHelper.CURRENT_BOOK, "Philipiians"); String currentChapter = getActivity() .getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE) .getString(SharedPreferencesHelper.CURRENT_CHAPTER, "1"); String currentVerse = getActivity() .getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE) .getString(SharedPreferencesHelper.CURRENT_VERSE, "1"); String currentTranslation = getActivity() .getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE) .getString(SharedPreferencesHelper.CURRENT_TRANSLATION, "ESV"); new SwordInitTask().execute(currentBook, currentChapter, currentVerse, currentTranslation); } // // Give some text to display if there is no data. In a real // // application this would come from a resource. // setEmptyText("No applications"); // // // We have a menu item to show in action bar. // setHasOptionsMenu(true); // // // Only have one choice // getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); // // // Create an empty adapter we will use to display the loaded data. // mAdapter = new AppListAdapter(getActivity()); // setListAdapter(mAdapter); // // // Start out with a progress indicator. // setListShown(false); // Prepare the loader. Either re-connect with an existing one, // or start a new one. getLoaderManager().initLoader(0, null, this); }