diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5467b30 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libs/pfa-core"] + path = libs/pfa-core + url = https://github.com/SecUSo/pfa-core diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml deleted file mode 100644 index 7b9f40e..0000000 --- a/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/AboutActivity.kt b/app/src/main/java/org/secuso/privacyfriendlyexample/ui/AboutActivity.kt deleted file mode 100644 index fffb34e..0000000 --- a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/AboutActivity.kt +++ /dev/null @@ -1,51 +0,0 @@ -/* - This file is part of Privacy Friendly App Example. - - Privacy Friendly App Example 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 any later version. - - Privacy Friendly App Example 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 Privacy Friendly App Example. If not, see . - */ -package org.secuso.privacyfriendlyexample.ui - -import android.os.Bundle -import androidx.appcompat.app.AppCompatActivity -import android.text.method.LinkMovementMethod - -import org.secuso.privacyfriendlyexample.BuildConfig -import org.secuso.privacyfriendlyexample.R -import org.secuso.privacyfriendlyexample.databinding.ActivityAboutBinding - -/** - * This activity manages the AboutPage. - * @author Christopher Beckmann (Kamuno), Karola Marky (yonjuni) - * Created on 15.06.16. - */ -class AboutActivity : AppCompatActivity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - val binding = ActivityAboutBinding.inflate(layoutInflater) - setContentView(binding.root) - - supportActionBar?.setDisplayHomeAsUpEnabled(true) - - binding.mainContent.alpha = 0f - binding.mainContent.animate().alpha(1f).duration = BaseActivity.MAIN_CONTENT_FADEIN_DURATION.toLong() - - overridePendingTransition(0, 0) - - binding.secusoWebsite.movementMethod = LinkMovementMethod.getInstance() - binding.githubURL.movementMethod = LinkMovementMethod.getInstance() - binding.textFieldVersion.text = getString(R.string.version_number, BuildConfig.VERSION_NAME) - } -} - diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt b/app/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt deleted file mode 100644 index 35a4947..0000000 --- a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/BaseActivity.kt +++ /dev/null @@ -1,203 +0,0 @@ -/* - This file is part of Privacy Friendly App Example. - - Privacy Friendly App Example 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 any later version. - - Privacy Friendly App Example 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 Privacy Friendly App Example. If not, see . - */ -package org.secuso.privacyfriendlyexample.ui - -import android.content.Intent -import android.content.SharedPreferences -import android.os.Build -import android.os.Bundle -import android.os.Handler -import android.preference.PreferenceActivity -import android.preference.PreferenceManager -import com.google.android.material.navigation.NavigationView -import com.google.android.material.navigation.NavigationView.OnNavigationItemSelectedListener -import androidx.core.app.TaskStackBuilder -import androidx.core.view.GravityCompat -import androidx.drawerlayout.widget.DrawerLayout -import androidx.appcompat.app.ActionBarDrawerToggle -import androidx.appcompat.app.AppCompatActivity -import androidx.appcompat.widget.Toolbar -import android.view.MenuItem -import android.view.View - -import org.secuso.privacyfriendlyexample.R - -/** - * This class is a parent class of all activities that can be accessed from the - * Navigation Drawer (example see MainActivity.java) - * - * The default NavigationDrawer functionality is implemented in this class. If you wish to inherit - * the default behaviour, make sure the content view has a NavigationDrawer with the id 'nav_view', - * the header should point to 'nav_header_main' and the menu should be loaded from 'main_drawer'. - * - * Also the main layout that holds the content of the activity should have the id 'main_content'. - * This way it will automatically fade in and out every time a transition is happening. - * - * @author Christopher Beckmann (Kamuno), Karola Marky (yonjuni) - * @version 20161225 - */ -abstract class BaseActivity : AppCompatActivity(), OnNavigationItemSelectedListener { - companion object { - // delay to launch nav drawer item, to allow close animation to play - internal const val NAVDRAWER_LAUNCH_DELAY = 250 - // fade in and fade out durations for the main content when switching between - // different Activities of the app through the Nav Drawer - internal const val MAIN_CONTENT_FADEOUT_DURATION = 150 - internal const val MAIN_CONTENT_FADEIN_DURATION = 250 - } - - // Navigation drawer: - private var mDrawerLayout: DrawerLayout? = null - private var mNavigationView: NavigationView? = null - - // Helper - private val mHandler: Handler = Handler() - protected val mSharedPreferences: SharedPreferences by lazy { PreferenceManager.getDefaultSharedPreferences(this) } - - protected abstract val navigationDrawerID: Int - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - overridePendingTransition(0, 0) - } - - override fun onBackPressed() { - val drawer = findViewById(R.id.drawer_layout) as DrawerLayout - if (drawer.isDrawerOpen(GravityCompat.START)) { - drawer.closeDrawer(GravityCompat.START) - } else { - super.onBackPressed() - } - } - - override fun onNavigationItemSelected(item: MenuItem): Boolean = goToNavigationItem(item.itemId) - - protected fun goToNavigationItem(itemId: Int): Boolean { - if (itemId == navigationDrawerID) { - // just close drawer because we are already in this activity - mDrawerLayout?.closeDrawer(GravityCompat.START) - return true - } - - // delay transition so the drawer can close - mHandler.postDelayed({ callDrawerItem(itemId) }, NAVDRAWER_LAUNCH_DELAY.toLong()) - - mDrawerLayout?.closeDrawer(GravityCompat.START) - - selectNavigationItem(itemId) - - // fade out the active activity - val mainContent = findViewById(R.id.main_content) - mainContent?.animate()!!.alpha(0f).duration = MAIN_CONTENT_FADEOUT_DURATION.toLong() - return true - } - - // set active navigation item - private fun selectNavigationItem(itemId: Int) { - mNavigationView ?: return - - for (i in 0 until mNavigationView!!.menu.size()) { - val b = itemId == mNavigationView!!.menu.getItem(i).itemId - mNavigationView!!.menu.getItem(i).isChecked = b - } - } - - /** - * Enables back navigation for activities that are launched from the NavBar. See - * `AndroidManifest.xml` to find out the parent activity names for each activity. - * @param intent - */ - private fun createBackStack(intent: Intent) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - val builder = TaskStackBuilder.create(this) - builder.addNextIntentWithParentStack(intent) - builder.startActivities() - } else { - startActivity(intent) - finish() - } - } - - /** - * This method manages the behaviour of the navigation drawer - * Add your menu items (ids) to res/menu/main_drawer.xmlparam itemId Item that has been clicked by the user - */ - private fun callDrawerItem(itemId: Int) { - - val intent: Intent - - when (itemId) { - R.id.nav_example -> { - intent = Intent(this, MainActivity::class.java).apply { - flags = Intent.FLAG_ACTIVITY_CLEAR_TOP - } - startActivity(intent) - } - R.id.nav_game -> { - intent = Intent(this, GameActivity::class.java) - createBackStack(intent) - } - R.id.nav_about -> { - intent = Intent(this, AboutActivity::class.java) - createBackStack(intent) - } - R.id.nav_help -> { - intent = Intent(this, HelpActivity::class.java) - createBackStack(intent) - } - R.id.nav_tutorial -> { - intent = Intent(this, TutorialActivity::class.java).apply { - flags = Intent.FLAG_ACTIVITY_CLEAR_TOP - } - startActivity(intent) - } - R.id.nav_settings -> { - intent = Intent(this, SettingsActivity::class.java) - intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.GeneralPreferenceFragment::class.java.name) - intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true) - createBackStack(intent) - } - } - } - - override fun onPostCreate(savedInstanceState: Bundle?) { - super.onPostCreate(savedInstanceState) - - val toolbar = findViewById(R.id.toolbar) as Toolbar - if (supportActionBar == null) { - setSupportActionBar(toolbar) - } - - mDrawerLayout = findViewById(R.id.drawer_layout) as DrawerLayout - val toggle = ActionBarDrawerToggle( - this, mDrawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) - mDrawerLayout!!.addDrawerListener(toggle) - toggle.syncState() - - mNavigationView = findViewById(R.id.nav_view) as NavigationView - mNavigationView!!.setNavigationItemSelectedListener(this) - - selectNavigationItem(navigationDrawerID) - - val mainContent = findViewById(R.id.main_content) - if (mainContent != null) { - mainContent.alpha = 0f - mainContent.animate().alpha(1f).duration = MAIN_CONTENT_FADEIN_DURATION.toLong() - } - } -} diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/HelpActivity.kt b/app/src/main/java/org/secuso/privacyfriendlyexample/ui/HelpActivity.kt deleted file mode 100644 index c1c4136..0000000 --- a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/HelpActivity.kt +++ /dev/null @@ -1,64 +0,0 @@ -/* - This file is part of Privacy Friendly App Example. - - Privacy Friendly App Example 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 any later version. - - Privacy Friendly App Example 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 Privacy Friendly App Example. If not, see . - */ -package org.secuso.privacyfriendlyexample.ui - -import android.os.Bundle - -import org.secuso.privacyfriendlyexample.R -import org.secuso.privacyfriendlyexample.databinding.ActivityHelpBinding - -import org.secuso.privacyfriendlyexample.ui.adapter.ExpandableListAdapter -import java.util.* -import kotlin.collections.LinkedHashMap - - -/** - * Class structure taken from tutorial at http://www.journaldev.com/9942/android-expandablelistview-example-tutorial - * last access 27th October 2016 - * @author Christopher Beckmann (Kamuno), Karola Marky (yonjuni) - */ -class HelpActivity : BaseActivity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - val binding = ActivityHelpBinding.inflate(layoutInflater) - setContentView(binding.root) - - val expandableListDetail = buildData() - val expandableListTitleGeneral = expandableListDetail.keys.toList() - - binding.generalExpandableListView.setAdapter(ExpandableListAdapter(this, expandableListTitleGeneral, expandableListDetail)) - - overridePendingTransition(0, 0) - } - - /** - * ID of the menu item it belongs to - */ - override val navigationDrawerID: Int = R.id.nav_help - - private fun buildData(): LinkedHashMap> { - val expandableListDetail = LinkedHashMap>() - - expandableListDetail[getString(R.string.help_whatis)] = Collections.singletonList(getString(R.string.help_whatis_answer)) - expandableListDetail[getString(R.string.help_feature_one)] = Collections.singletonList(getString(R.string.help_feature_one_answer)) - expandableListDetail[getString(R.string.help_privacy)] = Collections.singletonList(getString(R.string.help_privacy_answer)) - expandableListDetail[getString(R.string.help_permission)] = Collections.singletonList(getString(R.string.help_permission_answer)) - - return expandableListDetail - } -} diff --git a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/SettingsActivity.java b/app/src/main/java/org/secuso/privacyfriendlyexample/ui/SettingsActivity.java deleted file mode 100644 index 6f088a4..0000000 --- a/app/src/main/java/org/secuso/privacyfriendlyexample/ui/SettingsActivity.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - This file is part of Privacy Friendly App Example. - - Privacy Friendly App Example 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 any later version. - - Privacy Friendly App Example 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 Privacy Friendly App Example. If not, see . - */ -package org.secuso.privacyfriendlyexample.ui; - - -import android.annotation.TargetApi; -import android.content.Context; -import android.content.Intent; -import android.content.res.Configuration; -import android.os.Build; -import android.os.Bundle; -import android.preference.ListPreference; -import android.preference.Preference; -import android.preference.PreferenceActivity; -import android.preference.PreferenceFragment; -import android.preference.PreferenceManager; -import android.view.MenuItem; - -import org.secuso.privacyfriendlyexample.R; - -/** - * A {@link PreferenceActivity} that presents a set of application settings. On - * handset devices, settings are presented as a single list. On tablets, - * settings are split by category, with category headers shown to the left of - * the list of settings. - *

- * See - * Android Design: Settings for design guidelines and the Settings - * API Guide for more information on developing a Settings UI. - */ -public class SettingsActivity extends BaseActivity { - /** - * A preference value change listener that updates the preference's summary - * to reflect its new value. - */ - private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object value) { - String stringValue = value.toString(); - - if (preference instanceof ListPreference) { - // For list preferences, look up the correct display value in - // the preference's 'entries' list. - ListPreference listPreference = (ListPreference) preference; - int index = listPreference.findIndexOfValue(stringValue); - - // Set the summary to reflect the new value. - preference.setSummary( - index >= 0 - ? listPreference.getEntries()[index] - : null); - } else { - // For all other preferences, set the summary to the value's - // simple string representation. - preference.setSummary(stringValue); - } - return true; - } - }; - - /** - * Helper method to determine if the device has an extra-large screen. For - * example, 10" tablets are extra-large. - */ - private static boolean isXLargeTablet(Context context) { - return (context.getResources().getConfiguration().screenLayout - & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE; - } - - /** - * Binds a preference's summary to its value. More specifically, when the - * preference's value is changed, its summary (line of text below the - * preference title) is updated to reflect the value. The summary is also - * immediately updated upon calling this method. The exact display format is - * dependent on the type of preference. - * - * @see #sBindPreferenceSummaryToValueListener - */ - private static void bindPreferenceSummaryToValue(Preference preference) { - // Set the listener to watch for value changes. - preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); - - // Trigger the listener immediately with the preference's - // current value. - sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, - PreferenceManager - .getDefaultSharedPreferences(preference.getContext()) - .getString(preference.getKey(), "")); - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setContentView(R.layout.activity_settings); - - //setupActionBar(); - - - overridePendingTransition(0, 0); - } - - @Override - protected int getNavigationDrawerID() { - return R.id.nav_settings; - } - - /** - * Set up the {@link android.app.ActionBar}, if the API is available. - */ - /*private void setupActionBar() { - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - // Show the Up button in the action bar. - actionBar.setDisplayHomeAsUpEnabled(true); - } - }*/ - - /*@Override - public boolean onMenuItemSelected(int featureId, MenuItem item) { - int id = item.getItemId(); - if (id == android.R.id.home) { - //finish(); - Intent intent = new Intent(this, MainActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); - finish(); - return true; - - // (!super.onMenuItemSelected(featureId, item)) { - // NavUtils.navigateUpFromSameTask(this); - //} - //return true; - } - return super.onMenuItemSelected(featureId, item); - }*/ - - /** - * {@inheritDoc} - */ - /*@Override - public boolean onIsMultiPane() { - return isXLargeTablet(this); - }*/ - - /** - * {@inheritDoc} - */ - /*@Override - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - public void onBuildHeaders(List

target) { - loadHeadersFromResource(R.xml.pref_headers, target); - }*/ - - /** - * This method stops fragment injection in malicious applications. - * Make sure to deny any unknown fragments here. - */ - protected boolean isValidFragment(String fragmentName) { - return PreferenceFragment.class.getName().equals(fragmentName) - || GeneralPreferenceFragment.class.getName().equals(fragmentName); - } - - /** - * This fragment shows general preferences only. It is used when the - * activity is showing a two-pane settings UI. - * The commented method bindPrefenceSummaryToValue should be added for all preferences - * with a summary that is depended from the current value of the preference - */ - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - public static class GeneralPreferenceFragment extends PreferenceFragment { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.pref_general); - //setHasOptionsMenu(true); - - // Bind the summaries of EditText/List/Dialog/Ringtone preferences - // to their values. When their values change, their summaries are - // updated to reflect the new value, per the Android Design - // guidelines. - //bindPreferenceSummaryToValue(findPreference("example_text")); - //bindPreferenceSummaryToValue(findPreference("example_list")); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - int id = item.getItemId(); - if (id == android.R.id.home) { - //getActivity().finish(); - startActivity(new Intent(getActivity(), SettingsActivity.class)); - return true; - } - return super.onOptionsItemSelected(item); - } - } -} diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml deleted file mode 100644 index 88fbf26..0000000 --- a/app/src/main/res/layout/activity_about.xml +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about_with_navigationdrawer.xml b/app/src/main/res/layout/activity_about_with_navigationdrawer.xml deleted file mode 100644 index 4794c53..0000000 --- a/app/src/main/res/layout/activity_about_with_navigationdrawer.xml +++ /dev/null @@ -1,166 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_help.xml b/app/src/main/res/layout/activity_help.xml deleted file mode 100644 index 6ae29e2..0000000 --- a/app/src/main/res/layout/activity_help.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index fbce05d..0000000 --- a/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - -