Welcome to mirror list, hosted at ThFree Co, Russian Federation.

VersionInfoDialogFragment.java « owncloudnewsreader « luhmer « de « java « main « src « News-Android-App - github.com/nextcloud/news-android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 28687eaa115e6628878a7cb90043aba8404311fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* Android ownCloud News
*
* @author David Luhmer
* @copyright 2013 David Luhmer david-dev@live.de
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/

package de.luhmer.owncloudnewsreader;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.pm.PackageInfo;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager.LayoutParams;
import android.widget.TextView;

import com.actionbarsherlock.app.SherlockDialogFragment;

import it.gmariotti.changelibs.library.view.ChangeLogListView;

/**
 * Activity which displays a login screen to the user, offering registration as
 * well.
 */
public class VersionInfoDialogFragment extends SherlockDialogFragment {

	@SuppressLint("SetJavaScriptEnabled")
	@Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Build the dialog and set up the button click handlers
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        LayoutInflater inflater = getActivity().getLayoutInflater();
        final View view = inflater.inflate(R.layout.dialog_version_info, null);
        builder.setView(view).setTitle(getString(R.string.menu_About_Changelog));

        try {
            PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
            String version = pInfo.versionName;
            ((TextView)view.findViewById(R.id.tv_androidAppVersion)).setText("You're using Version " + version);


            ChangeLogListView clListView = (ChangeLogListView) view.findViewById(R.id.changelog_listview);
            clListView.setCallback(new ChangeLogListView.FinishedLoadingCallback() {
                @Override
                public void FinishedLoading() {
                     view.findViewById(R.id.changeLogLoadingProgressBar).setVisibility(View.GONE);
                }
            });

        } catch (Exception ex) {
            ex.printStackTrace();
        }

        return builder.create();
    }

	/* (non-Javadoc)
	 * @see android.support.v4.app.DialogFragment#onStart()
	 */
	@TargetApi(Build.VERSION_CODES.FROYO)
	@Override
	public void onStart() {
		//Use the full screen for this dialog even in Landscape Mode.
		LayoutParams params = getDialog().getWindow().getAttributes();
        if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.ECLAIR_MR1)
        	params.width = LayoutParams.FILL_PARENT;
        else
        	params.width = LayoutParams.MATCH_PARENT;
        
        getDialog().getWindow().setAttributes(params);
        
		super.onStart();
	}
}