This repository has been archived by the owner on Dec 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e74cd68
commit 88f64bc
Showing
12 changed files
with
267 additions
and
69 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
Binary file not shown.
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 |
---|---|---|
@@ -1 +1 @@ | ||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":11,"versionName":"1.0.9","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] | ||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":12,"versionName":"1.1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] |
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
136 changes: 136 additions & 0 deletions
136
app/src/main/java/com/RichardLuo/notificationpush/Application.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,136 @@ | ||
package com.RichardLuo.notificationpush; | ||
|
||
import android.content.SharedPreferences; | ||
import android.content.pm.ApplicationInfo; | ||
import android.content.pm.PackageManager; | ||
import android.graphics.drawable.Drawable; | ||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.AdapterView; | ||
import android.widget.BaseAdapter; | ||
import android.widget.ImageView; | ||
import android.widget.ListView; | ||
import android.widget.ProgressBar; | ||
import android.widget.Spinner; | ||
import android.widget.TextView; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class Application extends AppCompatActivity { | ||
ListView listView; | ||
SharedPreferences preferences; | ||
ProgressBar progressBar; | ||
Handler handler = new Handler(); | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setTheme(getSharedPreferences("MainActivity", MODE_PRIVATE).getInt("style", R.style.base_AppTheme_teal)); | ||
setContentView(R.layout.activity_application); | ||
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true); | ||
preferences = getPreferences(MODE_PRIVATE); | ||
listView = findViewById(R.id.listview); | ||
progressBar = findViewById(R.id.progressBar); | ||
final PackageManager packageManager = getPackageManager(); | ||
final List<ApplicationInfo> packageInfo = packageManager.getInstalledApplications(0); | ||
|
||
new Thread() { | ||
@Override | ||
public void run() { | ||
super.run(); | ||
final List<info> packageView = new ArrayList<>(); | ||
for (final ApplicationInfo applicationInfo : packageInfo) { | ||
final String name = packageManager.getApplicationLabel(applicationInfo).toString(); | ||
Spinner.OnItemSelectedListener onItemSelectedListener = new Spinner.OnItemSelectedListener() { | ||
@Override | ||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | ||
if (position == 0) { | ||
preferences.edit().remove(applicationInfo.packageName).apply(); | ||
return; | ||
} | ||
preferences.edit().putInt(applicationInfo.packageName, position).apply(); | ||
} | ||
|
||
@Override | ||
public void onNothingSelected(AdapterView<?> parent) { | ||
|
||
} | ||
}; | ||
packageView.add(new info(name, packageManager.getApplicationIcon(applicationInfo), onItemSelectedListener,preferences.getInt(applicationInfo.packageName, 0))); | ||
} | ||
|
||
handler.post(new Runnable() { | ||
@Override | ||
public void run() { | ||
listView.setAdapter(new BaseAdapter() { | ||
@Override | ||
public int getCount() { | ||
return packageView.size(); | ||
} | ||
|
||
@Override | ||
public Object getItem(int position) { | ||
return packageView.get(position); | ||
} | ||
|
||
@Override | ||
public long getItemId(int position) { | ||
return position; | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
ViewHolder holder; | ||
info info = packageView.get(position); | ||
if (convertView == null) { | ||
convertView = LayoutInflater.from(getBaseContext()).inflate(R.layout.app_layout, listView, false); | ||
holder = new ViewHolder(); | ||
holder.text = convertView.findViewById(R.id.appName); | ||
holder.icon = convertView.findViewById(R.id.imageView); | ||
holder.spinner = convertView.findViewById(R.id.spinner); | ||
convertView.setTag(holder); | ||
} else { | ||
holder = (ViewHolder) convertView.getTag(); | ||
} | ||
holder.text.setText(info.text); | ||
holder.icon.setImageDrawable(info.icon); | ||
holder.spinner.setSelection(info.selection); | ||
holder.spinner.setOnItemSelectedListener(info.onItemSelectedListener); | ||
return convertView; | ||
} | ||
}); | ||
progressBar.setVisibility(View.GONE); | ||
} | ||
}); | ||
} | ||
|
||
class ViewHolder { | ||
TextView text; | ||
ImageView icon; | ||
Spinner spinner; | ||
} | ||
|
||
class info { | ||
String text; | ||
Drawable icon; | ||
Spinner.OnItemSelectedListener onItemSelectedListener; | ||
int selection; | ||
|
||
info(String text, Drawable icon, Spinner.OnItemSelectedListener onItemSelectedListener, int selection) { | ||
this.text = text; | ||
this.icon = icon; | ||
this.onItemSelectedListener = onItemSelectedListener; | ||
this.selection = selection; | ||
} | ||
} | ||
}.start(); | ||
} | ||
|
||
|
||
} |
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
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,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<ListView | ||
android:id="@+id/listview" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> | ||
|
||
|
||
<ProgressBar | ||
android:id="@+id/progressBar" | ||
style="?android:attr/progressBarStyle" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" /> | ||
|
||
</FrameLayout> |
Oops, something went wrong.