Version up: 1.3.22
[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 as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18
19 package com.owncloud.android.ui.dialog;
20
21 import java.io.InputStream;
22 import java.util.Scanner;
23
24 import android.app.AlertDialog;
25 import android.app.Dialog;
26 import android.content.DialogInterface;
27 import android.net.Uri;
28 import android.os.Bundle;
29 import android.view.LayoutInflater;
30 import android.view.View;
31 import android.webkit.WebView;
32 import android.widget.TextView;
33
34 import com.actionbarsherlock.app.SherlockDialogFragment;
35 import com.owncloud.android.R;
36
37 /**
38 * Dialog to show the contents of res/raw/CHANGELOG.txt
39 */
40 public class ChangelogDialog extends SherlockDialogFragment {
41
42 private static final String ARG_CANCELABLE = ChangelogDialog.class.getCanonicalName() + ".ARG_CANCELABLE";
43
44
45 /**
46 * Public factory method to get dialog instances.
47 *
48 * @param cancelable If 'true', the dialog can be cancelled by the user input (BACK button, touch outside...)
49 * @return New dialog instance, ready to show.
50 */
51 public static ChangelogDialog newInstance(boolean cancelable) {
52 ChangelogDialog fragment = new ChangelogDialog();
53 Bundle args = new Bundle();
54 args.putBoolean(ARG_CANCELABLE, cancelable);
55 fragment.setArguments(args);
56 return fragment;
57 }
58
59
60 /**
61 * {@inheritDoc}
62 */
63 @Override
64 public Dialog onCreateDialog(Bundle savedInstanceState) {
65 /// load the custom view to insert in the dialog, between title and
66 WebView webview = new WebView(getActivity());
67 webview.loadUrl("file:///android_res/raw/" + getResources().getResourceEntryName(R.raw.changelog) + ".html");
68
69 /// build the dialog
70 AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
71
72 Dialog dialog = builder.setView(webview)
73 .setIcon(R.drawable.icon)
74 //.setTitle(R.string.whats_new)
75 .setPositiveButton(R.string.common_ok,
76 new DialogInterface.OnClickListener() {
77 @Override
78 public void onClick(DialogInterface dialog, int which) {
79 dialog.dismiss();
80 }
81 }).create();
82
83 dialog.setCancelable(getArguments().getBoolean(ARG_CANCELABLE));
84 return dialog;
85 }
86
87 /**
88 * {@inheritDoc}
89 *-/
90 @Override
91 public View onCreateView(LayoutInflater inflater, ViewGroup container, 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