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