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