Skip to content

Commit

Permalink
Adjust T&C popup to include links to T&C and Privacy Policy
Browse files Browse the repository at this point in the history
  • Loading branch information
zafodB committed Aug 27, 2021
1 parent ef7d01c commit 5e370e0
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import dk.aau.netsec.hostage.Hostage;
Expand All @@ -30,7 +37,15 @@ public class AboutFragment extends Fragment {
private ViewGroup container;
private Bundle savedInstanceState;

@SuppressLint("SetTextI18n")
private static final String PRIVACY_POLICY_URL = "https://aau-network-security.github.io/HosTaGe/Privacy_policy.html";
private static final String TERMS_CONDITIONS_URL = "https://aau-network-security.github.io/HosTaGe/terms.html";

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
setHasOptionsMenu(true);
super.onCreate(savedInstanceState);
}

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
super.onCreateView(inflater, container, savedInstanceState);

Expand Down Expand Up @@ -64,6 +79,28 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
return rootView;
}

@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
inflater.inflate(R.menu.privacy_policy_menu, menu);
}

@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == R.id.terms_link_open){
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(TERMS_CONDITIONS_URL));
startActivity(browserIntent);

return true;
} else if (item.getItemId() == R.id.privacy_link_open){
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(PRIVACY_POLICY_URL));
startActivity(browserIntent);

return true;
}

return false;
}


@Override
public void onDestroy() {
Expand Down
19 changes: 19 additions & 0 deletions src/main/res/drawable/ic_menu_book.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M21,5c-1.11,-0.35 -2.33,-0.5 -3.5,-0.5c-1.95,0 -4.05,0.4 -5.5,1.5c-1.45,-1.1 -3.55,-1.5 -5.5,-1.5S2.45,4.9 1,6v14.65c0,0.25 0.25,0.5 0.5,0.5c0.1,0 0.15,-0.05 0.25,-0.05C3.1,20.45 5.05,20 6.5,20c1.95,0 4.05,0.4 5.5,1.5c1.35,-0.85 3.8,-1.5 5.5,-1.5c1.65,0 3.35,0.3 4.75,1.05c0.1,0.05 0.15,0.05 0.25,0.05c0.25,0 0.5,-0.25 0.5,-0.5V6C22.4,5.55 21.75,5.25 21,5zM21,18.5c-1.1,-0.35 -2.3,-0.5 -3.5,-0.5c-1.7,0 -4.15,0.65 -5.5,1.5V8c1.35,-0.85 3.8,-1.5 5.5,-1.5c1.2,0 2.4,0.15 3.5,0.5V18.5z"/>
<path
android:fillColor="@android:color/white"
android:pathData="M17.5,10.5c0.88,0 1.73,0.09 2.5,0.26V9.24C19.21,9.09 18.36,9 17.5,9c-1.7,0 -3.24,0.29 -4.5,0.83v1.66C14.13,10.85 15.7,10.5 17.5,10.5z"/>
<path
android:fillColor="@android:color/white"
android:pathData="M13,12.49v1.66c1.13,-0.64 2.7,-0.99 4.5,-0.99c0.88,0 1.73,0.09 2.5,0.26V11.9c-0.79,-0.15 -1.64,-0.24 -2.5,-0.24C15.8,11.66 14.26,11.96 13,12.49z"/>
<path
android:fillColor="@android:color/white"
android:pathData="M17.5,14.33c-1.7,0 -3.24,0.29 -4.5,0.83v1.66c1.13,-0.64 2.7,-0.99 4.5,-0.99c0.88,0 1.73,0.09 2.5,0.26v-1.52C19.21,14.41 18.36,14.33 17.5,14.33z"/>
</vector>
6 changes: 6 additions & 0 deletions src/main/res/menu/privacy_policy_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/terms_link_open"
android:icon="@drawable/ic_menu_book"
android:title="@string/terms_link_open"
app:showAsAction="always" />

<item
android:id="@+id/privacy_link_open"
android:icon="@drawable/ic_privacy_tip"
Expand Down
3 changes: 2 additions & 1 deletion src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@
<string name="pcap_log_setting_description">PCAP-Protokolle an den unten angegebenen Speicherort schrieben</string>
<string name="pcap_location_setting_description">Speicherort der Protokollausgabe ändern</string>
<string name="pcap_log_rotation_name">Log-Rotationsfrequenz</string>
<string name="policy_link_open">Im Browser öffnen</string>
<string name="policy_link_open">Datenschutzerklärung öffnen</string>
<string name="agree">Akzeptieren</string>
<string name="disagree">Nicht akzeptieren</string>
<string name="terms_link_open">"Geschäftsbedingungen öffnen "</string>
</resources>
3 changes: 2 additions & 1 deletion src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@
<string name="pcap_location_setting_description">Change log output location</string>
<string name="pcap_log_rotation_name">Specify log rotation frequency</string>

<string name="policy_link_open">Open in Browser</string>
<string name="policy_link_open">View Privacy Policy</string>
<string name="terms_link_open">View Terms and Conditions</string>
<string name="pcap_notification">PCAP logging service is running</string>
<string name="pcap_notification_text">This could drain battery faster</string>
<string name="seconds">seconds</string>
Expand Down
2 changes: 1 addition & 1 deletion src/main/res/values/strings_disclaimer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
To use this application, you must agree to <a href="https://aau-network-security.github.io/HosTaGe/terms.html">
Terms and Conditions</a> and <a href="https://aau-network-security.github.io/HosTaGe/Privacy_policy.html">Privacy Policy</a>.
</p><p>
You can always find the Privacy Policy under <i>Privacy Policy</i> in the main menu.
You can always find the Terms and Conditions and Privacy Policy under <i>About</i> in the main menu.
</p>
]]>
</string>
Expand Down

1 comment on commit 5e370e0

@zafodB
Copy link
Collaborator Author

@zafodB zafodB commented on 5e370e0 Aug 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the T&C text from the alert dialog and replace it with links to T&C and Privacy Policy on GitHub Pages.

Add a section that these links can always be found under About section in the menu.

Please sign in to comment.