mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 14:42:30 +00:00
Merge pull request #390 from lioncash/master
[Android] Separate the GPL waiver code into its own DialogFragment.
This commit is contained in:
commit
0c5f375d8c
@ -27,11 +27,11 @@ import android.widget.Toast;
|
|||||||
import com.retroarch.R;
|
import com.retroarch.R;
|
||||||
import com.retroarch.browser.CoreSelection;
|
import com.retroarch.browser.CoreSelection;
|
||||||
import com.retroarch.browser.HistorySelection;
|
import com.retroarch.browser.HistorySelection;
|
||||||
import com.retroarch.browser.ModuleWrapper;
|
|
||||||
import com.retroarch.browser.NativeInterface;
|
import com.retroarch.browser.NativeInterface;
|
||||||
import com.retroarch.browser.RetroActivity;
|
import com.retroarch.browser.RetroActivity;
|
||||||
import com.retroarch.browser.dirfragment.DirectoryFragment;
|
import com.retroarch.browser.dirfragment.DirectoryFragment;
|
||||||
import com.retroarch.browser.dirfragment.DirectoryFragment.OnDirectoryFragmentClosedListener;
|
import com.retroarch.browser.dirfragment.DirectoryFragment.OnDirectoryFragmentClosedListener;
|
||||||
|
import com.retroarch.browser.mainmenu.gplwaiver.GPLWaiverDialogFragment;
|
||||||
import com.retroarch.browser.preferences.fragments.util.PreferenceListFragment;
|
import com.retroarch.browser.preferences.fragments.util.PreferenceListFragment;
|
||||||
import com.retroarch.browser.preferences.util.UserPreferences;
|
import com.retroarch.browser.preferences.util.UserPreferences;
|
||||||
|
|
||||||
@ -76,41 +76,11 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
|
|||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
showGPLWaiver();
|
// First-run, so we show the GPL waiver agreement dialog.
|
||||||
|
GPLWaiverDialogFragment.newInstance().show(getFragmentManager(), "gplWaiver");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showGPLWaiver()
|
|
||||||
{
|
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity())
|
|
||||||
.setTitle(R.string.gpl_waiver)
|
|
||||||
.setMessage(R.string.gpl_waiver_desc)
|
|
||||||
.setPositiveButton(R.string.keep_cores, null)
|
|
||||||
.setNegativeButton(R.string.remove_cores, new DialogInterface.OnClickListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which)
|
|
||||||
{
|
|
||||||
final File[] libs = new File(getActivity().getApplicationInfo().dataDir, "/cores").listFiles();
|
|
||||||
for (final File lib : libs)
|
|
||||||
{
|
|
||||||
ModuleWrapper module = new ModuleWrapper(getActivity().getApplicationContext(), lib);
|
|
||||||
|
|
||||||
boolean gplv3 = module.getCoreLicense().equals("GPLv3");
|
|
||||||
boolean gplv2 = module.getCoreLicense().equals("GPLv2");
|
|
||||||
|
|
||||||
if (!gplv3 && !gplv2)
|
|
||||||
{
|
|
||||||
String libName = lib.getName();
|
|
||||||
Log.i("GPL WAIVER", "Deleting non-GPL core" + libName + "...");
|
|
||||||
lib.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
alert.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void extractAssets()
|
private void extractAssets()
|
||||||
{
|
{
|
||||||
if (areAssetsExtracted())
|
if (areAssetsExtracted())
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
package com.retroarch.browser.mainmenu.gplwaiver;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import com.retroarch.R;
|
||||||
|
import com.retroarch.browser.ModuleWrapper;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link DialogFragment} responsible for displaying
|
||||||
|
* the GPL waiver dialog on the first-run of this app.
|
||||||
|
*/
|
||||||
|
public final class GPLWaiverDialogFragment extends DialogFragment
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Method for statically instatiating a new
|
||||||
|
* instance of a GPLWaiverDialogFragment.
|
||||||
|
*
|
||||||
|
* @return a new instance of a GPLWaiverDialogFragment.
|
||||||
|
*/
|
||||||
|
public static GPLWaiverDialogFragment newInstance()
|
||||||
|
{
|
||||||
|
return new GPLWaiverDialogFragment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
AlertDialog.Builder gplDialog = new AlertDialog.Builder(getActivity());
|
||||||
|
gplDialog.setTitle(R.string.gpl_waiver);
|
||||||
|
gplDialog.setMessage(R.string.gpl_waiver_desc);
|
||||||
|
gplDialog.setPositiveButton(R.string.keep_cores, null);
|
||||||
|
gplDialog.setNegativeButton(R.string.remove_cores, new DialogInterface.OnClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which)
|
||||||
|
{
|
||||||
|
final File[] libs = new File(getActivity().getApplicationInfo().dataDir, "/cores").listFiles();
|
||||||
|
for (final File lib : libs)
|
||||||
|
{
|
||||||
|
ModuleWrapper module = new ModuleWrapper(getActivity().getApplicationContext(), lib);
|
||||||
|
|
||||||
|
boolean gplv3 = module.getCoreLicense().equals("GPLv3");
|
||||||
|
boolean gplv2 = module.getCoreLicense().equals("GPLv2");
|
||||||
|
|
||||||
|
if (!gplv3 && !gplv2)
|
||||||
|
{
|
||||||
|
String libName = lib.getName();
|
||||||
|
Log.i("GPL WAIVER", "Deleting non-GPL core" + libName + "...");
|
||||||
|
lib.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return gplDialog.create();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user