1 /* ownCloud Android client application
2 * Copyright (C) 2012-2013 ownCloud Inc.
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.
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.
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/>.
18 package com
.owncloud
.android
.ui
.dialog
;
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
;
26 import com
.actionbarsherlock
.app
.SherlockDialogFragment
;
27 import com
.owncloud
.android
.R
;
28 import com
.owncloud
.android
.utils
.DisplayUtils
;
32 * Dialog to show the contents of res/raw/CHANGELOG.txt
34 public class ChangelogDialog
extends SherlockDialogFragment
{
36 private static final String ARG_CANCELABLE
= ChangelogDialog
.class.getCanonicalName() + ".ARG_CANCELABLE";
40 * Public factory method to get dialog instances.
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.
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
);
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");
64 AlertDialog
.Builder builder
= new AlertDialog
.Builder(getActivity());
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() {
72 public void onClick(DialogInterface dialog
, int which
) {
77 dialog
.setCancelable(getArguments().getBoolean(ARG_CANCELABLE
));
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);
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() : "";
96 /// make clickable the links in the change log file
97 SpannableString sText = new SpannableString(text);
98 Linkify.addLinks(sText, Linkify.ALL);