Skip to content

Commit 56680f6

Browse files
committed
add github files
1 parent 8b8ec3e commit 56680f6

File tree

2 files changed

+53
-13
lines changed

2 files changed

+53
-13
lines changed

app/src/main/java/fr/shayfox/k_note/controller/MainActivity.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import android.annotation.SuppressLint;
44
import android.content.Context;
55
import android.content.Intent;
6+
import android.content.pm.PackageInfo;
7+
import android.content.pm.PackageManager;
68
import android.database.Cursor;
79
import android.graphics.Canvas;
810
import android.graphics.Color;
@@ -38,13 +40,17 @@
3840
import com.google.android.material.snackbar.Snackbar;
3941
import com.google.gson.Gson;
4042
import com.google.gson.GsonBuilder;
43+
import com.google.gson.JsonSyntaxException;
4144

4245
import java.io.BufferedReader;
4346
import java.io.File;
4447
import java.io.FileInputStream;
4548
import java.io.FileNotFoundException;
4649
import java.io.IOException;
4750
import java.io.InputStreamReader;
51+
import java.net.HttpURLConnection;
52+
import java.net.URL;
53+
import java.nio.charset.Charset;
4854
import java.util.Collections;
4955
import java.util.concurrent.atomic.AtomicBoolean;
5056
import java.util.stream.Collectors;
@@ -77,6 +83,8 @@ protected void onCreate(Bundle savedInstanceState) {
7783
INSTANCE = this;
7884
Thread.setDefaultUncaughtExceptionHandler(new ExeptionHandlerPrint());
7985

86+
checkUpdate();
87+
8088
mAppManager = new AppManager(getApplicationContext());
8189
mNoteAdapter = new NoteAdapter(mAppManager.getNoteList(), this);
8290
binding = ActivityMainBinding.inflate(getLayoutInflater());
@@ -287,6 +295,42 @@ protected void onCreate(Bundle savedInstanceState) {
287295
});
288296
}
289297

298+
private void checkUpdate() {
299+
// PackageManager manager = getApplicationContext().getPackageManager();
300+
// PackageInfo info;
301+
// try {
302+
// info = manager.getPackageInfo(
303+
// getApplicationContext().getPackageName(), 0);
304+
// } catch (PackageManager.NameNotFoundException e) {
305+
// throw new RuntimeException(e);
306+
// }
307+
// String version = info.versionName;
308+
//
309+
// System.out.println("Version: "+version);
310+
//
311+
// try {
312+
// System.out.println("connection");
313+
// final HttpURLConnection connection = (HttpURLConnection) new URL("https://api.github.com/repos/ShayF0x/K-Note/releases/latest").openConnection();
314+
// //connection.setRequestProperty("User-Agent", USER_AGENT);
315+
// connection.connect();
316+
//
317+
// if (connection.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) {
318+
// System.out.println("error");
319+
// return;
320+
// }
321+
//
322+
// try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charset.forName("UTF8")))) {
323+
// System.out.println(reader);
324+
// } catch (JsonSyntaxException | NumberFormatException ex) {
325+
// System.out.println("Failed to parse the latest version info.");
326+
// ex.printStackTrace();
327+
// }
328+
// } catch (IOException ex) {
329+
// System.out.println("LOG: Failed to get release info from api.github.com.");
330+
// ex.printStackTrace();
331+
// }
332+
}
333+
290334
@Override
291335
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
292336
switch (requestCode) {

gradle.properties

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
# Project-wide Gradle settings.
2-
# IDE (e.g. Android Studio) users:
3-
# Gradle settings configured through the IDE *will override*
4-
# any settings specified in this file.
5-
# For more details on how to configure your build environment visit
1+
## For more details on how to configure your build environment visit
62
# http://www.gradle.org/docs/current/userguide/build_environment.html
3+
#
74
# Specifies the JVM arguments used for the daemon process.
85
# The setting is particularly useful for tweaking memory settings.
9-
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
6+
# Default value: -Xmx1024m -XX:MaxPermSize=256m
7+
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
8+
#
109
# When configured, Gradle will run in incubating parallel mode.
1110
# This option should only be used with decoupled projects. More details, visit
1211
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1312
# org.gradle.parallel=true
14-
# AndroidX package structure to make it clearer which packages are bundled with the
15-
# Android operating system, and which are packaged with your app's APK
16-
# https://developer.android.com/topic/libraries/support-library/androidx-rn
13+
#Sun Mar 26 16:52:31 CEST 2023
14+
android.nonTransitiveRClass=true
15+
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding\=UTF-8
1716
android.useAndroidX=true
18-
# Enables namespacing of each library's R class so that its R class includes only the
19-
# resources declared in the library itself and none from the library's dependencies,
20-
# thereby reducing the size of the R class for that library
21-
android.nonTransitiveRClass=true
17+
android.enableJetifier=true

0 commit comments

Comments
 (0)