-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
track history, uninstall instead of hide
- Loading branch information
Showing
11 changed files
with
958 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/src/main/java/io/github/h4mu/sysprotec/AppDetailActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package io.github.h4mu.sysprotec; | ||
|
||
import android.content.Intent; | ||
import android.content.pm.ApplicationInfo; | ||
import android.content.pm.PackageManager; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.provider.Settings; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
public class AppDetailActivity extends AppCompatActivity { | ||
private ApplicationInfo applicationInfo; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_app_detail); | ||
String packageName = getIntent().getStringExtra(AppsHistoryActivity.COLUMN_PACKAGE); | ||
|
||
try { | ||
applicationInfo = getPackageManager().getApplicationInfo(packageName, PackageManager.GET_META_DATA); | ||
} catch (PackageManager.NameNotFoundException e) { | ||
((TextView) findViewById(R.id.nameText)).setText(packageName); | ||
((TextView) findViewById(R.id.packageText)).setText(packageName); | ||
((TextView) findViewById(R.id.appDescriptionText)).setText(R.string.not_installed); | ||
return; | ||
} | ||
|
||
findViewById(R.id.button).setEnabled(true); | ||
((TextView) findViewById(R.id.nameText)).setText(applicationInfo.loadLabel(getPackageManager())); | ||
((TextView) findViewById(R.id.packageText)).setText(packageName); | ||
((TextView) findViewById(R.id.appDescriptionText)).setText(applicationInfo.loadDescription(getPackageManager())); | ||
} | ||
|
||
public void onRemoveAppClicked(View view) { | ||
if (applicationInfo != null) { | ||
Intent intent = new Intent(); | ||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | ||
intent.setData(Uri.fromParts("package", applicationInfo.packageName, null)); | ||
startActivity(intent); | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
app/src/main/java/io/github/h4mu/sysprotec/AppsHistoryActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package io.github.h4mu.sysprotec; | ||
|
||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.os.Bundle; | ||
import android.preference.PreferenceManager; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.AdapterView; | ||
import android.widget.ListView; | ||
import android.widget.SimpleAdapter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
|
||
public class AppsHistoryActivity extends AppCompatActivity implements AdapterView.OnItemClickListener { | ||
static final String COLUMN_PACKAGE = "package"; | ||
private static final String COLUMN_INSTALLDATE = "install date"; | ||
private ArrayList<HashMap<String, String>> apps = new ArrayList<>(); | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_apps_history); | ||
|
||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); | ||
for (String item : sharedPref.getString("history", "").split(";")) { | ||
String[] pkgDate = item.split("\\|"); | ||
if (pkgDate.length >= 2) { | ||
HashMap<String, String> row = new HashMap<>(); | ||
row.put(COLUMN_PACKAGE, pkgDate[1]); | ||
row.put(COLUMN_INSTALLDATE, pkgDate[0]); | ||
apps.add(row); | ||
} | ||
} | ||
|
||
ListView listView = findViewById(R.id.packageList); | ||
listView.setAdapter(new SimpleAdapter(this, apps, android.R.layout.simple_list_item_2, | ||
new String[]{COLUMN_INSTALLDATE, COLUMN_PACKAGE}, new int[]{android.R.id.text1, android.R.id.text2})); | ||
listView.setOnItemClickListener(this); | ||
} | ||
|
||
@Override | ||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | ||
Intent intent = new Intent(AppsHistoryActivity.this, AppDetailActivity.class); | ||
intent.putExtra(COLUMN_PACKAGE, apps.get(position).get(COLUMN_PACKAGE)); | ||
startActivity(intent); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
app/src/main/java/io/github/h4mu/sysprotec/LicenseActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.github.h4mu.sysprotec; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
public class LicenseActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_license); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".AppDetailActivity"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
tools:layout_editor_absoluteX="8dp" | ||
tools:layout_editor_absoluteY="8dp"> | ||
|
||
<Button | ||
android:id="@+id/button" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:enabled="false" | ||
android:onClick="onRemoveAppClicked" | ||
android:text="@string/removeApp" /> | ||
|
||
<TextView | ||
android:id="@+id/nameText" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="TextView" | ||
android:textAppearance="@style/TextAppearance.AppCompat.Title" /> | ||
|
||
<TextView | ||
android:id="@+id/packageText" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="TextView" | ||
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" /> | ||
|
||
<TextView | ||
android:id="@+id/appDescriptionText" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="TextView" /> | ||
|
||
</LinearLayout> | ||
</android.support.constraint.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".AppsHistoryActivity"> | ||
|
||
<ListView | ||
android:id="@+id/packageList" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
</android.support.constraint.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".LicenseActivity"> | ||
|
||
<ScrollView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:layout_editor_absoluteY="8dp" | ||
tools:layout_editor_absoluteX="8dp" | ||
android:scrollbars="vertical" | ||
android:fillViewport="true"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/textView" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:layout_weight="1.0" | ||
android:text="@string/licenseText" | ||
tools:layout_editor_absoluteX="0dp" | ||
tools:layout_editor_absoluteY="0dp" /> | ||
</LinearLayout> | ||
</ScrollView> | ||
</android.support.constraint.ConstraintLayout> |
Oops, something went wrong.