Merge branch 'master' into 7-assign-team-to-repo
This commit is contained in:
commit
cd902ff1ca
@ -12,6 +12,7 @@ import org.gitnex.tea4j.models.GiteaVersion;
|
|||||||
import org.gitnex.tea4j.models.UserInfo;
|
import org.gitnex.tea4j.models.UserInfo;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||||
import org.mian.gitnex.databinding.ActivityAddNewAccountBinding;
|
import org.mian.gitnex.databinding.ActivityAddNewAccountBinding;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
@ -114,9 +115,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||||||
private void versionCheck(final String instanceUrl, final String loginToken) {
|
private void versionCheck(final String instanceUrl, final String loginToken) {
|
||||||
|
|
||||||
Call<GiteaVersion> callVersion;
|
Call<GiteaVersion> callVersion;
|
||||||
|
|
||||||
callVersion = RetrofitClient.getApiInterface(ctx).getGiteaVersionWithToken("token " + loginToken);
|
callVersion = RetrofitClient.getApiInterface(ctx).getGiteaVersionWithToken("token " + loginToken);
|
||||||
|
|
||||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -205,14 +204,15 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||||||
assert userDetails != null;
|
assert userDetails != null;
|
||||||
// insert new account to db if does not exist
|
// insert new account to db if does not exist
|
||||||
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
String accountName = userDetails.getUsername() + "@" + instanceUrl;
|
||||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
UserAccountsApi userAccountsApi = BaseApi.getInstance(ctx, UserAccountsApi.class);
|
||||||
int checkAccount = userAccountsApi.getCount(accountName);
|
boolean userAccountExists = userAccountsApi.userAccountExists(accountName);
|
||||||
|
|
||||||
if(checkAccount == 0) {
|
if(!userAccountExists) {
|
||||||
|
|
||||||
userAccountsApi.insertNewAccount(accountName, instanceUrl, userDetails.getUsername(), loginToken, "");
|
userAccountsApi.createNewAccount(accountName, instanceUrl, userDetails.getUsername(), loginToken, "");
|
||||||
Toasty.success(ctx, getResources().getString(R.string.accountAddedMessage));
|
Toasty.success(ctx, getResources().getString(R.string.accountAddedMessage));
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
@ -13,11 +13,13 @@ import org.gitnex.tea4j.models.PullRequests;
|
|||||||
import org.gitnex.tea4j.models.UserRepositories;
|
import org.gitnex.tea4j.models.UserRepositories;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||||
import org.mian.gitnex.database.models.Repository;
|
import org.mian.gitnex.database.models.Repository;
|
||||||
import org.mian.gitnex.database.models.UserAccount;
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
import org.mian.gitnex.databinding.ActivityDeeplinksBinding;
|
import org.mian.gitnex.databinding.ActivityDeeplinksBinding;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.UrlHelper;
|
import org.mian.gitnex.helpers.UrlHelper;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -65,7 +67,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check for the links(URI) to be in the db
|
// check for the links(URI) to be in the db
|
||||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
UserAccountsApi userAccountsApi = BaseApi.getInstance(ctx, UserAccountsApi.class);
|
||||||
List<UserAccount> userAccounts = userAccountsApi.usersAccounts();
|
List<UserAccount> userAccounts = userAccountsApi.usersAccounts();
|
||||||
|
|
||||||
for(UserAccount userAccount : userAccounts) {
|
for(UserAccount userAccount : userAccounts) {
|
||||||
@ -79,13 +81,9 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
|
|
||||||
accountFound = true;
|
accountFound = true;
|
||||||
|
|
||||||
tinyDB.putString("loginUid", userAccount.getUserName());
|
AppUtil.switchToAccount(ctx, userAccount);
|
||||||
tinyDB.putString("userLogin", userAccount.getUserName());
|
|
||||||
tinyDB.putString(userAccount.getUserName() + "-token", userAccount.getToken());
|
|
||||||
tinyDB.putString("instanceUrl", userAccount.getInstanceUrl());
|
|
||||||
tinyDB.putInt("currentActiveAccountId", userAccount.getAccountId());
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +110,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
final String repoName = restOfUrl[restOfUrl.length - 3];
|
final String repoName = restOfUrl[restOfUrl.length - 3];
|
||||||
|
|
||||||
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||||
RepositoriesApi repositoryData = new RepositoriesApi(ctx);
|
RepositoriesApi repositoryData = BaseApi.getInstance(ctx, RepositoriesApi.class);
|
||||||
|
|
||||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
|
|
||||||
@ -344,7 +342,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
tinyDB.putString("repoFullName", repoOwner + "/" + repoName);
|
tinyDB.putString("repoFullName", repoOwner + "/" + repoName);
|
||||||
|
|
||||||
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||||
RepositoriesApi repositoryData = new RepositoriesApi(ctx);
|
RepositoriesApi repositoryData = BaseApi.getInstance(ctx, RepositoriesApi.class);
|
||||||
|
|
||||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
|
|
||||||
@ -415,7 +413,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||||||
tinyDB.putString("repoBranch", repoInfo.getDefault_branch());
|
tinyDB.putString("repoBranch", repoInfo.getDefault_branch());
|
||||||
|
|
||||||
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||||
RepositoriesApi repositoryData = new RepositoriesApi(ctx);
|
RepositoriesApi repositoryData = BaseApi.getInstance(ctx, RepositoriesApi.class);
|
||||||
|
|
||||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import org.gitnex.tea4j.models.UserInfo;
|
|||||||
import org.gitnex.tea4j.models.UserTokens;
|
import org.gitnex.tea4j.models.UserTokens;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||||
import org.mian.gitnex.database.models.UserAccount;
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
import org.mian.gitnex.databinding.ActivityLoginBinding;
|
import org.mian.gitnex.databinding.ActivityLoginBinding;
|
||||||
@ -358,19 +359,19 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
// insert new account to db if does not exist
|
// insert new account to db if does not exist
|
||||||
String accountName = userDetails.getUsername() + "@" + TinyDB.getInstance(ctx).getString("instanceUrl");
|
String accountName = userDetails.getUsername() + "@" + TinyDB.getInstance(ctx).getString("instanceUrl");
|
||||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
UserAccountsApi userAccountsApi = BaseApi.getInstance(ctx, UserAccountsApi.class);
|
||||||
int checkAccount = userAccountsApi.getCount(accountName);
|
boolean userAccountExists = userAccountsApi.userAccountExists(accountName);
|
||||||
long accountId;
|
long accountId;
|
||||||
|
|
||||||
if(checkAccount == 0) {
|
if(!userAccountExists) {
|
||||||
|
|
||||||
accountId = userAccountsApi.insertNewAccount(accountName, TinyDB.getInstance(ctx).getString("instanceUrl"), userDetails.getUsername(), loginToken, "");
|
accountId = userAccountsApi.createNewAccount(accountName, TinyDB.getInstance(ctx).getString("instanceUrl"), userDetails.getUsername(), loginToken, "");
|
||||||
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
userAccountsApi.updateTokenByAccountName(accountName, loginToken);
|
userAccountsApi.updateTokenByAccountName(accountName, loginToken);
|
||||||
UserAccount data = userAccountsApi.getAccountData(accountName);
|
UserAccount data = userAccountsApi.getAccountByName(accountName);
|
||||||
tinyDB.putInt("currentActiveAccountId", data.getAccountId());
|
tinyDB.putInt("currentActiveAccountId", data.getAccountId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,20 +547,20 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
// insert new account to db if does not exist
|
// insert new account to db if does not exist
|
||||||
String accountName = userDetails.getUsername() + "@" + TinyDB.getInstance(ctx).getString("instanceUrl");
|
String accountName = userDetails.getUsername() + "@" + TinyDB.getInstance(ctx).getString("instanceUrl");
|
||||||
UserAccountsApi userAccountsApi = new UserAccountsApi(ctx);
|
UserAccountsApi userAccountsApi = BaseApi.getInstance(ctx, UserAccountsApi.class);
|
||||||
int checkAccount = userAccountsApi.getCount(accountName);
|
boolean userAccountExists = userAccountsApi.userAccountExists(accountName);
|
||||||
long accountId;
|
long accountId;
|
||||||
|
|
||||||
if(checkAccount == 0) {
|
if(!userAccountExists) {
|
||||||
|
|
||||||
accountId = userAccountsApi
|
accountId = userAccountsApi
|
||||||
.insertNewAccount(accountName, TinyDB.getInstance(ctx).getString("instanceUrl"), userDetails.getUsername(), newToken.getSha1(), "");
|
.createNewAccount(accountName, TinyDB.getInstance(ctx).getString("instanceUrl"), userDetails.getUsername(), newToken.getSha1(), "");
|
||||||
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
tinyDB.putInt("currentActiveAccountId", (int) accountId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
userAccountsApi.updateTokenByAccountName(accountName, newToken.getSha1());
|
userAccountsApi.updateTokenByAccountName(accountName, newToken.getSha1());
|
||||||
UserAccount data = userAccountsApi.getAccountData(accountName);
|
UserAccount data = userAccountsApi.getAccountByName(accountName);
|
||||||
tinyDB.putInt("currentActiveAccountId", data.getAccountId());
|
tinyDB.putInt("currentActiveAccountId", data.getAccountId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ import androidx.appcompat.app.AlertDialog;
|
|||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.biometric.BiometricPrompt;
|
import androidx.biometric.BiometricPrompt;
|
||||||
|
import androidx.cardview.widget.CardView;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
|
||||||
import androidx.core.view.GravityCompat;
|
import androidx.core.view.GravityCompat;
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
@ -33,6 +33,7 @@ import org.mian.gitnex.R;
|
|||||||
import org.mian.gitnex.adapters.UserAccountsNavAdapter;
|
import org.mian.gitnex.adapters.UserAccountsNavAdapter;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||||
import org.mian.gitnex.database.models.UserAccount;
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
import org.mian.gitnex.databinding.ActivityMainBinding;
|
import org.mian.gitnex.databinding.ActivityMainBinding;
|
||||||
@ -71,10 +72,6 @@ import retrofit2.Callback;
|
|||||||
public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener, BottomSheetDraftsFragment.BottomSheetListener {
|
public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener, BottomSheetDraftsFragment.BottomSheetListener {
|
||||||
|
|
||||||
private DrawerLayout drawer;
|
private DrawerLayout drawer;
|
||||||
private TextView userFullName;
|
|
||||||
private TextView userEmail;
|
|
||||||
private ImageView userAvatar;
|
|
||||||
private ImageView userAvatarBackground;
|
|
||||||
private TextView toolbarTitle;
|
private TextView toolbarTitle;
|
||||||
private Typeface myTypeface;
|
private Typeface myTypeface;
|
||||||
|
|
||||||
@ -93,38 +90,25 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
ActivityMainBinding activityMainBinding = ActivityMainBinding.inflate(getLayoutInflater());
|
ActivityMainBinding activityMainBinding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||||
setContentView(activityMainBinding.getRoot());
|
setContentView(activityMainBinding.getRoot());
|
||||||
|
|
||||||
tinyDB.putBoolean("noConnection", false);
|
|
||||||
|
|
||||||
String currentVersion = tinyDB.getString("giteaVersion");
|
|
||||||
|
|
||||||
Intent mainIntent = getIntent();
|
Intent mainIntent = getIntent();
|
||||||
String launchFragment = mainIntent.getStringExtra("launchFragment");
|
|
||||||
|
// DO NOT MOVE
|
||||||
|
if(mainIntent.hasExtra("switchAccountId") &&
|
||||||
|
AppUtil.switchToAccount(ctx, BaseApi.getInstance(ctx, UserAccountsApi.class)
|
||||||
|
.getAccountById(mainIntent.getIntExtra("switchAccountId", 0)))) {
|
||||||
|
|
||||||
|
mainIntent.removeExtra("switchAccountId");
|
||||||
|
recreate();
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
// DO NOT MOVE
|
||||||
|
|
||||||
|
tinyDB.putBoolean("noConnection", false);
|
||||||
|
|
||||||
loginUid = tinyDB.getString("loginUid");
|
loginUid = tinyDB.getString("loginUid");
|
||||||
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
|
||||||
|
|
||||||
if(tinyDB.getString("dateFormat").isEmpty()) {
|
|
||||||
|
|
||||||
tinyDB.putString("dateFormat", "pretty");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tinyDB.getString("codeBlockStr").isEmpty()) {
|
|
||||||
|
|
||||||
tinyDB.putInt("codeBlockColor", ResourcesCompat.getColor(getResources(), R.color.colorLightGreen, null));
|
|
||||||
tinyDB.putInt("codeBlockBackground", ResourcesCompat.getColor(getResources(), R.color.black, null));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tinyDB.getString("enableCounterIssueBadgeInit").isEmpty()) {
|
|
||||||
|
|
||||||
tinyDB.putBoolean("enableCounterIssueBadge", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tinyDB.getString("homeScreenStr").isEmpty()) {
|
|
||||||
|
|
||||||
tinyDB.putString("homeScreenStr", "yes");
|
|
||||||
tinyDB.putInt("homeScreenId", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||||
|
|
||||||
if(!tinyDB.getBoolean("loggedInMode")) {
|
if(!tinyDB.getBoolean("loggedInMode")) {
|
||||||
@ -133,9 +117,10 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDB.getInt("currentActiveAccountId") <= 0) {
|
if(tinyDB.getInt("currentActiveAccountId", -1) <= 0) {
|
||||||
|
AlertDialogs.forceLogoutDialog(ctx,
|
||||||
AlertDialogs.forceLogoutDialog(ctx, getResources().getString(R.string.forceLogoutDialogHeader), getResources().getString(R.string.forceLogoutDialogDescription), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
getResources().getString(R.string.forceLogoutDialogHeader),
|
||||||
|
getResources().getString(R.string.forceLogoutDialogDescription), getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
||||||
}
|
}
|
||||||
|
|
||||||
Toolbar toolbar = activityMainBinding.toolbar;
|
Toolbar toolbar = activityMainBinding.toolbar;
|
||||||
@ -144,17 +129,17 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
switch(tinyDB.getInt("customFontId", -1)) {
|
switch(tinyDB.getInt("customFontId", -1)) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/roboto.ttf");
|
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/roboto.ttf");
|
||||||
break;
|
break;
|
||||||
case 2:
|
|
||||||
|
|
||||||
|
case 2:
|
||||||
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodeproregular.ttf");
|
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
|
|
||||||
|
default:
|
||||||
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/manroperegular.ttf");
|
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/manroperegular.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// biometric auth
|
// biometric auth
|
||||||
@ -201,43 +186,33 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
Fragment fragmentById = fm.findFragmentById(R.id.fragment_container);
|
Fragment fragmentById = fm.findFragmentById(R.id.fragment_container);
|
||||||
|
|
||||||
if(fragmentById instanceof SettingsFragment) {
|
if(fragmentById instanceof SettingsFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleSettings));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleSettings));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof MyRepositoriesFragment) {
|
else if(fragmentById instanceof MyRepositoriesFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleMyRepos));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof StarredRepositoriesFragment) {
|
else if(fragmentById instanceof StarredRepositoriesFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof OrganizationsFragment) {
|
else if(fragmentById instanceof OrganizationsFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleOrganizations));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof ExploreFragment) {
|
else if(fragmentById instanceof ExploreFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleExplore));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof NotificationsFragment) {
|
else if(fragmentById instanceof NotificationsFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(R.string.pageTitleNotifications);
|
toolbarTitle.setText(R.string.pageTitleNotifications);
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof ProfileFragment) {
|
else if(fragmentById instanceof ProfileFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleProfile));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof DraftsFragment) {
|
else if(fragmentById instanceof DraftsFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof AdministrationFragment) {
|
else if(fragmentById instanceof AdministrationFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
|
||||||
}
|
}
|
||||||
else if(fragmentById instanceof UserAccountsFragment) {
|
else if(fragmentById instanceof UserAccountsFragment) {
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleUserAccounts));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleUserAccounts));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,6 +231,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
drawer.addDrawerListener(toggle);
|
drawer.addDrawerListener(toggle);
|
||||||
drawer.addDrawerListener(new DrawerLayout.DrawerListener() {
|
drawer.addDrawerListener(new DrawerLayout.DrawerListener() {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDrawerOpened(@NonNull View drawerView) {
|
public void onDrawerOpened(@NonNull View drawerView) {
|
||||||
|
|
||||||
@ -269,27 +245,26 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
String userFullNameNav = tinyDB.getString("userFullname");
|
String userFullNameNav = tinyDB.getString("userFullname");
|
||||||
String userAvatarNav = tinyDB.getString("userAvatar");
|
String userAvatarNav = tinyDB.getString("userAvatar");
|
||||||
|
|
||||||
userEmail = hView.findViewById(R.id.userEmail);
|
TextView userEmail = hView.findViewById(R.id.userEmail);
|
||||||
userFullName = hView.findViewById(R.id.userFullname);
|
TextView userFullName = hView.findViewById(R.id.userFullname);
|
||||||
userAvatar = hView.findViewById(R.id.userAvatar);
|
ImageView userAvatar = hView.findViewById(R.id.userAvatar);
|
||||||
userAvatarBackground = hView.findViewById(R.id.userAvatarBackground);
|
ImageView userAvatarBackground = hView.findViewById(R.id.userAvatarBackground);
|
||||||
|
CardView navRecyclerViewFrame = hView.findViewById(R.id.userAccountsFrame);
|
||||||
|
|
||||||
List<UserAccount> userAccountsList;
|
List<UserAccount> userAccountsList = new ArrayList<>();
|
||||||
userAccountsList = new ArrayList<>();
|
|
||||||
UserAccountsApi userAccountsApi;
|
UserAccountsApi userAccountsApi;
|
||||||
userAccountsApi = new UserAccountsApi(ctx);
|
userAccountsApi = BaseApi.getInstance(ctx, UserAccountsApi.class);
|
||||||
|
|
||||||
RecyclerView navRecyclerViewUserAccounts = hView.findViewById(R.id.navRecyclerViewUserAccounts);
|
RecyclerView navRecyclerViewUserAccounts = hView.findViewById(R.id.userAccounts);
|
||||||
UserAccountsNavAdapter adapterUserAccounts;
|
UserAccountsNavAdapter adapterUserAccounts;
|
||||||
|
|
||||||
adapterUserAccounts = new UserAccountsNavAdapter(ctx, userAccountsList, drawer, toolbarTitle);
|
adapterUserAccounts = new UserAccountsNavAdapter(ctx, userAccountsList, drawer, toolbarTitle);
|
||||||
|
|
||||||
userAccountsApi.getAllAccounts().observe((AppCompatActivity) ctx, userAccounts -> {
|
userAccountsApi.getAllAccounts().observe((AppCompatActivity) ctx, userAccounts -> {
|
||||||
|
|
||||||
if(userAccounts.size() > 0) {
|
if(userAccounts.size() > 0) {
|
||||||
|
|
||||||
userAccountsList.addAll(userAccounts);
|
userAccountsList.addAll(userAccounts);
|
||||||
navRecyclerViewUserAccounts.setAdapter(adapterUserAccounts);
|
navRecyclerViewUserAccounts.setAdapter(adapterUserAccounts);
|
||||||
|
navRecyclerViewFrame.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -297,21 +272,21 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
userFullName.setTypeface(myTypeface);
|
userFullName.setTypeface(myTypeface);
|
||||||
|
|
||||||
if(!userEmailNav.equals("")) {
|
if(!userEmailNav.equals("")) {
|
||||||
|
|
||||||
userEmail.setText(userEmailNav);
|
userEmail.setText(userEmailNav);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!userFullNameNav.equals("")) {
|
if(!userFullNameNav.equals("")) {
|
||||||
|
|
||||||
userFullName.setText(Html.fromHtml(userFullNameNav));
|
userFullName.setText(Html.fromHtml(userFullNameNav));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!userAvatarNav.equals("")) {
|
if(!userAvatarNav.equals("")) {
|
||||||
|
|
||||||
|
int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 3);
|
||||||
|
|
||||||
PicassoService.getInstance(ctx).get()
|
PicassoService.getInstance(ctx).get()
|
||||||
.load(userAvatarNav)
|
.load(userAvatarNav)
|
||||||
.placeholder(R.drawable.loader_animated)
|
.placeholder(R.drawable.loader_animated)
|
||||||
.transform(new RoundedTransformation(8, 0))
|
.transform(new RoundedTransformation(avatarRadius, 0))
|
||||||
.resize(160, 160)
|
.resize(160, 160)
|
||||||
.centerCrop().into(userAvatar);
|
.centerCrop().into(userAvatar);
|
||||||
|
|
||||||
@ -348,7 +323,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
|
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {
|
||||||
|
|
||||||
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(tinyDB.getBoolean("userIsAdmin"));
|
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(tinyDB.getBoolean("userIsAdmin"));
|
||||||
navigationView.getMenu().findItem(R.id.nav_notifications).setVisible(new Version(currentVersion).higherOrEqual("1.12.3"));
|
navigationView.getMenu().findItem(R.id.nav_notifications).setVisible(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.3"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -362,6 +338,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
toggle.syncState();
|
toggle.syncState();
|
||||||
toolbar.setNavigationIcon(R.drawable.ic_menu);
|
toolbar.setNavigationIcon(R.drawable.ic_menu);
|
||||||
|
|
||||||
|
String launchFragment = mainIntent.getStringExtra("launchFragment");
|
||||||
|
|
||||||
if(launchFragment != null) {
|
if(launchFragment != null) {
|
||||||
|
|
||||||
mainIntent.removeExtra("launchFragment");
|
mainIntent.removeExtra("launchFragment");
|
||||||
@ -369,13 +347,12 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
switch(launchFragment) {
|
switch(launchFragment) {
|
||||||
|
|
||||||
case "drafts":
|
case "drafts":
|
||||||
|
|
||||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DraftsFragment()).commit();
|
||||||
navigationView.setCheckedItem(R.id.nav_comments_draft);
|
navigationView.setCheckedItem(R.id.nav_comments_draft);
|
||||||
return;
|
return;
|
||||||
case "notifications":
|
|
||||||
|
|
||||||
|
case "notifications":
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleNotifications));
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleNotifications));
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new NotificationsFragment()).commit();
|
||||||
navigationView.setCheckedItem(R.id.nav_notifications);
|
navigationView.setCheckedItem(R.id.nav_notifications);
|
||||||
@ -416,9 +393,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
if(savedInstanceState == null) {
|
if(savedInstanceState == null) {
|
||||||
|
|
||||||
if(!new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
if(!new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
||||||
|
|
||||||
if(tinyDB.getInt("homeScreenId") == 7) {
|
if(tinyDB.getInt("homeScreenId") == 7) {
|
||||||
|
|
||||||
tinyDB.putInt("homeScreenId", 0);
|
tinyDB.putInt("homeScreenId", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -659,29 +634,22 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
|
|
||||||
private void giteaVersion() {
|
private void giteaVersion() {
|
||||||
|
|
||||||
final TinyDB tinyDb = TinyDB.getInstance(appCtx);
|
Call<GiteaVersion> callVersion = RetrofitClient.getApiInterface(ctx).getGiteaVersionWithToken(Authorization.get(ctx));
|
||||||
|
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
|
||||||
|
|
||||||
Call<GiteaVersion> callVersion = RetrofitClient.getApiInterface(ctx).getGiteaVersionWithToken(token);
|
|
||||||
|
|
||||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull final Call<GiteaVersion> callVersion, @NonNull retrofit2.Response<GiteaVersion> responseVersion) {
|
public void onResponse(@NonNull final Call<GiteaVersion> callVersion, @NonNull retrofit2.Response<GiteaVersion> responseVersion) {
|
||||||
|
|
||||||
if(responseVersion.code() == 200) {
|
if(responseVersion.code() == 200 && responseVersion.body() != null) {
|
||||||
|
String version = responseVersion.body().getVersion();
|
||||||
|
|
||||||
GiteaVersion version = responseVersion.body();
|
tinyDB.putString("giteaVersion", version);
|
||||||
assert version != null;
|
BaseApi.getInstance(ctx, UserAccountsApi.class).updateServerVersion(version, tinyDB.getInt("currentActiveAccountId"));
|
||||||
|
|
||||||
tinyDb.putString("giteaVersion", version.getVersion());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<GiteaVersion> callVersion, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<GiteaVersion> callVersion, @NonNull Throwable t) {
|
||||||
|
|
||||||
Log.e("onFailure-version", t.toString());
|
Log.e("onFailure-version", t.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -14,6 +14,7 @@ import org.gitnex.tea4j.models.RepositoryTransfer;
|
|||||||
import org.gitnex.tea4j.models.UserRepositories;
|
import org.gitnex.tea4j.models.UserRepositories;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
import org.mian.gitnex.databinding.ActivityRepositorySettingsBinding;
|
import org.mian.gitnex.databinding.ActivityRepositorySettingsBinding;
|
||||||
import org.mian.gitnex.databinding.CustomRepositoryDeleteDialogBinding;
|
import org.mian.gitnex.databinding.CustomRepositoryDeleteDialogBinding;
|
||||||
@ -139,7 +140,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
Toasty.success(ctx, getString(R.string.repoTransferSuccess));
|
Toasty.success(ctx, getString(R.string.repoTransferSuccess));
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
RepositoriesApi.deleteRepository((int) tinyDB.getLong("repositoryId", 0));
|
BaseApi.getInstance(ctx, RepositoriesApi.class).deleteRepository((int) tinyDB.getLong("repositoryId", 0));
|
||||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||||
RepositorySettingsActivity.this.startActivity(intent);
|
RepositorySettingsActivity.this.startActivity(intent);
|
||||||
}
|
}
|
||||||
@ -220,7 +221,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
Toasty.success(ctx, getString(R.string.repoDeletionSuccess));
|
Toasty.success(ctx, getString(R.string.repoDeletionSuccess));
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
RepositoriesApi.deleteRepository((int) tinyDB.getLong("repositoryId", 0));
|
BaseApi.getInstance(ctx, RepositoriesApi.class).deleteRepository((int) tinyDB.getLong("repositoryId", 0));
|
||||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||||
RepositorySettingsActivity.this.startActivity(intent);
|
RepositorySettingsActivity.this.startActivity(intent);
|
||||||
}
|
}
|
||||||
@ -383,7 +384,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||||||
if(!repositoryName.equals(repoName)) {
|
if(!repositoryName.equals(repoName)) {
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
RepositoriesApi.updateRepositoryOwnerAndName(repositoryOwner, repoName, (int) tinyDB.getLong("repositoryId", 0));
|
BaseApi.getInstance(ctx, RepositoriesApi.class).updateRepositoryOwnerAndName(repositoryOwner, repoName, (int) tinyDB.getLong("repositoryId", 0));
|
||||||
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
|
||||||
RepositorySettingsActivity.this.startActivity(intent);
|
RepositorySettingsActivity.this.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,13 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||||||
viewBinding.enableNotificationsMode.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
viewBinding.enableNotificationsMode.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
|
||||||
tinyDB.putBoolean("notificationsEnabled", isChecked);
|
tinyDB.putBoolean("notificationsEnabled", isChecked);
|
||||||
if(!isChecked) Notifications.stopWorker(ctx);
|
|
||||||
|
if(isChecked) {
|
||||||
|
Notifications.startWorker(ctx);
|
||||||
|
} else {
|
||||||
|
Notifications.stopWorker(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.info(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -31,17 +31,13 @@ import retrofit2.Callback;
|
|||||||
public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAdapter.CronTasksViewHolder> {
|
public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAdapter.CronTasksViewHolder> {
|
||||||
|
|
||||||
private final List<CronTasks> tasksList;
|
private final List<CronTasks> tasksList;
|
||||||
private final Context mCtx;
|
|
||||||
private static TinyDB tinyDb;
|
private static TinyDB tinyDb;
|
||||||
|
|
||||||
static class CronTasksViewHolder extends RecyclerView.ViewHolder {
|
static class CronTasksViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private CronTasks cronTasks;
|
private CronTasks cronTasks;
|
||||||
|
|
||||||
private final ImageView runTask;
|
|
||||||
private final TextView taskName;
|
private final TextView taskName;
|
||||||
private final LinearLayout cronTasksInfo;
|
|
||||||
private final LinearLayout cronTasksRun;
|
|
||||||
|
|
||||||
private CronTasksViewHolder(View itemView) {
|
private CronTasksViewHolder(View itemView) {
|
||||||
|
|
||||||
@ -51,10 +47,10 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
|
|||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
runTask = itemView.findViewById(R.id.runTask);
|
ImageView runTask = itemView.findViewById(R.id.runTask);
|
||||||
taskName = itemView.findViewById(R.id.taskName);
|
taskName = itemView.findViewById(R.id.taskName);
|
||||||
cronTasksInfo = itemView.findViewById(R.id.cronTasksInfo);
|
LinearLayout cronTasksInfo = itemView.findViewById(R.id.cronTasksInfo);
|
||||||
cronTasksRun = itemView.findViewById(R.id.cronTasksRun);
|
LinearLayout cronTasksRun = itemView.findViewById(R.id.cronTasksRun);
|
||||||
|
|
||||||
cronTasksInfo.setOnClickListener(taskInfo -> {
|
cronTasksInfo.setOnClickListener(taskInfo -> {
|
||||||
|
|
||||||
@ -96,10 +92,9 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdminCronTasksAdapter(Context mCtx, List<CronTasks> tasksListMain) {
|
public AdminCronTasksAdapter(Context ctx, List<CronTasks> tasksListMain) {
|
||||||
|
|
||||||
tinyDb = TinyDB.getInstance(mCtx);
|
tinyDb = TinyDB.getInstance(ctx);
|
||||||
this.mCtx = mCtx;
|
|
||||||
this.tasksList = tasksListMain;
|
this.tasksList = tasksListMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ import java.util.List;
|
|||||||
public class AdminGetUsersAdapter extends RecyclerView.Adapter<AdminGetUsersAdapter.UsersViewHolder> implements Filterable {
|
public class AdminGetUsersAdapter extends RecyclerView.Adapter<AdminGetUsersAdapter.UsersViewHolder> implements Filterable {
|
||||||
|
|
||||||
private final List<UserInfo> usersList;
|
private final List<UserInfo> usersList;
|
||||||
private final Context mCtx;
|
private final Context context;
|
||||||
private final List<UserInfo> usersListFull;
|
private final List<UserInfo> usersListFull;
|
||||||
|
|
||||||
static class UsersViewHolder extends RecyclerView.ViewHolder {
|
static class UsersViewHolder extends RecyclerView.ViewHolder {
|
||||||
@ -60,9 +60,9 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<AdminGetUsersAdap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdminGetUsersAdapter(Context mCtx, List<UserInfo> usersListMain) {
|
public AdminGetUsersAdapter(Context ctx, List<UserInfo> usersListMain) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.usersList = usersListMain;
|
this.usersList = usersListMain;
|
||||||
usersListFull = new ArrayList<>(usersList);
|
usersListFull = new ArrayList<>(usersList);
|
||||||
}
|
}
|
||||||
@ -79,17 +79,18 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<AdminGetUsersAdap
|
|||||||
public void onBindViewHolder(@NonNull AdminGetUsersAdapter.UsersViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull AdminGetUsersAdapter.UsersViewHolder holder, int position) {
|
||||||
|
|
||||||
UserInfo currentItem = usersList.get(position);
|
UserInfo currentItem = usersList.get(position);
|
||||||
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
holder.userLoginId = currentItem.getLogin();
|
holder.userLoginId = currentItem.getLogin();
|
||||||
|
|
||||||
if(!currentItem.getFullname().equals("")) {
|
if(!currentItem.getFullname().equals("")) {
|
||||||
|
|
||||||
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
|
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
|
||||||
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
holder.userFullName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
||||||
holder.userName.setVisibility(View.GONE);
|
holder.userName.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,12 +108,12 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<AdminGetUsersAdap
|
|||||||
holder.userRole.setVisibility(View.VISIBLE);
|
holder.userRole.setVisibility(View.VISIBLE);
|
||||||
TextDrawable drawable = TextDrawable.builder()
|
TextDrawable drawable = TextDrawable.builder()
|
||||||
.beginConfig()
|
.beginConfig()
|
||||||
.textColor(ResourcesCompat.getColor(mCtx.getResources(), R.color.colorWhite, null))
|
.textColor(ResourcesCompat.getColor(context.getResources(), R.color.colorWhite, null))
|
||||||
.fontSize(44)
|
.fontSize(44)
|
||||||
.width(180)
|
.width(180)
|
||||||
.height(60)
|
.height(60)
|
||||||
.endConfig()
|
.endConfig()
|
||||||
.buildRoundRect(mCtx.getResources().getString(R.string.userRoleAdmin).toLowerCase(), ResourcesCompat.getColor(mCtx.getResources(), R.color.releasePre, null), 8);
|
.buildRoundRect(context.getResources().getString(R.string.userRoleAdmin).toLowerCase(), ResourcesCompat.getColor(context.getResources(), R.color.releasePre, null), 8);
|
||||||
holder.userRole.setImageDrawable(drawable);
|
holder.userRole.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -120,7 +121,7 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<AdminGetUsersAdap
|
|||||||
holder.userRole.setVisibility(View.GONE);
|
holder.userRole.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
import org.gitnex.tea4j.models.Collaborators;
|
import org.gitnex.tea4j.models.Collaborators;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
@ -24,7 +25,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdapter.AssigneesViewHolder> {
|
public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdapter.AssigneesViewHolder> {
|
||||||
|
|
||||||
private final Context mCtx;
|
private final Context context;
|
||||||
private final List<Collaborators> assigneesList;
|
private final List<Collaborators> assigneesList;
|
||||||
private List<String> assigneesStrings = new ArrayList<>();
|
private List<String> assigneesStrings = new ArrayList<>();
|
||||||
private List<String> currentAssignees;
|
private List<String> currentAssignees;
|
||||||
@ -36,9 +37,9 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||||||
void assigneesInterface(List<String> data);
|
void assigneesInterface(List<String> data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssigneesListAdapter(Context mCtx, List<Collaborators> dataMain, AssigneesListAdapterListener assigneesListener, List<String> currentAssignees) {
|
public AssigneesListAdapter(Context ctx, List<Collaborators> dataMain, AssigneesListAdapterListener assigneesListener, List<String> currentAssignees) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.assigneesList = dataMain;
|
this.assigneesList = dataMain;
|
||||||
this.assigneesListener = assigneesListener;
|
this.assigneesListener = assigneesListener;
|
||||||
this.currentAssignees = currentAssignees;
|
this.currentAssignees = currentAssignees;
|
||||||
@ -73,6 +74,7 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||||||
public void onBindViewHolder(@NonNull AssigneesListAdapter.AssigneesViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull AssigneesListAdapter.AssigneesViewHolder holder, int position) {
|
||||||
|
|
||||||
Collaborators currentItem = assigneesList.get(position);
|
Collaborators currentItem = assigneesList.get(position);
|
||||||
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
if(currentItem.getFull_name().equals("")) {
|
if(currentItem.getFull_name().equals("")) {
|
||||||
|
|
||||||
@ -83,7 +85,7 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||||||
holder.assigneesName.setText(Html.fromHtml(currentItem.getFull_name()));
|
holder.assigneesName.setText(Html.fromHtml(currentItem.getFull_name()));
|
||||||
}
|
}
|
||||||
PicassoService
|
PicassoService
|
||||||
.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(holder.assigneesAvatar);
|
.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(holder.assigneesAvatar);
|
||||||
|
|
||||||
for(int i = 0; i < assigneesList.size(); i++) {
|
for(int i = 0; i < assigneesList.size(); i++) {
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||||||
public class CollaboratorsAdapter extends BaseAdapter {
|
public class CollaboratorsAdapter extends BaseAdapter {
|
||||||
|
|
||||||
private final List<Collaborators> collaboratorsList;
|
private final List<Collaborators> collaboratorsList;
|
||||||
private final Context mCtx;
|
private final Context context;
|
||||||
|
|
||||||
private static class ViewHolder {
|
private static class ViewHolder {
|
||||||
|
|
||||||
@ -46,9 +46,9 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CollaboratorsAdapter(Context mCtx, List<Collaborators> collaboratorsListMain) {
|
public CollaboratorsAdapter(Context ctx, List<Collaborators> collaboratorsListMain) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.collaboratorsList = collaboratorsListMain;
|
this.collaboratorsList = collaboratorsListMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
if (finalView == null) {
|
if (finalView == null) {
|
||||||
|
|
||||||
finalView = LayoutInflater.from(mCtx).inflate(R.layout.list_collaborators, null);
|
finalView = LayoutInflater.from(context).inflate(R.layout.list_collaborators, null);
|
||||||
viewHolder = new ViewHolder(finalView);
|
viewHolder = new ViewHolder(finalView);
|
||||||
finalView.setTag(viewHolder);
|
finalView.setTag(viewHolder);
|
||||||
}
|
}
|
||||||
@ -90,8 +90,10 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
private void initData(ViewHolder viewHolder, int position) {
|
private void initData(ViewHolder viewHolder, int position) {
|
||||||
|
|
||||||
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
Collaborators currentItem = collaboratorsList.get(position);
|
Collaborators currentItem = collaboratorsList.get(position);
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.collaboratorAvatar);
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(viewHolder.collaboratorAvatar);
|
||||||
|
|
||||||
viewHolder.userLoginId = currentItem.getLogin();
|
viewHolder.userLoginId = currentItem.getLogin();
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ import java.util.Locale;
|
|||||||
|
|
||||||
public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
private final Context ctx;
|
private final Context context;
|
||||||
private final int TYPE_LOAD = 0;
|
private final int TYPE_LOAD = 0;
|
||||||
private List<Commits> commitsList;
|
private List<Commits> commitsList;
|
||||||
private CommitsAdapter.OnLoadMoreListener loadMoreListener;
|
private CommitsAdapter.OnLoadMoreListener loadMoreListener;
|
||||||
@ -35,7 +35,7 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||||||
|
|
||||||
public CommitsAdapter(Context ctx, List<Commits> commitsListMain) {
|
public CommitsAdapter(Context ctx, List<Commits> commitsListMain) {
|
||||||
|
|
||||||
this.ctx = ctx;
|
this.context = ctx;
|
||||||
this.commitsList = commitsListMain;
|
this.commitsList = commitsListMain;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||||||
@Override
|
@Override
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(ctx);
|
LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
|
|
||||||
if(viewType == TYPE_LOAD) {
|
if(viewType == TYPE_LOAD) {
|
||||||
return new CommitsHolder(inflater.inflate(R.layout.list_commits, parent, false));
|
return new CommitsHolder(inflater.inflate(R.layout.list_commits, parent, false));
|
||||||
@ -52,7 +52,6 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||||||
else {
|
else {
|
||||||
return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
|
return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -62,13 +61,11 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||||||
|
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
loadMoreListener.onLoadMore();
|
loadMoreListener.onLoadMore();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getItemViewType(position) == TYPE_LOAD) {
|
if(getItemViewType(position) == TYPE_LOAD) {
|
||||||
|
|
||||||
((CommitsHolder) holder).bindData(commitsList.get(position));
|
((CommitsHolder) holder).bindData(commitsList.get(position));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -82,14 +79,12 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||||||
else {
|
else {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
|
|
||||||
return commitsList.size();
|
return commitsList.size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CommitsHolder extends RecyclerView.ViewHolder {
|
class CommitsHolder extends RecyclerView.ViewHolder {
|
||||||
@ -107,27 +102,25 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||||||
commitCommitter = itemView.findViewById(R.id.commitCommitterVw);
|
commitCommitter = itemView.findViewById(R.id.commitCommitterVw);
|
||||||
commitDate = itemView.findViewById(R.id.commitDateVw);
|
commitDate = itemView.findViewById(R.id.commitDateVw);
|
||||||
commitHtmlUrl = itemView.findViewById(R.id.commitHtmlUrlVw);
|
commitHtmlUrl = itemView.findViewById(R.id.commitHtmlUrlVw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
void bindData(Commits commitsModel) {
|
void bindData(Commits commitsModel) {
|
||||||
|
|
||||||
final TinyDB tinyDb = TinyDB.getInstance(ctx);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
commitTitle.setText(EmojiParser.parseToUnicode(commitsModel.getCommit().getMessage()));
|
commitTitle.setText(EmojiParser.parseToUnicode(commitsModel.getCommit().getMessage()));
|
||||||
commitCommitter.setText(ctx.getString(R.string.commitCommittedBy, commitsModel.getCommit().getCommitter().getName()));
|
commitCommitter.setText(context.getString(R.string.commitCommittedBy, commitsModel.getCommit().getCommitter().getName()));
|
||||||
|
|
||||||
commitDate.setText(TimeHelper.formatTime(commitsModel.getCommit().getCommitter().getDate(), new Locale(locale), timeFormat, ctx));
|
commitDate.setText(TimeHelper.formatTime(commitsModel.getCommit().getCommitter().getDate(), new Locale(locale), timeFormat, context));
|
||||||
|
|
||||||
if(timeFormat.equals("pretty")) {
|
if(timeFormat.equals("pretty")) {
|
||||||
commitDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(commitsModel.getCommit().getCommitter().getDate()), ctx));
|
commitDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(commitsModel.getCommit().getCommitter().getDate()), context));
|
||||||
}
|
}
|
||||||
|
|
||||||
commitHtmlUrl.setOnClickListener(v -> ctx.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(commitsModel.getHtml_url()))));
|
commitHtmlUrl.setOnClickListener(v -> context.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(commitsModel.getHtml_url()))));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -138,32 +131,27 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||||
|
|
||||||
isMoreDataAvailable = moreDataAvailable;
|
isMoreDataAvailable = moreDataAvailable;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyDataChanged() {
|
public void notifyDataChanged() {
|
||||||
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnLoadMoreListener {
|
public interface OnLoadMoreListener {
|
||||||
|
|
||||||
void onLoadMore();
|
void onLoadMore();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoadMoreListener(CommitsAdapter.OnLoadMoreListener loadMoreListener) {
|
public void setLoadMoreListener(CommitsAdapter.OnLoadMoreListener loadMoreListener) {
|
||||||
|
|
||||||
this.loadMoreListener = loadMoreListener;
|
this.loadMoreListener = loadMoreListener;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateList(List<Commits> list) {
|
public void updateList(List<Commits> list) {
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
package org.mian.gitnex.adapters;
|
|
||||||
|
|
||||||
import android.text.SpannableStringBuilder;
|
|
||||||
import android.text.method.LinkMovementMethod;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import org.mian.gitnex.R;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Author M M Arif
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class CreditsAdapter extends RecyclerView.Adapter<CreditsAdapter.CreditsViewHolder> {
|
|
||||||
|
|
||||||
private List<CharSequence> creditsList;
|
|
||||||
|
|
||||||
static class CreditsViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
private TextView creditText;
|
|
||||||
|
|
||||||
private CreditsViewHolder(View itemView) {
|
|
||||||
super(itemView);
|
|
||||||
|
|
||||||
creditText = itemView.findViewById(R.id.creditText);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CreditsAdapter(List<CharSequence> creditsListMain) {
|
|
||||||
this.creditsList = creditsListMain;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public CreditsAdapter.CreditsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
||||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.credits, parent, false);
|
|
||||||
return new CreditsAdapter.CreditsViewHolder(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(@NonNull CreditsAdapter.CreditsViewHolder holder, int position) {
|
|
||||||
|
|
||||||
SpannableStringBuilder strBuilder = new SpannableStringBuilder(creditsList.get(position));
|
|
||||||
holder.creditText.setText((strBuilder));
|
|
||||||
holder.creditText.setMovementMethod(LinkMovementMethod.getInstance());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return creditsList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -17,6 +17,7 @@ import androidx.fragment.app.FragmentManager;
|
|||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.DraftsApi;
|
import org.mian.gitnex.database.api.DraftsApi;
|
||||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||||
@ -33,7 +34,7 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
|
|
||||||
private List<DraftWithRepository> draftsList;
|
private List<DraftWithRepository> draftsList;
|
||||||
private final FragmentManager fragmentManager;
|
private final FragmentManager fragmentManager;
|
||||||
private final Context mCtx;
|
private final Context context;
|
||||||
|
|
||||||
class DraftsViewHolder extends RecyclerView.ViewHolder {
|
class DraftsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
@ -56,7 +57,8 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
|
|
||||||
int getDraftId = draftWithRepository.getDraftId();
|
int getDraftId = draftWithRepository.getDraftId();
|
||||||
deleteDraft(getAdapterPosition());
|
deleteDraft(getAdapterPosition());
|
||||||
DraftsApi draftsApi = new DraftsApi(mCtx);
|
|
||||||
|
DraftsApi draftsApi = BaseApi.getInstance(context, DraftsApi.class);
|
||||||
draftsApi.deleteSingleDraft(getDraftId);
|
draftsApi.deleteSingleDraft(getDraftId);
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -76,24 +78,23 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
bundle.putString("commentAction", "edit");
|
bundle.putString("commentAction", "edit");
|
||||||
}
|
}
|
||||||
|
|
||||||
TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("issueNumber", String.valueOf(draftWithRepository.getIssueId()));
|
tinyDb.putString("issueNumber", String.valueOf(draftWithRepository.getIssueId()));
|
||||||
tinyDb.putLong("repositoryId", draftWithRepository.getRepositoryId());
|
tinyDb.putLong("repositoryId", draftWithRepository.getRepositoryId());
|
||||||
tinyDb.putString("issueType", draftWithRepository.getIssueType());
|
tinyDb.putString("issueType", draftWithRepository.getIssueType());
|
||||||
tinyDb.putString("repoFullName", draftWithRepository.getRepositoryOwner() + "/" + draftWithRepository.getRepositoryName());
|
tinyDb.putString("repoFullName", draftWithRepository.getRepositoryOwner() + "/" + draftWithRepository.getRepositoryName());
|
||||||
|
|
||||||
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle);
|
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle);
|
||||||
bottomSheetReplyFragment.setOnInteractedListener(() -> mCtx.startActivity(new Intent(mCtx, IssueDetailActivity.class)));
|
bottomSheetReplyFragment.setOnInteractedListener(() -> context.startActivity(new Intent(context, IssueDetailActivity.class)));
|
||||||
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
|
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DraftsAdapter(Context mCtx, FragmentManager fragmentManager, List<DraftWithRepository> draftsListMain) {
|
public DraftsAdapter(Context ctx, FragmentManager fragmentManager, List<DraftWithRepository> draftsListMain) {
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.fragmentManager = fragmentManager;
|
this.fragmentManager = fragmentManager;
|
||||||
this.draftsList = draftsListMain;
|
this.draftsList = draftsListMain;
|
||||||
}
|
}
|
||||||
@ -103,8 +104,7 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
draftsList.remove(position);
|
draftsList.remove(position);
|
||||||
notifyItemRemoved(position);
|
notifyItemRemoved(position);
|
||||||
notifyItemRangeChanged(position, draftsList.size());
|
notifyItemRangeChanged(position, draftsList.size());
|
||||||
Toasty.success(mCtx, mCtx.getResources().getString(R.string.draftsSingleDeleteSuccess));
|
Toasty.success(context, context.getResources().getString(R.string.draftsSingleDeleteSuccess));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -120,14 +120,14 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||||||
|
|
||||||
DraftWithRepository currentItem = draftsList.get(position);
|
DraftWithRepository currentItem = draftsList.get(position);
|
||||||
|
|
||||||
String issueNumber = "<font color='" + ResourcesCompat.getColor(mCtx.getResources(), R.color.lightGray, null) + "'>" + mCtx.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
|
String issueNumber = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
|
||||||
Spanned headTitle = HtmlCompat
|
Spanned headTitle = HtmlCompat
|
||||||
.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName(), HtmlCompat.FROM_HTML_MODE_LEGACY);
|
.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName(), HtmlCompat.FROM_HTML_MODE_LEGACY);
|
||||||
|
|
||||||
holder.repoInfo.setText(headTitle);
|
holder.repoInfo.setText(headTitle);
|
||||||
holder.draftWithRepository = currentItem;
|
holder.draftWithRepository = currentItem;
|
||||||
|
|
||||||
Markdown.render(mCtx, currentItem.getDraftText(), holder.draftText);
|
Markdown.render(context, currentItem.getDraftText(), holder.draftText);
|
||||||
|
|
||||||
if(!currentItem.getCommentId().equalsIgnoreCase("new")) {
|
if(!currentItem.getCommentId().equalsIgnoreCase("new")) {
|
||||||
holder.editCommentStatus.setVisibility(View.VISIBLE);
|
holder.editCommentStatus.setVisibility(View.VISIBLE);
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package org.mian.gitnex.adapters;
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
@ -11,30 +8,31 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
import com.amulyakhare.textdrawable.TextDrawable;
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
|
||||||
import org.gitnex.tea4j.models.UserRepositories;
|
import org.gitnex.tea4j.models.UserRepositories;
|
||||||
import org.gitnex.tea4j.models.WatchInfo;
|
import org.gitnex.tea4j.models.WatchInfo;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
import org.mian.gitnex.database.models.Repository;
|
import org.mian.gitnex.database.models.Repository;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
|
import org.mian.gitnex.helpers.ClickListener;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
import org.ocpsoft.prettytime.PrettyTime;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Locale;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -44,70 +42,64 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepositoriesAdapter.ReposSearchViewHolder> {
|
public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepositoriesAdapter.ReposSearchViewHolder> {
|
||||||
|
|
||||||
private List<UserRepositories> searchedReposList;
|
private final List<UserRepositories> reposList;
|
||||||
private Context mCtx;
|
private final Context context;
|
||||||
|
|
||||||
public ExploreRepositoriesAdapter(List<UserRepositories> dataList, Context mCtx) {
|
public ExploreRepositoriesAdapter(List<UserRepositories> dataList, Context ctx) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.searchedReposList = dataList;
|
this.reposList = dataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ReposSearchViewHolder extends RecyclerView.ViewHolder {
|
static class ReposSearchViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private ImageView image;
|
private UserRepositories userRepositories;
|
||||||
private TextView repoName;
|
|
||||||
private TextView repoDescription;
|
private final ImageView image;
|
||||||
private TextView fullName;
|
private final TextView repoName;
|
||||||
|
private final TextView orgName;
|
||||||
|
private final TextView repoDescription;
|
||||||
private CheckBox isRepoAdmin;
|
private CheckBox isRepoAdmin;
|
||||||
private ImageView repoPrivatePublic;
|
private final TextView repoStars;
|
||||||
private TextView repoStars;
|
private final TextView repoLastUpdated;
|
||||||
private TextView repoForks;
|
|
||||||
private TextView repoOpenIssuesCount;
|
|
||||||
private TextView repoType;
|
|
||||||
private LinearLayout archiveRepo;
|
|
||||||
private TextView repoBranch;
|
|
||||||
private TextView htmlUrl;
|
|
||||||
|
|
||||||
private ReposSearchViewHolder(View itemView) {
|
private ReposSearchViewHolder(View itemView) {
|
||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
repoName = itemView.findViewById(R.id.repoName);
|
repoName = itemView.findViewById(R.id.repoName);
|
||||||
|
orgName = itemView.findViewById(R.id.orgName);
|
||||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||||
image = itemView.findViewById(R.id.imageAvatar);
|
|
||||||
fullName = itemView.findViewById(R.id.repoFullName);
|
|
||||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
image = itemView.findViewById(R.id.imageAvatar);
|
||||||
repoStars = itemView.findViewById(R.id.repoStars);
|
repoStars = itemView.findViewById(R.id.repoStars);
|
||||||
repoForks = itemView.findViewById(R.id.repoForks);
|
repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
|
||||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
|
||||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
|
||||||
repoType = itemView.findViewById(R.id.repoType);
|
|
||||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
|
||||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
|
||||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
TextView repoFullName = v.findViewById(R.id.repoFullName);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
intent.putExtra("repoFullName", userRepositories.getFullName());
|
||||||
|
|
||||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
tinyDb.putString("repoFullName", userRepositories.getFullName());
|
||||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||||
tinyDb.putString("repoBranch", repoBranch.getText().toString());
|
tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
|
||||||
|
|
||||||
String[] parts = fullName.getText().toString().split("/");
|
if(userRepositories.getPrivateFlag()) {
|
||||||
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] parts = userRepositories.getFullName().split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||||
|
|
||||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
@ -116,13 +108,11 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
|
|
||||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", id);
|
tinyDb.putLong("repositoryId", id);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
@ -165,7 +155,6 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
|
|
||||||
tinyDb.putBoolean("repoWatch", false);
|
tinyDb.putBoolean("repoWatch", false);
|
||||||
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -174,74 +163,6 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
reposDropdownMenu.setOnClickListener(v -> {
|
|
||||||
|
|
||||||
final Context context = v.getContext();
|
|
||||||
|
|
||||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
|
||||||
|
|
||||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
|
||||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
|
||||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
|
||||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
|
||||||
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
|
|
||||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
|
||||||
|
|
||||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
|
||||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
|
||||||
dialog.setContentView(view);
|
|
||||||
dialog.show();
|
|
||||||
|
|
||||||
repoCopyUrl.setOnClickListener(openInBrowser -> {
|
|
||||||
|
|
||||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
|
|
||||||
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
|
|
||||||
assert clipboard != null;
|
|
||||||
clipboard.setPrimaryClip(clip);
|
|
||||||
|
|
||||||
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
|
|
||||||
dialog.dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
|
||||||
|
|
||||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
|
||||||
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
|
|
||||||
context.startActivity(intentOpenInBrowser);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoStargazers.setOnClickListener(stargazers -> {
|
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
|
||||||
intent.putExtra("repoFullNameForStars", fullName.getText());
|
|
||||||
context.startActivity(intent);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoWatchers.setOnClickListener(watchers -> {
|
|
||||||
|
|
||||||
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
|
||||||
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
|
|
||||||
context.startActivity(intentW);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoForksList.setOnClickListener(forks -> {
|
|
||||||
|
|
||||||
Intent intentW = new Intent(context, RepoForksActivity.class);
|
|
||||||
intentW.putExtra("repoFullNameForForks", fullName.getText());
|
|
||||||
context.startActivity(intentW);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -257,10 +178,16 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull final ExploreRepositoriesAdapter.ReposSearchViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull final ExploreRepositoriesAdapter.ReposSearchViewHolder holder, int position) {
|
||||||
|
|
||||||
UserRepositories currentItem = searchedReposList.get(position);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
holder.repoDescription.setVisibility(View.GONE);
|
UserRepositories currentItem = reposList.get(position);
|
||||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
|
||||||
|
String locale = tinyDb.getString("locale");
|
||||||
|
String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
holder.userRepositories = currentItem;
|
||||||
|
holder.orgName.setText(currentItem.getFullName().split("/")[0]);
|
||||||
|
holder.repoName.setText(currentItem.getFullName().split("/")[1]);
|
||||||
|
holder.repoStars.setText(currentItem.getStars_count());
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
int color = generator.getColor(currentItem.getName());
|
int color = generator.getColor(currentItem.getName());
|
||||||
@ -270,7 +197,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
|
|
||||||
if(currentItem.getAvatar_url() != null) {
|
if(currentItem.getAvatar_url() != null) {
|
||||||
if(!currentItem.getAvatar_url().equals("")) {
|
if(!currentItem.getAvatar_url().equals("")) {
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image);
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.image);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.image.setImageDrawable(drawable);
|
holder.image.setImageDrawable(drawable);
|
||||||
@ -280,41 +207,48 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
holder.image.setImageDrawable(drawable);
|
holder.image.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.repoName.setText(currentItem.getName());
|
if(currentItem.getUpdated_at() != null) {
|
||||||
|
|
||||||
|
switch(timeFormat) {
|
||||||
|
case "pretty": {
|
||||||
|
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
|
||||||
|
String createdTime = prettyTime.format(currentItem.getUpdated_at());
|
||||||
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "normal": {
|
||||||
|
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
|
String createdTime = formatter.format(currentItem.getUpdated_at());
|
||||||
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "normal1": {
|
||||||
|
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
|
String createdTime = formatter.format(currentItem.getUpdated_at());
|
||||||
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
holder.repoLastUpdated.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
if(!currentItem.getDescription().equals("")) {
|
if(!currentItem.getDescription().equals("")) {
|
||||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
|
||||||
holder.repoDescription.setText(currentItem.getDescription());
|
holder.repoDescription.setText(currentItem.getDescription());
|
||||||
}
|
}
|
||||||
holder.fullName.setText(currentItem.getFullName());
|
|
||||||
if(currentItem.getPrivateFlag()) {
|
|
||||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock);
|
|
||||||
holder.repoType.setText(R.string.strPrivate);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
holder.repoPrivatePublic.setVisibility(View.GONE);
|
|
||||||
holder.repoType.setText(R.string.strPublic);
|
|
||||||
}
|
|
||||||
holder.repoStars.setText(currentItem.getStars_count());
|
|
||||||
holder.repoForks.setText(currentItem.getForks_count());
|
|
||||||
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
|
||||||
if(holder.isRepoAdmin == null) {
|
if(holder.isRepoAdmin == null) {
|
||||||
holder.isRepoAdmin = new CheckBox(mCtx);
|
holder.isRepoAdmin = new CheckBox(context);
|
||||||
}
|
}
|
||||||
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||||
|
|
||||||
if(currentItem.isArchived()) {
|
|
||||||
holder.archiveRepo.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
holder.archiveRepo.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
|
|
||||||
return searchedReposList.size();
|
return reposList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyDataChanged() {
|
public void notifyDataChanged() {
|
||||||
|
@ -27,7 +27,7 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
|||||||
private final List<Files> originalFiles = new ArrayList<>();
|
private final List<Files> originalFiles = new ArrayList<>();
|
||||||
private final List<Files> alteredFiles = new ArrayList<>();
|
private final List<Files> alteredFiles = new ArrayList<>();
|
||||||
|
|
||||||
private final Context mCtx;
|
private final Context context;
|
||||||
|
|
||||||
private final FilesAdapterListener filesListener;
|
private final FilesAdapterListener filesListener;
|
||||||
|
|
||||||
@ -40,7 +40,6 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
|||||||
|
|
||||||
private Files file;
|
private Files file;
|
||||||
|
|
||||||
private final LinearLayout fileFrame;
|
|
||||||
private final ImageView fileTypeIs;
|
private final ImageView fileTypeIs;
|
||||||
private final TextView fileName;
|
private final TextView fileName;
|
||||||
private final TextView fileInfo;
|
private final TextView fileInfo;
|
||||||
@ -49,7 +48,7 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
|||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
fileFrame = itemView.findViewById(R.id.fileFrame);
|
LinearLayout fileFrame = itemView.findViewById(R.id.fileFrame);
|
||||||
fileName = itemView.findViewById(R.id.fileName);
|
fileName = itemView.findViewById(R.id.fileName);
|
||||||
fileTypeIs = itemView.findViewById(R.id.fileTypeIs);
|
fileTypeIs = itemView.findViewById(R.id.fileTypeIs);
|
||||||
fileInfo = itemView.findViewById(R.id.fileInfo);
|
fileInfo = itemView.findViewById(R.id.fileInfo);
|
||||||
@ -124,11 +123,10 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FilesAdapter(Context mCtx, FilesAdapterListener filesListener) {
|
public FilesAdapter(Context ctx, FilesAdapterListener filesListener) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.filesListener = filesListener;
|
this.filesListener = filesListener;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Files> getOriginalFiles() {
|
public List<Files> getOriginalFiles() {
|
||||||
@ -141,7 +139,6 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
|||||||
alteredFiles.addAll(originalFiles);
|
alteredFiles.addAll(originalFiles);
|
||||||
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -162,28 +159,28 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
|||||||
switch(currentItem.getType()) {
|
switch(currentItem.getType()) {
|
||||||
|
|
||||||
case "file":
|
case "file":
|
||||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(mCtx, R.drawable.ic_file));
|
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_file));
|
||||||
holder.fileInfo.setVisibility(View.VISIBLE);
|
holder.fileInfo.setVisibility(View.VISIBLE);
|
||||||
holder.fileInfo.setText(FileUtils.byteCountToDisplaySize(currentItem.getSize()));
|
holder.fileInfo.setText(FileUtils.byteCountToDisplaySize(currentItem.getSize()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "dir":
|
case "dir":
|
||||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(mCtx, R.drawable.ic_directory));
|
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_directory));
|
||||||
holder.fileInfo.setVisibility(View.GONE);
|
holder.fileInfo.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "submodule":
|
case "submodule":
|
||||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(mCtx, R.drawable.ic_submodule));
|
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_submodule));
|
||||||
holder.fileInfo.setVisibility(View.GONE);
|
holder.fileInfo.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "symlink":
|
case "symlink":
|
||||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(mCtx, R.drawable.ic_symlink));
|
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_symlink));
|
||||||
holder.fileInfo.setVisibility(View.GONE);
|
holder.fileInfo.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(mCtx, R.drawable.ic_question));
|
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_question));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,6 @@ public class FilesDiffAdapter extends BaseAdapter {
|
|||||||
COLOR_NORMAL = AppUtil.getColorFromAttribute(context, R.attr.primaryBackgroundColor);
|
COLOR_NORMAL = AppUtil.getColorFromAttribute(context, R.attr.primaryBackgroundColor);
|
||||||
COLOR_SELECTED = AppUtil.getColorFromAttribute(context, R.attr.diffSelectedColor);
|
COLOR_SELECTED = AppUtil.getColorFromAttribute(context, R.attr.diffSelectedColor);
|
||||||
COLOR_FONT = AppUtil.getColorFromAttribute(context, R.attr.inputTextColor);
|
COLOR_FONT = AppUtil.getColorFromAttribute(context, R.attr.inputTextColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -94,7 +93,6 @@ public class FilesDiffAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
diffStats.setVisibility(View.GONE);
|
diffStats.setVisibility(View.GONE);
|
||||||
diffLines.addView(getMessageView(context.getResources().getString(R.string.binaryFileError)));
|
diffLines.addView(getMessageView(context.getResources().getString(R.string.binaryFileError)));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -168,7 +166,6 @@ public class FilesDiffAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
diffTextView.setOnClickListener(v -> {
|
diffTextView.setOnClickListener(v -> {
|
||||||
|
|
||||||
if(((DiffTextView) v).getCurrentBackgroundColor() != COLOR_SELECTED) {
|
if(((DiffTextView) v).getCurrentBackgroundColor() != COLOR_SELECTED) {
|
||||||
@ -197,7 +194,6 @@ public class FilesDiffAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
stringBuilder.append(((DiffTextView) view).getText());
|
stringBuilder.append(((DiffTextView) view).getText());
|
||||||
stringBuilder.append("\n");
|
stringBuilder.append("\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stringBuilder.append("```\n\n");
|
stringBuilder.append("```\n\n");
|
||||||
@ -209,7 +205,6 @@ public class FilesDiffAdapter extends BaseAdapter {
|
|||||||
bundle.putBoolean("cursorToEnd", true);
|
bundle.putBoolean("cursorToEnd", true);
|
||||||
|
|
||||||
BottomSheetReplyFragment.newInstance(bundle).show(fragmentManager, "replyBottomSheet");
|
BottomSheetReplyFragment.newInstance(bundle).show(fragmentManager, "replyBottomSheet");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -226,7 +221,6 @@ public class FilesDiffAdapter extends BaseAdapter {
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
diffLines.addView(getMessageView(context.getResources().getString(R.string.fileTooLarge)));
|
diffLines.addView(getMessageView(context.getResources().getString(R.string.fileTooLarge)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -248,13 +242,11 @@ public class FilesDiffAdapter extends BaseAdapter {
|
|||||||
textView.setText(message);
|
textView.setText(message);
|
||||||
|
|
||||||
return textView;
|
return textView;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getLines(String content) {
|
private String[] getLines(String content) {
|
||||||
|
|
||||||
return content.split("\\R");
|
return content.split("\\R");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdapter.IssueCommentViewHolder> {
|
public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdapter.IssueCommentViewHolder> {
|
||||||
|
|
||||||
private final Context ctx;
|
private final Context context;
|
||||||
private final TinyDB tinyDB;
|
private final TinyDB tinyDB;
|
||||||
private final Bundle bundle;
|
private final Bundle bundle;
|
||||||
private final List<IssueComments> issuesComments;
|
private final List<IssueComments> issuesComments;
|
||||||
@ -53,14 +53,13 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
|
|
||||||
public IssueCommentsAdapter(Context ctx, Bundle bundle, List<IssueComments> issuesCommentsMain, FragmentManager fragmentManager, BottomSheetReplyFragment.OnInteractedListener onInteractedListener) {
|
public IssueCommentsAdapter(Context ctx, Bundle bundle, List<IssueComments> issuesCommentsMain, FragmentManager fragmentManager, BottomSheetReplyFragment.OnInteractedListener onInteractedListener) {
|
||||||
|
|
||||||
this.ctx = ctx;
|
this.context = ctx;
|
||||||
this.bundle = bundle;
|
this.bundle = bundle;
|
||||||
this.issuesComments = issuesCommentsMain;
|
this.issuesComments = issuesCommentsMain;
|
||||||
this.fragmentManager = fragmentManager;
|
this.fragmentManager = fragmentManager;
|
||||||
this.onInteractedListener = onInteractedListener;
|
this.onInteractedListener = onInteractedListener;
|
||||||
|
|
||||||
tinyDB = TinyDB.getInstance(ctx);
|
tinyDB = TinyDB.getInstance(ctx);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class IssueCommentViewHolder extends RecyclerView.ViewHolder {
|
class IssueCommentViewHolder extends RecyclerView.ViewHolder {
|
||||||
@ -318,39 +317,40 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
|
|
||||||
String timeFormat = tinyDB.getString("dateFormat");
|
String timeFormat = tinyDB.getString("dateFormat");
|
||||||
IssueComments issueComment = issuesComments.get(position);
|
IssueComments issueComment = issuesComments.get(position);
|
||||||
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
holder.userLoginId = issueComment.getUser().getLogin();
|
holder.userLoginId = issueComment.getUser().getLogin();
|
||||||
|
|
||||||
holder.issueComment = issueComment;
|
holder.issueComment = issueComment;
|
||||||
holder.author.setText(issueComment.getUser().getUsername());
|
holder.author.setText(issueComment.getUser().getUsername());
|
||||||
|
|
||||||
PicassoService.getInstance(ctx).get()
|
PicassoService.getInstance(context).get()
|
||||||
.load(issueComment.getUser().getAvatar_url())
|
.load(issueComment.getUser().getAvatar_url())
|
||||||
.placeholder(R.drawable.loader_animated)
|
.placeholder(R.drawable.loader_animated)
|
||||||
.transform(new RoundedTransformation(4, 0))
|
.transform(new RoundedTransformation(imgRadius, 0))
|
||||||
.resize(AppUtil.getPixelsFromDensity(ctx, 35), AppUtil.getPixelsFromDensity(ctx, 35))
|
.resize(AppUtil.getPixelsFromDensity(context, 35), AppUtil.getPixelsFromDensity(context, 35))
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.into(holder.avatar);
|
.into(holder.avatar);
|
||||||
|
|
||||||
Markdown.render(ctx, EmojiParser.parseToUnicode(issueComment.getBody()), holder.comment);
|
Markdown.render(context, EmojiParser.parseToUnicode(issueComment.getBody()), holder.comment);
|
||||||
|
|
||||||
StringBuilder informationBuilder = null;
|
StringBuilder informationBuilder = null;
|
||||||
if(issueComment.getCreated_at() != null) {
|
if(issueComment.getCreated_at() != null) {
|
||||||
|
|
||||||
if(timeFormat.equals("pretty")) {
|
if(timeFormat.equals("pretty")) {
|
||||||
|
|
||||||
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), Locale.getDefault(), "pretty", ctx));
|
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), Locale.getDefault(), "pretty", context));
|
||||||
holder.information.setOnClickListener(v -> TimeHelper.customDateFormatForToastDateFormat(issueComment.getCreated_at()));
|
holder.information.setOnClickListener(v -> TimeHelper.customDateFormatForToastDateFormat(issueComment.getCreated_at()));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(timeFormat.equals("normal")) {
|
else if(timeFormat.equals("normal")) {
|
||||||
|
|
||||||
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), Locale.getDefault(), "normal", ctx));
|
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), Locale.getDefault(), "normal", context));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!issueComment.getCreated_at().equals(issueComment.getUpdated_at())) {
|
if(!issueComment.getCreated_at().equals(issueComment.getUpdated_at())) {
|
||||||
if(informationBuilder != null) {
|
if(informationBuilder != null) {
|
||||||
informationBuilder.append(ctx.getString(R.string.colorfulBulletSpan)).append(ctx.getString(R.string.modifiedText));
|
informationBuilder.append(context.getString(R.string.colorfulBulletSpan)).append(context.getString(R.string.modifiedText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -361,7 +361,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||||||
bundle1.putAll(bundle);
|
bundle1.putAll(bundle);
|
||||||
bundle1.putInt("commentId", issueComment.getId());
|
bundle1.putInt("commentId", issueComment.getId());
|
||||||
|
|
||||||
ReactionList reactionList = new ReactionList(ctx, bundle1);
|
ReactionList reactionList = new ReactionList(context, bundle1);
|
||||||
|
|
||||||
holder.commentReactionBadges.addView(reactionList);
|
holder.commentReactionBadges.addView(reactionList);
|
||||||
reactionList.setOnReactionAddedListener(() -> {
|
reactionList.setOnReactionAddedListener(() -> {
|
||||||
|
@ -7,7 +7,6 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
@ -41,11 +40,10 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
private OnLoadMoreListener loadMoreListener;
|
private OnLoadMoreListener loadMoreListener;
|
||||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||||
|
|
||||||
public IssuesAdapter(Context context, List<Issues> issuesListMain) {
|
public IssuesAdapter(Context ctx, List<Issues> issuesListMain) {
|
||||||
|
|
||||||
this.context = context;
|
this.context = ctx;
|
||||||
this.issuesList = issuesListMain;
|
this.issuesList = issuesListMain;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -60,7 +58,6 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
else {
|
else {
|
||||||
return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
|
return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,15 +67,12 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
|
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
loadMoreListener.onLoadMore();
|
loadMoreListener.onLoadMore();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getItemViewType(position) == TYPE_LOAD) {
|
if(getItemViewType(position) == TYPE_LOAD) {
|
||||||
|
|
||||||
((IssuesHolder) holder).bindData(issuesList.get(position));
|
((IssuesHolder) holder).bindData(issuesList.get(position));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -90,14 +84,12 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
else {
|
else {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
|
|
||||||
return issuesList.size();
|
return issuesList.size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class IssuesHolder extends RecyclerView.ViewHolder {
|
class IssuesHolder extends RecyclerView.ViewHolder {
|
||||||
@ -112,16 +104,14 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
IssuesHolder(View itemView) {
|
IssuesHolder(View itemView) {
|
||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
issueAssigneeAvatar = itemView.findViewById(R.id.assigneeAvatar);
|
issueAssigneeAvatar = itemView.findViewById(R.id.assigneeAvatar);
|
||||||
issueTitle = itemView.findViewById(R.id.issueTitle);
|
issueTitle = itemView.findViewById(R.id.issueTitle);
|
||||||
issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount);
|
issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount);
|
||||||
LinearLayout frameCommentsCount = itemView.findViewById(R.id.frameCommentsCount);
|
|
||||||
issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime);
|
issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime);
|
||||||
|
|
||||||
issueTitle.setOnClickListener(title -> {
|
itemView.setOnClickListener(layoutView -> {
|
||||||
|
|
||||||
Context context = title.getContext();
|
Context context = layoutView.getContext();
|
||||||
|
|
||||||
Intent intent = new Intent(context, IssueDetailActivity.class);
|
Intent intent = new Intent(context, IssueDetailActivity.class);
|
||||||
intent.putExtra("issueNumber", issue.getNumber());
|
intent.putExtra("issueNumber", issue.getNumber());
|
||||||
@ -130,21 +120,6 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
tinyDb.putString("issueNumber", String.valueOf(issue.getNumber()));
|
tinyDb.putString("issueNumber", String.valueOf(issue.getNumber()));
|
||||||
tinyDb.putString("issueType", "Issue");
|
tinyDb.putString("issueType", "Issue");
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
frameCommentsCount.setOnClickListener(commentsCount -> {
|
|
||||||
|
|
||||||
Context context = commentsCount.getContext();
|
|
||||||
|
|
||||||
Intent intent = new Intent(context, IssueDetailActivity.class);
|
|
||||||
intent.putExtra("issueNumber", issue.getNumber());
|
|
||||||
|
|
||||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
|
||||||
tinyDb.putString("issueNumber", String.valueOf(issue.getNumber()));
|
|
||||||
tinyDb.putString("issueType", "Issue");
|
|
||||||
context.startActivity(intent);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
issueAssigneeAvatar.setOnClickListener(v -> {
|
issueAssigneeAvatar.setOnClickListener(v -> {
|
||||||
@ -163,10 +138,12 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
String locale = tinyDb.getString("locale");
|
String locale = tinyDb.getString("locale");
|
||||||
String timeFormat = tinyDb.getString("dateFormat");
|
String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
PicassoService.getInstance(context).get()
|
PicassoService.getInstance(context).get()
|
||||||
.load(issue.getUser().getAvatar_url())
|
.load(issue.getUser().getAvatar_url())
|
||||||
.placeholder(R.drawable.loader_animated)
|
.placeholder(R.drawable.loader_animated)
|
||||||
.transform(new RoundedTransformation(8, 0))
|
.transform(new RoundedTransformation(imgRadius, 0))
|
||||||
.resize(120, 120)
|
.resize(120, 120)
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.into(issueAssigneeAvatar);
|
.into(issueAssigneeAvatar);
|
||||||
@ -209,32 +186,27 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||||
|
|
||||||
isMoreDataAvailable = moreDataAvailable;
|
isMoreDataAvailable = moreDataAvailable;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyDataChanged() {
|
public void notifyDataChanged() {
|
||||||
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnLoadMoreListener {
|
public interface OnLoadMoreListener {
|
||||||
|
|
||||||
void onLoadMore();
|
void onLoadMore();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||||
|
|
||||||
this.loadMoreListener = loadMoreListener;
|
this.loadMoreListener = loadMoreListener;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateList(List<Issues> list) {
|
public void updateList(List<Issues> list) {
|
||||||
|
@ -20,7 +20,6 @@ import org.mian.gitnex.R;
|
|||||||
import org.mian.gitnex.activities.CreateLabelActivity;
|
import org.mian.gitnex.activities.CreateLabelActivity;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.ColorInverter;
|
import org.mian.gitnex.helpers.ColorInverter;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,21 +28,17 @@ import java.util.List;
|
|||||||
|
|
||||||
public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsViewHolder> {
|
public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsViewHolder> {
|
||||||
|
|
||||||
private List<Labels> labelsList;
|
private final List<Labels> labelsList;
|
||||||
final private Context mCtx;
|
|
||||||
private ArrayList<Integer> labelsArray = new ArrayList<>();
|
|
||||||
private static String type;
|
private static String type;
|
||||||
private static String orgName;
|
private static String orgName;
|
||||||
|
|
||||||
static class LabelsViewHolder extends RecyclerView.ViewHolder {
|
static class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private TextView labelTitle;
|
private Labels labels;
|
||||||
private TextView labelId;
|
|
||||||
private TextView labelColor;
|
|
||||||
|
|
||||||
private CardView labelView;
|
private final CardView labelView;
|
||||||
private ImageView labelIcon;
|
private final ImageView labelIcon;
|
||||||
private TextView labelName;
|
private final TextView labelName;
|
||||||
|
|
||||||
private LabelsViewHolder(View itemView) {
|
private LabelsViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@ -52,9 +47,6 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
|||||||
labelIcon = itemView.findViewById(R.id.labelIcon);
|
labelIcon = itemView.findViewById(R.id.labelIcon);
|
||||||
labelName = itemView.findViewById(R.id.labelName);
|
labelName = itemView.findViewById(R.id.labelName);
|
||||||
ImageView labelsOptionsMenu = itemView.findViewById(R.id.labelsOptionsMenu);
|
ImageView labelsOptionsMenu = itemView.findViewById(R.id.labelsOptionsMenu);
|
||||||
labelTitle = itemView.findViewById(R.id.labelTitle);
|
|
||||||
labelId = itemView.findViewById(R.id.labelId);
|
|
||||||
labelColor = itemView.findViewById(R.id.labelColor);
|
|
||||||
|
|
||||||
labelsOptionsMenu.setOnClickListener(v -> {
|
labelsOptionsMenu.setOnClickListener(v -> {
|
||||||
|
|
||||||
@ -67,7 +59,7 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
|||||||
TextView labelMenuDelete = view.findViewById(R.id.labelMenuDelete);
|
TextView labelMenuDelete = view.findViewById(R.id.labelMenuDelete);
|
||||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||||
|
|
||||||
bottomSheetHeader.setText(labelTitle.getText());
|
bottomSheetHeader.setText(labels.getName());
|
||||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||||
dialog.setContentView(view);
|
dialog.setContentView(view);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
@ -75,27 +67,25 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
|||||||
labelMenuEdit.setOnClickListener(editLabel -> {
|
labelMenuEdit.setOnClickListener(editLabel -> {
|
||||||
|
|
||||||
Intent intent = new Intent(context, CreateLabelActivity.class);
|
Intent intent = new Intent(context, CreateLabelActivity.class);
|
||||||
intent.putExtra("labelId", labelId.getText());
|
intent.putExtra("labelId", String.valueOf(labels.getId()));
|
||||||
intent.putExtra("labelTitle", labelTitle.getText());
|
intent.putExtra("labelTitle", labels.getName());
|
||||||
intent.putExtra("labelColor", labelColor.getText());
|
intent.putExtra("labelColor", labels.getColor());
|
||||||
intent.putExtra("labelAction", "edit");
|
intent.putExtra("labelAction", "edit");
|
||||||
intent.putExtra("type", type);
|
intent.putExtra("type", type);
|
||||||
intent.putExtra("orgName", orgName);
|
intent.putExtra("orgName", orgName);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
labelMenuDelete.setOnClickListener(deleteLabel -> {
|
labelMenuDelete.setOnClickListener(deleteLabel -> {
|
||||||
|
|
||||||
AlertDialogs.labelDeleteDialog(context, labelTitle.getText().toString(), labelId.getText().toString(),
|
AlertDialogs.labelDeleteDialog(context, labels.getName(), String.valueOf(labels.getId()),
|
||||||
context.getResources().getString(R.string.labelDeleteTitle),
|
context.getResources().getString(R.string.labelDeleteTitle),
|
||||||
context.getResources().getString(R.string.labelDeleteMessage),
|
context.getResources().getString(R.string.labelDeleteMessage),
|
||||||
context.getResources().getString(R.string.labelDeleteTitle),
|
context.getResources().getString(R.string.labelDeleteTitle),
|
||||||
context.getResources().getString(R.string.labelDeleteNegativeButton),
|
context.getResources().getString(R.string.labelDeleteNegativeButton),
|
||||||
type, orgName);
|
type, orgName);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -103,9 +93,8 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LabelsAdapter(Context mCtx, List<Labels> labelsMain, String type, String orgName) {
|
public LabelsAdapter(Context ctx, List<Labels> labelsMain, String type, String orgName) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
|
||||||
this.labelsList = labelsMain;
|
this.labelsList = labelsMain;
|
||||||
LabelsAdapter.type = type;
|
LabelsAdapter.type = type;
|
||||||
LabelsAdapter.orgName = orgName;
|
LabelsAdapter.orgName = orgName;
|
||||||
@ -122,10 +111,7 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
|||||||
public void onBindViewHolder(@NonNull LabelsAdapter.LabelsViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull LabelsAdapter.LabelsViewHolder holder, int position) {
|
||||||
|
|
||||||
Labels currentItem = labelsList.get(position);
|
Labels currentItem = labelsList.get(position);
|
||||||
|
holder.labels = currentItem;
|
||||||
holder.labelTitle.setText(currentItem.getName());
|
|
||||||
holder.labelId.setText(String.valueOf(currentItem.getId()));
|
|
||||||
holder.labelColor.setText(currentItem.getColor());
|
|
||||||
|
|
||||||
String labelColor = currentItem.getColor();
|
String labelColor = currentItem.getColor();
|
||||||
String labelName = currentItem.getName();
|
String labelName = currentItem.getName();
|
||||||
@ -138,7 +124,6 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
|||||||
holder.labelName.setTextColor(contrastColor);
|
holder.labelName.setTextColor(contrastColor);
|
||||||
holder.labelName.setText(labelName);
|
holder.labelName.setText(labelName);
|
||||||
holder.labelView.setCardBackgroundColor(color);
|
holder.labelView.setCardBackgroundColor(color);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,11 +22,11 @@ import java.util.List;
|
|||||||
public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.LabelsViewHolder> {
|
public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.LabelsViewHolder> {
|
||||||
|
|
||||||
private List<Integer> currentLabelsIds;
|
private List<Integer> currentLabelsIds;
|
||||||
private List<Labels> labels;
|
private final List<Labels> labels;
|
||||||
private List<String> labelsStrings = new ArrayList<>();
|
private final List<String> labelsStrings = new ArrayList<>();
|
||||||
private List<Integer> labelsIds = new ArrayList<>();
|
private List<Integer> labelsIds = new ArrayList<>();
|
||||||
|
|
||||||
private LabelsListAdapterListener labelsListener;
|
private final LabelsListAdapterListener labelsListener;
|
||||||
|
|
||||||
public interface LabelsListAdapterListener {
|
public interface LabelsListAdapterListener {
|
||||||
|
|
||||||
@ -43,9 +43,9 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
|
|||||||
|
|
||||||
static class LabelsViewHolder extends RecyclerView.ViewHolder {
|
static class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private CheckBox labelSelection;
|
private final CheckBox labelSelection;
|
||||||
private TextView labelText;
|
private final TextView labelText;
|
||||||
private ImageView labelColor;
|
private final ImageView labelColor;
|
||||||
|
|
||||||
private LabelsViewHolder(View itemView) {
|
private LabelsViewHolder(View itemView) {
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ import java.util.List;
|
|||||||
public class MembersByOrgAdapter extends BaseAdapter implements Filterable {
|
public class MembersByOrgAdapter extends BaseAdapter implements Filterable {
|
||||||
|
|
||||||
private final List<UserInfo> membersList;
|
private final List<UserInfo> membersList;
|
||||||
private final Context mCtx;
|
private final Context context;
|
||||||
private final List<UserInfo> membersListFull;
|
private final List<UserInfo> membersListFull;
|
||||||
|
|
||||||
private static class ViewHolder {
|
private static class ViewHolder {
|
||||||
@ -50,9 +50,9 @@ public class MembersByOrgAdapter extends BaseAdapter implements Filterable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MembersByOrgAdapter(Context mCtx, List<UserInfo> membersListMain) {
|
public MembersByOrgAdapter(Context ctx, List<UserInfo> membersListMain) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.membersList = membersListMain;
|
this.membersList = membersListMain;
|
||||||
membersListFull = new ArrayList<>(membersList);
|
membersListFull = new ArrayList<>(membersList);
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ public class MembersByOrgAdapter extends BaseAdapter implements Filterable {
|
|||||||
|
|
||||||
if (finalView == null) {
|
if (finalView == null) {
|
||||||
|
|
||||||
finalView = LayoutInflater.from(mCtx).inflate(R.layout.list_members_by_org, null);
|
finalView = LayoutInflater.from(context).inflate(R.layout.list_members_by_org, null);
|
||||||
viewHolder = new ViewHolder(finalView);
|
viewHolder = new ViewHolder(finalView);
|
||||||
finalView.setTag(viewHolder);
|
finalView.setTag(viewHolder);
|
||||||
}
|
}
|
||||||
@ -96,7 +96,9 @@ public class MembersByOrgAdapter extends BaseAdapter implements Filterable {
|
|||||||
private void initData(MembersByOrgAdapter.ViewHolder viewHolder, int position) {
|
private void initData(MembersByOrgAdapter.ViewHolder viewHolder, int position) {
|
||||||
|
|
||||||
UserInfo currentItem = membersList.get(position);
|
UserInfo currentItem = membersList.get(position);
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(viewHolder.memberAvatar);
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(viewHolder.memberAvatar);
|
||||||
|
|
||||||
viewHolder.userLoginId = currentItem.getLogin();
|
viewHolder.userLoginId = currentItem.getLogin();
|
||||||
|
|
||||||
@ -108,7 +110,6 @@ public class MembersByOrgAdapter extends BaseAdapter implements Filterable {
|
|||||||
|
|
||||||
viewHolder.memberName.setText(currentItem.getLogin());
|
viewHolder.memberName.setText(currentItem.getLogin());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,19 +35,17 @@ import java.util.Locale;
|
|||||||
|
|
||||||
public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
private Context context;
|
private final Context context;
|
||||||
private final int TYPE_LOAD = 0;
|
private final int TYPE_LOAD = 0;
|
||||||
private List<Milestones> dataList;
|
private List<Milestones> dataList;
|
||||||
private OnLoadMoreListener loadMoreListener;
|
private OnLoadMoreListener loadMoreListener;
|
||||||
private boolean isLoading = false;
|
private boolean isLoading = false;
|
||||||
private boolean isMoreDataAvailable = true;
|
private boolean isMoreDataAvailable = true;
|
||||||
private String TAG = Constants.tagMilestonesAdapter;
|
|
||||||
|
|
||||||
public MilestonesAdapter(Context context, List<Milestones> dataListMain) {
|
public MilestonesAdapter(Context ctx, List<Milestones> dataListMain) {
|
||||||
|
|
||||||
this.context = context;
|
this.context = ctx;
|
||||||
this.dataList = dataListMain;
|
this.dataList = dataListMain;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -62,7 +60,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
else {
|
else {
|
||||||
return new MilestonesAdapter.LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
|
return new MilestonesAdapter.LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -72,33 +69,29 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
|
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
loadMoreListener.onLoadMore();
|
loadMoreListener.onLoadMore();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getItemViewType(position) == TYPE_LOAD) {
|
if(getItemViewType(position) == TYPE_LOAD) {
|
||||||
|
|
||||||
((MilestonesAdapter.DataHolder) holder).bindData(dataList.get(position));
|
((MilestonesAdapter.DataHolder) holder).bindData(dataList.get(position));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DataHolder extends RecyclerView.ViewHolder {
|
class DataHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private TextView milestoneId;
|
private Milestones milestones;
|
||||||
private TextView msTitle;
|
|
||||||
private TextView msDescription;
|
private final TextView msTitle;
|
||||||
private TextView msOpenIssues;
|
private final TextView msDescription;
|
||||||
private TextView msClosedIssues;
|
private final TextView msOpenIssues;
|
||||||
private TextView msDueDate;
|
private final TextView msClosedIssues;
|
||||||
private ProgressBar msProgress;
|
private final TextView msDueDate;
|
||||||
private TextView milestoneStatus;
|
private final ProgressBar msProgress;
|
||||||
|
|
||||||
DataHolder(View itemView) {
|
DataHolder(View itemView) {
|
||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
milestoneId = itemView.findViewById(R.id.milestoneId);
|
|
||||||
msTitle = itemView.findViewById(R.id.milestoneTitle);
|
msTitle = itemView.findViewById(R.id.milestoneTitle);
|
||||||
msDescription = itemView.findViewById(R.id.milestoneDescription);
|
msDescription = itemView.findViewById(R.id.milestoneDescription);
|
||||||
msOpenIssues = itemView.findViewById(R.id.milestoneIssuesOpen);
|
msOpenIssues = itemView.findViewById(R.id.milestoneIssuesOpen);
|
||||||
@ -106,12 +99,11 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
msDueDate = itemView.findViewById(R.id.milestoneDueDate);
|
msDueDate = itemView.findViewById(R.id.milestoneDueDate);
|
||||||
msProgress = itemView.findViewById(R.id.milestoneProgress);
|
msProgress = itemView.findViewById(R.id.milestoneProgress);
|
||||||
ImageView milestonesMenu = itemView.findViewById(R.id.milestonesMenu);
|
ImageView milestonesMenu = itemView.findViewById(R.id.milestonesMenu);
|
||||||
milestoneStatus = itemView.findViewById(R.id.milestoneStatus);
|
|
||||||
|
|
||||||
milestonesMenu.setOnClickListener(v -> {
|
milestonesMenu.setOnClickListener(v -> {
|
||||||
|
|
||||||
Context ctx = v.getContext();
|
Context ctx = v.getContext();
|
||||||
int milestoneId_ = Integer.parseInt(milestoneId.getText().toString());
|
int milestoneId_ = Integer.parseInt(String.valueOf(milestones.getId()));
|
||||||
|
|
||||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(ctx).inflate(R.layout.bottom_sheet_milestones_in_list, null);
|
@SuppressLint("InflateParams") View view = LayoutInflater.from(ctx).inflate(R.layout.bottom_sheet_milestones_in_list, null);
|
||||||
|
|
||||||
@ -122,17 +114,15 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
dialog.setContentView(view);
|
dialog.setContentView(view);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
if(milestoneStatus.getText().toString().equals("open")) {
|
if(milestones.getState().equals("open")) {
|
||||||
|
|
||||||
closeMilestone.setVisibility(View.VISIBLE);
|
closeMilestone.setVisibility(View.VISIBLE);
|
||||||
openMilestone.setVisibility(View.GONE);
|
openMilestone.setVisibility(View.GONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
closeMilestone.setVisibility(View.GONE);
|
closeMilestone.setVisibility(View.GONE);
|
||||||
openMilestone.setVisibility(View.VISIBLE);
|
openMilestone.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
closeMilestone.setOnClickListener(v12 -> {
|
closeMilestone.setOnClickListener(v12 -> {
|
||||||
@ -140,7 +130,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
MilestoneActions.closeMilestone(ctx, milestoneId_);
|
MilestoneActions.closeMilestone(ctx, milestoneId_);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
updateAdapter(getAdapterPosition());
|
updateAdapter(getAdapterPosition());
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
openMilestone.setOnClickListener(v12 -> {
|
openMilestone.setOnClickListener(v12 -> {
|
||||||
@ -148,7 +137,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
MilestoneActions.openMilestone(ctx, milestoneId_);
|
MilestoneActions.openMilestone(ctx, milestoneId_);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
updateAdapter(getAdapterPosition());
|
updateAdapter(getAdapterPosition());
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -158,13 +146,11 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
void bindData(Milestones dataModel) {
|
void bindData(Milestones dataModel) {
|
||||||
|
|
||||||
|
this.milestones = dataModel;
|
||||||
final TinyDB tinyDb = TinyDB.getInstance(context);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
milestoneId.setText(String.valueOf(dataModel.getId()));
|
|
||||||
milestoneStatus.setText(dataModel.getState());
|
|
||||||
|
|
||||||
Markdown.render(context, dataModel.getTitle(), msTitle);
|
Markdown.render(context, dataModel.getTitle(), msTitle);
|
||||||
|
|
||||||
if(!dataModel.getDescription().equals("")) {
|
if(!dataModel.getDescription().equals("")) {
|
||||||
@ -185,14 +171,12 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
|
|
||||||
msProgress.setProgress(100);
|
msProgress.setProgress(100);
|
||||||
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 100), context));
|
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 100), context));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
int msCompletion = 100 * dataModel.getClosed_issues() / (dataModel.getOpen_issues() + dataModel.getClosed_issues());
|
int msCompletion = 100 * dataModel.getClosed_issues() / (dataModel.getOpen_issues() + dataModel.getClosed_issues());
|
||||||
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, msCompletion), context));
|
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, msCompletion), context));
|
||||||
msProgress.setProgress(msCompletion);
|
msProgress.setProgress(msCompletion);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -200,11 +184,11 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
|
|
||||||
msProgress.setProgress(0);
|
msProgress.setProgress(0);
|
||||||
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 0), context));
|
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 0), context));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dataModel.getDue_on() != null) {
|
if(dataModel.getDue_on() != null) {
|
||||||
|
|
||||||
|
String TAG = Constants.tagMilestonesAdapter;
|
||||||
if(timeFormat.equals("normal") || timeFormat.equals("pretty")) {
|
if(timeFormat.equals("normal") || timeFormat.equals("pretty")) {
|
||||||
|
|
||||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", new Locale(locale));
|
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", new Locale(locale));
|
||||||
@ -226,7 +210,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
|
|
||||||
msDueDate.setText(dueDate);
|
msDueDate.setText(dueDate);
|
||||||
msDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToast(dataModel.getDue_on()), context));
|
msDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToast(dataModel.getDue_on()), context));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(timeFormat.equals("normal1")) {
|
else if(timeFormat.equals("normal1")) {
|
||||||
|
|
||||||
@ -244,7 +227,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
assert date1 != null;
|
assert date1 != null;
|
||||||
String dueDate = formatter.format(date1);
|
String dueDate = formatter.format(date1);
|
||||||
msDueDate.setText(dueDate);
|
msDueDate.setText(dueDate);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -262,7 +244,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
dataList.remove(position);
|
dataList.remove(position);
|
||||||
notifyItemRemoved(position);
|
notifyItemRemoved(position);
|
||||||
notifyItemRangeChanged(position, dataList.size());
|
notifyItemRangeChanged(position, dataList.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -274,14 +255,12 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
else {
|
else {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
|
|
||||||
return dataList.size();
|
return dataList.size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class LoadHolder extends RecyclerView.ViewHolder {
|
static class LoadHolder extends RecyclerView.ViewHolder {
|
||||||
@ -290,32 +269,27 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||||
|
|
||||||
isMoreDataAvailable = moreDataAvailable;
|
isMoreDataAvailable = moreDataAvailable;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyDataChanged() {
|
public void notifyDataChanged() {
|
||||||
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnLoadMoreListener {
|
public interface OnLoadMoreListener {
|
||||||
|
|
||||||
void onLoadMore();
|
void onLoadMore();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||||
|
|
||||||
this.loadMoreListener = loadMoreListener;
|
this.loadMoreListener = loadMoreListener;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateList(List<Milestones> list) {
|
public void updateList(List<Milestones> list) {
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package org.mian.gitnex.adapters;
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
@ -13,31 +10,32 @@ import android.widget.CheckBox;
|
|||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
import com.amulyakhare.textdrawable.TextDrawable;
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
|
||||||
import org.gitnex.tea4j.models.UserRepositories;
|
import org.gitnex.tea4j.models.UserRepositories;
|
||||||
import org.gitnex.tea4j.models.WatchInfo;
|
import org.gitnex.tea4j.models.WatchInfo;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
import org.mian.gitnex.database.models.Repository;
|
import org.mian.gitnex.database.models.Repository;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
|
import org.mian.gitnex.helpers.ClickListener;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
import org.ocpsoft.prettytime.PrettyTime;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Locale;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -47,64 +45,59 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.MyReposViewHolder> implements Filterable {
|
public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.MyReposViewHolder> implements Filterable {
|
||||||
|
|
||||||
private List<UserRepositories> reposList;
|
private final List<UserRepositories> reposList;
|
||||||
private Context mCtx;
|
private final Context context;
|
||||||
private List<UserRepositories> reposListFull;
|
private final List<UserRepositories> reposListFull;
|
||||||
|
|
||||||
static class MyReposViewHolder extends RecyclerView.ViewHolder {
|
static class MyReposViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private ImageView imageAvatar;
|
private UserRepositories userRepositories;
|
||||||
private TextView repoName;
|
|
||||||
private TextView repoDescription;
|
private final ImageView image;
|
||||||
private TextView repoFullName;
|
private final TextView repoName;
|
||||||
private ImageView repoPrivatePublic;
|
private final TextView orgName;
|
||||||
private TextView repoStars;
|
private final TextView repoDescription;
|
||||||
private TextView repoForks;
|
|
||||||
private TextView repoOpenIssuesCount;
|
|
||||||
private TextView repoType;
|
|
||||||
private CheckBox isRepoAdmin;
|
private CheckBox isRepoAdmin;
|
||||||
private LinearLayout archiveRepo;
|
private final TextView repoStars;
|
||||||
private TextView repoBranch;
|
private final TextView repoLastUpdated;
|
||||||
private TextView htmlUrl;
|
|
||||||
|
|
||||||
private MyReposViewHolder(View itemView) {
|
private MyReposViewHolder(View itemView) {
|
||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
repoName = itemView.findViewById(R.id.repoName);
|
repoName = itemView.findViewById(R.id.repoName);
|
||||||
|
orgName = itemView.findViewById(R.id.orgName);
|
||||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||||
imageAvatar = itemView.findViewById(R.id.imageAvatar);
|
|
||||||
repoFullName = itemView.findViewById(R.id.repoFullName);
|
|
||||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
|
||||||
repoStars = itemView.findViewById(R.id.repoStars);
|
|
||||||
repoForks = itemView.findViewById(R.id.repoForks);
|
|
||||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
|
||||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
|
||||||
repoType = itemView.findViewById(R.id.repoType);
|
|
||||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
image = itemView.findViewById(R.id.imageAvatar);
|
||||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
repoStars = itemView.findViewById(R.id.repoStars);
|
||||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
intent.putExtra("repoFullName", userRepositories.getFullName());
|
||||||
|
|
||||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
tinyDb.putString("repoFullName", userRepositories.getFullName());
|
||||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
|
||||||
tinyDb.putString("repoType", repoType.getText().toString());
|
|
||||||
//tinyDb.putBoolean("resumeIssues", true);
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||||
tinyDb.putString("repoBranch", repoBranch.getText().toString());
|
tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
|
||||||
|
|
||||||
String[] parts = repoFullName.getText().toString().split("/");
|
if(userRepositories.getPrivateFlag()) {
|
||||||
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] parts = userRepositories.getFullName().split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||||
|
|
||||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
@ -113,13 +106,11 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
|
|
||||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", id);
|
tinyDb.putLong("repositoryId", id);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
@ -172,81 +163,13 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
reposDropdownMenu.setOnClickListener(v -> {
|
|
||||||
|
|
||||||
final Context context = v.getContext();
|
|
||||||
|
|
||||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
|
||||||
|
|
||||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
|
||||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
|
||||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
|
||||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
|
||||||
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
|
|
||||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
|
||||||
|
|
||||||
bottomSheetHeader.setText(String.format("%s / %s", repoFullName.getText().toString().split("/")[0], repoFullName.getText().toString().split("/")[1]));
|
|
||||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
|
||||||
dialog.setContentView(view);
|
|
||||||
dialog.show();
|
|
||||||
|
|
||||||
repoCopyUrl.setOnClickListener(openInBrowser -> {
|
|
||||||
|
|
||||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
|
|
||||||
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
|
|
||||||
assert clipboard != null;
|
|
||||||
clipboard.setPrimaryClip(clip);
|
|
||||||
|
|
||||||
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
|
|
||||||
dialog.dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
|
||||||
|
|
||||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
|
||||||
intentOpenInBrowser.putExtra("repoFullNameBrowser", repoFullName.getText());
|
|
||||||
context.startActivity(intentOpenInBrowser);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoStargazers.setOnClickListener(stargazers -> {
|
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
|
||||||
intent.putExtra("repoFullNameForStars", repoFullName.getText());
|
|
||||||
context.startActivity(intent);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoWatchers.setOnClickListener(watchers -> {
|
|
||||||
|
|
||||||
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
|
||||||
intentW.putExtra("repoFullNameForWatchers", repoFullName.getText());
|
|
||||||
context.startActivity(intentW);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoForksList.setOnClickListener(forks -> {
|
|
||||||
|
|
||||||
Intent intentW = new Intent(context, RepoForksActivity.class);
|
|
||||||
intentW.putExtra("repoFullNameForForks", repoFullName.getText());
|
|
||||||
context.startActivity(intentW);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyReposListAdapter(Context mCtx, List<UserRepositories> reposListMain) {
|
public MyReposListAdapter(Context ctx, List<UserRepositories> reposListMain) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.reposList = reposListMain;
|
this.reposList = reposListMain;
|
||||||
reposListFull = new ArrayList<>(reposList);
|
reposListFull = new ArrayList<>(reposList);
|
||||||
}
|
}
|
||||||
@ -262,10 +185,16 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull MyReposListAdapter.MyReposViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull MyReposListAdapter.MyReposViewHolder holder, int position) {
|
||||||
|
|
||||||
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
UserRepositories currentItem = reposList.get(position);
|
UserRepositories currentItem = reposList.get(position);
|
||||||
holder.repoDescription.setVisibility(View.GONE);
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
|
||||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
String locale = tinyDb.getString("locale");
|
||||||
|
String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
holder.userRepositories = currentItem;
|
||||||
|
holder.orgName.setText(currentItem.getFullName().split("/")[0]);
|
||||||
|
holder.repoName.setText(currentItem.getFullName().split("/")[1]);
|
||||||
|
holder.repoStars.setText(currentItem.getStars_count());
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
int color = generator.getColor(currentItem.getName());
|
int color = generator.getColor(currentItem.getName());
|
||||||
@ -275,46 +204,52 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
|
|
||||||
if(currentItem.getAvatar_url() != null) {
|
if(currentItem.getAvatar_url() != null) {
|
||||||
if(!currentItem.getAvatar_url().equals("")) {
|
if(!currentItem.getAvatar_url().equals("")) {
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.imageAvatar);
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.image);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.imageAvatar.setImageDrawable(drawable);
|
holder.image.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.imageAvatar.setImageDrawable(drawable);
|
holder.image.setImageDrawable(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(currentItem.getUpdated_at() != null) {
|
||||||
|
|
||||||
|
switch(timeFormat) {
|
||||||
|
case "pretty": {
|
||||||
|
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
|
||||||
|
String createdTime = prettyTime.format(currentItem.getUpdated_at());
|
||||||
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "normal": {
|
||||||
|
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
|
String createdTime = formatter.format(currentItem.getUpdated_at());
|
||||||
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "normal1": {
|
||||||
|
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
|
String createdTime = formatter.format(currentItem.getUpdated_at());
|
||||||
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
holder.repoLastUpdated.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.repoName.setText(currentItem.getName());
|
|
||||||
if(!currentItem.getDescription().equals("")) {
|
if(!currentItem.getDescription().equals("")) {
|
||||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
|
||||||
holder.repoDescription.setText(currentItem.getDescription());
|
holder.repoDescription.setText(currentItem.getDescription());
|
||||||
}
|
}
|
||||||
holder.repoFullName.setText(currentItem.getFullName());
|
|
||||||
if(currentItem.getPrivateFlag()) {
|
|
||||||
holder.repoPrivatePublic.setVisibility(View.VISIBLE);
|
|
||||||
holder.repoType.setText(R.string.strPrivate);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
holder.repoPrivatePublic.setVisibility(View.GONE);
|
|
||||||
holder.repoType.setText(R.string.strPublic);
|
|
||||||
}
|
|
||||||
holder.repoStars.setText(currentItem.getStars_count());
|
|
||||||
holder.repoForks.setText(currentItem.getForks_count());
|
|
||||||
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
|
||||||
|
|
||||||
if(holder.isRepoAdmin == null) {
|
if(holder.isRepoAdmin == null) {
|
||||||
holder.isRepoAdmin = new CheckBox(mCtx);
|
holder.isRepoAdmin = new CheckBox(context);
|
||||||
}
|
}
|
||||||
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||||
|
|
||||||
if(currentItem.isArchived()) {
|
|
||||||
holder.archiveRepo.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
holder.archiveRepo.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -329,7 +264,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
return myReposFilter;
|
return myReposFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Filter myReposFilter = new Filter() {
|
private final Filter myReposFilter = new Filter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FilterResults performFiltering(CharSequence constraint) {
|
protected FilterResults performFiltering(CharSequence constraint) {
|
||||||
|
@ -13,6 +13,7 @@ import androidx.core.text.HtmlCompat;
|
|||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import org.gitnex.tea4j.models.NotificationThread;
|
import org.gitnex.tea4j.models.NotificationThread;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
import org.mian.gitnex.database.models.Repository;
|
import org.mian.gitnex.database.models.Repository;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
@ -24,11 +25,11 @@ import java.util.List;
|
|||||||
|
|
||||||
public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdapter.NotificationsViewHolder> {
|
public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdapter.NotificationsViewHolder> {
|
||||||
|
|
||||||
private Context context;
|
private final Context context;
|
||||||
private List<NotificationThread> notificationThreads;
|
private final List<NotificationThread> notificationThreads;
|
||||||
private OnMoreClickedListener onMoreClickedListener;
|
private final OnMoreClickedListener onMoreClickedListener;
|
||||||
private OnNotificationClickedListener onNotificationClickedListener;
|
private final OnNotificationClickedListener onNotificationClickedListener;
|
||||||
private TinyDB tinyDb;
|
private final TinyDB tinyDb;
|
||||||
|
|
||||||
public NotificationsAdapter(Context context, List<NotificationThread> notificationThreads, OnMoreClickedListener onMoreClickedListener, OnNotificationClickedListener onNotificationClickedListener) {
|
public NotificationsAdapter(Context context, List<NotificationThread> notificationThreads, OnMoreClickedListener onMoreClickedListener, OnNotificationClickedListener onNotificationClickedListener) {
|
||||||
|
|
||||||
@ -37,19 +38,18 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
|
|||||||
this.notificationThreads = notificationThreads;
|
this.notificationThreads = notificationThreads;
|
||||||
this.onMoreClickedListener = onMoreClickedListener;
|
this.onMoreClickedListener = onMoreClickedListener;
|
||||||
this.onNotificationClickedListener = onNotificationClickedListener;
|
this.onNotificationClickedListener = onNotificationClickedListener;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class NotificationsViewHolder extends RecyclerView.ViewHolder {
|
static class NotificationsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private LinearLayout frame;
|
private final LinearLayout frame;
|
||||||
private TextView subject;
|
private final TextView subject;
|
||||||
private TextView repository;
|
private final TextView repository;
|
||||||
private ImageView typePr;
|
private final ImageView typePr;
|
||||||
private ImageView typeIssue;
|
private final ImageView typeIssue;
|
||||||
private ImageView typeUnknown;
|
private final ImageView typeUnknown;
|
||||||
private ImageView pinned;
|
private final ImageView pinned;
|
||||||
private ImageView more;
|
private final ImageView more;
|
||||||
|
|
||||||
public NotificationsViewHolder(@NonNull View itemView) {
|
public NotificationsViewHolder(@NonNull View itemView) {
|
||||||
|
|
||||||
@ -63,7 +63,6 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
|
|||||||
typeUnknown = itemView.findViewById(R.id.typeUnknown);
|
typeUnknown = itemView.findViewById(R.id.typeUnknown);
|
||||||
pinned = itemView.findViewById(R.id.pinned);
|
pinned = itemView.findViewById(R.id.pinned);
|
||||||
more = itemView.findViewById(R.id.more);
|
more = itemView.findViewById(R.id.more);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +72,6 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
|
|||||||
|
|
||||||
View v = LayoutInflater.from(context).inflate(R.layout.list_notifications, parent, false);
|
View v = LayoutInflater.from(context).inflate(R.layout.list_notifications, parent, false);
|
||||||
return new NotificationsAdapter.NotificationsViewHolder(v);
|
return new NotificationsAdapter.NotificationsViewHolder(v);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -90,8 +88,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
|
|||||||
|
|
||||||
if(notificationThread.isPinned()) {
|
if(notificationThread.isPinned()) {
|
||||||
holder.pinned.setVisibility(View.VISIBLE);
|
holder.pinned.setVisibility(View.VISIBLE);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
holder.pinned.setVisibility(View.GONE);
|
holder.pinned.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,26 +123,20 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
|
|||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||||
|
|
||||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
|
|
||||||
if(count == 0) {
|
if(count == 0) {
|
||||||
|
|
||||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", id);
|
tinyDb.putLong("repositoryId", id);
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
holder.more.setOnClickListener(v -> onMoreClickedListener.onMoreClicked(notificationThread));
|
holder.more.setOnClickListener(v -> onMoreClickedListener.onMoreClicked(notificationThread));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,6 +16,7 @@ import org.gitnex.tea4j.models.UserOrganizations;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.OrganizationDetailActivity;
|
import org.mian.gitnex.activities.OrganizationDetailActivity;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -27,42 +28,42 @@ import java.util.List;
|
|||||||
|
|
||||||
public class OrganizationsListAdapter extends RecyclerView.Adapter<OrganizationsListAdapter.OrganizationsViewHolder> implements Filterable {
|
public class OrganizationsListAdapter extends RecyclerView.Adapter<OrganizationsListAdapter.OrganizationsViewHolder> implements Filterable {
|
||||||
|
|
||||||
private List<UserOrganizations> orgList;
|
private final List<UserOrganizations> orgList;
|
||||||
private Context mCtx;
|
private final Context context;
|
||||||
private List<UserOrganizations> orgListFull;
|
private final List<UserOrganizations> orgListFull;
|
||||||
|
|
||||||
static class OrganizationsViewHolder extends RecyclerView.ViewHolder {
|
static class OrganizationsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private ImageView image;
|
private UserOrganizations userOrganizations;
|
||||||
private TextView mTextView1;
|
|
||||||
private TextView mTextView2;
|
private final ImageView image;
|
||||||
private TextView organizationId;
|
private final TextView orgName;
|
||||||
|
private final TextView orgDescription;
|
||||||
|
|
||||||
private OrganizationsViewHolder(View itemView) {
|
private OrganizationsViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
mTextView1 = itemView.findViewById(R.id.orgUsername);
|
orgName = itemView.findViewById(R.id.orgName);
|
||||||
mTextView2 = itemView.findViewById(R.id.orgDescription);
|
orgDescription = itemView.findViewById(R.id.orgDescription);
|
||||||
image = itemView.findViewById(R.id.imageAvatar);
|
image = itemView.findViewById(R.id.imageAvatar);
|
||||||
organizationId = itemView.findViewById(R.id.organizationId);
|
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
||||||
intent.putExtra("orgName", mTextView1.getText().toString());
|
intent.putExtra("orgName", userOrganizations.getUsername());
|
||||||
|
|
||||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
tinyDb.putString("orgName", mTextView1.getText().toString());
|
tinyDb.putString("orgName", userOrganizations.getUsername());
|
||||||
tinyDb.putString("organizationId", organizationId.getText().toString());
|
tinyDb.putString("organizationId", String.valueOf(userOrganizations.getId()));
|
||||||
tinyDb.putBoolean("organizationAction", true);
|
tinyDb.putBoolean("organizationAction", true);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrganizationsListAdapter(Context mCtx, List<UserOrganizations> orgsListMain) {
|
public OrganizationsListAdapter(Context ctx, List<UserOrganizations> orgsListMain) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.orgList = orgsListMain;
|
this.orgList = orgsListMain;
|
||||||
orgListFull = new ArrayList<>(orgList);
|
orgListFull = new ArrayList<>(orgList);
|
||||||
}
|
}
|
||||||
@ -80,16 +81,16 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<Organizations
|
|||||||
public void onBindViewHolder(@NonNull OrganizationsViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull OrganizationsViewHolder holder, int position) {
|
||||||
|
|
||||||
UserOrganizations currentItem = orgList.get(position);
|
UserOrganizations currentItem = orgList.get(position);
|
||||||
holder.mTextView2.setVisibility(View.GONE);
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
holder.organizationId.setText(Integer.toString(currentItem.getId()));
|
|
||||||
|
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image);
|
holder.userOrganizations = currentItem;
|
||||||
holder.mTextView1.setText(currentItem.getUsername());
|
holder.orgName.setText(currentItem.getUsername());
|
||||||
|
|
||||||
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.image);
|
||||||
|
|
||||||
if (!currentItem.getDescription().equals("")) {
|
if (!currentItem.getDescription().equals("")) {
|
||||||
|
|
||||||
holder.mTextView2.setVisibility(View.VISIBLE);
|
holder.orgDescription.setText(currentItem.getDescription());
|
||||||
holder.mTextView2.setText(currentItem.getDescription());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,13 +20,13 @@ import java.util.List;
|
|||||||
|
|
||||||
public class ProfileEmailsAdapter extends RecyclerView.Adapter<ProfileEmailsAdapter.EmailsViewHolder> {
|
public class ProfileEmailsAdapter extends RecyclerView.Adapter<ProfileEmailsAdapter.EmailsViewHolder> {
|
||||||
|
|
||||||
private List<Emails> emailsList;
|
private final List<Emails> emailsList;
|
||||||
private Context mCtx;
|
private final Context context;
|
||||||
|
|
||||||
static class EmailsViewHolder extends RecyclerView.ViewHolder {
|
static class EmailsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private ImageView emailPrimary;
|
private final ImageView emailPrimary;
|
||||||
private TextView userEmail;
|
private final TextView userEmail;
|
||||||
|
|
||||||
private EmailsViewHolder(View itemView) {
|
private EmailsViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@ -37,8 +37,8 @@ public class ProfileEmailsAdapter extends RecyclerView.Adapter<ProfileEmailsAdap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProfileEmailsAdapter(Context mCtx, List<Emails> emailsListMain) {
|
public ProfileEmailsAdapter(Context ctx, List<Emails> emailsListMain) {
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.emailsList = emailsListMain;
|
this.emailsList = emailsListMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,12 +59,12 @@ public class ProfileEmailsAdapter extends RecyclerView.Adapter<ProfileEmailsAdap
|
|||||||
if(currentItem.getPrimary()) {
|
if(currentItem.getPrimary()) {
|
||||||
TextDrawable drawable = TextDrawable.builder()
|
TextDrawable drawable = TextDrawable.builder()
|
||||||
.beginConfig()
|
.beginConfig()
|
||||||
.textColor(ResourcesCompat.getColor(mCtx.getResources(), R.color.colorWhite, null))
|
.textColor(ResourcesCompat.getColor(context.getResources(), R.color.colorWhite, null))
|
||||||
.fontSize(36)
|
.fontSize(36)
|
||||||
.width(220)
|
.width(220)
|
||||||
.height(60)
|
.height(60)
|
||||||
.endConfig()
|
.endConfig()
|
||||||
.buildRoundRect(mCtx.getResources().getString(R.string.emailTypeText), ResourcesCompat.getColor(mCtx.getResources(), R.color.tooltipBackground, null), 8);
|
.buildRoundRect(context.getResources().getString(R.string.emailTypeText), ResourcesCompat.getColor(context.getResources(), R.color.tooltipBackground, null), 8);
|
||||||
holder.emailPrimary.setImageDrawable(drawable);
|
holder.emailPrimary.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||||||
public class ProfileFollowersAdapter extends RecyclerView.Adapter<ProfileFollowersAdapter.FollowersViewHolder> {
|
public class ProfileFollowersAdapter extends RecyclerView.Adapter<ProfileFollowersAdapter.FollowersViewHolder> {
|
||||||
|
|
||||||
private final List<UserInfo> followersList;
|
private final List<UserInfo> followersList;
|
||||||
private final Context mCtx;
|
private final Context context;
|
||||||
|
|
||||||
static class FollowersViewHolder extends RecyclerView.ViewHolder {
|
static class FollowersViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
@ -50,9 +50,9 @@ public class ProfileFollowersAdapter extends RecyclerView.Adapter<ProfileFollowe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProfileFollowersAdapter(Context mCtx, List<UserInfo> followersListMain) {
|
public ProfileFollowersAdapter(Context ctx, List<UserInfo> followersListMain) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.followersList = followersListMain;
|
this.followersList = followersListMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,21 +68,20 @@ public class ProfileFollowersAdapter extends RecyclerView.Adapter<ProfileFollowe
|
|||||||
public void onBindViewHolder(@NonNull ProfileFollowersAdapter.FollowersViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull ProfileFollowersAdapter.FollowersViewHolder holder, int position) {
|
||||||
|
|
||||||
UserInfo currentItem = followersList.get(position);
|
UserInfo currentItem = followersList.get(position);
|
||||||
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
holder.userLoginId = currentItem.getLogin();
|
holder.userLoginId = currentItem.getLogin();
|
||||||
|
|
||||||
if(!currentItem.getFullname().equals("")) {
|
if(!currentItem.getFullname().equals("")) {
|
||||||
|
|
||||||
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
|
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
|
||||||
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
holder.userFullName.setText(currentItem.getUsername());
|
||||||
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
|
||||||
holder.userName.setVisibility(View.GONE);
|
holder.userName.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||||||
public class ProfileFollowingAdapter extends RecyclerView.Adapter<ProfileFollowingAdapter.FollowingViewHolder> {
|
public class ProfileFollowingAdapter extends RecyclerView.Adapter<ProfileFollowingAdapter.FollowingViewHolder> {
|
||||||
|
|
||||||
private final List<UserInfo> followingList;
|
private final List<UserInfo> followingList;
|
||||||
private final Context mCtx;
|
private final Context context;
|
||||||
|
|
||||||
static class FollowingViewHolder extends RecyclerView.ViewHolder {
|
static class FollowingViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
@ -50,9 +50,9 @@ public class ProfileFollowingAdapter extends RecyclerView.Adapter<ProfileFollowi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProfileFollowingAdapter(Context mCtx, List<UserInfo> followingListMain) {
|
public ProfileFollowingAdapter(Context ctx, List<UserInfo> followingListMain) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.followingList = followingListMain;
|
this.followingList = followingListMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,21 +68,20 @@ public class ProfileFollowingAdapter extends RecyclerView.Adapter<ProfileFollowi
|
|||||||
public void onBindViewHolder(@NonNull ProfileFollowingAdapter.FollowingViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull ProfileFollowingAdapter.FollowingViewHolder holder, int position) {
|
||||||
|
|
||||||
UserInfo currentItem = followingList.get(position);
|
UserInfo currentItem = followingList.get(position);
|
||||||
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
holder.userLoginId = currentItem.getLogin();
|
holder.userLoginId = currentItem.getLogin();
|
||||||
|
|
||||||
if(!currentItem.getFullname().equals("")) {
|
if(!currentItem.getFullname().equals("")) {
|
||||||
|
|
||||||
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
|
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
|
||||||
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
holder.userFullName.setText(currentItem.getUsername());
|
||||||
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
|
||||||
holder.userName.setVisibility(View.GONE);
|
holder.userName.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,7 +7,6 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
@ -42,7 +41,6 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.prList = prListMain;
|
this.prList = prListMain;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -57,7 +55,6 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
else {
|
else {
|
||||||
return new PullRequestsAdapter.LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
|
return new PullRequestsAdapter.LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -89,7 +86,6 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
|
|
||||||
return prList.size();
|
return prList.size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class PullRequestsHolder extends RecyclerView.ViewHolder {
|
class PullRequestsHolder extends RecyclerView.ViewHolder {
|
||||||
@ -104,43 +100,12 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
PullRequestsHolder(View itemView) {
|
PullRequestsHolder(View itemView) {
|
||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
assigneeAvatar = itemView.findViewById(R.id.assigneeAvatar);
|
assigneeAvatar = itemView.findViewById(R.id.assigneeAvatar);
|
||||||
prTitle = itemView.findViewById(R.id.prTitle);
|
prTitle = itemView.findViewById(R.id.prTitle);
|
||||||
prCommentsCount = itemView.findViewById(R.id.prCommentsCount);
|
prCommentsCount = itemView.findViewById(R.id.prCommentsCount);
|
||||||
LinearLayout frameCommentsCount = itemView.findViewById(R.id.frameCommentsCount);
|
|
||||||
prCreatedTime = itemView.findViewById(R.id.prCreatedTime);
|
prCreatedTime = itemView.findViewById(R.id.prCreatedTime);
|
||||||
|
|
||||||
prTitle.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
Context context = v.getContext();
|
|
||||||
|
|
||||||
Intent intent = new Intent(context, IssueDetailActivity.class);
|
|
||||||
intent.putExtra("issueNumber", pullRequest.getNumber());
|
|
||||||
intent.putExtra("prMergeable", pullRequest.isMergeable());
|
|
||||||
intent.putExtra("prHeadBranch", pullRequest.getHead().getRef());
|
|
||||||
|
|
||||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
|
||||||
tinyDb.putString("issueNumber", String.valueOf(pullRequest.getNumber()));
|
|
||||||
tinyDb.putString("prMergeable", String.valueOf(pullRequest.isMergeable()));
|
|
||||||
tinyDb.putString("prHeadBranch", pullRequest.getHead().getRef());
|
|
||||||
|
|
||||||
if(pullRequest.getHead() != null && pullRequest.getHead().getRepo() != null) {
|
|
||||||
tinyDb.putString("prIsFork", String.valueOf(pullRequest.getHead().getRepo().isFork()));
|
|
||||||
tinyDb.putString("prForkFullName", pullRequest.getHead().getRepo().getFull_name());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// pull was done from a deleted fork
|
|
||||||
tinyDb.putString("prIsFork", "true");
|
|
||||||
tinyDb.putString("prForkFullName", context.getString(R.string.prDeletedFork));
|
|
||||||
}
|
|
||||||
|
|
||||||
tinyDb.putString("issueType", "Pull");
|
|
||||||
context.startActivity(intent);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
frameCommentsCount.setOnClickListener(v -> {
|
|
||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
|
|
||||||
@ -184,11 +149,12 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
String locale = tinyDb.getString("locale");
|
String locale = tinyDb.getString("locale");
|
||||||
String timeFormat = tinyDb.getString("dateFormat");
|
String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
PicassoService.getInstance(context).get()
|
PicassoService.getInstance(context).get()
|
||||||
.load(pullRequest.getUser().getAvatar_url())
|
.load(pullRequest.getUser().getAvatar_url())
|
||||||
.placeholder(R.drawable.loader_animated)
|
.placeholder(R.drawable.loader_animated)
|
||||||
.transform(new RoundedTransformation(8, 0))
|
.transform(new RoundedTransformation(imgRadius, 0))
|
||||||
.resize(120, 120)
|
.resize(120, 120)
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.into(this.assigneeAvatar);
|
.into(this.assigneeAvatar);
|
||||||
@ -226,19 +192,16 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnLoadMoreListener {
|
public interface OnLoadMoreListener {
|
||||||
|
|
||||||
void onLoadMore();
|
void onLoadMore();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoadMoreListener(PullRequestsAdapter.OnLoadMoreListener loadMoreListener) {
|
public void setLoadMoreListener(PullRequestsAdapter.OnLoadMoreListener loadMoreListener) {
|
||||||
|
|
||||||
this.loadMoreListener = loadMoreListener;
|
this.loadMoreListener = loadMoreListener;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateList(List<PullRequests> list) {
|
public void updateList(List<PullRequests> list) {
|
||||||
|
@ -7,7 +7,6 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.text.HtmlCompat;
|
import androidx.core.text.HtmlCompat;
|
||||||
@ -16,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
import org.gitnex.tea4j.models.Releases;
|
import org.gitnex.tea4j.models.Releases;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.ClickListener;
|
import org.mian.gitnex.helpers.ClickListener;
|
||||||
import org.mian.gitnex.helpers.Markdown;
|
import org.mian.gitnex.helpers.Markdown;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
@ -30,25 +30,24 @@ import java.util.Locale;
|
|||||||
|
|
||||||
public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.ReleasesViewHolder> {
|
public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.ReleasesViewHolder> {
|
||||||
|
|
||||||
private List<Releases> releasesList;
|
private final List<Releases> releasesList;
|
||||||
private Context mCtx;
|
private final Context context;
|
||||||
|
|
||||||
static class ReleasesViewHolder extends RecyclerView.ViewHolder {
|
static class ReleasesViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private TextView releaseType;
|
private final TextView releaseType;
|
||||||
private TextView releaseName;
|
private final TextView releaseName;
|
||||||
private ImageView authorAvatar;
|
private final ImageView authorAvatar;
|
||||||
private TextView authorName;
|
private final TextView authorName;
|
||||||
private TextView releaseTag;
|
private final TextView releaseTag;
|
||||||
private TextView releaseCommitSha;
|
private final TextView releaseDate;
|
||||||
private TextView releaseDate;
|
private final TextView releaseBodyContent;
|
||||||
private TextView releaseBodyContent;
|
private final LinearLayout downloadFrame;
|
||||||
private LinearLayout downloadFrame;
|
private final LinearLayout downloads;
|
||||||
private RelativeLayout downloads;
|
private final TextView releaseZipDownload;
|
||||||
private TextView releaseZipDownload;
|
private final TextView releaseTarDownload;
|
||||||
private TextView releaseTarDownload;
|
private final ImageView downloadDropdownIcon;
|
||||||
private ImageView downloadDropdownIcon;
|
private final RecyclerView downloadList;
|
||||||
private RecyclerView downloadList;
|
|
||||||
|
|
||||||
private ReleasesViewHolder(View itemView) {
|
private ReleasesViewHolder(View itemView) {
|
||||||
|
|
||||||
@ -59,7 +58,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||||||
authorAvatar = itemView.findViewById(R.id.authorAvatar);
|
authorAvatar = itemView.findViewById(R.id.authorAvatar);
|
||||||
authorName = itemView.findViewById(R.id.authorName);
|
authorName = itemView.findViewById(R.id.authorName);
|
||||||
releaseTag = itemView.findViewById(R.id.releaseTag);
|
releaseTag = itemView.findViewById(R.id.releaseTag);
|
||||||
releaseCommitSha = itemView.findViewById(R.id.releaseCommitSha);
|
TextView releaseCommitSha = itemView.findViewById(R.id.releaseCommitSha);
|
||||||
releaseDate = itemView.findViewById(R.id.releaseDate);
|
releaseDate = itemView.findViewById(R.id.releaseDate);
|
||||||
releaseBodyContent = itemView.findViewById(R.id.releaseBodyContent);
|
releaseBodyContent = itemView.findViewById(R.id.releaseBodyContent);
|
||||||
downloadFrame = itemView.findViewById(R.id.downloadFrame);
|
downloadFrame = itemView.findViewById(R.id.downloadFrame);
|
||||||
@ -71,12 +70,11 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||||||
|
|
||||||
downloadList.setHasFixedSize(true);
|
downloadList.setHasFixedSize(true);
|
||||||
downloadList.setLayoutManager(new LinearLayoutManager(itemView.getContext()));
|
downloadList.setLayoutManager(new LinearLayoutManager(itemView.getContext()));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReleasesAdapter(Context mCtx, List<Releases> releasesMain) {
|
public ReleasesAdapter(Context ctx, List<Releases> releasesMain) {
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.releasesList = releasesMain;
|
this.releasesList = releasesMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,9 +88,10 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ReleasesAdapter.ReleasesViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull ReleasesAdapter.ReleasesViewHolder holder, int position) {
|
||||||
|
|
||||||
final TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
final String locale = tinyDb.getString("locale");
|
final String locale = tinyDb.getString("locale");
|
||||||
final String timeFormat = tinyDb.getString("dateFormat");
|
final String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
Releases currentItem = releasesList.get(position);
|
Releases currentItem = releasesList.get(position);
|
||||||
|
|
||||||
@ -111,25 +110,25 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(currentItem.getAuthor().getAvatar_url() != null) {
|
if(currentItem.getAuthor().getAvatar_url() != null) {
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAuthor().getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.authorAvatar);
|
PicassoService.getInstance(context).get().load(currentItem.getAuthor().getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.authorAvatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.authorName.setText(mCtx.getResources().getString(R.string.releasePublishedBy, currentItem.getAuthor().getUsername()));
|
holder.authorName.setText(context.getResources().getString(R.string.releasePublishedBy, currentItem.getAuthor().getUsername()));
|
||||||
|
|
||||||
if(currentItem.getTag_name() != null) {
|
if(currentItem.getTag_name() != null) {
|
||||||
holder.releaseTag.setText(currentItem.getTag_name());
|
holder.releaseTag.setText(currentItem.getTag_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentItem.getPublished_at() != null) {
|
if(currentItem.getPublished_at() != null) {
|
||||||
holder.releaseDate.setText(TimeHelper.formatTime(currentItem.getPublished_at(), new Locale(locale), timeFormat, mCtx));
|
holder.releaseDate.setText(TimeHelper.formatTime(currentItem.getPublished_at(), new Locale(locale), timeFormat, context));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(timeFormat.equals("pretty")) {
|
if(timeFormat.equals("pretty")) {
|
||||||
holder.releaseDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getPublished_at()), mCtx));
|
holder.releaseDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getPublished_at()), context));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!currentItem.getBody().equals("")) {
|
if(!currentItem.getBody().equals("")) {
|
||||||
Markdown.render(mCtx, currentItem.getBody(), holder.releaseBodyContent);
|
Markdown.render(context, currentItem.getBody(), holder.releaseBodyContent);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.releaseBodyContent.setText(R.string.noReleaseBodyContent);
|
holder.releaseBodyContent.setText(R.string.noReleaseBodyContent);
|
||||||
@ -141,28 +140,25 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||||||
|
|
||||||
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_down);
|
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_down);
|
||||||
holder.downloads.setVisibility(View.VISIBLE);
|
holder.downloads.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_right);
|
holder.downloadDropdownIcon.setImageResource(R.drawable.ic_chevron_right);
|
||||||
holder.downloads.setVisibility(View.GONE);
|
holder.downloads.setVisibility(View.GONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
holder.releaseZipDownload.setText(
|
holder.releaseZipDownload.setText(
|
||||||
HtmlCompat.fromHtml("<a href='" + currentItem.getZipball_url() + "'>" + mCtx.getResources().getString(R.string.zipArchiveDownloadReleasesTab) + "</a> ", HtmlCompat.FROM_HTML_MODE_LEGACY));
|
HtmlCompat.fromHtml("<a href='" + currentItem.getZipball_url() + "'>" + context.getResources().getString(R.string.zipArchiveDownloadReleasesTab) + "</a> ", HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||||
holder.releaseZipDownload.setMovementMethod(LinkMovementMethod.getInstance());
|
holder.releaseZipDownload.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
holder.releaseTarDownload.setText(
|
holder.releaseTarDownload.setText(
|
||||||
HtmlCompat.fromHtml("<a href='" + currentItem.getTarball_url() + "'>" + mCtx.getResources().getString(R.string.tarArchiveDownloadReleasesTab) + "</a> ", HtmlCompat.FROM_HTML_MODE_LEGACY));
|
HtmlCompat.fromHtml("<a href='" + currentItem.getTarball_url() + "'>" + context.getResources().getString(R.string.tarArchiveDownloadReleasesTab) + "</a> ", HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||||
holder.releaseTarDownload.setMovementMethod(LinkMovementMethod.getInstance());
|
holder.releaseTarDownload.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
ReleasesDownloadsAdapter adapter = new ReleasesDownloadsAdapter(currentItem.getAssets());
|
ReleasesDownloadsAdapter adapter = new ReleasesDownloadsAdapter(currentItem.getAssets());
|
||||||
holder.downloadList.setAdapter(adapter);
|
holder.downloadList.setAdapter(adapter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,18 +18,16 @@ import java.util.List;
|
|||||||
|
|
||||||
public class ReleasesDownloadsAdapter extends RecyclerView.Adapter<ReleasesDownloadsAdapter.ReleasesDownloadsViewHolder> {
|
public class ReleasesDownloadsAdapter extends RecyclerView.Adapter<ReleasesDownloadsAdapter.ReleasesDownloadsViewHolder> {
|
||||||
|
|
||||||
private List<Releases.assetsObject> releasesDownloadsList;
|
private final List<Releases.assetsObject> releasesDownloadsList;
|
||||||
|
|
||||||
static class ReleasesDownloadsViewHolder extends RecyclerView.ViewHolder {
|
static class ReleasesDownloadsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private TextView downloadName;
|
private final TextView downloadName;
|
||||||
|
|
||||||
private ReleasesDownloadsViewHolder(View itemView) {
|
private ReleasesDownloadsViewHolder(View itemView) {
|
||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
downloadName = itemView.findViewById(R.id.downloadName);
|
downloadName = itemView.findViewById(R.id.downloadName);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +55,6 @@ public class ReleasesDownloadsAdapter extends RecyclerView.Adapter<ReleasesDownl
|
|||||||
holder.downloadName.setMovementMethod(LinkMovementMethod.getInstance());
|
holder.downloadName.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -9,29 +9,31 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
import com.amulyakhare.textdrawable.TextDrawable;
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
|
||||||
import org.gitnex.tea4j.models.UserRepositories;
|
import org.gitnex.tea4j.models.UserRepositories;
|
||||||
import org.gitnex.tea4j.models.WatchInfo;
|
import org.gitnex.tea4j.models.WatchInfo;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
import org.mian.gitnex.database.models.Repository;
|
import org.mian.gitnex.database.models.Repository;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
|
import org.mian.gitnex.helpers.ClickListener;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
import org.ocpsoft.prettytime.PrettyTime;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -41,7 +43,7 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
private Context ctx;
|
private final Context context;
|
||||||
private final int TYPE_LOAD = 0;
|
private final int TYPE_LOAD = 0;
|
||||||
private List<UserRepositories> forksList;
|
private List<UserRepositories> forksList;
|
||||||
private OnLoadMoreListener loadMoreListener;
|
private OnLoadMoreListener loadMoreListener;
|
||||||
@ -50,16 +52,15 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
|
|
||||||
public RepoForksAdapter(Context ctx, List<UserRepositories> forksListMain) {
|
public RepoForksAdapter(Context ctx, List<UserRepositories> forksListMain) {
|
||||||
|
|
||||||
this.ctx = ctx;
|
this.context = ctx;
|
||||||
this.forksList = forksListMain;
|
this.forksList = forksListMain;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(ctx);
|
LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
|
|
||||||
if(viewType == TYPE_LOAD) {
|
if(viewType == TYPE_LOAD) {
|
||||||
return new RepoForksAdapter.ForksHolder(inflater.inflate(R.layout.list_repositories, parent, false));
|
return new RepoForksAdapter.ForksHolder(inflater.inflate(R.layout.list_repositories, parent, false));
|
||||||
@ -67,7 +68,6 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
else {
|
else {
|
||||||
return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
|
return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -77,15 +77,12 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
|
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
loadMoreListener.onLoadMore();
|
loadMoreListener.onLoadMore();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getItemViewType(position) == TYPE_LOAD) {
|
if(getItemViewType(position) == TYPE_LOAD) {
|
||||||
|
|
||||||
((RepoForksAdapter.ForksHolder) holder).bindData(forksList.get(position));
|
((RepoForksAdapter.ForksHolder) holder).bindData(forksList.get(position));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -97,57 +94,51 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
else {
|
else {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
|
|
||||||
return forksList.size();
|
return forksList.size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ForksHolder extends RecyclerView.ViewHolder {
|
class ForksHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private ImageView image;
|
private UserRepositories userRepositories;
|
||||||
private TextView repoName;
|
|
||||||
private TextView repoDescription;
|
private final ImageView image;
|
||||||
private TextView fullName;
|
private final TextView repoName;
|
||||||
|
private final TextView orgName;
|
||||||
|
private final TextView repoDescription;
|
||||||
private CheckBox isRepoAdmin;
|
private CheckBox isRepoAdmin;
|
||||||
private ImageView repoPrivatePublic;
|
private final TextView repoStars;
|
||||||
private TextView repoStars;
|
private final TextView repoLastUpdated;
|
||||||
private TextView repoForks;
|
|
||||||
private TextView repoOpenIssuesCount;
|
|
||||||
private TextView repoType;
|
|
||||||
private LinearLayout archiveRepo;
|
|
||||||
private TextView repoBranch;
|
|
||||||
private ImageView reposDropdownMenu;
|
|
||||||
|
|
||||||
ForksHolder(View itemView) {
|
ForksHolder(View itemView) {
|
||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
repoName = itemView.findViewById(R.id.repoName);
|
repoName = itemView.findViewById(R.id.repoName);
|
||||||
|
orgName = itemView.findViewById(R.id.orgName);
|
||||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||||
image = itemView.findViewById(R.id.imageAvatar);
|
image = itemView.findViewById(R.id.imageAvatar);
|
||||||
fullName = itemView.findViewById(R.id.repoFullName);
|
|
||||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
|
||||||
repoStars = itemView.findViewById(R.id.repoStars);
|
repoStars = itemView.findViewById(R.id.repoStars);
|
||||||
repoForks = itemView.findViewById(R.id.repoForks);
|
repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
|
||||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
|
||||||
reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
|
||||||
repoType = itemView.findViewById(R.id.repoType);
|
|
||||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
|
||||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
void bindData(UserRepositories forksModel) {
|
void bindData(UserRepositories forksModel) {
|
||||||
|
|
||||||
repoDescription.setVisibility(View.GONE);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
repoBranch.setText(forksModel.getDefault_branch());
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
|
String locale = tinyDb.getString("locale");
|
||||||
|
String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
this.userRepositories = forksModel;
|
||||||
|
orgName.setText(forksModel.getFullName().split("/")[0]);
|
||||||
|
repoName.setText(forksModel.getFullName().split("/")[1]);
|
||||||
|
repoStars.setText(forksModel.getStars_count());
|
||||||
|
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
int color = generator.getColor(forksModel.getName());
|
int color = generator.getColor(forksModel.getName());
|
||||||
@ -158,8 +149,8 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
|
|
||||||
if(forksModel.getAvatar_url() != null) {
|
if(forksModel.getAvatar_url() != null) {
|
||||||
if(!forksModel.getAvatar_url().equals("")) {
|
if(!forksModel.getAvatar_url().equals("")) {
|
||||||
PicassoService.getInstance(ctx).get().load(forksModel.getAvatar_url()).placeholder(R.drawable.loader_animated)
|
PicassoService.getInstance(context).get().load(forksModel.getAvatar_url()).placeholder(R.drawable.loader_animated)
|
||||||
.transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(image);
|
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
image.setImageDrawable(drawable);
|
image.setImageDrawable(drawable);
|
||||||
@ -169,61 +160,68 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
image.setImageDrawable(drawable);
|
image.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
repoName.setText(forksModel.getName());
|
if(forksModel.getUpdated_at() != null) {
|
||||||
|
|
||||||
|
switch(timeFormat) {
|
||||||
|
case "pretty": {
|
||||||
|
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
|
||||||
|
String createdTime = prettyTime.format(forksModel.getUpdated_at());
|
||||||
|
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(forksModel.getUpdated_at()), context));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "normal": {
|
||||||
|
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
|
String createdTime = formatter.format(forksModel.getUpdated_at());
|
||||||
|
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "normal1": {
|
||||||
|
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
|
String createdTime = formatter.format(forksModel.getUpdated_at());
|
||||||
|
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
repoLastUpdated.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
if(!forksModel.getDescription().equals("")) {
|
if(!forksModel.getDescription().equals("")) {
|
||||||
repoDescription.setVisibility(View.VISIBLE);
|
|
||||||
repoDescription.setText(forksModel.getDescription());
|
repoDescription.setText(forksModel.getDescription());
|
||||||
}
|
}
|
||||||
fullName.setText(forksModel.getFullName());
|
|
||||||
|
|
||||||
if(forksModel.getPrivateFlag()) {
|
|
||||||
repoPrivatePublic.setImageResource(R.drawable.ic_lock);
|
|
||||||
repoType.setText(R.string.strPrivate);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
repoPrivatePublic.setVisibility(View.GONE);
|
|
||||||
repoType.setText(R.string.strPublic);
|
|
||||||
}
|
|
||||||
|
|
||||||
repoStars.setText(forksModel.getStars_count());
|
|
||||||
repoForks.setText(forksModel.getForks_count());
|
|
||||||
repoOpenIssuesCount.setText(forksModel.getOpen_issues_count());
|
|
||||||
|
|
||||||
if(isRepoAdmin == null) {
|
if(isRepoAdmin == null) {
|
||||||
isRepoAdmin = new CheckBox(ctx);
|
isRepoAdmin = new CheckBox(context);
|
||||||
}
|
}
|
||||||
isRepoAdmin.setChecked(forksModel.getPermissions().isAdmin());
|
isRepoAdmin.setChecked(forksModel.getPermissions().isAdmin());
|
||||||
|
|
||||||
if(forksModel.isArchived()) {
|
|
||||||
archiveRepo.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
archiveRepo.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
TextView repoFullName = v.findViewById(R.id.repoFullName);
|
|
||||||
TextView repoType_ = v.findViewById(R.id.repoType);
|
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
intent.putExtra("repoFullName", userRepositories.getFullName());
|
||||||
|
|
||||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
tinyDb.putString("repoFullName", userRepositories.getFullName());
|
||||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
|
||||||
tinyDb.putString("repoType", repoType_.getText().toString());
|
|
||||||
//tinyDb.putBoolean("resumeIssues", true);
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||||
tinyDb.putString("repoBranch", repoBranch.getText().toString());
|
tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
|
||||||
|
|
||||||
String[] parts = repoFullName.getText().toString().split("/");
|
if(userRepositories.getPrivateFlag()) {
|
||||||
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] parts = userRepositories.getFullName().split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||||
|
|
||||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
@ -232,13 +230,11 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
|
|
||||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", id);
|
tinyDb.putLong("repositoryId", id);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
@ -291,63 +287,6 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
reposDropdownMenu.setOnClickListener(v -> {
|
|
||||||
|
|
||||||
final Context context = v.getContext();
|
|
||||||
|
|
||||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
|
||||||
|
|
||||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
|
||||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
|
||||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
|
||||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
|
||||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
|
||||||
|
|
||||||
bottomSheetHeader
|
|
||||||
.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
|
||||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
|
||||||
dialog.setContentView(view);
|
|
||||||
dialog.show();
|
|
||||||
|
|
||||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
|
||||||
|
|
||||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
|
||||||
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
|
|
||||||
context.startActivity(intentOpenInBrowser);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoStargazers.setOnClickListener(stargazers -> {
|
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
|
||||||
intent.putExtra("repoFullNameForStars", fullName.getText());
|
|
||||||
context.startActivity(intent);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoWatchers.setOnClickListener(watchers -> {
|
|
||||||
|
|
||||||
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
|
||||||
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
|
|
||||||
context.startActivity(intentW);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoForksList.setOnClickListener(watchers -> {
|
|
||||||
|
|
||||||
Intent intentW = new Intent(context, RepoForksActivity.class);
|
|
||||||
intentW.putExtra("repoFullNameForForks", fullName.getText());
|
|
||||||
context.startActivity(intentW);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -358,32 +297,27 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||||
|
|
||||||
isMoreDataAvailable = moreDataAvailable;
|
isMoreDataAvailable = moreDataAvailable;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyDataChanged() {
|
public void notifyDataChanged() {
|
||||||
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnLoadMoreListener {
|
public interface OnLoadMoreListener {
|
||||||
|
|
||||||
void onLoadMore();
|
void onLoadMore();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoadMoreListener(RepoForksAdapter.OnLoadMoreListener loadMoreListener) {
|
public void setLoadMoreListener(RepoForksAdapter.OnLoadMoreListener loadMoreListener) {
|
||||||
|
|
||||||
this.loadMoreListener = loadMoreListener;
|
this.loadMoreListener = loadMoreListener;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateList(List<UserRepositories> list) {
|
public void updateList(List<UserRepositories> list) {
|
||||||
|
@ -12,6 +12,7 @@ import android.widget.TextView;
|
|||||||
import org.gitnex.tea4j.models.UserInfo;
|
import org.gitnex.tea4j.models.UserInfo;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -22,13 +23,13 @@ import java.util.List;
|
|||||||
|
|
||||||
public class RepoStargazersAdapter extends BaseAdapter {
|
public class RepoStargazersAdapter extends BaseAdapter {
|
||||||
|
|
||||||
private List<UserInfo> stargazersList;
|
private final List<UserInfo> stargazersList;
|
||||||
private Context mCtx;
|
private final Context context;
|
||||||
|
|
||||||
private static class ViewHolder {
|
private static class ViewHolder {
|
||||||
|
|
||||||
private ImageView memberAvatar;
|
private final ImageView memberAvatar;
|
||||||
private TextView memberName;
|
private final TextView memberName;
|
||||||
|
|
||||||
ViewHolder(View v) {
|
ViewHolder(View v) {
|
||||||
memberAvatar = v.findViewById(R.id.memberAvatar);
|
memberAvatar = v.findViewById(R.id.memberAvatar);
|
||||||
@ -36,8 +37,8 @@ public class RepoStargazersAdapter extends BaseAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RepoStargazersAdapter(Context mCtx, List<UserInfo> membersListMain) {
|
public RepoStargazersAdapter(Context ctx, List<UserInfo> membersListMain) {
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.stargazersList = membersListMain;
|
this.stargazersList = membersListMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ public class RepoStargazersAdapter extends BaseAdapter {
|
|||||||
RepoStargazersAdapter.ViewHolder viewHolder;
|
RepoStargazersAdapter.ViewHolder viewHolder;
|
||||||
|
|
||||||
if (finalView == null) {
|
if (finalView == null) {
|
||||||
finalView = LayoutInflater.from(mCtx).inflate(R.layout.list_repo_stargazers, null);
|
finalView = LayoutInflater.from(context).inflate(R.layout.list_repo_stargazers, null);
|
||||||
viewHolder = new ViewHolder(finalView);
|
viewHolder = new ViewHolder(finalView);
|
||||||
finalView.setTag(viewHolder);
|
finalView.setTag(viewHolder);
|
||||||
}
|
}
|
||||||
@ -79,23 +80,25 @@ public class RepoStargazersAdapter extends BaseAdapter {
|
|||||||
private void initData(RepoStargazersAdapter.ViewHolder viewHolder, int position) {
|
private void initData(RepoStargazersAdapter.ViewHolder viewHolder, int position) {
|
||||||
|
|
||||||
UserInfo currentItem = stargazersList.get(position);
|
UserInfo currentItem = stargazersList.get(position);
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
final TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
|
||||||
|
|
||||||
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
Typeface myTypeface;
|
Typeface myTypeface;
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
switch(tinyDb.getInt("customFontId", -1)) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf");
|
myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/roboto.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/sourcecodeproregular.ttf");
|
myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/manroperegular.ttf");
|
myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/manroperegular.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import android.widget.TextView;
|
|||||||
import org.gitnex.tea4j.models.UserInfo;
|
import org.gitnex.tea4j.models.UserInfo;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -22,13 +23,13 @@ import java.util.List;
|
|||||||
|
|
||||||
public class RepoWatchersAdapter extends BaseAdapter {
|
public class RepoWatchersAdapter extends BaseAdapter {
|
||||||
|
|
||||||
private List<UserInfo> watchersList;
|
private final List<UserInfo> watchersList;
|
||||||
private Context mCtx;
|
private final Context context;
|
||||||
|
|
||||||
private static class ViewHolder {
|
private static class ViewHolder {
|
||||||
|
|
||||||
private ImageView memberAvatar;
|
private final ImageView memberAvatar;
|
||||||
private TextView memberName;
|
private final TextView memberName;
|
||||||
|
|
||||||
ViewHolder(View v) {
|
ViewHolder(View v) {
|
||||||
memberAvatar = v.findViewById(R.id.memberAvatar);
|
memberAvatar = v.findViewById(R.id.memberAvatar);
|
||||||
@ -36,8 +37,8 @@ public class RepoWatchersAdapter extends BaseAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RepoWatchersAdapter(Context mCtx, List<UserInfo> membersListMain) {
|
public RepoWatchersAdapter(Context ctx, List<UserInfo> membersListMain) {
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.watchersList = membersListMain;
|
this.watchersList = membersListMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ public class RepoWatchersAdapter extends BaseAdapter {
|
|||||||
RepoWatchersAdapter.ViewHolder viewHolder;
|
RepoWatchersAdapter.ViewHolder viewHolder;
|
||||||
|
|
||||||
if (finalView == null) {
|
if (finalView == null) {
|
||||||
finalView = LayoutInflater.from(mCtx).inflate(R.layout.list_repo_watchers, null);
|
finalView = LayoutInflater.from(context).inflate(R.layout.list_repo_watchers, null);
|
||||||
viewHolder = new ViewHolder(finalView);
|
viewHolder = new ViewHolder(finalView);
|
||||||
finalView.setTag(viewHolder);
|
finalView.setTag(viewHolder);
|
||||||
}
|
}
|
||||||
@ -79,23 +80,25 @@ public class RepoWatchersAdapter extends BaseAdapter {
|
|||||||
private void initData(RepoWatchersAdapter.ViewHolder viewHolder, int position) {
|
private void initData(RepoWatchersAdapter.ViewHolder viewHolder, int position) {
|
||||||
|
|
||||||
UserInfo currentItem = watchersList.get(position);
|
UserInfo currentItem = watchersList.get(position);
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
final TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
|
||||||
|
|
||||||
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
Typeface myTypeface;
|
Typeface myTypeface;
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
switch(tinyDb.getInt("customFontId", -1)) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf");
|
myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/roboto.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/sourcecodeproregular.ttf");
|
myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/manroperegular.ttf");
|
myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/manroperegular.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package org.mian.gitnex.adapters;
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
@ -13,31 +10,32 @@ import android.widget.CheckBox;
|
|||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
import com.amulyakhare.textdrawable.TextDrawable;
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
|
||||||
import org.gitnex.tea4j.models.UserRepositories;
|
import org.gitnex.tea4j.models.UserRepositories;
|
||||||
import org.gitnex.tea4j.models.WatchInfo;
|
import org.gitnex.tea4j.models.WatchInfo;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
import org.mian.gitnex.database.models.Repository;
|
import org.mian.gitnex.database.models.Repository;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
|
import org.mian.gitnex.helpers.ClickListener;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
import org.ocpsoft.prettytime.PrettyTime;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Locale;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -47,66 +45,59 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.ReposViewHolder> implements Filterable {
|
public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.ReposViewHolder> implements Filterable {
|
||||||
|
|
||||||
private List<UserRepositories> reposList;
|
private final List<UserRepositories> reposList;
|
||||||
private Context mCtx;
|
private final Context context;
|
||||||
private List<UserRepositories> reposListFull;
|
private final List<UserRepositories> reposListFull;
|
||||||
|
|
||||||
static class ReposViewHolder extends RecyclerView.ViewHolder {
|
static class ReposViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private ImageView image;
|
private UserRepositories userRepositories;
|
||||||
private TextView repoName;
|
|
||||||
private TextView repoDescription;
|
private final ImageView image;
|
||||||
private TextView fullName;
|
private final TextView repoName;
|
||||||
|
private final TextView orgName;
|
||||||
|
private final TextView repoDescription;
|
||||||
private CheckBox isRepoAdmin;
|
private CheckBox isRepoAdmin;
|
||||||
private ImageView repoPrivatePublic;
|
private final TextView repoStars;
|
||||||
private TextView repoStars;
|
private final TextView repoLastUpdated;
|
||||||
private TextView repoForks;
|
|
||||||
private TextView repoOpenIssuesCount;
|
|
||||||
private TextView repoType;
|
|
||||||
private LinearLayout archiveRepo;
|
|
||||||
private TextView repoBranch;
|
|
||||||
private TextView htmlUrl;
|
|
||||||
|
|
||||||
private ReposViewHolder(View itemView) {
|
private ReposViewHolder(View itemView) {
|
||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
repoName = itemView.findViewById(R.id.repoName);
|
repoName = itemView.findViewById(R.id.repoName);
|
||||||
|
orgName = itemView.findViewById(R.id.orgName);
|
||||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||||
image = itemView.findViewById(R.id.imageAvatar);
|
image = itemView.findViewById(R.id.imageAvatar);
|
||||||
fullName = itemView.findViewById(R.id.repoFullName);
|
|
||||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
|
||||||
repoStars = itemView.findViewById(R.id.repoStars);
|
repoStars = itemView.findViewById(R.id.repoStars);
|
||||||
repoForks = itemView.findViewById(R.id.repoForks);
|
repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
|
||||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
|
||||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
|
||||||
repoType = itemView.findViewById(R.id.repoType);
|
|
||||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
|
||||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
|
||||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
TextView repoFullName = v.findViewById(R.id.repoFullName);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
TextView repoType_ = v.findViewById(R.id.repoType);
|
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
intent.putExtra("repoFullName", userRepositories.getFullName());
|
||||||
|
|
||||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
tinyDb.putString("repoFullName", userRepositories.getFullName());
|
||||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
|
||||||
tinyDb.putString("repoType", repoType_.getText().toString());
|
|
||||||
//tinyDb.putBoolean("resumeIssues", true);
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||||
tinyDb.putString("repoBranch", repoBranch.getText().toString());
|
tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
|
||||||
|
|
||||||
String[] parts = repoFullName.getText().toString().split("/");
|
if(userRepositories.getPrivateFlag()) {
|
||||||
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] parts = userRepositories.getFullName().split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||||
|
|
||||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
@ -115,13 +106,11 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
|
|
||||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", id);
|
tinyDb.putLong("repositoryId", id);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
@ -173,81 +162,13 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
reposDropdownMenu.setOnClickListener(v -> {
|
|
||||||
|
|
||||||
final Context context = v.getContext();
|
|
||||||
|
|
||||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
|
||||||
|
|
||||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
|
||||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
|
||||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
|
||||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
|
||||||
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
|
|
||||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
|
||||||
|
|
||||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
|
||||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
|
||||||
dialog.setContentView(view);
|
|
||||||
dialog.show();
|
|
||||||
|
|
||||||
repoCopyUrl.setOnClickListener(openInBrowser -> {
|
|
||||||
|
|
||||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
|
|
||||||
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
|
|
||||||
assert clipboard != null;
|
|
||||||
clipboard.setPrimaryClip(clip);
|
|
||||||
|
|
||||||
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
|
|
||||||
dialog.dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
|
||||||
|
|
||||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
|
||||||
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
|
|
||||||
context.startActivity(intentOpenInBrowser);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoStargazers.setOnClickListener(stargazers -> {
|
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
|
||||||
intent.putExtra("repoFullNameForStars", fullName.getText());
|
|
||||||
context.startActivity(intent);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoWatchers.setOnClickListener(watchers -> {
|
|
||||||
|
|
||||||
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
|
||||||
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
|
|
||||||
context.startActivity(intentW);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoForksList.setOnClickListener(forks -> {
|
|
||||||
|
|
||||||
Intent intentW = new Intent(context, RepoForksActivity.class);
|
|
||||||
intentW.putExtra("repoFullNameForForks", fullName.getText());
|
|
||||||
context.startActivity(intentW);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReposListAdapter(Context mCtx, List<UserRepositories> reposListMain) {
|
public ReposListAdapter(Context ctx, List<UserRepositories> reposListMain) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.reposList = reposListMain;
|
this.reposList = reposListMain;
|
||||||
reposListFull = new ArrayList<>(reposList);
|
reposListFull = new ArrayList<>(reposList);
|
||||||
}
|
}
|
||||||
@ -263,20 +184,26 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ReposViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull ReposViewHolder holder, int position) {
|
||||||
|
|
||||||
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
UserRepositories currentItem = reposList.get(position);
|
UserRepositories currentItem = reposList.get(position);
|
||||||
holder.repoDescription.setVisibility(View.GONE);
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
|
||||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
String locale = tinyDb.getString("locale");
|
||||||
|
String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
holder.userRepositories = currentItem;
|
||||||
|
holder.orgName.setText(currentItem.getFullName().split("/")[0]);
|
||||||
|
holder.repoName.setText(currentItem.getFullName().split("/")[1]);
|
||||||
|
holder.repoStars.setText(currentItem.getStars_count());
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
int color = generator.getColor(currentItem.getName());
|
int color = generator.getColor(currentItem.getName());
|
||||||
String firstCharacter = String.valueOf(currentItem.getName().charAt(0));
|
String firstCharacter = String.valueOf(currentItem.getFullName().split("/")[0].charAt(0));
|
||||||
|
|
||||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||||
|
|
||||||
if(currentItem.getAvatar_url() != null) {
|
if(currentItem.getAvatar_url() != null) {
|
||||||
if(!currentItem.getAvatar_url().equals("")) {
|
if(!currentItem.getAvatar_url().equals("")) {
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image);
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.image);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.image.setImageDrawable(drawable);
|
holder.image.setImageDrawable(drawable);
|
||||||
@ -286,35 +213,42 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
holder.image.setImageDrawable(drawable);
|
holder.image.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.repoName.setText(currentItem.getName());
|
if(currentItem.getUpdated_at() != null) {
|
||||||
|
|
||||||
|
switch(timeFormat) {
|
||||||
|
case "pretty": {
|
||||||
|
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
|
||||||
|
String createdTime = prettyTime.format(currentItem.getUpdated_at());
|
||||||
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "normal": {
|
||||||
|
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
|
String createdTime = formatter.format(currentItem.getUpdated_at());
|
||||||
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "normal1": {
|
||||||
|
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
|
String createdTime = formatter.format(currentItem.getUpdated_at());
|
||||||
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
holder.repoLastUpdated.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
if(!currentItem.getDescription().equals("")) {
|
if(!currentItem.getDescription().equals("")) {
|
||||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
|
||||||
holder.repoDescription.setText(currentItem.getDescription());
|
holder.repoDescription.setText(currentItem.getDescription());
|
||||||
}
|
}
|
||||||
holder.fullName.setText(currentItem.getFullName());
|
|
||||||
if(currentItem.getPrivateFlag()) {
|
|
||||||
holder.repoPrivatePublic.setVisibility(View.VISIBLE);
|
|
||||||
holder.repoType.setText(R.string.strPrivate);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
holder.repoPrivatePublic.setVisibility(View.GONE);
|
|
||||||
holder.repoType.setText(R.string.strPublic);
|
|
||||||
}
|
|
||||||
holder.repoStars.setText(currentItem.getStars_count());
|
|
||||||
holder.repoForks.setText(currentItem.getForks_count());
|
|
||||||
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
|
||||||
if(holder.isRepoAdmin == null) {
|
if(holder.isRepoAdmin == null) {
|
||||||
holder.isRepoAdmin = new CheckBox(mCtx);
|
holder.isRepoAdmin = new CheckBox(context);
|
||||||
}
|
}
|
||||||
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||||
|
|
||||||
if(currentItem.isArchived()) {
|
|
||||||
holder.archiveRepo.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
holder.archiveRepo.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -329,7 +263,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
return reposFilter;
|
return reposFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Filter reposFilter = new Filter() {
|
private final Filter reposFilter = new Filter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FilterResults performFiltering(CharSequence constraint) {
|
protected FilterResults performFiltering(CharSequence constraint) {
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package org.mian.gitnex.adapters;
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
@ -13,31 +10,32 @@ import android.widget.CheckBox;
|
|||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
import com.amulyakhare.textdrawable.TextDrawable;
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
|
||||||
import org.gitnex.tea4j.models.UserRepositories;
|
import org.gitnex.tea4j.models.UserRepositories;
|
||||||
import org.gitnex.tea4j.models.WatchInfo;
|
import org.gitnex.tea4j.models.WatchInfo;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
import org.mian.gitnex.database.models.Repository;
|
import org.mian.gitnex.database.models.Repository;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
|
import org.mian.gitnex.helpers.ClickListener;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
import org.ocpsoft.prettytime.PrettyTime;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Locale;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -47,63 +45,59 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesByOrgAdapter.OrgReposViewHolder> implements Filterable {
|
public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesByOrgAdapter.OrgReposViewHolder> implements Filterable {
|
||||||
|
|
||||||
private List<UserRepositories> reposList;
|
private final List<UserRepositories> reposList;
|
||||||
private Context mCtx;
|
private final Context context;
|
||||||
private List<UserRepositories> reposListFull;
|
private final List<UserRepositories> reposListFull;
|
||||||
|
|
||||||
static class OrgReposViewHolder extends RecyclerView.ViewHolder {
|
static class OrgReposViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private ImageView image;
|
private UserRepositories userRepositories;
|
||||||
private TextView repoName;
|
|
||||||
private TextView repoDescription;
|
private final ImageView image;
|
||||||
private TextView fullName;
|
private final TextView repoName;
|
||||||
|
private final TextView orgName;
|
||||||
|
private final TextView repoDescription;
|
||||||
private CheckBox isRepoAdmin;
|
private CheckBox isRepoAdmin;
|
||||||
private ImageView repoPrivatePublic;
|
private final TextView repoStars;
|
||||||
private TextView repoStars;
|
private final TextView repoLastUpdated;
|
||||||
private TextView repoForks;
|
|
||||||
private TextView repoOpenIssuesCount;
|
|
||||||
private TextView repoType;
|
|
||||||
private LinearLayout archiveRepo;
|
|
||||||
private TextView repoBranch;
|
|
||||||
private TextView htmlUrl;
|
|
||||||
|
|
||||||
private OrgReposViewHolder(View itemView) {
|
private OrgReposViewHolder(View itemView) {
|
||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
repoName = itemView.findViewById(R.id.repoName);
|
repoName = itemView.findViewById(R.id.repoName);
|
||||||
|
orgName = itemView.findViewById(R.id.orgName);
|
||||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||||
image = itemView.findViewById(R.id.imageAvatar);
|
image = itemView.findViewById(R.id.imageAvatar);
|
||||||
fullName = itemView.findViewById(R.id.repoFullName);
|
|
||||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
|
||||||
repoStars = itemView.findViewById(R.id.repoStars);
|
repoStars = itemView.findViewById(R.id.repoStars);
|
||||||
repoForks = itemView.findViewById(R.id.repoForks);
|
repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
|
||||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
|
||||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
|
||||||
repoType = itemView.findViewById(R.id.repoType);
|
|
||||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
|
||||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
|
||||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", fullName.getText().toString());
|
intent.putExtra("repoFullName", userRepositories.getFullName());
|
||||||
|
|
||||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
tinyDb.putString("repoFullName", userRepositories.getFullName());
|
||||||
tinyDb.putString("repoFullName", fullName.getText().toString());
|
|
||||||
tinyDb.putString("repoType", repoType.getText().toString());
|
|
||||||
//tinyDb.putBoolean("resumeIssues", true);
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||||
tinyDb.putString("repoBranch", repoBranch.getText().toString());
|
tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
|
||||||
|
|
||||||
String[] parts = fullName.getText().toString().split("/");
|
if(userRepositories.getPrivateFlag()) {
|
||||||
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] parts = userRepositories.getFullName().split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||||
|
|
||||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
@ -112,13 +106,11 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
|
|
||||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", id);
|
tinyDb.putLong("repositoryId", id);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
@ -167,81 +159,13 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
|
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
reposDropdownMenu.setOnClickListener(v -> {
|
|
||||||
|
|
||||||
final Context context = v.getContext();
|
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
|
||||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
|
||||||
|
|
||||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
|
||||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
|
||||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
|
||||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
|
||||||
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
|
|
||||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
|
||||||
|
|
||||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
|
||||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
|
||||||
dialog.setContentView(view);
|
|
||||||
dialog.show();
|
|
||||||
|
|
||||||
repoCopyUrl.setOnClickListener(openInBrowser -> {
|
|
||||||
|
|
||||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
|
|
||||||
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
|
|
||||||
assert clipboard != null;
|
|
||||||
clipboard.setPrimaryClip(clip);
|
|
||||||
|
|
||||||
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
|
|
||||||
dialog.dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
|
||||||
|
|
||||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
|
||||||
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
|
|
||||||
context.startActivity(intentOpenInBrowser);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoStargazers.setOnClickListener(stargazers -> {
|
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
|
||||||
intent.putExtra("repoFullNameForStars", fullName.getText());
|
|
||||||
context.startActivity(intent);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoWatchers.setOnClickListener(watchers -> {
|
|
||||||
|
|
||||||
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
|
||||||
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
|
|
||||||
context.startActivity(intentW);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoForksList.setOnClickListener(forks -> {
|
|
||||||
|
|
||||||
Intent intentW = new Intent(context, RepoForksActivity.class);
|
|
||||||
intentW.putExtra("repoFullNameForForks", fullName.getText());
|
|
||||||
context.startActivity(intentW);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RepositoriesByOrgAdapter(Context mCtx, List<UserRepositories> reposListMain) {
|
public RepositoriesByOrgAdapter(Context ctx, List<UserRepositories> reposListMain) {
|
||||||
this.mCtx = mCtx;
|
|
||||||
|
this.context = ctx;
|
||||||
this.reposList = reposListMain;
|
this.reposList = reposListMain;
|
||||||
reposListFull = new ArrayList<>(reposList);
|
reposListFull = new ArrayList<>(reposList);
|
||||||
}
|
}
|
||||||
@ -249,6 +173,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public RepositoriesByOrgAdapter.OrgReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public RepositoriesByOrgAdapter.OrgReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
|
||||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_repositories, parent, false);
|
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_repositories, parent, false);
|
||||||
return new RepositoriesByOrgAdapter.OrgReposViewHolder(v);
|
return new RepositoriesByOrgAdapter.OrgReposViewHolder(v);
|
||||||
}
|
}
|
||||||
@ -256,10 +181,16 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RepositoriesByOrgAdapter.OrgReposViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RepositoriesByOrgAdapter.OrgReposViewHolder holder, int position) {
|
||||||
|
|
||||||
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
UserRepositories currentItem = reposList.get(position);
|
UserRepositories currentItem = reposList.get(position);
|
||||||
holder.repoDescription.setVisibility(View.GONE);
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
|
||||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
String locale = tinyDb.getString("locale");
|
||||||
|
String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
holder.userRepositories = currentItem;
|
||||||
|
holder.orgName.setText(currentItem.getFullName().split("/")[0]);
|
||||||
|
holder.repoName.setText(currentItem.getFullName().split("/")[1]);
|
||||||
|
holder.repoStars.setText(currentItem.getStars_count());
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
int color = generator.getColor(currentItem.getName());
|
int color = generator.getColor(currentItem.getName());
|
||||||
@ -277,7 +208,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
|
|
||||||
if (currentItem.getAvatar_url() != null) {
|
if (currentItem.getAvatar_url() != null) {
|
||||||
if (!currentItem.getAvatar_url().equals("")) {
|
if (!currentItem.getAvatar_url().equals("")) {
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image);
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.image);
|
||||||
} else {
|
} else {
|
||||||
holder.image.setImageDrawable(drawable);
|
holder.image.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
@ -286,36 +217,42 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
holder.image.setImageDrawable(drawable);
|
holder.image.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.repoName.setText(currentItem.getName());
|
if(currentItem.getUpdated_at() != null) {
|
||||||
|
|
||||||
|
switch(timeFormat) {
|
||||||
|
case "pretty": {
|
||||||
|
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
|
||||||
|
String createdTime = prettyTime.format(currentItem.getUpdated_at());
|
||||||
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "normal": {
|
||||||
|
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
|
String createdTime = formatter.format(currentItem.getUpdated_at());
|
||||||
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "normal1": {
|
||||||
|
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
|
String createdTime = formatter.format(currentItem.getUpdated_at());
|
||||||
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
holder.repoLastUpdated.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
if(!currentItem.getDescription().equals("")) {
|
if(!currentItem.getDescription().equals("")) {
|
||||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
|
||||||
holder.repoDescription.setText(currentItem.getDescription());
|
holder.repoDescription.setText(currentItem.getDescription());
|
||||||
}
|
}
|
||||||
holder.fullName.setText(currentItem.getFullName());
|
|
||||||
if(currentItem.getPrivateFlag()) {
|
|
||||||
holder.repoPrivatePublic.setVisibility(View.VISIBLE);
|
|
||||||
holder.repoType.setText(R.string.strPrivate);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
holder.repoPrivatePublic.setVisibility(View.GONE);
|
|
||||||
holder.repoType.setText(R.string.strPublic);
|
|
||||||
}
|
|
||||||
holder.repoStars.setText(currentItem.getStars_count());
|
|
||||||
holder.repoForks.setText(currentItem.getForks_count());
|
|
||||||
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
|
||||||
|
|
||||||
if(holder.isRepoAdmin == null) {
|
if(holder.isRepoAdmin == null) {
|
||||||
holder.isRepoAdmin = new CheckBox(mCtx);
|
holder.isRepoAdmin = new CheckBox(context);
|
||||||
}
|
}
|
||||||
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||||
|
|
||||||
if(currentItem.isArchived()) {
|
|
||||||
holder.archiveRepo.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
holder.archiveRepo.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,6 +15,7 @@ import org.gitnex.tea4j.models.Issues;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
import org.mian.gitnex.database.models.Repository;
|
import org.mian.gitnex.database.models.Repository;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
@ -35,14 +36,14 @@ import java.util.Locale;
|
|||||||
public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapter.SearchViewHolder> {
|
public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapter.SearchViewHolder> {
|
||||||
|
|
||||||
private final List<Issues> searchedList;
|
private final List<Issues> searchedList;
|
||||||
private final Context mCtx;
|
private final Context context;
|
||||||
private final TinyDB tinyDb;
|
private final TinyDB tinyDb;
|
||||||
|
|
||||||
public SearchIssuesAdapter(List<Issues> dataList, Context mCtx) {
|
public SearchIssuesAdapter(List<Issues> dataList, Context ctx) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.searchedList = dataList;
|
this.searchedList = dataList;
|
||||||
this.tinyDb = TinyDB.getInstance(mCtx);
|
this.tinyDb = TinyDB.getInstance(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SearchViewHolder extends RecyclerView.ViewHolder {
|
class SearchViewHolder extends RecyclerView.ViewHolder {
|
||||||
@ -63,7 +64,7 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
|
|||||||
issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount);
|
issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount);
|
||||||
issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime);
|
issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime);
|
||||||
|
|
||||||
issueTitle.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
|
|
||||||
@ -80,7 +81,7 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
|
|||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||||
|
|
||||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
|
|
||||||
@ -121,19 +122,20 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
|
|||||||
public void onBindViewHolder(@NonNull final SearchIssuesAdapter.SearchViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull final SearchIssuesAdapter.SearchViewHolder holder, int position) {
|
||||||
|
|
||||||
Issues currentItem = searchedList.get(position);
|
Issues currentItem = searchedList.get(position);
|
||||||
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
String locale = tinyDb.getString("locale");
|
String locale = tinyDb.getString("locale");
|
||||||
String timeFormat = tinyDb.getString("dateFormat");
|
String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
|
||||||
PicassoService.getInstance(mCtx).get()
|
PicassoService.getInstance(context).get()
|
||||||
.load(currentItem.getUser().getAvatar_url())
|
.load(currentItem.getUser().getAvatar_url())
|
||||||
.placeholder(R.drawable.loader_animated)
|
.placeholder(R.drawable.loader_animated)
|
||||||
.transform(new RoundedTransformation(8, 0))
|
.transform(new RoundedTransformation(imgRadius, 0))
|
||||||
.resize(120, 120)
|
.resize(120, 120)
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.into(holder.issueAssigneeAvatar);
|
.into(holder.issueAssigneeAvatar);
|
||||||
|
|
||||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(mCtx.getResources(), R.color.lightGray, null) + "'>" + currentItem.getRepository().getFull_name() + mCtx.getResources().getString(R.string.hash) + currentItem.getNumber() + "</font>";
|
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + currentItem.getRepository().getFull_name() + context.getResources().getString(R.string.hash) + currentItem.getNumber() + "</font>";
|
||||||
|
|
||||||
holder.issue = currentItem;
|
holder.issue = currentItem;
|
||||||
holder.issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + currentItem.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
holder.issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + currentItem.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||||
@ -144,17 +146,17 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
|
|||||||
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
|
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
|
||||||
String createdTime = prettyTime.format(currentItem.getCreated_at());
|
String createdTime = prettyTime.format(currentItem.getCreated_at());
|
||||||
holder.issueCreatedTime.setText(createdTime);
|
holder.issueCreatedTime.setText(createdTime);
|
||||||
holder.issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getCreated_at()), mCtx));
|
holder.issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getCreated_at()), context));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "normal": {
|
case "normal": {
|
||||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + mCtx.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
String createdTime = formatter.format(currentItem.getCreated_at());
|
String createdTime = formatter.format(currentItem.getCreated_at());
|
||||||
holder.issueCreatedTime.setText(createdTime);
|
holder.issueCreatedTime.setText(createdTime);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "normal1": {
|
case "normal1": {
|
||||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + mCtx.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
String createdTime = formatter.format(currentItem.getCreated_at());
|
String createdTime = formatter.format(currentItem.getCreated_at());
|
||||||
holder.issueCreatedTime.setText(createdTime);
|
holder.issueCreatedTime.setText(createdTime);
|
||||||
break;
|
break;
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
package org.mian.gitnex.adapters;
|
|
||||||
|
|
||||||
import android.text.SpannableStringBuilder;
|
|
||||||
import android.text.method.LinkMovementMethod;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import org.mian.gitnex.R;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Author M M Arif
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class SponsorsAdapter extends RecyclerView.Adapter<SponsorsAdapter.SponsorsViewHolder> {
|
|
||||||
|
|
||||||
private List<CharSequence> sponsorsList;
|
|
||||||
|
|
||||||
static class SponsorsViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
private TextView sponsorText;
|
|
||||||
|
|
||||||
private SponsorsViewHolder(View itemView) {
|
|
||||||
super(itemView);
|
|
||||||
|
|
||||||
sponsorText = itemView.findViewById(R.id.sponsorText);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public SponsorsAdapter(List<CharSequence> sponsorsListMain) {
|
|
||||||
this.sponsorsList = sponsorsListMain;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public SponsorsAdapter.SponsorsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
||||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.sponsors, parent, false);
|
|
||||||
return new SponsorsAdapter.SponsorsViewHolder(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(@NonNull SponsorsAdapter.SponsorsViewHolder holder, int position) {
|
|
||||||
|
|
||||||
SpannableStringBuilder strBuilder = new SpannableStringBuilder(sponsorsList.get(position));
|
|
||||||
holder.sponsorText.setText((strBuilder));
|
|
||||||
holder.sponsorText.setMovementMethod(LinkMovementMethod.getInstance());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return sponsorsList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,8 +1,5 @@
|
|||||||
package org.mian.gitnex.adapters;
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
@ -13,31 +10,32 @@ import android.widget.CheckBox;
|
|||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
import com.amulyakhare.textdrawable.TextDrawable;
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
|
||||||
import org.gitnex.tea4j.models.UserRepositories;
|
import org.gitnex.tea4j.models.UserRepositories;
|
||||||
import org.gitnex.tea4j.models.WatchInfo;
|
import org.gitnex.tea4j.models.WatchInfo;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
import org.mian.gitnex.database.models.Repository;
|
import org.mian.gitnex.database.models.Repository;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
|
import org.mian.gitnex.helpers.ClickListener;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
import org.ocpsoft.prettytime.PrettyTime;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Locale;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
||||||
@ -47,63 +45,59 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposListAdapter.StarredReposViewHolder> implements Filterable {
|
public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposListAdapter.StarredReposViewHolder> implements Filterable {
|
||||||
|
|
||||||
private List<UserRepositories> reposList;
|
private final List<UserRepositories> reposList;
|
||||||
private Context mCtx;
|
private final Context context;
|
||||||
private List<UserRepositories> reposListFull;
|
private final List<UserRepositories> reposListFull;
|
||||||
|
|
||||||
static class StarredReposViewHolder extends RecyclerView.ViewHolder {
|
static class StarredReposViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private ImageView image;
|
private UserRepositories userRepositories;
|
||||||
private TextView repoName;
|
|
||||||
private TextView repoDescription;
|
private final ImageView image;
|
||||||
private TextView fullName;
|
private final TextView repoName;
|
||||||
|
private final TextView orgName;
|
||||||
|
private final TextView repoDescription;
|
||||||
private CheckBox isRepoAdmin;
|
private CheckBox isRepoAdmin;
|
||||||
private ImageView repoPrivatePublic;
|
private final TextView repoStars;
|
||||||
private TextView repoStars;
|
private final TextView repoLastUpdated;
|
||||||
private TextView repoForks;
|
|
||||||
private TextView repoOpenIssuesCount;
|
|
||||||
private TextView repoType;
|
|
||||||
private LinearLayout archiveRepo;
|
|
||||||
private TextView repoBranch;
|
|
||||||
private TextView htmlUrl;
|
|
||||||
|
|
||||||
private StarredReposViewHolder(View itemView) {
|
private StarredReposViewHolder(View itemView) {
|
||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
repoName = itemView.findViewById(R.id.repoName);
|
repoName = itemView.findViewById(R.id.repoName);
|
||||||
|
orgName = itemView.findViewById(R.id.orgName);
|
||||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||||
image = itemView.findViewById(R.id.imageAvatar);
|
image = itemView.findViewById(R.id.imageAvatar);
|
||||||
fullName = itemView.findViewById(R.id.repoFullName);
|
|
||||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
|
||||||
repoStars = itemView.findViewById(R.id.repoStars);
|
repoStars = itemView.findViewById(R.id.repoStars);
|
||||||
repoForks = itemView.findViewById(R.id.repoForks);
|
repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
|
||||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
|
||||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
|
||||||
repoType = itemView.findViewById(R.id.repoType);
|
|
||||||
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
|
||||||
repoBranch = itemView.findViewById(R.id.repoBranch);
|
|
||||||
htmlUrl = itemView.findViewById(R.id.htmlUrl);
|
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", fullName.getText().toString());
|
intent.putExtra("repoFullName", userRepositories.getFullName());
|
||||||
|
|
||||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
tinyDb.putString("repoFullName", userRepositories.getFullName());
|
||||||
tinyDb.putString("repoFullName", fullName.getText().toString());
|
|
||||||
tinyDb.putString("repoType", repoType.getText().toString());
|
|
||||||
//tinyDb.putBoolean("resumeIssues", true);
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||||
tinyDb.putString("repoBranch", repoBranch.getText().toString());
|
tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
|
||||||
|
|
||||||
String[] parts = fullName.getText().toString().split("/");
|
if(userRepositories.getPrivateFlag()) {
|
||||||
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] parts = userRepositories.getFullName().split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||||
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
||||||
|
|
||||||
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||||
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
@ -112,13 +106,11 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
|
|
||||||
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", id);
|
tinyDb.putLong("repositoryId", id);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
||||||
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
@ -170,81 +162,12 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
reposDropdownMenu.setOnClickListener(v -> {
|
|
||||||
|
|
||||||
final Context context = v.getContext();
|
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
|
||||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
|
||||||
|
|
||||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
|
||||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
|
||||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
|
||||||
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
|
||||||
TextView repoCopyUrl = view.findViewById(R.id.repoCopyUrl);
|
|
||||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
|
||||||
|
|
||||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
|
||||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
|
||||||
dialog.setContentView(view);
|
|
||||||
dialog.show();
|
|
||||||
|
|
||||||
repoCopyUrl.setOnClickListener(openInBrowser -> {
|
|
||||||
|
|
||||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(context).getSystemService(Context.CLIPBOARD_SERVICE);
|
|
||||||
ClipData clip = ClipData.newPlainText("repoUrl", htmlUrl.getText().toString());
|
|
||||||
assert clipboard != null;
|
|
||||||
clipboard.setPrimaryClip(clip);
|
|
||||||
|
|
||||||
Toasty.info(context, context.getString(R.string.copyIssueUrlToastMsg));
|
|
||||||
dialog.dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
|
||||||
|
|
||||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
|
||||||
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
|
|
||||||
context.startActivity(intentOpenInBrowser);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoStargazers.setOnClickListener(stargazers -> {
|
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
|
||||||
intent.putExtra("repoFullNameForStars", fullName.getText());
|
|
||||||
context.startActivity(intent);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoWatchers.setOnClickListener(watchers -> {
|
|
||||||
|
|
||||||
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
|
||||||
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
|
|
||||||
context.startActivity(intentW);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
repoForksList.setOnClickListener(forks -> {
|
|
||||||
|
|
||||||
Intent intentW = new Intent(context, RepoForksActivity.class);
|
|
||||||
intentW.putExtra("repoFullNameForForks", fullName.getText());
|
|
||||||
context.startActivity(intentW);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public StarredReposListAdapter(Context mCtx, List<UserRepositories> reposListMain) {
|
public StarredReposListAdapter(Context ctx, List<UserRepositories> reposListMain) {
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.reposList = reposListMain;
|
this.reposList = reposListMain;
|
||||||
reposListFull = new ArrayList<>(reposList);
|
reposListFull = new ArrayList<>(reposList);
|
||||||
}
|
}
|
||||||
@ -259,10 +182,16 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull StarredReposListAdapter.StarredReposViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull StarredReposListAdapter.StarredReposViewHolder holder, int position) {
|
||||||
|
|
||||||
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
UserRepositories currentItem = reposList.get(position);
|
UserRepositories currentItem = reposList.get(position);
|
||||||
holder.repoDescription.setVisibility(View.GONE);
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
holder.repoBranch.setText(currentItem.getDefault_branch());
|
|
||||||
holder.htmlUrl.setText(currentItem.getHtml_url());
|
String locale = tinyDb.getString("locale");
|
||||||
|
String timeFormat = tinyDb.getString("dateFormat");
|
||||||
|
holder.userRepositories = currentItem;
|
||||||
|
holder.orgName.setText(currentItem.getFullName().split("/")[0]);
|
||||||
|
holder.repoName.setText(currentItem.getFullName().split("/")[1]);
|
||||||
|
holder.repoStars.setText(currentItem.getStars_count());
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
int color = generator.getColor(currentItem.getName());
|
int color = generator.getColor(currentItem.getName());
|
||||||
@ -280,7 +209,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
|
|
||||||
if (currentItem.getAvatar_url() != null) {
|
if (currentItem.getAvatar_url() != null) {
|
||||||
if (!currentItem.getAvatar_url().equals("")) {
|
if (!currentItem.getAvatar_url().equals("")) {
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image);
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.image);
|
||||||
} else {
|
} else {
|
||||||
holder.image.setImageDrawable(drawable);
|
holder.image.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
@ -289,35 +218,42 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
holder.image.setImageDrawable(drawable);
|
holder.image.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.repoName.setText(currentItem.getName());
|
if(currentItem.getUpdated_at() != null) {
|
||||||
|
|
||||||
|
switch(timeFormat) {
|
||||||
|
case "pretty": {
|
||||||
|
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
|
||||||
|
String createdTime = prettyTime.format(currentItem.getUpdated_at());
|
||||||
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "normal": {
|
||||||
|
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
|
String createdTime = formatter.format(currentItem.getUpdated_at());
|
||||||
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "normal1": {
|
||||||
|
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
||||||
|
String createdTime = formatter.format(currentItem.getUpdated_at());
|
||||||
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
holder.repoLastUpdated.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
if(!currentItem.getDescription().equals("")) {
|
if(!currentItem.getDescription().equals("")) {
|
||||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
|
||||||
holder.repoDescription.setText(currentItem.getDescription());
|
holder.repoDescription.setText(currentItem.getDescription());
|
||||||
}
|
}
|
||||||
holder.fullName.setText(currentItem.getFullName());
|
|
||||||
if(currentItem.getPrivateFlag()) {
|
|
||||||
holder.repoPrivatePublic.setVisibility(View.VISIBLE);
|
|
||||||
holder.repoType.setText(R.string.strPrivate);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
holder.repoPrivatePublic.setVisibility(View.GONE);
|
|
||||||
holder.repoType.setText(R.string.strPublic);
|
|
||||||
}
|
|
||||||
holder.repoStars.setText(currentItem.getStars_count());
|
|
||||||
holder.repoForks.setText(currentItem.getForks_count());
|
|
||||||
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
|
||||||
if(holder.isRepoAdmin == null) {
|
if(holder.isRepoAdmin == null) {
|
||||||
holder.isRepoAdmin = new CheckBox(mCtx);
|
holder.isRepoAdmin = new CheckBox(context);
|
||||||
}
|
}
|
||||||
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||||
|
|
||||||
if(currentItem.isArchived()) {
|
|
||||||
holder.archiveRepo.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
holder.archiveRepo.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -330,7 +266,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
return starredReposFilter;
|
return starredReposFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Filter starredReposFilter = new Filter() {
|
private final Filter starredReposFilter = new Filter() {
|
||||||
@Override
|
@Override
|
||||||
protected FilterResults performFiltering(CharSequence constraint) {
|
protected FilterResults performFiltering(CharSequence constraint) {
|
||||||
List<UserRepositories> filteredList = new ArrayList<>();
|
List<UserRepositories> filteredList = new ArrayList<>();
|
||||||
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
public class TeamMembersByOrgAdapter extends BaseAdapter {
|
public class TeamMembersByOrgAdapter extends BaseAdapter {
|
||||||
|
|
||||||
private final List<UserInfo> teamMembersList;
|
private final List<UserInfo> teamMembersList;
|
||||||
private final Context mCtx;
|
private final Context context;
|
||||||
|
|
||||||
private static class ViewHolder {
|
private static class ViewHolder {
|
||||||
|
|
||||||
@ -48,9 +48,9 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TeamMembersByOrgAdapter(Context mCtx, List<UserInfo> membersListMain) {
|
public TeamMembersByOrgAdapter(Context ctx, List<UserInfo> membersListMain) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.teamMembersList = membersListMain;
|
this.teamMembersList = membersListMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
if (finalView == null) {
|
if (finalView == null) {
|
||||||
|
|
||||||
finalView = LayoutInflater.from(mCtx).inflate(R.layout.list_members_by_team_by_org, null);
|
finalView = LayoutInflater.from(context).inflate(R.layout.list_members_by_team_by_org, null);
|
||||||
viewHolder = new ViewHolder(finalView);
|
viewHolder = new ViewHolder(finalView);
|
||||||
finalView.setTag(viewHolder);
|
finalView.setTag(viewHolder);
|
||||||
}
|
}
|
||||||
@ -93,25 +93,27 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
|
|||||||
private void initData(TeamMembersByOrgAdapter.ViewHolder viewHolder, int position) {
|
private void initData(TeamMembersByOrgAdapter.ViewHolder viewHolder, int position) {
|
||||||
|
|
||||||
UserInfo currentItem = teamMembersList.get(position);
|
UserInfo currentItem = teamMembersList.get(position);
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(viewHolder.memberAvatar);
|
||||||
|
|
||||||
viewHolder.userLoginId = currentItem.getLogin();
|
viewHolder.userLoginId = currentItem.getLogin();
|
||||||
|
|
||||||
final TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
final TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
Typeface myTypeface;
|
Typeface myTypeface;
|
||||||
|
|
||||||
switch(tinyDb.getInt("customFontId", -1)) {
|
switch(tinyDb.getInt("customFontId", -1)) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf");
|
myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/roboto.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/sourcecodeproregular.ttf");
|
myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/manroperegular.ttf");
|
myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/manroperegular.ttf");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,44 +22,41 @@ import java.util.List;
|
|||||||
|
|
||||||
public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.OrgTeamsViewHolder> implements Filterable {
|
public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.OrgTeamsViewHolder> implements Filterable {
|
||||||
|
|
||||||
private List<Teams> teamList;
|
private final List<Teams> teamList;
|
||||||
private Context mCtx;
|
private final Context context;
|
||||||
private List<Teams> teamListFull;
|
private final List<Teams> teamListFull;
|
||||||
|
|
||||||
static class OrgTeamsViewHolder extends RecyclerView.ViewHolder {
|
static class OrgTeamsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private TextView teamTitle;
|
private Teams teams;
|
||||||
private TextView teamId;
|
|
||||||
private TextView teamDescription;
|
private final TextView teamTitle;
|
||||||
private TextView teamPermission;
|
private final TextView teamDescription;
|
||||||
|
private final TextView teamPermission;
|
||||||
|
|
||||||
private OrgTeamsViewHolder(View itemView) {
|
private OrgTeamsViewHolder(View itemView) {
|
||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
teamTitle = itemView.findViewById(R.id.teamTitle);
|
teamTitle = itemView.findViewById(R.id.teamTitle);
|
||||||
teamId = itemView.findViewById(R.id.teamId);
|
|
||||||
teamDescription = itemView.findViewById(R.id.teamDescription);
|
teamDescription = itemView.findViewById(R.id.teamDescription);
|
||||||
teamPermission = itemView.findViewById(R.id.teamPermission);
|
teamPermission = itemView.findViewById(R.id.teamPermission);
|
||||||
|
|
||||||
itemView.setOnClickListener(new View.OnClickListener() {
|
itemView.setOnClickListener(v -> {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
|
|
||||||
Intent intent = new Intent(context, OrganizationTeamMembersActivity.class);
|
Intent intent = new Intent(context, OrganizationTeamMembersActivity.class);
|
||||||
intent.putExtra("teamTitle", teamTitle.getText().toString());
|
intent.putExtra("teamTitle", teams.getName());
|
||||||
intent.putExtra("teamId", teamId.getText().toString());
|
intent.putExtra("teamId", String.valueOf(teams.getId()));
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TeamsByOrgAdapter(Context mCtx, List<Teams> teamListMain) {
|
public TeamsByOrgAdapter(Context ctx, List<Teams> teamListMain) {
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.teamList = teamListMain;
|
this.teamList = teamListMain;
|
||||||
teamListFull = new ArrayList<>(teamList);
|
teamListFull = new ArrayList<>(teamList);
|
||||||
}
|
}
|
||||||
@ -75,8 +72,10 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
|||||||
public void onBindViewHolder(@NonNull TeamsByOrgAdapter.OrgTeamsViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull TeamsByOrgAdapter.OrgTeamsViewHolder holder, int position) {
|
||||||
|
|
||||||
Teams currentItem = teamList.get(position);
|
Teams currentItem = teamList.get(position);
|
||||||
holder.teamId.setText(String.valueOf(currentItem.getId()));
|
|
||||||
|
holder.teams = currentItem;
|
||||||
holder.teamTitle.setText(currentItem.getName());
|
holder.teamTitle.setText(currentItem.getName());
|
||||||
|
|
||||||
if (!currentItem.getDescription().equals("")) {
|
if (!currentItem.getDescription().equals("")) {
|
||||||
holder.teamDescription.setVisibility(View.VISIBLE);
|
holder.teamDescription.setVisibility(View.VISIBLE);
|
||||||
holder.teamDescription.setText(currentItem.getDescription());
|
holder.teamDescription.setText(currentItem.getDescription());
|
||||||
@ -85,8 +84,7 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
|||||||
holder.teamDescription.setVisibility(View.GONE);
|
holder.teamDescription.setVisibility(View.GONE);
|
||||||
holder.teamDescription.setText("");
|
holder.teamDescription.setText("");
|
||||||
}
|
}
|
||||||
holder.teamPermission.setText(mCtx.getResources().getString(R.string.teamPermission, currentItem.getPermission()));
|
holder.teamPermission.setText(context.getResources().getString(R.string.teamPermission, currentItem.getPermission()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -99,7 +97,7 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
|||||||
return orgTeamsFilter;
|
return orgTeamsFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Filter orgTeamsFilter = new Filter() {
|
private final Filter orgTeamsFilter = new Filter() {
|
||||||
@Override
|
@Override
|
||||||
protected FilterResults performFiltering(CharSequence constraint) {
|
protected FilterResults performFiltering(CharSequence constraint) {
|
||||||
List<Teams> filteredList = new ArrayList<>();
|
List<Teams> filteredList = new ArrayList<>();
|
||||||
|
@ -14,8 +14,10 @@ import androidx.appcompat.content.res.AppCompatResources;
|
|||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||||
import org.mian.gitnex.database.models.UserAccount;
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
@ -29,7 +31,7 @@ import io.mikael.urlbuilder.UrlBuilder;
|
|||||||
public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapter.UserAccountsViewHolder> {
|
public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapter.UserAccountsViewHolder> {
|
||||||
|
|
||||||
private final List<UserAccount> userAccountsList;
|
private final List<UserAccount> userAccountsList;
|
||||||
private final Context mCtx;
|
private final Context context;
|
||||||
private TinyDB tinyDB;
|
private TinyDB tinyDB;
|
||||||
|
|
||||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||||
@ -55,49 +57,43 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||||||
|
|
||||||
deleteAccount.setOnClickListener(itemDelete -> {
|
deleteAccount.setOnClickListener(itemDelete -> {
|
||||||
|
|
||||||
new AlertDialog.Builder(mCtx)
|
new AlertDialog.Builder(context)
|
||||||
.setIcon(AppCompatResources.getDrawable(mCtx, R.drawable.ic_delete))
|
.setIcon(AppCompatResources.getDrawable(context, R.drawable.ic_delete))
|
||||||
.setTitle(mCtx.getResources().getString(R.string.removeAccountPopupTitle))
|
.setTitle(context.getResources().getString(R.string.removeAccountPopupTitle))
|
||||||
.setMessage(mCtx.getResources().getString(R.string.removeAccountPopupMessage))
|
.setMessage(context.getResources().getString(R.string.removeAccountPopupMessage))
|
||||||
.setPositiveButton(mCtx.getResources().getString(R.string.removeButton), (dialog, which) -> {
|
.setPositiveButton(context.getResources().getString(R.string.removeButton), (dialog, which) -> {
|
||||||
|
|
||||||
updateLayoutByPosition(getAdapterPosition());
|
updateLayoutByPosition(getAdapterPosition());
|
||||||
UserAccountsApi userAccountsApi = new UserAccountsApi(mCtx);
|
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
|
||||||
userAccountsApi.deleteAccount(Integer.parseInt(String.valueOf(accountId)));
|
userAccountsApi.deleteAccount(Integer.parseInt(String.valueOf(accountId)));
|
||||||
}).setNeutralButton(mCtx.getResources().getString(R.string.cancelButton), null)
|
}).setNeutralButton(context.getResources().getString(R.string.cancelButton), null)
|
||||||
.show();
|
.show();
|
||||||
});
|
});
|
||||||
|
|
||||||
itemView.setOnClickListener(switchAccount -> {
|
itemView.setOnClickListener(switchAccount -> {
|
||||||
|
|
||||||
UserAccountsApi userAccountsApi = new UserAccountsApi(mCtx);
|
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
|
||||||
UserAccount userAccount = userAccountsApi.getAccountData(accountName);
|
UserAccount userAccount = userAccountsApi.getAccountByName(accountName);
|
||||||
|
|
||||||
if(tinyDB.getInt("currentActiveAccountId") != userAccount.getAccountId()) {
|
if(AppUtil.switchToAccount(context, userAccount)) {
|
||||||
|
|
||||||
String url = UrlBuilder.fromString(userAccount.getInstanceUrl())
|
String url = UrlBuilder.fromString(userAccount.getInstanceUrl())
|
||||||
.withPath("/")
|
.withPath("/")
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
tinyDB.putString("loginUid", userAccount.getUserName());
|
Toasty.success(context, context.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url));
|
||||||
tinyDB.putString("userLogin", userAccount.getUserName());
|
((Activity) context).recreate();
|
||||||
tinyDB.putString(userAccount.getUserName() + "-token", userAccount.getToken());
|
|
||||||
tinyDB.putString("instanceUrl", userAccount.getInstanceUrl());
|
|
||||||
tinyDB.putInt("currentActiveAccountId", userAccount.getAccountId());
|
|
||||||
|
|
||||||
Toasty.success(mCtx, mCtx.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url));
|
|
||||||
((Activity) mCtx).recreate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserAccountsAdapter(Context mCtx, List<UserAccount> userAccountsListMain) {
|
public UserAccountsAdapter(Context ctx, List<UserAccount> userAccountsListMain) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.userAccountsList = userAccountsListMain;
|
this.userAccountsList = userAccountsListMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +102,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||||||
userAccountsList.remove(position);
|
userAccountsList.remove(position);
|
||||||
notifyItemRemoved(position);
|
notifyItemRemoved(position);
|
||||||
notifyItemRangeChanged(position, userAccountsList.size());
|
notifyItemRangeChanged(position, userAccountsList.size());
|
||||||
Toasty.success(mCtx, mCtx.getResources().getString(R.string.accountDeletedMessage));
|
Toasty.success(context, context.getResources().getString(R.string.accountDeletedMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -122,7 +118,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||||||
public void onBindViewHolder(@NonNull UserAccountsAdapter.UserAccountsViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull UserAccountsAdapter.UserAccountsViewHolder holder, int position) {
|
||||||
|
|
||||||
UserAccount currentItem = userAccountsList.get(position);
|
UserAccount currentItem = userAccountsList.get(position);
|
||||||
tinyDB = TinyDB.getInstance(mCtx);
|
tinyDB = TinyDB.getInstance(context);
|
||||||
|
|
||||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
||||||
.withPath("/")
|
.withPath("/")
|
||||||
@ -131,17 +127,23 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||||||
holder.accountId = currentItem.getAccountId();
|
holder.accountId = currentItem.getAccountId();
|
||||||
holder.accountName = currentItem.getAccountName();
|
holder.accountName = currentItem.getAccountName();
|
||||||
|
|
||||||
holder.userId.setText(String.format("@%s", currentItem.getUserName()));
|
holder.userId.setText(currentItem.getUserName());
|
||||||
holder.accountUrl.setText(url);
|
holder.accountUrl.setText(url);
|
||||||
|
|
||||||
PicassoService.getInstance(mCtx).get().load(url + "img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.repoAvatar);
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
|
PicassoService.getInstance(context).get()
|
||||||
|
.load(url + "img/favicon.png")
|
||||||
|
.placeholder(R.drawable.loader_animated)
|
||||||
|
.transform(new RoundedTransformation(imgRadius, 0))
|
||||||
|
.resize(120, 120)
|
||||||
|
.centerCrop()
|
||||||
|
.into(holder.repoAvatar);
|
||||||
|
|
||||||
if(tinyDB.getInt("currentActiveAccountId") == currentItem.getAccountId()) {
|
if(tinyDB.getInt("currentActiveAccountId") == currentItem.getAccountId()) {
|
||||||
|
|
||||||
holder.activeAccount.setVisibility(View.VISIBLE);
|
holder.activeAccount.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
holder.deleteAccount.setVisibility(View.VISIBLE);
|
holder.deleteAccount.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import androidx.annotation.Nullable;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.database.models.UserAccount;
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -23,18 +24,17 @@ import io.mikael.urlbuilder.UrlBuilder;
|
|||||||
|
|
||||||
public class UserAccountsListDialogAdapter extends ArrayAdapter<UserAccount> {
|
public class UserAccountsListDialogAdapter extends ArrayAdapter<UserAccount> {
|
||||||
|
|
||||||
private final Context mCtx;
|
private final Context context;
|
||||||
private final TinyDB tinyDB;
|
private final TinyDB tinyDB;
|
||||||
private final List<UserAccount> userAccounts;
|
private final List<UserAccount> userAccounts;
|
||||||
|
|
||||||
public UserAccountsListDialogAdapter(@NonNull Context mCtx, int resource, @NonNull List<UserAccount> userAccounts) {
|
public UserAccountsListDialogAdapter(@NonNull Context ctx, int resource, @NonNull List<UserAccount> userAccounts) {
|
||||||
|
|
||||||
super(mCtx, resource, userAccounts);
|
super(ctx, resource, userAccounts);
|
||||||
|
|
||||||
tinyDB = TinyDB.getInstance(mCtx);
|
tinyDB = TinyDB.getInstance(ctx);
|
||||||
this.userAccounts = userAccounts;
|
this.userAccounts = userAccounts;
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -42,7 +42,7 @@ public class UserAccountsListDialogAdapter extends ArrayAdapter<UserAccount> {
|
|||||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||||
|
|
||||||
if(convertView == null) {
|
if(convertView == null) {
|
||||||
convertView = LayoutInflater.from(mCtx).inflate(R.layout.custom_user_accounts_list, parent, false);
|
convertView = LayoutInflater.from(context).inflate(R.layout.custom_user_accounts_list, parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageView profileImage = convertView.findViewById(R.id.profileImage);
|
ImageView profileImage = convertView.findViewById(R.id.profileImage);
|
||||||
@ -51,6 +51,7 @@ public class UserAccountsListDialogAdapter extends ArrayAdapter<UserAccount> {
|
|||||||
ImageView activeAccount = convertView.findViewById(R.id.activeAccount);
|
ImageView activeAccount = convertView.findViewById(R.id.activeAccount);
|
||||||
|
|
||||||
UserAccount currentItem = userAccounts.get(position);
|
UserAccount currentItem = userAccounts.get(position);
|
||||||
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
|
|
||||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
String url = UrlBuilder.fromString(currentItem.getInstanceUrl())
|
||||||
.withPath("/")
|
.withPath("/")
|
||||||
@ -67,7 +68,7 @@ public class UserAccountsListDialogAdapter extends ArrayAdapter<UserAccount> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PicassoService
|
PicassoService
|
||||||
.getInstance(mCtx).get().load(url + "img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(profileImage);
|
.getInstance(context).get().load(url + "img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(profileImage);
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
|
|
||||||
|
@ -18,11 +18,10 @@ import androidx.drawerlayout.widget.DrawerLayout;
|
|||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
|
||||||
import org.mian.gitnex.database.models.UserAccount;
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
import org.mian.gitnex.fragments.UserAccountsFragment;
|
import org.mian.gitnex.fragments.UserAccountsFragment;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import io.mikael.urlbuilder.UrlBuilder;
|
import io.mikael.urlbuilder.UrlBuilder;
|
||||||
@ -34,13 +33,13 @@ import io.mikael.urlbuilder.UrlBuilder;
|
|||||||
public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNavAdapter.UserAccountsViewHolder> {
|
public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNavAdapter.UserAccountsViewHolder> {
|
||||||
|
|
||||||
private static DrawerLayout drawer;
|
private static DrawerLayout drawer;
|
||||||
private List<UserAccount> userAccountsList;
|
private final List<UserAccount> userAccountsList;
|
||||||
private Context mCtx;
|
private final Context context;
|
||||||
private TextView toolbarTitle;
|
private final TextView toolbarTitle;
|
||||||
|
|
||||||
public UserAccountsNavAdapter(Context mCtx, List<UserAccount> userAccountsListMain, DrawerLayout drawerLayout, TextView toolbarTitle) {
|
public UserAccountsNavAdapter(Context ctx, List<UserAccount> userAccountsListMain, DrawerLayout drawerLayout, TextView toolbarTitle) {
|
||||||
|
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.userAccountsList = userAccountsListMain;
|
this.userAccountsList = userAccountsListMain;
|
||||||
drawer = drawerLayout;
|
drawer = drawerLayout;
|
||||||
this.toolbarTitle = toolbarTitle;
|
this.toolbarTitle = toolbarTitle;
|
||||||
@ -48,7 +47,7 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
|||||||
|
|
||||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private ImageView userAccountAvatar;
|
private final ImageView userAccountAvatar;
|
||||||
|
|
||||||
private UserAccountsViewHolder(View itemView) {
|
private UserAccountsViewHolder(View itemView) {
|
||||||
|
|
||||||
@ -57,7 +56,6 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
|||||||
userAccountAvatar = itemView.findViewById(R.id.userAccountAvatar);
|
userAccountAvatar = itemView.findViewById(R.id.userAccountAvatar);
|
||||||
|
|
||||||
itemView.setOnClickListener(item -> {
|
itemView.setOnClickListener(item -> {
|
||||||
|
|
||||||
customDialogUserAccountsList(userAccountsList);
|
customDialogUserAccountsList(userAccountsList);
|
||||||
drawer.closeDrawers();
|
drawer.closeDrawers();
|
||||||
});
|
});
|
||||||
@ -84,8 +82,15 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
|||||||
.withPath("/")
|
.withPath("/")
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
PicassoService
|
int imageSize = AppUtil.getPixelsFromDensity(context, 35);
|
||||||
.getInstance(mCtx).get().load(url + "img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.userAccountAvatar);
|
|
||||||
|
PicassoService.getInstance(context).get()
|
||||||
|
.load(url + "img/favicon.png")
|
||||||
|
.placeholder(R.drawable.loader_animated)
|
||||||
|
.transform(new RoundedTransformation(8, 0))
|
||||||
|
.resize(imageSize, imageSize)
|
||||||
|
.centerCrop()
|
||||||
|
.into(holder.userAccountAvatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -96,8 +101,7 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
|||||||
|
|
||||||
private void customDialogUserAccountsList(List<UserAccount> allAccountsList) {
|
private void customDialogUserAccountsList(List<UserAccount> allAccountsList) {
|
||||||
|
|
||||||
TinyDB tinyDB = TinyDB.getInstance(mCtx);
|
Dialog dialog = new Dialog(context, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
||||||
Dialog dialog = new Dialog(mCtx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
|
|
||||||
dialog.setContentView(R.layout.custom_user_accounts_dialog);
|
dialog.setContentView(R.layout.custom_user_accounts_dialog);
|
||||||
|
|
||||||
ListView listView = dialog.findViewById(R.id.accountsList);
|
ListView listView = dialog.findViewById(R.id.accountsList);
|
||||||
@ -109,38 +113,33 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
|||||||
|
|
||||||
manageAccounts.setOnClickListener(item -> {
|
manageAccounts.setOnClickListener(item -> {
|
||||||
|
|
||||||
toolbarTitle.setText(mCtx.getResources().getString(R.string.pageTitleUserAccounts));
|
toolbarTitle.setText(context.getResources().getString(R.string.pageTitleUserAccounts));
|
||||||
AppCompatActivity activity = (AppCompatActivity) mCtx;
|
AppCompatActivity activity = (AppCompatActivity) context;
|
||||||
activity.getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new UserAccountsFragment()).commit();
|
activity.getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new UserAccountsFragment()).commit();
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
UserAccountsListDialogAdapter arrayAdapter = new UserAccountsListDialogAdapter(mCtx, R.layout.custom_user_accounts_list, allAccountsList);
|
UserAccountsListDialogAdapter arrayAdapter = new UserAccountsListDialogAdapter(context, R.layout.custom_user_accounts_list, allAccountsList);
|
||||||
listView.setAdapter(arrayAdapter);
|
listView.setAdapter(arrayAdapter);
|
||||||
|
|
||||||
listView.setOnItemClickListener((adapterView, view, which, l) -> {
|
listView.setOnItemClickListener((adapterView, view, which, l) -> {
|
||||||
|
|
||||||
String accountNameSwitch = allAccountsList.get(which).getAccountName();
|
UserAccount userAccount = allAccountsList.get(which);
|
||||||
UserAccountsApi userAccountsApi = new UserAccountsApi(mCtx);
|
|
||||||
UserAccount userAccount = userAccountsApi.getAccountData(accountNameSwitch);
|
|
||||||
|
|
||||||
if(tinyDB.getInt("currentActiveAccountId") != userAccount.getAccountId()) {
|
if(AppUtil.switchToAccount(context, userAccount)) {
|
||||||
|
|
||||||
String url = UrlBuilder.fromString(userAccount.getInstanceUrl())
|
String url = UrlBuilder.fromString(userAccount.getInstanceUrl())
|
||||||
.withPath("/")
|
.withPath("/")
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
tinyDB.putString("loginUid", userAccount.getUserName());
|
Toasty.success(context, context.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url));
|
||||||
tinyDB.putString("userLogin", userAccount.getUserName());
|
((Activity) context).recreate();
|
||||||
tinyDB.putString(userAccount.getUserName() + "-token", userAccount.getToken());
|
|
||||||
tinyDB.putString("instanceUrl", userAccount.getInstanceUrl());
|
|
||||||
tinyDB.putInt("currentActiveAccountId", userAccount.getAccountId());
|
|
||||||
|
|
||||||
Toasty.success(mCtx, mCtx.getResources().getString(R.string.switchAccountSuccess, userAccount.getUserName(), url));
|
|
||||||
((Activity) mCtx).recreate();
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.mian.gitnex.adapters;
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -20,6 +19,7 @@ import org.mian.gitnex.actions.CollaboratorActions;
|
|||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
@ -34,84 +34,69 @@ import retrofit2.Response;
|
|||||||
|
|
||||||
public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.UserSearchViewHolder> {
|
public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.UserSearchViewHolder> {
|
||||||
|
|
||||||
private List<UserInfo> usersSearchList;
|
private final List<UserInfo> usersSearchList;
|
||||||
private Context mCtx;
|
private final Context context;
|
||||||
|
|
||||||
public UserSearchAdapter(List<UserInfo> dataList, Context mCtx) {
|
public UserSearchAdapter(List<UserInfo> dataList, Context ctx) {
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.usersSearchList = dataList;
|
this.usersSearchList = dataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class UserSearchViewHolder extends RecyclerView.ViewHolder {
|
static class UserSearchViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private ImageView userAvatar;
|
private UserInfo userInfo;
|
||||||
private TextView userFullName;
|
|
||||||
private TextView userName;
|
|
||||||
private TextView userNameMain;
|
|
||||||
private ImageView addCollaboratorButtonAdd;
|
|
||||||
private ImageView addCollaboratorButtonRemove;
|
|
||||||
|
|
||||||
private String[] permissionList = {"Read", "Write", "Admin"};
|
private final ImageView userAvatar;
|
||||||
|
private final TextView userFullName;
|
||||||
|
private final TextView userName;
|
||||||
|
private final ImageView addCollaboratorButtonAdd;
|
||||||
|
private final ImageView addCollaboratorButtonRemove;
|
||||||
|
|
||||||
|
private final String[] permissionList = {"Read", "Write", "Admin"};
|
||||||
final private int permissionSelectedChoice = 0;
|
final private int permissionSelectedChoice = 0;
|
||||||
|
|
||||||
private UserSearchViewHolder(View itemView) {
|
private UserSearchViewHolder(View itemView) {
|
||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
userAvatar = itemView.findViewById(R.id.userAvatar);
|
userAvatar = itemView.findViewById(R.id.userAvatar);
|
||||||
userFullName = itemView.findViewById(R.id.userFullName);
|
userFullName = itemView.findViewById(R.id.userFullName);
|
||||||
userName = itemView.findViewById(R.id.userName);
|
userName = itemView.findViewById(R.id.userName);
|
||||||
userNameMain = itemView.findViewById(R.id.userNameMain);
|
|
||||||
addCollaboratorButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
|
addCollaboratorButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
|
||||||
addCollaboratorButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
|
addCollaboratorButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
|
||||||
|
|
||||||
addCollaboratorButtonAdd.setOnClickListener(new View.OnClickListener() {
|
addCollaboratorButtonAdd.setOnClickListener(v -> {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
|
|
||||||
final Context context = v.getContext();
|
final Context context = v.getContext();
|
||||||
|
|
||||||
AlertDialog.Builder pBuilder = new AlertDialog.Builder(context);
|
AlertDialog.Builder pBuilder = new AlertDialog.Builder(context);
|
||||||
|
|
||||||
pBuilder.setTitle(R.string.newTeamPermission);
|
pBuilder.setTitle(R.string.newTeamPermission);
|
||||||
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, new DialogInterface.OnClickListener() {
|
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, (dialogInterface, i) -> {
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setNegativeButton(R.string.cancelButton, null)
|
.setNegativeButton(R.string.cancelButton, null)
|
||||||
.setPositiveButton(R.string.addButton, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.addButton, (dialog, which) -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
|
|
||||||
ListView lw = ((AlertDialog)dialog).getListView();
|
ListView lw = ((AlertDialog)dialog).getListView();
|
||||||
Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition());
|
Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition());
|
||||||
|
|
||||||
CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userNameMain.getText().toString());
|
CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userInfo.getUsername());
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AlertDialog pDialog = pBuilder.create();
|
AlertDialog pDialog = pBuilder.create();
|
||||||
pDialog.show();
|
pDialog.show();
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
addCollaboratorButtonRemove.setOnClickListener(new View.OnClickListener() {
|
addCollaboratorButtonRemove.setOnClickListener(v -> {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
|
|
||||||
AlertDialogs.collaboratorRemoveDialog(context, userNameMain.getText().toString(),
|
AlertDialogs.collaboratorRemoveDialog(context, userInfo.getUsername(),
|
||||||
context.getResources().getString(R.string.removeCollaboratorTitle),
|
context.getResources().getString(R.string.removeCollaboratorTitle),
|
||||||
context.getResources().getString(R.string.removeCollaboratorMessage),
|
context.getResources().getString(R.string.removeCollaboratorMessage),
|
||||||
context.getResources().getString(R.string.removeButton),
|
context.getResources().getString(R.string.removeButton),
|
||||||
context.getResources().getString(R.string.cancelButton), "fa");
|
context.getResources().getString(R.string.cancelButton), "fa");
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -128,9 +113,9 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull final UserSearchAdapter.UserSearchViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull final UserSearchAdapter.UserSearchViewHolder holder, int position) {
|
||||||
|
|
||||||
final UserInfo currentItem = usersSearchList.get(position);
|
UserInfo currentItem = usersSearchList.get(position);
|
||||||
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
holder.userNameMain.setText(currentItem.getUsername());
|
holder.userInfo = currentItem;
|
||||||
|
|
||||||
if (!currentItem.getFullname().equals("")) {
|
if (!currentItem.getFullname().equals("")) {
|
||||||
|
|
||||||
@ -138,18 +123,18 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
holder.userFullName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getUsername()));
|
||||||
|
|
||||||
if (!currentItem.getAvatar().equals("")) {
|
if (!currentItem.getAvatar().equals("")) {
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getItemCount() > 0) {
|
if(getItemCount() > 0) {
|
||||||
|
|
||||||
TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
@ -157,8 +142,8 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
|||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
|
|
||||||
Call<Collaborators> call = RetrofitClient
|
Call<Collaborators> call = RetrofitClient
|
||||||
.getApiInterface(mCtx)
|
.getApiInterface(context)
|
||||||
.checkRepoCollaborator(Authorization.get(mCtx), repoOwner, repoName, currentItem.getUsername());
|
.checkRepoCollaborator(Authorization.get(context), repoOwner, repoName, currentItem.getUsername());
|
||||||
|
|
||||||
call.enqueue(new Callback<Collaborators>() {
|
call.enqueue(new Callback<Collaborators>() {
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import org.mian.gitnex.R;
|
|||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
@ -29,25 +30,25 @@ import retrofit2.Response;
|
|||||||
|
|
||||||
public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSearchForTeamMemberAdapter.UserSearchViewHolder> {
|
public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSearchForTeamMemberAdapter.UserSearchViewHolder> {
|
||||||
|
|
||||||
private List<UserInfo> usersSearchList;
|
private final List<UserInfo> usersSearchList;
|
||||||
private Context mCtx;
|
private final Context context;
|
||||||
private int teamId;
|
private static int teamId;
|
||||||
|
|
||||||
public UserSearchForTeamMemberAdapter(List<UserInfo> dataList, Context mCtx, int teamId) {
|
public UserSearchForTeamMemberAdapter(List<UserInfo> dataList, Context ctx, int teamId) {
|
||||||
this.mCtx = mCtx;
|
this.context = ctx;
|
||||||
this.usersSearchList = dataList;
|
this.usersSearchList = dataList;
|
||||||
this.teamId = teamId;
|
UserSearchForTeamMemberAdapter.teamId = teamId;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class UserSearchViewHolder extends RecyclerView.ViewHolder {
|
static class UserSearchViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private ImageView userAvatar;
|
private UserInfo userInfo;
|
||||||
private TextView userFullName;
|
|
||||||
private TextView userName;
|
private final ImageView userAvatar;
|
||||||
private TextView userNameMain;
|
private final TextView userFullName;
|
||||||
private ImageView addMemberButtonAdd;
|
private final TextView userName;
|
||||||
private ImageView addMemberButtonRemove;
|
private final ImageView addMemberButtonAdd;
|
||||||
private TextView teamId_;
|
private final ImageView addMemberButtonRemove;
|
||||||
|
|
||||||
private UserSearchViewHolder(View itemView) {
|
private UserSearchViewHolder(View itemView) {
|
||||||
|
|
||||||
@ -55,35 +56,30 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
|||||||
userAvatar = itemView.findViewById(R.id.userAvatar);
|
userAvatar = itemView.findViewById(R.id.userAvatar);
|
||||||
userFullName = itemView.findViewById(R.id.userFullName);
|
userFullName = itemView.findViewById(R.id.userFullName);
|
||||||
userName = itemView.findViewById(R.id.userName);
|
userName = itemView.findViewById(R.id.userName);
|
||||||
userNameMain = itemView.findViewById(R.id.userNameMain);
|
|
||||||
addMemberButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
|
addMemberButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
|
||||||
addMemberButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
|
addMemberButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
|
||||||
teamId_ = itemView.findViewById(R.id.teamId);
|
|
||||||
|
|
||||||
addMemberButtonAdd.setOnClickListener(v -> {
|
addMemberButtonAdd.setOnClickListener(v -> {
|
||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
|
|
||||||
AlertDialogs.addMemberDialog(context, userNameMain.getText().toString(),
|
AlertDialogs.addMemberDialog(context, userInfo.getLogin(),
|
||||||
context.getResources().getString(R.string.addTeamMemberTitle),
|
context.getResources().getString(R.string.addTeamMemberTitle),
|
||||||
context.getResources().getString(R.string.addTeamMemberMessage),
|
context.getResources().getString(R.string.addTeamMemberMessage),
|
||||||
context.getResources().getString(R.string.addButton),
|
context.getResources().getString(R.string.addButton),
|
||||||
context.getResources().getString(R.string.cancelButton), Integer.parseInt(teamId_.getText().toString()));
|
context.getResources().getString(R.string.cancelButton), Integer.parseInt(String.valueOf(teamId)));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
addMemberButtonRemove.setOnClickListener(v -> {
|
addMemberButtonRemove.setOnClickListener(v -> {
|
||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
|
|
||||||
AlertDialogs.removeMemberDialog(context, userNameMain.getText().toString(),
|
AlertDialogs.removeMemberDialog(context, userInfo.getLogin(),
|
||||||
context.getResources().getString(R.string.removeTeamMemberTitle),
|
context.getResources().getString(R.string.removeTeamMemberTitle),
|
||||||
context.getResources().getString(R.string.removeTeamMemberMessage),
|
context.getResources().getString(R.string.removeTeamMemberMessage),
|
||||||
context.getResources().getString(R.string.removeButton),
|
context.getResources().getString(R.string.removeButton),
|
||||||
context.getResources().getString(R.string.cancelButton), Integer.parseInt(teamId_.getText().toString()));
|
context.getResources().getString(R.string.cancelButton), Integer.parseInt(String.valueOf(teamId)));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -98,39 +94,36 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull final UserSearchForTeamMemberAdapter.UserSearchViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull final UserSearchForTeamMemberAdapter.UserSearchViewHolder holder, int position) {
|
||||||
|
|
||||||
final UserInfo currentItem = usersSearchList.get(position);
|
UserInfo currentItem = usersSearchList.get(position);
|
||||||
|
holder.userInfo = currentItem;
|
||||||
holder.userNameMain.setText(currentItem.getLogin());
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||||
holder.teamId_.setText(String.valueOf(teamId));
|
|
||||||
|
|
||||||
if (!currentItem.getFullname().equals("")) {
|
if (!currentItem.getFullname().equals("")) {
|
||||||
|
|
||||||
|
|
||||||
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
|
holder.userFullName.setText(Html.fromHtml(currentItem.getFullname()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
holder.userFullName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
holder.userFullName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.userName.setText(mCtx.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||||
|
|
||||||
if (!currentItem.getAvatar().equals("")) {
|
if (!currentItem.getAvatar().equals("")) {
|
||||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getItemCount() > 0) {
|
if(getItemCount() > 0) {
|
||||||
|
|
||||||
TinyDB tinyDb = TinyDB.getInstance(mCtx);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
String repoFullName = tinyDb.getString("repoFullName");
|
String repoFullName = tinyDb.getString("repoFullName");
|
||||||
String[] parts = repoFullName.split("/");
|
String[] parts = repoFullName.split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
||||||
|
|
||||||
Call<UserInfo> call = RetrofitClient
|
Call<UserInfo> call = RetrofitClient
|
||||||
.getApiInterface(mCtx)
|
.getApiInterface(context)
|
||||||
.checkTeamMember(Authorization.get(mCtx), teamId, currentItem.getLogin());
|
.checkTeamMember(Authorization.get(context), teamId, currentItem.getLogin());
|
||||||
|
|
||||||
call.enqueue(new Callback<UserInfo>() {
|
call.enqueue(new Callback<UserInfo>() {
|
||||||
|
|
||||||
@ -167,8 +160,7 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
|||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<UserInfo> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
Toasty.error(mCtx, mCtx.getResources().getString(R.string.genericServerResponseError));
|
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,7 @@ package org.mian.gitnex.core;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
import org.acra.ACRA;
|
import org.acra.ACRA;
|
||||||
import org.acra.BuildConfig;
|
import org.acra.BuildConfig;
|
||||||
import org.acra.ReportField;
|
import org.acra.ReportField;
|
||||||
@ -34,7 +35,6 @@ import org.mian.gitnex.notifications.Notifications;
|
|||||||
|
|
||||||
public class MainApplication extends Application {
|
public class MainApplication extends Application {
|
||||||
|
|
||||||
private Context appCtx;
|
|
||||||
private TinyDB tinyDB;
|
private TinyDB tinyDB;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -42,7 +42,7 @@ public class MainApplication extends Application {
|
|||||||
|
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
appCtx = getApplicationContext();
|
Context appCtx = getApplicationContext();
|
||||||
tinyDB = TinyDB.getInstance(appCtx);
|
tinyDB = TinyDB.getInstance(appCtx);
|
||||||
|
|
||||||
setDefaults();
|
setDefaults();
|
||||||
@ -76,6 +76,7 @@ public class MainApplication extends Application {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void attachBaseContext(Context context) {
|
protected void attachBaseContext(Context context) {
|
||||||
|
|
||||||
super.attachBaseContext(context);
|
super.attachBaseContext(context);
|
||||||
|
|
||||||
tinyDB = TinyDB.getInstance(context);
|
tinyDB = TinyDB.getInstance(context);
|
||||||
@ -97,46 +98,59 @@ public class MainApplication extends Application {
|
|||||||
|
|
||||||
// enabling counter badges by default
|
// enabling counter badges by default
|
||||||
if(tinyDB.getString("enableCounterBadgesInit").isEmpty()) {
|
if(tinyDB.getString("enableCounterBadgesInit").isEmpty()) {
|
||||||
|
|
||||||
tinyDB.putBoolean("enableCounterBadges", true);
|
tinyDB.putBoolean("enableCounterBadges", true);
|
||||||
tinyDB.putString("enableCounterBadgesInit", "yes");
|
tinyDB.putString("enableCounterBadgesInit", "yes");
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable crash reports by default
|
// enable crash reports by default
|
||||||
if(tinyDB.getString("crashReportingEnabledInit").isEmpty()) {
|
if(tinyDB.getString("crashReportingEnabledInit").isEmpty()) {
|
||||||
|
|
||||||
tinyDB.putBoolean("crashReportingEnabled", true);
|
tinyDB.putBoolean("crashReportingEnabled", true);
|
||||||
tinyDB.putString("crashReportingEnabledInit", "yes");
|
tinyDB.putString("crashReportingEnabledInit", "yes");
|
||||||
}
|
}
|
||||||
|
|
||||||
// default cache setter
|
// default cache setter
|
||||||
if(tinyDB.getString("cacheSizeStr").isEmpty()) {
|
if(tinyDB.getString("cacheSizeStr").isEmpty()) {
|
||||||
|
|
||||||
tinyDB.putString("cacheSizeStr", getResources().getString(R.string.cacheSizeDataSelectionSelectedText));
|
tinyDB.putString("cacheSizeStr", getResources().getString(R.string.cacheSizeDataSelectionSelectedText));
|
||||||
}
|
}
|
||||||
if(tinyDB.getString("cacheSizeImagesStr").isEmpty()) {
|
if(tinyDB.getString("cacheSizeImagesStr").isEmpty()) {
|
||||||
|
|
||||||
tinyDB.putString("cacheSizeImagesStr", getResources().getString(R.string.cacheSizeImagesSelectionSelectedText));
|
tinyDB.putString("cacheSizeImagesStr", getResources().getString(R.string.cacheSizeImagesSelectionSelectedText));
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable comment drafts by default
|
// enable comment drafts by default
|
||||||
if(tinyDB.getString("draftsCommentsDeletionEnabledInit").isEmpty()) {
|
if(tinyDB.getString("draftsCommentsDeletionEnabledInit").isEmpty()) {
|
||||||
|
|
||||||
tinyDB.putBoolean("draftsCommentsDeletionEnabled", true);
|
tinyDB.putBoolean("draftsCommentsDeletionEnabled", true);
|
||||||
tinyDB.putString("draftsCommentsDeletionEnabledInit", "yes");
|
tinyDB.putString("draftsCommentsDeletionEnabledInit", "yes");
|
||||||
}
|
}
|
||||||
|
|
||||||
// setting default polling delay
|
// setting default polling delay
|
||||||
if(tinyDB.getInt("pollingDelayMinutes", 0) <= 0) {
|
if(tinyDB.getInt("pollingDelayMinutes", 0) <= 0) {
|
||||||
|
|
||||||
tinyDB.putInt("pollingDelayMinutes", Constants.defaultPollingDelay);
|
tinyDB.putInt("pollingDelayMinutes", Constants.defaultPollingDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable biometric by default
|
// disable biometric by default
|
||||||
if(tinyDB.getString("biometricStatusInit").isEmpty()) {
|
if(tinyDB.getString("biometricStatusInit").isEmpty()) {
|
||||||
|
|
||||||
tinyDB.putBoolean("biometricStatus", false);
|
tinyDB.putBoolean("biometricStatus", false);
|
||||||
tinyDB.putString("biometricStatusInit", "yes");
|
tinyDB.putString("biometricStatusInit", "yes");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set default date format
|
||||||
|
if(tinyDB.getString("dateFormat").isEmpty()) {
|
||||||
|
tinyDB.putString("dateFormat", "pretty");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tinyDB.getString("codeBlockStr").isEmpty()) {
|
||||||
|
tinyDB.putInt("codeBlockColor", ResourcesCompat.getColor(getResources(), R.color.colorLightGreen, null));
|
||||||
|
tinyDB.putInt("codeBlockBackground", ResourcesCompat.getColor(getResources(), R.color.black, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tinyDB.getString("enableCounterIssueBadgeInit").isEmpty()) {
|
||||||
|
tinyDB.putBoolean("enableCounterIssueBadge", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tinyDB.getString("homeScreenStr").isEmpty()) {
|
||||||
|
tinyDB.putString("homeScreenStr", "yes");
|
||||||
|
tinyDB.putInt("homeScreenId", 0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
57
app/src/main/java/org/mian/gitnex/database/api/BaseApi.java
Normal file
57
app/src/main/java/org/mian/gitnex/database/api/BaseApi.java
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package org.mian.gitnex.database.api;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import org.mian.gitnex.database.db.GitnexDatabase;
|
||||||
|
import org.mian.gitnex.helpers.Constants;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author opyale
|
||||||
|
*/
|
||||||
|
|
||||||
|
public abstract class BaseApi {
|
||||||
|
|
||||||
|
private static final Map<Class<? extends BaseApi>, Object> instances = new HashMap<>();
|
||||||
|
|
||||||
|
protected static final ExecutorService executorService = Executors.newCachedThreadPool();
|
||||||
|
protected final GitnexDatabase gitnexDatabase;
|
||||||
|
|
||||||
|
protected BaseApi(Context context) {
|
||||||
|
gitnexDatabase = GitnexDatabase.getDatabaseInstance(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends BaseApi> T getInstance(@NonNull Context context, @NonNull Class<T> clazz) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if(!instances.containsKey(clazz)) {
|
||||||
|
synchronized(BaseApi.class) {
|
||||||
|
if(!instances.containsKey(clazz)) {
|
||||||
|
|
||||||
|
T instance = clazz
|
||||||
|
.getDeclaredConstructor(Context.class)
|
||||||
|
.newInstance(context);
|
||||||
|
|
||||||
|
instances.put(clazz, instance);
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (T) instances.get(clazz);
|
||||||
|
|
||||||
|
} catch(NoSuchMethodException | IllegalAccessException |
|
||||||
|
InvocationTargetException | InstantiationException ignored) {}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,30 +1,23 @@
|
|||||||
package org.mian.gitnex.database.api;
|
package org.mian.gitnex.database.api;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import org.mian.gitnex.database.dao.DraftsDao;
|
import org.mian.gitnex.database.dao.DraftsDao;
|
||||||
import org.mian.gitnex.database.db.GitnexDatabase;
|
|
||||||
import org.mian.gitnex.database.models.Draft;
|
import org.mian.gitnex.database.models.Draft;
|
||||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||||
import org.mian.gitnex.helpers.Constants;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class DraftsApi {
|
public class DraftsApi extends BaseApi {
|
||||||
|
|
||||||
private static DraftsDao draftsDao;
|
private final DraftsDao draftsDao;
|
||||||
private static long draftId;
|
|
||||||
private static Integer checkDraftFlag;
|
|
||||||
|
|
||||||
public DraftsApi(Context context) {
|
DraftsApi(Context context) {
|
||||||
|
super(context);
|
||||||
GitnexDatabase db;
|
draftsDao = gitnexDatabase.draftsDao();
|
||||||
db = GitnexDatabase.getDatabaseInstance(context);
|
|
||||||
draftsDao = db.draftsDao();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long insertDraft(int repositoryId, int draftAccountId, int issueId, String draftText, String draftType, String commentId, String issueType) {
|
public long insertDraft(int repositoryId, int draftAccountId, int issueId, String draftText, String draftType, String commentId, String issueType) {
|
||||||
@ -41,87 +34,44 @@ public class DraftsApi {
|
|||||||
return insertDraftAsyncTask(draft);
|
return insertDraftAsyncTask(draft);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long insertDraftAsyncTask(final Draft draft) {
|
private long insertDraftAsyncTask(final Draft draft) {
|
||||||
|
return draftsDao.insertDraft(draft);
|
||||||
try {
|
|
||||||
|
|
||||||
Thread thread = new Thread(() -> draftId = draftsDao.insertDraft(draft));
|
|
||||||
thread.start();
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
catch(InterruptedException e) {
|
|
||||||
|
|
||||||
Log.e(Constants.draftsApi, e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return draftId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getDraftIdAsync(int issueId, int draftRepositoryId) {
|
public long getDraftIdAsync(int issueId, int draftRepositoryId) {
|
||||||
|
return draftsDao.getDraftId(issueId, draftRepositoryId);
|
||||||
try {
|
|
||||||
|
|
||||||
Thread thread = new Thread(() -> draftId = draftsDao.getDraftId(issueId, draftRepositoryId));
|
|
||||||
thread.start();
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
catch(InterruptedException e) {
|
|
||||||
|
|
||||||
Log.e(Constants.draftsApi, e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return draftId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer checkDraft(int issueId, int draftRepositoryId, String commentId) {
|
public Integer checkDraft(int issueId, int draftRepositoryId, String commentId) {
|
||||||
|
return draftsDao.checkDraftDao(issueId, draftRepositoryId, commentId);
|
||||||
try {
|
|
||||||
|
|
||||||
Thread thread = new Thread(() -> checkDraftFlag = draftsDao.checkDraftDao(issueId, draftRepositoryId, commentId));
|
|
||||||
thread.start();
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
catch(InterruptedException e) {
|
|
||||||
|
|
||||||
Log.e(Constants.draftsApi, e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return checkDraftFlag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<DraftWithRepository>> getDrafts(int accountId) {
|
public LiveData<List<DraftWithRepository>> getDrafts(int accountId) {
|
||||||
|
|
||||||
return draftsDao.fetchAllDrafts(accountId);
|
return draftsDao.fetchAllDrafts(accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<Draft> getDraftByIssueId(int issueId) {
|
public LiveData<Draft> getDraftByIssueId(int issueId) {
|
||||||
|
|
||||||
return draftsDao.fetchDraftByIssueId(issueId);
|
return draftsDao.fetchDraftByIssueId(issueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteSingleDraft(final int draftId) {
|
public void deleteSingleDraft(final int draftId) {
|
||||||
|
|
||||||
final LiveData<Draft> draft = draftsDao.fetchDraftById(draftId);
|
final LiveData<Draft> draft = draftsDao.fetchDraftById(draftId);
|
||||||
|
|
||||||
if(draft != null) {
|
if(draft != null) {
|
||||||
|
executorService.execute(() -> draftsDao.deleteByDraftId(draftId));
|
||||||
new Thread(() -> draftsDao.deleteByDraftId(draftId)).start();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteAllDrafts(final int accountId) {
|
public void deleteAllDrafts(final int accountId) {
|
||||||
|
executorService.execute(() -> draftsDao.deleteAllDrafts(accountId));
|
||||||
new Thread(() -> draftsDao.deleteAllDrafts(accountId)).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateDraft(final String draftText, final int draftId, final String commentId) {
|
public void updateDraft(final String draftText, final int draftId, final String commentId) {
|
||||||
|
executorService.execute(() -> draftsDao.updateDraft(draftText, draftId, commentId));
|
||||||
new Thread(() -> draftsDao.updateDraft(draftText, draftId, commentId)).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateDraftByIssueIdAsyncTask(final String draftText, final int issueId, final int draftRepositoryId, final String commentId) {
|
public void updateDraftByIssueIdAsyncTask(final String draftText, final int issueId, final int draftRepositoryId, final String commentId) {
|
||||||
|
executorService.execute(() -> draftsDao.updateDraftByIssueId(draftText, issueId, draftRepositoryId, commentId));
|
||||||
new Thread(() -> draftsDao.updateDraftByIssueId(draftText, issueId, draftRepositoryId, commentId)).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,22 @@
|
|||||||
package org.mian.gitnex.database.api;
|
package org.mian.gitnex.database.api;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import org.mian.gitnex.database.dao.RepositoriesDao;
|
import org.mian.gitnex.database.dao.RepositoriesDao;
|
||||||
import org.mian.gitnex.database.db.GitnexDatabase;
|
|
||||||
import org.mian.gitnex.database.models.Repository;
|
import org.mian.gitnex.database.models.Repository;
|
||||||
import org.mian.gitnex.helpers.Constants;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class RepositoriesApi {
|
public class RepositoriesApi extends BaseApi {
|
||||||
|
|
||||||
private static RepositoriesDao repositoriesDao;
|
private final RepositoriesDao repositoriesDao;
|
||||||
private static long repositoryId;
|
|
||||||
private static Repository repository;
|
|
||||||
private static Integer checkRepository;
|
|
||||||
|
|
||||||
public RepositoriesApi(Context context) {
|
RepositoriesApi(Context context) {
|
||||||
|
super(context);
|
||||||
GitnexDatabase db;
|
repositoriesDao = gitnexDatabase.repositoriesDao();
|
||||||
db = GitnexDatabase.getDatabaseInstance(context);
|
|
||||||
repositoriesDao = db.repositoriesDao();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long insertRepository(int repoAccountId, String repositoryOwner, String repositoryName) {
|
public long insertRepository(int repoAccountId, String repositoryOwner, String repositoryName) {
|
||||||
@ -38,108 +30,43 @@ public class RepositoriesApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long insertRepositoryAsyncTask(Repository repository) {
|
public long insertRepositoryAsyncTask(Repository repository) {
|
||||||
|
return repositoriesDao.newRepository(repository);
|
||||||
try {
|
|
||||||
|
|
||||||
Thread thread = new Thread(() -> repositoryId = repositoriesDao.newRepository(repository));
|
|
||||||
thread.start();
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
catch(InterruptedException e) {
|
|
||||||
|
|
||||||
Log.e(Constants.repositoriesApi, e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return repositoryId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Repository getRepository(int repoAccountId, String repositoryOwner, String repositoryName) {
|
public Repository getRepository(int repoAccountId, String repositoryOwner, String repositoryName) {
|
||||||
|
return repositoriesDao.getSingleRepositoryDao(repoAccountId, repositoryOwner, repositoryName);
|
||||||
try {
|
|
||||||
|
|
||||||
Thread thread = new Thread(() -> repository = repositoriesDao.getSingleRepositoryDao(repoAccountId, repositoryOwner, repositoryName));
|
|
||||||
thread.start();
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
catch(InterruptedException e) {
|
|
||||||
|
|
||||||
Log.e(Constants.repositoriesApi, e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return repository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Repository>> getAllRepositories() {
|
public LiveData<List<Repository>> getAllRepositories() {
|
||||||
|
|
||||||
return repositoriesDao.fetchAllRepositories();
|
return repositoriesDao.fetchAllRepositories();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Repository>> getAllRepositoriesByAccount(int repoAccountId) {
|
public LiveData<List<Repository>> getAllRepositoriesByAccount(int repoAccountId) {
|
||||||
|
|
||||||
return repositoriesDao.getAllRepositoriesByAccountDao(repoAccountId);
|
return repositoriesDao.getAllRepositoriesByAccountDao(repoAccountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer checkRepository(int repoAccountId, String repositoryOwner, String repositoryName) {
|
public Integer checkRepository(int repoAccountId, String repositoryOwner, String repositoryName) {
|
||||||
|
return repositoriesDao.checkRepositoryDao(repoAccountId, repositoryOwner, repositoryName);
|
||||||
try {
|
|
||||||
|
|
||||||
Thread thread = new Thread(() -> checkRepository = repositoriesDao.checkRepositoryDao(repoAccountId, repositoryOwner, repositoryName));
|
|
||||||
thread.start();
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
catch(InterruptedException e) {
|
|
||||||
|
|
||||||
Log.e(Constants.repositoriesApi, e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return checkRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Repository fetchRepositoryById(int repositoryId) {
|
public Repository fetchRepositoryById(int repositoryId) {
|
||||||
|
return repositoriesDao.fetchRepositoryByIdDao(repositoryId);
|
||||||
try {
|
|
||||||
|
|
||||||
Thread thread = new Thread(() -> repository = repositoriesDao.fetchRepositoryByIdDao(repositoryId));
|
|
||||||
thread.start();
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
catch(InterruptedException e) {
|
|
||||||
|
|
||||||
Log.e(Constants.repositoriesApi, e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return repository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Repository fetchRepositoryByAccountIdByRepositoryId(int repositoryId, int repoAccountId) {
|
public Repository fetchRepositoryByAccountIdByRepositoryId(int repositoryId, int repoAccountId) {
|
||||||
|
return repositoriesDao.fetchRepositoryByAccountIdByRepositoryIdDao(repositoryId, repoAccountId);
|
||||||
try {
|
|
||||||
|
|
||||||
Thread thread = new Thread(() -> repository = repositoriesDao.fetchRepositoryByAccountIdByRepositoryIdDao(repositoryId, repoAccountId));
|
|
||||||
thread.start();
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
catch(InterruptedException e) {
|
|
||||||
|
|
||||||
Log.e(Constants.repositoriesApi, e.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return repository;
|
public void updateRepositoryOwnerAndName(String repositoryOwner, String repositoryName, int repositoryId) {
|
||||||
|
executorService.execute(() -> repositoriesDao.updateRepositoryOwnerAndName(repositoryOwner, repositoryName, repositoryId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateRepositoryOwnerAndName(String repositoryOwner, String repositoryName, int repositoryId) {
|
public void deleteRepositoriesByAccount(final int repoAccountId) {
|
||||||
|
executorService.execute(() -> repositoriesDao.deleteRepositoriesByAccount(repoAccountId));
|
||||||
new Thread(() -> repositoriesDao.updateRepositoryOwnerAndName(repositoryOwner, repositoryName, repositoryId)).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteRepositoriesByAccount(final int repoAccountId) {
|
public void deleteRepository(final int repositoryId) {
|
||||||
|
executorService.execute(() -> repositoriesDao.deleteRepository(repositoryId));
|
||||||
new Thread(() -> repositoriesDao.deleteRepositoriesByAccount(repoAccountId)).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void deleteRepository(final int repositoryId) {
|
|
||||||
|
|
||||||
new Thread(() -> repositoriesDao.deleteRepository(repositoryId)).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,25 @@
|
|||||||
package org.mian.gitnex.database.api;
|
package org.mian.gitnex.database.api;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import org.mian.gitnex.database.dao.UserAccountsDao;
|
import org.mian.gitnex.database.dao.UserAccountsDao;
|
||||||
import org.mian.gitnex.database.db.GitnexDatabase;
|
|
||||||
import org.mian.gitnex.database.models.UserAccount;
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
import org.mian.gitnex.helpers.Constants;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class UserAccountsApi {
|
public class UserAccountsApi extends BaseApi {
|
||||||
|
|
||||||
private static UserAccountsDao userAccountsDao;
|
private final UserAccountsDao userAccountsDao;
|
||||||
private static UserAccount userAccount;
|
|
||||||
private static List<UserAccount> userAccounts;
|
|
||||||
private static Integer checkAccount;
|
|
||||||
private static long accountId;
|
|
||||||
|
|
||||||
public UserAccountsApi(Context context) {
|
UserAccountsApi(Context context) {
|
||||||
|
super(context);
|
||||||
GitnexDatabase db;
|
userAccountsDao = gitnexDatabase.userAccountsDao();
|
||||||
db = GitnexDatabase.getDatabaseInstance(context);
|
|
||||||
userAccountsDao = db.userAccountsDao();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long insertNewAccount(String accountName, String instanceUrl, String userName, String token, String serverVersion) {
|
public long createNewAccount(String accountName, String instanceUrl, String userName, String token, String serverVersion) {
|
||||||
|
|
||||||
UserAccount userAccount = new UserAccount();
|
UserAccount userAccount = new UserAccount();
|
||||||
userAccount.setAccountName(accountName);
|
userAccount.setAccountName(accountName);
|
||||||
@ -37,96 +28,48 @@ public class UserAccountsApi {
|
|||||||
userAccount.setToken(token);
|
userAccount.setToken(token);
|
||||||
userAccount.setServerVersion(serverVersion);
|
userAccount.setServerVersion(serverVersion);
|
||||||
|
|
||||||
return insertNewAccountAsync(userAccount);
|
return userAccountsDao.createAccount(userAccount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long insertNewAccountAsync(final UserAccount userAccount) {
|
public void updateServerVersion(final String serverVersion, final int accountId) {
|
||||||
|
executorService.execute(() -> userAccountsDao.updateServerVersion(serverVersion, accountId));
|
||||||
try {
|
|
||||||
|
|
||||||
Thread thread = new Thread(() -> accountId = userAccountsDao.newAccount(userAccount));
|
|
||||||
thread.start();
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
catch(InterruptedException e) {
|
|
||||||
|
|
||||||
Log.e(Constants.userAccountsApi, e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return accountId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateServerVersion(final String serverVersion, final int accountId) {
|
|
||||||
|
|
||||||
new Thread(() -> userAccountsDao.updateServerVersion(serverVersion, accountId)).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateToken(final int accountId, final String token) {
|
public void updateToken(final int accountId, final String token) {
|
||||||
|
executorService.execute(() -> userAccountsDao.updateAccountToken(accountId, token));
|
||||||
new Thread(() -> userAccountsDao.updateAccountToken(accountId, token)).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTokenByAccountName(final String accountName, final String token) {
|
public void updateTokenByAccountName(final String accountName, final String token) {
|
||||||
|
executorService.execute(() -> userAccountsDao.updateAccountTokenByAccountName(accountName, token));
|
||||||
new Thread(() -> userAccountsDao.updateAccountTokenByAccountName(accountName, token)).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserAccount getAccountData(String accountName) {
|
public UserAccount getAccountByName(String accountName) {
|
||||||
|
return userAccountsDao.getAccountByName(accountName);
|
||||||
try {
|
|
||||||
|
|
||||||
Thread thread = new Thread(() -> userAccount = userAccountsDao.fetchRowByAccount_(accountName));
|
|
||||||
thread.start();
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
catch(InterruptedException e) {
|
|
||||||
|
|
||||||
Log.e(Constants.userAccountsApi, e.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return userAccount;
|
public UserAccount getAccountById(int accountId) {
|
||||||
|
return userAccountsDao.getAccountById(accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getCount(String accountName) {
|
public Integer getCount() {
|
||||||
|
return userAccountsDao.getCount();
|
||||||
try {
|
|
||||||
|
|
||||||
Thread thread = new Thread(() -> checkAccount = userAccountsDao.getCount(accountName));
|
|
||||||
thread.start();
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
catch(InterruptedException e) {
|
|
||||||
|
|
||||||
Log.e(Constants.userAccountsApi, e.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return checkAccount;
|
public Boolean userAccountExists(String accountName) {
|
||||||
|
return userAccountsDao.userAccountExists(accountName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<UserAccount>> getAllAccounts() {
|
public LiveData<List<UserAccount>> getAllAccounts() {
|
||||||
|
return userAccountsDao.getAllAccounts();
|
||||||
return userAccountsDao.fetchAllAccounts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserAccount> usersAccounts() {
|
public List<UserAccount> usersAccounts() {
|
||||||
|
return userAccountsDao.userAccounts();
|
||||||
try {
|
|
||||||
|
|
||||||
Thread thread = new Thread(() -> userAccounts = userAccountsDao.userAccounts());
|
|
||||||
thread.start();
|
|
||||||
thread.join();
|
|
||||||
}
|
|
||||||
catch(InterruptedException e) {
|
|
||||||
|
|
||||||
Log.e(Constants.userAccountsApi, e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return userAccounts;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAccount(final int accountId) {
|
public void deleteAccount(final int accountId) {
|
||||||
|
executorService.execute(() -> userAccountsDao.deleteAccount(accountId));
|
||||||
new Thread(() -> userAccountsDao.deleteAccount(accountId)).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,22 +15,25 @@ import java.util.List;
|
|||||||
public interface UserAccountsDao {
|
public interface UserAccountsDao {
|
||||||
|
|
||||||
@Insert
|
@Insert
|
||||||
long newAccount(UserAccount userAccounts);
|
long createAccount(UserAccount userAccounts);
|
||||||
|
|
||||||
@Query("SELECT * FROM UserAccounts ORDER BY accountId ASC")
|
@Query("SELECT * FROM UserAccounts ORDER BY accountId ASC")
|
||||||
LiveData<List<UserAccount>> fetchAllAccounts();
|
LiveData<List<UserAccount>> getAllAccounts();
|
||||||
|
|
||||||
@Query("SELECT * FROM UserAccounts ORDER BY accountId ASC")
|
@Query("SELECT * FROM UserAccounts ORDER BY accountId ASC")
|
||||||
List<UserAccount> userAccounts();
|
List<UserAccount> userAccounts();
|
||||||
|
|
||||||
@Query("SELECT COUNT(accountId) FROM UserAccounts WHERE accountName = :accountName")
|
@Query("SELECT COUNT(accountId) FROM UserAccounts")
|
||||||
Integer getCount(String accountName);
|
Integer getCount();
|
||||||
|
|
||||||
@Query("SELECT * FROM UserAccounts WHERE accountName = :accountName")
|
@Query("SELECT COUNT(accountId) FROM UserAccounts WHERE accountName = :accountName LIMIT 1")
|
||||||
UserAccount fetchRowByAccount_(String accountName);
|
Boolean userAccountExists(String accountName);
|
||||||
|
|
||||||
@Query("SELECT * FROM UserAccounts WHERE accountId = :accountId")
|
@Query("SELECT * FROM UserAccounts WHERE accountName = :accountName LIMIT 1")
|
||||||
UserAccount fetchRowByAccountId(int accountId);
|
UserAccount getAccountByName(String accountName);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM UserAccounts WHERE accountId = :accountId LIMIT 1")
|
||||||
|
UserAccount getAccountById(int accountId);
|
||||||
|
|
||||||
@Query("UPDATE UserAccounts SET serverVersion = :serverVersion WHERE accountId = :accountId")
|
@Query("UPDATE UserAccounts SET serverVersion = :serverVersion WHERE accountId = :accountId")
|
||||||
void updateServerVersion(String serverVersion, int accountId);
|
void updateServerVersion(String serverVersion, int accountId);
|
||||||
|
@ -22,32 +22,16 @@ import org.mian.gitnex.database.models.UserAccount;
|
|||||||
version = 3, exportSchema = false)
|
version = 3, exportSchema = false)
|
||||||
public abstract class GitnexDatabase extends RoomDatabase {
|
public abstract class GitnexDatabase extends RoomDatabase {
|
||||||
|
|
||||||
|
private static final String DB_NAME = "gitnex";
|
||||||
private static GitnexDatabase gitnexDatabase;
|
private static GitnexDatabase gitnexDatabase;
|
||||||
|
|
||||||
public static GitnexDatabase getDatabaseInstance(Context context) {
|
|
||||||
|
|
||||||
if (gitnexDatabase == null) {
|
|
||||||
|
|
||||||
String DB_NAME = "gitnex";
|
|
||||||
gitnexDatabase = Room.databaseBuilder(context, GitnexDatabase.class, DB_NAME)
|
|
||||||
//.fallbackToDestructiveMigration()
|
|
||||||
.addMigrations(MIGRATION_1_2, MIGRATION_2_3)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
return gitnexDatabase;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract DraftsDao draftsDao();
|
public abstract DraftsDao draftsDao();
|
||||||
|
|
||||||
public abstract RepositoriesDao repositoriesDao();
|
public abstract RepositoriesDao repositoriesDao();
|
||||||
|
|
||||||
public abstract UserAccountsDao userAccountsDao();
|
public abstract UserAccountsDao userAccountsDao();
|
||||||
|
|
||||||
private static final Migration MIGRATION_1_2 = new Migration(1, 2) {
|
private static final Migration MIGRATION_1_2 = new Migration(1, 2) {
|
||||||
@Override
|
@Override
|
||||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
|
||||||
//database.execSQL("DROP TABLE Drafts");
|
//database.execSQL("DROP TABLE Drafts");
|
||||||
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'commentId' TEXT");
|
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'commentId' TEXT");
|
||||||
}
|
}
|
||||||
@ -56,8 +40,27 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||||||
private static final Migration MIGRATION_2_3 = new Migration(2, 3) {
|
private static final Migration MIGRATION_2_3 = new Migration(2, 3) {
|
||||||
@Override
|
@Override
|
||||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
|
||||||
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'issueType' TEXT");
|
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'issueType' TEXT");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static GitnexDatabase getDatabaseInstance(Context context) {
|
||||||
|
|
||||||
|
if (gitnexDatabase == null) {
|
||||||
|
synchronized(GitnexDatabase.class) {
|
||||||
|
if(gitnexDatabase == null) {
|
||||||
|
|
||||||
|
gitnexDatabase = Room.databaseBuilder(context, GitnexDatabase.class, DB_NAME)
|
||||||
|
// .fallbackToDestructiveMigration()
|
||||||
|
.allowMainThreadQueries()
|
||||||
|
.addMigrations(MIGRATION_1_2, MIGRATION_2_3)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return gitnexDatabase;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,12 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||||
|
import com.vdurmont.emoji.EmojiParser;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.actions.ActionResult;
|
import org.mian.gitnex.actions.ActionResult;
|
||||||
import org.mian.gitnex.actions.IssueActions;
|
import org.mian.gitnex.actions.IssueActions;
|
||||||
import org.mian.gitnex.activities.MainActivity;
|
import org.mian.gitnex.activities.MainActivity;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.DraftsApi;
|
import org.mian.gitnex.database.api.DraftsApi;
|
||||||
import org.mian.gitnex.databinding.BottomSheetReplyLayoutBinding;
|
import org.mian.gitnex.databinding.BottomSheetReplyLayoutBinding;
|
||||||
import org.mian.gitnex.helpers.Constants;
|
import org.mian.gitnex.helpers.Constants;
|
||||||
@ -56,12 +58,11 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
|||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
|
|
||||||
tinyDB = TinyDB.getInstance(context);
|
tinyDB = TinyDB.getInstance(context);
|
||||||
draftsApi = new DraftsApi(context);
|
draftsApi = BaseApi.getInstance(context, DraftsApi.class);
|
||||||
|
|
||||||
repositoryId = (int) tinyDB.getLong("repositoryId", 0);
|
repositoryId = (int) tinyDB.getLong("repositoryId", 0);
|
||||||
currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||||
issueNumber = Integer.parseInt(tinyDB.getString("issueNumber"));
|
issueNumber = Integer.parseInt(tinyDB.getString("issueNumber"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@ -87,7 +88,6 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
|||||||
|
|
||||||
send.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_save));
|
send.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_save));
|
||||||
mode = Mode.EDIT;
|
mode = Mode.EDIT;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(arguments.getString("draftId") != null) {
|
if(arguments.getString("draftId") != null) {
|
||||||
@ -97,7 +97,7 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
|||||||
|
|
||||||
if(!tinyDB.getString("issueTitle").isEmpty()) {
|
if(!tinyDB.getString("issueTitle").isEmpty()) {
|
||||||
|
|
||||||
toolbarTitle.setText(tinyDB.getString("issueTitle"));
|
toolbarTitle.setText(EmojiParser.parseToUnicode(tinyDB.getString("issueTitle")));
|
||||||
}
|
}
|
||||||
else if(arguments.getString("draftTitle") != null) {
|
else if(arguments.getString("draftTitle") != null) {
|
||||||
|
|
||||||
@ -134,7 +134,6 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
comment.addTextChangedListener(new TextWatcher() {
|
comment.addTextChangedListener(new TextWatcher() {
|
||||||
@ -283,7 +282,7 @@ public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
DraftsApi.updateDraft(text, (int) draftId, "TODO");
|
draftsApi.updateDraft(text, (int) draftId, "TODO");
|
||||||
}
|
}
|
||||||
|
|
||||||
draftsHint.setVisibility(View.VISIBLE);
|
draftsHint.setVisibility(View.VISIBLE);
|
||||||
|
@ -22,6 +22,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.MainActivity;
|
import org.mian.gitnex.activities.MainActivity;
|
||||||
import org.mian.gitnex.adapters.DraftsAdapter;
|
import org.mian.gitnex.adapters.DraftsAdapter;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.DraftsApi;
|
import org.mian.gitnex.database.api.DraftsApi;
|
||||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||||
import org.mian.gitnex.databinding.FragmentDraftsBinding;
|
import org.mian.gitnex.databinding.FragmentDraftsBinding;
|
||||||
@ -59,7 +60,7 @@ public class DraftsFragment extends Fragment {
|
|||||||
TinyDB tinyDb = TinyDB.getInstance(ctx);
|
TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||||
|
|
||||||
draftsList_ = new ArrayList<>();
|
draftsList_ = new ArrayList<>();
|
||||||
draftsApi = new DraftsApi(ctx);
|
draftsApi = BaseApi.getInstance(ctx, DraftsApi.class);
|
||||||
|
|
||||||
noData = fragmentDraftsBinding.noData;
|
noData = fragmentDraftsBinding.noData;
|
||||||
mRecyclerView = fragmentDraftsBinding.recyclerView;
|
mRecyclerView = fragmentDraftsBinding.recyclerView;
|
||||||
@ -123,7 +124,7 @@ public class DraftsFragment extends Fragment {
|
|||||||
|
|
||||||
if(draftsList_.size() > 0) {
|
if(draftsList_.size() > 0) {
|
||||||
|
|
||||||
DraftsApi.deleteAllDrafts(accountId);
|
BaseApi.getInstance(ctx, DraftsApi.class).deleteAllDrafts(accountId);
|
||||||
draftsList_.clear();
|
draftsList_.clear();
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
Toasty.success(ctx, getResources().getString(R.string.draftsDeleteSuccess));
|
Toasty.success(ctx, getResources().getString(R.string.draftsDeleteSuccess));
|
||||||
|
@ -168,7 +168,6 @@ public class IssuesFragment extends Fragment {
|
|||||||
|
|
||||||
loadInitial(Authorization.get(getContext()), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState"));
|
loadInitial(Authorization.get(getContext()), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState"));
|
||||||
tinyDb.putBoolean("resumeIssues", false);
|
tinyDb.putBoolean("resumeIssues", false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -191,14 +190,12 @@ public class IssuesFragment extends Fragment {
|
|||||||
issuesList.addAll(response.body());
|
issuesList.addAll(response.body());
|
||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
noDataIssues.setVisibility(View.GONE);
|
noDataIssues.setVisibility(View.GONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
issuesList.clear();
|
issuesList.clear();
|
||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
noDataIssues.setVisibility(View.VISIBLE);
|
noDataIssues.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mProgressBar.setVisibility(View.GONE);
|
||||||
@ -208,7 +205,6 @@ public class IssuesFragment extends Fragment {
|
|||||||
|
|
||||||
noDataIssues.setVisibility(View.VISIBLE);
|
noDataIssues.setVisibility(View.VISIBLE);
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mProgressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log.e(TAG, String.valueOf(response.code()));
|
Log.e(TAG, String.valueOf(response.code()));
|
||||||
@ -311,7 +307,6 @@ public class IssuesFragment extends Fragment {
|
|||||||
|
|
||||||
filter(newText);
|
filter(newText);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -74,11 +74,10 @@ public class ProfileEmailsFragment extends Fragment {
|
|||||||
noDataEmails = fragmentProfileEmailsBinding.noDataEmails;
|
noDataEmails = fragmentProfileEmailsBinding.noDataEmails;
|
||||||
mRecyclerView = fragmentProfileEmailsBinding.recyclerView;
|
mRecyclerView = fragmentProfileEmailsBinding.recyclerView;
|
||||||
|
|
||||||
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||||
|
|
||||||
mRecyclerView.setHasFixedSize(true);
|
mRecyclerView.setHasFixedSize(true);
|
||||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
|
||||||
DividerItemDecoration.VERTICAL);
|
|
||||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
mProgressBar = fragmentProfileEmailsBinding.progressBar;
|
mProgressBar = fragmentProfileEmailsBinding.progressBar;
|
||||||
|
@ -10,20 +10,16 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.Observer;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import org.gitnex.tea4j.models.UserInfo;
|
|
||||||
import org.mian.gitnex.adapters.ProfileFollowersAdapter;
|
import org.mian.gitnex.adapters.ProfileFollowersAdapter;
|
||||||
import org.mian.gitnex.databinding.FragmentProfileFollowersBinding;
|
import org.mian.gitnex.databinding.FragmentProfileFollowersBinding;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.viewmodels.ProfileFollowersViewModel;
|
import org.mian.gitnex.viewmodels.ProfileFollowersViewModel;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -75,11 +71,10 @@ public class ProfileFollowersFragment extends Fragment {
|
|||||||
noDataFollowers = fragmentProfileFollowersBinding.noDataFollowers;
|
noDataFollowers = fragmentProfileFollowersBinding.noDataFollowers;
|
||||||
mRecyclerView = fragmentProfileFollowersBinding.recyclerView;
|
mRecyclerView = fragmentProfileFollowersBinding.recyclerView;
|
||||||
|
|
||||||
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||||
|
|
||||||
mRecyclerView.setHasFixedSize(true);
|
mRecyclerView.setHasFixedSize(true);
|
||||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
|
||||||
DividerItemDecoration.VERTICAL);
|
|
||||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
mProgressBar = fragmentProfileFollowersBinding.progressBar;
|
mProgressBar = fragmentProfileFollowersBinding.progressBar;
|
||||||
@ -100,10 +95,10 @@ public class ProfileFollowersFragment extends Fragment {
|
|||||||
|
|
||||||
ProfileFollowersViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowersViewModel.class);
|
ProfileFollowersViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowersViewModel.class);
|
||||||
|
|
||||||
pfModel.getFollowersList(instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserInfo>>() {
|
pfModel.getFollowersList(instanceToken, getContext()).observe(getViewLifecycleOwner(), pfListMain -> {
|
||||||
@Override
|
|
||||||
public void onChanged(@Nullable List<UserInfo> pfListMain) {
|
|
||||||
adapter = new ProfileFollowersAdapter(getContext(), pfListMain);
|
adapter = new ProfileFollowersAdapter(getContext(), pfListMain);
|
||||||
|
|
||||||
if(adapter.getItemCount() > 0) {
|
if(adapter.getItemCount() > 0) {
|
||||||
mRecyclerView.setAdapter(adapter);
|
mRecyclerView.setAdapter(adapter);
|
||||||
noDataFollowers.setVisibility(View.GONE);
|
noDataFollowers.setVisibility(View.GONE);
|
||||||
@ -113,8 +108,8 @@ public class ProfileFollowersFragment extends Fragment {
|
|||||||
mRecyclerView.setAdapter(adapter);
|
mRecyclerView.setAdapter(adapter);
|
||||||
noDataFollowers.setVisibility(View.VISIBLE);
|
noDataFollowers.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mProgressBar.setVisibility(View.GONE);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,21 +10,17 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.Observer;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import org.gitnex.tea4j.models.UserInfo;
|
|
||||||
import org.mian.gitnex.adapters.ProfileFollowingAdapter;
|
import org.mian.gitnex.adapters.ProfileFollowingAdapter;
|
||||||
import org.mian.gitnex.databinding.FragmentProfileFollowingBinding;
|
import org.mian.gitnex.databinding.FragmentProfileFollowingBinding;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.viewmodels.ProfileFollowingViewModel;
|
import org.mian.gitnex.viewmodels.ProfileFollowingViewModel;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -78,11 +74,10 @@ public class ProfileFollowingFragment extends Fragment {
|
|||||||
noDataFollowing = fragmentProfileFollowingBinding.noDataFollowing;
|
noDataFollowing = fragmentProfileFollowingBinding.noDataFollowing;
|
||||||
mRecyclerView = fragmentProfileFollowingBinding.recyclerView;
|
mRecyclerView = fragmentProfileFollowingBinding.recyclerView;
|
||||||
|
|
||||||
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||||
|
|
||||||
mRecyclerView.setHasFixedSize(true);
|
mRecyclerView.setHasFixedSize(true);
|
||||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
|
||||||
DividerItemDecoration.VERTICAL);
|
|
||||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
mProgressBar = fragmentProfileFollowingBinding.progressBar;
|
mProgressBar = fragmentProfileFollowingBinding.progressBar;
|
||||||
@ -103,10 +98,10 @@ public class ProfileFollowingFragment extends Fragment {
|
|||||||
|
|
||||||
ProfileFollowingViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowingViewModel.class);
|
ProfileFollowingViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowingViewModel.class);
|
||||||
|
|
||||||
pfModel.getFollowingList(instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserInfo>>() {
|
pfModel.getFollowingList(instanceToken, getContext()).observe(getViewLifecycleOwner(), pfListMain -> {
|
||||||
@Override
|
|
||||||
public void onChanged(@Nullable List<UserInfo> pfListMain) {
|
|
||||||
adapter = new ProfileFollowingAdapter(getContext(), pfListMain);
|
adapter = new ProfileFollowingAdapter(getContext(), pfListMain);
|
||||||
|
|
||||||
if(adapter.getItemCount() > 0) {
|
if(adapter.getItemCount() > 0) {
|
||||||
mRecyclerView.setAdapter(adapter);
|
mRecyclerView.setAdapter(adapter);
|
||||||
noDataFollowing.setVisibility(View.GONE);
|
noDataFollowing.setVisibility(View.GONE);
|
||||||
@ -116,8 +111,8 @@ public class ProfileFollowingFragment extends Fragment {
|
|||||||
mRecyclerView.setAdapter(adapter);
|
mRecyclerView.setAdapter(adapter);
|
||||||
noDataFollowing.setVisibility(View.VISIBLE);
|
noDataFollowing.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mProgressBar.setVisibility(View.GONE);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -83,9 +83,11 @@ public class ProfileFragment extends Fragment {
|
|||||||
userFullName.setText(Html.fromHtml(tinyDb.getString("userFullname")));
|
userFullName.setText(Html.fromHtml(tinyDb.getString("userFullname")));
|
||||||
userLogin.setText(getString(R.string.usernameWithAt, tinyDb.getString("userLogin")));
|
userLogin.setText(getString(R.string.usernameWithAt, tinyDb.getString("userLogin")));
|
||||||
|
|
||||||
|
int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 3);
|
||||||
|
|
||||||
PicassoService.getInstance(ctx).get()
|
PicassoService.getInstance(ctx).get()
|
||||||
.load(tinyDb.getString("userAvatar"))
|
.load(tinyDb.getString("userAvatar"))
|
||||||
.transform(new RoundedTransformation(8, 0))
|
.transform(new RoundedTransformation(avatarRadius, 0))
|
||||||
.placeholder(R.drawable.loader_animated)
|
.placeholder(R.drawable.loader_animated)
|
||||||
.resize(120, 120)
|
.resize(120, 120)
|
||||||
.centerCrop().into(userAvatar);
|
.centerCrop().into(userAvatar);
|
||||||
|
@ -40,8 +40,8 @@ public class RepoInfoFragment extends Fragment {
|
|||||||
|
|
||||||
private Context ctx;
|
private Context ctx;
|
||||||
private LinearLayout pageContent;
|
private LinearLayout pageContent;
|
||||||
private static String repoNameF = "param2";
|
private static final String repoNameF = "param2";
|
||||||
private static String repoOwnerF = "param1";
|
private static final String repoOwnerF = "param1";
|
||||||
|
|
||||||
private FragmentRepoInfoBinding binding;
|
private FragmentRepoInfoBinding binding;
|
||||||
|
|
||||||
@ -284,6 +284,13 @@ public class RepoInfoFragment extends Fragment {
|
|||||||
tinyDb.putBoolean("hasPullRequests", false);
|
tinyDb.putBoolean("hasPullRequests", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(repoInfo.isArchived()) {
|
||||||
|
binding.repoIsArchived.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
binding.repoIsArchived.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
tinyDb.putString("repoHtmlUrl", repoInfo.getHtml_url());
|
tinyDb.putString("repoHtmlUrl", repoInfo.getHtml_url());
|
||||||
|
|
||||||
binding.progressBar.setVisibility(View.GONE);
|
binding.progressBar.setVisibility(View.GONE);
|
||||||
|
@ -63,8 +63,7 @@ public class RepositoriesFragment extends Fragment {
|
|||||||
mRecyclerView.setHasFixedSize(true);
|
mRecyclerView.setHasFixedSize(true);
|
||||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||||
DividerItemDecoration.VERTICAL);
|
|
||||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
createNewRepo = fragmentRepositoriesBinding.addNewRepo;
|
createNewRepo = fragmentRepositoriesBinding.addNewRepo;
|
||||||
|
@ -18,6 +18,7 @@ import org.mian.gitnex.R;
|
|||||||
import org.mian.gitnex.activities.AddNewAccountActivity;
|
import org.mian.gitnex.activities.AddNewAccountActivity;
|
||||||
import org.mian.gitnex.activities.MainActivity;
|
import org.mian.gitnex.activities.MainActivity;
|
||||||
import org.mian.gitnex.adapters.UserAccountsAdapter;
|
import org.mian.gitnex.adapters.UserAccountsAdapter;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
import org.mian.gitnex.database.api.UserAccountsApi;
|
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||||
import org.mian.gitnex.database.models.UserAccount;
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
import org.mian.gitnex.databinding.FragmentUserAccountsBinding;
|
import org.mian.gitnex.databinding.FragmentUserAccountsBinding;
|
||||||
@ -48,7 +49,7 @@ public class UserAccountsFragment extends Fragment {
|
|||||||
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.pageTitleUserAccounts));
|
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.pageTitleUserAccounts));
|
||||||
|
|
||||||
userAccountsList = new ArrayList<>();
|
userAccountsList = new ArrayList<>();
|
||||||
userAccountsApi = new UserAccountsApi(ctx);
|
userAccountsApi = BaseApi.getInstance(ctx, UserAccountsApi.class);
|
||||||
|
|
||||||
mRecyclerView = fragmentUserAccountsBinding.recyclerView;
|
mRecyclerView = fragmentUserAccountsBinding.recyclerView;
|
||||||
final SwipeRefreshLayout swipeRefresh = fragmentUserAccountsBinding.pullToRefresh;
|
final SwipeRefreshLayout swipeRefresh = fragmentUserAccountsBinding.pullToRefresh;
|
||||||
|
@ -13,6 +13,7 @@ import android.util.TypedValue;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.core.content.pm.PackageInfoCompat;
|
import androidx.core.content.pm.PackageInfoCompat;
|
||||||
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@ -69,7 +70,6 @@ public class AppUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasNetworkConnection(Context context) {
|
public static boolean hasNetworkConnection(Context context) {
|
||||||
|
|
||||||
return NetworkStatusObserver.getInstance(context).hasNetworkConnection();
|
return NetworkStatusObserver.getInstance(context).hasNetworkConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,32 +274,27 @@ public class AppUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getLastCharactersOfWord(String str, int count) {
|
public static String getLastCharactersOfWord(String str, int count) {
|
||||||
|
|
||||||
return str.substring(str.length() - count);
|
return str.substring(str.length() - count);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setMultiVisibility(int visibility, View... views) {
|
public static void setMultiVisibility(int visibility, View... views) {
|
||||||
|
|
||||||
for(View view : views) {
|
for(View view : views) {
|
||||||
|
|
||||||
view.setVisibility(visibility);
|
view.setVisibility(visibility);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getPixelsFromDensity(Context context, int dp) {
|
public static int getPixelsFromDensity(Context context, int dp) {
|
||||||
|
|
||||||
return (int) (context.getResources().getDisplayMetrics().density * dp);
|
return (int) (context.getResources().getDisplayMetrics().density * dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getPixelsFromScaledDensity(Context context, int sp) {
|
public static int getPixelsFromScaledDensity(Context context, int sp) {
|
||||||
|
|
||||||
return (int) (context.getResources().getDisplayMetrics().scaledDensity * sp);
|
return (int) (context.getResources().getDisplayMetrics().scaledDensity * sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getLineCount(String s) {
|
public static long getLineCount(String s) {
|
||||||
|
|
||||||
int lines = 0;
|
long lines = 0;
|
||||||
|
|
||||||
Pattern pattern = Pattern.compile("(\r\n|\r|\n)");
|
Pattern pattern = Pattern.compile("(\r\n|\r|\n)");
|
||||||
Matcher matcher = pattern.matcher(s);
|
Matcher matcher = pattern.matcher(s);
|
||||||
@ -307,6 +302,11 @@ public class AppUtil {
|
|||||||
while(matcher.find())
|
while(matcher.find())
|
||||||
lines++;
|
lines++;
|
||||||
|
|
||||||
|
// Sometimes there may be text, but no line breaks.
|
||||||
|
// This should still count as one line.
|
||||||
|
if(s.length() > 0 && lines == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -320,5 +320,27 @@ public class AppUtil {
|
|||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
|
|
||||||
Toasty.info(ctx, message);
|
Toasty.info(ctx, message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean switchToAccount(Context context, UserAccount userAccount) {
|
||||||
|
|
||||||
|
TinyDB tinyDB = TinyDB.getInstance(context);
|
||||||
|
|
||||||
|
if(tinyDB.getInt("currentActiveAccountId") != userAccount.getAccountId()) {
|
||||||
|
|
||||||
|
tinyDB.putString("loginUid", userAccount.getUserName());
|
||||||
|
tinyDB.putString("userLogin", userAccount.getUserName());
|
||||||
|
tinyDB.putString(userAccount.getUserName() + "-token", userAccount.getToken());
|
||||||
|
tinyDB.putString("instanceUrl", userAccount.getInstanceUrl());
|
||||||
|
tinyDB.putInt("currentActiveAccountId", userAccount.getAccountId());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.mian.gitnex.helpers;
|
package org.mian.gitnex.helpers;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
import okhttp3.Credentials;
|
import okhttp3.Credentials;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,11 +25,14 @@ public class Authorization {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String get(UserAccount userAccount) {
|
||||||
|
return "token " + userAccount.getToken();
|
||||||
|
}
|
||||||
|
|
||||||
public static String getWeb(Context context) {
|
public static String getWeb(Context context) {
|
||||||
|
|
||||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
||||||
return Credentials.basic("", tinyDb.getString(tinyDb.getString("loginUid") + "-token"));
|
return Credentials.basic("", tinyDb.getString(tinyDb.getString("loginUid") + "-token"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,11 @@ public class Constants {
|
|||||||
public static final String mainNotificationChannelId = "main_channel";
|
public static final String mainNotificationChannelId = "main_channel";
|
||||||
public static final String downloadNotificationChannelId = "dl_channel";
|
public static final String downloadNotificationChannelId = "dl_channel";
|
||||||
|
|
||||||
|
public static final long[] defaultVibrationPattern = new long[] { 1000, 1000 };
|
||||||
|
|
||||||
public static final String[] fallbackReactions = new String[]{"+1", "-1", "laugh", "hooray", "confused", "heart", "rocket", "eyes"};
|
public static final String[] fallbackReactions = new String[]{"+1", "-1", "laugh", "hooray", "confused", "heart", "rocket", "eyes"};
|
||||||
|
|
||||||
|
// work managers
|
||||||
|
public static final String notificationsWorkerId = "notifications_worker";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class Markdown {
|
|||||||
|
|
||||||
private static final int MAX_POOL_SIZE = 45;
|
private static final int MAX_POOL_SIZE = 45;
|
||||||
private static final int MAX_THREAD_KEEP_ALIVE_SECONDS = 120;
|
private static final int MAX_THREAD_KEEP_ALIVE_SECONDS = 120;
|
||||||
private static final int MAX_CLAIM_TIMEOUT_SECONDS = 5;
|
private static final int MAX_CLAIM_TIMEOUT_SECONDS = 120;
|
||||||
|
|
||||||
private static final Timeout timeout = new Timeout(MAX_CLAIM_TIMEOUT_SECONDS, TimeUnit.SECONDS);
|
private static final Timeout timeout = new Timeout(MAX_CLAIM_TIMEOUT_SECONDS, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class Version {
|
|||||||
final Pattern pattern_number_dot_number = Pattern.compile("^\\d+(\\.(\\d)+)*");
|
final Pattern pattern_number_dot_number = Pattern.compile("^\\d+(\\.(\\d)+)*");
|
||||||
|
|
||||||
if(!valid(raw)) {
|
if(!valid(raw)) {
|
||||||
throw new IllegalArgumentException("Invalid version format");
|
throw new IllegalArgumentException("Invalid version format: " + raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(raw.charAt(0) == 'v' || raw.charAt(0) == 'V') {
|
if(raw.charAt(0) == 'v' || raw.charAt(0) == 'V') {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mian.gitnex.helpers.views;
|
package org.mian.gitnex.helpers.views;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
@ -36,19 +37,16 @@ public class SyntaxHighlightedArea extends LinearLayout {
|
|||||||
private LinesView linesView;
|
private LinesView linesView;
|
||||||
|
|
||||||
public SyntaxHighlightedArea(@NonNull Context context) {
|
public SyntaxHighlightedArea(@NonNull Context context) {
|
||||||
|
|
||||||
super(context);
|
super(context);
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SyntaxHighlightedArea(@NonNull Context context, @Nullable AttributeSet attrs) {
|
public SyntaxHighlightedArea(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||||
|
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SyntaxHighlightedArea(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
public SyntaxHighlightedArea(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||||
|
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
@ -62,9 +60,10 @@ public class SyntaxHighlightedArea extends LinearLayout {
|
|||||||
sourceView = new TextView(getContext());
|
sourceView = new TextView(getContext());
|
||||||
|
|
||||||
sourceView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
sourceView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
sourceView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
|
||||||
sourceView.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/sourcecodeproregular.ttf"));
|
sourceView.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/sourcecodeproregular.ttf"));
|
||||||
|
sourceView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
||||||
sourceView.setTextColor(prism4jTheme.textColor());
|
sourceView.setTextColor(prism4jTheme.textColor());
|
||||||
|
sourceView.setTextIsSelectable(true);
|
||||||
|
|
||||||
int padding = AppUtil.getPixelsFromDensity(getContext(), 5);
|
int padding = AppUtil.getPixelsFromDensity(getContext(), 5);
|
||||||
sourceView.setPadding(padding, 0, padding, 0);
|
sourceView.setPadding(padding, 0, padding, 0);
|
||||||
@ -97,34 +96,57 @@ public class SyntaxHighlightedArea extends LinearLayout {
|
|||||||
public void setContent(@NonNull String source, @NonNull String extension) {
|
public void setContent(@NonNull String source, @NonNull String extension) {
|
||||||
|
|
||||||
if(source.length() > 0) {
|
if(source.length() > 0) {
|
||||||
linesView.setLineCount(AppUtil.getLineCount(source));
|
|
||||||
|
Thread highlightingThread = new Thread(() -> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
MainGrammarLocator mainGrammarLocator = MainGrammarLocator.getInstance();
|
MainGrammarLocator mainGrammarLocator = MainGrammarLocator.getInstance();
|
||||||
Prism4j prism4j = new Prism4j(mainGrammarLocator);
|
|
||||||
|
|
||||||
CharSequence highlightedSource = Prism4jSyntaxHighlight.create(prism4j, prism4jTheme, MainGrammarLocator.DEFAULT_FALLBACK_LANGUAGE)
|
CharSequence highlightedSource = Prism4jSyntaxHighlight
|
||||||
|
.create(new Prism4j(mainGrammarLocator), prism4jTheme, MainGrammarLocator.DEFAULT_FALLBACK_LANGUAGE)
|
||||||
.highlight(mainGrammarLocator.fromExtension(extension), source);
|
.highlight(mainGrammarLocator.fromExtension(extension), source);
|
||||||
|
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
if(highlightedSource.charAt(highlightedSource.length() - 1) == '\n') {
|
if(highlightedSource.charAt(highlightedSource.length() - 1) == '\n') {
|
||||||
// Removes a line break which is probably added by Prism4j but not actually present in the source.
|
// Removes a line break which is probably added by Prism4j but not actually present in the source.
|
||||||
// This line should be altered in case this gets fixed.
|
// This line should be altered in case this gets fixed.
|
||||||
sourceView.setText(highlightedSource.subSequence(0, highlightedSource.length() - 1));
|
sourceView.setText(highlightedSource.subSequence(0, highlightedSource.length() - 1));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sourceView.setText(highlightedSource);
|
sourceView.setText(highlightedSource);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
} catch(Throwable ignored) {
|
} catch(Throwable ignored) {
|
||||||
// Fall back to plaintext if something fails
|
// Fall back to plaintext if something fails
|
||||||
sourceView.setText(source);
|
getActivity().runOnUiThread(() -> sourceView.setText(source));
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
Thread lineCountingThread = new Thread(() -> {
|
||||||
|
|
||||||
|
long lineCount = AppUtil.getLineCount(source);
|
||||||
|
|
||||||
|
try {
|
||||||
|
highlightingThread.join();
|
||||||
|
} catch(InterruptedException ignored) {}
|
||||||
|
|
||||||
|
getActivity().runOnUiThread(() -> linesView.setLineCount(lineCount));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
highlightingThread.start();
|
||||||
|
lineCountingThread.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Activity getActivity() {
|
||||||
|
return (Activity) getContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getContent() {
|
public String getContent() {
|
||||||
|
|
||||||
return sourceView.getText().toString();
|
return sourceView.getText().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,27 +159,31 @@ public class SyntaxHighlightedArea extends LinearLayout {
|
|||||||
@ColorInt private int textColor;
|
@ColorInt private int textColor;
|
||||||
@ColorInt private int lineColor;
|
@ColorInt private int lineColor;
|
||||||
|
|
||||||
private int lineCount;
|
private long lineCount;
|
||||||
|
|
||||||
public LinesView(Context context) {
|
public LinesView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLineCount(int lineCount) {
|
public void setLineCount(long lineCount) {
|
||||||
this.lineCount = lineCount;
|
this.lineCount = lineCount;
|
||||||
|
requestLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBackgroundColor(@ColorInt int backgroundColor) {
|
public void setBackgroundColor(@ColorInt int backgroundColor) {
|
||||||
this.backgroundColor = backgroundColor;
|
this.backgroundColor = backgroundColor;
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTextColor(@ColorInt int textColor) {
|
public void setTextColor(@ColorInt int textColor) {
|
||||||
this.textColor = textColor;
|
this.textColor = textColor;
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLineColor(@ColorInt int lineColor) {
|
public void setLineColor(@ColorInt int lineColor) {
|
||||||
this.lineColor = lineColor;
|
this.lineColor = lineColor;
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Paint getPaint() {
|
public Paint getPaint() {
|
||||||
|
@ -13,7 +13,6 @@ import androidx.work.WorkManager;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.helpers.Constants;
|
import org.mian.gitnex.helpers.Constants;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Version;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,8 +21,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
|
|
||||||
public class Notifications {
|
public class Notifications {
|
||||||
|
|
||||||
private static int notificationsSupported = -1;
|
|
||||||
|
|
||||||
public static int uniqueNotificationId(Context context) {
|
public static int uniqueNotificationId(Context context) {
|
||||||
|
|
||||||
TinyDB tinyDB = TinyDB.getInstance(context);
|
TinyDB tinyDB = TinyDB.getInstance(context);
|
||||||
@ -51,7 +48,7 @@ public class Notifications {
|
|||||||
mainChannel.setDescription(context.getString(R.string.mainNotificationChannelDescription));
|
mainChannel.setDescription(context.getString(R.string.mainNotificationChannelDescription));
|
||||||
|
|
||||||
if(tinyDB.getBoolean("notificationsEnableVibration", true)) {
|
if(tinyDB.getBoolean("notificationsEnableVibration", true)) {
|
||||||
mainChannel.setVibrationPattern(new long[] { 1000, 1000 });
|
mainChannel.setVibrationPattern(Constants.defaultVibrationPattern);
|
||||||
mainChannel.enableVibration(true);
|
mainChannel.enableVibration(true);
|
||||||
} else {
|
} else {
|
||||||
mainChannel.enableVibration(false);
|
mainChannel.enableVibration(false);
|
||||||
@ -75,7 +72,7 @@ public class Notifications {
|
|||||||
|
|
||||||
public static void stopWorker(Context context) {
|
public static void stopWorker(Context context) {
|
||||||
|
|
||||||
WorkManager.getInstance(context).cancelAllWorkByTag(context.getPackageName());
|
WorkManager.getInstance(context).cancelAllWorkByTag(Constants.notificationsWorkerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startWorker(Context context) {
|
public static void startWorker(Context context) {
|
||||||
@ -84,10 +81,6 @@ public class Notifications {
|
|||||||
|
|
||||||
if(tinyDB.getBoolean("notificationsEnabled", true)) {
|
if(tinyDB.getBoolean("notificationsEnabled", true)) {
|
||||||
|
|
||||||
if(notificationsSupported == -1) checkVersion(tinyDB);
|
|
||||||
|
|
||||||
if(notificationsSupported == 1) {
|
|
||||||
|
|
||||||
Constraints.Builder constraints = new Constraints.Builder()
|
Constraints.Builder constraints = new Constraints.Builder()
|
||||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||||
.setRequiresBatteryNotLow(false)
|
.setRequiresBatteryNotLow(false)
|
||||||
@ -95,7 +88,6 @@ public class Notifications {
|
|||||||
.setRequiresCharging(false);
|
.setRequiresCharging(false);
|
||||||
|
|
||||||
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
|
||||||
constraints.setRequiresDeviceIdle(false);
|
constraints.setRequiresDeviceIdle(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,23 +95,11 @@ public class Notifications {
|
|||||||
|
|
||||||
PeriodicWorkRequest periodicWorkRequest = new PeriodicWorkRequest.Builder(NotificationsWorker.class, pollingDelayMinutes, TimeUnit.MINUTES)
|
PeriodicWorkRequest periodicWorkRequest = new PeriodicWorkRequest.Builder(NotificationsWorker.class, pollingDelayMinutes, TimeUnit.MINUTES)
|
||||||
.setConstraints(constraints.build())
|
.setConstraints(constraints.build())
|
||||||
.addTag(context.getPackageName())
|
.addTag(Constants.notificationsWorkerId)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
WorkManager.getInstance(context).enqueueUniquePeriodicWork(context.getPackageName(), ExistingPeriodicWorkPolicy.KEEP, periodicWorkRequest);
|
WorkManager.getInstance(context).enqueueUniquePeriodicWork(Constants.notificationsWorkerId, ExistingPeriodicWorkPolicy.KEEP, periodicWorkRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkVersion(TinyDB tinyDB) {
|
|
||||||
|
|
||||||
String currentVersion = tinyDB.getString("giteaVersion");
|
|
||||||
|
|
||||||
if(tinyDB.getBoolean("loggedInMode") && !currentVersion.isEmpty()) {
|
|
||||||
|
|
||||||
notificationsSupported = new Version(currentVersion).higherOrEqual("1.12.3") ? 1 : 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -15,12 +15,18 @@ import org.gitnex.tea4j.models.NotificationThread;
|
|||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.MainActivity;
|
import org.mian.gitnex.activities.MainActivity;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
|
import org.mian.gitnex.database.api.UserAccountsApi;
|
||||||
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
import org.mian.gitnex.helpers.AppUtil;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.helpers.Constants;
|
import org.mian.gitnex.helpers.Constants;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
|
import org.mian.gitnex.helpers.Version;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
|
|
||||||
@ -30,86 +36,101 @@ import retrofit2.Response;
|
|||||||
|
|
||||||
public class NotificationsWorker extends Worker {
|
public class NotificationsWorker extends Worker {
|
||||||
|
|
||||||
private static final int MAXIMUM_NOTIFICATIONS = 100;
|
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final TinyDB tinyDB;
|
private final TinyDB tinyDB;
|
||||||
|
private final Map<UserAccount, Map<String, String>> userAccounts;
|
||||||
|
|
||||||
public NotificationsWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
|
public NotificationsWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
|
||||||
|
|
||||||
super(context, workerParams);
|
super(context, workerParams);
|
||||||
|
|
||||||
|
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
|
||||||
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.tinyDB = TinyDB.getInstance(context);
|
this.tinyDB = TinyDB.getInstance(context);
|
||||||
|
this.userAccounts = new HashMap<>(userAccountsApi.getCount());
|
||||||
|
|
||||||
|
for(UserAccount userAccount : userAccountsApi.usersAccounts()) {
|
||||||
|
|
||||||
|
// We do also accept empty values, since the server version was not saved properly in the beginning.
|
||||||
|
if(userAccount.getServerVersion() == null || userAccount.getServerVersion().isEmpty() ||
|
||||||
|
new Version(userAccount.getServerVersion()).higherOrEqual("1.12.3")) {
|
||||||
|
|
||||||
|
Map<String, String> userAccountParameters = new HashMap<>();
|
||||||
|
userAccountParameters.put("previousTimestamp", AppUtil.getTimestampFromDate(context, new Date()));
|
||||||
|
|
||||||
|
userAccounts.put(userAccount, userAccountParameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Result doWork() {
|
public Result doWork() {
|
||||||
|
pollingLoops();
|
||||||
int notificationLoops = tinyDB.getInt("pollingDelayMinutes", Constants.defaultPollingDelay) >= 15 ? 1 : Math.min(15 - tinyDB.getInt("pollingDelayMinutes"), 10);
|
return Result.success();
|
||||||
|
|
||||||
for(int i = 0; i < notificationLoops; i++) {
|
|
||||||
|
|
||||||
long startPollingTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
String previousRefreshTimestamp = tinyDB.getString("previousRefreshTimestamp", AppUtil.getTimestampFromDate(context, new Date()));
|
|
||||||
|
|
||||||
Call<List<NotificationThread>> call = RetrofitClient
|
|
||||||
.getApiInterface(context)
|
|
||||||
.getNotificationThreads(Authorization.get(context), false, new String[]{"unread"}, previousRefreshTimestamp,
|
|
||||||
null, 1, MAXIMUM_NOTIFICATIONS);
|
|
||||||
|
|
||||||
Response<List<NotificationThread>> response = call.execute();
|
|
||||||
|
|
||||||
if(response.code() == 200) {
|
|
||||||
|
|
||||||
assert response.body() != null;
|
|
||||||
|
|
||||||
List<NotificationThread> notificationThreads = response.body();
|
|
||||||
|
|
||||||
if(!notificationThreads.isEmpty())
|
|
||||||
sendNotification(notificationThreads);
|
|
||||||
|
|
||||||
tinyDB.putString("previousRefreshTimestamp", AppUtil.getTimestampFromDate(context, new Date()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch(Exception ignored) {}
|
/**
|
||||||
|
* Used to bypass the 15-minute limit of {@code WorkManager}.
|
||||||
|
*/
|
||||||
|
private void pollingLoops() {
|
||||||
|
int notificationLoops = tinyDB.getInt("pollingDelayMinutes", Constants.defaultPollingDelay) < 15 ?
|
||||||
|
Math.min(15 - tinyDB.getInt("pollingDelayMinutes"), 10) : 1;
|
||||||
|
|
||||||
|
for(int i = 0; i < notificationLoops; i++) {
|
||||||
|
long startPollingTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
startPolling();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(notificationLoops > 1 && i < (notificationLoops - 1)) {
|
if(notificationLoops > 1 && i < (notificationLoops - 1)) {
|
||||||
|
|
||||||
Thread.sleep(60000 - (System.currentTimeMillis() - startPollingTime));
|
Thread.sleep(60000 - (System.currentTimeMillis() - startPollingTime));
|
||||||
}
|
}
|
||||||
} catch(InterruptedException ignored) {}
|
} catch(InterruptedException ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.success();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendNotification(List<NotificationThread> notificationThreads) {
|
private void startPolling() {
|
||||||
|
for(UserAccount userAccount : userAccounts.keySet()) {
|
||||||
|
Map<String, String> userAccountParameters = userAccounts.get(userAccount);
|
||||||
|
|
||||||
int summaryId = 0;
|
try {
|
||||||
PendingIntent pendingIntent = getPendingIntent();
|
Call<List<NotificationThread>> call = RetrofitClient
|
||||||
|
.getApiInterface(context, userAccount.getInstanceUrl())
|
||||||
|
.getNotificationThreads(Authorization.get(userAccount), false, new String[]{"unread"},
|
||||||
|
userAccountParameters.get("previousTimestamp"), null, 1, Integer.MAX_VALUE);
|
||||||
|
|
||||||
|
Response<List<NotificationThread>> response = call.execute();
|
||||||
|
|
||||||
|
if(response.code() == 200 && response.body() != null) {
|
||||||
|
List<NotificationThread> notificationThreads = response.body();
|
||||||
|
if(!notificationThreads.isEmpty()) {
|
||||||
|
sendNotifications(userAccount, notificationThreads);
|
||||||
|
}
|
||||||
|
userAccountParameters.put("previousTimestamp", AppUtil.getTimestampFromDate(context, new Date()));
|
||||||
|
}
|
||||||
|
} catch(Exception ignored) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendNotifications(@NonNull UserAccount userAccount, @NonNull List<NotificationThread> notificationThreads) {
|
||||||
|
|
||||||
|
PendingIntent pendingIntent = getPendingIntent(userAccount);
|
||||||
|
|
||||||
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context);
|
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context);
|
||||||
|
|
||||||
Notification summaryNotification = new NotificationCompat.Builder(context, context.getPackageName())
|
Notification summaryNotification = new NotificationCompat.Builder(context, Constants.mainNotificationChannelId)
|
||||||
.setContentTitle(context.getString(R.string.newMessages))
|
.setContentTitle(context.getString(R.string.newMessages, userAccount.getUserName()))
|
||||||
.setContentText(String.format(context.getString(R.string.youHaveGotNewNotifications), notificationThreads.size()))
|
.setContentText(String.format(context.getString(R.string.youHaveGotNewNotifications), notificationThreads.size()))
|
||||||
.setSmallIcon(R.drawable.gitnex_transparent)
|
.setSmallIcon(R.drawable.gitnex_transparent)
|
||||||
.setGroup(context.getPackageName())
|
.setGroup(userAccount.getUserName())
|
||||||
.setGroupSummary(true)
|
.setGroupSummary(true)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setContentIntent(pendingIntent)
|
.setContentIntent(pendingIntent)
|
||||||
.setChannelId(Constants.mainNotificationChannelId)
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
notificationManagerCompat.notify(summaryId, summaryNotification);
|
notificationManagerCompat.notify(userAccount.getAccountId(), summaryNotification);
|
||||||
|
|
||||||
for(NotificationThread notificationThread : notificationThreads) {
|
for(NotificationThread notificationThread : notificationThreads) {
|
||||||
|
|
||||||
@ -119,7 +140,7 @@ public class NotificationsWorker extends Worker {
|
|||||||
|
|
||||||
NotificationCompat.Builder builder1 = getBaseNotificationBuilder()
|
NotificationCompat.Builder builder1 = getBaseNotificationBuilder()
|
||||||
.setContentTitle(notificationHeader)
|
.setContentTitle(notificationHeader)
|
||||||
.setGroup(context.getPackageName())
|
.setGroup(userAccount.getUserName())
|
||||||
.setContentIntent(pendingIntent);
|
.setContentIntent(pendingIntent);
|
||||||
|
|
||||||
notificationManagerCompat.notify(Notifications.uniqueNotificationId(context), builder1.build());
|
notificationManagerCompat.notify(Notifications.uniqueNotificationId(context), builder1.build());
|
||||||
@ -129,21 +150,19 @@ public class NotificationsWorker extends Worker {
|
|||||||
|
|
||||||
private NotificationCompat.Builder getBaseNotificationBuilder() {
|
private NotificationCompat.Builder getBaseNotificationBuilder() {
|
||||||
|
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, context.getPackageName())
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, Constants.mainNotificationChannelId)
|
||||||
.setSmallIcon(R.drawable.gitnex_transparent)
|
.setSmallIcon(R.drawable.gitnex_transparent)
|
||||||
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
|
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
|
||||||
.setCategory(NotificationCompat.CATEGORY_MESSAGE)
|
.setCategory(NotificationCompat.CATEGORY_MESSAGE)
|
||||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||||
.setChannelId(Constants.mainNotificationChannelId)
|
|
||||||
.setAutoCancel(true);
|
.setAutoCancel(true);
|
||||||
|
|
||||||
if(tinyDB.getBoolean("notificationsEnableLights", true)) {
|
if(tinyDB.getBoolean("notificationsEnableLights", true)) {
|
||||||
|
|
||||||
builder.setLights(tinyDB.getInt("notificationsLightColor", Color.GREEN), 1500, 1500);
|
builder.setLights(tinyDB.getInt("notificationsLightColor", Color.GREEN), 1500, 1500);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinyDB.getBoolean("notificationsEnableVibration", true)) {
|
if(tinyDB.getBoolean("notificationsEnableVibration", true)) {
|
||||||
builder.setVibrate(new long[]{ 1000, 1000 });
|
builder.setVibrate(Constants.defaultVibrationPattern);
|
||||||
} else {
|
} else {
|
||||||
builder.setVibrate(null);
|
builder.setVibrate(null);
|
||||||
}
|
}
|
||||||
@ -151,13 +170,16 @@ public class NotificationsWorker extends Worker {
|
|||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PendingIntent getPendingIntent() {
|
private PendingIntent getPendingIntent(@NonNull UserAccount userAccount) {
|
||||||
|
|
||||||
Intent intent = new Intent(context, MainActivity.class);
|
Intent intent = new Intent(context, MainActivity.class);
|
||||||
|
|
||||||
intent.putExtra("launchFragment", "notifications");
|
intent.putExtra("launchFragment", "notifications");
|
||||||
|
intent.putExtra("switchAccountId", userAccount.getAccountId());
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
|
||||||
return PendingIntent.getActivity(context, 0, intent, 0);
|
return PendingIntent.getActivity(context, userAccount.getAccountId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
14
app/src/main/res/drawable/shape_files_diffs.xml
Normal file
14
app/src/main/res/drawable/shape_files_diffs.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<shape
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
|
||||||
|
<corners android:radius="0dp" />
|
||||||
|
<solid
|
||||||
|
android:color="?attr/iconsColor"/>
|
||||||
|
<padding
|
||||||
|
android:bottom="2dp"
|
||||||
|
android:left="5dp"
|
||||||
|
android:right="5dp"
|
||||||
|
android:top="2dp" />
|
||||||
|
|
||||||
|
</shape>
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_arrow_back" />
|
android:src="@drawable/ic_arrow_back" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -96,9 +96,9 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/assigneeAvatar"
|
android:id="@+id/assigneeAvatar"
|
||||||
android:layout_width="48dp"
|
android:layout_width="@dimen/list_avatar_size"
|
||||||
android:layout_height="48dp"
|
android:layout_height="@dimen/list_avatar_size"
|
||||||
android:layout_marginEnd="15dp"
|
android:layout_marginEnd="10dp"
|
||||||
android:contentDescription="@string/generalImgContentText" />
|
android:contentDescription="@string/generalImgContentText" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -109,7 +109,7 @@
|
|||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
android:textColor="?attr/primaryTextColor"
|
android:textColor="?attr/primaryTextColor"
|
||||||
android:textIsSelectable="true"
|
android:textIsSelectable="true"
|
||||||
android:textSize="18sp" />
|
android:textSize="16sp" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/msdueFrame"
|
android:id="@+id/msdueFrame"
|
||||||
@ -174,7 +174,7 @@
|
|||||||
android:autoLink="web"
|
android:autoLink="web"
|
||||||
android:textColorLink="@color/lightBlue"
|
android:textColorLink="@color/lightBlue"
|
||||||
android:textIsSelectable="true"
|
android:textIsSelectable="true"
|
||||||
android:textSize="16sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<HorizontalScrollView
|
<HorizontalScrollView
|
||||||
android:layout_below="@+id/issueDescription"
|
android:layout_below="@+id/issueDescription"
|
||||||
@ -212,7 +212,7 @@
|
|||||||
android:text="@string/createdText"
|
android:text="@string/createdText"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:textColor="?attr/hintColor"
|
android:textColor="?attr/hintColor"
|
||||||
android:textSize="14sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/issueModified"
|
android:id="@+id/issueModified"
|
||||||
@ -220,7 +220,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="?attr/hintColor"
|
android:textColor="?attr/hintColor"
|
||||||
android:layout_toEndOf="@+id/issueCreatedTime"
|
android:layout_toEndOf="@+id/issueCreatedTime"
|
||||||
android:textSize="14sp"
|
android:textSize="12sp"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:text="@string/modifiedText" />
|
android:text="@string/modifiedText" />
|
||||||
|
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<HorizontalScrollView
|
<HorizontalScrollView
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -28,6 +28,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
@ -10,6 +11,7 @@
|
|||||||
android:id="@+id/appbar"
|
android:id="@+id/appbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
android:theme="@style/Widget.AppCompat.SearchView">
|
android:theme="@style/Widget.AppCompat.SearchView">
|
||||||
|
|
||||||
<com.google.android.material.appbar.MaterialToolbar
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
@ -22,10 +24,13 @@
|
|||||||
android:id="@+id/close"
|
android:id="@+id/close"
|
||||||
android:layout_width="@dimen/close_button_size"
|
android:layout_width="@dimen/close_button_size"
|
||||||
android:layout_height="@dimen/close_button_size"
|
android:layout_height="@dimen/close_button_size"
|
||||||
android:layout_marginRight="15dp"
|
|
||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:layout_marginRight="15dp"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_arrow_back" />
|
android:src="@drawable/ic_arrow_back" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -33,9 +38,9 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
android:text="@string/repoSettingsTitle"
|
android:text="@string/repoSettingsTitle"
|
||||||
android:textColor="?attr/primaryTextColor"
|
android:textColor="?attr/primaryTextColor"
|
||||||
android:maxLines="1"
|
|
||||||
android:textSize="20sp" />
|
android:textSize="20sp" />
|
||||||
|
|
||||||
</com.google.android.material.appbar.MaterialToolbar>
|
</com.google.android.material.appbar.MaterialToolbar>
|
||||||
@ -56,11 +61,14 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:text="@string/repoSettingsEditProperties"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:drawablePadding="32dp"
|
android:drawablePadding="32dp"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
|
android:text="@string/repoSettingsEditProperties"
|
||||||
android:textColor="?attr/primaryTextColor"
|
android:textColor="?attr/primaryTextColor"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:padding="16dp"
|
|
||||||
app:drawableStartCompat="@drawable/ic_edit" />
|
app:drawableStartCompat="@drawable/ic_edit" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
@ -72,21 +80,25 @@
|
|||||||
android:id="@+id/transferOwnerFrame"
|
android:id="@+id/transferOwnerFrame"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:visibility="gone">
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/transferRepositoryOwnership"
|
android:id="@+id/transferRepositoryOwnership"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:text="@string/repoSettingsTransferOwnership"
|
|
||||||
android:drawablePadding="32dp"
|
android:drawablePadding="32dp"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:text="@string/repoSettingsTransferOwnership"
|
||||||
android:textColor="?attr/primaryTextColor"
|
android:textColor="?attr/primaryTextColor"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:paddingTop="16dp"
|
|
||||||
android:paddingStart="16dp"
|
|
||||||
android:paddingEnd="16dp"
|
|
||||||
app:drawableStartCompat="@drawable/ic_arrow_up" />
|
app:drawableStartCompat="@drawable/ic_arrow_up" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -94,12 +106,12 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:paddingStart="72dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
android:text="@string/repoSettingsTransferOwnershipHint"
|
android:text="@string/repoSettingsTransferOwnershipHint"
|
||||||
android:textColor="?attr/hintColor"
|
android:textColor="?attr/hintColor"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp" />
|
||||||
android:paddingBottom="16dp"
|
|
||||||
android:paddingStart="72dp"
|
|
||||||
android:paddingEnd="16dp" />
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -110,8 +122,11 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:paddingBottom="16dp">
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -119,13 +134,13 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:text="@string/repoSettingsDelete"
|
|
||||||
android:drawablePadding="32dp"
|
android:drawablePadding="32dp"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:text="@string/repoSettingsDelete"
|
||||||
android:textColor="?attr/primaryTextColor"
|
android:textColor="?attr/primaryTextColor"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:paddingTop="16dp"
|
|
||||||
android:paddingStart="16dp"
|
|
||||||
android:paddingEnd="16dp"
|
|
||||||
app:drawableStartCompat="@drawable/ic_delete" />
|
app:drawableStartCompat="@drawable/ic_delete" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -133,11 +148,11 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:paddingStart="72dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
android:text="@string/repoSettingsDeleteHint"
|
android:text="@string/repoSettingsDeleteHint"
|
||||||
android:textColor="?attr/hintColor"
|
android:textColor="?attr/hintColor"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp" />
|
||||||
android:paddingStart="72dp"
|
|
||||||
android:paddingEnd="16dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
android:id="@+id/appbar"
|
android:id="@+id/appbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
android:theme="@style/Widget.AppCompat.SearchView">
|
android:theme="@style/Widget.AppCompat.SearchView">
|
||||||
|
|
||||||
<com.google.android.material.appbar.MaterialToolbar
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
@ -23,10 +24,13 @@
|
|||||||
android:id="@+id/close"
|
android:id="@+id/close"
|
||||||
android:layout_width="@dimen/close_button_size"
|
android:layout_width="@dimen/close_button_size"
|
||||||
android:layout_height="@dimen/close_button_size"
|
android:layout_height="@dimen/close_button_size"
|
||||||
android:layout_marginRight="15dp"
|
|
||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
android:gravity="center_vertical"
|
android:layout_marginRight="15dp"
|
||||||
android:contentDescription="@string/close"
|
android:contentDescription="@string/close"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
android:src="@drawable/ic_close" />
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -34,9 +38,9 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
android:text="@string/settingsAppearanceHeader"
|
android:text="@string/settingsAppearanceHeader"
|
||||||
android:textColor="?attr/primaryTextColor"
|
android:textColor="?attr/primaryTextColor"
|
||||||
android:maxLines="1"
|
|
||||||
android:textSize="20sp" />
|
android:textSize="20sp" />
|
||||||
|
|
||||||
</com.google.android.material.appbar.MaterialToolbar>
|
</com.google.android.material.appbar.MaterialToolbar>
|
||||||
@ -47,29 +51,32 @@
|
|||||||
android:id="@+id/themeSelectionFrame"
|
android:id="@+id/themeSelectionFrame"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
|
android:paddingTop="10dp"
|
||||||
|
android:paddingBottom="10dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/themeHeaderSelector"
|
android:id="@+id/themeHeaderSelector"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="16sp"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:layout_marginStart="44dp"
|
android:layout_marginStart="44dp"
|
||||||
android:layout_marginEnd="24dp"
|
android:layout_marginEnd="24dp"
|
||||||
android:text="@string/themeSelectionHeaderText"
|
android:text="@string/themeSelectionHeaderText"
|
||||||
android:textColor="?attr/primaryTextColor"/>
|
android:textColor="?attr/primaryTextColor"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/themeSelected"
|
android:id="@+id/themeSelected"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="14sp"
|
|
||||||
android:layout_marginStart="44dp"
|
android:layout_marginStart="44dp"
|
||||||
android:layout_marginEnd="24dp"
|
android:layout_marginEnd="24dp"
|
||||||
android:text="@string/themeSelectionSelectedText"
|
android:text="@string/themeSelectionSelectedText"
|
||||||
android:textColor="?attr/selectedTextColor"/>
|
android:textColor="?attr/selectedTextColor"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -77,29 +84,32 @@
|
|||||||
android:id="@+id/customFontFrame"
|
android:id="@+id/customFontFrame"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="15dp"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:orientation="vertical">
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="10dp"
|
||||||
|
android:paddingBottom="10dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/customFontHeaderSelector"
|
android:id="@+id/customFontHeaderSelector"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="16sp"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:layout_marginStart="44dp"
|
android:layout_marginStart="44dp"
|
||||||
android:layout_marginEnd="24dp"
|
android:layout_marginEnd="24dp"
|
||||||
android:text="@string/settingsCustomFontHeaderText"
|
android:text="@string/settingsCustomFontHeaderText"
|
||||||
android:textColor="?attr/primaryTextColor"/>
|
android:textColor="?attr/primaryTextColor"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/customFontSelected"
|
android:id="@+id/customFontSelected"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="14sp"
|
|
||||||
android:layout_marginStart="44dp"
|
android:layout_marginStart="44dp"
|
||||||
android:layout_marginEnd="24dp"
|
android:layout_marginEnd="24dp"
|
||||||
android:text="@string/settingsCustomFontDefault"
|
android:text="@string/settingsCustomFontDefault"
|
||||||
android:textColor="?attr/selectedTextColor"/>
|
android:textColor="?attr/selectedTextColor"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -107,29 +117,32 @@
|
|||||||
android:id="@+id/timeFrame"
|
android:id="@+id/timeFrame"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="15dp"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:orientation="vertical">
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="10dp"
|
||||||
|
android:paddingBottom="10dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvDateTimeHeaderSelector"
|
android:id="@+id/tvDateTimeHeaderSelector"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="16sp"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:layout_marginStart="44dp"
|
android:layout_marginStart="44dp"
|
||||||
android:layout_marginEnd="24dp"
|
android:layout_marginEnd="24dp"
|
||||||
android:text="@string/settingsDateTimeHeaderText"
|
android:text="@string/settingsDateTimeHeaderText"
|
||||||
android:textColor="?attr/primaryTextColor"/>
|
android:textColor="?attr/primaryTextColor"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvDateTimeSelected"
|
android:id="@+id/tvDateTimeSelected"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="14sp"
|
|
||||||
android:layout_marginStart="44dp"
|
android:layout_marginStart="44dp"
|
||||||
android:layout_marginEnd="24dp"
|
android:layout_marginEnd="24dp"
|
||||||
android:text="@string/settingsDateTimeHeaderDefault"
|
android:text="@string/settingsDateTimeHeaderDefault"
|
||||||
android:textColor="?attr/selectedTextColor"/>
|
android:textColor="?attr/selectedTextColor"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -137,30 +150,31 @@
|
|||||||
android:id="@+id/counterBadgeFrame"
|
android:id="@+id/counterBadgeFrame"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="25dp"
|
android:orientation="horizontal"
|
||||||
android:orientation="horizontal">
|
android:paddingTop="10dp"
|
||||||
|
android:paddingBottom="10dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvCounterBadgeHeader"
|
android:id="@+id/tvCounterBadgeHeader"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="16sp"
|
|
||||||
android:layout_marginStart="44dp"
|
android:layout_marginStart="44dp"
|
||||||
android:layout_marginEnd="24dp"
|
android:layout_marginEnd="24dp"
|
||||||
android:text="@string/settingsCounterBadges"
|
android:text="@string/settingsCounterBadges"
|
||||||
android:textColor="?attr/primaryTextColor"/>
|
android:textColor="?attr/primaryTextColor"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||||
android:id="@+id/switchCounterBadge"
|
android:id="@+id/switchCounterBadge"
|
||||||
android:layout_toEndOf="@+id/tvCounterBadgeHeader"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:switchMinWidth="56dp"
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:layout_toEndOf="@+id/tvCounterBadgeHeader"
|
||||||
|
android:gravity="end"
|
||||||
android:paddingStart="0dp"
|
android:paddingStart="0dp"
|
||||||
android:paddingEnd="24dp"
|
android:paddingEnd="24dp"
|
||||||
android:layout_alignParentEnd="true"
|
android:switchMinWidth="56dp" />
|
||||||
android:gravity="end"
|
|
||||||
android:layout_gravity="end" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user