Add App Settings Access in Report pages

This commit is contained in:
Schoumi 2019-06-04 11:23:27 +02:00
parent 8491b433f7
commit 1f97fe7688
14 changed files with 72 additions and 11 deletions

6
.gitignore vendored
View File

@ -22,4 +22,10 @@ proguard/
.idea
*.iml
#vim
.*swp
.*swo
.tags
captures/

View File

@ -20,13 +20,17 @@ package org.eu.exodus_privacy.exodusprivacy;
import android.support.v4.app.FragmentManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.databinding.DataBindingUtil;
import android.support.design.widget.Snackbar;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v7.widget.SearchView;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MenuInflater;
import android.view.inputmethod.InputMethodManager;
@ -38,15 +42,19 @@ import org.eu.exodus_privacy.exodusprivacy.listener.NetworkListener;
public class MainActivity extends AppCompatActivity {
AppListFragment appList;
ReportFragment report;
SearchView searchView;
private Menu mMenu;
private AppListFragment appList;
private ReportFragment report;
private SearchView searchView;
private Menu toolbarMenu;
private MenuItem settingsMenuItem;
private String packageName;
private MainBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final MainBinding mainBinding = DataBindingUtil.setContentView(this,R.layout.main);
binding = DataBindingUtil.setContentView(this,R.layout.main);
final MainBinding mainBinding = binding;
NetworkListener networkListener = new NetworkListener() {
@Override
@ -84,13 +92,14 @@ public class MainActivity extends AppCompatActivity {
.addToBackStack(null)
.commit();
packageName = packageInfo.packageName;
searchView.clearFocus();
if (mMenu != null)
(mMenu.findItem(R.id.action_filter)).collapseActionView();
if (toolbarMenu != null)
(toolbarMenu.findItem(R.id.action_filter)).collapseActionView();
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
assert imm != null;
imm.hideSoftInputFromWindow(mainBinding.fragmentContainer.getWindowToken(), 0);
};
appList = AppListFragment.newInstance(networkListener,onAppClickListener);
@ -106,14 +115,16 @@ public class MainActivity extends AppCompatActivity {
public void onBackPressed() {
if (getSupportFragmentManager().getBackStackEntryCount() == 0)
finish();
else
else {
getSupportFragmentManager().popBackStack();
report = null;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
mMenu = menu;
toolbarMenu = menu;
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
searchView = (SearchView) menu.findItem(R.id.action_filter).getActionView();
@ -131,6 +142,28 @@ public class MainActivity extends AppCompatActivity {
return true;
}
});
settingsMenuItem = menu.findItem(R.id.action_settings);
if (report != null)
settingsMenuItem.setVisible(true);
else
settingsMenuItem.setVisible(false);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId() == R.id.action_settings) {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.fromParts("package",packageName,null));
try {
startActivity(intent);
} catch(android.content.ActivityNotFoundException e) {
Snackbar bar = Snackbar.make(binding.fragmentContainer,R.string.no_settings,Snackbar.LENGTH_LONG);
bar.show();
}
return true;
}
return false;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 967 B

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
</vector>

View File

@ -0,0 +1,4 @@
<vector android:height="24dp" android:viewportHeight="20"
android:viewportWidth="20" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFFFF" android:pathData="M15.95,10.78c0.03,-0.25 0.05,-0.51 0.05,-0.78s-0.02,-0.53 -0.06,-0.78l1.69,-1.32c0.15,-0.12 0.19,-0.34 0.1,-0.51l-1.6,-2.77c-0.1,-0.18 -0.31,-0.24 -0.49,-0.18l-1.99,0.8c-0.42,-0.32 -0.86,-0.58 -1.35,-0.78L12,2.34c-0.03,-0.2 -0.2,-0.34 -0.4,-0.34H8.4c-0.2,0 -0.36,0.14 -0.39,0.34l-0.3,2.12c-0.49,0.2 -0.94,0.47 -1.35,0.78l-1.99,-0.8c-0.18,-0.07 -0.39,0 -0.49,0.18l-1.6,2.77c-0.1,0.18 -0.06,0.39 0.1,0.51l1.69,1.32c-0.04,0.25 -0.07,0.52 -0.07,0.78s0.02,0.53 0.06,0.78L2.37,12.1c-0.15,0.12 -0.19,0.34 -0.1,0.51l1.6,2.77c0.1,0.18 0.31,0.24 0.49,0.18l1.99,-0.8c0.42,0.32 0.86,0.58 1.35,0.78l0.3,2.12c0.04,0.2 0.2,0.34 0.4,0.34h3.2c0.2,0 0.37,-0.14 0.39,-0.34l0.3,-2.12c0.49,-0.2 0.94,-0.47 1.35,-0.78l1.99,0.8c0.18,0.07 0.39,0 0.49,-0.18l1.6,-2.77c0.1,-0.18 0.06,-0.39 -0.1,-0.51l-1.67,-1.32zM10,13c-1.65,0 -3,-1.35 -3,-3s1.35,-3 3,-3 3,1.35 3,3 -1.35,3 -3,3z"/>
</vector>

View File

@ -7,4 +7,9 @@
android:title="@string/menu_action_filter"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="ifRoom|collapseActionView" />
</menu>
<item
android:id="@+id/action_settings"
android:icon="@drawable/ic_settings"
android:title="@string/menu_action_settings"
app:showAsAction="ifRoom" />
</menu>

View File

@ -22,7 +22,9 @@
<string name="parse_trackers">Processing Trackers:</string>
<string name="get_trackers_connection">Getting trackers: Waiting for server connection</string>
<string name="get_trackers">Getting trackers</string>
<string name="no_settings">This app doesn\'t have settings</string>
<!-- Menu -->
<string name="menu_action_filter">Filter</string>
<string name="menu_action_settings">Application Settings</string>
</resources>

View File

@ -6,6 +6,7 @@ buildscript {
maven {
url "https://maven.google.com"
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'

View File

@ -4,3 +4,4 @@ distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionSha256Sum=14cd15fc8cc8705bd69dcfa3c8fefb27eb7027f5de4b47a8b279218f76895a91