/*
* TeleStax, Open Source Cloud Communications
* Copyright 2011-2015, Telestax Inc and individual contributors
* by the @authors tag.
*
* This program is free software: you can redistribute it and/or modify
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This program 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 program. If not, see <http://www.gnu.org/licenses/>
*
* For questions related to commercial use licensing, please contact sales@telestax.com.
*
*/
package org.restcomm.android.olympus;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class AboutFragment extends DialogFragment {
/**
* Create a new instance of MyDialogFragment, providing "num"
* as an argument.
*/
public static AboutFragment newInstance()
{
AboutFragment f = new AboutFragment();
return f;
}
// Override the Fragment.onAttach() method to instantiate the NoticeDialogListener
@Override
public void onAttach(Activity activity)
{
super.onAttach(activity);
}
@Override
public void onDetach()
{
super.onDetach();
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}
// Notice that for this doesn't work if onCreateView has been overriden as described above. To add
// custom view when using alert we need to use builder.setView() as seen below
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
// Get the layout inflater
View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_about, null);
// Update version automatically from gradle file
TextView versionTextView = (TextView)view.findViewById(R.id.textView_version_name);
versionTextView.setText(BuildConfig.APPLICATION_ID + " " + BuildConfig.VERSION_NAME + "#" + BuildConfig.VERSION_CODE);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle);
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(view)
.setTitle("About")
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton)
{
}
}
);
return builder.create();
}
}