Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardLuo0 committed May 30, 2019
1 parent 5540863 commit 149ff0e
Show file tree
Hide file tree
Showing 10 changed files with 669 additions and 662 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This app is for forwarding your notification from one phone to another using the
### Only for users from China
* 服务端可能必须24小时挂梯!

# if you want to compile by yourself
# If you want to compile by yourself
* 下载源码(Download the source code)
* 在firebase中建立新项目(Create a new project in firebase)
* 根据Google的firebase文档加入google-services.json文件(Add google-services.json file according to the official document of Google)
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.RichardLuo.notificationpush"
minSdkVersion 22
targetSdkVersion 28
versionCode 15
versionName "1.1.1"
versionCode 16
versionName "1.1.1(1)"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":15,"versionName":"1.1.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":16,"versionName":"1.1.1(1)","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
194 changes: 97 additions & 97 deletions app/src/main/java/com/RichardLuo/notificationpush/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,112 +24,112 @@
import java.util.Objects;

public class Application extends AppCompatActivity {
ListView listView;
SharedPreferences preferences;
ProgressBar progressBar;
Handler handler = new Handler();
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);
@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();
}
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) {
@Override
public void onNothingSelected(AdapterView<?> parent) {

}
};
packageView.add(new info(name, packageManager.getApplicationIcon(applicationInfo), onItemSelectedListener, preferences.getInt(applicationInfo.packageName, 0)));
}
}
};
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();
}
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 Object getItem(int position) {
return packageView.get(position);
}

@Override
public long getItemId(int position) {
return 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);
}
});
}
@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 ViewHolder {
TextView text;
ImageView icon;
Spinner spinner;
}

class info {
String text;
Drawable icon;
Spinner.OnItemSelectedListener onItemSelectedListener;
int selection;
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();
}
info(String text, Drawable icon, Spinner.OnItemSelectedListener onItemSelectedListener, int selection) {
this.text = text;
this.icon = icon;
this.onItemSelectedListener = onItemSelectedListener;
this.selection = selection;
}
}
}.start();
}
}
Loading

0 comments on commit 149ff0e

Please sign in to comment.