diff --git a/build.gradle b/build.gradle index 34604f33..dc4540fb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,39 +1,39 @@ // root build.gradle buildscript { ext { - agp_version = '8.1.2' + android_gradle_plugin_version = '8.1.3' kotlin_version = '1.9.10' material_design_version = '1.10.0' - appcompat_version = '1.6.1' - annotation_version = '1.6.0' - fragment_version = '1.6.1' - nav_version = '2.7.4' - room_version = '2.6.0' + androidx_appcompat_version = '1.6.1' + androidx_annotation_version = '1.6.0' + androidx_fragment_version = '1.6.2' + androidx_navigation_version = '2.7.5' + androidx_room_version = '2.6.0' flexbox_version = '3.0.0' - splash_version = '1.0.1' - recyclerview_version = '1.3.2' - preference_version = '1.2.1' - cardview_version = '1.0.0' + androidx_splash_version = '1.0.1' + androidx_recyclerview_version = '1.3.2' + androidx_preference_version = '1.2.1' + androidx_cardview_version = '1.0.0' retrofit_version = '2.9.0' gson_version = '2.10.1' // DirCacheCheckout.java uses InputStream.transferTo() since 6.3; no such method on Android. jgit_version = '6.2.0.202206071550-r' // instead of 6.5.0.202303070854-r slf4j_version = '2.0.7' junit_version = '4.13.2' - test_junit_version = '1.1.5' - test_core_version = '1.5.0' - test_monitor_version = '1.6.1' - test_runner_version = '1.5.2' - test_rules_version = '1.5.0' - uiautomator_version = '2.2.0' - espresso_version = '3.5.1' + androidx_test_junit_version = '1.1.5' + androidx_test_core_version = '1.5.0' + androidx_test_monitor_version = '1.6.1' + androidx_test_runner_version = '1.5.2' + androidx_test_rules_version = '1.5.0' + androidx_test_uiautomator_version = '2.2.0' + androidx_test_espresso_version = '3.5.1' } } plugins { - id 'com.android.application' version "$agp_version" apply false - id 'com.android.library' version "$agp_version" apply false - id 'androidx.navigation.safeargs' version "$nav_version" apply false + id 'com.android.application' version "$android_gradle_plugin_version" apply false + id 'com.android.library' version "$android_gradle_plugin_version" apply false + id 'androidx.navigation.safeargs' version "$androidx_navigation_version" apply false } /** Version Settings, loaded from file `version.properties` */ diff --git a/gradle.properties b/gradle.properties index a9e2aa41..027a3997 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,6 +7,5 @@ org.gradle.configureondemand = true org.gradle.workers.max = 6 org.gradle.parallel = true -android.suppressUnsupportedCompileSdk = 34 android.enableJetifier = false android.useAndroidX = true diff --git a/library/build.gradle b/library/build.gradle index 4f01f1e1..8866a5a4 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -68,18 +68,18 @@ dependencies { implementation "com.google.android.material:material:$material_design_version" // Annotations - implementation "androidx.annotation:annotation:$annotation_version" + implementation "androidx.annotation:annotation:$androidx_annotation_version" // App Compat - implementation "androidx.appcompat:appcompat:$appcompat_version" + implementation "androidx.appcompat:appcompat:$androidx_appcompat_version" // Data-Binding Runtime - implementation "androidx.databinding:databinding-runtime:$agp_version" + implementation "androidx.databinding:databinding-runtime:$android_gradle_plugin_version" // Room Runtime - annotationProcessor "androidx.room:room-compiler:$room_version" - testImplementation "androidx.room:room-testing:$room_version" - implementation "androidx.room:room-runtime:$room_version" + annotationProcessor "androidx.room:room-compiler:$androidx_room_version" + testImplementation "androidx.room:room-testing:$androidx_room_version" + implementation "androidx.room:room-runtime:$androidx_room_version" // Retrofit2 implementation "com.google.code.gson:gson:$gson_version" @@ -89,7 +89,7 @@ dependencies { } testImplementation "junit:junit:$junit_version" - androidTestImplementation "androidx.test.ext:junit:$test_junit_version" + androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit_version" } tasks.register('javadoc', Javadoc) { diff --git a/mobile/build.gradle b/mobile/build.gradle index a0db459e..e5564373 100644 --- a/mobile/build.gradle +++ b/mobile/build.gradle @@ -112,30 +112,30 @@ dependencies { implementation "com.google.android.material:material:$material_design_version" // Annotations - implementation "androidx.annotation:annotation:$annotation_version" + implementation "androidx.annotation:annotation:$androidx_annotation_version" // Flexbox Layout implementation "com.google.android.flexbox:flexbox:$flexbox_version" // https://developer.android.com/jetpack/androidx/ - implementation "androidx.appcompat:appcompat:$appcompat_version" - implementation "androidx.core:core-splashscreen:$splash_version" - implementation "androidx.recyclerview:recyclerview:$recyclerview_version" - implementation "androidx.preference:preference:$preference_version" - implementation "androidx.cardview:cardview:$cardview_version" + implementation "androidx.appcompat:appcompat:$androidx_appcompat_version" + implementation "androidx.core:core-splashscreen:$androidx_splash_version" + implementation "androidx.recyclerview:recyclerview:$androidx_recyclerview_version" + implementation "androidx.preference:preference:$androidx_preference_version" + implementation "androidx.cardview:cardview:$androidx_cardview_version" // Navigation - androidTestImplementation "androidx.navigation:navigation-testing:$nav_version" - implementation "androidx.navigation:navigation-fragment:$nav_version" + androidTestImplementation "androidx.navigation:navigation-testing:$androidx_navigation_version" + implementation "androidx.navigation:navigation-fragment:$androidx_navigation_version" // Fragment - androidTestImplementation "androidx.fragment:fragment-testing:$fragment_version" - implementation "androidx.fragment:fragment:$fragment_version" + androidTestImplementation "androidx.fragment:fragment-testing:$androidx_fragment_version" + implementation "androidx.fragment:fragment:$androidx_fragment_version" // Room Runtime - annotationProcessor "androidx.room:room-compiler:$room_version" - testImplementation "androidx.room:room-testing:$room_version" - implementation "androidx.room:room-runtime:$room_version" + annotationProcessor "androidx.room:room-compiler:$androidx_room_version" + testImplementation "androidx.room:room-testing:$androidx_room_version" + implementation "androidx.room:room-runtime:$androidx_room_version" // Retrofit2 implementation "com.google.code.gson:gson:$gson_version" @@ -156,30 +156,30 @@ dependencies { // Required for connected tests. // https://mvnrepository.com/artifact/androidx.test/monitor - debugImplementation "androidx.test:monitor:$test_monitor_version" + debugImplementation "androidx.test:monitor:$androidx_test_monitor_version" // https://mvnrepository.com/artifact/androidx.test.ext - androidTestImplementation "androidx.test.ext:junit:$test_junit_version" + androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit_version" // https://mvnrepository.com/artifact/androidx.test // https://developer.android.com/jetpack/androidx/releases/test - androidTestImplementation "androidx.test:core:$test_core_version" - androidTestImplementation "androidx.test:runner:$test_runner_version" - androidTestImplementation "androidx.test:rules:$test_rules_version" + androidTestImplementation "androidx.test:core:$androidx_test_core_version" + androidTestImplementation "androidx.test:runner:$androidx_test_runner_version" + androidTestImplementation "androidx.test:rules:$androidx_test_rules_version" // https://mvnrepository.com/artifact/androidx.test.uiautomator/uiautomator - androidTestImplementation "androidx.test.uiautomator:uiautomator:$uiautomator_version" + androidTestImplementation "androidx.test.uiautomator:uiautomator:$androidx_test_uiautomator_version" // Espresso - androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version" - // androidTestImplementation "androidx.test.espresso:espresso-contrib:$espresso_version" - // androidTestImplementation "androidx.test.espresso:espresso-intents:$espresso_version" - // androidTestImplementation "androidx.test.espresso:espresso-accessibility:$espresso_version" - androidTestImplementation "androidx.test.espresso:espresso-web:$espresso_version" + androidTestImplementation "androidx.test.espresso:espresso-core:$androidx_test_espresso_version" + // androidTestImplementation "androidx.test.espresso:espresso-contrib:$androidx_test_espresso_version" + // androidTestImplementation "androidx.test.espresso:espresso-intents:$androidx_test_espresso_version" + // androidTestImplementation "androidx.test.espresso:espresso-accessibility:$androidx_test_espresso_version" + androidTestImplementation "androidx.test.espresso:espresso-web:$androidx_test_espresso_version" // androidTestImplementation "androidx.test.espresso.idling:idling-concurrent:$espresso_version" // The following dependency can be either "implementation" or "androidTestImplementation", // depending on whether you want it to appear on your APK's compile classpath or the test APK classpath. - // androidTestImplementation "androidx.test.espresso:espresso-idling-resource:$espresso_version" + // androidTestImplementation "androidx.test.espresso:espresso-idling-resource:$androidx_test_espresso_version" } diff --git a/mobile/src/androidTest/java/io/syslogic/github/TestProfile.java b/mobile/src/androidTest/java/io/syslogic/github/TestProfile.java index 39823340..ee1bf2b9 100644 --- a/mobile/src/androidTest/java/io/syslogic/github/TestProfile.java +++ b/mobile/src/androidTest/java/io/syslogic/github/TestProfile.java @@ -1,17 +1,17 @@ package io.syslogic.github; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiObject2; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; /** * Profile Test Case diff --git a/mobile/src/androidTest/java/io/syslogic/github/TestRepositories.java b/mobile/src/androidTest/java/io/syslogic/github/TestRepositories.java index a3a582a9..5c1621e5 100644 --- a/mobile/src/androidTest/java/io/syslogic/github/TestRepositories.java +++ b/mobile/src/androidTest/java/io/syslogic/github/TestRepositories.java @@ -1,17 +1,17 @@ package io.syslogic.github; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiObject2; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; /** * Repositories Test Case diff --git a/mobile/src/androidTest/java/io/syslogic/github/TestRepository.java b/mobile/src/androidTest/java/io/syslogic/github/TestRepository.java index 91869887..4a50e9e5 100644 --- a/mobile/src/androidTest/java/io/syslogic/github/TestRepository.java +++ b/mobile/src/androidTest/java/io/syslogic/github/TestRepository.java @@ -1,17 +1,17 @@ package io.syslogic.github; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiObject2; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; /** * Repository Test Case diff --git a/mobile/src/androidTest/java/io/syslogic/github/TestSuite.java b/mobile/src/androidTest/java/io/syslogic/github/TestSuite.java index f118d896..4bdabd25 100644 --- a/mobile/src/androidTest/java/io/syslogic/github/TestSuite.java +++ b/mobile/src/androidTest/java/io/syslogic/github/TestSuite.java @@ -1,10 +1,5 @@ package io.syslogic.github; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.core.IsNull.notNullValue; - import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -14,6 +9,12 @@ import android.os.Bundle; import android.util.Log; +import org.junit.Assert; +import org.junit.runner.RunWith; +import org.junit.runners.Suite.SuiteClasses; + +import java.util.List; + import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.uiautomator.By; import androidx.test.uiautomator.Direction; @@ -25,11 +26,10 @@ import androidx.test.uiautomator.UiSelector; import androidx.test.uiautomator.Until; -import org.junit.Assert; -import org.junit.runner.RunWith; -import org.junit.runners.Suite.SuiteClasses; - -import java.util.List; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.core.IsNull.notNullValue; /** * Application Test Suite diff --git a/mobile/src/main/java/io/syslogic/github/activity/AuthenticatorActivity.java b/mobile/src/main/java/io/syslogic/github/activity/AuthenticatorActivity.java index 2a17f32b..3e9bfd66 100644 --- a/mobile/src/main/java/io/syslogic/github/activity/AuthenticatorActivity.java +++ b/mobile/src/main/java/io/syslogic/github/activity/AuthenticatorActivity.java @@ -8,16 +8,16 @@ import android.util.Log; import android.widget.Toast; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.annotation.VisibleForTesting; -import androidx.databinding.ViewDataBinding; - import com.google.gson.JsonObject; import com.google.gson.JsonParser; import java.io.IOException; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; +import androidx.databinding.ViewDataBinding; + import io.syslogic.github.BuildConfig; import io.syslogic.github.R; import io.syslogic.github.api.GithubClient; diff --git a/mobile/src/main/java/io/syslogic/github/activity/NavHostActivity.java b/mobile/src/main/java/io/syslogic/github/activity/NavHostActivity.java index 2f892714..3cc5e740 100644 --- a/mobile/src/main/java/io/syslogic/github/activity/NavHostActivity.java +++ b/mobile/src/main/java/io/syslogic/github/activity/NavHostActivity.java @@ -2,6 +2,8 @@ import android.os.Bundle; +import androidx.activity.OnBackPressedCallback; +import androidx.activity.OnBackPressedDispatcher; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; @@ -50,6 +52,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { this.setDataBinding(FragmentNavHostBinding .inflate(getLayoutInflater(), findViewById(android.R.id.content), true)); + this.addBackPressedCallback(); this.setNavController(); } @@ -61,6 +64,22 @@ private void setNavController() { } } + /** + * Register an {@link OnBackPressedCallback]} with the {@link OnBackPressedDispatcher}. + * The callback either pops the FragmentManager's back-stack - or it navigates upwards. + */ + private void addBackPressedCallback() { + getOnBackPressedDispatcher().addCallback(NavHostActivity.this, new OnBackPressedCallback(true) { + @Override + public void handleOnBackPressed() { + if (getSupportFragmentManager().getBackStackEntryCount() > 0) { + getSupportFragmentManager().popBackStack(); + } else { + getNavController().navigateUp(); + } + } + }); + } public NavController getNavController() { return this.navController; } diff --git a/mobile/src/main/java/io/syslogic/github/adapter/BaseArrayAdapter.java b/mobile/src/main/java/io/syslogic/github/adapter/BaseArrayAdapter.java index f7d2f3fc..a8f413d5 100644 --- a/mobile/src/main/java/io/syslogic/github/adapter/BaseArrayAdapter.java +++ b/mobile/src/main/java/io/syslogic/github/adapter/BaseArrayAdapter.java @@ -7,14 +7,14 @@ import android.view.ViewGroup; import android.widget.BaseAdapter; +import java.util.ArrayList; +import java.util.List; + import androidx.annotation.ArrayRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatTextView; -import java.util.ArrayList; -import java.util.List; - import io.syslogic.github.R; import io.syslogic.github.model.SpinnerItem; diff --git a/mobile/src/main/java/io/syslogic/github/adapter/QueryStringAdapter.java b/mobile/src/main/java/io/syslogic/github/adapter/QueryStringAdapter.java index 3bfcc55d..9e271825 100644 --- a/mobile/src/main/java/io/syslogic/github/adapter/QueryStringAdapter.java +++ b/mobile/src/main/java/io/syslogic/github/adapter/QueryStringAdapter.java @@ -4,14 +4,13 @@ import android.content.Context; import android.util.Log; -import androidx.annotation.NonNull; - import java.util.List; +import androidx.annotation.NonNull; import io.syslogic.github.api.model.QueryString; -import io.syslogic.github.model.SpinnerItem; import io.syslogic.github.api.room.Abstraction; import io.syslogic.github.api.room.QueryStringsDao; +import io.syslogic.github.model.SpinnerItem; /** * Query-String {@link BaseArrayAdapter} diff --git a/mobile/src/main/java/io/syslogic/github/content/RepositoryProvider.java b/mobile/src/main/java/io/syslogic/github/content/RepositoryProvider.java index 1f987cf5..7be33461 100644 --- a/mobile/src/main/java/io/syslogic/github/content/RepositoryProvider.java +++ b/mobile/src/main/java/io/syslogic/github/content/RepositoryProvider.java @@ -7,11 +7,11 @@ import android.database.Cursor; import android.net.Uri; +import java.util.Objects; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import java.util.Objects; - import io.syslogic.github.Constants; import io.syslogic.github.api.model.Repository; import io.syslogic.github.api.room.Abstraction; diff --git a/mobile/src/main/java/io/syslogic/github/content/RepositorySyncAdapter.java b/mobile/src/main/java/io/syslogic/github/content/RepositorySyncAdapter.java index 2e0cac63..5f43ac99 100644 --- a/mobile/src/main/java/io/syslogic/github/content/RepositorySyncAdapter.java +++ b/mobile/src/main/java/io/syslogic/github/content/RepositorySyncAdapter.java @@ -9,15 +9,15 @@ import android.os.Bundle; import android.util.Log; -import androidx.annotation.NonNull; -import androidx.preference.PreferenceManager; - import com.google.gson.JsonObject; import com.google.gson.JsonParser; import java.io.IOException; import java.util.ArrayList; +import androidx.annotation.NonNull; +import androidx.preference.PreferenceManager; + import io.syslogic.github.BuildConfig; import io.syslogic.github.Constants; import io.syslogic.github.api.GithubClient; diff --git a/mobile/src/main/java/io/syslogic/github/dialog/ProgressDialogFragment.java b/mobile/src/main/java/io/syslogic/github/dialog/ProgressDialogFragment.java index ae2a1764..df0ab793 100644 --- a/mobile/src/main/java/io/syslogic/github/dialog/ProgressDialogFragment.java +++ b/mobile/src/main/java/io/syslogic/github/dialog/ProgressDialogFragment.java @@ -8,13 +8,13 @@ import android.view.View; import android.view.ViewGroup; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - import org.eclipse.jgit.lib.ProgressMonitor; import java.util.Locale; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import io.syslogic.github.R; import io.syslogic.github.databinding.DialogProgressBinding; diff --git a/mobile/src/main/java/io/syslogic/github/fragment/BaseFragment.java b/mobile/src/main/java/io/syslogic/github/fragment/BaseFragment.java index 1d27f3fe..9099c28e 100644 --- a/mobile/src/main/java/io/syslogic/github/fragment/BaseFragment.java +++ b/mobile/src/main/java/io/syslogic/github/fragment/BaseFragment.java @@ -10,8 +10,16 @@ import android.os.Build; import android.os.Bundle; import android.util.Log; +import android.view.LayoutInflater; +import android.view.ViewGroup; import android.widget.Toast; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import java.io.IOException; +import java.util.Objects; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; @@ -19,12 +27,6 @@ import androidx.fragment.app.Fragment; import androidx.preference.PreferenceManager; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import java.io.IOException; -import java.util.Objects; - import io.syslogic.github.BuildConfig; import io.syslogic.github.Constants; import io.syslogic.github.R; @@ -159,10 +161,10 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis } } - @NonNull - abstract public ViewDataBinding getDataBinding(); + protected abstract void setDataBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container); - abstract protected void setDataBinding(@NonNull ViewDataBinding binding); + @NonNull + public abstract ViewDataBinding getDataBinding(); @Nullable protected String getAccessToken() { diff --git a/mobile/src/main/java/io/syslogic/github/fragment/HomeScreenFragment.java b/mobile/src/main/java/io/syslogic/github/fragment/HomeScreenFragment.java index 70d11faf..da7cec8b 100644 --- a/mobile/src/main/java/io/syslogic/github/fragment/HomeScreenFragment.java +++ b/mobile/src/main/java/io/syslogic/github/fragment/HomeScreenFragment.java @@ -9,14 +9,13 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.databinding.ViewDataBinding; import io.syslogic.github.R; import io.syslogic.github.activity.NavHostActivity; import io.syslogic.github.api.model.User; import io.syslogic.github.databinding.FragmentHomeScreenBinding; -import io.syslogic.github.network.TokenCallback; import io.syslogic.github.menu.HomeScreenMenuProvider; +import io.syslogic.github.network.TokenCallback; /** * Home Screen {@link BaseFragment} @@ -45,7 +44,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c NavHostActivity activity = ((NavHostActivity) this.requireActivity()); activity.setMenuProvider(new HomeScreenMenuProvider(activity)); - this.setDataBinding(FragmentHomeScreenBinding.inflate(inflater, container, false)); + this.setDataBinding(inflater, container); activity.setSupportActionBar(this.getDataBinding().toolbarHomeScreen.toolbarHomeScreen); if (! isNetworkAvailable(activity)) { @@ -76,16 +75,6 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c return this.mDataBinding.getRoot(); } - @NonNull - public FragmentHomeScreenBinding getDataBinding() { - return this.mDataBinding; - } - - @Override - protected void setDataBinding(@NonNull ViewDataBinding binding) { - this.mDataBinding = (FragmentHomeScreenBinding) binding; - } - @Override public void onNetworkAvailable() { super.onNetworkAvailable(); @@ -100,4 +89,15 @@ public void onNetworkLost() { public void onLogin(@NonNull User item) { this.mDataBinding.setUser(item); } + + @Override + protected void setDataBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) { + this.mDataBinding = FragmentHomeScreenBinding.inflate(inflater, container, false); + } + + @NonNull + @Override + public FragmentHomeScreenBinding getDataBinding() { + return this.mDataBinding; + } } diff --git a/mobile/src/main/java/io/syslogic/github/fragment/PreferencesFragment.java b/mobile/src/main/java/io/syslogic/github/fragment/PreferencesFragment.java index 18038617..68781071 100644 --- a/mobile/src/main/java/io/syslogic/github/fragment/PreferencesFragment.java +++ b/mobile/src/main/java/io/syslogic/github/fragment/PreferencesFragment.java @@ -15,6 +15,9 @@ import android.provider.Settings; import android.util.Log; +import java.io.File; +import java.util.Objects; + import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; @@ -25,9 +28,6 @@ import androidx.preference.PreferenceManager; import androidx.preference.PreferenceScreen; -import java.io.File; -import java.util.Objects; - import io.syslogic.github.BuildConfig; import io.syslogic.github.Constants; import io.syslogic.github.R; diff --git a/mobile/src/main/java/io/syslogic/github/fragment/ProfileFragment.java b/mobile/src/main/java/io/syslogic/github/fragment/ProfileFragment.java index 644f790f..f3c147f7 100644 --- a/mobile/src/main/java/io/syslogic/github/fragment/ProfileFragment.java +++ b/mobile/src/main/java/io/syslogic/github/fragment/ProfileFragment.java @@ -12,7 +12,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; -import androidx.databinding.ViewDataBinding; import io.syslogic.github.Constants; import io.syslogic.github.R; @@ -55,25 +54,21 @@ public void onCreate(@Nullable Bundle savedInstanceState) { @Override @SuppressLint("SetJavaScriptEnabled") public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - this.setDataBinding(FragmentProfileBinding.inflate(inflater, container, false)); - if (this.getContext() != null) { - - if (! isNetworkAvailable(this.getContext())) { - this.onNetworkLost(); - } else { - - this.mDataBinding.webview.getSettings().setJavaScriptEnabled(true); - this.mDataBinding.webview.setWebViewClient(new WebViewClient() { - @Override - public void onPageCommitVisible (WebView view, String url) { - if (! contentLoaded) {contentLoaded = true;} - } - }); - - String token = this.getAccessToken(); - if (getCurrentUser() == null && token != null) { - this.setUser(token, this); + this.setDataBinding(inflater, container); + if (! isNetworkAvailable(this.requireContext())) { + this.onNetworkLost(); + } else { + this.mDataBinding.webview.getSettings().setJavaScriptEnabled(true); + this.mDataBinding.webview.setWebViewClient(new WebViewClient() { + @Override + public void onPageCommitVisible (WebView view, String url) { + if (! contentLoaded) {contentLoaded = true;} } + }); + + String token = this.getAccessToken(); + if (getCurrentUser() == null && token != null) { + this.setUser(token, this); } } return this.mDataBinding.getRoot(); @@ -88,16 +83,6 @@ private void setItemId(@NonNull Long value) { this.itemId = value; } - @NonNull - public FragmentProfileBinding getDataBinding() { - return this.mDataBinding; - } - - @Override - protected void setDataBinding(@NonNull ViewDataBinding binding) { - this.mDataBinding = (FragmentProfileBinding) binding; - } - @Override public void onNetworkAvailable() { super.onNetworkAvailable(); @@ -120,4 +105,15 @@ public void onLogin(@NonNull User item) { this.mDataBinding.setProfile(item); } } + + @Override + protected void setDataBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) { + this.mDataBinding = FragmentProfileBinding.inflate(inflater, container, false); + } + + @NonNull + @Override + public FragmentProfileBinding getDataBinding() { + return this.mDataBinding; + } } diff --git a/mobile/src/main/java/io/syslogic/github/fragment/QueryStringFragment.java b/mobile/src/main/java/io/syslogic/github/fragment/QueryStringFragment.java index fc4cdfcc..8fadd157 100644 --- a/mobile/src/main/java/io/syslogic/github/fragment/QueryStringFragment.java +++ b/mobile/src/main/java/io/syslogic/github/fragment/QueryStringFragment.java @@ -12,7 +12,6 @@ import androidx.appcompat.app.ActionBar; import androidx.databinding.BindingMethod; import androidx.databinding.BindingMethods; -import androidx.databinding.ViewDataBinding; import androidx.navigation.NavController; import androidx.navigation.Navigation; @@ -65,8 +64,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { @NonNull @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - - this.setDataBinding(FragmentQueryStringBinding.inflate(inflater, container, false)); + this.setDataBinding(inflater, container); BaseActivity activity = ((BaseActivity) this.requireActivity()); activity.setSupportActionBar(this.getDataBinding().toolbarQueryString.toolbarQueryString); @@ -116,13 +114,14 @@ private void setItemId(@NonNull Long value) { this.itemId = value; } - @NonNull - public FragmentQueryStringBinding getDataBinding() { - return this.mDataBinding; + @Override + protected void setDataBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) { + this.mDataBinding = FragmentQueryStringBinding.inflate(inflater, container, false); } + @NonNull @Override - protected void setDataBinding(@NonNull ViewDataBinding binding) { - this.mDataBinding = (FragmentQueryStringBinding) binding; + public FragmentQueryStringBinding getDataBinding() { + return this.mDataBinding; } } diff --git a/mobile/src/main/java/io/syslogic/github/fragment/QueryStringsFragment.java b/mobile/src/main/java/io/syslogic/github/fragment/QueryStringsFragment.java index fe8cf8ac..e002418b 100644 --- a/mobile/src/main/java/io/syslogic/github/fragment/QueryStringsFragment.java +++ b/mobile/src/main/java/io/syslogic/github/fragment/QueryStringsFragment.java @@ -8,7 +8,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; -import androidx.databinding.ViewDataBinding; import androidx.navigation.NavController; import androidx.navigation.Navigation; @@ -41,7 +40,7 @@ public QueryStringsFragment() {} @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { BaseActivity activity = ((BaseActivity) this.requireActivity()); - this.setDataBinding(FragmentQueryStringsBinding.inflate(inflater, container, false)); + this.setDataBinding(inflater, container); /* Setting up the toolbar, in order to show the topics editor. */ activity.setSupportActionBar(this.getDataBinding().toolbarQueryStrings.toolbarQueryStrings); @@ -67,13 +66,14 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c return this.getDataBinding().getRoot(); } - @NonNull - public FragmentQueryStringsBinding getDataBinding() { - return this.mDataBinding; + @Override + protected void setDataBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) { + this.mDataBinding = FragmentQueryStringsBinding.inflate(inflater, container, false); } + @NonNull @Override - protected void setDataBinding(@NonNull ViewDataBinding binding) { - this.mDataBinding = (FragmentQueryStringsBinding) binding; + public FragmentQueryStringsBinding getDataBinding() { + return this.mDataBinding; } } diff --git a/mobile/src/main/java/io/syslogic/github/fragment/RepositoriesFragment.java b/mobile/src/main/java/io/syslogic/github/fragment/RepositoriesFragment.java index 4436693e..2f58c4cf 100644 --- a/mobile/src/main/java/io/syslogic/github/fragment/RepositoriesFragment.java +++ b/mobile/src/main/java/io/syslogic/github/fragment/RepositoriesFragment.java @@ -9,19 +9,18 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatSpinner; -import androidx.databinding.ViewDataBinding; import io.syslogic.github.R; import io.syslogic.github.activity.NavHostActivity; import io.syslogic.github.adapter.RepositoryTypeAdapter; import io.syslogic.github.adapter.SortFieldListingAdapter; import io.syslogic.github.adapter.SortOrderAdapter; -import io.syslogic.github.model.SpinnerItem; import io.syslogic.github.api.model.User; import io.syslogic.github.databinding.FragmentRepositoriesBinding; +import io.syslogic.github.menu.RepositoriesMenuProvider; import io.syslogic.github.model.PagerState; +import io.syslogic.github.model.SpinnerItem; import io.syslogic.github.network.TokenCallback; -import io.syslogic.github.menu.RepositoriesMenuProvider; import io.syslogic.github.recyclerview.RepositoriesAdapter; import io.syslogic.github.recyclerview.RepositoriesLinearView; import io.syslogic.github.recyclerview.ScrollListener; @@ -48,16 +47,17 @@ public RepositoriesFragment() {} @NonNull @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - - NavHostActivity activity = ((NavHostActivity) this.requireActivity()); - this.setDataBinding(FragmentRepositoriesBinding.inflate(inflater, container, false)); + this.setDataBinding(inflater, container); this.getDataBinding().setPagerState(new PagerState()); /* It removes & adds {@link BaseMenuProvider} */ + NavHostActivity activity = ((NavHostActivity) this.requireActivity()); activity.setMenuProvider(new RepositoriesMenuProvider(activity)); activity.setSupportActionBar(this.getDataBinding().toolbarRepositories.toolbarRepositories); - this.mDataBinding.toolbarRepositories.home.setOnClickListener(view -> activity.onBackPressed()); + this.mDataBinding.toolbarRepositories.home.setOnClickListener(view -> { + activity.getOnBackPressedDispatcher().onBackPressed(); + }); /* {@link AppCompatSpinner} spinner_repository_type */ AppCompatSpinner spinnerRepositoryType = this.getDataBinding().toolbarRepositories.spinnerRepositoryType; @@ -158,16 +158,6 @@ public void onNothingSelected(AdapterView parent) {} return this.getDataBinding().getRoot(); } - @NonNull - public FragmentRepositoriesBinding getDataBinding() { - return this.mDataBinding; - } - - @Override - protected void setDataBinding(@NonNull ViewDataBinding binding) { - this.mDataBinding = (FragmentRepositoriesBinding) binding; - } - @Override public void onNetworkAvailable() { super.onNetworkAvailable(); @@ -207,4 +197,15 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis public void onLogin(@NonNull User item) { if (this.mDataBinding != null) {this.mDataBinding.setUser(item);} } + + @Override + protected void setDataBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) { + this.mDataBinding = FragmentRepositoriesBinding.inflate(inflater, container, false); + } + + @NonNull + @Override + public FragmentRepositoriesBinding getDataBinding() { + return this.mDataBinding; + } } diff --git a/mobile/src/main/java/io/syslogic/github/fragment/RepositoryFragment.java b/mobile/src/main/java/io/syslogic/github/fragment/RepositoryFragment.java index d488c1a6..a2a6db42 100644 --- a/mobile/src/main/java/io/syslogic/github/fragment/RepositoryFragment.java +++ b/mobile/src/main/java/io/syslogic/github/fragment/RepositoryFragment.java @@ -21,11 +21,6 @@ import android.widget.AdapterView; import android.widget.Toast; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.AppCompatSpinner; -import androidx.databinding.ViewDataBinding; - import com.google.gson.JsonObject; import com.google.gson.JsonParser; @@ -40,6 +35,9 @@ import java.io.IOException; import java.util.ArrayList; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatSpinner; import io.syslogic.github.Constants; import io.syslogic.github.R; import io.syslogic.github.api.GithubClient; @@ -103,88 +101,85 @@ public void onCreate(@Nullable Bundle savedInstanceState) { @Override @SuppressLint("SetJavaScriptEnabled") public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - this.setDataBinding(FragmentRepositoryBinding.inflate(inflater, container, false)); + this.setDataBinding(inflater, container); + if (! isNetworkAvailable(this.requireContext())) { + this.onNetworkLost(); + } else { - if (this.getContext() != null) { - if (! isNetworkAvailable(this.getContext())) { - this.onNetworkLost(); - } else { - - this.mDataBinding.webview.getSettings().setJavaScriptEnabled(true); - this.mDataBinding.webview.setWebViewClient(new WebViewClient() { - @Override - public void onPageCommitVisible (WebView view, String url) { - contentLoaded = true; - if (getDataBinding().viewflipperContent.getDisplayedChild() == 0) { - getDataBinding().viewflipperContent.showNext(); - } + this.mDataBinding.webview.getSettings().setJavaScriptEnabled(true); + this.mDataBinding.webview.setWebViewClient(new WebViewClient() { + @Override + public void onPageCommitVisible (WebView view, String url) { + contentLoaded = true; + if (getDataBinding().viewflipperContent.getDisplayedChild() == 0) { + getDataBinding().viewflipperContent.showNext(); } - }); - this.getRepository(this.repositoryId); - - this.mDataBinding.toolbarDownload.spinnerBranch.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { - int count = 0; - @Override - public void onItemSelected(AdapterView parent, View view, int position, long id) { - if (count > 0) { - WebView webview = getDataBinding().webview; - AppCompatSpinner spinner = getDataBinding().toolbarDownload.spinnerBranch; - String branch = spinner.getSelectedItem().toString(); - String url = webview.getUrl(); - - if (url != null) { - if (url.equals("https://github.com/" + getDataBinding().getRepository().getFullName())) { - url += "/tree/" + branch; - } else { - Uri uri = Uri.parse(url); - String token = uri.getLastPathSegment(); - if (token != null) { - url = url.replace(token, branch); - } + } + }); + this.getRepository(this.repositoryId); + + this.mDataBinding.toolbarDownload.spinnerBranch.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + int count = 0; + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + if (count > 0) { + WebView webview = getDataBinding().webview; + AppCompatSpinner spinner = getDataBinding().toolbarDownload.spinnerBranch; + String branch = spinner.getSelectedItem().toString(); + String url = webview.getUrl(); + + if (url != null) { + if (url.equals("https://github.com/" + getDataBinding().getRepository().getFullName())) { + url += "/tree/" + branch; + } else { + Uri uri = Uri.parse(url); + String token = uri.getLastPathSegment(); + if (token != null) { + url = url.replace(token, branch); } - url = url.replace("/tree/master", ""); - if (mDebug) {Log.d(LOG_TAG, url);} - webview.loadUrl(url); } + url = url.replace("/tree/master", ""); + if (mDebug) {Log.d(LOG_TAG, url);} + webview.loadUrl(url); } - count++; } - @Override - public void onNothingSelected(AdapterView parent) {} - }); + count++; + } + @Override + public void onNothingSelected(AdapterView parent) {} + }); - /* The download button; TODO: consider tarball? */ - this.mDataBinding.toolbarDownload.buttonDownload.setOnClickListener(view -> { - String branch = getDataBinding().toolbarDownload.spinnerBranch.getSelectedItem().toString(); - downloadBranchAsZip(branch); - }); + /* The download button; TODO: consider tarball? */ + this.mDataBinding.toolbarDownload.buttonDownload.setOnClickListener(view -> { + String branch = getDataBinding().toolbarDownload.spinnerBranch.getSelectedItem().toString(); + downloadBranchAsZip(branch); + }); - /* The git clone button (experimental). */ - this.mDataBinding.toolbarDownload.buttonClone.setOnClickListener(view -> { - assert this.prefs != null; - String directory = this.prefs.getString(Constants.PREFERENCE_KEY_WORKSPACE_DIRECTORY, Environment.getExternalStorageDirectory() + "/Workspace"); - String name = getDataBinding().getRepository().getName(); - File destination = new File(directory + "/" + name); - - // directory should be empty. - if (destination.exists()) { - if (! destination.delete()) { - Log.e(LOG_TAG, "destination directory not deleted"); - return; - } + /* The git clone button (experimental). */ + this.mDataBinding.toolbarDownload.buttonClone.setOnClickListener(view -> { + assert this.prefs != null; + String directory = this.prefs.getString(Constants.PREFERENCE_KEY_WORKSPACE_DIRECTORY, Environment.getExternalStorageDirectory() + "/Workspace"); + String name = getDataBinding().getRepository().getName(); + File destination = new File(directory + "/" + name); + + // directory should be empty. + if (destination.exists()) { + if (! destination.delete()) { + Log.e(LOG_TAG, "destination directory not deleted"); + return; } - if (! destination.exists()) { - if (! destination.mkdir()) { - Log.e(LOG_TAG, "destination directory not created"); - return; - } - } - if (destination.exists() && destination.isDirectory()) { - String branch = getDataBinding().toolbarDownload.spinnerBranch.getSelectedItem().toString(); - gitClone(destination, branch); + } + if (! destination.exists()) { + if (! destination.mkdir()) { + Log.e(LOG_TAG, "destination directory not created"); + return; } - }); - } + } + if (destination.exists() && destination.isDirectory()) { + String branch = getDataBinding().toolbarDownload.spinnerBranch.getSelectedItem().toString(); + gitClone(destination, branch); + } + }); } return this.mDataBinding.getRoot(); } @@ -247,16 +242,6 @@ private String getRepoUrl() { .replace("api.github.com/repos", "github.com") + ".git"; } - @NonNull - public FragmentRepositoryBinding getDataBinding() { - return this.mDataBinding; - } - - @Override - protected void setDataBinding(@NonNull ViewDataBinding binding) { - this.mDataBinding = (FragmentRepositoryBinding) binding; - } - @Override public void onNetworkAvailable() { super.onNetworkAvailable(); @@ -523,4 +508,15 @@ public void showDownloads() { @Override public void onLogin(@NonNull User item) {} + + @Override + protected void setDataBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) { + this.mDataBinding = FragmentRepositoryBinding.inflate(inflater, container, false); + } + + @NonNull + @Override + public FragmentRepositoryBinding getDataBinding() { + return this.mDataBinding; + } } diff --git a/mobile/src/main/java/io/syslogic/github/fragment/RepositorySearchFragment.java b/mobile/src/main/java/io/syslogic/github/fragment/RepositorySearchFragment.java index a91d5656..47a48d22 100644 --- a/mobile/src/main/java/io/syslogic/github/fragment/RepositorySearchFragment.java +++ b/mobile/src/main/java/io/syslogic/github/fragment/RepositorySearchFragment.java @@ -7,26 +7,25 @@ import android.view.ViewGroup; import android.widget.AdapterView; +import java.util.List; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatSpinner; -import androidx.databinding.ViewDataBinding; - -import java.util.List; import io.syslogic.github.Constants; import io.syslogic.github.R; import io.syslogic.github.activity.NavHostActivity; import io.syslogic.github.adapter.QueryStringAdapter; import io.syslogic.github.api.model.QueryString; -import io.syslogic.github.model.SpinnerItem; import io.syslogic.github.api.model.User; import io.syslogic.github.api.room.Abstraction; import io.syslogic.github.api.room.QueryStringsDao; import io.syslogic.github.databinding.FragmentRepositorySearchBinding; +import io.syslogic.github.menu.RepositorySearchMenuProvider; import io.syslogic.github.model.PagerState; +import io.syslogic.github.model.SpinnerItem; import io.syslogic.github.network.TokenCallback; -import io.syslogic.github.menu.RepositorySearchMenuProvider; import io.syslogic.github.recyclerview.RepositorySearchAdapter; import io.syslogic.github.recyclerview.RepositorySearchLinearView; import io.syslogic.github.recyclerview.ScrollListener; @@ -59,7 +58,7 @@ public RepositorySearchFragment() {} public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { NavHostActivity activity = ((NavHostActivity) this.requireActivity()); - this.setDataBinding(FragmentRepositorySearchBinding.inflate(inflater, container, false)); + this.setDataBinding(inflater, container); this.getDataBinding().setPagerState(new PagerState()); /* It removes & adds {@link BaseMenuProvider} */ @@ -67,7 +66,9 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c /* the SpinnerItem has the same ID as the QueryString. */ activity.setSupportActionBar(this.getDataBinding().toolbarRepositorySearch.toolbarRepositorySearch); - this.mDataBinding.toolbarRepositorySearch.home.setOnClickListener(view -> activity.onBackPressed()); + this.mDataBinding.toolbarRepositorySearch.home.setOnClickListener(view -> { + activity.getOnBackPressedDispatcher().onBackPressed(); + }); AppCompatSpinner spinner = this.getDataBinding().toolbarRepositorySearch.spinnerQueryString; spinner.setAdapter(new QueryStringAdapter(requireContext())); @@ -134,18 +135,6 @@ public void onNothingSelected(AdapterView parent) {} return this.getDataBinding().getRoot(); } - @NonNull - public FragmentRepositorySearchBinding getDataBinding() { - return this.mDataBinding; - } - - @Override - protected void setDataBinding(@NonNull ViewDataBinding binding) { - if (binding instanceof FragmentRepositorySearchBinding) { - this.mDataBinding = (FragmentRepositorySearchBinding) binding; - } - } - @Override public void onNetworkAvailable() { @@ -203,4 +192,15 @@ public void onNetworkLost() { public void onLogin(@NonNull User item) { this.mDataBinding.setUser(item); } + + @Override + protected void setDataBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) { + this.mDataBinding = FragmentRepositorySearchBinding.inflate(inflater, container, false); + } + + @NonNull + @Override + public FragmentRepositorySearchBinding getDataBinding() { + return this.mDataBinding; + } } diff --git a/mobile/src/main/java/io/syslogic/github/fragment/WorkflowJobsFragment.java b/mobile/src/main/java/io/syslogic/github/fragment/WorkflowJobsFragment.java index d48dec80..7eada657 100644 --- a/mobile/src/main/java/io/syslogic/github/fragment/WorkflowJobsFragment.java +++ b/mobile/src/main/java/io/syslogic/github/fragment/WorkflowJobsFragment.java @@ -8,7 +8,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.databinding.ViewDataBinding; import io.syslogic.github.Constants; import io.syslogic.github.R; @@ -86,13 +85,15 @@ public void onCreate(@Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { NavHostActivity activity = ((NavHostActivity) this.requireActivity()); - this.setDataBinding(FragmentWorkflowJobsBinding.inflate(inflater, container, false)); + this.setDataBinding(inflater, container); /* It removes & adds {@link BaseMenuProvider} */ activity.setMenuProvider(new WorkflowsMenuProvider(activity)); activity.setSupportActionBar(this.getDataBinding().toolbarWorkflowJobs.toolbarWorkflowJobs); - this.mDataBinding.toolbarWorkflowJobs.home.setOnClickListener(view -> activity.onBackPressed()); + this.mDataBinding.toolbarWorkflowJobs.home.setOnClickListener(view -> { + activity.getOnBackPressedDispatcher().onBackPressed(); + }); // Recyclerview.Adapter WorkflowStepsAdapter adapter = new WorkflowStepsAdapter(requireContext()); @@ -167,16 +168,6 @@ private void setRunId(@NonNull Long value) { this.runId = value; } - @NonNull - public FragmentWorkflowJobsBinding getDataBinding() { - return this.mDataBinding; - } - - @Override - protected void setDataBinding(@NonNull ViewDataBinding binding) { - this.mDataBinding = (FragmentWorkflowJobsBinding) binding; - } - @Override public void onNetworkAvailable() { super.onNetworkAvailable(); @@ -192,4 +183,15 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis super.onRequestPermissionsResult(requestCode, permissions, grantResults); // if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {} } + + @Override + protected void setDataBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) { + this.mDataBinding = FragmentWorkflowJobsBinding.inflate(inflater, container, false); + } + + @NonNull + @Override + public FragmentWorkflowJobsBinding getDataBinding() { + return this.mDataBinding; + } } diff --git a/mobile/src/main/java/io/syslogic/github/fragment/WorkflowRunFragment.java b/mobile/src/main/java/io/syslogic/github/fragment/WorkflowRunFragment.java index 1e15debf..5245253e 100644 --- a/mobile/src/main/java/io/syslogic/github/fragment/WorkflowRunFragment.java +++ b/mobile/src/main/java/io/syslogic/github/fragment/WorkflowRunFragment.java @@ -8,7 +8,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.databinding.ViewDataBinding; import io.syslogic.github.Constants; import io.syslogic.github.R; @@ -85,13 +84,15 @@ public void onCreate(@Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { NavHostActivity activity = ((NavHostActivity) this.requireActivity()); - this.setDataBinding(FragmentWorkflowRunBinding.inflate(inflater, container, false)); + this.setDataBinding(inflater, container); /* It removes & adds {@link BaseMenuProvider} */ activity.setMenuProvider(new WorkflowsMenuProvider(activity)); activity.setSupportActionBar(this.getDataBinding().toolbarWorkflowRun.toolbarWorkflowRun); - this.mDataBinding.toolbarWorkflowRun.home.setOnClickListener(view -> activity.onBackPressed()); + this.mDataBinding.toolbarWorkflowRun.home.setOnClickListener(view -> { + activity.getOnBackPressedDispatcher().onBackPressed(); + }); if (! isNetworkAvailable(this.requireContext())) { this.onNetworkLost(); @@ -175,16 +176,6 @@ private void setRunId(@NonNull Long value) { this.runId = value; } - @NonNull - public FragmentWorkflowRunBinding getDataBinding() { - return this.mDataBinding; - } - - @Override - protected void setDataBinding(@NonNull ViewDataBinding binding) { - this.mDataBinding = (FragmentWorkflowRunBinding) binding; - } - @Override public void onNetworkAvailable() { super.onNetworkAvailable(); @@ -200,4 +191,15 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis super.onRequestPermissionsResult(requestCode, permissions, grantResults); // if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {} } + + @Override + protected void setDataBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) { + this.mDataBinding = FragmentWorkflowRunBinding.inflate(inflater, container, false); + } + + @NonNull + @Override + public FragmentWorkflowRunBinding getDataBinding() { + return this.mDataBinding; + } } diff --git a/mobile/src/main/java/io/syslogic/github/fragment/WorkflowRunsFragment.java b/mobile/src/main/java/io/syslogic/github/fragment/WorkflowRunsFragment.java index fc24dd45..1dbbfe6c 100644 --- a/mobile/src/main/java/io/syslogic/github/fragment/WorkflowRunsFragment.java +++ b/mobile/src/main/java/io/syslogic/github/fragment/WorkflowRunsFragment.java @@ -8,7 +8,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.databinding.ViewDataBinding; import io.syslogic.github.Constants; import io.syslogic.github.R; @@ -79,13 +78,15 @@ public void onCreate(@Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { NavHostActivity activity = ((NavHostActivity) this.requireActivity()); - this.setDataBinding(FragmentWorkflowRunsBinding.inflate(inflater, container, false)); + this.setDataBinding(inflater, container); /* It removes & adds {@link BaseMenuProvider} */ activity.setMenuProvider(new WorkflowsMenuProvider(activity)); activity.setSupportActionBar(this.getDataBinding().toolbarWorkflowRuns.toolbarWorkflowRuns); - this.mDataBinding.toolbarWorkflowRuns.home.setOnClickListener(view -> activity.onBackPressed()); + this.mDataBinding.toolbarWorkflowRuns.home.setOnClickListener(view -> { + activity.getOnBackPressedDispatcher().onBackPressed(); + }); // Recyclerview.Adapter WorkflowRunsAdapter adapter = new WorkflowRunsAdapter(requireContext(), this.repositoryId); @@ -151,16 +152,6 @@ private void setRepositoryName(@NonNull String value) { this.repositoryName = value; } - @NonNull - public FragmentWorkflowRunsBinding getDataBinding() { - return this.mDataBinding; - } - - @Override - protected void setDataBinding(@NonNull ViewDataBinding binding) { - this.mDataBinding = (FragmentWorkflowRunsBinding) binding; - } - @Override public void onNetworkAvailable() { super.onNetworkAvailable(); @@ -176,4 +167,15 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis super.onRequestPermissionsResult(requestCode, permissions, grantResults); // if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {} } + + @Override + protected void setDataBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) { + this.mDataBinding = FragmentWorkflowRunsBinding.inflate(inflater, container, false); + } + + @NonNull + @Override + public FragmentWorkflowRunsBinding getDataBinding() { + return this.mDataBinding; + } } diff --git a/mobile/src/main/java/io/syslogic/github/fragment/WorkflowsFragment.java b/mobile/src/main/java/io/syslogic/github/fragment/WorkflowsFragment.java index 7da75d4c..bc8417ea 100644 --- a/mobile/src/main/java/io/syslogic/github/fragment/WorkflowsFragment.java +++ b/mobile/src/main/java/io/syslogic/github/fragment/WorkflowsFragment.java @@ -7,15 +7,14 @@ import android.view.ViewGroup; import android.widget.Toast; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.databinding.ViewDataBinding; - import com.google.gson.JsonObject; import com.google.gson.JsonParser; import java.io.IOException; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import io.syslogic.github.Constants; import io.syslogic.github.R; import io.syslogic.github.activity.NavHostActivity; @@ -89,14 +88,16 @@ public void onCreate(@Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { NavHostActivity activity = ((NavHostActivity) this.requireActivity()); - this.setDataBinding(FragmentWorkflowsBinding.inflate(inflater, container, false)); + this.setDataBinding(inflater, container); /* It removes & adds {@link BaseMenuProvider} */ activity.setMenuProvider(new WorkflowsMenuProvider(activity)); // the SpinnerItem has the same ID as the QueryString. activity.setSupportActionBar(this.getDataBinding().toolbarWorkflows.toolbarWorkflows); - this.mDataBinding.toolbarWorkflows.home.setOnClickListener(view -> activity.onBackPressed()); + this.mDataBinding.toolbarWorkflows.home.setOnClickListener(view -> { + activity.getOnBackPressedDispatcher().onBackPressed(); + }); // Recyclerview.Adapter WorkflowsAdapter adapter = new WorkflowsAdapter(requireContext()); @@ -176,16 +177,6 @@ private void setRepositoryName(@NonNull String value) { this.repositoryName = value; } - @NonNull - public FragmentWorkflowsBinding getDataBinding() { - return this.mDataBinding; - } - - @Override - protected void setDataBinding(@NonNull ViewDataBinding binding) { - this.mDataBinding = (FragmentWorkflowsBinding) binding; - } - @Override public void onNetworkAvailable() { super.onNetworkAvailable(); @@ -201,4 +192,15 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis super.onRequestPermissionsResult(requestCode, permissions, grantResults); // if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {} } + + @Override + protected void setDataBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) { + this.mDataBinding = FragmentWorkflowsBinding.inflate(inflater, container, false); + } + + @NonNull + @Override + public FragmentWorkflowsBinding getDataBinding() { + return this.mDataBinding; + } } diff --git a/mobile/src/main/java/io/syslogic/github/menu/BaseMenuProvider.java b/mobile/src/main/java/io/syslogic/github/menu/BaseMenuProvider.java index 413a8a68..964679a6 100644 --- a/mobile/src/main/java/io/syslogic/github/menu/BaseMenuProvider.java +++ b/mobile/src/main/java/io/syslogic/github/menu/BaseMenuProvider.java @@ -4,14 +4,14 @@ import android.view.MenuInflater; import android.view.MenuItem; +import java.lang.ref.WeakReference; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.view.MenuProvider; import androidx.navigation.NavController; import androidx.navigation.fragment.NavHostFragment; -import java.lang.ref.WeakReference; - import io.syslogic.github.activity.BaseActivity; /** diff --git a/mobile/src/main/java/io/syslogic/github/network/AccountAuthenticator.java b/mobile/src/main/java/io/syslogic/github/network/AccountAuthenticator.java index e6b3ff80..e278d168 100644 --- a/mobile/src/main/java/io/syslogic/github/network/AccountAuthenticator.java +++ b/mobile/src/main/java/io/syslogic/github/network/AccountAuthenticator.java @@ -8,11 +8,11 @@ import android.content.Intent; import android.os.Bundle; +import java.lang.ref.WeakReference; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import java.lang.ref.WeakReference; - import io.syslogic.github.activity.AuthenticatorActivity; /** diff --git a/mobile/src/main/java/io/syslogic/github/network/TokenHelper.java b/mobile/src/main/java/io/syslogic/github/network/TokenHelper.java index 1c1488d1..07807b70 100644 --- a/mobile/src/main/java/io/syslogic/github/network/TokenHelper.java +++ b/mobile/src/main/java/io/syslogic/github/network/TokenHelper.java @@ -8,21 +8,18 @@ import android.os.Bundle; import android.util.Log; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - import com.google.gson.JsonObject; import com.google.gson.JsonParser; import java.io.IOException; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import io.syslogic.github.BuildConfig; import io.syslogic.github.Constants; import io.syslogic.github.api.GithubClient; import io.syslogic.github.api.model.User; - import okhttp3.ResponseBody; - import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/mobile/src/main/java/io/syslogic/github/recyclerview/QueryStringsAdapter.java b/mobile/src/main/java/io/syslogic/github/recyclerview/QueryStringsAdapter.java index 0978f68e..2e6f5b9d 100644 --- a/mobile/src/main/java/io/syslogic/github/recyclerview/QueryStringsAdapter.java +++ b/mobile/src/main/java/io/syslogic/github/recyclerview/QueryStringsAdapter.java @@ -6,6 +6,9 @@ import android.view.View; import android.view.ViewGroup; +import java.lang.ref.WeakReference; +import java.util.List; + import androidx.annotation.NonNull; import androidx.cardview.widget.CardView; import androidx.databinding.DataBindingUtil; @@ -14,9 +17,6 @@ import androidx.navigation.Navigation; import androidx.recyclerview.widget.RecyclerView; -import java.lang.ref.WeakReference; -import java.util.List; - import io.syslogic.github.BuildConfig; import io.syslogic.github.Constants; import io.syslogic.github.R; diff --git a/mobile/src/main/java/io/syslogic/github/recyclerview/RepositoriesAdapter.java b/mobile/src/main/java/io/syslogic/github/recyclerview/RepositoriesAdapter.java index 0b9b758b..94efa488 100644 --- a/mobile/src/main/java/io/syslogic/github/recyclerview/RepositoriesAdapter.java +++ b/mobile/src/main/java/io/syslogic/github/recyclerview/RepositoriesAdapter.java @@ -11,6 +11,9 @@ import android.view.View; import android.view.ViewGroup; +import java.lang.ref.WeakReference; +import java.util.ArrayList; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.cardview.widget.CardView; @@ -20,9 +23,6 @@ import androidx.navigation.Navigation; import androidx.recyclerview.widget.RecyclerView; -import java.lang.ref.WeakReference; -import java.util.ArrayList; - import io.syslogic.github.BuildConfig; import io.syslogic.github.Constants; import io.syslogic.github.R; diff --git a/mobile/src/main/java/io/syslogic/github/recyclerview/RepositorySearchAdapter.java b/mobile/src/main/java/io/syslogic/github/recyclerview/RepositorySearchAdapter.java index 0f7a406a..13f1689a 100644 --- a/mobile/src/main/java/io/syslogic/github/recyclerview/RepositorySearchAdapter.java +++ b/mobile/src/main/java/io/syslogic/github/recyclerview/RepositorySearchAdapter.java @@ -14,6 +14,12 @@ import android.view.ViewGroup; import android.widget.Toast; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.cardview.widget.CardView; @@ -23,12 +29,6 @@ import androidx.navigation.Navigation; import androidx.recyclerview.widget.RecyclerView; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Locale; - import io.syslogic.github.BuildConfig; import io.syslogic.github.Constants; import io.syslogic.github.R; diff --git a/mobile/src/main/java/io/syslogic/github/recyclerview/TopicsAdapter.java b/mobile/src/main/java/io/syslogic/github/recyclerview/TopicsAdapter.java index d93deba0..8cc988ca 100644 --- a/mobile/src/main/java/io/syslogic/github/recyclerview/TopicsAdapter.java +++ b/mobile/src/main/java/io/syslogic/github/recyclerview/TopicsAdapter.java @@ -4,13 +4,13 @@ import android.view.View; import android.view.ViewGroup; +import java.util.List; + import androidx.annotation.NonNull; import androidx.cardview.widget.CardView; import androidx.databinding.DataBindingUtil; import androidx.recyclerview.widget.RecyclerView; -import java.util.List; - import io.syslogic.github.R; import io.syslogic.github.activity.BaseActivity; import io.syslogic.github.databinding.CardviewTopicBinding; diff --git a/mobile/src/main/java/io/syslogic/github/recyclerview/TopicsFlexboxView.java b/mobile/src/main/java/io/syslogic/github/recyclerview/TopicsFlexboxView.java index c32b6c61..18cd6c2f 100644 --- a/mobile/src/main/java/io/syslogic/github/recyclerview/TopicsFlexboxView.java +++ b/mobile/src/main/java/io/syslogic/github/recyclerview/TopicsFlexboxView.java @@ -3,14 +3,14 @@ import android.content.Context; import android.util.AttributeSet; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.recyclerview.widget.RecyclerView; - import com.google.android.flexbox.FlexDirection; import com.google.android.flexbox.FlexboxLayoutManager; import com.google.android.flexbox.JustifyContent; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.RecyclerView; + /** * Topics {@link RecyclerView} * diff --git a/mobile/src/main/java/io/syslogic/github/recyclerview/WorkflowRunsAdapter.java b/mobile/src/main/java/io/syslogic/github/recyclerview/WorkflowRunsAdapter.java index d2344277..7d51a8d7 100644 --- a/mobile/src/main/java/io/syslogic/github/recyclerview/WorkflowRunsAdapter.java +++ b/mobile/src/main/java/io/syslogic/github/recyclerview/WorkflowRunsAdapter.java @@ -7,6 +7,10 @@ import android.view.View; import android.view.ViewGroup; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; + import androidx.annotation.NonNull; import androidx.cardview.widget.CardView; import androidx.databinding.DataBindingUtil; @@ -15,10 +19,6 @@ import androidx.navigation.Navigation; import androidx.recyclerview.widget.RecyclerView; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.List; - import io.syslogic.github.BuildConfig; import io.syslogic.github.Constants; import io.syslogic.github.R; diff --git a/mobile/src/main/java/io/syslogic/github/recyclerview/WorkflowStepsAdapter.java b/mobile/src/main/java/io/syslogic/github/recyclerview/WorkflowStepsAdapter.java index 14eeafec..02b048fb 100644 --- a/mobile/src/main/java/io/syslogic/github/recyclerview/WorkflowStepsAdapter.java +++ b/mobile/src/main/java/io/syslogic/github/recyclerview/WorkflowStepsAdapter.java @@ -5,15 +5,15 @@ import android.view.LayoutInflater; import android.view.ViewGroup; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; + import androidx.annotation.NonNull; import androidx.cardview.widget.CardView; import androidx.databinding.DataBindingUtil; import androidx.recyclerview.widget.RecyclerView; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.List; - import io.syslogic.github.BuildConfig; import io.syslogic.github.R; import io.syslogic.github.api.GithubClient; diff --git a/mobile/src/main/java/io/syslogic/github/recyclerview/WorkflowsAdapter.java b/mobile/src/main/java/io/syslogic/github/recyclerview/WorkflowsAdapter.java index 7f1c1b1d..6b510b97 100644 --- a/mobile/src/main/java/io/syslogic/github/recyclerview/WorkflowsAdapter.java +++ b/mobile/src/main/java/io/syslogic/github/recyclerview/WorkflowsAdapter.java @@ -7,6 +7,10 @@ import android.view.View; import android.view.ViewGroup; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; + import androidx.annotation.NonNull; import androidx.cardview.widget.CardView; import androidx.databinding.DataBindingUtil; @@ -15,10 +19,6 @@ import androidx.navigation.Navigation; import androidx.recyclerview.widget.RecyclerView; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.List; - import io.syslogic.github.BuildConfig; import io.syslogic.github.Constants; import io.syslogic.github.R; diff --git a/version.properties b/version.properties index 4b83102e..60e799c1 100644 --- a/version.properties +++ b/version.properties @@ -1,2 +1,2 @@ -versionName = 1.0.1 -versionCode = 2 +versionName = 1.0.2 +versionCode = 3