diff --git a/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java b/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java index d2d092af..f1006e77 100644 --- a/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java @@ -389,7 +389,6 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList assert version != null; VersionCheck vt = VersionCheck.check(getString(R.string.versionLow), getString(R.string.versionHigh), version.getVersion()); - tinyDb.putString("giteaVersion", version.getVersion()); switch (vt) { case UNSUPPORTED_NEW: diff --git a/app/src/main/java/org/mian/gitnex/activities/MainActivity.java b/app/src/main/java/org/mian/gitnex/activities/MainActivity.java index 8756fc0f..349a85bf 100644 --- a/app/src/main/java/org/mian/gitnex/activities/MainActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/MainActivity.java @@ -30,6 +30,7 @@ import org.mian.gitnex.fragments.StarredRepositoriesFragment; import org.mian.gitnex.helpers.AlertDialogs; import org.mian.gitnex.helpers.Authorization; import org.mian.gitnex.helpers.Toasty; +import org.mian.gitnex.models.GiteaVersion; import org.mian.gitnex.models.UserInfo; import org.mian.gitnex.util.AppUtil; import org.mian.gitnex.helpers.RoundedTransformation; @@ -217,6 +218,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On } else { displayUserInfo(instanceUrl, instanceToken, loginUid); + giteaVersion(instanceUrl); tinyDb.putBoolean("noConnection", false); } @@ -311,6 +313,42 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On } + private void giteaVersion(final String instanceUrl) { + + final TinyDB tinyDb = new TinyDB(getApplicationContext()); + + Call callVersion = RetrofitClient + .getInstance(instanceUrl, getApplicationContext()) + .getApiInterface() + .getGiteaVersion(); + + callVersion.enqueue(new Callback() { + + @Override + public void onResponse(@NonNull final Call callVersion, @NonNull retrofit2.Response responseVersion) { + + if (responseVersion.code() == 200) { + + GiteaVersion version = responseVersion.body(); + assert version != null; + + tinyDb.putString("giteaVersion", version.getVersion()); + + } + + } + + @Override + public void onFailure(@NonNull Call callVersion, Throwable t) { + + Log.e("onFailure-version", t.toString()); + + } + + }); + + } + private void displayUserInfo(String instanceUrl, String token, String loginUid) { final TinyDB tinyDb = new TinyDB(getApplicationContext());