Skip to content

Commit 8bd2da7

Browse files
committed
Initial commit
0 parents  commit 8bd2da7

21 files changed

+847
-0
lines changed

.gitignore

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Built application files
2+
*.apk
3+
*.aar
4+
*.ap_
5+
*.aab
6+
7+
# Files for the ART/Dalvik VM
8+
*.dex
9+
10+
# Java class files
11+
*.class
12+
13+
# Generated files
14+
bin/
15+
gen/
16+
out/
17+
# Uncomment the following line in case you need and you don't have the release build type files in your app
18+
release/
19+
20+
# Gradle files
21+
.gradle/
22+
build/
23+
24+
# Local configuration file (sdk path, etc)
25+
local.properties
26+
27+
# Proguard folder generated by Eclipse
28+
proguard/
29+
30+
# Log Files
31+
*.log
32+
33+
# Android Studio Navigation editor temp files
34+
.navigation/
35+
36+
# Android Studio captures folder
37+
captures/
38+
39+
# IntelliJ
40+
*.iml
41+
.idea/workspace.xml
42+
.idea/tasks.xml
43+
.idea/gradle.xml
44+
.idea/assetWizardSettings.xml
45+
.idea/dictionaries
46+
.idea/libraries
47+
# Android Studio 3 in .gitignore file.
48+
.idea/caches
49+
.idea/modules.xml
50+
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
51+
.idea/navEditor.xml
52+
53+
# Keystore files
54+
# Uncomment the following lines if you do not want to check your keystore files in.
55+
#*.jks
56+
#*.keystore
57+
58+
# External native build folder generated in Android Studio 2.2 and later
59+
.externalNativeBuild
60+
.cxx/
61+
62+
# Google Services (e.g. APIs or Firebase)
63+
# google-services.json
64+
65+
# Freeline
66+
freeline.py
67+
freeline/
68+
freeline_project_description.json
69+
70+
# fastlane
71+
fastlane/report.xml
72+
fastlane/Preview.html
73+
fastlane/screenshots
74+
fastlane/test_output
75+
fastlane/readme.md
76+
77+
# Version control
78+
vcs.xml
79+
80+
# lint
81+
lint/intermediates/
82+
lint/generated/
83+
lint/outputs/
84+
lint/tmp/
85+
# lint/reports/
86+
87+
# Android Profiling
88+
*.hprof

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
5+
android {
6+
compileSdkVersion 30
7+
buildToolsVersion "30.0.2"
8+
9+
defaultConfig {
10+
applicationId "xzr.hkf"
11+
minSdkVersion 5
12+
targetSdkVersion 30
13+
versionCode 1
14+
versionName "1.0"
15+
}
16+
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
compileOptions {
24+
sourceCompatibility JavaVersion.VERSION_1_8
25+
targetCompatibility JavaVersion.VERSION_1_8
26+
}
27+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

app/src/main/AndroidManifest.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="xzr.hkf">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@drawable/icon"
8+
android:label="@string/app_name"
9+
android:supportsRtl="true"
10+
android:theme="@style/Theme.HorizonKernelFlasher">
11+
<activity android:name=".MainActivity">
12+
<intent-filter>
13+
<action android:name="android.intent.action.MAIN" />
14+
15+
<category android:name="android.intent.category.LAUNCHER" />
16+
</intent-filter>
17+
</activity>
18+
</application>
19+
20+
</manifest>
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
package xzr.hkf;
2+
3+
import android.app.Activity;
4+
import android.app.AlertDialog;
5+
import android.content.Intent;
6+
import android.net.Uri;
7+
import android.os.Bundle;
8+
import android.view.Menu;
9+
import android.view.MenuItem;
10+
import android.widget.ScrollView;
11+
import android.widget.TextView;
12+
import android.widget.Toast;
13+
14+
public class MainActivity extends Activity {
15+
TextView logView;
16+
ScrollView scrollView;
17+
enum status{
18+
flashing,
19+
flashing_done,
20+
error,
21+
normal
22+
}
23+
static status cur_status;
24+
@Override
25+
protected void onCreate(Bundle savedInstanceState) {
26+
super.onCreate(savedInstanceState);
27+
scrollView=new ScrollView(this);
28+
logView=new TextView(this);
29+
scrollView.addView(logView);
30+
setContentView(scrollView);
31+
32+
flash_new();
33+
}
34+
35+
void update_title(){
36+
runOnUiThread(() -> {
37+
switch (cur_status){
38+
case error:
39+
setTitle(R.string.failed);
40+
break;
41+
case flashing:
42+
setTitle(R.string.flashing);
43+
break;
44+
case flashing_done:
45+
setTitle(R.string.flashing_done);
46+
break;
47+
default:
48+
setTitle(R.string.app_name);
49+
}
50+
});
51+
}
52+
53+
void flash_new(){
54+
if(cur_status== MainActivity.status.flashing){
55+
Toast.makeText(this,R.string.task_running,Toast.LENGTH_SHORT).show();
56+
return;
57+
}
58+
59+
logView.setText("");
60+
cur_status=status.normal;
61+
update_title();
62+
Toast.makeText(this,R.string.please_select_kzip,Toast.LENGTH_LONG).show();
63+
runWithFilePath(this, new Worker(this));
64+
}
65+
66+
@Override
67+
public void onBackPressed() {
68+
if(cur_status!=status.flashing)
69+
super.onBackPressed();
70+
}
71+
72+
@Override
73+
public boolean onCreateOptionsMenu(Menu menu) {
74+
getMenuInflater().inflate(R.menu.menu_main, menu);
75+
return super.onCreateOptionsMenu(menu);
76+
}
77+
78+
@Override
79+
public boolean onOptionsItemSelected(MenuItem item) {
80+
if (item.getItemId() == R.id.about) {
81+
new AlertDialog.Builder(this)
82+
.setTitle(R.string.about)
83+
.setMessage(R.string.about_msg)
84+
.setPositiveButton(R.string.ok, null)
85+
.setNegativeButton("Github", (dialog1, which1) -> MainActivity.this.startActivity(new Intent() {{
86+
setAction(Intent.ACTION_VIEW);
87+
setData(Uri.parse("https://github.com/xzr467706992/HorizonKernelFlasher"));
88+
}})).create().show();
89+
}
90+
else if(item.getItemId()==R.id.flash_new){
91+
flash_new();
92+
}
93+
return true;
94+
}
95+
96+
public static void _appendLog(String log, Activity activity){
97+
activity.runOnUiThread(() -> {
98+
((MainActivity) activity).logView.append(log+"\n");
99+
((MainActivity)activity).scrollView.fullScroll(ScrollView.FOCUS_DOWN);
100+
});
101+
}
102+
103+
public static void appendLog(String log, Activity activity){
104+
if(!log.startsWith("ui_print"))
105+
return;
106+
log=log.replace("ui_print","");
107+
_appendLog(log,activity);
108+
}
109+
110+
static class fileWorker extends Thread{
111+
public Uri uri;
112+
}
113+
114+
private static fileWorker file_worker;
115+
public static void runWithFilePath(Activity activity,fileWorker what){
116+
MainActivity.file_worker=what;
117+
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
118+
intent.setType("*/*");
119+
intent.addCategory(Intent.CATEGORY_OPENABLE);
120+
activity.startActivityForResult(intent, 0);
121+
}
122+
123+
@Override
124+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
125+
super.onActivityResult(requestCode, resultCode, data);
126+
if (resultCode == Activity.RESULT_OK) {
127+
file_worker.uri = data.getData();
128+
if(file_worker!=null) {
129+
file_worker.start();
130+
file_worker=null;
131+
}
132+
}
133+
}
134+
}

0 commit comments

Comments
 (0)