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