added license view

Signed-off-by: nuclearfog <hatespirit666@gmail.com>
This commit is contained in:
nuclearfog 2021-10-01 19:30:08 +02:00
parent 58ddc2eddd
commit 01a2a4a637
No known key found for this signature in database
GPG Key ID: AA0271FBE406DB98
8 changed files with 145 additions and 10 deletions

View File

@ -55,6 +55,7 @@ dependencies {
implementation 'org.twitter4j:twitter4j-core:4.0.7'
//noinspection GradleDependency
implementation 'com.squareup.picasso:picasso:2.8'
implementation 'com.larswerkman:LicenseView:1.1'
implementation 'com.github.open-android:Picasso-transformations:0.1.0'
implementation 'com.github.QuadFlask:colorpicker:0.0.15'
implementation 'com.github.nuclearfog:ZoomView:1.0.2'

View File

@ -1,5 +1,12 @@
package org.nuclearfog.twidda.activity;
import static android.os.AsyncTask.Status.RUNNING;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static org.nuclearfog.twidda.activity.MainActivity.RETURN_APP_LOGOUT;
import static org.nuclearfog.twidda.activity.MainActivity.RETURN_DB_CLEARED;
import static org.nuclearfog.twidda.dialog.ConfirmDialog.DialogType;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
@ -44,17 +51,11 @@ import org.nuclearfog.twidda.database.GlobalSettings;
import org.nuclearfog.twidda.dialog.ConfirmDialog;
import org.nuclearfog.twidda.dialog.ConfirmDialog.OnConfirmListener;
import org.nuclearfog.twidda.dialog.InfoDialog;
import org.nuclearfog.twidda.dialog.LicenseDialog;
import java.util.List;
import java.util.regex.Matcher;
import static android.os.AsyncTask.Status.RUNNING;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static org.nuclearfog.twidda.activity.MainActivity.RETURN_APP_LOGOUT;
import static org.nuclearfog.twidda.activity.MainActivity.RETURN_DB_CLEARED;
import static org.nuclearfog.twidda.dialog.ConfirmDialog.DialogType;
/**
* Settings Activity class.
*
@ -68,7 +69,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
private LocationAdapter locationAdapter;
private FontAdapter fontAdapter;
private Dialog connectDialog, databaseDialog, logoutDialog, color_dialog_selector, appInfo;
private Dialog connectDialog, databaseDialog, logoutDialog, color_dialog_selector, appInfo, license;
private View root, layout_hq_image, layout_key, layout_proxy, layout_auth_en, layout_auth;
private EditText proxyAddr, proxyPort, proxyUser, proxyPass, api_key1, api_key2;
private CompoundButton enableProxy, enableAuth, hqImage, enableAPI;
@ -156,6 +157,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
fontSpinner.setSelected(false);
AppStyles.setTheme(settings, root);
AppStyles.setOverflowIcon(toolbar, settings.getIconColor());
if (!settings.isLoggedIn()) {
trend_card.setVisibility(GONE);
@ -198,6 +200,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
databaseDialog = new ConfirmDialog(this, DialogType.DEL_DATABASE, this);
logoutDialog = new ConfirmDialog(this, DialogType.APP_LOG_OUT, this);
appInfo = new InfoDialog(this);
license = new LicenseDialog(this);
for (Button button : colorButtons)
button.setOnClickListener(this);
@ -261,6 +264,10 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
if (!appInfo.isShowing()) {
appInfo.show();
}
} else if (item.getItemId() == R.id.settings_licenses) {
if (!license.isShowing()) {
license.show();
}
}
return super.onOptionsItemSelected(item);
}

View File

@ -0,0 +1,30 @@
package org.nuclearfog.twidda.dialog;
import android.app.Dialog;
import android.content.Context;
import com.larswerkman.licenseview.LicenseView;
import org.nuclearfog.twidda.R;
/**
* Dialog class to show 3rd party licenses
*
* @author nuclearfog
*/
public class LicenseDialog extends Dialog {
/**
*
*/
public LicenseDialog(Context context) {
super(context, R.style.AppInfoDialog);
setContentView(R.layout.dialog_licenses);
LicenseView licenseView = findViewById(R.id.license_view);
try {
licenseView.setLicenses(R.xml.licenses);
} catch (Exception err) {
dismiss();
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<com.larswerkman.licenseview.LicenseView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/license_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.larswerkman.licenseview.LicenseView>

View File

@ -4,8 +4,12 @@
<item
android:id="@+id/settings_info"
android:icon="@drawable/info"
android:title="@string/menu_app_info"
app:showAsAction="always" />
app:showAsAction="never" />
<item
android:id="@+id/settings_licenses"
android:title="@string/menu_licenses"
app:showAsAction="never" />
</menu>

View File

@ -215,4 +215,5 @@
<string name="menu_refresh_exclude">Filterliste aktualisieren</string>
<string name="info_refreshing_exclude_list">aktualisiere Filterliste</string>
<string name="info_exclude_list_updated">Filterliste aktualisiert!</string>
<string name="menu_licenses">Lizenzen</string>
</resources>

View File

@ -205,6 +205,7 @@
<string name="menu_follow_user">follow</string>
<string name="menu_goto_lists">Userlists</string>
<string name="menu_app_info">About</string>
<string name="menu_licenses">Licenses</string>
<string name="menu_block_user">block</string>
<string name="menu_unmute_user">unmute</string>
<string name="menu_follow_requested">follow requested</string>

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<licenses>
<license
name="Twitter4J"
title="dd"
type="library">
Copyright 2007 Yusuke Yamamoto 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 https://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.
</license>
<license
name="Picasso"
type="library">
Copyright 2013 Square, Inc. 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 https://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.
</license>
<license
name="Picasso transformations"
type="library">
Copyright (C) 2020 Wasabeef 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 https://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.
</license>
<license
name="Colorpicker"
type="library">
Copyright 2014-2017 QuadFlask 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 https://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.
</license>
<license
name="SwitchButton"
type="library">
Copyright kyleduo 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 https://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.
</license>
<license
name="Android-Link-Preview"
type="library">
Copyright 2013 Leonardo Cardoso 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 https://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.
</license>
<license
name="LicenseView"
type="library">
Copyright 2013 Lars Werkman 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 https://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.
</license>
</licenses>