Merge pull request #287 from LukeOwncloud/setup_md
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / dialog / ChangelogDialog.java
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
18 package com.owncloud.android.ui.dialog;
19
20 import android.app.AlertDialog;
21 import android.app.Dialog;
22 import android.content.DialogInterface;
23 import android.os.Bundle;
24 import android.webkit.WebView;
25
26 import com.actionbarsherlock.app.SherlockDialogFragment;
27 import com.owncloud.android.R;
28
29 /**
30 * Dialog to show the contents of res/raw/CHANGELOG.txt
31 */
32 public class ChangelogDialog extends SherlockDialogFragment {
33
34 private static final String ARG_CANCELABLE = ChangelogDialog.class.getCanonicalName() + ".ARG_CANCELABLE";
35
36
37 /**
38 * Public factory method to get dialog instances.
39 *
40 * @param cancelable If 'true', the dialog can be cancelled by the user input (BACK button, touch outside...)
41 * @return New dialog instance, ready to show.
42 */
43 public static ChangelogDialog newInstance(boolean cancelable) {
44 ChangelogDialog fragment = new ChangelogDialog();
45 Bundle args = new Bundle();
46 args.putBoolean(ARG_CANCELABLE, cancelable);
47 fragment.setArguments(args);
48 return fragment;
49 }
50
51
52 /**
53 * {@inheritDoc}
54 */
55 @Override
56 public Dialog onCreateDialog(Bundle savedInstanceState) {
57 /// load the custom view to insert in the dialog, between title and
58 WebView webview = new WebView(getActivity());
59 webview.loadUrl("file:///android_res/raw/" + getResources().getResourceEntryName(R.raw.changelog) + ".html");
60
61 /// build the dialog
62 AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
63
64 Dialog dialog = builder.setView(webview)
65 .setIcon(R.drawable.icon)
66 //.setTitle(R.string.whats_new)
67 .setPositiveButton(R.string.common_ok,
68 new DialogInterface.OnClickListener() {
69 @Override
70 public void onClick(DialogInterface dialog, int which) {
71 dialog.dismiss();
72 }
73 }).create();
74
75 dialog.setCancelable(getArguments().getBoolean(ARG_CANCELABLE));
76 return dialog;
77 }
78
79 /**
80 * {@inheritDoc}
81 *-/
82 @Override
83 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
84 /// load the custom layout
85 View view = inflater.inflate(R.layout.fragment_changelog, container);
86 mEditText = (EditText) view.findViewById(R.id.txt_your_name);
87 getDialog().setTitle(R.string.whats_new);
88
89 /// read full contents of the change log file (don't make it too big)
90 InputStream changeLogStream = getResources().openRawResource(R.raw.changelog);
91 Scanner scanner = new java.util.Scanner(changeLogStream).useDelimiter("\\A");
92 String text = scanner.hasNext() ? scanner.next() : "";
93
94 /// make clickable the links in the change log file
95 SpannableString sText = new SpannableString(text);
96 Linkify.addLinks(sText, Linkify.ALL);
97
98 return view;
99 }
100 */
101 }
102
103