@Override public View getView(int position, View convertView, ViewGroup parent) { int type = getItemViewType(position); View res = convertView != null ? convertView : LayoutInflater.from(dialogContext) .inflate( type == 0 ? R.layout.item_label_chooser : android.R.layout.simple_list_item_1, null); if (type == 0) { TextView text1 = V.get(res, android.R.id.text1); Label label = getItem(position); text1.setText(label.title); U.applyLabelColor(label, text1); } else { TextView text1 = V.get(res, android.R.id.text1); text1.setText(context.getString(R.string.create_label_titik3)); // for API 10 or lower, forcefully set text color if (VERSION.SDK_INT <= 10) { text1.setTextColor(0xff000000); } } return res; }
@Override protected void onFinishInflate() { super.onFinishInflate(); cbKind = V.get(this, R.id.cbKind); tCurrentDate = V.get(this, R.id.tCurrentDate); bPrev = V.get(this, R.id.bPrev); bNext = V.get(this, R.id.bNext); bReload = V.get(this, R.id.bReload); cbKind.setAdapter(adapter = new DevotionKindAdapter()); cbKind.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected( final AdapterView<?> parent, final View view, final int position, final long id) { listener.cbKind_itemSelected(adapter.getItem(position)); } @Override public void onNothingSelected(final AdapterView<?> parent) {} }); bPrev.setOnClickListener(v -> listener.bPrev_click()); bNext.setOnClickListener(v -> listener.bNext_click()); bReload.setOnClickListener( v -> { listener.bReload_click(); closeDrawer(); }); }
@Override protected void onFinishInflate() { super.onFinishInflate(); scrollDescription = V.get(this, R.id.scrollDescription); tDescription = V.get(this, R.id.tDescription); bRestart = V.get(this, R.id.bRestart); bRestart.setOnClickListener(v -> listener.bRestart_click()); }
@Override public View getView(int position, View convertView, ViewGroup parent) { View res = convertView != null ? convertView : getLayoutInflater().inflate(R.layout.item_bookmark_filter, null); ImageView imgFilterIcon = V.get(res, R.id.imgFilterIcon); if (position < 3) { imgFilterIcon.setVisibility(View.VISIBLE); imgFilterIcon.setImageResource( position == 0 ? R.drawable.attribute_type_bookmark : position == 1 ? R.drawable.attribute_type_note : position == 2 ? R.drawable.highlight_color_checked : 0); imgFilterIcon.setBackgroundColor(position == 2 ? 0xffffff00 : 0); } else { imgFilterIcon.setVisibility(View.GONE); } TextView lFilterCaption = V.get(res, R.id.lFilterCaption); if (position < 4) { lFilterCaption.setVisibility(View.VISIBLE); lFilterCaption.setText(presetCaptions[position]); } else { lFilterCaption.setVisibility(View.GONE); } TextView lFilterLabel = V.get(res, R.id.lFilterLabel); if (position < 4) { lFilterLabel.setVisibility(View.GONE); } else { Label label = getItem(position); lFilterLabel.setVisibility(View.VISIBLE); lFilterLabel.setText(label.title); U.applyLabelColor(label, lFilterLabel); } View drag_handle = V.get(res, R.id.drag_handle); if (position < 4) { drag_handle.setVisibility(View.GONE); } else { drag_handle.setVisibility(View.VISIBLE); } return res; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_font_manager); setTitle(R.string.fm_activity_title); lsFont = V.get(this, R.id.lsFont); lEmptyError = V.get(this, R.id.lEmptyError); lsFont.setAdapter(adapter = new FontAdapter()); lsFont.setEmptyView(lEmptyError); bindService( new Intent(App.context, DownloadService.class), serviceConnection, BIND_AUTO_CREATE); }
@Override protected void onCreate(Bundle savedInstanceState) { enableNonToolbarUpButton(); super.onCreate(savedInstanceState); setContentView(R.layout.activity_share); String title = getIntent().getStringExtra(Intent.EXTRA_TITLE); setTitle(title); final Intent intent = getIntent().getParcelableExtra(Intent.EXTRA_INTENT); final Intent[] initialIntents = null; final List<ResolveInfo> rList = null; lsIntent = V.get(this, R.id.lsIntent); // fix for memory leak: // https://github.com/square/leakcanary/blob/master/leakcanary-android/src/main/java/com/squareup/leakcanary/AndroidExcludedRefs.java // // UserManager has a static sInstance field that creates an instance and caches it the first // time UserManager.get() is called. This instance is created with the outer context (which // is an activity base context). // Tracked here: https://code.google.com/p/android/issues/detail?id=173789 // Introduced by: https://github.com/android/platform_frameworks_base/commit // /27db46850b708070452c0ce49daf5f79503fbde6 // Fix: trigger a call to UserManager.get() in Application.onCreate(), so that the // UserManager instance gets cached with a reference to the application context. // // This fix: instead of calling this.getPackageManager(), call getPackageManager // using the app context. mPm = getApplicationContext().getPackageManager(); intent.setComponent(null); // show progress dialog so that it does not appear to be hang final MaterialDialog pd = new MaterialDialog.Builder(this) .content(R.string.please_wait_titik3) .cancelable(false) .progress(true, 0) .show(); new AsyncTask<Void, Void, Void>() { @Override public Void doInBackground(Void... params) { mAdapter = new ResolveListAdapter(ShareActivity.this, intent, initialIntents, rList); return null; } @Override protected void onPostExecute(Void result) { lsIntent.setAdapter(mAdapter); pd.dismiss(); } }.execute(); lsIntent.setOnItemClickListener(lsIntent_itemClick); }
@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); } }
@Override public View getView(int position, View convertView, ViewGroup parent) { View res = convertView != null ? convertView : getLayoutInflater().inflate(R.layout.item_font_download, null); UrlImageView imgPreview = V.get(res, R.id.imgPreview); TextView lFontName = V.get(res, R.id.lFontName); View bDownload = V.get(res, R.id.bDownload); View bDelete = V.get(res, R.id.bDelete); ProgressBar progressbar = V.get(res, R.id.progressbar); TextView lErrorMsg = V.get(res, R.id.lErrorMsg); FontItem item = getItem(position); String dlkey = getFontDownloadKey(item.name); lFontName.setText(item.name); lFontName.setVisibility(View.VISIBLE); imgPreview.setTag(R.id.TAG_fontName, lFontName); imgPreview.setOnStateChangeListener(imgPreview_stateChange); imgPreview.setUrl(String.format(URL_fontPreview, item.name)); bDownload.setTag(R.id.TAG_fontItem, item); bDownload.setOnClickListener(bDownload_click); bDelete.setTag(R.id.TAG_fontItem, item); bDelete.setOnClickListener(bDelete_click); if (FontManager.isInstalled(item.name)) { progressbar.setIndeterminate(false); progressbar.setMax(100); progressbar.setProgress(100); bDownload.setVisibility(View.GONE); bDelete.setVisibility(View.VISIBLE); lErrorMsg.setVisibility(View.GONE); } else { DownloadEntry entry = dls.getEntry(dlkey); if (entry == null) { progressbar.setIndeterminate(false); progressbar.setMax(100); progressbar.setProgress(0); bDownload.setVisibility(View.VISIBLE); bDownload.setEnabled(true); bDelete.setVisibility(View.GONE); lErrorMsg.setVisibility(View.GONE); } else { if (entry.state == DownloadService.State.created) { progressbar.setIndeterminate(true); bDownload.setVisibility(View.VISIBLE); bDownload.setEnabled(false); bDelete.setVisibility(View.GONE); lErrorMsg.setVisibility(View.GONE); } else if (entry.state == DownloadService.State.downloading) { if (entry.length == -1) { progressbar.setIndeterminate(true); } else { progressbar.setIndeterminate(false); progressbar.setMax((int) entry.length); progressbar.setProgress((int) entry.progress); } bDownload.setVisibility(View.VISIBLE); bDownload.setEnabled(false); bDelete.setVisibility(View.GONE); lErrorMsg.setVisibility(View.GONE); } else if (entry.state == DownloadService.State.finished) { progressbar.setIndeterminate(false); progressbar.setMax(100); // consider full progressbar.setProgress(100); // consider full bDownload.setVisibility(View.GONE); bDelete.setVisibility(View.VISIBLE); lErrorMsg.setVisibility(View.GONE); } else if (entry.state == DownloadService.State.failed) { progressbar.setIndeterminate(false); progressbar.setMax(100); progressbar.setProgress(0); bDownload.setVisibility(View.VISIBLE); bDownload.setEnabled(true); bDelete.setVisibility(View.GONE); lErrorMsg.setVisibility(View.VISIBLE); lErrorMsg.setText(entry.errorMsg); } } } return res; }
public void show() { final Bookmark2 bookmark = this.ari == 0 ? S.getDb().getBookmarkById(id) : S.getDb().getBookmarkByAri(ari, Db.Bookmark2.kind_bookmark); // set yang belum diset if (this.ari == 0 && bookmark != null) { this.ari = bookmark.ari; this.reference = S.activeVersion.reference(bookmark.ari); } final AlertDialog.Builder builder = new AlertDialog.Builder(context); final Context contextForLayout = Build.VERSION.SDK_INT >= 11 ? builder.getContext() : context; View dialogView = LayoutInflater.from(contextForLayout).inflate(R.layout.dialog_edit_bookmark, null); this.panelLabels = V.get(dialogView, R.id.panelLabels); final EditText tCaption = V.get(dialogView, R.id.tCaption); final Button bAddLabel = V.get(dialogView, R.id.bAddLabel); bAddLabel.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { adapter = new LabelAdapter(); AlertDialog.Builder b = new AlertDialog.Builder(context) .setTitle(R.string.add_label_title) .setAdapter(adapter, bAddLabel_dialog_itemSelected) .setNegativeButton(R.string.cancel, null); if (VERSION.SDK_INT >= 11) { adapter.setDialogContext(Api11.AlertDialog_Builder_getContext(b)); } b.show(); } }); if (bookmark != null) { labels = new TreeSet<Label>(); List<Label> ll = S.getDb().listLabelsByBookmarkId(bookmark._id); if (ll != null) labels.addAll(ll); } setLabelsText(); tCaption.setText(bookmark != null ? bookmark.caption : reference); builder .setView(dialogView) .setTitle(reference) .setIcon(R.drawable.ic_attr_bookmark) .setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Bookmark2 nonfinalBookmark = bookmark; String caption = tCaption.getText().toString(); // If there is no caption, show reference if (caption.length() == 0 || caption.trim().length() == 0) { caption = reference; } if (nonfinalBookmark != null) { nonfinalBookmark.caption = caption; nonfinalBookmark.modifyTime = new Date(); S.getDb().updateBookmark(nonfinalBookmark); } else { nonfinalBookmark = S.getDb() .insertBookmark( ari, Db.Bookmark2.kind_bookmark, caption, new Date(), new Date()); } if (nonfinalBookmark != null) { S.getDb().updateLabels(nonfinalBookmark, labels); } if (listener != null) listener.onOk(); } }) .setNegativeButton(R.string.cancel, null) .show(); }
@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)); } } }
@Override protected void onFinishInflate() { super.onFinishInflate(); setClickable(true); for (int i = 0, len = getChildCount(); i < len; i++) { getChildAt(i).setDuplicateParentStateEnabled(false); } bBible = V.get(this, R.id.bBible); bDevotion = V.get(this, R.id.bDevotion); bReadingPlan = V.get(this, R.id.bReadingPlan); bSongs = V.get(this, R.id.bSongs); bSettings = V.get(this, R.id.bSettings); bHelp = V.get(this, R.id.bHelp); final int selectedTextColor = getResources().getColor(R.color.accent); if (this instanceof Text) bBible.setTextColor(selectedTextColor); if (this instanceof Devotion) bDevotion.setTextColor(selectedTextColor); if (this instanceof ReadingPlan) bReadingPlan.setTextColor(selectedTextColor); if (this instanceof Songs) bSongs.setTextColor(selectedTextColor); // hide and show according to app config if (!isInEditMode()) { bSongs.setVisibility(AppConfig.get().menuSongs ? VISIBLE : GONE); bDevotion.setVisibility(AppConfig.get().menuDevotion ? VISIBLE : GONE); } bBible.setOnClickListener( v -> { bBible_click(); closeDrawer(); }); bDevotion.setOnClickListener( v -> { bDevotion_click(); closeDrawer(); }); bReadingPlan.setOnClickListener( v -> { bReadingPlan_click(); closeDrawer(); }); bSongs.setOnClickListener( v -> { bSongs_click(); closeDrawer(); }); bSettings.setOnClickListener( v -> { bSettings_click(); closeDrawer(); }); bHelp.setOnClickListener( v -> { bHelp_click(); closeDrawer(); }); }
@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); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_bookmark); setTitle(R.string.judul_bukmak_activity); adapter = new BookmarkFilterAdapter(); adapter.reload(); lv = V.get(this, android.R.id.list); lv.setDropListener(adapter); lv.setOnItemClickListener(lv_click); lv.setAdapter(adapter); BookmarkFilterController c = new BookmarkFilterController(lv, adapter); lv.setFloatViewManager(c); lv.setOnTouchListener(c); registerForContextMenu(lv); Intent intent = getIntent(); if (U.equals(intent.getAction(), Intent.ACTION_VIEW)) { Uri data = intent.getData(); if (data != null && (U.equals(data.getScheme(), "content") || U.equals(data.getScheme(), "file"))) { // $NON-NLS-1$ //$NON-NLS-2$ try { final InputStream inputStream = getContentResolver().openInputStream(data); final AlertDialog[] dialog = {null}; dialog[0] = new AlertDialog.Builder(BookmarkActivity.this) .setMessage(R.string.apakah_anda_mau_menumpuk_pembatas_buku_dan_catatan_tanya) .setNegativeButton(R.string.cancel, null) .setNeutralButton( R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog_, int which) { dialog[0].setOnDismissListener(null); importBookmarks(inputStream, false, true); } }) .setPositiveButton( R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog_, int which) { dialog[0].setOnDismissListener(null); importBookmarks(inputStream, true, true); } }) .show(); dialog[0].setOnDismissListener(finishActivityListener); } catch (FileNotFoundException e) { msgbox(getString(R.string.bl_file_not_found_filename, data.toString())) .setOnDismissListener(finishActivityListener); } } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_help); webview = V.get(this, R.id.webView); bOk = V.get(this, R.id.bOk); bCancel = V.get(this, R.id.bCancel); View panelFaqOnly = V.get(this, R.id.panelFaqOnly); TextView tMessage = V.get(this, R.id.tMessage); WebSettings webSettings = webview.getSettings(); webSettings.setSavePassword(false); webSettings.setSaveFormData(false); webSettings.setJavaScriptEnabled(false); webSettings.setSupportZoom(true); webSettings.setBuiltInZoomControls(true); bOk.setOnClickListener(bOk_click); bCancel.setOnClickListener(bCancel_click); final String page = getIntent().getStringExtra(EXTRA_page); okIntent = getIntent().getParcelableExtra(EXTRA_okIntent); String message = getIntent().getStringExtra(EXTRA_message); tMessage.setText(message); final boolean showMessagePanel = getIntent().getBooleanExtra(EXTRA_showMessagePanel, false); if (!showMessagePanel) { panelFaqOnly.setVisibility(View.GONE); } if (page != null) { webview.loadUrl("file:///android_asset/" + page); } webview.setWebViewClient( new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { final Uri uri = Uri.parse(url); final String scheme = uri.getScheme(); if ("http".equals(scheme) || "https".equals(scheme)) { // open in external browser final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(uri); startActivity(intent); return true; } if ("bible".equals(scheme)) { // try to decode using OSIS format final String ssp = uri.getSchemeSpecificPart(); final IntArrayList ariRanges = TargetDecoder.decode("o:" + ssp); if (ariRanges == null || ariRanges.size() == 0) { new AlertDialog.Builder(HelpActivity.this) .setMessage(getString(R.string.alamat_tidak_sah_alamat, url)) .setPositiveButton(R.string.ok, null) .show(); } else { final VersesDialog dialog = VersesDialog.newInstance(ariRanges); dialog.show(getSupportFragmentManager(), VersesDialog.class.getSimpleName()); dialog.setListener( new VersesDialog.VersesDialogListener() { @Override public void onVerseSelected(final VersesDialog dialog, final int ari) { Log.d(TAG, "Verse link clicked from page"); final Intent intent = Launcher.openAppAtBibleLocation(ari); startActivity(intent); } }); } return true; } return false; } @Override public void onPageFinished(final WebView view, final String url) { super.onPageFinished(view, url); setTitle(view.getTitle()); } }); }