Skip to content

Commit

Permalink
Add open-source licenses dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
jkennethcarino committed Sep 17, 2017
1 parent 3414578 commit 2ea5a97
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 3 deletions.
116 changes: 116 additions & 0 deletions app/src/main/assets/licenses.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<html>
<head>
<style>
body {
font-family: sans-serif;
}
pre {
background-color: #eeeeee;
padding: 1em;
white-space: pre-wrap;
}
</style>
</head>
<body>

<ul>
<li>AnkiDroid API</li>
</ul>
<pre>
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser 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 General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with
this program. If not, see &lt;http://www.gnu.org/licenses/&gt;.
</pre>

<ul>
<li>Butter Knife</li>
</ul>
<pre>
Copyright 2013 Jake Wharton

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
</pre>

<ul>
<li>EasyPermissions</li>
</ul>
<pre>
Copyright 2017 Google

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
</pre>

<ul>
<li>RTextEditorView</li>
</ul>
<pre>
Copyright (c) 2017 Jhon Kenneth Cariño

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</pre>

<ul>
<li>Color Picker</li>
</ul>
<pre>
Copyright (C) 2017 Jared Rummler

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
</pre>

</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public boolean onCreateOptionsMenu(Menu menu) {
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();

if (id == R.id.action_settings) {
if (id == R.id.action_open_source_licenses) {
LicensesDialogFragment licensesDialog = new LicensesDialogFragment();
licensesDialog.show(getSupportFragmentManager(), "licenses-dialog");
return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (C) 2017 Jhon Kenneth Cariño
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.jkcarino.ankieditor.ui.editor;

import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog;
import android.webkit.WebView;

import com.jkcarino.ankieditor.R;

public class LicensesDialogFragment extends DialogFragment {

public LicensesDialogFragment() {}

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
WebView webView = new WebView(getActivity());
webView.loadUrl("file:///android_asset/licenses.html");

return new AlertDialog.Builder(getActivity())
.setTitle(R.string.open_source_licenses)
.setView(webView)
.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
}
}
)
.create();
}

@Override
public void show(FragmentManager manager, String tag) {
if (manager.findFragmentByTag(tag) == null) {
super.show(manager, tag);
}
}
}
4 changes: 2 additions & 2 deletions app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.jkcarino.ankieditor.MainActivity">
<item
android:id="@+id/action_settings"
android:id="@+id/action_open_source_licenses"
android:orderInCategory="100"
android:title="@string/action_settings"
android:title="@string/open_source_licenses"
app:showAsAction="never" />
</menu>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<resources>
<string name="app_name">AnkiEditor</string>
<string name="action_settings">Settings</string>
<string name="open_source_licenses">Open-source licenses</string>

<!-- No AnkiDroid Installed -->
<string name="title_no_ankidroid_installed">No AnkiDroid Installed</string>
Expand Down

0 comments on commit 2ea5a97

Please sign in to comment.