ChangelogDialog.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* ownCloud Android client application
  2. * Copyright (C) 2012-2013 ownCloud Inc.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. package com.owncloud.android.ui.dialog;
  18. import android.app.AlertDialog;
  19. import android.app.Dialog;
  20. import android.content.DialogInterface;
  21. import android.os.Bundle;
  22. import android.webkit.WebView;
  23. import com.actionbarsherlock.app.SherlockDialogFragment;
  24. import com.owncloud.android.R;
  25. /**
  26. * Dialog to show the contents of res/raw/CHANGELOG.txt
  27. */
  28. public class ChangelogDialog extends SherlockDialogFragment {
  29. private static final String ARG_CANCELABLE = ChangelogDialog.class.getCanonicalName() + ".ARG_CANCELABLE";
  30. /**
  31. * Public factory method to get dialog instances.
  32. *
  33. * @param cancelable If 'true', the dialog can be cancelled by the user input (BACK button, touch outside...)
  34. * @return New dialog instance, ready to show.
  35. */
  36. public static ChangelogDialog newInstance(boolean cancelable) {
  37. ChangelogDialog fragment = new ChangelogDialog();
  38. Bundle args = new Bundle();
  39. args.putBoolean(ARG_CANCELABLE, cancelable);
  40. fragment.setArguments(args);
  41. return fragment;
  42. }
  43. /**
  44. * {@inheritDoc}
  45. */
  46. @Override
  47. public Dialog onCreateDialog(Bundle savedInstanceState) {
  48. /// load the custom view to insert in the dialog, between title and
  49. WebView webview = new WebView(getActivity());
  50. webview.loadUrl("file:///android_res/raw/" + getResources().getResourceEntryName(R.raw.changelog) + ".html");
  51. /// build the dialog
  52. AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
  53. Dialog dialog = builder.setView(webview)
  54. .setIcon(R.drawable.icon)
  55. //.setTitle(R.string.whats_new)
  56. .setPositiveButton(R.string.common_ok,
  57. new DialogInterface.OnClickListener() {
  58. @Override
  59. public void onClick(DialogInterface dialog, int which) {
  60. dialog.dismiss();
  61. }
  62. }).create();
  63. dialog.setCancelable(getArguments().getBoolean(ARG_CANCELABLE));
  64. return dialog;
  65. }
  66. /**
  67. * {@inheritDoc}
  68. *-/
  69. @Override
  70. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  71. /// load the custom layout
  72. View view = inflater.inflate(R.layout.fragment_changelog, container);
  73. mEditText = (EditText) view.findViewById(R.id.txt_your_name);
  74. getDialog().setTitle(R.string.whats_new);
  75. /// read full contents of the change log file (don't make it too big)
  76. InputStream changeLogStream = getResources().openRawResource(R.raw.changelog);
  77. Scanner scanner = new java.util.Scanner(changeLogStream).useDelimiter("\\A");
  78. String text = scanner.hasNext() ? scanner.next() : "";
  79. /// make clickable the links in the change log file
  80. SpannableString sText = new SpannableString(text);
  81. Linkify.addLinks(sText, Linkify.ALL);
  82. return view;
  83. }
  84. */
  85. }