mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-06-18 08:12:44 +02:00
Compare commits
2 Commits
v3.9.1-dev
...
v3.9.3-dev
Author | SHA1 | Date | |
---|---|---|---|
01ac26e67b | |||
434ddd1342 |
@ -164,6 +164,8 @@ dependencies {
|
||||
implementation "io.github.wulkanowy:signer-android:0.1.1"
|
||||
|
||||
implementation "androidx.work:work-runtime-ktx:${versions.work}"
|
||||
|
||||
implementation 'com.hypertrack:hyperlog:0.0.10'
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -36,6 +36,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.hypertrack.hyperlog.HyperLog;
|
||||
import com.mikepenz.iconics.Iconics;
|
||||
import com.mikepenz.iconics.IconicsColor;
|
||||
import com.mikepenz.iconics.IconicsDrawable;
|
||||
@ -81,6 +82,7 @@ import pl.szczodrzynski.edziennik.network.NetworkUtils;
|
||||
import pl.szczodrzynski.edziennik.network.TLSSocketFactory;
|
||||
import pl.szczodrzynski.edziennik.sync.SyncWorker;
|
||||
import pl.szczodrzynski.edziennik.ui.modules.base.CrashActivity;
|
||||
import pl.szczodrzynski.edziennik.utils.DebugLogFormat;
|
||||
import pl.szczodrzynski.edziennik.utils.PermissionChecker;
|
||||
import pl.szczodrzynski.edziennik.utils.Themes;
|
||||
import pl.szczodrzynski.edziennik.utils.Utils;
|
||||
@ -294,6 +296,10 @@ public class App extends androidx.multidex.MultiDexApplication implements Config
|
||||
}
|
||||
|
||||
if (App.devMode || BuildConfig.DEBUG) {
|
||||
HyperLog.initialize(this);
|
||||
HyperLog.setLogLevel(Log.VERBOSE);
|
||||
HyperLog.setLogFormat(new DebugLogFormat(this));
|
||||
|
||||
ChuckerCollector chuckerCollector = new ChuckerCollector(this, true, RetentionManager.Period.ONE_HOUR);
|
||||
ChuckerInterceptor chuckerInterceptor = new ChuckerInterceptor(this, chuckerCollector);
|
||||
httpBuilder.addInterceptor(chuckerInterceptor);
|
||||
|
@ -36,7 +36,6 @@ import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import pl.droidsonroids.gif.GifDrawable
|
||||
import pl.szczodrzynski.edziennik.App.APP_URL
|
||||
import pl.szczodrzynski.edziennik.api.v2.ApiService
|
||||
import pl.szczodrzynski.edziennik.api.v2.events.*
|
||||
import pl.szczodrzynski.edziennik.api.v2.events.task.EdziennikTask
|
||||
import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikInterface.*
|
||||
@ -524,17 +523,14 @@ class MainActivity : AppCompatActivity() {
|
||||
fun syncCurrentFeature() {
|
||||
swipeRefreshLayout.isRefreshing = true
|
||||
Toast.makeText(this, fragmentToSyncName(navTargetId), Toast.LENGTH_SHORT).show()
|
||||
ApiService.start(this)
|
||||
val fragmentParam = when (navTargetId) {
|
||||
DRAWER_ITEM_MESSAGES -> MessagesFragment.pageSelection
|
||||
else -> 0
|
||||
}
|
||||
EventBus.getDefault().postSticky(
|
||||
EdziennikTask.syncProfile(
|
||||
App.profileId,
|
||||
listOf(navTargetId to fragmentParam)
|
||||
)
|
||||
)
|
||||
EdziennikTask.syncProfile(
|
||||
App.profileId,
|
||||
listOf(navTargetId to fragmentParam)
|
||||
).enqueue(this)
|
||||
}
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onSyncStartedEvent(event: ApiTaskStartedEvent) {
|
||||
@ -783,7 +779,7 @@ class MainActivity : AppCompatActivity() {
|
||||
fun loadProfile(id: Int) = loadProfile(id, navTargetId)
|
||||
fun loadProfile(id: Int, arguments: Bundle?) = loadProfile(id, navTargetId, arguments)
|
||||
fun loadProfile(id: Int, drawerSelection: Int, arguments: Bundle? = null) {
|
||||
d("NavDebug", "loadProfile(id = $id, drawerSelection = $drawerSelection)")
|
||||
//d("NavDebug", "loadProfile(id = $id, drawerSelection = $drawerSelection)")
|
||||
if (app.profile != null && App.profileId == id) {
|
||||
drawer.currentProfile = app.profile.id
|
||||
loadTarget(drawerSelection, arguments)
|
||||
|
@ -232,11 +232,13 @@ class ApiService : Service() {
|
||||
____) | __/ | \ V /| | (_| __/ | (_) \ V / __/ | | | | | (_| | __/\__ \
|
||||
|_____/ \___|_| \_/ |_|\___\___| \___/ \_/ \___|_| |_| |_|\__,_|\___||__*/
|
||||
override fun onCreate() {
|
||||
d(TAG, "Service created")
|
||||
EventBus.getDefault().register(this)
|
||||
notification.setIdle().setCloseAction()
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
d(TAG, "Foreground service onStartCommand")
|
||||
startForeground(EdziennikNotification.NOTIFICATION_ID, notification.notification)
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ package pl.szczodrzynski.edziennik.api.v2.events.task
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build.VERSION.SDK_INT
|
||||
import android.os.Build.VERSION_CODES.O
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.api.v2.ApiService
|
||||
@ -25,7 +27,12 @@ abstract class IApiTask(open val profileId: Int) {
|
||||
abstract fun cancel()
|
||||
|
||||
fun enqueue(context: Context) {
|
||||
context.startService(Intent(context, ApiService::class.java))
|
||||
Intent(context, ApiService::class.java).let {
|
||||
if (SDK_INT >= O)
|
||||
context.startForegroundService(it)
|
||||
else
|
||||
context.startService(it)
|
||||
}
|
||||
EventBus.getDefault().postSticky(this)
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@ -31,11 +32,13 @@ import androidx.work.WorkManager;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.chuckerteam.chucker.api.Chucker;
|
||||
import com.hypertrack.hyperlog.HyperLog;
|
||||
import com.mikepenz.iconics.IconicsColor;
|
||||
import com.mikepenz.iconics.IconicsDrawable;
|
||||
import com.mikepenz.iconics.IconicsSize;
|
||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -114,6 +117,19 @@ public class HomeFragment extends Fragment {
|
||||
startActivity(new Intent(activity, LoginLibrusCaptchaActivity.class));
|
||||
}));
|
||||
|
||||
b.getLogs.setOnClickListener((v -> {
|
||||
File logs = HyperLog.getDeviceLogsInFile(activity, true);
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
|
||||
if(logs.exists()) {
|
||||
intent.setType("text/plain");
|
||||
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+logs.getAbsolutePath()));
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, "Share debug logs");
|
||||
intent.putExtra(Intent.EXTRA_TEXT, "Share debug logs");
|
||||
startActivity(Intent.createChooser(intent, "Share debug logs"));
|
||||
}
|
||||
}));
|
||||
|
||||
//((TextView)v.findViewById(R.id.nextSync)).setText(getString(R.string.next_sync_format,Time.fromMillis(app.appJobs.syncJobTime).getStringHMS()));
|
||||
|
||||
|
||||
|
@ -533,7 +533,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
||||
syncCardIntervalItem.setChecked(app.appConfig.registerSyncEnabled);
|
||||
syncCardIntervalItem.setOnClickAction(() -> {
|
||||
List<CharSequence> intervalNames = new ArrayList<>();
|
||||
if (App.devMode) {
|
||||
if (App.devMode && false) {
|
||||
intervalNames.add(HomeFragment.plural(activity, R.plurals.time_till_seconds, 30));
|
||||
intervalNames.add(HomeFragment.plural(activity, R.plurals.time_till_minutes, 2));
|
||||
}
|
||||
@ -545,7 +545,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
||||
intervalNames.add(HomeFragment.plural(activity, R.plurals.time_till_hours, 3));
|
||||
intervalNames.add(HomeFragment.plural(activity, R.plurals.time_till_hours, 4));
|
||||
List<Integer> intervals = new ArrayList<>();
|
||||
if (App.devMode) {
|
||||
if (App.devMode && false) {
|
||||
intervals.add(30);
|
||||
intervals.add(2 * 60);
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
package pl.szczodrzynski.edziennik.utils
|
||||
|
||||
import android.content.Context
|
||||
import com.hypertrack.hyperlog.LogFormat
|
||||
|
||||
class DebugLogFormat(context: Context) : LogFormat(context) {
|
||||
override fun getFormattedLogMessage(logLevelName: String?, tag: String?, message: String?, timeStamp: String?, senderName: String?, osVersion: String?, deviceUUID: String?): String {
|
||||
return "${timeStamp?.replace("[TZ]".toRegex(), " ")}D/$tag: $message"
|
||||
}
|
||||
}
|
@ -26,6 +26,8 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.hypertrack.hyperlog.HyperLog;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
@ -106,15 +108,15 @@ public class Utils {
|
||||
|
||||
public static void d(String TAG, String message) {
|
||||
if (App.devMode) {
|
||||
Log.d("Szkolny/"+TAG, message);
|
||||
HyperLog.d("Szkolny/"+TAG, message);
|
||||
//debugLog.add(TAG+": "+message);
|
||||
}
|
||||
}
|
||||
public static void c(String TAG, String message) {
|
||||
if (App.devMode) {
|
||||
/*if (App.devMode) {
|
||||
Log.d(TAG, "// " + message);
|
||||
///debugLog.add(TAG+": // "+message);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,6 +39,14 @@
|
||||
tools:visibility="visible"
|
||||
tools:ignore="HardcodedText">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/getLogs"
|
||||
style="@style/Widget.MaterialComponents.Button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:text="Save Debug Logs" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/librusCaptchaButton"
|
||||
style="@style/Widget.MaterialComponents.Button"
|
||||
|
@ -5,8 +5,8 @@ buildscript {
|
||||
kotlin_version = '1.3.50'
|
||||
|
||||
release = [
|
||||
versionName: "3.9.1-dev",
|
||||
versionCode: 3090100
|
||||
versionName: "3.9.3-dev",
|
||||
versionCode: 3090300
|
||||
]
|
||||
|
||||
setup = [
|
||||
|
Reference in New Issue
Block a user