diff --git a/app/build.gradle b/app/build.gradle index 9ff96c29a..51ae7b1f4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,18 +2,18 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' - android { namespace 'com.orgzly' compileSdkVersion 32 defaultConfig { + def application_id = "com.orgzlyrevived" minSdkVersion 21 // Lollipop (5.0) targetSdkVersion 32 // Android 12L - applicationId "com.orgzlyrevived" - versionCode 183 - versionName "1.8.14" + versionCode 188 + versionName "1.8.15" + applicationId application_id testInstrumentationRunner "com.orgzly.android.OrgzlyTestRunner" // testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -21,8 +21,11 @@ android { multiDexEnabled true buildConfigField "String", "DROPBOX_APP_KEY", gradle.ext.appProperties.getProperty("dropbox.app_key", '""') + resValue "string", "dropbox_app_key_schema", gradle.ext.appProperties.getProperty("dropbox.app_key_schema", '') + resValue "string", "application_id", application_id + javaCompileOptions { annotationProcessorOptions { arguments = [ @@ -183,10 +186,8 @@ dependencies { exclude group: 'xpp3', module: 'xpp3' } - constraints { - implementation('com.squareup.okhttp3:okhttp:4.10.0-RC1') { - because 'https://github.com/orgzly/orgzly-android/issues/880' - } + implementation('com.squareup.okhttp3:okhttp:4.10.0-RC1') { + because 'https://github.com/orgzly/orgzly-android/issues/880' } implementation "io.github.rburgst:okhttp-digest:$versions.okhttp_digest" diff --git a/app/src/main/java/com/orgzly/android/data/logs/AppLogsRepository.kt b/app/src/main/java/com/orgzly/android/data/logs/AppLogsRepository.kt index b64c49b84..98fe13d03 100644 --- a/app/src/main/java/com/orgzly/android/data/logs/AppLogsRepository.kt +++ b/app/src/main/java/com/orgzly/android/data/logs/AppLogsRepository.kt @@ -5,5 +5,5 @@ import kotlinx.coroutines.flow.Flow interface AppLogsRepository { fun log(type: String, str: String) - fun getFlow(type: String): Flow> + fun getFlow(): Flow> } \ No newline at end of file diff --git a/app/src/main/java/com/orgzly/android/data/logs/DatabaseAppLogsRepository.kt b/app/src/main/java/com/orgzly/android/data/logs/DatabaseAppLogsRepository.kt index 6f21f8184..34c2b43ae 100644 --- a/app/src/main/java/com/orgzly/android/data/logs/DatabaseAppLogsRepository.kt +++ b/app/src/main/java/com/orgzly/android/data/logs/DatabaseAppLogsRepository.kt @@ -18,8 +18,8 @@ class DatabaseAppLogsRepository @Inject constructor(db: OrgzlyDatabase) : AppLog dbAppLog.insert(entry) } - override fun getFlow(type: String): Flow> { - return dbAppLog.getFlow(type).map { logEntries -> + override fun getFlow(): Flow> { + return dbAppLog.getFlow().map { logEntries -> logEntries.map { entry -> LogEntry(entry.timestamp, entry.name, entry.message) } diff --git a/app/src/main/java/com/orgzly/android/db/dao/AppLogDao.kt b/app/src/main/java/com/orgzly/android/db/dao/AppLogDao.kt index 8267f3a06..7cd46ea46 100644 --- a/app/src/main/java/com/orgzly/android/db/dao/AppLogDao.kt +++ b/app/src/main/java/com/orgzly/android/db/dao/AppLogDao.kt @@ -7,6 +7,6 @@ import kotlinx.coroutines.flow.Flow @Dao abstract class AppLogDao : BaseDao { - @Query("SELECT * FROM app_logs WHERE name = :name ORDER BY timestamp") - abstract fun getFlow(name: String): Flow> + @Query("SELECT * FROM app_logs ORDER BY timestamp") + abstract fun getFlow(): Flow> } diff --git a/app/src/main/java/com/orgzly/android/sync/SyncWorker.kt b/app/src/main/java/com/orgzly/android/sync/SyncWorker.kt index 9ccb8bc34..e06428a94 100644 --- a/app/src/main/java/com/orgzly/android/sync/SyncWorker.kt +++ b/app/src/main/java/com/orgzly/android/sync/SyncWorker.kt @@ -9,6 +9,7 @@ import com.orgzly.R import com.orgzly.android.App import com.orgzly.android.SharingShortcutsManager import com.orgzly.android.data.DataRepository +import com.orgzly.android.data.logs.AppLogsRepository import com.orgzly.android.db.entity.BookAction import com.orgzly.android.prefs.AppPreferences import com.orgzly.android.reminders.RemindersScheduler @@ -16,6 +17,7 @@ import com.orgzly.android.repos.* import com.orgzly.android.ui.notifications.SyncNotifications import com.orgzly.android.ui.util.haveNetworkConnection import com.orgzly.android.util.AppPermissions +import com.orgzly.android.util.LogMajorEvents import com.orgzly.android.util.LogUtils import com.orgzly.android.widgets.ListWidgetProvider import kotlinx.coroutines.Dispatchers @@ -29,6 +31,9 @@ class SyncWorker(val context: Context, val params: WorkerParameters) : @Inject lateinit var dataRepository: DataRepository + @Inject + lateinit var appLogs: AppLogsRepository + override suspend fun doWork(): Result { App.appComponent.inject(this) @@ -84,15 +89,28 @@ class SyncWorker(val context: Context, val params: WorkerParameters) : checkConditions()?.let { return it } + val syncStartTime = System.currentTimeMillis() + syncRepos()?.let { return it } RemindersScheduler.notifyDataSetChanged(App.getAppContext()) ListWidgetProvider.notifyDataSetChanged(App.getAppContext()) SharingShortcutsManager().replaceDynamicShortcuts(App.getAppContext()) + val syncEndTime = System.currentTimeMillis() + // Save last successful sync time to preferences - val time = System.currentTimeMillis() - AppPreferences.lastSuccessfulSyncTime(context, time) + AppPreferences.lastSuccessfulSyncTime(context, syncEndTime) + + if (LogMajorEvents.isEnabled()) { + val syncDuration = (syncEndTime - syncStartTime) + val numberOfRepos = dataRepository.getRepos().size + val numberOfBooks = dataRepository.getBooks().size + appLogs.log( + LogMajorEvents.SYNC, + "Sync took $syncDuration milliseconds. Synced $numberOfBooks books in $numberOfRepos repos." + ) + } return SyncState.getInstance(SyncState.Type.FINISHED) } @@ -275,4 +293,4 @@ class SyncWorker(val context: Context, val params: WorkerParameters) : companion object { private val TAG: String = SyncWorker::class.java.name } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/orgzly/android/ui/logs/AppLogsActivity.kt b/app/src/main/java/com/orgzly/android/ui/logs/AppLogsActivity.kt index bb503d83d..ebd223d20 100644 --- a/app/src/main/java/com/orgzly/android/ui/logs/AppLogsActivity.kt +++ b/app/src/main/java/com/orgzly/android/ui/logs/AppLogsActivity.kt @@ -16,6 +16,7 @@ import com.orgzly.android.ui.util.getAlarmManager import com.orgzly.android.ui.util.sharePlainText import com.orgzly.android.ui.util.userFriendlyPeriod import com.orgzly.databinding.ActivityLogsBinding +import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch import org.joda.time.DateTime import javax.inject.Inject diff --git a/app/src/main/java/com/orgzly/android/ui/logs/AppLogsViewModel.kt b/app/src/main/java/com/orgzly/android/ui/logs/AppLogsViewModel.kt index 385bc3d46..0208ec83c 100644 --- a/app/src/main/java/com/orgzly/android/ui/logs/AppLogsViewModel.kt +++ b/app/src/main/java/com/orgzly/android/ui/logs/AppLogsViewModel.kt @@ -7,7 +7,7 @@ import kotlinx.coroutines.flow.map import java.util.* class AppLogsViewModel(appLogsRepository: AppLogsRepository) : CommonViewModel() { - val logs = appLogsRepository.getFlow(LogMajorEvents.REMINDERS).map { + val logs = appLogsRepository.getFlow().map { it.map { logEntry -> val date = Date(logEntry.time) val type = logEntry.type diff --git a/app/src/main/java/com/orgzly/android/util/LogMajorEvents.kt b/app/src/main/java/com/orgzly/android/util/LogMajorEvents.kt index 7418af14d..2c47910b3 100644 --- a/app/src/main/java/com/orgzly/android/util/LogMajorEvents.kt +++ b/app/src/main/java/com/orgzly/android/util/LogMajorEvents.kt @@ -13,6 +13,7 @@ class LogMajorEvents { companion object { const val REMINDERS = "reminders" + const val SYNC = "sync" fun isEnabled(): Boolean { return AppPreferences.logMajorEvents(App.getAppContext()) diff --git a/app/src/main/res/layout/dialog_whats_new.xml b/app/src/main/res/layout/dialog_whats_new.xml index 517655969..da74c7366 100644 --- a/app/src/main/res/layout/dialog_whats_new.xml +++ b/app/src/main/res/layout/dialog_whats_new.xml @@ -20,6 +20,31 @@ android:layout_height="wrap_content" /> + + + + + + + + + + + + Depo ayarlarının çalışacağından emin ol. Uzak Bağlantı (örn. git@github.com:orgzly/orgzly-android.git) Dizin konumu (örn. \"/sdcard/orgzly\") - SSH anahtar konumu (örn. \"/sdcard/id_rsa\") Kullanıcı adı Parola Yazar (örn. Sarı Çizmeli Mehmet) diff --git a/app/src/main/res/xml/prefs_screen_developer.xml b/app/src/main/res/xml/prefs_screen_developer.xml index 193feef32..efb8a859f 100644 --- a/app/src/main/res/xml/prefs_screen_developer.xml +++ b/app/src/main/res/xml/prefs_screen_developer.xml @@ -21,7 +21,7 @@ android:title="@string/logs"> diff --git a/app/src/main/res/xml/prefs_screen_reminders.xml b/app/src/main/res/xml/prefs_screen_reminders.xml index 16a33ce8f..8bb70730e 100644 --- a/app/src/main/res/xml/prefs_screen_reminders.xml +++ b/app/src/main/res/xml/prefs_screen_reminders.xml @@ -62,7 +62,7 @@ android:summary="@string/notification_channel_settings_summary"> - + diff --git a/app/src/main/res/xml/prefs_screen_sync.xml b/app/src/main/res/xml/prefs_screen_sync.xml index 1dc86abc1..78c2d01cf 100644 --- a/app/src/main/res/xml/prefs_screen_sync.xml +++ b/app/src/main/res/xml/prefs_screen_sync.xml @@ -11,7 +11,7 @@ android:summary="@string/repos_preference_summary"> @@ -27,7 +27,7 @@ android:summary="@string/ssh_keygen_preference_summary"> diff --git a/app/src/main/res/xml/shortcuts.xml b/app/src/main/res/xml/shortcuts.xml index a3fe67e6a..7e77eebc6 100644 --- a/app/src/main/res/xml/shortcuts.xml +++ b/app/src/main/res/xml/shortcuts.xml @@ -12,7 +12,7 @@ android:shortcutShortLabel="@string/new_note"> @@ -23,7 +23,7 @@ android:shortcutShortLabel="@string/sync">