mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2023-12-13 20:50:18 +01:00
Fix some formats, reformat
This commit is contained in:
parent
459cddc0da
commit
a250753669
|
@ -13,7 +13,7 @@ line_comment = //
|
|||
block_comment_start = /*
|
||||
block_comment = *
|
||||
block_comment_end = */
|
||||
max_line_length = off
|
||||
max_line_length = 220
|
||||
|
||||
[*.json]
|
||||
indent_size = 2
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
</value>
|
||||
</option>
|
||||
</JavaCodeStyleSettings>
|
||||
<XML>
|
||||
<option name="XML_ALIGN_ATTRIBUTES" value="false" />
|
||||
</XML>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="RIGHT_MARGIN" value="220" />
|
||||
<option name="KEEP_LINE_BREAKS" value="false" />
|
||||
|
@ -23,7 +26,6 @@
|
|||
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
|
||||
<option name="BLANK_LINES_AROUND_FIELD_IN_INTERFACE" value="1" />
|
||||
<option name="BLANK_LINES_AFTER_CLASS_HEADER" value="1" />
|
||||
<option name="BLANK_LINES_AFTER_ANONYMOUS_CLASS_HEADER" value="1" />
|
||||
<option name="BLANK_LINES_BEFORE_CLASS_END" value="1" />
|
||||
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
depends_on:
|
||||
- build
|
||||
- locale
|
||||
- check
|
||||
- build
|
||||
- locale
|
||||
- check
|
||||
|
||||
run_on: [ success, failure ]
|
||||
skip_clone: true
|
||||
|
||||
pipeline:
|
||||
discord:
|
||||
image: appleboy/drone-discord
|
||||
settings:
|
||||
message: "{{#success build.status}} ✅ Build #{{build.number}} of `{{repo.name}}` succeeded.\n\n📝 Commit by {{commit.author}}:\n``` {{commit.message}} ```\n\n🌐 {{ build.link }} {{else}} ❌ Build #{{build.number}} of `{{repo.name}}` failed.\n\n📝 Commit by {{commit.author}}:\n``` {{commit.message}} ```\n\n🌐 {{ build.link }} {{/success}}\n"
|
||||
webhook_id:
|
||||
from_secret:
|
||||
DISCORD_BOT_ID
|
||||
webhook_token:
|
||||
from_secret:
|
||||
DISCORD_BOT_SECRET
|
||||
when:
|
||||
event: [ push ]
|
||||
branch: main
|
||||
discord:
|
||||
image: appleboy/drone-discord
|
||||
settings:
|
||||
message: "{{#success build.status}} ✅ Build #{{build.number}} of `{{repo.name}}` succeeded.\n\n📝 Commit by {{commit.author}}:\n``` {{commit.message}} ```\n\n🌐 {{ build.link }} {{else}} ❌ Build #{{build.number}} of `{{repo.name}}` failed.\n\n📝 Commit by {{commit.author}}:\n``` {{commit.message}} ```\n\n🌐 {{ build.link }} {{/success}}\n"
|
||||
webhook_id:
|
||||
from_secret:
|
||||
DISCORD_BOT_ID
|
||||
webhook_token:
|
||||
from_secret:
|
||||
DISCORD_BOT_SECRET
|
||||
when:
|
||||
event: [ push ]
|
||||
branch: main
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="org.mian.gitnex">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
|
||||
|
||||
<application
|
||||
android:name=".core.MainApplication"
|
||||
|
@ -20,183 +20,183 @@
|
|||
tools:targetApi="n">
|
||||
<activity
|
||||
android:name=".activities.MergePullRequestActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.FileViewActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
<activity
|
||||
android:name=".activities.CreateFileActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
<activity
|
||||
android:name=".activities.RepoWatchersActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
<activity
|
||||
android:name=".activities.RepoStargazersActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
<activity
|
||||
android:name=".activities.AdminGetUsersActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.AdminUnadoptedReposActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CreateReleaseActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.EditIssueActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CreateNewUserActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.MyProfileEmailActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.AddCollaboratorToRepositoryActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CreateTeamByOrgActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.OrganizationTeamInfoActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.OrganizationDetailActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
<activity
|
||||
android:name=".activities.CreateLabelActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CreateIssueActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CreateMilestoneActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.IssueDetailActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:windowSoftInputMode="adjustNothing" />
|
||||
android:windowSoftInputMode="adjustNothing"/>
|
||||
<activity
|
||||
android:name=".activities.RepoDetailActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
<activity
|
||||
android:name=".activities.MainActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@android:style/Theme.NoTitleBar"
|
||||
android:exported="true">
|
||||
android:exported="true"
|
||||
android:theme="@android:style/Theme.NoTitleBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activities.LoginActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@android:style/Theme.NoTitleBar" />
|
||||
android:theme="@android:style/Theme.NoTitleBar"/>
|
||||
<activity
|
||||
android:name=".activities.CreateRepoActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CreateOrganizationActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.DiffActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@android:style/Theme.NoTitleBar" />
|
||||
android:theme="@android:style/Theme.NoTitleBar"/>
|
||||
<activity
|
||||
android:name=".activities.CommitsActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CommitDetailActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:theme="@android:style/Theme.NoTitleBar" />
|
||||
android:theme="@android:style/Theme.NoTitleBar"/>
|
||||
<activity
|
||||
android:name=".activities.SettingsAppearanceActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.ProfileActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.SettingsSecurityActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.SettingsTranslationActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.SettingsReportsActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.AddNewTeamMemberActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.AddNewTeamRepoActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.SettingsDraftsActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.RepoForksActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.AddNewAccountActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.RepositorySettingsActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.CreatePullRequestActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.SettingsGeneralActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.SettingsNotificationsActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.AdminCronTasksActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:name=".activities.WikiActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
|
||||
<activity
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:name=".activities.CodeEditorActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation" />
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:windowSoftInputMode="adjustResize"/>
|
||||
|
||||
<meta-data
|
||||
android:name="com.samsung.android.keepalive.density"
|
||||
android:value="true" /> <!-- Version >= 3.0. DeX Dual Mode support -->
|
||||
android:value="true"/> <!-- Version >= 3.0. DeX Dual Mode support -->
|
||||
<meta-data
|
||||
android:name="com.samsung.android.multidisplay.keep_process_alive"
|
||||
android:value="true" /> <!-- deep links -->
|
||||
android:value="true"/> <!-- deep links -->
|
||||
<activity
|
||||
android:name=".activities.DeepLinksActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask"
|
||||
android:noHistory="true"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
||||
android:exported="true">
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
|
||||
<data android:scheme="http" />
|
||||
<data android:scheme="https" />
|
||||
<data android:host="codeberg.org" />
|
||||
<data android:host="gitea.com" />
|
||||
<data android:host="try.gitea.io" />
|
||||
<data android:host="code.obermui.de" />
|
||||
<data android:host="git.fsfe.org" />
|
||||
<data android:host="opendev.org" />
|
||||
<data android:scheme="http"/>
|
||||
<data android:scheme="https"/>
|
||||
<data android:host="codeberg.org"/>
|
||||
<data android:host="gitea.com"/>
|
||||
<data android:host="try.gitea.io"/>
|
||||
<data android:host="code.obermui.de"/>
|
||||
<data android:host="git.fsfe.org"/>
|
||||
<data android:host="opendev.org"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
|
|
@ -14,11 +14,8 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
public class ActionResult<R> {
|
||||
|
||||
public enum Status {SUCCESS, FAILED}
|
||||
|
||||
private final BlockingQueue<Boolean> blockingQueue;
|
||||
private final List<OnFinishedListener<R>> onFinishedListeners;
|
||||
|
||||
private boolean invalidated = false;
|
||||
|
||||
public ActionResult() {
|
||||
|
@ -74,9 +71,7 @@ public class ActionResult<R> {
|
|||
|
||||
}
|
||||
|
||||
public static class None {
|
||||
|
||||
}
|
||||
public enum Status {SUCCESS, FAILED}
|
||||
|
||||
public interface OnFinishedListener<R> {
|
||||
|
||||
|
@ -84,4 +79,8 @@ public class ActionResult<R> {
|
|||
|
||||
}
|
||||
|
||||
public static class None {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -60,8 +60,8 @@ public class AssigneesActions {
|
|||
});
|
||||
}
|
||||
|
||||
public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List<User> assigneesList, Dialog dialogAssignees,
|
||||
AssigneesListAdapter assigneesAdapter, CustomAssigneesSelectionDialogBinding assigneesBinding) {
|
||||
public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List<User> assigneesList, Dialog dialogAssignees, AssigneesListAdapter assigneesAdapter,
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding) {
|
||||
|
||||
Call<List<User>> call = RetrofitClient.getApiInterface(ctx).repoGetAssignees(repoOwner, repoName);
|
||||
|
||||
|
|
|
@ -68,8 +68,7 @@ public class CollaboratorActions {
|
|||
AddCollaboratorOption permissionString = new AddCollaboratorOption();
|
||||
permissionString.setPermission(permission);
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context)
|
||||
.repoAddCollaborator(repository.getOwner(), repository.getName(), userName, permissionString);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).repoAddCollaborator(repository.getOwner(), repository.getName(), userName, permissionString);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
|
|
@ -35,8 +35,7 @@ public class IssueActions {
|
|||
EditIssueCommentOption commentObj = new EditIssueCommentOption();
|
||||
commentObj.setBody(comment);
|
||||
|
||||
Call<Comment> call = RetrofitClient.getApiInterface(context)
|
||||
.issueEditComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) commentId, commentObj);
|
||||
Call<Comment> call = RetrofitClient.getApiInterface(context).issueEditComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) commentId, commentObj);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -75,8 +74,7 @@ public class IssueActions {
|
|||
|
||||
EditIssueOption issueStatJson = new EditIssueOption();
|
||||
issueStatJson.setState(issueState);
|
||||
Call<Issue> call = RetrofitClient.getApiInterface(ctx)
|
||||
.issueEditIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), issueStatJson);
|
||||
Call<Issue> call = RetrofitClient.getApiInterface(ctx).issueEditIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), issueStatJson);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -109,8 +107,7 @@ public class IssueActions {
|
|||
|
||||
IssueDetailActivity.singleIssueUpdate = true;
|
||||
((IssueDetailActivity) ctx).onResume();
|
||||
if(((Activity) ctx).getIntent().getStringExtra("openedFromLink") == null || !((Activity) ctx).getIntent()
|
||||
.getStringExtra("openedFromLink").equals("true")) {
|
||||
if(((Activity) ctx).getIntent().getStringExtra("openedFromLink") == null || !((Activity) ctx).getIntent().getStringExtra("openedFromLink").equals("true")) {
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
}
|
||||
}
|
||||
|
@ -147,8 +144,7 @@ public class IssueActions {
|
|||
Call<Void> call;
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx)
|
||||
.issueAddSubscription(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(),
|
||||
((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
.issueAddSubscription(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -189,8 +185,7 @@ public class IssueActions {
|
|||
Call<Void> call;
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx)
|
||||
.issueDeleteSubscription(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(),
|
||||
((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
.issueDeleteSubscription(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -233,8 +228,7 @@ public class IssueActions {
|
|||
CreateIssueCommentOption issueComment = new CreateIssueCommentOption();
|
||||
issueComment.setBody(comment);
|
||||
|
||||
Call<Comment> call = RetrofitClient.getApiInterface(context)
|
||||
.issueCreateComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), issueComment);
|
||||
Call<Comment> call = RetrofitClient.getApiInterface(context).issueCreateComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), issueComment);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
|
|
@ -56,8 +56,7 @@ public class LabelsActions {
|
|||
});
|
||||
}
|
||||
|
||||
public static void getRepositoryLabels(Context ctx, String repoOwner, String repoName, List<Label> labelsList, Dialog dialogLabels,
|
||||
LabelsListAdapter labelsAdapter, CustomLabelsSelectionDialogBinding labelsBinding) {
|
||||
public static void getRepositoryLabels(Context ctx, String repoOwner, String repoName, List<Label> labelsList, Dialog dialogLabels, LabelsListAdapter labelsAdapter, CustomLabelsSelectionDialogBinding labelsBinding) {
|
||||
|
||||
Call<List<Label>> call = RetrofitClient.getApiInterface(ctx).issueListLabels(repoOwner, repoName, null, null);
|
||||
|
||||
|
|
|
@ -32,8 +32,7 @@ public class MilestoneActions {
|
|||
|
||||
EditMilestoneOption milestoneStateJson = new EditMilestoneOption();
|
||||
milestoneStateJson.setState(state);
|
||||
Call<Milestone> call = RetrofitClient.getApiInterface(ctx)
|
||||
.issueEditMilestone(repository.getOwner(), repository.getName(), String.valueOf(milestoneId_), milestoneStateJson);
|
||||
Call<Milestone> call = RetrofitClient.getApiInterface(ctx).issueEditMilestone(repository.getOwner(), repository.getName(), String.valueOf(milestoneId_), milestoneStateJson);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
|
|
@ -44,8 +44,7 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
|||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ActivityAddCollaboratorToRepositoryBinding activityAddCollaboratorToRepositoryBinding = ActivityAddCollaboratorToRepositoryBinding.inflate(
|
||||
getLayoutInflater());
|
||||
ActivityAddCollaboratorToRepositoryBinding activityAddCollaboratorToRepositoryBinding = ActivityAddCollaboratorToRepositoryBinding.inflate(getLayoutInflater());
|
||||
setContentView(activityAddCollaboratorToRepositoryBinding.getRoot());
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
|
|
@ -70,8 +70,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||
ArrayAdapter<Protocol> adapterProtocols = new ArrayAdapter<>(ctx, R.layout.list_spinner_items, Protocol.values());
|
||||
|
||||
viewBinding.protocolSpinner.setAdapter(adapterProtocols);
|
||||
viewBinding.protocolSpinner.setOnItemClickListener(
|
||||
(parent, view1, position, id) -> spinnerSelectedValue = String.valueOf(parent.getItemAtPosition(position)));
|
||||
viewBinding.protocolSpinner.setOnItemClickListener((parent, view1, position, id) -> spinnerSelectedValue = String.valueOf(parent.getItemAtPosition(position)));
|
||||
viewBinding.addNewAccount.setOnClickListener(login -> {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
@ -116,8 +115,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||
|
||||
URI rawInstanceUrl = UrlBuilder.fromString(UrlHelper.fixScheme(instanceUrlET, "http")).toUri();
|
||||
|
||||
URI instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(protocol.toLowerCase())
|
||||
.withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/")).toUri();
|
||||
URI instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(protocol.toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/")).toUri();
|
||||
|
||||
versionCheck(instanceUrl.toString(), loginToken);
|
||||
serverPageLimitSettings();
|
||||
|
@ -155,8 +153,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||
if(giteaVersion.less(getString(R.string.versionLow))) {
|
||||
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx).setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setIcon(R.drawable.ic_warning)
|
||||
.setCancelable(true);
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setIcon(R.drawable.ic_warning).setCancelable(true);
|
||||
|
||||
alertDialogBuilder.setNeutralButton(getString(R.string.cancelButton), (dialog, which) -> {
|
||||
|
||||
|
@ -208,8 +205,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||
generalAPISettings.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull final Call<GeneralAPISettings> generalAPISettings,
|
||||
@NonNull retrofit2.Response<GeneralAPISettings> response) {
|
||||
public void onResponse(@NonNull final Call<GeneralAPISettings> generalAPISettings, @NonNull retrofit2.Response<GeneralAPISettings> response) {
|
||||
|
||||
if(response.code() == 200 && response.body() != null) {
|
||||
|
||||
|
@ -251,8 +247,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
|||
|
||||
if(!userAccountExists) {
|
||||
|
||||
long id = userAccountsApi.createNewAccount(accountName, instanceUrl, userDetails.getLogin(), loginToken,
|
||||
giteaVersion.toString(), maxResponseItems, defaultPagingNumber);
|
||||
long id = userAccountsApi.createNewAccount(accountName, instanceUrl, userDetails.getLogin(), loginToken, giteaVersion.toString(), maxResponseItems, defaultPagingNumber);
|
||||
UserAccount account = userAccountsApi.getAccountById((int) id);
|
||||
AppUtil.switchToAccount(AddNewAccountActivity.this, account);
|
||||
Toasty.success(ctx, getResources().getString(R.string.accountAddedMessage));
|
||||
|
|
|
@ -51,8 +51,7 @@ public class AddNewTeamRepoActivity extends BaseActivity {
|
|||
addNewTeamRepositoryBinding.recyclerViewTeamRepos.setHasFixedSize(true);
|
||||
addNewTeamRepositoryBinding.recyclerViewTeamRepos.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(addNewTeamRepositoryBinding.recyclerViewTeamRepos.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(addNewTeamRepositoryBinding.recyclerViewTeamRepos.getContext(), DividerItemDecoration.VERTICAL);
|
||||
addNewTeamRepositoryBinding.recyclerViewTeamRepos.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
dataList = new ArrayList<>();
|
||||
|
@ -79,8 +78,7 @@ public class AddNewTeamRepoActivity extends BaseActivity {
|
|||
dataList.clear();
|
||||
dataList.addAll(response.body());
|
||||
|
||||
adapter = new TeamRepositoriesAdapter(dataList, ctx, Math.toIntExact(teamId), getIntent().getStringExtra("orgName"),
|
||||
teamName);
|
||||
adapter = new TeamRepositoriesAdapter(dataList, ctx, Math.toIntExact(teamId), getIntent().getStringExtra("orgName"), teamName);
|
||||
|
||||
addNewTeamRepositoryBinding.recyclerViewTeamRepos.setAdapter(adapter);
|
||||
addNewTeamRepositoryBinding.noData.setVisibility(View.GONE);
|
||||
|
|
|
@ -20,13 +20,11 @@ import org.mian.gitnex.viewmodels.AdminCronTasksViewModel;
|
|||
|
||||
public class AdminCronTasksActivity extends BaseActivity {
|
||||
|
||||
private final int PAGE = 1;
|
||||
private AdminCronTasksViewModel adminCronTasksViewModel;
|
||||
private View.OnClickListener onClickListener;
|
||||
private AdminCronTasksAdapter adapter;
|
||||
|
||||
private ActivityAdminCronTasksBinding activityAdminCronTasksBinding;
|
||||
|
||||
private final int PAGE = 1;
|
||||
private int resultLimit;
|
||||
|
||||
@Override
|
||||
|
@ -48,8 +46,7 @@ public class AdminCronTasksActivity extends BaseActivity {
|
|||
activityAdminCronTasksBinding.recyclerView.setHasFixedSize(true);
|
||||
activityAdminCronTasksBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAdminCronTasksBinding.recyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAdminCronTasksBinding.recyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||
activityAdminCronTasksBinding.recyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
activityAdminCronTasksBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
|
|
@ -55,8 +55,7 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
|
|||
|
||||
activityAdminGetUsersBinding.recyclerView.setHasFixedSize(true);
|
||||
activityAdminGetUsersBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAdminGetUsersBinding.recyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(activityAdminGetUsersBinding.recyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||
activityAdminGetUsersBinding.recyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
activityAdminGetUsersBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
@ -70,8 +69,6 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetLi
|
|||
fetchDataAsync();
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
private void fetchDataAsync() {
|
||||
|
||||
AdminGetUsersViewModel adminUsersModel = new ViewModelProvider(this).get(AdminGetUsersViewModel.class);
|
||||
|
|
|
@ -45,8 +45,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
break;
|
||||
case 2:
|
||||
|
||||
if(TimeHelper.timeBetweenHours(tinyDB.getInt("darkThemeTimeHour", 18), tinyDB.getInt("lightThemeTimeHour", 6),
|
||||
tinyDB.getInt("darkThemeTimeMinute", 0), tinyDB.getInt("lightThemeTimeMinute", 0))) {
|
||||
if(TimeHelper.timeBetweenHours(tinyDB.getInt("darkThemeTimeHour", 18), tinyDB.getInt("lightThemeTimeHour", 6), tinyDB.getInt("darkThemeTimeMinute", 0), tinyDB.getInt("lightThemeTimeMinute", 0))) {
|
||||
|
||||
setTheme(R.style.AppTheme);
|
||||
}
|
||||
|
@ -60,8 +59,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
setTheme(R.style.AppThemeRetro);
|
||||
break;
|
||||
case 4:
|
||||
if(TimeHelper.timeBetweenHours(tinyDB.getInt("darkThemeTimeHour", 18), tinyDB.getInt("lightThemeTimeHour", 6),
|
||||
tinyDB.getInt("darkThemeTimeMinute", 0), tinyDB.getInt("lightThemeTimeMinute", 0))) {
|
||||
if(TimeHelper.timeBetweenHours(tinyDB.getInt("darkThemeTimeHour", 18), tinyDB.getInt("lightThemeTimeHour", 6), tinyDB.getInt("darkThemeTimeMinute", 0), tinyDB.getInt("lightThemeTimeMinute", 0))) {
|
||||
|
||||
setTheme(R.style.AppTheme);
|
||||
}
|
||||
|
@ -126,8 +124,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
|
||||
});
|
||||
|
||||
BiometricPrompt.PromptInfo biometricPromptBuilder = new BiometricPrompt.PromptInfo.Builder().setTitle(
|
||||
getString(R.string.biometricAuthTitle)).setSubtitle(getString(R.string.biometricAuthSubTitle))
|
||||
BiometricPrompt.PromptInfo biometricPromptBuilder = new BiometricPrompt.PromptInfo.Builder().setTitle(getString(R.string.biometricAuthTitle)).setSubtitle(getString(R.string.biometricAuthSubTitle))
|
||||
.setNegativeButtonText(getString(R.string.cancelButton)).build();
|
||||
|
||||
biometricPrompt.authenticate(biometricPromptBuilder);
|
||||
|
|
|
@ -23,10 +23,10 @@ import java.util.Map;
|
|||
|
||||
public class CodeEditorActivity extends BaseActivity {
|
||||
|
||||
private ActivityCodeEditorBinding binding;
|
||||
private LanguageManager languageManager;
|
||||
private final LanguageName currentLanguage = LanguageName.JAVA;
|
||||
private final ThemeName currentTheme = ThemeName.FIVE_COLOR;
|
||||
private ActivityCodeEditorBinding binding;
|
||||
private LanguageManager languageManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
|
|
@ -38,17 +38,16 @@ import retrofit2.Response;
|
|||
|
||||
public class CommitsActivity extends BaseActivity {
|
||||
|
||||
private final String TAG = "CommitsActivity";
|
||||
public RepositoryContext repository;
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView noData;
|
||||
private ProgressBar progressBar;
|
||||
private final String TAG = "CommitsActivity";
|
||||
private int resultLimit;
|
||||
private int pageSize = 1;
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
private List<Commit> commitsList;
|
||||
private CommitsAdapter adapter;
|
||||
public RepositoryContext repository;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
|
|
@ -36,19 +36,14 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
private ActivityCreateFileBinding binding;
|
||||
|
||||
public static final int FILE_ACTION_CREATE = 0;
|
||||
public static final int FILE_ACTION_DELETE = 1;
|
||||
public static final int FILE_ACTION_EDIT = 2;
|
||||
|
||||
private final List<String> branches = new ArrayList<>();
|
||||
private ActivityCreateFileBinding binding;
|
||||
private int fileAction = FILE_ACTION_CREATE;
|
||||
|
||||
private String filePath;
|
||||
private String fileSha;
|
||||
|
||||
private final List<String> branches = new ArrayList<>();
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
|
@ -121,8 +116,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||
disableProcessButton();
|
||||
|
||||
NetworkStatusObserver networkStatusObserver = NetworkStatusObserver.getInstance(ctx);
|
||||
networkStatusObserver.registerNetworkStatusListener(
|
||||
hasNetworkConnection -> runOnUiThread(() -> binding.newFileCreate.setEnabled(hasNetworkConnection)));
|
||||
networkStatusObserver.registerNetworkStatusListener(hasNetworkConnection -> runOnUiThread(() -> binding.newFileCreate.setEnabled(hasNetworkConnection)));
|
||||
|
||||
binding.newFileCreate.setOnClickListener(v -> processNewFile());
|
||||
|
||||
|
@ -160,8 +154,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||
switch(fileAction) {
|
||||
|
||||
case FILE_ACTION_CREATE:
|
||||
createNewFile(repository.getOwner(), repository.getName(), newFileName, AppUtil.encodeBase64(newFileContent), newFileCommitMessage,
|
||||
newFileBranchName);
|
||||
createNewFile(repository.getOwner(), repository.getName(), newFileName, AppUtil.encodeBase64(newFileContent), newFileCommitMessage, newFileBranchName);
|
||||
break;
|
||||
|
||||
case FILE_ACTION_DELETE:
|
||||
|
@ -169,8 +162,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||
break;
|
||||
|
||||
case FILE_ACTION_EDIT:
|
||||
editFile(repository.getOwner(), repository.getName(), filePath, AppUtil.encodeBase64(newFileContent), newFileCommitMessage,
|
||||
newFileBranchName, fileSha);
|
||||
editFile(repository.getOwner(), repository.getName(), filePath, AppUtil.encodeBase64(newFileContent), newFileCommitMessage, newFileBranchName, fileSha);
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -295,8 +287,7 @@ public class CreateFileActivity extends BaseActivity {
|
|||
|
||||
}
|
||||
|
||||
private void editFile(String repoOwner, String repoName, String fileName, String fileContent, String fileCommitMessage, String branchName,
|
||||
String fileSha) {
|
||||
private void editFile(String repoOwner, String repoName, String fileName, String fileContent, String fileCommitMessage, String branchName, String fileSha) {
|
||||
|
||||
UpdateFileOptions editFileJsonStr = new UpdateFileOptions();
|
||||
editFileJsonStr.setContent(fileContent);
|
||||
|
|
|
@ -49,6 +49,9 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreateIssueActivity extends BaseActivity implements View.OnClickListener, LabelsListAdapter.LabelsListAdapterListener, AssigneesListAdapter.AssigneesListAdapterListener {
|
||||
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
private final LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
private final List<User> assigneesList = new ArrayList<>();
|
||||
private ActivityCreateIssueBinding viewBinding;
|
||||
private CustomLabelsSelectionDialogBinding labelsBinding;
|
||||
private CustomAssigneesSelectionDialogBinding assigneesBinding;
|
||||
|
@ -60,16 +63,10 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
private String assigneesSetter;
|
||||
private int milestoneId;
|
||||
private Date currentDate = null;
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
private AssigneesListAdapter assigneesAdapter;
|
||||
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
private final LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
private final List<User> assigneesList = new ArrayList<>();
|
||||
private List<String> assigneesListData = new ArrayList<>();
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
|
@ -178,8 +175,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
assigneesBinding.save.setOnClickListener(assigneesBinding_ -> dialogAssignees.dismiss());
|
||||
|
||||
dialogAssignees.show();
|
||||
AssigneesActions.getRepositoryAssignees(ctx, repository.getOwner(), repository.getName(), assigneesList, dialogAssignees, assigneesAdapter,
|
||||
assigneesBinding);
|
||||
AssigneesActions.getRepositoryAssignees(ctx, repository.getOwner(), repository.getName(), assigneesList, dialogAssignees, assigneesAdapter, assigneesBinding);
|
||||
}
|
||||
|
||||
private void showLabels() {
|
||||
|
@ -226,8 +222,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
createNewIssueFunc(repository.getOwner(), repository.getName(), newIssueDescriptionForm, milestoneId, newIssueTitleForm);
|
||||
}
|
||||
|
||||
private void createNewIssueFunc(String repoOwner, String repoName, String newIssueDescriptionForm, int newIssueMilestoneIdForm,
|
||||
String newIssueTitleForm) {
|
||||
private void createNewIssueFunc(String repoOwner, String repoName, String newIssueDescriptionForm, int newIssueMilestoneIdForm, String newIssueTitleForm) {
|
||||
|
||||
ArrayList<Long> labelIds = new ArrayList<>();
|
||||
for(Integer i : labelsIds) {
|
||||
|
@ -319,8 +314,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreateIssueActivity.this, R.layout.list_spinner_items,
|
||||
new ArrayList<>(milestonesList.keySet()));
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreateIssueActivity.this, R.layout.list_spinner_items, new ArrayList<>(milestonesList.keySet()));
|
||||
|
||||
viewBinding.newIssueMilestoneSpinner.setAdapter(adapter);
|
||||
enableProcessButton();
|
||||
|
@ -330,8 +324,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
|||
milestoneId = 0;
|
||||
}
|
||||
else if(view instanceof TextView) {
|
||||
milestoneId = Math.toIntExact(
|
||||
Objects.requireNonNull(milestonesList.get(((TextView) view).getText().toString())).getId());
|
||||
milestoneId = Math.toIntExact(Objects.requireNonNull(milestonesList.get(((TextView) view).getText().toString())).getId());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -47,7 +47,9 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
|
||||
private RepositoryContext repository;
|
||||
private String labelColor = "";
|
||||
private final View.OnClickListener createLabelListener = v -> processCreateLabel();
|
||||
private String labelColorDefault = "";
|
||||
private final View.OnClickListener updateLabelListener = v -> processUpdateLabel();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -121,10 +123,6 @@ public class CreateLabelActivity extends BaseActivity {
|
|||
|
||||
}
|
||||
|
||||
private final View.OnClickListener createLabelListener = v -> processCreateLabel();
|
||||
|
||||
private final View.OnClickListener updateLabelListener = v -> processUpdateLabel();
|
||||
|
||||
private void processUpdateLabel() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
|
|
@ -41,6 +41,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||
private RepositoryContext repository;
|
||||
|
||||
private Date currentDate = null;
|
||||
private final View.OnClickListener createMilestoneListener = v -> processNewMilestone();
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
|
@ -92,8 +93,6 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
|||
|
||||
}
|
||||
|
||||
private final View.OnClickListener createMilestoneListener = v -> processNewMilestone();
|
||||
|
||||
private void processNewMilestone() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
|
|
@ -33,6 +33,7 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||
private EditText userEmail;
|
||||
private EditText userPassword;
|
||||
private Button createUserButton;
|
||||
private final View.OnClickListener createNewUserListener = v -> processCreateNewUser();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -172,8 +173,6 @@ public class CreateNewUserActivity extends BaseActivity {
|
|||
|
||||
}
|
||||
|
||||
private final View.OnClickListener createNewUserListener = v -> processCreateNewUser();
|
||||
|
||||
private void initCloseListener() {
|
||||
|
||||
onClickListener = view -> finish();
|
||||
|
|
|
@ -35,6 +35,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||
|
||||
private EditText orgName;
|
||||
private EditText orgDesc;
|
||||
private final View.OnClickListener createOrgListener = v -> processNewOrganization();
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
|
@ -89,8 +90,6 @@ public class CreateOrganizationActivity extends BaseActivity {
|
|||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
private final View.OnClickListener createOrgListener = v -> processNewOrganization();
|
||||
|
||||
private void processNewOrganization() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
|
|
@ -43,23 +43,20 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreatePullRequestActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener {
|
||||
|
||||
private final List<String> assignees = new ArrayList<>();
|
||||
LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
List<String> branchesList = new ArrayList<>();
|
||||
List<Label> labelsList = new ArrayList<>();
|
||||
private View.OnClickListener onClickListener;
|
||||
private ActivityCreatePrBinding viewBinding;
|
||||
private int resultLimit;
|
||||
private Dialog dialogLabels;
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private final List<String> assignees = new ArrayList<>();
|
||||
private int milestoneId;
|
||||
private Date currentDate = null;
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
|
||||
LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
List<String> branchesList = new ArrayList<>();
|
||||
List<Label> labelsList = new ArrayList<>();
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -162,8 +159,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
createPullRequest.setLabels(labelIds);
|
||||
createPullRequest.setDueDate(currentDate);
|
||||
|
||||
Call<PullRequest> transferCall = RetrofitClient.getApiInterface(ctx)
|
||||
.repoCreatePullRequest(repository.getOwner(), repository.getName(), createPullRequest);
|
||||
Call<PullRequest> transferCall = RetrofitClient.getApiInterface(ctx).repoCreatePullRequest(repository.getOwner(), repository.getName(), createPullRequest);
|
||||
|
||||
transferCall.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -228,8 +224,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
dialogLabels.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding labelsBinding = CustomLabelsSelectionDialogBinding.inflate(
|
||||
LayoutInflater.from(ctx));
|
||||
org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding labelsBinding = CustomLabelsSelectionDialogBinding.inflate(LayoutInflater.from(ctx));
|
||||
|
||||
View view = labelsBinding.getRoot();
|
||||
dialogLabels.setContentView(view);
|
||||
|
@ -293,8 +288,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
|
||||
List<Milestone> milestonesList_ = response.body();
|
||||
|
||||
milestonesList.put(getString(R.string.issueCreatedNoMilestone),
|
||||
new Milestone().id(0L).title(getString(R.string.issueCreatedNoMilestone)));
|
||||
milestonesList.put(getString(R.string.issueCreatedNoMilestone), new Milestone().id(0L).title(getString(R.string.issueCreatedNoMilestone)));
|
||||
assert milestonesList_ != null;
|
||||
|
||||
if(milestonesList_.size() > 0) {
|
||||
|
@ -308,8 +302,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
|
|||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreatePullRequestActivity.this, R.layout.list_spinner_items,
|
||||
new ArrayList<>(milestonesList.keySet()));
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(CreatePullRequestActivity.this, R.layout.list_spinner_items, new ArrayList<>(milestonesList.keySet()));
|
||||
|
||||
viewBinding.milestonesSpinner.setAdapter(adapter);
|
||||
enableProcessButton();
|
||||
|
|
|
@ -38,8 +38,9 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreateReleaseActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
public ImageView closeActivity;
|
||||
List<String> branchesList = new ArrayList<>();
|
||||
private View.OnClickListener onClickListener;
|
||||
private EditText releaseTagName;
|
||||
private AutoCompleteTextView releaseBranch;
|
||||
private EditText releaseTitle;
|
||||
|
@ -49,10 +50,8 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
private Button createNewRelease;
|
||||
private String selectedBranch;
|
||||
private Button createNewTag;
|
||||
|
||||
private RepositoryContext repository;
|
||||
|
||||
List<String> branchesList = new ArrayList<>();
|
||||
private final View.OnClickListener createReleaseListener = v -> processNewRelease();
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
|
@ -182,8 +181,6 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
});
|
||||
}
|
||||
|
||||
private final View.OnClickListener createReleaseListener = v -> processNewRelease();
|
||||
|
||||
private void processNewRelease() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
@ -220,12 +217,11 @@ public class CreateReleaseActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
disableProcessButton();
|
||||
createNewReleaseFunc(repository.getOwner(), repository.getName(), newReleaseTagName, newReleaseTitle, newReleaseContent, selectedBranch,
|
||||
newReleaseType, newReleaseDraft);
|
||||
createNewReleaseFunc(repository.getOwner(), repository.getName(), newReleaseTagName, newReleaseTitle, newReleaseContent, selectedBranch, newReleaseType, newReleaseDraft);
|
||||
}
|
||||
|
||||
private void createNewReleaseFunc(String repoOwner, String repoName, String newReleaseTagName, String newReleaseTitle, String newReleaseContent,
|
||||
String selectedBranch, boolean newReleaseType, boolean newReleaseDraft) {
|
||||
private void createNewReleaseFunc(String repoOwner, String repoName, String newReleaseTagName, String newReleaseTitle, String newReleaseContent, String selectedBranch, boolean newReleaseType,
|
||||
boolean newReleaseDraft) {
|
||||
|
||||
CreateReleaseOption createReleaseJson = new CreateReleaseOption();
|
||||
createReleaseJson.setName(newReleaseTitle);
|
||||
|
|
|
@ -36,23 +36,20 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
//https://github.com/go-gitea/gitea/blob/52cfd2743c0e85b36081cf80a850e6a5901f1865/models/repo.go#L964-L967
|
||||
final List<String> reservedRepoNames = Arrays.asList(".", "..");
|
||||
final Pattern reservedRepoPatterns = Pattern.compile("\\.(git|wiki)$");
|
||||
public ImageView closeActivity;
|
||||
List<String> organizationsList = new ArrayList<>();
|
||||
private View.OnClickListener onClickListener;
|
||||
private AutoCompleteTextView spinner;
|
||||
private Button createRepo;
|
||||
private EditText repoName;
|
||||
private EditText repoDesc;
|
||||
private CheckBox repoAccess;
|
||||
|
||||
private String loginUid;
|
||||
|
||||
private String selectedOwner;
|
||||
|
||||
List<String> organizationsList = new ArrayList<>();
|
||||
|
||||
//https://github.com/go-gitea/gitea/blob/52cfd2743c0e85b36081cf80a850e6a5901f1865/models/repo.go#L964-L967
|
||||
final List<String> reservedRepoNames = Arrays.asList(".", "..");
|
||||
final Pattern reservedRepoPatterns = Pattern.compile("\\.(git|wiki)$");
|
||||
private final View.OnClickListener createRepoListener = v -> processNewRepo();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -96,8 +93,6 @@ public class CreateRepoActivity extends BaseActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private final View.OnClickListener createRepoListener = v -> processNewRepo();
|
||||
|
||||
private void processNewRepo() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
|
|
@ -33,6 +33,10 @@ import retrofit2.Callback;
|
|||
|
||||
public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClickListener {
|
||||
|
||||
private final String[] permissionList = {"Read", "Write", "Admin"};
|
||||
private final String[] accessControlsList = new String[]{"Code", "Issues", "Pull Request", "Releases", "Wiki", "External Wiki", "External Issues"};
|
||||
private final boolean[] selectedAccessControlsTrueFalse = new boolean[]{false, false, false, false, false, false, false};
|
||||
public int permissionSelectedChoice = -1;
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView teamName;
|
||||
private TextView teamDesc;
|
||||
|
@ -41,16 +45,8 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
private TextView teamAccessControls;
|
||||
private TextView teamAccessControlsArray;
|
||||
private Button createTeamButton;
|
||||
private final String[] permissionList = {"Read", "Write", "Admin"};
|
||||
public int permissionSelectedChoice = -1;
|
||||
|
||||
private final String[] accessControlsList = new String[]{"Code", "Issues", "Pull Request", "Releases", "Wiki", "External Wiki",
|
||||
"External Issues"};
|
||||
|
||||
private List<String> pushAccessList;
|
||||
|
||||
private final boolean[] selectedAccessControlsTrueFalse = new boolean[]{false, false, false, false, false, false, false};
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
|
@ -161,10 +157,8 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
|
||||
if(value) {
|
||||
|
||||
teamAccessControls.setText(
|
||||
getString(R.string.newTeamPermissionValues, teamAccessControls.getText(), pushAccessList.get(selectedVal)));
|
||||
teamAccessControlsArray.setText(
|
||||
getString(R.string.newTeamPermissionValuesFinal, teamAccessControlsArray.getText(), repoCode));
|
||||
teamAccessControls.setText(getString(R.string.newTeamPermissionValues, teamAccessControls.getText(), pushAccessList.get(selectedVal)));
|
||||
teamAccessControlsArray.setText(getString(R.string.newTeamPermissionValuesFinal, teamAccessControlsArray.getText(), repoCode));
|
||||
}
|
||||
|
||||
selectedVal++;
|
||||
|
@ -264,8 +258,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
|||
createNewTeamCall(orgName, newTeamName, newTeamDesc, newTeamPermission, newTeamAccessControls_);
|
||||
}
|
||||
|
||||
private void createNewTeamCall(String orgName, String newTeamName, String newTeamDesc, String newTeamPermission,
|
||||
List<String> newTeamAccessControls) {
|
||||
private void createNewTeamCall(String orgName, String newTeamName, String newTeamDesc, String newTeamPermission, List<String> newTeamAccessControls) {
|
||||
|
||||
CreateTeamOption createNewTeamJson = new CreateTeamOption();
|
||||
createNewTeamJson.setName(newTeamName);
|
||||
|
|
|
@ -174,9 +174,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
issueIntent.putExtra("issueComment", urlSplitted[1]);
|
||||
}
|
||||
|
||||
IssueContext issue = new IssueContext(
|
||||
new RepositoryContext(data.getPathSegments().get(0), data.getPathSegments().get(1), ctx),
|
||||
Integer.parseInt(data.getLastPathSegment()), "Issue");
|
||||
IssueContext issue = new IssueContext(new RepositoryContext(data.getPathSegments().get(0), data.getPathSegments().get(1), ctx), Integer.parseInt(data.getLastPathSegment()), "Issue");
|
||||
|
||||
issue.getRepository().saveToDB(ctx);
|
||||
|
||||
|
@ -186,12 +184,10 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
finish();
|
||||
}
|
||||
else if(Objects.requireNonNull(data.getLastPathSegment()).contains("issues")) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "issue"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "issue"), 500);
|
||||
}
|
||||
else if(data.getLastPathSegment().equals("new")) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "issueNew"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "issueNew"), 500);
|
||||
}
|
||||
else {
|
||||
ctx.startActivity(mainIntent);
|
||||
|
@ -214,14 +210,12 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
|
||||
}
|
||||
else if(Objects.requireNonNull(data.getLastPathSegment()).contains("pulls")) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "pull"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "pull"), 500);
|
||||
}
|
||||
else if(data.getLastPathSegment().equals("files")) { // pr diff
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
issueIntent.putExtra("openPrDiff", "true");
|
||||
getPullRequest(data.getPathSegments().get(0), data.getPathSegments().get(1),
|
||||
Integer.parseInt(data.getPathSegments().get(3)));
|
||||
getPullRequest(data.getPathSegments().get(0), data.getPathSegments().get(1), Integer.parseInt(data.getPathSegments().get(3)));
|
||||
}, 500);
|
||||
}
|
||||
else {
|
||||
|
@ -231,36 +225,29 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
else if(data.getPathSegments().get(2).equals("compare")) { // new pull request
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "pullNew"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "pullNew"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("commit")) {
|
||||
repoIntent.putExtra("sha", data.getLastPathSegment());
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "commit"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "commit"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("commits")) { // commits list
|
||||
String branch = data.getLastPathSegment();
|
||||
repoIntent.putExtra("branchName", branch);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "commitsList"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "commitsList"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("milestones") && data.getLastPathSegment().equals("new")) { // new milestone
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestonesNew"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestonesNew"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("milestones")) { // milestones
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("milestone")) { // milestone
|
||||
repoIntent.putExtra("milestoneId", data.getLastPathSegment());
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "milestones"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("releases") && data.getLastPathSegment().equals("new")) { // new release
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "newRelease"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "newRelease"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("releases")) { // releases
|
||||
if(data.getPathSegments().size() == 5) {
|
||||
|
@ -268,26 +255,20 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
repoIntent.putExtra("releaseTagName", data.getLastPathSegment());
|
||||
}
|
||||
}
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "releases"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "releases"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("labels")) { // labels
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "labels"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "labels"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("settings")) { // repo settings
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "settings"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "settings"), 500);
|
||||
}
|
||||
else if(data.getLastPathSegment().equals("branches")) { // branches list
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "branchesList"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "branchesList"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().size() == 5 && data.getPathSegments().get(2).equals("src") && data.getPathSegments().get(3)
|
||||
.equals("branch")) { // branch
|
||||
else if(data.getPathSegments().size() == 5 && data.getPathSegments().get(2).equals("src") && data.getPathSegments().get(3).equals("branch")) { // branch
|
||||
repoIntent.putExtra("selectedBranch", data.getLastPathSegment());
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "branch"), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> goToRepoSection(data.getPathSegments().get(0), data.getPathSegments().get(1), "branch"), 500);
|
||||
}
|
||||
else if(data.getPathSegments().get(2).equals("src") && data.getPathSegments().get(3).equals("branch")) { // file/dir
|
||||
StringBuilder filePath = new StringBuilder();
|
||||
|
@ -298,9 +279,7 @@ public class DeepLinksActivity extends BaseActivity {
|
|||
filePath.append("/");
|
||||
}
|
||||
filePath.deleteCharAt(filePath.toString().length() - 1);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> getFile(data.getPathSegments().get(0), data.getPathSegments().get(1), filePath.toString(),
|
||||
data.getPathSegments().get(4)), 500);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> getFile(data.getPathSegments().get(0), data.getPathSegments().get(1), filePath.toString(), data.getPathSegments().get(4)), 500);
|
||||
}
|
||||
else { // no action, show options
|
||||
showNoActionButtons();
|
||||
|
|
|
@ -48,20 +48,18 @@ import retrofit2.Callback;
|
|||
|
||||
public class EditIssueActivity extends BaseActivity implements View.OnClickListener {
|
||||
|
||||
private final String msState = "open";
|
||||
private View.OnClickListener onClickListener;
|
||||
private int resultLimit;
|
||||
|
||||
private EditText editIssueTitle;
|
||||
private EditText editIssueDescription;
|
||||
private TextView editIssueDueDate;
|
||||
private Button editIssueButton;
|
||||
private AutoCompleteTextView editIssueMilestoneSpinner;
|
||||
|
||||
private final String msState = "open";
|
||||
private int milestoneId = 0;
|
||||
private Date currentDate = null;
|
||||
|
||||
private LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
private final LinkedHashMap<String, Milestone> milestonesList = new LinkedHashMap<>();
|
||||
|
||||
private IssueContext issue;
|
||||
|
||||
|
@ -152,8 +150,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||
}
|
||||
|
||||
disableProcessButton();
|
||||
editIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getIssueIndex(), editIssueTitleForm,
|
||||
editIssueDescriptionForm, milestoneId);
|
||||
editIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getIssueIndex(), editIssueTitleForm, editIssueDescriptionForm, milestoneId);
|
||||
}
|
||||
|
||||
private void editIssue(String repoOwner, String repoName, int issueIndex, String title, String description, int milestoneId) {
|
||||
|
@ -254,8 +251,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||
// get milestones list
|
||||
if(response.body().getId() > 0) {
|
||||
|
||||
Call<List<Milestone>> call_ = RetrofitClient.getApiInterface(ctx)
|
||||
.issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
Call<List<Milestone>> call_ = RetrofitClient.getApiInterface(ctx).issueGetMilestonesList(repoOwner, repoName, msState, null, 1, resultLimit);
|
||||
|
||||
call_.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -284,8 +280,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(EditIssueActivity.this, R.layout.list_spinner_items,
|
||||
new ArrayList<>(milestonesList.keySet()));
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(EditIssueActivity.this, R.layout.list_spinner_items, new ArrayList<>(milestonesList.keySet()));
|
||||
|
||||
editIssueMilestoneSpinner.setAdapter(adapter);
|
||||
|
||||
|
@ -294,8 +289,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
|||
milestoneId = 0;
|
||||
}
|
||||
else if(view instanceof TextView) {
|
||||
milestoneId = Math.toIntExact(
|
||||
Objects.requireNonNull(milestonesList.get(((TextView) view).getText().toString())).getId());
|
||||
milestoneId = Math.toIntExact(Objects.requireNonNull(milestonesList.get(((TextView) view).getText().toString())).getId());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -48,25 +48,82 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
|||
private ActivityFileViewBinding binding;
|
||||
private ContentsResponse file;
|
||||
private RepositoryContext repository;
|
||||
ActivityResultLauncher<Intent> activityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
|
||||
if(result.getResultCode() == Activity.RESULT_OK) {
|
||||
|
||||
assert result.getData() != null;
|
||||
|
||||
try {
|
||||
|
||||
OutputStream outputStream = getContentResolver().openOutputStream(result.getData().getData());
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx, ctx.getPackageName()).setContentTitle(getString(R.string.fileViewerNotificationTitleStarted))
|
||||
.setContentText(getString(R.string.fileViewerNotificationDescriptionStarted, file.getName())).setSmallIcon(R.drawable.gitnex_transparent).setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
.setChannelId(Constants.downloadNotificationChannelId).setProgress(100, 0, false).setOngoing(true);
|
||||
|
||||
int notificationId = Notifications.uniqueNotificationId(ctx);
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
|
||||
Thread thread = new Thread(() -> {
|
||||
|
||||
try {
|
||||
|
||||
Call<ResponseBody> call = RetrofitClient.getWebInterface(ctx).getFileContents(repository.getOwner(), repository.getName(), repository.getBranchRef(), file.getPath());
|
||||
|
||||
Response<ResponseBody> response = call.execute();
|
||||
|
||||
assert response.body() != null;
|
||||
|
||||
AppUtil.copyProgress(response.body().byteStream(), outputStream, file.getSize(), progress -> {
|
||||
builder.setProgress(100, progress, false);
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
});
|
||||
|
||||
builder.setContentTitle(getString(R.string.fileViewerNotificationTitleFinished)).setContentText(getString(R.string.fileViewerNotificationDescriptionFinished, file.getName()));
|
||||
|
||||
}
|
||||
catch(IOException ignored) {
|
||||
|
||||
builder.setContentTitle(getString(R.string.fileViewerNotificationTitleFailed)).setContentText(getString(R.string.fileViewerNotificationDescriptionFailed, file.getName()));
|
||||
|
||||
}
|
||||
finally {
|
||||
|
||||
builder.setProgress(0, 0, false).setOngoing(false);
|
||||
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
thread.start();
|
||||
|
||||
}
|
||||
catch(IOException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
private boolean renderMd = false;
|
||||
private boolean processable = false;
|
||||
|
||||
public ActivityResultLauncher<Intent> editFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("fileModified", false)) {
|
||||
switch(result.getData().getIntExtra("fileAction", CreateFileActivity.FILE_ACTION_EDIT)) {
|
||||
case CreateFileActivity.FILE_ACTION_CREATE:
|
||||
case CreateFileActivity.FILE_ACTION_EDIT:
|
||||
getSingleFileContents(repository.getOwner(), repository.getName(), file.getPath(), repository.getBranchRef());
|
||||
break;
|
||||
default:
|
||||
finish();
|
||||
}
|
||||
public ActivityResultLauncher<Intent> editFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("fileModified", false)) {
|
||||
switch(result.getData().getIntExtra("fileAction", CreateFileActivity.FILE_ACTION_EDIT)) {
|
||||
case CreateFileActivity.FILE_ACTION_CREATE:
|
||||
case CreateFileActivity.FILE_ACTION_EDIT:
|
||||
getSingleFileContents(repository.getOwner(), repository.getName(), file.getPath(), repository.getBranchRef());
|
||||
break;
|
||||
default:
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -328,73 +385,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetListene
|
|||
|
||||
}
|
||||
|
||||
ActivityResultLauncher<Intent> activityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
|
||||
if(result.getResultCode() == Activity.RESULT_OK) {
|
||||
|
||||
assert result.getData() != null;
|
||||
|
||||
try {
|
||||
|
||||
OutputStream outputStream = getContentResolver().openOutputStream(result.getData().getData());
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx, ctx.getPackageName()).setContentTitle(
|
||||
getString(R.string.fileViewerNotificationTitleStarted))
|
||||
.setContentText(getString(R.string.fileViewerNotificationDescriptionStarted, file.getName()))
|
||||
.setSmallIcon(R.drawable.gitnex_transparent).setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
.setChannelId(Constants.downloadNotificationChannelId).setProgress(100, 0, false).setOngoing(true);
|
||||
|
||||
int notificationId = Notifications.uniqueNotificationId(ctx);
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
;
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
|
||||
Thread thread = new Thread(() -> {
|
||||
|
||||
try {
|
||||
|
||||
Call<ResponseBody> call = RetrofitClient.getWebInterface(ctx)
|
||||
.getFileContents(repository.getOwner(), repository.getName(), repository.getBranchRef(), file.getPath());
|
||||
|
||||
Response<ResponseBody> response = call.execute();
|
||||
|
||||
assert response.body() != null;
|
||||
|
||||
AppUtil.copyProgress(response.body().byteStream(), outputStream, file.getSize(), progress -> {
|
||||
builder.setProgress(100, progress, false);
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
});
|
||||
|
||||
builder.setContentTitle(getString(R.string.fileViewerNotificationTitleFinished))
|
||||
.setContentText(getString(R.string.fileViewerNotificationDescriptionFinished, file.getName()));
|
||||
|
||||
}
|
||||
catch(IOException ignored) {
|
||||
|
||||
builder.setContentTitle(getString(R.string.fileViewerNotificationTitleFailed))
|
||||
.setContentText(getString(R.string.fileViewerNotificationDescriptionFailed, file.getName()));
|
||||
|
||||
}
|
||||
finally {
|
||||
|
||||
builder.setProgress(0, 0, false).setOngoing(false);
|
||||
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
thread.start();
|
||||
|
||||
}
|
||||
catch(IOException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
|
|
@ -89,53 +89,49 @@ import retrofit2.Response;
|
|||
|
||||
public class IssueDetailActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener, AssigneesListAdapter.AssigneesListAdapterListener, BottomSheetListener {
|
||||
|
||||
public static boolean singleIssueUpdate = false;
|
||||
public static boolean commentPosted = false;
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
private final List<User> assigneesList = new ArrayList<>();
|
||||
public boolean commentEdited = false;
|
||||
private IssueCommentsAdapter adapter;
|
||||
|
||||
private String repoOwner;
|
||||
private String repoName;
|
||||
private int issueIndex;
|
||||
private String issueCreator;
|
||||
private IssueContext issue;
|
||||
|
||||
private LabelsListAdapter labelsAdapter;
|
||||
private AssigneesListAdapter assigneesAdapter;
|
||||
|
||||
private List<Integer> currentLabelsIds = new ArrayList<>();
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
private final List<User> assigneesList = new ArrayList<>();
|
||||
private List<String> assigneesListData = new ArrayList<>();
|
||||
private List<String> currentAssignees = new ArrayList<>();
|
||||
|
||||
private Dialog dialogLabels;
|
||||
private Dialog dialogAssignees;
|
||||
|
||||
private CustomLabelsSelectionDialogBinding labelsBinding;
|
||||
private CustomAssigneesSelectionDialogBinding assigneesBinding;
|
||||
private ActivityIssueDetailBinding viewBinding;
|
||||
|
||||
public static boolean singleIssueUpdate = false;
|
||||
public boolean commentEdited = false;
|
||||
public static boolean commentPosted = false;
|
||||
|
||||
private IssueCommentsViewModel issueCommentsModel;
|
||||
private Runnable showMenu = () -> {
|
||||
};
|
||||
private boolean loadingFinishedIssue = false;
|
||||
private boolean loadingFinishedPr = false;
|
||||
private boolean loadingFinishedRepo = false;
|
||||
public ActivityResultLauncher<Intent> editIssueLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("issueEdited", false)) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
public ActivityResultLauncher<Intent> editIssueLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("issueEdited", false)) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
viewBinding.frameAssignees.removeAllViews();
|
||||
viewBinding.frameLabels.removeAllViews();
|
||||
issue.setIssue(null);
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
|
||||
viewBinding.frameAssignees.removeAllViews();
|
||||
viewBinding.frameLabels.removeAllViews();
|
||||
issue.setIssue(null);
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
|
||||
}, 500);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -325,8 +321,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
issue.setIssue(response2.body());
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
currentAssignees.clear();
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> AssigneesActions.getCurrentIssueAssignees(ctx, repoOwner, repoName, issueIndex, currentAssignees), 1000);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> AssigneesActions.getCurrentIssueAssignees(ctx, repoOwner, repoName, issueIndex, currentAssignees), 1000);
|
||||
}
|
||||
else if(response2.code() == 401) {
|
||||
|
||||
|
@ -381,8 +376,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
issue.setIssue(null);
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
currentLabelsIds.clear();
|
||||
new Handler(Looper.getMainLooper()).postDelayed(
|
||||
() -> LabelsActions.getCurrentIssueLabels(ctx, repoOwner, repoName, issueIndex, currentLabelsIds), 1000);
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> LabelsActions.getCurrentIssueLabels(ctx, repoOwner, repoName, issueIndex, currentLabelsIds), 1000);
|
||||
IssuesFragment.resumeIssues = true;
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
@ -412,12 +406,6 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
});
|
||||
}
|
||||
|
||||
private Runnable showMenu = () -> {
|
||||
};
|
||||
private boolean loadingFinishedIssue = false;
|
||||
private boolean loadingFinishedPr = false;
|
||||
private boolean loadingFinishedRepo = false;
|
||||
|
||||
private void updateMenuState() {
|
||||
if(loadingFinishedIssue && loadingFinishedPr && loadingFinishedRepo) {
|
||||
showMenu.run();
|
||||
|
@ -449,8 +437,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
if(id == android.R.id.home) {
|
||||
|
||||
if(issue.hasIssue() && getIntent().getStringExtra("openedFromLink") != null && getIntent().getStringExtra("openedFromLink")
|
||||
.equals("true")) {
|
||||
if(issue.hasIssue() && getIntent().getStringExtra("openedFromLink") != null && getIntent().getStringExtra("openedFromLink").equals("true")) {
|
||||
Intent intent = issue.getRepository().getIntent(ctx, RepoDetailActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
|
@ -502,8 +489,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
viewBinding.scrollViewComments.post(() -> {
|
||||
|
||||
issueCommentsModel.loadIssueComments(repoOwner, repoName, issueIndex, ctx,
|
||||
() -> viewBinding.scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN));
|
||||
issueCommentsModel.loadIssueComments(repoOwner, repoName, issueIndex, ctx, () -> viewBinding.scrollViewComments.fullScroll(ScrollView.FOCUS_DOWN));
|
||||
|
||||
commentPosted = false;
|
||||
});
|
||||
|
@ -645,14 +631,12 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
if(issue.getIssue().getPullRequest().isMerged()) { // merged
|
||||
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_pull_request);
|
||||
ImageViewCompat.setImageTintList(viewBinding.issuePrState,
|
||||
ColorStateList.valueOf(ctx.getResources().getColor(R.color.iconPrMergedColor)));
|
||||
ImageViewCompat.setImageTintList(viewBinding.issuePrState, ColorStateList.valueOf(ctx.getResources().getColor(R.color.iconPrMergedColor)));
|
||||
}
|
||||
else if(!issue.getIssue().getPullRequest().isMerged() && issue.getIssue().getState().equals("closed")) { // closed
|
||||
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_pull_request);
|
||||
ImageViewCompat.setImageTintList(viewBinding.issuePrState,
|
||||
ColorStateList.valueOf(ctx.getResources().getColor(R.color.iconIssuePrClosedColor)));
|
||||
ImageViewCompat.setImageTintList(viewBinding.issuePrState, ColorStateList.valueOf(ctx.getResources().getColor(R.color.iconIssuePrClosedColor)));
|
||||
}
|
||||
else { // open
|
||||
|
||||
|
@ -664,8 +648,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
loadingFinishedPr = true;
|
||||
updateMenuState();
|
||||
viewBinding.issuePrState.setImageResource(R.drawable.ic_issue);
|
||||
ImageViewCompat.setImageTintList(viewBinding.issuePrState,
|
||||
ColorStateList.valueOf(ctx.getResources().getColor(R.color.iconIssuePrClosedColor)));
|
||||
ImageViewCompat.setImageTintList(viewBinding.issuePrState, ColorStateList.valueOf(ctx.getResources().getColor(R.color.iconIssuePrClosedColor)));
|
||||
}
|
||||
else {
|
||||
loadingFinishedPr = true;
|
||||
|
@ -679,12 +662,10 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
final String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
issueCreator = issue.getIssue().getUser().getLogin();
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(viewBinding.assigneeAvatar);
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(getResources(), R.color.lightGray, null) + "'>" + appCtx.getResources()
|
||||
.getString(R.string.hash) + issue.getIssue().getNumber() + "</font>";
|
||||
viewBinding.issueTitle.setText(
|
||||
HtmlCompat.fromHtml(issueNumber_ + " " + EmojiParser.parseToUnicode(issue.getIssue().getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop()
|
||||
.into(viewBinding.assigneeAvatar);
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(getResources(), R.color.lightGray, null) + "'>" + appCtx.getResources().getString(R.string.hash) + issue.getIssue().getNumber() + "</font>";
|
||||
viewBinding.issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + EmojiParser.parseToUnicode(issue.getIssue().getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
String cleanIssueDescription = issue.getIssue().getBody().trim();
|
||||
|
||||
viewBinding.assigneeAvatar.setOnClickListener(loginId -> {
|
||||
|
@ -694,8 +675,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
});
|
||||
|
||||
viewBinding.assigneeAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(ctx, issue.getIssue().getUser().getLogin(),
|
||||
ctx.getString(R.string.copyLoginIdToClipBoard, issue.getIssue().getUser().getLogin()));
|
||||
AppUtil.copyToClipboard(ctx, issue.getIssue().getUser().getLogin(), ctx.getString(R.string.copyLoginIdToClipBoard, issue.getIssue().getUser().getLogin()));
|
||||
return true;
|
||||
});
|
||||
|
||||
|
@ -714,9 +694,8 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
ImageView assigneesView = new ImageView(ctx);
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getAssignees().get(i).getAvatarUrl())
|
||||
.placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(100, 100).centerCrop()
|
||||
.into(assigneesView);
|
||||
PicassoService.getInstance(ctx).get().load(issue.getIssue().getAssignees().get(i).getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(100, 100)
|
||||
.centerCrop().into(assigneesView);
|
||||
|
||||
viewBinding.frameAssignees.addView(assigneesView);
|
||||
assigneesView.setLayoutParams(params1);
|
||||
|
@ -729,8 +708,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
});
|
||||
|
||||
assigneesView.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(ctx, issue.getIssue().getAssignees().get(finalI).getLogin(),
|
||||
ctx.getString(R.string.copyLoginIdToClipBoard, issue.getIssue().getAssignees().get(finalI).getLogin()));
|
||||
AppUtil.copyToClipboard(ctx, issue.getIssue().getAssignees().get(finalI).getLogin(), ctx.getString(R.string.copyLoginIdToClipBoard, issue.getIssue().getAssignees().get(finalI).getLogin()));
|
||||
return true;
|
||||
});
|
||||
|
||||
|
@ -751,8 +729,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
viewBinding.assigneesScrollView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
|
||||
if(issue.getIssue().getLabels() != null) {
|
||||
|
@ -773,10 +750,9 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
int height = AppUtil.getPixelsFromDensity(ctx, 20);
|
||||
int textSize = AppUtil.getPixelsFromScaledDensity(ctx, 12);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT)
|
||||
.textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(ctx, 10)))
|
||||
.height(height).endConfig().buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(ctx, 18));
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(ctx, 10))).height(height).endConfig()
|
||||
.buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(ctx, 18));
|
||||
|
||||
labelsView.setImageDrawable(drawable);
|
||||
viewBinding.frameLabels.addView(labelsView);
|
||||
|
@ -795,8 +771,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", locale);
|
||||
String dueDate = formatter.format(issue.getIssue().getDueDate());
|
||||
viewBinding.issueDueDate.setText(dueDate);
|
||||
viewBinding.issueDueDate.setOnClickListener(
|
||||
new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getDueDate()), ctx));
|
||||
viewBinding.issueDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getDueDate()), ctx));
|
||||
}
|
||||
else if(timeFormat.equals("normal1")) {
|
||||
|
||||
|
@ -817,8 +792,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
edited = getString(R.string.colorfulBulletSpan) + getString(R.string.modifiedText);
|
||||
viewBinding.issueModified.setVisibility(View.VISIBLE);
|
||||
viewBinding.issueModified.setText(edited);
|
||||
viewBinding.issueModified.setOnClickListener(
|
||||
new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getUpdatedAt()), ctx));
|
||||
viewBinding.issueModified.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getUpdatedAt()), ctx));
|
||||
}
|
||||
else {
|
||||
|
||||
|
@ -851,8 +825,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
|
|||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
|
||||
viewBinding.issueCreatedTime.setOnClickListener(
|
||||
new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getCreatedAt()), ctx));
|
||||
viewBinding.issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getIssue().getCreatedAt()), ctx));
|
||||
}
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
|
|
|
@ -43,15 +43,12 @@ import retrofit2.Callback;
|
|||
|
||||
public class LoginActivity extends BaseActivity {
|
||||
|
||||
private enum LoginType {BASIC, TOKEN}
|
||||
|
||||
private Button loginButton;
|
||||
private EditText instanceUrlET, loginUidET, loginPassword, otpCode, loginTokenCode;
|
||||
private AutoCompleteTextView protocolSpinner;
|
||||
private RadioGroup loginMethod;
|
||||
private String device_id = "token";
|
||||
private String selectedProtocol;
|
||||
|
||||
private URI instanceUrl;
|
||||
private Version giteaVersion;
|
||||
private int maxResponseItems = 50;
|
||||
|
@ -94,25 +91,21 @@ public class LoginActivity extends BaseActivity {
|
|||
});
|
||||
|
||||
if(R.id.loginToken == loginMethod.getCheckedRadioButtonId()) {
|
||||
AppUtil.setMultiVisibility(View.GONE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout),
|
||||
findViewById(R.id.otpCodeLayout));
|
||||
AppUtil.setMultiVisibility(View.GONE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout), findViewById(R.id.otpCodeLayout));
|
||||
findViewById(R.id.loginTokenCodeLayout).setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
AppUtil.setMultiVisibility(View.VISIBLE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout),
|
||||
findViewById(R.id.otpCodeLayout));
|
||||
AppUtil.setMultiVisibility(View.VISIBLE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout), findViewById(R.id.otpCodeLayout));
|
||||
findViewById(R.id.loginTokenCodeLayout).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
loginMethod.setOnCheckedChangeListener((group, checkedId) -> {
|
||||
if(checkedId == R.id.loginToken) {
|
||||
AppUtil.setMultiVisibility(View.GONE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout),
|
||||
findViewById(R.id.otpCodeLayout));
|
||||
AppUtil.setMultiVisibility(View.GONE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout), findViewById(R.id.otpCodeLayout));
|
||||
findViewById(R.id.loginTokenCodeLayout).setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
AppUtil.setMultiVisibility(View.VISIBLE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout),
|
||||
findViewById(R.id.otpCodeLayout));
|
||||
AppUtil.setMultiVisibility(View.VISIBLE, findViewById(R.id.login_uidLayout), findViewById(R.id.login_passwdLayout), findViewById(R.id.otpCodeLayout));
|
||||
findViewById(R.id.loginTokenCodeLayout).setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
@ -153,11 +146,9 @@ public class LoginActivity extends BaseActivity {
|
|||
|
||||
LoginType loginType = (loginMethod.getCheckedRadioButtonId() == R.id.loginUsernamePassword) ? LoginType.BASIC : LoginType.TOKEN;
|
||||
|
||||
URI rawInstanceUrl = UrlBuilder.fromString(
|
||||
UrlHelper.fixScheme(instanceUrlET.getText().toString().replaceAll("[\\uFEFF|#]", "").trim(), "http")).toUri();
|
||||
URI rawInstanceUrl = UrlBuilder.fromString(UrlHelper.fixScheme(instanceUrlET.getText().toString().replaceAll("[\\uFEFF|#]", "").trim(), "http")).toUri();
|
||||
|
||||
instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(selectedProtocol.toLowerCase())
|
||||
.withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/")).toUri();
|
||||
instanceUrl = UrlBuilder.fromUri(rawInstanceUrl).withScheme(selectedProtocol.toLowerCase()).withPath(PathsHelper.join(rawInstanceUrl.getPath(), "/api/v1/")).toUri();
|
||||
|
||||
// cache values to make them available the next time the user wants to log in
|
||||
tinyDB.putString("loginType", loginType.name().toLowerCase());
|
||||
|
@ -223,8 +214,7 @@ public class LoginActivity extends BaseActivity {
|
|||
generalAPISettings.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull final Call<GeneralAPISettings> generalAPISettings,
|
||||
@NonNull retrofit2.Response<GeneralAPISettings> response) {
|
||||
public void onResponse(@NonNull final Call<GeneralAPISettings> generalAPISettings, @NonNull retrofit2.Response<GeneralAPISettings> response) {
|
||||
|
||||
if(response.code() == 200 && response.body() != null) {
|
||||
|
||||
|
@ -287,8 +277,7 @@ public class LoginActivity extends BaseActivity {
|
|||
if(giteaVersion.less(getString(R.string.versionLow))) {
|
||||
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx).setTitle(getString(R.string.versionAlertDialogHeader))
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setIcon(R.drawable.ic_warning)
|
||||
.setCancelable(true);
|
||||
.setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setIcon(R.drawable.ic_warning).setCancelable(true);
|
||||
|
||||
alertDialogBuilder.setNeutralButton(getString(R.string.cancelButton), (dialog, which) -> {
|
||||
|
||||
|
@ -371,8 +360,7 @@ public class LoginActivity extends BaseActivity {
|
|||
boolean userAccountExists = userAccountsApi.userAccountExists(accountName);
|
||||
UserAccount account;
|
||||
if(!userAccountExists) {
|
||||
long accountId = userAccountsApi.createNewAccount(accountName, instanceUrl.toString(), userDetails.getLogin(), loginToken,
|
||||
giteaVersion.toString(), maxResponseItems, defaultPagingNumber);
|
||||
long accountId = userAccountsApi.createNewAccount(accountName, instanceUrl.toString(), userDetails.getLogin(), loginToken, giteaVersion.toString(), maxResponseItems, defaultPagingNumber);
|
||||
account = userAccountsApi.getAccountById((int) accountId);
|
||||
}
|
||||
else {
|
||||
|
@ -445,13 +433,11 @@ public class LoginActivity extends BaseActivity {
|
|||
Call<Void> delToken;
|
||||
if(loginOTP != 0) {
|
||||
|
||||
delToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null)
|
||||
.userDeleteAccessToken(loginOTP, loginUid, String.valueOf(t.getId()));
|
||||
delToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null).userDeleteAccessToken(loginOTP, loginUid, String.valueOf(t.getId()));
|
||||
}
|
||||
else {
|
||||
|
||||
delToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null)
|
||||
.userDeleteAccessToken(loginUid, String.valueOf(t.getId()));
|
||||
delToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null).userDeleteAccessToken(loginUid, String.valueOf(t.getId()));
|
||||
}
|
||||
|
||||
delToken.enqueue(new Callback<>() {
|
||||
|
@ -509,13 +495,11 @@ public class LoginActivity extends BaseActivity {
|
|||
|
||||
if(loginOTP != 0) {
|
||||
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null)
|
||||
.userCreateToken(loginOTP, loginUid, createUserToken);
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null).userCreateToken(loginOTP, loginUid, createUserToken);
|
||||
}
|
||||
else {
|
||||
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null)
|
||||
.userCreateToken(loginUid, createUserToken);
|
||||
callCreateToken = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), credential, null).userCreateToken(loginUid, createUserToken);
|
||||
}
|
||||
|
||||
callCreateToken.enqueue(new Callback<>() {
|
||||
|
@ -530,8 +514,7 @@ public class LoginActivity extends BaseActivity {
|
|||
|
||||
if(!newToken.getSha1().equals("")) {
|
||||
|
||||
Call<User> call = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), "token " + newToken.getSha1(), null)
|
||||
.userGetCurrent();
|
||||
Call<User> call = RetrofitClient.getApiInterface(ctx, instanceUrl.toString(), "token " + newToken.getSha1(), null).userGetCurrent();
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -554,8 +537,7 @@ public class LoginActivity extends BaseActivity {
|
|||
|
||||
UserAccount account;
|
||||
if(!userAccountExists) {
|
||||
long accountId = userAccountsApi.createNewAccount(accountName, instanceUrl.toString(),
|
||||
userDetails.getLogin(), newToken.getSha1(), giteaVersion.toString(), maxResponseItems,
|
||||
long accountId = userAccountsApi.createNewAccount(accountName, instanceUrl.toString(), userDetails.getLogin(), newToken.getSha1(), giteaVersion.toString(), maxResponseItems,
|
||||
defaultPagingNumber);
|
||||
account = userAccountsApi.getAccountById((int) accountId);
|
||||
}
|
||||
|
@ -605,7 +587,6 @@ public class LoginActivity extends BaseActivity {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
private void loadDefaults() {
|
||||
|
||||
if(tinyDB.getString("loginType").equals(LoginType.BASIC.name().toLowerCase())) {
|
||||
|
@ -649,4 +630,6 @@ public class LoginActivity extends BaseActivity {
|
|||
loginButton.setEnabled(true);
|
||||
}
|
||||
|
||||
private enum LoginType {BASIC, TOKEN}
|
||||
|
||||
}
|
||||
|
|
|
@ -97,8 +97,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
Handler handler = new Handler();
|
||||
|
||||
// DO NOT MOVE
|
||||
if(mainIntent.hasExtra("switchAccountId") && AppUtil.switchToAccount(ctx,
|
||||
BaseApi.getInstance(ctx, UserAccountsApi.class).getAccountById(mainIntent.getIntExtra("switchAccountId", 0)))) {
|
||||
if(mainIntent.hasExtra("switchAccountId") && AppUtil.switchToAccount(ctx, BaseApi.getInstance(ctx, UserAccountsApi.class).getAccountById(mainIntent.getIntExtra("switchAccountId", 0)))) {
|
||||
|
||||
mainIntent.removeExtra("switchAccountId");
|
||||
recreate();
|
||||
|
@ -164,8 +163,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
Menu menu = navigationView.getMenu();
|
||||
navNotifications = menu.findItem(R.id.nav_notifications);
|
||||
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigationDrawerOpen,
|
||||
R.string.navigationDrawerClose);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigationDrawerOpen, R.string.navigationDrawerClose);
|
||||
|
||||
drawer.addDrawerListener(toggle);
|
||||
drawer.addDrawerListener(new DrawerLayout.DrawerListener() {
|
||||
|
@ -221,26 +219,25 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
|
||||
int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 3);
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(userAvatarNav).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(avatarRadius, 0)).resize(160, 160).centerCrop().into(userAvatar);
|
||||
PicassoService.getInstance(ctx).get().load(userAvatarNav).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(avatarRadius, 0)).resize(160, 160).centerCrop()
|
||||
.into(userAvatar);
|
||||
|
||||
PicassoService.getInstance(ctx).get().load(userAvatarNav).transform(new BlurTransformation(ctx))
|
||||
.into(userAvatarBackground, new com.squareup.picasso.Callback() {
|
||||
PicassoService.getInstance(ctx).get().load(userAvatarNav).transform(new BlurTransformation(ctx)).into(userAvatarBackground, new com.squareup.picasso.Callback() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
||||
int textColor = new ColorInverter().getImageViewContrastColor(userAvatarBackground);
|
||||
int textColor = new ColorInverter().getImageViewContrastColor(userAvatarBackground);
|
||||
|
||||
userFullName.setTextColor(textColor);
|
||||
userEmail.setTextColor(textColor);
|
||||
}
|
||||
userFullName.setTextColor(textColor);
|
||||
userEmail.setTextColor(textColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -475,8 +472,8 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
|
||||
if(frag != null) {
|
||||
|
||||
new AlertDialog.Builder(ctx).setTitle(R.string.deleteAllDrafts).setIcon(R.drawable.ic_delete).setCancelable(false)
|
||||
.setMessage(R.string.deleteAllDraftsDialogMessage).setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
new AlertDialog.Builder(ctx).setTitle(R.string.deleteAllDrafts).setIcon(R.drawable.ic_delete).setCancelable(false).setMessage(R.string.deleteAllDraftsDialogMessage)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
|
||||
frag.deleteAllDrafts(currentActiveAccountId);
|
||||
dialog.dismiss();
|
||||
|
@ -623,8 +620,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
generalAPISettings.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull final Call<GeneralAPISettings> generalAPISettings,
|
||||
@NonNull retrofit2.Response<GeneralAPISettings> response) {
|
||||
public void onResponse(@NonNull final Call<GeneralAPISettings> generalAPISettings, @NonNull retrofit2.Response<GeneralAPISettings> response) {
|
||||
|
||||
if(response.code() == 200 && response.body() != null) {
|
||||
|
||||
|
@ -638,8 +634,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||
defaultPagingNumber = Math.toIntExact(response.body().getDefaultPagingNum());
|
||||
}
|
||||
|
||||
BaseApi.getInstance(ctx, UserAccountsApi.class)
|
||||
.updateServerPagingLimit(maxResponseItems, defaultPagingNumber, tinyDB.getInt("currentActiveAccountId"));
|
||||
BaseApi.getInstance(ctx, UserAccountsApi.class).updateServerPagingLimit(maxResponseItems, defaultPagingNumber, tinyDB.getInt("currentActiveAccountId"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||
private IssueContext issue;
|
||||
private ActivityMergePullRequestBinding viewBinding;
|
||||
private String Do;
|
||||
private final View.OnClickListener mergePullRequest = v -> processMergePullRequest();
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
|
@ -132,8 +133,6 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
private final View.OnClickListener mergePullRequest = v -> processMergePullRequest();
|
||||
|
||||
private void processMergePullRequest() {
|
||||
|
||||
String mergePRDesc = Objects.requireNonNull(viewBinding.mergeDescription.getText()).toString();
|
||||
|
@ -180,8 +179,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||
break;
|
||||
}
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx)
|
||||
.repoMergePullRequest(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), mergePR);
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).repoMergePullRequest(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), mergePR);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -201,8 +199,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
|||
PullRequestActions.deleteHeadBranch(ctx, repoOwner, repoName, issue.getPullRequest().getHead().getRef(), false);
|
||||
}
|
||||
else {
|
||||
PullRequestActions.deleteHeadBranch(ctx, issue.getRepository().getOwner(), issue.getRepository().getName(),
|
||||
issue.getPullRequest().getHead().getRef(), false);
|
||||
PullRequestActions.deleteHeadBranch(ctx, issue.getRepository().getOwner(), issue.getRepository().getName(), issue.getPullRequest().getHead().getRef(), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ public class MyProfileEmailActivity extends BaseActivity {
|
|||
private View.OnClickListener onClickListener;
|
||||
private EditText userEmail;
|
||||
private Button addEmailButton;
|
||||
private final View.OnClickListener addEmailListener = v -> processAddNewEmail();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -69,8 +70,6 @@ public class MyProfileEmailActivity extends BaseActivity {
|
|||
|
||||
}
|
||||
|
||||
private final View.OnClickListener addEmailListener = v -> processAddNewEmail();
|
||||
|
||||
private void processAddNewEmail() {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
|
|
@ -105,8 +105,7 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
|||
}
|
||||
|
||||
public void init() {
|
||||
OrganizationDetailActivity.SectionsPagerAdapter mSectionsPagerAdapter = new OrganizationDetailActivity.SectionsPagerAdapter(
|
||||
getSupportFragmentManager());
|
||||
OrganizationDetailActivity.SectionsPagerAdapter mSectionsPagerAdapter = new OrganizationDetailActivity.SectionsPagerAdapter(getSupportFragmentManager());
|
||||
|
||||
ViewPager mViewPager = findViewById(R.id.container);
|
||||
mViewPager.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -74,9 +74,8 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
|||
|
||||
viewPager.setAdapter(new ViewPagerAdapter(this));
|
||||
|
||||
String[] tabTitles = {ctx.getResources().getString(R.string.tabTextInfo), ctx.getResources().getString(R.string.navRepos),
|
||||
ctx.getResources().getString(R.string.navStarredRepos), ctx.getResources().getString(R.string.navOrg),
|
||||
ctx.getResources().getString(R.string.profileTabFollowers), ctx.getResources().getString(R.string.profileTabFollowing)};
|
||||
String[] tabTitles = {ctx.getResources().getString(R.string.tabTextInfo), ctx.getResources().getString(R.string.navRepos), ctx.getResources().getString(R.string.navStarredRepos),
|
||||
ctx.getResources().getString(R.string.navOrg), ctx.getResources().getString(R.string.profileTabFollowers), ctx.getResources().getString(R.string.profileTabFollowing)};
|
||||
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> tab.setText(tabTitles[position])).attach();
|
||||
|
||||
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
|
||||
|
@ -174,6 +173,32 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
int id = item.getItemId();
|
||||
|
||||
if(id == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
else if(id == R.id.genericMenu) {
|
||||
new BottomSheetUserProfileFragment(following).show(getSupportFragmentManager(), "userProfileBottomSheet");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
if(!username.equals(getAccount().getAccount().getUserName())) {
|
||||
getMenuInflater().inflate(R.menu.generic_nav_dotted_menu, menu);
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
public class ViewPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
public ViewPagerAdapter(@NonNull FragmentActivity fa) {
|
||||
|
@ -207,30 +232,4 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
int id = item.getItemId();
|
||||
|
||||
if(id == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
else if(id == R.id.genericMenu) {
|
||||
new BottomSheetUserProfileFragment(following).show(getSupportFragmentManager(), "userProfileBottomSheet");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
if(!username.equals(getAccount().getAccount().getUserName())) {
|
||||
getMenuInflater().inflate(R.menu.generic_nav_dotted_menu, menu);
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,72 +64,59 @@ import retrofit2.Response;
|
|||
|
||||
public class RepoDetailActivity extends BaseActivity implements BottomSheetListener {
|
||||
|
||||
public static boolean updateRepo = false;
|
||||
private final ActivityResultLauncher<Intent> settingsLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("nameChanged", false)) {
|
||||
recreate();
|
||||
}
|
||||
}
|
||||
});
|
||||
public ViewPager2 viewPager;
|
||||
public RepositoryContext repository;
|
||||
private TextView textViewBadgeIssue;
|
||||
private TextView textViewBadgePull;
|
||||
private TextView textViewBadgeRelease;
|
||||
private Typeface myTypeface;
|
||||
|
||||
private FragmentRefreshListener fragmentRefreshListener;
|
||||
private FragmentRefreshListener fragmentRefreshListenerPr;
|
||||
private FragmentRefreshListener fragmentRefreshListenerMilestone;
|
||||
private final ActivityResultLauncher<Intent> createMilestoneLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 201) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("milestoneCreated", false)) {
|
||||
if(fragmentRefreshListenerMilestone != null) {
|
||||
fragmentRefreshListenerMilestone.onRefresh(repository.getMilestoneState().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
private FragmentRefreshListener fragmentRefreshListenerFiles;
|
||||
private final ActivityResultLauncher<Intent> editFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("fileModified", false)) {
|
||||
if(fragmentRefreshListenerFiles != null) {
|
||||
fragmentRefreshListenerFiles.onRefresh(repository.getBranchRef());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
private FragmentRefreshListener fragmentRefreshListenerFilterIssuesByMilestone;
|
||||
private FragmentRefreshListener fragmentRefreshListenerReleases;
|
||||
|
||||
public ViewPager2 viewPager;
|
||||
|
||||
public RepositoryContext repository;
|
||||
|
||||
public static boolean updateRepo = false;
|
||||
private Dialog progressDialog;
|
||||
|
||||
private final ActivityResultLauncher<Intent> createReleaseLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 201) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("updateReleases", false)) {
|
||||
if(fragmentRefreshListenerReleases != null) {
|
||||
fragmentRefreshListenerReleases.onRefresh(null);
|
||||
}
|
||||
repository.removeRepository();
|
||||
getRepoInfo(repository.getOwner(), repository.getName());
|
||||
private Dialog progressDialog; private final ActivityResultLauncher<Intent> createReleaseLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 201) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("updateReleases", false)) {
|
||||
if(fragmentRefreshListenerReleases != null) {
|
||||
fragmentRefreshListenerReleases.onRefresh(null);
|
||||
}
|
||||
repository.removeRepository();
|
||||
getRepoInfo(repository.getOwner(), repository.getName());
|
||||
}
|
||||
});
|
||||
|
||||
private final ActivityResultLauncher<Intent> createMilestoneLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if(result.getResultCode() == 201) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("milestoneCreated", false)) {
|
||||
if(fragmentRefreshListenerMilestone != null) {
|
||||
fragmentRefreshListenerMilestone.onRefresh(repository.getMilestoneState().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private final ActivityResultLauncher<Intent> editFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("fileModified", false)) {
|
||||
if(fragmentRefreshListenerFiles != null) {
|
||||
fragmentRefreshListenerFiles.onRefresh(repository.getBranchRef());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private final ActivityResultLauncher<Intent> settingsLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if(result.getResultCode() == 200) {
|
||||
assert result.getData() != null;
|
||||
if(result.getData().getBooleanExtra("nameChanged", false)) {
|
||||
recreate();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -367,8 +354,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
progressDialog.setContentView(R.layout.custom_progress_loader);
|
||||
progressDialog.show();
|
||||
|
||||
Call<List<Milestone>> call = RetrofitClient.getApiInterface(ctx)
|
||||
.issueGetMilestonesList(repository.getOwner(), repository.getName(), "open", null, 1, 50);
|
||||
Call<List<Milestone>> call = RetrofitClient.getApiInterface(ctx).issueGetMilestonesList(repository.getOwner(), repository.getName(), "open", null, 1, 50);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -486,52 +472,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
});
|
||||
}
|
||||
|
||||
public class ViewPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
public ViewPagerAdapter(@NonNull FragmentActivity fa) {
|
||||
super(fa);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
|
||||
Fragment fragment = null;
|
||||
|
||||
switch(position) {
|
||||
case 0: // Repository details
|
||||
return RepoInfoFragment.newInstance(repository);
|
||||
case 1: // Files
|
||||
return FilesFragment.newInstance(repository);
|
||||
case 2: // Issues
|
||||
fragment = IssuesFragment.newInstance(repository);
|
||||
break;
|
||||
case 3: // Pull requests
|
||||
fragment = PullRequestsFragment.newInstance(repository);
|
||||
break;
|
||||
case 4: // Releases
|
||||
return ReleasesFragment.newInstance(repository);
|
||||
case 5: // Wiki
|
||||
return WikiFragment.newInstance(repository);
|
||||
case 6: // Milestones
|
||||
fragment = MilestonesFragment.newInstance(repository);
|
||||
break;
|
||||
case 7: // Labels
|
||||
return LabelsFragment.newInstance(repository);
|
||||
case 8: // Collaborators
|
||||
return CollaboratorsFragment.newInstance(repository);
|
||||
}
|
||||
assert fragment != null;
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void getRepoInfo(final String owner, String repo) {
|
||||
|
||||
LinearProgressIndicator loading = findViewById(R.id.loadingIndicator);
|
||||
|
@ -590,11 +530,9 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
|
||||
viewPager.setAdapter(new ViewPagerAdapter(this));
|
||||
|
||||
String[] tabTitles = {ctx.getResources().getString(R.string.tabTextInfo), ctx.getResources().getString(R.string.tabTextFiles),
|
||||
ctx.getResources().getString(R.string.pageTitleIssues), ctx.getResources().getString(R.string.tabPullRequests),
|
||||
ctx.getResources().getString(R.string.tabTextReleases), ctx.getResources().getString(R.string.wiki),
|
||||
ctx.getResources().getString(R.string.tabTextMl), ctx.getResources().getString(R.string.newIssueLabelsTitle),
|
||||
ctx.getResources().getString(R.string.tabTextCollaborators)};
|
||||
String[] tabTitles = {ctx.getResources().getString(R.string.tabTextInfo), ctx.getResources().getString(R.string.tabTextFiles), ctx.getResources().getString(R.string.pageTitleIssues),
|
||||
ctx.getResources().getString(R.string.tabPullRequests), ctx.getResources().getString(R.string.tabTextReleases), ctx.getResources().getString(R.string.wiki),
|
||||
ctx.getResources().getString(R.string.tabTextMl), ctx.getResources().getString(R.string.newIssueLabelsTitle), ctx.getResources().getString(R.string.tabTextCollaborators)};
|
||||
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> tab.setText(tabTitles[position])).attach();
|
||||
|
||||
ViewGroup viewGroup = (ViewGroup) tabLayout.getChildAt(0);
|
||||
|
@ -869,4 +807,53 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||
this.fragmentRefreshListenerReleases = fragmentRefreshListener;
|
||||
}
|
||||
|
||||
public class ViewPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
public ViewPagerAdapter(@NonNull FragmentActivity fa) {
|
||||
super(fa);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
|
||||
Fragment fragment = null;
|
||||
|
||||
switch(position) {
|
||||
case 0: // Repository details
|
||||
return RepoInfoFragment.newInstance(repository);
|
||||
case 1: // Files
|
||||
return FilesFragment.newInstance(repository);
|
||||
case 2: // Issues
|
||||
fragment = IssuesFragment.newInstance(repository);
|
||||
break;
|
||||
case 3: // Pull requests
|
||||
fragment = PullRequestsFragment.newInstance(repository);
|
||||
break;
|
||||
case 4: // Releases
|
||||
return ReleasesFragment.newInstance(repository);
|
||||
case 5: // Wiki
|
||||
return WikiFragment.newInstance(repository);
|
||||
case 6: // Milestones
|
||||
fragment = MilestonesFragment.newInstance(repository);
|
||||
break;
|
||||
case 7: // Labels
|
||||
return LabelsFragment.newInstance(repository);
|
||||
case 8: // Collaborators
|
||||
return CollaboratorsFragment.newInstance(repository);
|
||||
}
|
||||
assert fragment != null;
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -39,9 +39,9 @@ import retrofit2.Response;
|
|||
|
||||
public class RepoForksActivity extends BaseActivity {
|
||||
|
||||
private final String TAG = "RepositoryForks";
|
||||
private TextView noData;
|
||||
private ProgressBar progressBar;
|
||||
private final String TAG = "RepositoryForks";
|
||||
private int resultLimit;
|
||||
private int pageSize = 1;
|
||||
|
||||
|
|
|
@ -110,8 +110,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
TransferRepoOption repositoryTransfer = new TransferRepoOption();
|
||||
repositoryTransfer.setNewOwner(newOwner);
|
||||
|
||||
Call<Repository> transferCall = RetrofitClient.getApiInterface(ctx)
|
||||
.repoTransfer(repositoryTransfer, repository.getOwner(), repository.getName());
|
||||
Call<Repository> transferCall = RetrofitClient.getApiInterface(ctx).repoTransfer(repositoryTransfer, repository.getOwner(), repository.getName());
|
||||
|
||||
transferCall.enqueue(new Callback<Repository>() {
|
||||
|
||||
|
@ -285,20 +284,18 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
propBinding.repoEnableSquash.setChecked(repoInfo.isAllowSquashMerge());
|
||||
propBinding.repoEnableForceMerge.setChecked(repoInfo.isAllowRebaseExplicit());
|
||||
|
||||
propBinding.save.setOnClickListener(saveProperties -> saveRepositoryProperties(String.valueOf(propBinding.repoName.getText()),
|
||||
String.valueOf(propBinding.repoWebsite.getText()), String.valueOf(propBinding.repoDescription.getText()),
|
||||
propBinding.repoPrivate.isChecked(), propBinding.repoAsTemplate.isChecked(), propBinding.repoEnableIssues.isChecked(),
|
||||
propBinding.repoEnableWiki.isChecked(), propBinding.repoEnablePr.isChecked(), propBinding.repoEnableTimer.isChecked(),
|
||||
propBinding.repoEnableMerge.isChecked(), propBinding.repoEnableRebase.isChecked(), propBinding.repoEnableSquash.isChecked(),
|
||||
propBinding.repoEnableForceMerge.isChecked()));
|
||||
propBinding.save.setOnClickListener(
|
||||
saveProperties -> saveRepositoryProperties(String.valueOf(propBinding.repoName.getText()), String.valueOf(propBinding.repoWebsite.getText()), String.valueOf(propBinding.repoDescription.getText()),
|
||||
propBinding.repoPrivate.isChecked(), propBinding.repoAsTemplate.isChecked(), propBinding.repoEnableIssues.isChecked(), propBinding.repoEnableWiki.isChecked(), propBinding.repoEnablePr.isChecked(),
|
||||
propBinding.repoEnableTimer.isChecked(), propBinding.repoEnableMerge.isChecked(), propBinding.repoEnableRebase.isChecked(), propBinding.repoEnableSquash.isChecked(),
|
||||
propBinding.repoEnableForceMerge.isChecked()));
|
||||
|
||||
dialogProp.setCancelable(false);
|
||||
dialogProp.show();
|
||||
}
|
||||
|
||||
private void saveRepositoryProperties(String repoName, String repoWebsite, String repoDescription, boolean repoPrivate, boolean repoAsTemplate,
|
||||
boolean repoEnableIssues, boolean repoEnableWiki, boolean repoEnablePr, boolean repoEnableTimer, boolean repoEnableMerge,
|
||||
boolean repoEnableRebase, boolean repoEnableSquash, boolean repoEnableForceMerge) {
|
||||
private void saveRepositoryProperties(String repoName, String repoWebsite, String repoDescription, boolean repoPrivate, boolean repoAsTemplate, boolean repoEnableIssues, boolean repoEnableWiki, boolean repoEnablePr,
|
||||
boolean repoEnableTimer, boolean repoEnableMerge, boolean repoEnableRebase, boolean repoEnableSquash, boolean repoEnableForceMerge) {
|
||||
|
||||
EditRepoOption repoProps = new EditRepoOption();
|
||||
repoProps.setName(repoName);
|
||||
|
@ -333,8 +330,7 @@ public class RepositorySettingsActivity extends BaseActivity {
|
|||
repository.setRepository(response.body());
|
||||
|
||||
if(!repository.getName().equals(repoName)) {
|
||||
Objects.requireNonNull(BaseApi.getInstance(ctx, RepositoriesApi.class))
|
||||
.updateRepositoryOwnerAndName(repository.getOwner(), repoName, repository.getRepositoryId());
|
||||
Objects.requireNonNull(BaseApi.getInstance(ctx, RepositoriesApi.class)).updateRepositoryOwnerAndName(repository.getOwner(), repoName, repository.getRepositoryId());
|
||||
Intent result = new Intent();
|
||||
result.putExtra("nameChanged", true);
|
||||
setResult(200, result);
|
||||
|
|
|
@ -25,16 +25,13 @@ import org.mian.gitnex.helpers.Toasty;
|
|||
|
||||
public class SettingsAppearanceActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private static String[] timeList;
|
||||
private static int timeSelectedChoice = 0;
|
||||
|
||||
private static String[] customFontList;
|
||||
private static int customFontSelectedChoice = 0;
|
||||
|
||||
private static String[] themeList;
|
||||
private static int themeSelectedChoice = 0;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -83,10 +80,8 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
customFontSelectedChoice = tinyDB.getInt("customFontId", 1);
|
||||
themeSelectedChoice = tinyDB.getInt("themeId", 6); // use system theme as default
|
||||
|
||||
activitySettingsAppearanceBinding.lightThemeSelectedTime.setText(
|
||||
ctx.getResources().getString(R.string.settingsThemeTimeSelectedHint, lightHour, lightMinute));
|
||||
activitySettingsAppearanceBinding.darkThemeSelectedTime.setText(
|
||||
ctx.getResources().getString(R.string.settingsThemeTimeSelectedHint, darkHour, darkMinute));
|
||||
activitySettingsAppearanceBinding.lightThemeSelectedTime.setText(ctx.getResources().getString(R.string.settingsThemeTimeSelectedHint, lightHour, lightMinute));
|
||||
activitySettingsAppearanceBinding.darkThemeSelectedTime.setText(ctx.getResources().getString(R.string.settingsThemeTimeSelectedHint, darkHour, darkMinute));
|
||||
activitySettingsAppearanceBinding.tvDateTimeSelected.setText(timeList[timeSelectedChoice]);
|
||||
activitySettingsAppearanceBinding.customFontSelected.setText(customFontList[customFontSelectedChoice]);
|
||||
activitySettingsAppearanceBinding.themeSelected.setText(themeList[themeSelectedChoice]);
|
||||
|
@ -119,8 +114,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
});
|
||||
activitySettingsAppearanceBinding.labelsInListFrame.setOnClickListener(
|
||||
v -> activitySettingsAppearanceBinding.switchLabelsInListBadge.setChecked(
|
||||
!activitySettingsAppearanceBinding.switchLabelsInListBadge.isChecked()));
|
||||
v -> activitySettingsAppearanceBinding.switchLabelsInListBadge.setChecked(!activitySettingsAppearanceBinding.switchLabelsInListBadge.isChecked()));
|
||||
|
||||
// theme selection dialog
|
||||
themeFrame.setOnClickListener(view -> {
|
||||
|
|
|
@ -16,14 +16,12 @@ import java.util.List;
|
|||
|
||||
public class SettingsGeneralActivity extends BaseActivity {
|
||||
|
||||
private static int homeScreenSelectedChoice = 0;
|
||||
private static int defaultLinkHandlerScreenSelectedChoice = 0;
|
||||
private ActivitySettingsGeneralBinding viewBinding;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private List<String> homeScreenList;
|
||||
private static int homeScreenSelectedChoice = 0;
|
||||
|
||||
private List<String> linkHandlerDefaultScreen;
|
||||
private static int defaultLinkHandlerScreenSelectedChoice = 0;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
|
|
@ -35,8 +35,7 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
|
||||
viewBinding.close.setOnClickListener(onClickListener);
|
||||
|
||||
viewBinding.pollingDelaySelected.setText(
|
||||
String.format(getString(R.string.pollingDelaySelectedText), tinyDB.getInt("pollingDelayMinutes", Constants.defaultPollingDelay)));
|
||||
viewBinding.pollingDelaySelected.setText(String.format(getString(R.string.pollingDelaySelectedText), tinyDB.getInt("pollingDelayMinutes", Constants.defaultPollingDelay)));
|
||||
viewBinding.chooseColorState.setCardBackgroundColor(tinyDB.getInt("notificationsLightColor", Color.GREEN));
|
||||
|
||||
viewBinding.enableNotificationsMode.setChecked(tinyDB.getBoolean("notificationsEnabled", true));
|
||||
|
@ -44,8 +43,7 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
viewBinding.enableVibrationMode.setChecked(tinyDB.getBoolean("notificationsEnableVibration", true));
|
||||
|
||||
if(!viewBinding.enableNotificationsMode.isChecked()) {
|
||||
AppUtil.setMultiVisibility(View.GONE, viewBinding.chooseColorFrame, viewBinding.enableLightsFrame, viewBinding.enableVibrationFrame,
|
||||
viewBinding.pollingDelayFrame);
|
||||
AppUtil.setMultiVisibility(View.GONE, viewBinding.chooseColorFrame, viewBinding.enableLightsFrame, viewBinding.enableVibrationFrame, viewBinding.pollingDelayFrame);
|
||||
}
|
||||
|
||||
if(!viewBinding.enableLightsMode.isChecked()) {
|
||||
|
@ -58,20 +56,17 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
|
||||
if(isChecked) {
|
||||
Notifications.startWorker(ctx);
|
||||
AppUtil.setMultiVisibility(View.VISIBLE, viewBinding.chooseColorFrame, viewBinding.enableLightsFrame,
|
||||
viewBinding.enableVibrationFrame, viewBinding.pollingDelayFrame);
|
||||
AppUtil.setMultiVisibility(View.VISIBLE, viewBinding.chooseColorFrame, viewBinding.enableLightsFrame, viewBinding.enableVibrationFrame, viewBinding.pollingDelayFrame);
|
||||
}
|
||||
else {
|
||||
Notifications.stopWorker(ctx);
|
||||
AppUtil.setMultiVisibility(View.GONE, viewBinding.chooseColorFrame, viewBinding.enableLightsFrame, viewBinding.enableVibrationFrame,
|
||||
viewBinding.pollingDelayFrame);
|
||||
AppUtil.setMultiVisibility(View.GONE, viewBinding.chooseColorFrame, viewBinding.enableLightsFrame, viewBinding.enableVibrationFrame, viewBinding.pollingDelayFrame);
|
||||
}
|
||||
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
viewBinding.enableNotificationsFrame.setOnClickListener(
|
||||
v -> viewBinding.enableNotificationsMode.setChecked(!viewBinding.enableNotificationsMode.isChecked()));
|
||||
viewBinding.enableNotificationsFrame.setOnClickListener(v -> viewBinding.enableNotificationsMode.setChecked(!viewBinding.enableNotificationsMode.isChecked()));
|
||||
|
||||
// polling delay
|
||||
viewBinding.pollingDelayFrame.setOnClickListener(v -> {
|
||||
|
@ -144,8 +139,7 @@ public class SettingsNotificationsActivity extends BaseActivity {
|
|||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
|
||||
});
|
||||
viewBinding.enableVibrationFrame.setOnClickListener(
|
||||
v -> viewBinding.enableVibrationMode.setChecked(!viewBinding.enableVibrationMode.isChecked()));
|
||||
viewBinding.enableVibrationFrame.setOnClickListener(v -> viewBinding.enableVibrationMode.setChecked(!viewBinding.enableVibrationMode.isChecked()));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,7 @@ public class SettingsReportsActivity extends BaseActivity {
|
|||
tinyDB.putBoolean("crashReportingEnabled", isChecked);
|
||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||
});
|
||||
activitySettingsReportsBinding.enableSendReports.setOnClickListener(
|
||||
v -> activitySettingsReportsBinding.crashReportsSwitch.setChecked(!activitySettingsReportsBinding.crashReportsSwitch.isChecked()));
|
||||
activitySettingsReportsBinding.enableSendReports.setOnClickListener(v -> activitySettingsReportsBinding.crashReportsSwitch.setChecked(!activitySettingsReportsBinding.crashReportsSwitch.isChecked()));
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
|
|
@ -29,13 +29,11 @@ import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTI
|
|||
|
||||
public class SettingsSecurityActivity extends BaseActivity {
|
||||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private static String[] cacheSizeDataList;
|
||||
private static int cacheSizeDataSelectedChoice = 0;
|
||||
|
||||
private static String[] cacheSizeImagesList;
|
||||
private static int cacheSizeImagesSelectedChoice = 0;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -229,8 +227,7 @@ public class SettingsSecurityActivity extends BaseActivity {
|
|||
builder.setMessage(getResources().getString(R.string.settingsCertsPopupMessage));
|
||||
builder.setPositiveButton(R.string.menuDeleteText, (dialog, which) -> {
|
||||
|
||||
appCtx.getSharedPreferences(MemorizingTrustManager.KEYSTORE_NAME, Context.MODE_PRIVATE).edit()
|
||||
.remove(MemorizingTrustManager.KEYSTORE_KEY).apply();
|
||||
appCtx.getSharedPreferences(MemorizingTrustManager.KEYSTORE_NAME, Context.MODE_PRIVATE).edit().remove(MemorizingTrustManager.KEYSTORE_KEY).apply();
|
||||
AppUtil.logout(this);
|
||||
});
|
||||
|
||||
|
|
|
@ -20,9 +20,14 @@ import java.util.Locale;
|
|||
|
||||
public class SettingsTranslationActivity extends BaseActivity {
|
||||
|
||||
private static int langSelectedChoice = 0;
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private static int langSelectedChoice = 0;
|
||||
private static String getLanguageDisplayName(String langCode) {
|
||||
Locale english = new Locale("en");
|
||||
Locale translated = new Locale(langCode);
|
||||
return String.format("%s (%s)", translated.getDisplayName(translated), translated.getDisplayName(english));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -88,10 +93,4 @@ public class SettingsTranslationActivity extends BaseActivity {
|
|||
onClickListener = view -> finish();
|
||||
}
|
||||
|
||||
private static String getLanguageDisplayName(String langCode) {
|
||||
Locale english = new Locale("en");
|
||||
Locale translated = new Locale(langCode);
|
||||
return String.format("%s (%s)", translated.getDisplayName(translated), translated.getDisplayName(english));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -105,8 +105,7 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
createWikiPageOptions.setTitle(wikiTitle);
|
||||
createWikiPageOptions.setContentBase64(AppUtil.encodeBase64(wikiContent));
|
||||
|
||||
Call<WikiPage> call = RetrofitClient.getApiInterface(ctx)
|
||||
.repoCreateWikiPage(repository.getOwner(), repository.getName(), createWikiPageOptions);
|
||||
Call<WikiPage> call = RetrofitClient.getApiInterface(ctx).repoCreateWikiPage(repository.getOwner(), repository.getName(), createWikiPageOptions);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -154,8 +153,7 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
createWikiPageOptions.setTitle(wikiTitle);
|
||||
createWikiPageOptions.setContentBase64(AppUtil.encodeBase64(wikiContent));
|
||||
|
||||
Call<WikiPage> call = RetrofitClient.getApiInterface(ctx)
|
||||
.repoEditWikiPage(repository.getOwner(), repository.getName(), pageName, createWikiPageOptions);
|
||||
Call<WikiPage> call = RetrofitClient.getApiInterface(ctx).repoEditWikiPage(repository.getOwner(), repository.getName(), pageName, createWikiPageOptions);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
|
@ -265,33 +263,31 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
|
||||
private void deleteWiki(final String owner, final String repo, final String pageName) {
|
||||
|
||||
new AlertDialog.Builder(ctx).setTitle(String.format(ctx.getString(R.string.deleteGenericTitle), pageName))
|
||||
.setMessage(ctx.getString(R.string.deleteWikiPageMessage, pageName)).setIcon(R.drawable.ic_delete)
|
||||
.setPositiveButton(R.string.menuDeleteText,
|
||||
(dialog, whichButton) -> RetrofitClient.getApiInterface(ctx).repoDeleteWikiPage(owner, repo, pageName).enqueue(new Callback<>() {
|
||||
new AlertDialog.Builder(ctx).setTitle(String.format(ctx.getString(R.string.deleteGenericTitle), pageName)).setMessage(ctx.getString(R.string.deleteWikiPageMessage, pageName)).setIcon(R.drawable.ic_delete)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient.getApiInterface(ctx).repoDeleteWikiPage(owner, repo, pageName).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
Toasty.success(ctx, getString(R.string.wikiPageDeleted));
|
||||
WikiFragment.resumeWiki = true;
|
||||
finish();
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
if(response.isSuccessful()) {
|
||||
Toasty.success(ctx, getString(R.string.wikiPageDeleted));
|
||||
WikiFragment.resumeWiki = true;
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
})).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
})).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -354,9 +350,7 @@ public class WikiActivity extends BaseActivity implements BottomSheetListener {
|
|||
|
||||
if(action.equalsIgnoreCase("edit") || action.equalsIgnoreCase("add")) {
|
||||
if(renderMd) {
|
||||
Markdown.render(ctx,
|
||||
EmojiParser.parseToUnicode(String.valueOf(Objects.requireNonNull(binding.contentLayout.getEditText()).getText())),
|
||||
binding.markdownPreview, repository);
|
||||
Markdown.render(ctx, EmojiParser.parseToUnicode(String.valueOf(Objects.requireNonNull(binding.contentLayout.getEditText()).getText())), binding.markdownPreview, repository);
|
||||
|
||||
binding.markdownPreview.setVisibility(View.VISIBLE);
|
||||
binding.contentLayout.setVisibility(View.GONE);
|
||||
|
|
|
@ -31,11 +31,77 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
|
|||
|
||||
private final List<Cron> tasksList;
|
||||
|
||||
public AdminCronTasksAdapter(List<Cron> tasksListMain) {
|
||||
this.tasksList = tasksListMain;
|
||||
}
|
||||
|
||||
private static void runCronTask(final Context ctx, final String taskName) {
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).adminCronRun(taskName);
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
case 204:
|
||||
Toasty.success(ctx, ctx.getString(R.string.adminCronTaskSuccessMsg, taskName));
|
||||
break;
|
||||
|
||||
case 401:
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
break;
|
||||
|
||||
case 403:
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
break;
|
||||
|
||||
case 404:
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
break;
|
||||
|
||||
default:
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public AdminCronTasksAdapter.CronTasksViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_admin_cron_tasks, parent, false);
|
||||
return new AdminCronTasksAdapter.CronTasksViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull AdminCronTasksAdapter.CronTasksViewHolder holder, int position) {
|
||||
|
||||
Cron currentItem = tasksList.get(position);
|
||||
|
||||
holder.cronTasks = currentItem;
|
||||
holder.taskName.setText(StringUtils.capitalize(currentItem.getName().replace("_", " ")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return tasksList.size();
|
||||
}
|
||||
|
||||
static class CronTasksViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Cron cronTasks;
|
||||
|
||||
private final TextView taskName;
|
||||
private Cron cronTasks;
|
||||
|
||||
private CronTasksViewHolder(View itemView) {
|
||||
|
||||
|
@ -91,71 +157,4 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
|
|||
|
||||
}
|
||||
|
||||
public AdminCronTasksAdapter(List<Cron> tasksListMain) {
|
||||
this.tasksList = tasksListMain;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public AdminCronTasksAdapter.CronTasksViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_admin_cron_tasks, parent, false);
|
||||
return new AdminCronTasksAdapter.CronTasksViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull AdminCronTasksAdapter.CronTasksViewHolder holder, int position) {
|
||||
|
||||
Cron currentItem = tasksList.get(position);
|
||||
|
||||
holder.cronTasks = currentItem;
|
||||
holder.taskName.setText(StringUtils.capitalize(currentItem.getName().replace("_", " ")));
|
||||
}
|
||||
|
||||
private static void runCronTask(final Context ctx, final String taskName) {
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).adminCronRun(taskName);
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
case 204:
|
||||
Toasty.success(ctx, ctx.getString(R.string.adminCronTaskSuccessMsg, taskName));
|
||||
break;
|
||||
|
||||
case 401:
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
break;
|
||||
|
||||
case 403:
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
break;
|
||||
|
||||
case 404:
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
break;
|
||||
|
||||
default:
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return tasksList.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,11 +30,44 @@ import java.util.List;
|
|||
|
||||
public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Filterable {
|
||||
|
||||
private List<User> usersList;
|
||||
private final List<User> usersListFull;
|
||||
private final Context context;
|
||||
private List<User> usersList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final Filter usersFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<User> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(usersListFull);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(User item : usersListFull) {
|
||||
if(item.getEmail().toLowerCase().contains(filterPattern) || item.getFullName().toLowerCase().contains(filterPattern) || item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
usersList.clear();
|
||||
usersList.addAll((List) results.values);
|
||||
notifyDataChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public AdminGetUsersAdapter(List<User> usersListMain, Context ctx) {
|
||||
this.context = ctx;
|
||||
|
@ -69,14 +102,50 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
return usersList.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<User> list) {
|
||||
usersList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return usersFilter;
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
class ReposHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private String userLoginId;
|
||||
private final ImageView userAvatar;
|
||||
private final TextView userFullName;
|
||||
private final TextView userEmail;
|
||||
private final ImageView userRole;
|
||||
private final TextView userName;
|
||||
private String userLoginId;
|
||||
|
||||
ReposHolder(View itemView) {
|
||||
|
||||
|
@ -126,10 +195,8 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
if(users.isIsAdmin()) {
|
||||
|
||||
userRole.setVisibility(View.VISIBLE);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig()
|
||||
.textColor(ResourcesCompat.getColor(context.getResources(), R.color.colorWhite, null)).fontSize(44).width(180).height(60)
|
||||
.endConfig().buildRoundRect(context.getResources().getString(R.string.userRoleAdmin).toLowerCase(),
|
||||
ResourcesCompat.getColor(context.getResources(), R.color.releasePre, null), 8);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().textColor(ResourcesCompat.getColor(context.getResources(), R.color.colorWhite, null)).fontSize(44).width(180).height(60).endConfig()
|
||||
.buildRoundRect(context.getResources().getString(R.string.userRoleAdmin).toLowerCase(), ResourcesCompat.getColor(context.getResources(), R.color.releasePre, null), 8);
|
||||
userRole.setImageDrawable(drawable);
|
||||
}
|
||||
else {
|
||||
|
@ -137,81 +204,9 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
userRole.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
PicassoService.getInstance(context).get().load(users.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(userAvatar);
|
||||
PicassoService.getInstance(context).get().load(users.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(userAvatar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<User> list) {
|
||||
usersList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return usersFilter;
|
||||
}
|
||||
|
||||
private final Filter usersFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<User> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(usersListFull);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(User item : usersListFull) {
|
||||
if(item.getEmail().toLowerCase().contains(filterPattern) || item.getFullName().toLowerCase()
|
||||
.contains(filterPattern) || item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
usersList.clear();
|
||||
usersList.addAll((List) results.values);
|
||||
notifyDataChanged();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -25,36 +25,13 @@ import retrofit2.Callback;
|
|||
|
||||
public class AdminUnadoptedReposAdapter extends RecyclerView.Adapter<AdminUnadoptedReposAdapter.UnadoptedViewHolder> {
|
||||
|
||||
private List<String> repos;
|
||||
private final Runnable updateList;
|
||||
private final Runnable loadMoreListener;
|
||||
private boolean isLoading = false, hasMore = true;
|
||||
private final ActivityAdminCronTasksBinding activityAdminCronTasksBinding;
|
||||
private List<String> repos;
|
||||
private boolean isLoading = false, hasMore = true;
|
||||
|
||||
class UnadoptedViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private String repoName;
|
||||
private final TextView name;
|
||||
|
||||
private UnadoptedViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
Context ctx = itemView.getContext();
|
||||
|
||||
name = itemView.findViewById(R.id.repo_name);
|
||||
|
||||
itemView.setOnClickListener(taskInfo -> {
|
||||
String[] repoSplit = repoName.split("/");
|
||||
new AlertDialog.Builder(ctx).setTitle(repoName).setMessage(ctx.getString(R.string.unadoptedReposMessage, repoSplit[1], repoSplit[0]))
|
||||
.setNeutralButton(R.string.close, null).setPositiveButton(R.string.menuDeleteText, ((dialog, which) -> delete(ctx, repoName)))
|
||||
.setNegativeButton(R.string.adoptRepo, ((dialog, which) -> adopt(ctx, repoName, getBindingAdapterPosition()))).show();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public AdminUnadoptedReposAdapter(List<String> list, Runnable updateList, Runnable loadMore,
|
||||
ActivityAdminCronTasksBinding activityAdminCronTasksBinding) {
|
||||
public AdminUnadoptedReposAdapter(List<String> list, Runnable updateList, Runnable loadMore, ActivityAdminCronTasksBinding activityAdminCronTasksBinding) {
|
||||
this.repos = list;
|
||||
this.updateList = updateList;
|
||||
this.loadMoreListener = loadMore;
|
||||
|
@ -195,4 +172,26 @@ public class AdminUnadoptedReposAdapter extends RecyclerView.Adapter<AdminUnadop
|
|||
isLoading = false;
|
||||
}
|
||||
|
||||
class UnadoptedViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView name;
|
||||
private String repoName;
|
||||
|
||||
private UnadoptedViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
Context ctx = itemView.getContext();
|
||||
|
||||
name = itemView.findViewById(R.id.repo_name);
|
||||
|
||||
itemView.setOnClickListener(taskInfo -> {
|
||||
String[] repoSplit = repoName.split("/");
|
||||
new AlertDialog.Builder(ctx).setTitle(repoName).setMessage(ctx.getString(R.string.unadoptedReposMessage, repoSplit[1], repoSplit[0])).setNeutralButton(R.string.close, null)
|
||||
.setPositiveButton(R.string.menuDeleteText, ((dialog, which) -> delete(ctx, repoName))).setNegativeButton(R.string.adoptRepo, ((dialog, which) -> adopt(ctx, repoName, getBindingAdapterPosition())))
|
||||
.show();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,17 +28,10 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||
|
||||
private final Context context;
|
||||
private final List<User> assigneesList;
|
||||
private final AssigneesListAdapterListener assigneesListener;
|
||||
private List<String> assigneesStrings = new ArrayList<>();
|
||||
private List<String> currentAssignees;
|
||||
|
||||
private final AssigneesListAdapterListener assigneesListener;
|
||||
|
||||
public interface AssigneesListAdapterListener {
|
||||
|
||||
void assigneesInterface(List<String> data);
|
||||
|
||||
}
|
||||
|
||||
public AssigneesListAdapter(Context ctx, List<User> dataMain, AssigneesListAdapterListener assigneesListener, List<String> currentAssignees) {
|
||||
|
||||
this.context = ctx;
|
||||
|
@ -47,24 +40,6 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||
this.currentAssignees = currentAssignees;
|
||||
}
|
||||
|
||||
static class AssigneesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final CheckBox assigneesSelection;
|
||||
private final TextView assigneesName;
|
||||
private final ImageView assigneesAvatar;
|
||||
|
||||
private AssigneesViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
this.setIsRecyclable(false);
|
||||
|
||||
assigneesSelection = itemView.findViewById(R.id.assigneesSelection);
|
||||
assigneesName = itemView.findViewById(R.id.assigneesName);
|
||||
assigneesAvatar = itemView.findViewById(R.id.assigneesAvatar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public AssigneesListAdapter.AssigneesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
@ -87,8 +62,8 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||
|
||||
holder.assigneesName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
}
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(holder.assigneesAvatar);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).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++) {
|
||||
|
||||
|
@ -141,4 +116,28 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
|
|||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public interface AssigneesListAdapterListener {
|
||||
|
||||
void assigneesInterface(List<String> data);
|
||||
|
||||
}
|
||||
|
||||
static class AssigneesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final CheckBox assigneesSelection;
|
||||
private final TextView assigneesName;
|
||||
private final ImageView assigneesAvatar;
|
||||
|
||||
private AssigneesViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
this.setIsRecyclable(false);
|
||||
|
||||
assigneesSelection = itemView.findViewById(R.id.assigneesSelection);
|
||||
assigneesName = itemView.findViewById(R.id.assigneesName);
|
||||
assigneesAvatar = itemView.findViewById(R.id.assigneesAvatar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,61 +45,6 @@ public class CollaboratorSearchAdapter extends RecyclerView.Adapter<Collaborator
|
|||
this.repository = repository;
|
||||
}
|
||||
|
||||
class CollaboratorSearchViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private User userInfo;
|
||||
|
||||
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;
|
||||
|
||||
private CollaboratorSearchViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
userAvatar = itemView.findViewById(R.id.userAvatar);
|
||||
userFullName = itemView.findViewById(R.id.userFullName);
|
||||
userName = itemView.findViewById(R.id.userName);
|
||||
addCollaboratorButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
|
||||
addCollaboratorButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
|
||||
|
||||
addCollaboratorButtonAdd.setOnClickListener(v -> {
|
||||
AlertDialog.Builder pBuilder = new AlertDialog.Builder(context);
|
||||
|
||||
pBuilder.setTitle(R.string.newTeamPermission);
|
||||
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, null).setCancelable(false)
|
||||
.setNeutralButton(R.string.cancelButton, null).setPositiveButton(R.string.addButton, (dialog, which) -> {
|
||||
|
||||
ListView lw = ((AlertDialog) dialog).getListView();
|
||||
Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition());
|
||||
|
||||
CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userInfo.getLogin(), repository);
|
||||
});
|
||||
|
||||
AlertDialog pDialog = pBuilder.create();
|
||||
pDialog.show();
|
||||
});
|
||||
|
||||
addCollaboratorButtonRemove.setOnClickListener(v -> AlertDialogs.collaboratorRemoveDialog(context, userInfo.getLogin(), repository));
|
||||
|
||||
userAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userInfo.getLogin());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
userAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userInfo.getLogin(), context.getString(R.string.copyLoginIdToClipBoard, userInfo.getLogin()));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public CollaboratorSearchViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
@ -126,16 +71,15 @@ public class CollaboratorSearchAdapter extends RecyclerView.Adapter<Collaborator
|
|||
holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
|
||||
if(!currentItem.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(holder.userAvatar);
|
||||
}
|
||||
|
||||
if(getItemCount() > 0) {
|
||||
|
||||
final String loginUid = ((BaseActivity) context).getAccount().getAccount().getUserName();
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context)
|
||||
.repoCheckCollaborator(repository.getOwner(), repository.getName(), currentItem.getLogin());
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).repoCheckCollaborator(repository.getOwner(), repository.getName(), currentItem.getLogin());
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
|
@ -181,4 +125,56 @@ public class CollaboratorSearchAdapter extends RecyclerView.Adapter<Collaborator
|
|||
return usersSearchList.size();
|
||||
}
|
||||
|
||||
class CollaboratorSearchViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
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;
|
||||
private User userInfo;
|
||||
|
||||
private CollaboratorSearchViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
userAvatar = itemView.findViewById(R.id.userAvatar);
|
||||
userFullName = itemView.findViewById(R.id.userFullName);
|
||||
userName = itemView.findViewById(R.id.userName);
|
||||
addCollaboratorButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
|
||||
addCollaboratorButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
|
||||
|
||||
addCollaboratorButtonAdd.setOnClickListener(v -> {
|
||||
AlertDialog.Builder pBuilder = new AlertDialog.Builder(context);
|
||||
|
||||
pBuilder.setTitle(R.string.newTeamPermission);
|
||||
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, null).setCancelable(false).setNeutralButton(R.string.cancelButton, null).setPositiveButton(R.string.addButton, (dialog, which) -> {
|
||||
|
||||
ListView lw = ((AlertDialog) dialog).getListView();
|
||||
Object checkedItem = lw.getAdapter().getItem(lw.getCheckedItemPosition());
|
||||
|
||||
CollaboratorActions.addCollaborator(context, String.valueOf(checkedItem).toLowerCase(), userInfo.getLogin(), repository);
|
||||
});
|
||||
|
||||
AlertDialog pDialog = pBuilder.create();
|
||||
pDialog.show();
|
||||
});
|
||||
|
||||
addCollaboratorButtonRemove.setOnClickListener(v -> AlertDialogs.collaboratorRemoveDialog(context, userInfo.getLogin(), repository));
|
||||
|
||||
userAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userInfo.getLogin());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
userAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userInfo.getLogin(), context.getString(R.string.copyLoginIdToClipBoard, userInfo.getLogin()));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,32 +27,6 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
|||
private final List<User> collaboratorsList;
|
||||
private final Context context;
|
||||
|
||||
private class ViewHolder {
|
||||
|
||||
private String userLoginId;
|
||||
|
||||
private final ImageView collaboratorAvatar;
|
||||
private final TextView collaboratorName;
|
||||
|
||||
ViewHolder(View v) {
|
||||
|
||||
collaboratorAvatar = v.findViewById(R.id.collaboratorAvatar);
|
||||
collaboratorName = v.findViewById(R.id.collaboratorName);
|
||||
|
||||
collaboratorAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userLoginId);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
collaboratorAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public CollaboratorsAdapter(Context ctx, List<User> collaboratorsListMain) {
|
||||
|
||||
this.context = ctx;
|
||||
|
@ -100,8 +74,8 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
|||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
User currentItem = collaboratorsList.get(position);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop().into(viewHolder.collaboratorAvatar);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(180, 180).centerCrop()
|
||||
.into(viewHolder.collaboratorAvatar);
|
||||
|
||||
viewHolder.userLoginId = currentItem.getLogin();
|
||||
|
||||
|
@ -116,4 +90,29 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
|||
|
||||
}
|
||||
|
||||
private class ViewHolder {
|
||||
|
||||
private final ImageView collaboratorAvatar;
|
||||
private final TextView collaboratorName;
|
||||
private String userLoginId;
|
||||
|
||||
ViewHolder(View v) {
|
||||
|
||||
collaboratorAvatar = v.findViewById(R.id.collaboratorAvatar);
|
||||
collaboratorName = v.findViewById(R.id.collaboratorName);
|
||||
|
||||
collaboratorAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userLoginId);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
collaboratorAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,6 +71,25 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
return commitsList.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Commit> list) {
|
||||
commitsList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class CommitsHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
View rootView;
|
||||
|
@ -104,27 +123,24 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
|
||||
if(!Objects.equals(commitsModel.getCommit().getCommitter().getEmail(), commitsModel.getCommit().getAuthor().getEmail())) {
|
||||
commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(
|
||||
context.getString(R.string.commitAuthoredByAndCommittedByWhen, commitsModel.getCommit().getAuthor().getName(),
|
||||
commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()),
|
||||
context.getResources().getConfiguration().locale, "pretty", context)), HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
context.getString(R.string.commitAuthoredByAndCommittedByWhen, commitsModel.getCommit().getAuthor().getName(), commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), context.getResources().getConfiguration().locale, "pretty", context)),
|
||||
HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
}
|
||||
else {
|
||||
commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(
|
||||
context.getString(R.string.commitCommittedByWhen, commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()),
|
||||
context.getResources().getConfiguration().locale, "pretty", context)), HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(context.getString(R.string.commitCommittedByWhen, commitsModel.getCommit().getCommitter().getName(),
|
||||
TimeHelper.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), context.getResources().getConfiguration().locale, "pretty", context)),
|
||||
HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
}
|
||||
|
||||
if(commitsModel.getAuthor() != null && commitsModel.getAuthor().getAvatarUrl() != null && !commitsModel.getAuthor().getAvatarUrl()
|
||||
.isEmpty()) {
|
||||
if(commitsModel.getAuthor() != null && commitsModel.getAuthor().getAvatarUrl() != null && !commitsModel.getAuthor().getAvatarUrl().isEmpty()) {
|
||||
|
||||
commitAuthorAvatar.setVisibility(View.VISIBLE);
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get().load(commitsModel.getAuthor().getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(commitAuthorAvatar);
|
||||
PicassoService.getInstance(context).get().load(commitsModel.getAuthor().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120)
|
||||
.centerCrop().into(commitAuthorAvatar);
|
||||
|
||||
}
|
||||
else {
|
||||
|
@ -132,16 +148,15 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
commitAuthorAvatar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(commitsModel.getCommitter() != null && (commitsModel.getAuthor() == null || !commitsModel.getAuthor().getLogin()
|
||||
.equals(commitsModel.getCommitter().getLogin())) && commitsModel.getCommitter().getAvatarUrl() != null && !commitsModel.getCommitter()
|
||||
.getAvatarUrl().isEmpty()) {
|
||||
if(commitsModel.getCommitter() != null && (commitsModel.getAuthor() == null || !commitsModel.getAuthor().getLogin().equals(commitsModel.getCommitter().getLogin())) && commitsModel.getCommitter()
|
||||
.getAvatarUrl() != null && !commitsModel.getCommitter().getAvatarUrl().isEmpty()) {
|
||||
|
||||
commitCommitterAvatar.setVisibility(View.VISIBLE);
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get().load(commitsModel.getCommitter().getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(commitCommitterAvatar);
|
||||
PicassoService.getInstance(context).get().load(commitsModel.getCommitter().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120)
|
||||
.centerCrop().into(commitCommitterAvatar);
|
||||
|
||||
}
|
||||
else {
|
||||
|
@ -156,8 +171,7 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
intent = ((CommitsActivity) context).repository.getIntent(context, CommitDetailActivity.class);
|
||||
}
|
||||
else {
|
||||
intent = IssueContext.fromIntent(((DiffActivity) context).getIntent()).getRepository()
|
||||
.getIntent(context, CommitDetailActivity.class);
|
||||
intent = IssueContext.fromIntent(((DiffActivity) context).getIntent()).getRepository().getIntent(context, CommitDetailActivity.class);
|
||||
}
|
||||
intent.putExtra("sha", commitsModel.getSha());
|
||||
context.startActivity(intent);
|
||||
|
@ -167,23 +181,4 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Commit> list) {
|
||||
commitsList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,20 +23,18 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class DiffAdapter extends BaseAdapter {
|
||||
|
||||
private final Context context;
|
||||
private final FragmentManager fragmentManager;
|
||||
private final List<String> lines;
|
||||
private final IssueContext issue;
|
||||
|
||||
private final List<Integer> selectedLines;
|
||||
private final Typeface typeface;
|
||||
private final String type;
|
||||
|
||||
private static int COLOR_ADDED;
|
||||
private static int COLOR_REMOVED;
|
||||
private static int COLOR_NORMAL;
|
||||
private static int COLOR_SELECTED;
|
||||
private static int COLOR_FONT;
|
||||
private final Context context;
|
||||
private final FragmentManager fragmentManager;
|
||||
private final List<String> lines;
|
||||
private final IssueContext issue;
|
||||
private final List<Integer> selectedLines;
|
||||
private final Typeface typeface;
|
||||
private final String type;
|
||||
|
||||
public DiffAdapter(Context context, FragmentManager fragmentManager, List<String> lines, IssueContext issue, String type) {
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@ public class DiffFilesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
private static final Pattern statisticsPattern = Pattern.compile("(\\d+).*?,.*?(\\d+)");
|
||||
|
||||
private final Context context;
|
||||
private List<FileDiffView> fileDiffViews;
|
||||
private final IssueContext issue;
|
||||
private final String fragmentType;
|
||||
private List<FileDiffView> fileDiffViews;
|
||||
|
||||
public DiffFilesAdapter(Context context, List<FileDiffView> fileDiffViews, IssueContext issue, String fragmentType) {
|
||||
|
||||
|
@ -53,6 +53,25 @@ public class DiffFilesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
((DiffFilesAdapter.FilesHolder) holder).bindData(fileDiffViews.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return fileDiffViews.size();
|
||||
}
|
||||
|
||||
public void updateList(List<FileDiffView> list) {
|
||||
fileDiffViews = list;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
class FilesHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
FileDiffView diffFilesObject;
|
||||
|
@ -70,12 +89,10 @@ public class DiffFilesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
|
||||
main_frame.setOnClickListener(v -> {
|
||||
if(fragmentType.equalsIgnoreCase("commit")) {
|
||||
((CommitDetailActivity) context).getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragment_container, DiffFragment.newInstance(diffFilesObject, fragmentType)).commit();
|
||||
((CommitDetailActivity) context).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, DiffFragment.newInstance(diffFilesObject, fragmentType)).commit();
|
||||
}
|
||||
else {
|
||||
((DiffActivity) context).getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragment_container, DiffFragment.newInstance(diffFilesObject, issue)).commit();
|
||||
((DiffActivity) context).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, DiffFragment.newInstance(diffFilesObject, issue)).commit();
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -98,23 +115,4 @@ public class DiffFilesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return fileDiffViews.size();
|
||||
}
|
||||
|
||||
public void updateList(List<FileDiffView> list) {
|
||||
fileDiffViews = list;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,70 +33,9 @@ import java.util.List;
|
|||
|
||||
public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsViewHolder> {
|
||||
|
||||
private List<DraftWithRepository> draftsList;
|
||||
private final FragmentManager fragmentManager;
|
||||
private final Context context;
|
||||
|
||||
class DraftsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private DraftWithRepository draftWithRepository;
|
||||
|
||||
private final TextView draftText;
|
||||
private final TextView repoInfo;
|
||||
private final ImageView editCommentStatus;
|
||||
|
||||
private DraftsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
draftText = itemView.findViewById(R.id.draftText);
|
||||
repoInfo = itemView.findViewById(R.id.repoInfo);
|
||||
ImageView deleteDraft = itemView.findViewById(R.id.deleteDraft);
|
||||
editCommentStatus = itemView.findViewById(R.id.editCommentStatus);
|
||||
|
||||
deleteDraft.setOnClickListener(itemDelete -> {
|
||||
|
||||
int getDraftId = draftWithRepository.getDraftId();
|
||||
deleteDraft(getBindingAdapterPosition());
|
||||
|
||||
DraftsApi draftsApi = BaseApi.getInstance(context, DraftsApi.class);
|
||||
assert draftsApi != null;
|
||||
draftsApi.deleteSingleDraft(getDraftId);
|
||||
|
||||
});
|
||||
|
||||
itemView.setOnClickListener(itemEdit -> {
|
||||
|
||||
RepositoryContext repository = new RepositoryContext(draftWithRepository.getRepositoryOwner(),
|
||||
draftWithRepository.getRepositoryName(), context);
|
||||
repository.setRepositoryId(draftWithRepository.getRepositoryId());
|
||||
IssueContext issue = new IssueContext(repository, draftWithRepository.getIssueId(), draftWithRepository.getIssueType());
|
||||
Bundle bundle = issue.getBundle();
|
||||
|
||||
bundle.putString("commentBody", draftWithRepository.getDraftText());
|
||||
bundle.putString("issueNumber", String.valueOf(draftWithRepository.getIssueId()));
|
||||
bundle.putString("draftTitle", repoInfo.getText().toString());
|
||||
bundle.putString("commentId", draftWithRepository.getCommentId());
|
||||
bundle.putString("draftId", String.valueOf(draftWithRepository.getDraftId()));
|
||||
|
||||
if(!draftWithRepository.getCommentId().isEmpty()) {
|
||||
bundle.putString("commentAction", "edit");
|
||||
}
|
||||
|
||||
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle, issue);
|
||||
bottomSheetReplyFragment.setOnInteractedListener(() -> {
|
||||
Intent i = new IssueContext(
|
||||
new RepositoryContext(draftWithRepository.getRepositoryOwner(), draftWithRepository.getRepositoryName(), context),
|
||||
draftWithRepository.getIssueId(), draftWithRepository.getIssueType()).getIntent(context, IssueDetailActivity.class);
|
||||
i.putExtra("openedFromLink", "true");
|
||||
context.startActivity(i);
|
||||
});
|
||||
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private List<DraftWithRepository> draftsList;
|
||||
|
||||
public DraftsAdapter(Context ctx, FragmentManager fragmentManager, List<DraftWithRepository> draftsListMain) {
|
||||
this.context = ctx;
|
||||
|
@ -125,10 +64,8 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||
|
||||
DraftWithRepository currentItem = draftsList.get(position);
|
||||
|
||||
String issueNumber = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray,
|
||||
null) + "'>" + context.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
|
||||
Spanned headTitle = HtmlCompat.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName(),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY);
|
||||
String issueNumber = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + currentItem.getIssueId() + "</font>";
|
||||
Spanned headTitle = HtmlCompat.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName(), HtmlCompat.FROM_HTML_MODE_LEGACY);
|
||||
|
||||
holder.repoInfo.setText(headTitle);
|
||||
holder.draftWithRepository = currentItem;
|
||||
|
@ -154,4 +91,62 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
|
|||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
class DraftsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView draftText;
|
||||
private final TextView repoInfo;
|
||||
private final ImageView editCommentStatus;
|
||||
private DraftWithRepository draftWithRepository;
|
||||
|
||||
private DraftsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
draftText = itemView.findViewById(R.id.draftText);
|
||||
repoInfo = itemView.findViewById(R.id.repoInfo);
|
||||
ImageView deleteDraft = itemView.findViewById(R.id.deleteDraft);
|
||||
editCommentStatus = itemView.findViewById(R.id.editCommentStatus);
|
||||
|
||||
deleteDraft.setOnClickListener(itemDelete -> {
|
||||
|
||||
int getDraftId = draftWithRepository.getDraftId();
|
||||
deleteDraft(getBindingAdapterPosition());
|
||||
|
||||
DraftsApi draftsApi = BaseApi.getInstance(context, DraftsApi.class);
|
||||
assert draftsApi != null;
|
||||
draftsApi.deleteSingleDraft(getDraftId);
|
||||
|
||||
});
|
||||
|
||||
itemView.setOnClickListener(itemEdit -> {
|
||||
|
||||
RepositoryContext repository = new RepositoryContext(draftWithRepository.getRepositoryOwner(), draftWithRepository.getRepositoryName(), context);
|
||||
repository.setRepositoryId(draftWithRepository.getRepositoryId());
|
||||
IssueContext issue = new IssueContext(repository, draftWithRepository.getIssueId(), draftWithRepository.getIssueType());
|
||||
Bundle bundle = issue.getBundle();
|
||||
|
||||
bundle.putString("commentBody", draftWithRepository.getDraftText());
|
||||
bundle.putString("issueNumber", String.valueOf(draftWithRepository.getIssueId()));
|
||||
bundle.putString("draftTitle", repoInfo.getText().toString());
|
||||
bundle.putString("commentId", draftWithRepository.getCommentId());
|
||||
bundle.putString("draftId", String.valueOf(draftWithRepository.getDraftId()));
|
||||
|
||||
if(!draftWithRepository.getCommentId().isEmpty()) {
|
||||
bundle.putString("commentAction", "edit");
|
||||
}
|
||||
|
||||
BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(bundle, issue);
|
||||
bottomSheetReplyFragment.setOnInteractedListener(() -> {
|
||||
Intent i = new IssueContext(new RepositoryContext(draftWithRepository.getRepositoryOwner(), draftWithRepository.getRepositoryName(), context), draftWithRepository.getIssueId(),
|
||||
draftWithRepository.getIssueType()).getIntent(context, IssueDetailActivity.class);
|
||||
i.putExtra("openedFromLink", "true");
|
||||
context.startActivity(i);
|
||||
});
|
||||
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,10 +46,10 @@ import java.util.Locale;
|
|||
public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private final TinyDB tinyDb;
|
||||
private List<Issue> searchedList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final TinyDB tinyDb;
|
||||
|
||||
public ExploreIssuesAdapter(List<Issue> dataList, Context ctx) {
|
||||
this.context = ctx;
|
||||
|
@ -84,9 +84,38 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
return searchedList.size();
|
||||
}
|
||||
|
||||
class IssuesHolder extends RecyclerView.ViewHolder {
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
private Issue issue;
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Issue> list) {
|
||||
searchedList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
class IssuesHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView issueAssigneeAvatar;
|
||||
private final TextView issueTitle;
|
||||
|
@ -96,6 +125,7 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
private final LinearLayout frameLabels;
|
||||
private final HorizontalScrollView labelsScrollViewDots;
|
||||
private final LinearLayout frameLabelsDots;
|
||||
private Issue issue;
|
||||
|
||||
IssuesHolder(View itemView) {
|
||||
|
||||
|
@ -134,8 +164,7 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
});
|
||||
|
||||
issueAssigneeAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, issue.getUser().getLogin(),
|
||||
context.getString(R.string.copyLoginIdToClipBoard, issue.getUser().getLogin()));
|
||||
AppUtil.copyToClipboard(context, issue.getUser().getLogin(), context.getString(R.string.copyLoginIdToClipBoard, issue.getUser().getLogin()));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -148,17 +177,16 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
Locale locale = context.getResources().getConfiguration().locale;
|
||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
|
||||
PicassoService.getInstance(context).get().load(issue.getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(issueAssigneeAvatar);
|
||||
PicassoService.getInstance(context).get().load(issue.getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(issueAssigneeAvatar);
|
||||
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray,
|
||||
null) + "'>" + issue.getRepository().getFullName() + context.getResources().getString(R.string.hash) + issue.getNumber() + "</font>";
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + issue.getRepository().getFullName() + context.getResources()
|
||||
.getString(R.string.hash) + issue.getNumber() + "</font>";
|
||||
|
||||
issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + issue.getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
issueCommentsCount.setText(String.valueOf(issue.getComments()));
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
|
||||
if(issue.getLabels() != null) {
|
||||
|
@ -179,8 +207,7 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
frameLabelsDots.setGravity(Gravity.START | Gravity.TOP);
|
||||
labelsView.setLayoutParams(params);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).width(54).height(54).endConfig()
|
||||
.buildRound("", color);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).width(54).height(54).endConfig().buildRound("", color);
|
||||
|
||||
labelsView.setImageDrawable(drawable);
|
||||
frameLabelsDots.addView(labelsView);
|
||||
|
@ -206,10 +233,8 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
int height = AppUtil.getPixelsFromDensity(context, 20);
|
||||
int textSize = AppUtil.getPixelsFromScaledDensity(context, 12);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT)
|
||||
.textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize).width(
|
||||
LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize,
|
||||
AppUtil.getPixelsFromDensity(context, 8))).height(height).endConfig()
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(context, 8))).height(height).endConfig()
|
||||
.buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(context, 18));
|
||||
|
||||
labelsView.setImageDrawable(drawable);
|
||||
|
@ -227,20 +252,17 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
PrettyTime prettyTime = new PrettyTime(locale);
|
||||
String createdTime = prettyTime.format(issue.getCreatedAt());
|
||||
issueCreatedTime.setText(createdTime);
|
||||
issueCreatedTime.setOnClickListener(
|
||||
new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getCreatedAt()), context));
|
||||
issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getCreatedAt()), context));
|
||||
break;
|
||||
}
|
||||
case "normal": {
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm",
|
||||
locale);
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(issue.getCreatedAt());
|
||||
issueCreatedTime.setText(createdTime);
|
||||
break;
|
||||
}
|
||||
case "normal1": {
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm",
|
||||
locale);
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(issue.getCreatedAt());
|
||||
issueCreatedTime.setText(createdTime);
|
||||
break;
|
||||
|
@ -251,35 +273,4 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Issue> list) {
|
||||
searchedList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,10 +36,10 @@ import java.util.Locale;
|
|||
public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private final TinyDB tinyDb;
|
||||
private List<org.gitnex.tea4j.v2.models.Repository> reposList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final TinyDB tinyDb;
|
||||
|
||||
public ExploreRepositoriesAdapter(List<org.gitnex.tea4j.v2.models.Repository> dataList, Context ctx) {
|
||||
this.context = ctx;
|
||||
|
@ -73,18 +73,36 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||
return reposList.size();
|
||||
}
|
||||
|
||||
class RepositoriesHolder extends RecyclerView.ViewHolder {
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class RepositoriesHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView repoName;
|
||||
private final TextView orgName;
|
||||
private final TextView repoDescription;
|
||||
private CheckBox isRepoAdmin;
|
||||
private final TextView repoStars;
|
||||
private final TextView repoLastUpdated;
|
||||
private final View spacerView;
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
private CheckBox isRepoAdmin;
|
||||
|
||||
RepositoriesHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
@ -123,13 +141,12 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||
int color = generator.getColor(userRepositories.getName());
|
||||
String firstCharacter = String.valueOf(userRepositories.getFullName().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(userRepositories.getAvatarUrl() != null) {
|
||||
if(!userRepositories.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(userRepositories.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
PicassoService.getInstance(context).get().load(userRepositories.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(image);
|
||||
}
|
||||
else {
|
||||
image.setImageDrawable(drawable);
|
||||
|
@ -146,20 +163,17 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||
PrettyTime prettyTime = new PrettyTime(locale);
|
||||
String createdTime = prettyTime.format(userRepositories.getUpdatedAt());
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||
repoLastUpdated.setOnClickListener(
|
||||
new ClickListener(TimeHelper.customDateFormatForToastDateFormat(userRepositories.getUpdatedAt()), context));
|
||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(userRepositories.getUpdatedAt()), context));
|
||||
break;
|
||||
}
|
||||
case "normal": {
|
||||
DateFormat formatter = new SimpleDateFormat(
|
||||
"yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(userRepositories.getUpdatedAt());
|
||||
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", locale);
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(userRepositories.getUpdatedAt());
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||
break;
|
||||
|
@ -188,23 +202,4 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,116 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
|||
private final Context context;
|
||||
|
||||
private final FilesAdapterListener filesListener;
|
||||
private final Filter filesFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
|
||||
List<ContentsResponse> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(originalFiles);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(ContentsResponse item : originalFiles) {
|
||||
if(item.getName().toLowerCase().contains(filterPattern) || item.getPath().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
alteredFiles.clear();
|
||||
alteredFiles.addAll((List) results.values);
|
||||
|
||||
notifyDataSetChanged();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public FilesAdapter(Context ctx, FilesAdapterListener filesListener) {
|
||||
|
||||
this.context = ctx;
|
||||
this.filesListener = filesListener;
|
||||
}
|
||||
|
||||
public List<ContentsResponse> getOriginalFiles() {
|
||||
return originalFiles;
|
||||
}
|
||||
|
||||
public void notifyOriginalDataSetChanged() {
|
||||
|
||||
alteredFiles.clear();
|
||||
alteredFiles.addAll(originalFiles);
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public FilesAdapter.FilesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_files, parent, false);
|
||||
return new FilesAdapter.FilesViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull FilesAdapter.FilesViewHolder holder, int position) {
|
||||
|
||||
ContentsResponse currentItem = alteredFiles.get(position);
|
||||
|
||||
holder.file = currentItem;
|
||||
holder.fileName.setText(currentItem.getName());
|
||||
|
||||
switch(currentItem.getType()) {
|
||||
|
||||
case "file":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_file));
|
||||
holder.fileInfo.setVisibility(View.VISIBLE);
|
||||
holder.fileInfo.setText(FileUtils.byteCountToDisplaySize(Math.toIntExact(currentItem.getSize())));
|
||||
break;
|
||||
|
||||
case "dir":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_directory));
|
||||
holder.fileInfo.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
case "submodule":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_submodule));
|
||||
holder.fileInfo.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
case "symlink":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_symlink));
|
||||
holder.fileInfo.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
default:
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_question));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return alteredFiles.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return filesFilter;
|
||||
}
|
||||
|
||||
public interface FilesAdapterListener {
|
||||
|
||||
|
@ -39,11 +149,10 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
|||
|
||||
class FilesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private ContentsResponse file;
|
||||
|
||||
private final ImageView fileTypeIs;
|
||||
private final TextView fileName;
|
||||
private final TextView fileInfo;
|
||||
private ContentsResponse file;
|
||||
|
||||
private FilesViewHolder(View itemView) {
|
||||
|
||||
|
@ -125,115 +234,4 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
|
|||
|
||||
}
|
||||
|
||||
public FilesAdapter(Context ctx, FilesAdapterListener filesListener) {
|
||||
|
||||
this.context = ctx;
|
||||
this.filesListener = filesListener;
|
||||
}
|
||||
|
||||
public List<ContentsResponse> getOriginalFiles() {
|
||||
return originalFiles;
|
||||
}
|
||||
|
||||
public void notifyOriginalDataSetChanged() {
|
||||
|
||||
alteredFiles.clear();
|
||||
alteredFiles.addAll(originalFiles);
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public FilesAdapter.FilesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_files, parent, false);
|
||||
return new FilesAdapter.FilesViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull FilesAdapter.FilesViewHolder holder, int position) {
|
||||
|
||||
ContentsResponse currentItem = alteredFiles.get(position);
|
||||
|
||||
holder.file = currentItem;
|
||||
holder.fileName.setText(currentItem.getName());
|
||||
|
||||
switch(currentItem.getType()) {
|
||||
|
||||
case "file":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_file));
|
||||
holder.fileInfo.setVisibility(View.VISIBLE);
|
||||
holder.fileInfo.setText(FileUtils.byteCountToDisplaySize(Math.toIntExact(currentItem.getSize())));
|
||||
break;
|
||||
|
||||
case "dir":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_directory));
|
||||
holder.fileInfo.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
case "submodule":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_submodule));
|
||||
holder.fileInfo.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
case "symlink":
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_symlink));
|
||||
holder.fileInfo.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
default:
|
||||
holder.fileTypeIs.setImageDrawable(AppCompatResources.getDrawable(context, R.drawable.ic_question));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return alteredFiles.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return filesFilter;
|
||||
}
|
||||
|
||||
private final Filter filesFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
|
||||
List<ContentsResponse> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(originalFiles);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(ContentsResponse item : originalFiles) {
|
||||
if(item.getName().toLowerCase().contains(filterPattern) || item.getPath().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
alteredFiles.clear();
|
||||
alteredFiles.addAll((List) results.values);
|
||||
|
||||
notifyDataSetChanged();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -57,8 +57,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||
private final Locale locale;
|
||||
private final IssueContext issue;
|
||||
|
||||
public IssueCommentsAdapter(Context ctx, Bundle bundle, List<Comment> issuesCommentsMain, FragmentManager fragmentManager,
|
||||
Runnable onInteractedListener, IssueContext issue) {
|
||||
public IssueCommentsAdapter(Context ctx, Bundle bundle, List<Comment> issuesCommentsMain, FragmentManager fragmentManager, Runnable onInteractedListener, IssueContext issue) {
|
||||
|
||||
this.context = ctx;
|
||||
this.bundle = bundle;
|
||||
|
@ -70,16 +69,131 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||
this.issue = issue;
|
||||
}
|
||||
|
||||
class IssueCommentViewHolder extends RecyclerView.ViewHolder {
|
||||
private void updateAdapter(int position) {
|
||||
|
||||
private String userLoginId;
|
||||
private Comment issueComment;
|
||||
issuesComments.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, issuesComments.size());
|
||||
}
|
||||
|
||||
private void deleteIssueComment(final Context ctx, final int commentId, int position) {
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx).issueDeleteComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) commentId);
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
case 204:
|
||||
updateAdapter(position);
|
||||
Toasty.success(ctx, ctx.getResources().getString(R.string.deleteCommentSuccess));
|
||||
IssuesFragment.resumeIssues = true;
|
||||
break;
|
||||
|
||||
case 401:
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
break;
|
||||
|
||||
case 403:
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
break;
|
||||
|
||||
case 404:
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
break;
|
||||
|
||||
default:
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public IssueCommentsAdapter.IssueCommentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_issue_comments, parent, false);
|
||||
return new IssueCommentsAdapter.IssueCommentViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull IssueCommentsAdapter.IssueCommentViewHolder holder, int position) {
|
||||
|
||||
String timeFormat = tinyDB.getString("dateFormat", "pretty");
|
||||
Comment issueComment = issuesComments.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
holder.userLoginId = issueComment.getUser().getLogin();
|
||||
|
||||
holder.issueComment = issueComment;
|
||||
holder.author.setText(issueComment.getUser().getLogin());
|
||||
|
||||
PicassoService.getInstance(context).get().load(issueComment.getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(AppUtil.getPixelsFromDensity(context, 35), AppUtil.getPixelsFromDensity(context, 35)).centerCrop().into(holder.avatar);
|
||||
|
||||
Markdown.render(context, EmojiParser.parseToUnicode(issueComment.getBody()), holder.comment, issue.getRepository());
|
||||
|
||||
StringBuilder informationBuilder = null;
|
||||
if(issueComment.getCreatedAt() != null) {
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreatedAt(), locale, "pretty", context));
|
||||
holder.information.setOnClickListener(v -> TimeHelper.customDateFormatForToastDateFormat(issueComment.getCreatedAt()));
|
||||
}
|
||||
else if(timeFormat.equals("normal")) {
|
||||
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreatedAt(), locale, "normal", context));
|
||||
}
|
||||
|
||||
if(!issueComment.getCreatedAt().equals(issueComment.getUpdatedAt())) {
|
||||
if(informationBuilder != null) {
|
||||
informationBuilder.append(context.getString(R.string.colorfulBulletSpan)).append(context.getString(R.string.modifiedText));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
holder.information.setText(informationBuilder);
|
||||
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putAll(bundle);
|
||||
bundle1.putInt("commentId", Math.toIntExact(issueComment.getId()));
|
||||
|
||||
ReactionList reactionList = new ReactionList(context, bundle1);
|
||||
|
||||
holder.commentReactionBadges.addView(reactionList);
|
||||
reactionList.setOnReactionAddedListener(() -> {
|
||||
|
||||
if(holder.commentReactionBadges.getVisibility() != View.VISIBLE) {
|
||||
holder.commentReactionBadges.post(() -> holder.commentReactionBadges.setVisibility(View.VISIBLE));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return issuesComments.size();
|
||||
}
|
||||
|
||||
class IssueCommentViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView avatar;
|
||||
private final TextView author;
|
||||
private final TextView information;
|
||||
private final RecyclerView comment;
|
||||
private final LinearLayout commentReactionBadges;
|
||||
private String userLoginId;
|
||||
private Comment issueComment;
|
||||
|
||||
private IssueCommentViewHolder(View view) {
|
||||
|
||||
|
@ -236,122 +350,4 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
|
|||
|
||||
}
|
||||
|
||||
private void updateAdapter(int position) {
|
||||
|
||||
issuesComments.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, issuesComments.size());
|
||||
}
|
||||
|
||||
private void deleteIssueComment(final Context ctx, final int commentId, int position) {
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(ctx)
|
||||
.issueDeleteComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) commentId);
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
switch(response.code()) {
|
||||
|
||||
case 204:
|
||||
updateAdapter(position);
|
||||
Toasty.success(ctx, ctx.getResources().getString(R.string.deleteCommentSuccess));
|
||||
IssuesFragment.resumeIssues = true;
|
||||
break;
|
||||
|
||||
case 401:
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
break;
|
||||
|
||||
case 403:
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
break;
|
||||
|
||||
case 404:
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
break;
|
||||
|
||||
default:
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public IssueCommentsAdapter.IssueCommentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_issue_comments, parent, false);
|
||||
return new IssueCommentsAdapter.IssueCommentViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull IssueCommentsAdapter.IssueCommentViewHolder holder, int position) {
|
||||
|
||||
String timeFormat = tinyDB.getString("dateFormat", "pretty");
|
||||
Comment issueComment = issuesComments.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
holder.userLoginId = issueComment.getUser().getLogin();
|
||||
|
||||
holder.issueComment = issueComment;
|
||||
holder.author.setText(issueComment.getUser().getLogin());
|
||||
|
||||
PicassoService.getInstance(context).get().load(issueComment.getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0))
|
||||
.resize(AppUtil.getPixelsFromDensity(context, 35), AppUtil.getPixelsFromDensity(context, 35)).centerCrop().into(holder.avatar);
|
||||
|
||||
Markdown.render(context, EmojiParser.parseToUnicode(issueComment.getBody()), holder.comment, issue.getRepository());
|
||||
|
||||
StringBuilder informationBuilder = null;
|
||||
if(issueComment.getCreatedAt() != null) {
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreatedAt(), locale, "pretty", context));
|
||||
holder.information.setOnClickListener(v -> TimeHelper.customDateFormatForToastDateFormat(issueComment.getCreatedAt()));
|
||||
}
|
||||
else if(timeFormat.equals("normal")) {
|
||||
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreatedAt(), locale, "normal", context));
|
||||
}
|
||||
|
||||
if(!issueComment.getCreatedAt().equals(issueComment.getUpdatedAt())) {
|
||||
if(informationBuilder != null) {
|
||||
informationBuilder.append(context.getString(R.string.colorfulBulletSpan)).append(context.getString(R.string.modifiedText));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
holder.information.setText(informationBuilder);
|
||||
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putAll(bundle);
|
||||
bundle1.putInt("commentId", Math.toIntExact(issueComment.getId()));
|
||||
|
||||
ReactionList reactionList = new ReactionList(context, bundle1);
|
||||
|
||||
holder.commentReactionBadges.addView(reactionList);
|
||||
reactionList.setOnReactionAddedListener(() -> {
|
||||
|
||||
if(holder.commentReactionBadges.getVisibility() != View.VISIBLE) {
|
||||
holder.commentReactionBadges.post(() -> holder.commentReactionBadges.setVisibility(View.VISIBLE));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return issuesComments.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,10 +46,10 @@ import java.util.Locale;
|
|||
public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
TinyDB tinyDb;
|
||||
private List<Issue> issuesList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
TinyDB tinyDb;
|
||||
|
||||
public IssuesAdapter(Context ctx, List<Issue> issuesListMain) {
|
||||
|
||||
|
@ -87,9 +87,26 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
return issuesList.size();
|
||||
}
|
||||
|
||||
class IssuesHolder extends RecyclerView.ViewHolder {
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
private Issue issueObject;
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Issue> list) {
|
||||
issuesList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class IssuesHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView issueAssigneeAvatar;
|
||||
private final TextView issueTitle;
|
||||
|
@ -99,6 +116,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
private final LinearLayout frameLabels;
|
||||
private final HorizontalScrollView labelsScrollViewDots;
|
||||
private final LinearLayout frameLabelsDots;
|
||||
private Issue issueObject;
|
||||
|
||||
IssuesHolder(View itemView) {
|
||||
|
||||
|
@ -113,8 +131,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
frameLabelsDots = itemView.findViewById(R.id.frameLabelsDots);
|
||||
|
||||
issueAssigneeAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, issueObject.getUser().getLogin(),
|
||||
context.getString(R.string.copyLoginIdToClipBoard, issueObject.getUser().getLogin()));
|
||||
AppUtil.copyToClipboard(context, issueObject.getUser().getLogin(), context.getString(R.string.copyLoginIdToClipBoard, issueObject.getUser().getLogin()));
|
||||
return true;
|
||||
});
|
||||
|
||||
|
@ -133,26 +150,22 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get().load(issue.getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(issueAssigneeAvatar);
|
||||
PicassoService.getInstance(context).get().load(issue.getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(issueAssigneeAvatar);
|
||||
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray,
|
||||
null) + "'>" + context.getResources().getString(R.string.hash) + issue.getNumber() + "</font>";
|
||||
issueTitle.setText(
|
||||
HtmlCompat.fromHtml(issueNumber_ + " " + EmojiParser.parseToUnicode(issue.getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
String issueNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + issue.getNumber() + "</font>";
|
||||
issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + EmojiParser.parseToUnicode(issue.getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
|
||||
this.issueObject = issue;
|
||||
this.issueCommentsCount.setText(String.valueOf(issue.getComments()));
|
||||
|
||||
Intent intentIssueDetail = new IssueContext(issueObject, ((RepoDetailActivity) context).repository).getIntent(context,
|
||||
IssueDetailActivity.class);
|
||||
Intent intentIssueDetail = new IssueContext(issueObject, ((RepoDetailActivity) context).repository).getIntent(context, IssueDetailActivity.class);
|
||||
|
||||
itemView.setOnClickListener(layoutView -> context.startActivity(intentIssueDetail));
|
||||
frameLabels.setOnClickListener(v -> context.startActivity(intentIssueDetail));
|
||||
frameLabelsDots.setOnClickListener(v -> context.startActivity(intentIssueDetail));
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
|
||||
if(issue.getLabels() != null) {
|
||||
|
@ -173,8 +186,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
frameLabelsDots.setGravity(Gravity.START | Gravity.TOP);
|
||||
labelsView.setLayoutParams(params);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).width(54).height(54).endConfig()
|
||||
.buildRound("", color);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).width(54).height(54).endConfig().buildRound("", color);
|
||||
|
||||
labelsView.setImageDrawable(drawable);
|
||||
frameLabelsDots.addView(labelsView);
|
||||
|
@ -200,10 +212,8 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
int height = AppUtil.getPixelsFromDensity(context, 20);
|
||||
int textSize = AppUtil.getPixelsFromScaledDensity(context, 12);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT)
|
||||
.textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize).width(
|
||||
LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize,
|
||||
AppUtil.getPixelsFromDensity(context, 8))).height(height).endConfig()
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(context, 8))).height(height).endConfig()
|
||||
.buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(context, 18));
|
||||
|
||||
labelsView.setImageDrawable(drawable);
|
||||
|
@ -217,20 +227,17 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
PrettyTime prettyTime = new PrettyTime(locale);
|
||||
String createdTime = prettyTime.format(issue.getCreatedAt());
|
||||
this.issueCreatedTime.setText(createdTime);
|
||||
this.issueCreatedTime.setOnClickListener(
|
||||
new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getCreatedAt()), context));
|
||||
this.issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getCreatedAt()), context));
|
||||
break;
|
||||
}
|
||||
case "normal": {
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm",
|
||||
locale);
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(issue.getCreatedAt());
|
||||
this.issueCreatedTime.setText(createdTime);
|
||||
break;
|
||||
}
|
||||
case "normal1": {
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm",
|
||||
locale);
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(issue.getCreatedAt());
|
||||
this.issueCreatedTime.setText(createdTime);
|
||||
break;
|
||||
|
@ -241,23 +248,4 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Issue> list) {
|
||||
issuesList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,13 +35,50 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
|||
private final String type;
|
||||
private final String orgName;
|
||||
|
||||
class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||
public LabelsAdapter(Context ctx, List<Label> labelsMain, String type, String orgName) {
|
||||
|
||||
private Label labels;
|
||||
this.labelsList = labelsMain;
|
||||
this.type = type;
|
||||
this.orgName = orgName;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LabelsAdapter.LabelsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_labels, parent, false);
|
||||
return new LabelsAdapter.LabelsViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull LabelsAdapter.LabelsViewHolder holder, int position) {
|
||||
|
||||
Label currentItem = labelsList.get(position);
|
||||
holder.labels = currentItem;
|
||||
|
||||
String labelColor = currentItem.getColor();
|
||||
String labelName = currentItem.getName();
|
||||
|
||||
int color = Color.parseColor("#" + labelColor);
|
||||
int contrastColor = new ColorInverter().getContrastColor(color);
|
||||
|
||||
ImageViewCompat.setImageTintList(holder.labelIcon, ColorStateList.valueOf(contrastColor));
|
||||
|
||||
holder.labelName.setTextColor(contrastColor);
|
||||
holder.labelName.setText(labelName);
|
||||
holder.labelView.setCardBackgroundColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return labelsList.size();
|
||||
}
|
||||
|
||||
class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final CardView labelView;
|
||||
private final ImageView labelIcon;
|
||||
private final TextView labelName;
|
||||
private Label labels;
|
||||
|
||||
private LabelsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
@ -105,42 +142,4 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
|||
|
||||
}
|
||||
|
||||
public LabelsAdapter(Context ctx, List<Label> labelsMain, String type, String orgName) {
|
||||
|
||||
this.labelsList = labelsMain;
|
||||
this.type = type;
|
||||
this.orgName = orgName;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LabelsAdapter.LabelsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_labels, parent, false);
|
||||
return new LabelsAdapter.LabelsViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull LabelsAdapter.LabelsViewHolder holder, int position) {
|
||||
|
||||
Label currentItem = labelsList.get(position);
|
||||
holder.labels = currentItem;
|
||||
|
||||
String labelColor = currentItem.getColor();
|
||||
String labelName = currentItem.getName();
|
||||
|
||||
int color = Color.parseColor("#" + labelColor);
|
||||
int contrastColor = new ColorInverter().getContrastColor(color);
|
||||
|
||||
ImageViewCompat.setImageTintList(holder.labelIcon, ColorStateList.valueOf(contrastColor));
|
||||
|
||||
holder.labelName.setTextColor(contrastColor);
|
||||
holder.labelName.setText(labelName);
|
||||
holder.labelView.setCardBackgroundColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return labelsList.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,20 +21,11 @@ import java.util.List;
|
|||
|
||||
public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.LabelsViewHolder> {
|
||||
|
||||
private List<Integer> currentLabelsIds;
|
||||
private final List<Label> labels;
|
||||
private final List<String> labelsStrings = new ArrayList<>();
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
|
||||
private final LabelsListAdapterListener labelsListener;
|
||||
|
||||
public interface LabelsListAdapterListener {
|
||||
|
||||
void labelsInterface(List<String> data);
|
||||
|
||||
void labelsIdsInterface(List<Integer> data);
|
||||
|
||||
}
|
||||
private List<Integer> currentLabelsIds;
|
||||
private List<Integer> labelsIds = new ArrayList<>();
|
||||
|
||||
public LabelsListAdapter(List<Label> labelsMain, LabelsListAdapterListener labelsListener, List<Integer> currentLabelsIds) {
|
||||
|
||||
|
@ -43,24 +34,6 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
|
|||
this.currentLabelsIds = currentLabelsIds;
|
||||
}
|
||||
|
||||
static class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final CheckBox labelSelection;
|
||||
private final TextView labelText;
|
||||
private final ImageView labelColor;
|
||||
|
||||
private LabelsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
this.setIsRecyclable(false);
|
||||
|
||||
labelSelection = itemView.findViewById(R.id.labelSelection);
|
||||
labelText = itemView.findViewById(R.id.labelText);
|
||||
labelColor = itemView.findViewById(R.id.labelColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LabelsListAdapter.LabelsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
@ -133,4 +106,30 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
|
|||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public interface LabelsListAdapterListener {
|
||||
|
||||
void labelsInterface(List<String> data);
|
||||
|
||||
void labelsIdsInterface(List<Integer> data);
|
||||
|
||||
}
|
||||
|
||||
static class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final CheckBox labelSelection;
|
||||
private final TextView labelText;
|
||||
private final ImageView labelColor;
|
||||
|
||||
private LabelsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
this.setIsRecyclable(false);
|
||||
|
||||
labelSelection = itemView.findViewById(R.id.labelSelection);
|
||||
labelText = itemView.findViewById(R.id.labelText);
|
||||
labelColor = itemView.findViewById(R.id.labelColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,10 +35,10 @@ import java.util.Locale;
|
|||
public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private final RepositoryContext repository;
|
||||
private List<Milestone> dataList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final RepositoryContext repository;
|
||||
|
||||
public MilestonesAdapter(Context ctx, List<Milestone> dataListMain, RepositoryContext repository) {
|
||||
this.repository = repository;
|
||||
|
@ -64,9 +64,54 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
((MilestonesAdapter.DataHolder) holder).bindData(dataList.get(position));
|
||||
}
|
||||
|
||||
class DataHolder extends RecyclerView.ViewHolder {
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
private Milestone milestones;
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return dataList.size();
|
||||
}
|
||||
|
||||
private void updateAdapter(int position) {
|
||||
dataList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, dataList.size());
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Milestone> list) {
|
||||
dataList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
class DataHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView msTitle;
|
||||
private final TextView msDescription;
|
||||
|
@ -74,6 +119,7 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
private final TextView msClosedIssues;
|
||||
private final TextView msDueDate;
|
||||
private final ProgressBar msProgress;
|
||||
private Milestone milestones;
|
||||
|
||||
DataHolder(View itemView) {
|
||||
|
||||
|
@ -165,8 +211,7 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
else {
|
||||
|
||||
int msCompletion = (int) (100 * dataModel.getClosedIssues() / (dataModel.getOpenIssues() + dataModel.getClosedIssues()));
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -215,51 +260,4 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return dataList.size();
|
||||
}
|
||||
|
||||
private void updateAdapter(int position) {
|
||||
dataList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, dataList.size());
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Milestone> list) {
|
||||
dataList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,21 +23,6 @@ public class MyProfileEmailsAdapter extends RecyclerView.Adapter<MyProfileEmails
|
|||
private final List<Email> emailsList;
|
||||
private final Context context;
|
||||
|
||||
static class EmailsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView emailPrimary;
|
||||
private final TextView userEmail;
|
||||
|
||||
private EmailsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
emailPrimary = itemView.findViewById(R.id.emailPrimary);
|
||||
userEmail = itemView.findViewById(R.id.userEmail);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MyProfileEmailsAdapter(Context ctx, List<Email> emailsListMain) {
|
||||
this.context = ctx;
|
||||
this.emailsList = emailsListMain;
|
||||
|
@ -58,10 +43,8 @@ public class MyProfileEmailsAdapter extends RecyclerView.Adapter<MyProfileEmails
|
|||
holder.userEmail.setText(currentItem.getEmail());
|
||||
|
||||
if(currentItem.isPrimary()) {
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig()
|
||||
.textColor(ResourcesCompat.getColor(context.getResources(), R.color.colorWhite, null)).fontSize(36).width(220).height(60).endConfig()
|
||||
.buildRoundRect(context.getResources().getString(R.string.emailTypeText),
|
||||
ResourcesCompat.getColor(context.getResources(), R.color.tooltipBackground, null), 8);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().textColor(ResourcesCompat.getColor(context.getResources(), R.color.colorWhite, null)).fontSize(36).width(220).height(60).endConfig()
|
||||
.buildRoundRect(context.getResources().getString(R.string.emailTypeText), ResourcesCompat.getColor(context.getResources(), R.color.tooltipBackground, null), 8);
|
||||
holder.emailPrimary.setImageDrawable(drawable);
|
||||
}
|
||||
else {
|
||||
|
@ -75,4 +58,19 @@ public class MyProfileEmailsAdapter extends RecyclerView.Adapter<MyProfileEmails
|
|||
return emailsList.size();
|
||||
}
|
||||
|
||||
static class EmailsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView emailPrimary;
|
||||
private final TextView userEmail;
|
||||
|
||||
private EmailsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
emailPrimary = itemView.findViewById(R.id.emailPrimary);
|
||||
userEmail = itemView.findViewById(R.id.userEmail);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,13 +27,12 @@ import java.util.List;
|
|||
public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private List<NotificationThread> notificationThreads;
|
||||
private final OnMoreClickedListener onMoreClickedListener;
|
||||
private final OnNotificationClickedListener onNotificationClickedListener;
|
||||
private List<NotificationThread> notificationThreads;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public NotificationsAdapter(Context context, List<NotificationThread> notificationThreads, OnMoreClickedListener onMoreClickedListener,
|
||||
OnNotificationClickedListener onNotificationClickedListener) {
|
||||
public NotificationsAdapter(Context context, List<NotificationThread> notificationThreads, OnMoreClickedListener onMoreClickedListener, OnNotificationClickedListener onNotificationClickedListener) {
|
||||
|
||||
this.context = context;
|
||||
this.notificationThreads = notificationThreads;
|
||||
|
@ -66,14 +65,41 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
return notificationThreads.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void updateList(List<NotificationThread> list) {
|
||||
notificationThreads = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
public interface OnNotificationClickedListener {
|
||||
|
||||
void onNotificationClicked(NotificationThread notificationThread);
|
||||
|
||||
}
|
||||
|
||||
public interface OnMoreClickedListener {
|
||||
|
||||
void onMoreClicked(NotificationThread notificationThread);
|
||||
|
||||
}
|
||||
|
||||
class NotificationsHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final LinearLayout frame;
|
||||
private final TextView subject;
|
||||
private final TextView repository;
|
||||
private final ImageView type;
|
||||
private ImageView pinned;
|
||||
private final ImageView more;
|
||||
private ImageView pinned;
|
||||
|
||||
NotificationsHolder(View itemView) {
|
||||
|
||||
|
@ -93,8 +119,8 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
String subjectId = "";
|
||||
|
||||
if(StringUtils.containsAny(notificationThread.getSubject().getType().toLowerCase(), "pull", "issue")) {
|
||||
subjectId = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray,
|
||||
null) + "'>" + context.getResources().getString(R.string.hash) + url.substring(url.lastIndexOf("/") + 1) + "</font>";
|
||||
subjectId = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + url.substring(
|
||||
url.lastIndexOf("/") + 1) + "</font>";
|
||||
}
|
||||
|
||||
subject.setText(HtmlCompat.fromHtml(subjectId + " " + notificationThread.getSubject().getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
|
@ -157,31 +183,4 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void updateList(List<NotificationThread> list) {
|
||||
notificationThreads = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
public interface OnNotificationClickedListener {
|
||||
|
||||
void onNotificationClicked(NotificationThread notificationThread);
|
||||
|
||||
}
|
||||
|
||||
public interface OnMoreClickedListener {
|
||||
|
||||
void onMoreClicked(NotificationThread notificationThread);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,125 +28,10 @@ import java.util.List;
|
|||
public class OrganizationsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Filterable {
|
||||
|
||||
private final Context context;
|
||||
private List<Organization> orgList;
|
||||
private final List<Organization> orgListFull;
|
||||
private List<Organization> orgList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public OrganizationsListAdapter(Context ctx, List<Organization> orgListMain) {
|
||||
this.context = ctx;
|
||||
this.orgList = orgListMain;
|
||||
orgListFull = new ArrayList<>(orgList);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
return new OrganizationsListAdapter.OrgHolder(inflater.inflate(R.layout.list_organizations, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
}
|
||||
|
||||
((OrganizationsListAdapter.OrgHolder) holder).bindData(orgList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return orgList.size();
|
||||
}
|
||||
|
||||
class OrgHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Organization userOrganizations;
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView orgName;
|
||||
private final TextView orgDescription;
|
||||
|
||||
OrgHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
orgName = itemView.findViewById(R.id.orgName);
|
||||
orgDescription = itemView.findViewById(R.id.orgDescription);
|
||||
image = itemView.findViewById(R.id.imageAvatar);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
||||
intent.putExtra("orgName", userOrganizations.getUsername());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
void bindData(Organization org) {
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
this.userOrganizations = org;
|
||||
orgName.setText(org.getUsername());
|
||||
|
||||
PicassoService.getInstance(context).get().load(org.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
|
||||
if(!org.getDescription().equals("")) {
|
||||
orgDescription.setVisibility(View.VISIBLE);
|
||||
orgDescription.setText(org.getDescription());
|
||||
}
|
||||
else {
|
||||
orgDescription.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public abstract static class OnLoadMoreListener {
|
||||
|
||||
protected abstract void onLoadMore();
|
||||
|
||||
public void onLoadFinished() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Organization> list) {
|
||||
orgList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return orgFilter;
|
||||
}
|
||||
|
||||
private final Filter orgFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
|
@ -184,4 +69,116 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||
}
|
||||
};
|
||||
|
||||
public OrganizationsListAdapter(Context ctx, List<Organization> orgListMain) {
|
||||
this.context = ctx;
|
||||
this.orgList = orgListMain;
|
||||
orgListFull = new ArrayList<>(orgList);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
return new OrganizationsListAdapter.OrgHolder(inflater.inflate(R.layout.list_organizations, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
}
|
||||
|
||||
((OrganizationsListAdapter.OrgHolder) holder).bindData(orgList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return orgList.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Organization> list) {
|
||||
orgList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return orgFilter;
|
||||
}
|
||||
|
||||
public abstract static class OnLoadMoreListener {
|
||||
|
||||
protected abstract void onLoadMore();
|
||||
|
||||
public void onLoadFinished() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class OrgHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView orgName;
|
||||
private final TextView orgDescription;
|
||||
private Organization userOrganizations;
|
||||
|
||||
OrgHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
orgName = itemView.findViewById(R.id.orgName);
|
||||
orgDescription = itemView.findViewById(R.id.orgDescription);
|
||||
image = itemView.findViewById(R.id.imageAvatar);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
||||
intent.putExtra("orgName", userOrganizations.getUsername());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
void bindData(Organization org) {
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
this.userOrganizations = org;
|
||||
orgName.setText(org.getUsername());
|
||||
|
||||
PicassoService.getInstance(context).get().load(org.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
|
||||
if(!org.getDescription().equals("")) {
|
||||
orgDescription.setVisibility(View.VISIBLE);
|
||||
orgDescription.setText(org.getDescription());
|
||||
}
|
||||
else {
|
||||
orgDescription.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -79,9 +79,26 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
return prList.size();
|
||||
}
|
||||
|
||||
class PullRequestsHolder extends RecyclerView.ViewHolder {
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
private PullRequest pullRequestObject;
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<PullRequest> list) {
|
||||
prList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class PullRequestsHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView assigneeAvatar;
|
||||
private final TextView prTitle;
|
||||
|
@ -91,6 +108,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
private final LinearLayout frameLabels;
|
||||
private final HorizontalScrollView labelsScrollViewDots;
|
||||
private final LinearLayout frameLabelsDots;
|
||||
private PullRequest pullRequestObject;
|
||||
|
||||
PullRequestsHolder(View itemView) {
|
||||
|
||||
|
@ -105,8 +123,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
frameLabelsDots = itemView.findViewById(R.id.frameLabelsDots);
|
||||
|
||||
View.OnClickListener openPr = v -> {
|
||||
Intent intentPrDetail = new IssueContext(pullRequestObject, ((RepoDetailActivity) context).repository).getIntent(context,
|
||||
IssueDetailActivity.class);
|
||||
Intent intentPrDetail = new IssueContext(pullRequestObject, ((RepoDetailActivity) context).repository).getIntent(context, IssueDetailActivity.class);
|
||||
context.startActivity(intentPrDetail);
|
||||
};
|
||||
|
||||
|
@ -121,8 +138,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
});
|
||||
|
||||
assigneeAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, pullRequestObject.getUser().getLogin(),
|
||||
context.getString(R.string.copyLoginIdToClipBoard, pullRequestObject.getUser().getLogin()));
|
||||
AppUtil.copyToClipboard(context, pullRequestObject.getUser().getLogin(), context.getString(R.string.copyLoginIdToClipBoard, pullRequestObject.getUser().getLogin()));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -135,13 +151,12 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get().load(pullRequest.getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(this.assigneeAvatar);
|
||||
PicassoService.getInstance(context).get().load(pullRequest.getUser().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(this.assigneeAvatar);
|
||||
|
||||
this.pullRequestObject = pullRequest;
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
|
||||
if(pullRequest.getLabels() != null) {
|
||||
|
@ -162,8 +177,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
frameLabelsDots.setGravity(Gravity.START | Gravity.TOP);
|
||||
labelsView.setLayoutParams(params);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).width(54).height(54).endConfig()
|
||||
.buildRound("", color);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).width(54).height(54).endConfig().buildRound("", color);
|
||||
|
||||
labelsView.setImageDrawable(drawable);
|
||||
frameLabelsDots.addView(labelsView);
|
||||
|
@ -189,10 +203,8 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
int height = AppUtil.getPixelsFromDensity(context, 20);
|
||||
int textSize = AppUtil.getPixelsFromScaledDensity(context, 12);
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT)
|
||||
.textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize).width(
|
||||
LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize,
|
||||
AppUtil.getPixelsFromDensity(context, 8))).height(height).endConfig()
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize)
|
||||
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(context, 8))).height(height).endConfig()
|
||||
.buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(context, 18));
|
||||
|
||||
labelsView.setImageDrawable(drawable);
|
||||
|
@ -205,39 +217,17 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
labelsScrollViewWithText.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
String prNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray,
|
||||
null) + "'>" + context.getResources().getString(R.string.hash) + pullRequest.getNumber() + "</font>";
|
||||
String prNumber_ = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + pullRequest.getNumber() + "</font>";
|
||||
|
||||
this.prTitle.setText(
|
||||
HtmlCompat.fromHtml(prNumber_ + " " + EmojiParser.parseToUnicode(pullRequest.getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
this.prTitle.setText(HtmlCompat.fromHtml(prNumber_ + " " + EmojiParser.parseToUnicode(pullRequest.getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
this.prCommentsCount.setText(String.valueOf(pullRequest.getComments()));
|
||||
this.prCreatedTime.setText(TimeHelper.formatTime(pullRequest.getCreatedAt(), locale, timeFormat, context));
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
this.prCreatedTime.setOnClickListener(
|
||||
new ClickListener(TimeHelper.customDateFormatForToastDateFormat(pullRequest.getCreatedAt()), context));
|
||||
this.prCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(pullRequest.getCreatedAt()), context));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<PullRequest> list) {
|
||||
prList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ public class ReactionAuthorsAdapter extends RecyclerView.Adapter<ReactionAuthors
|
|||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
User userInfo = userInfos.get(position);
|
||||
|
||||
PicassoService.getInstance(context).get().load(userInfo.getAvatarUrl()).placeholder(R.drawable.loader_animated).resize(240, 240)
|
||||
.transform(new RoundedTransformation(AppUtil.getPixelsFromDensity(context, 6), 0)).centerCrop().into(holder.authorAvatar);
|
||||
PicassoService.getInstance(context).get().load(userInfo.getAvatarUrl()).placeholder(R.drawable.loader_animated).resize(240, 240).transform(new RoundedTransformation(AppUtil.getPixelsFromDensity(context, 6), 0))
|
||||
.centerCrop().into(holder.authorAvatar);
|
||||
|
||||
if(userInfo.getFullName() == null || userInfo.getFullName().isEmpty()) {
|
||||
holder.authorFullName.setVisibility(View.GONE);
|
||||
|
|
|
@ -42,89 +42,16 @@ import retrofit2.Response;
|
|||
|
||||
public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.ReleasesViewHolder> {
|
||||
|
||||
private List<Release> releasesList;
|
||||
private final Context context;
|
||||
private final String repoOwner;
|
||||
private final String repoName;
|
||||
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final FragmentRefreshListener startDownload;
|
||||
private final FragmentReleasesBinding fragmentReleasesBinding;
|
||||
private List<Release> releasesList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
protected class ReleasesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Release releases;
|
||||
|
||||
private final TextView releaseType;
|
||||
private final TextView releaseName;
|
||||
private final ImageView authorAvatar;
|
||||
private final TextView authorName;
|
||||
private final TextView releaseTag;
|
||||
private final TextView releaseDate;
|
||||
private final TextView releaseBodyContent;
|
||||
private final LinearLayout downloadCopyFrame;
|
||||
private final LinearLayout downloads;
|
||||
private final LinearLayout releaseZipDownloadFrame;
|
||||
private final LinearLayout releaseTarDownloadFrame;
|
||||
private final ImageView downloadDropdownIcon;
|
||||
private final RecyclerView downloadList;
|
||||
private final ImageView optionsMenu;
|
||||
|
||||
private ReleasesViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
releaseType = itemView.findViewById(R.id.releaseType);
|
||||
releaseName = itemView.findViewById(R.id.releaseName);
|
||||
authorAvatar = itemView.findViewById(R.id.authorAvatar);
|
||||
authorName = itemView.findViewById(R.id.authorName);
|
||||
releaseTag = itemView.findViewById(R.id.releaseTag);
|
||||
TextView releaseCommitSha = itemView.findViewById(R.id.releaseCommitSha);
|
||||
releaseDate = itemView.findViewById(R.id.releaseDate);
|
||||
releaseBodyContent = itemView.findViewById(R.id.releaseBodyContent);
|
||||
downloadCopyFrame = itemView.findViewById(R.id.downloadCopyFrame);
|
||||
downloads = itemView.findViewById(R.id.downloads);
|
||||
releaseZipDownloadFrame = itemView.findViewById(R.id.releaseZipDownloadFrame);
|
||||
releaseTarDownloadFrame = itemView.findViewById(R.id.releaseTarDownloadFrame);
|
||||
downloadDropdownIcon = itemView.findViewById(R.id.downloadDropdownIcon);
|
||||
downloadList = itemView.findViewById(R.id.downloadList);
|
||||
optionsMenu = itemView.findViewById(R.id.releasesOptionsMenu);
|
||||
|
||||
downloadList.setHasFixedSize(true);
|
||||
downloadList.setLayoutManager(new LinearLayoutManager(itemView.getContext()));
|
||||
|
||||
authorAvatar.setOnClickListener(loginId -> {
|
||||
Context context = loginId.getContext();
|
||||
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", releases.getAuthor().getLogin());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
optionsMenu.setOnClickListener(v -> {
|
||||
final Context context = v.getContext();
|
||||
|
||||
View view = LayoutInflater.from(context)
|
||||
.inflate(R.layout.bottom_sheet_release_in_list, itemView.findViewById(android.R.id.content), false);
|
||||
|
||||
TextView deleteRelease = view.findViewById(R.id.deleteRelease);
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
deleteRelease.setOnClickListener(v1 -> {
|
||||
deleteRelease(context, releases.getName(), releases.getId(), repoOwner, repoName, getBindingAdapterPosition());
|
||||
dialog.dismiss();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ReleasesAdapter(Context ctx, List<Release> releasesMain, FragmentRefreshListener startDownload, String repoOwner, String repoName,
|
||||
FragmentReleasesBinding fragmentReleasesBinding) {
|
||||
public ReleasesAdapter(Context ctx, List<Release> releasesMain, FragmentRefreshListener startDownload, String repoOwner, String repoName, FragmentReleasesBinding fragmentReleasesBinding) {
|
||||
this.context = ctx;
|
||||
this.releasesList = releasesMain;
|
||||
this.startDownload = startDownload;
|
||||
|
@ -167,8 +94,8 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||
}
|
||||
|
||||
if(currentItem.getAuthor().getAvatarUrl() != null) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAuthor().getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.authorAvatar);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAuthor().getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(holder.authorAvatar);
|
||||
}
|
||||
|
||||
holder.authorName.setText(context.getResources().getString(R.string.releasePublishedBy, currentItem.getAuthor().getLogin()));
|
||||
|
@ -182,8 +109,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||
}
|
||||
|
||||
if(timeFormat.equals("pretty")) {
|
||||
holder.releaseDate.setOnClickListener(
|
||||
new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getPublishedAt()), context));
|
||||
holder.releaseDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getPublishedAt()), context));
|
||||
}
|
||||
|
||||
if(!currentItem.getBody().equals("")) {
|
||||
|
@ -243,14 +169,6 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
@ -266,38 +184,113 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
|
|||
notifyItemRangeChanged(position, releasesList.size());
|
||||
}
|
||||
|
||||
private void deleteRelease(final Context context, final String releaseName, final Long releaseId, final String owner, final String repo,
|
||||
int position) {
|
||||
private void deleteRelease(final Context context, final String releaseName, final Long releaseId, final String owner, final String repo, int position) {
|
||||
|
||||
new AlertDialog.Builder(context).setTitle(String.format(context.getString(R.string.deleteGenericTitle), releaseName))
|
||||
.setMessage(R.string.deleteReleaseConfirmation).setIcon(R.drawable.ic_delete).setPositiveButton(R.string.menuDeleteText,
|
||||
(dialog, whichButton) -> RetrofitClient.getApiInterface(context).repoDeleteRelease(owner, repo, releaseId).enqueue(new Callback<>() {
|
||||
new AlertDialog.Builder(context).setTitle(String.format(context.getString(R.string.deleteGenericTitle), releaseName)).setMessage(R.string.deleteReleaseConfirmation).setIcon(R.drawable.ic_delete)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient.getApiInterface(context).repoDeleteRelease(owner, repo, releaseId).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
updateAdapter(position);
|
||||
Toasty.success(context, context.getString(R.string.releaseDeleted));
|
||||
MainActivity.reloadRepos = true;
|
||||
if(getItemCount() == 0) {
|
||||
fragmentReleasesBinding.noDataReleases.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
if(response.isSuccessful()) {
|
||||
updateAdapter(position);
|
||||
Toasty.success(context, context.getString(R.string.releaseDeleted));
|
||||
MainActivity.reloadRepos = true;
|
||||
if(getItemCount() == 0) {
|
||||
fragmentReleasesBinding.noDataReleases.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
})).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
})).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
protected class ReleasesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView releaseType;
|
||||
private final TextView releaseName;
|
||||
private final ImageView authorAvatar;
|
||||
private final TextView authorName;
|
||||
private final TextView releaseTag;
|
||||
private final TextView releaseDate;
|
||||
private final TextView releaseBodyContent;
|
||||
private final LinearLayout downloadCopyFrame;
|
||||
private final LinearLayout downloads;
|
||||
private final LinearLayout releaseZipDownloadFrame;
|
||||
private final LinearLayout releaseTarDownloadFrame;
|
||||
private final ImageView downloadDropdownIcon;
|
||||
private final RecyclerView downloadList;
|
||||
private final ImageView optionsMenu;
|
||||
private Release releases;
|
||||
|
||||
private ReleasesViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
releaseType = itemView.findViewById(R.id.releaseType);
|
||||
releaseName = itemView.findViewById(R.id.releaseName);
|
||||
authorAvatar = itemView.findViewById(R.id.authorAvatar);
|
||||
authorName = itemView.findViewById(R.id.authorName);
|
||||
releaseTag = itemView.findViewById(R.id.releaseTag);
|
||||
TextView releaseCommitSha = itemView.findViewById(R.id.releaseCommitSha);
|
||||
releaseDate = itemView.findViewById(R.id.releaseDate);
|
||||
releaseBodyContent = itemView.findViewById(R.id.releaseBodyContent);
|
||||
downloadCopyFrame = itemView.findViewById(R.id.downloadCopyFrame);
|
||||
downloads = itemView.findViewById(R.id.downloads);
|
||||
releaseZipDownloadFrame = itemView.findViewById(R.id.releaseZipDownloadFrame);
|
||||
releaseTarDownloadFrame = itemView.findViewById(R.id.releaseTarDownloadFrame);
|
||||
downloadDropdownIcon = itemView.findViewById(R.id.downloadDropdownIcon);
|
||||
downloadList = itemView.findViewById(R.id.downloadList);
|
||||
optionsMenu = itemView.findViewById(R.id.releasesOptionsMenu);
|
||||
|
||||
downloadList.setHasFixedSize(true);
|
||||
downloadList.setLayoutManager(new LinearLayoutManager(itemView.getContext()));
|
||||
|
||||
authorAvatar.setOnClickListener(loginId -> {
|
||||
Context context = loginId.getContext();
|
||||
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", releases.getAuthor().getLogin());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
optionsMenu.setOnClickListener(v -> {
|
||||
final Context context = v.getContext();
|
||||
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_release_in_list, itemView.findViewById(android.R.id.content), false);
|
||||
|
||||
TextView deleteRelease = view.findViewById(R.id.deleteRelease);
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
deleteRelease.setOnClickListener(v1 -> {
|
||||
deleteRelease(context, releases.getName(), releases.getId(), repoOwner, repoName, getBindingAdapterPosition());
|
||||
dialog.dismiss();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,18 +20,6 @@ public class ReleasesDownloadsAdapter extends RecyclerView.Adapter<ReleasesDownl
|
|||
private final List<Attachment> releasesDownloadsList;
|
||||
private final FragmentRefreshListener startDownload;
|
||||
|
||||
static class ReleasesDownloadsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView downloadName;
|
||||
|
||||
private ReleasesDownloadsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
downloadName = itemView.findViewById(R.id.downloadName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ReleasesDownloadsAdapter(List<Attachment> releasesDownloadsMain, FragmentRefreshListener startDownload) {
|
||||
|
||||
this.releasesDownloadsList = releasesDownloadsMain;
|
||||
|
@ -63,4 +51,16 @@ public class ReleasesDownloadsAdapter extends RecyclerView.Adapter<ReleasesDownl
|
|||
return releasesDownloadsList.size();
|
||||
}
|
||||
|
||||
static class ReleasesDownloadsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView downloadName;
|
||||
|
||||
private ReleasesDownloadsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
downloadName = itemView.findViewById(R.id.downloadName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,17 +74,35 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
return forksList.size();
|
||||
}
|
||||
|
||||
class ForksHolder extends RecyclerView.ViewHolder {
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
forksList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class ForksHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView repoName;
|
||||
private final TextView orgName;
|
||||
private final TextView repoDescription;
|
||||
private CheckBox isRepoAdmin;
|
||||
private final TextView repoStars;
|
||||
private final TextView repoLastUpdated;
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
private CheckBox isRepoAdmin;
|
||||
|
||||
ForksHolder(View itemView) {
|
||||
|
||||
|
@ -115,13 +133,12 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
int color = generator.getColor(forksModel.getName());
|
||||
String firstCharacter = String.valueOf(forksModel.getFullName().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(forksModel.getAvatarUrl() != null) {
|
||||
if(!forksModel.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(forksModel.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
PicassoService.getInstance(context).get().load(forksModel.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(image);
|
||||
}
|
||||
else {
|
||||
image.setImageDrawable(drawable);
|
||||
|
@ -138,20 +155,17 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
PrettyTime prettyTime = new PrettyTime(locale);
|
||||
String createdTime = prettyTime.format(forksModel.getUpdatedAt());
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||
repoLastUpdated.setOnClickListener(
|
||||
new ClickListener(TimeHelper.customDateFormatForToastDateFormat(forksModel.getUpdatedAt()), context));
|
||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(forksModel.getUpdatedAt()), context));
|
||||
break;
|
||||
}
|
||||
case "normal": {
|
||||
DateFormat formatter = new SimpleDateFormat(
|
||||
"yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(forksModel.getUpdatedAt());
|
||||
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", locale);
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(forksModel.getUpdatedAt());
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||
break;
|
||||
|
@ -190,23 +204,4 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
forksList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,11 +39,45 @@ import java.util.Locale;
|
|||
public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Filterable {
|
||||
|
||||
private final Context context;
|
||||
private List<org.gitnex.tea4j.v2.models.Repository> reposList;
|
||||
private final List<org.gitnex.tea4j.v2.models.Repository> reposListFull;
|
||||
private final TinyDB tinyDb;
|
||||
private List<org.gitnex.tea4j.v2.models.Repository> reposList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final TinyDB tinyDb;
|
||||
private final Filter reposFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
|
||||
List<org.gitnex.tea4j.v2.models.Repository> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(reposListFull);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(org.gitnex.tea4j.v2.models.Repository item : reposListFull) {
|
||||
if(item.getFullName().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
reposList.clear();
|
||||
reposList.addAll((List) results.values);
|
||||
notifyDataChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public ReposListAdapter(List<org.gitnex.tea4j.v2.models.Repository> reposListMain, Context ctx) {
|
||||
this.context = ctx;
|
||||
|
@ -79,18 +113,53 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
return reposList.size();
|
||||
}
|
||||
|
||||
class ReposHolder extends RecyclerView.ViewHolder {
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return reposFilter;
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
class ReposHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView image;
|
||||
private final TextView repoName;
|
||||
private final TextView orgName;
|
||||
private final TextView repoDescription;
|
||||
private CheckBox isRepoAdmin;
|
||||
private final TextView repoStars;
|
||||
private final TextView repoLastUpdated;
|
||||
private final View spacerView;
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
private CheckBox isRepoAdmin;
|
||||
|
||||
ReposHolder(View itemView) {
|
||||
|
||||
|
@ -130,13 +199,12 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
int color = generator.getColor(repositories.getName());
|
||||
String firstCharacter = String.valueOf(repositories.getFullName().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(repositories.getAvatarUrl() != null) {
|
||||
if(!repositories.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(repositories.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
||||
PicassoService.getInstance(context).get().load(repositories.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(image);
|
||||
}
|
||||
else {
|
||||
image.setImageDrawable(drawable);
|
||||
|
@ -153,20 +221,17 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
PrettyTime prettyTime = new PrettyTime(locale);
|
||||
String createdTime = prettyTime.format(repositories.getUpdatedAt());
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||
repoLastUpdated.setOnClickListener(
|
||||
new ClickListener(TimeHelper.customDateFormatForToastDateFormat(repositories.getUpdatedAt()), context));
|
||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(repositories.getUpdatedAt()), context));
|
||||
break;
|
||||
}
|
||||
case "normal": {
|
||||
DateFormat formatter = new SimpleDateFormat(
|
||||
"yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(repositories.getUpdatedAt());
|
||||
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", locale);
|
||||
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
||||
String createdTime = formatter.format(repositories.getUpdatedAt());
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
||||
break;
|
||||
|
@ -195,75 +260,4 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return reposFilter;
|
||||
}
|
||||
|
||||
private final Filter reposFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
|
||||
List<org.gitnex.tea4j.v2.models.Repository> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(reposListFull);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(org.gitnex.tea4j.v2.models.Repository item : reposListFull) {
|
||||
if(item.getFullName().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
reposList.clear();
|
||||
reposList.addAll((List) results.values);
|
||||
notifyDataChanged();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -31,62 +31,16 @@ import retrofit2.Response;
|
|||
|
||||
public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder> {
|
||||
|
||||
private List<Tag> tags;
|
||||
private final Context context;
|
||||
private final String repo;
|
||||
private final String owner;
|
||||
private final FragmentRefreshListener startDownload;
|
||||
private final FragmentReleasesBinding fragmentReleasesBinding;
|
||||
private List<Tag> tags;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
protected class TagsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Tag tagsHolder;
|
||||
private final TextView tagName;
|
||||
private final TextView tagBody;
|
||||
private final LinearLayout downloadCopyFrame;
|
||||
private final LinearLayout downloads;
|
||||
private final LinearLayout releaseZipDownloadFrame;
|
||||
private final LinearLayout releaseTarDownloadFrame;
|
||||
private final ImageView downloadDropdownIcon;
|
||||
private final ImageView options;
|
||||
|
||||
private TagsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
tagName = itemView.findViewById(R.id.tagName);
|
||||
tagBody = itemView.findViewById(R.id.tagBodyContent);
|
||||
downloadCopyFrame = itemView.findViewById(R.id.downloadCopyFrame);
|
||||
downloads = itemView.findViewById(R.id.downloads);
|
||||
releaseZipDownloadFrame = itemView.findViewById(R.id.releaseZipDownloadFrame);
|
||||
releaseTarDownloadFrame = itemView.findViewById(R.id.releaseTarDownloadFrame);
|
||||
downloadDropdownIcon = itemView.findViewById(R.id.downloadDropdownIcon);
|
||||
options = itemView.findViewById(R.id.tagsOptionsMenu);
|
||||
|
||||
options.setOnClickListener(v -> {
|
||||
final Context context = v.getContext();
|
||||
|
||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_tag_in_list, null);
|
||||
|
||||
TextView delete = view.findViewById(R.id.tagMenuDelete);
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
delete.setOnClickListener(v1 -> {
|
||||
tagDeleteDialog(context, tagsHolder.getName(), owner, repo, getBindingAdapterPosition());
|
||||
dialog.dismiss();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public TagsAdapter(Context ctx, List<Tag> releasesMain, String repoOwner, String repoName, FragmentRefreshListener startDownload,
|
||||
FragmentReleasesBinding fragmentReleasesBinding) {
|
||||
public TagsAdapter(Context ctx, List<Tag> releasesMain, String repoOwner, String repoName, FragmentRefreshListener startDownload, FragmentReleasesBinding fragmentReleasesBinding) {
|
||||
this.context = ctx;
|
||||
this.tags = releasesMain;
|
||||
owner = repoOwner;
|
||||
|
@ -163,14 +117,6 @@ public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder
|
|||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
@ -188,37 +134,89 @@ public class TagsAdapter extends RecyclerView.Adapter<TagsAdapter.TagsViewHolder
|
|||
|
||||
private void tagDeleteDialog(final Context context, final String tagName, final String owner, final String repo, int position) {
|
||||
|
||||
new AlertDialog.Builder(context).setTitle(String.format(context.getString(R.string.deleteGenericTitle), tagName))
|
||||
.setMessage(R.string.deleteTagConfirmation).setIcon(R.drawable.ic_delete).setPositiveButton(R.string.menuDeleteText,
|
||||
(dialog, whichButton) -> RetrofitClient.getApiInterface(context).repoDeleteTag(owner, repo, tagName).enqueue(new Callback<>() {
|
||||
new AlertDialog.Builder(context).setTitle(String.format(context.getString(R.string.deleteGenericTitle), tagName)).setMessage(R.string.deleteTagConfirmation).setIcon(R.drawable.ic_delete)
|
||||
.setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient.getApiInterface(context).repoDeleteTag(owner, repo, tagName).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
updateAdapter(position);
|
||||
Toasty.success(context, context.getString(R.string.tagDeleted));
|
||||
if(getItemCount() == 0) {
|
||||
fragmentReleasesBinding.noDataReleases.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 409) {
|
||||
Toasty.error(context, context.getString(R.string.tagDeleteError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
if(response.isSuccessful()) {
|
||||
updateAdapter(position);
|
||||
Toasty.success(context, context.getString(R.string.tagDeleted));
|
||||
if(getItemCount() == 0) {
|
||||
fragmentReleasesBinding.noDataReleases.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 409) {
|
||||
Toasty.error(context, context.getString(R.string.tagDeleteError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
})).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
})).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
protected class TagsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView tagName;
|
||||
private final TextView tagBody;
|
||||
private final LinearLayout downloadCopyFrame;
|
||||
private final LinearLayout downloads;
|
||||
private final LinearLayout releaseZipDownloadFrame;
|
||||
private final LinearLayout releaseTarDownloadFrame;
|
||||
private final ImageView downloadDropdownIcon;
|
||||
private final ImageView options;
|
||||
private Tag tagsHolder;
|
||||
|
||||
private TagsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
tagName = itemView.findViewById(R.id.tagName);
|
||||
tagBody = itemView.findViewById(R.id.tagBodyContent);
|
||||
downloadCopyFrame = itemView.findViewById(R.id.downloadCopyFrame);
|
||||
downloads = itemView.findViewById(R.id.downloads);
|
||||
releaseZipDownloadFrame = itemView.findViewById(R.id.releaseZipDownloadFrame);
|
||||
releaseTarDownloadFrame = itemView.findViewById(R.id.releaseTarDownloadFrame);
|
||||
downloadDropdownIcon = itemView.findViewById(R.id.downloadDropdownIcon);
|
||||
options = itemView.findViewById(R.id.tagsOptionsMenu);
|
||||
|
||||
options.setOnClickListener(v -> {
|
||||
final Context context = v.getContext();
|
||||
|
||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_tag_in_list, null);
|
||||
|
||||
TextView delete = view.findViewById(R.id.tagMenuDelete);
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
|
||||
delete.setOnClickListener(v1 -> {
|
||||
tagDeleteDialog(context, tagsHolder.getName(), owner, repo, getBindingAdapterPosition());
|
||||
dialog.dismiss();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ public class TeamMembersByOrgPreviewAdapter extends RecyclerView.Adapter<TeamMem
|
|||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
User userInfo = userData.get(position);
|
||||
|
||||
PicassoService.getInstance(context).get().load(userInfo.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(AppUtil.getPixelsFromDensity(context, 3), 0)).resize(120, 120).centerCrop().into(holder.avatar);
|
||||
PicassoService.getInstance(context).get().load(userInfo.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(AppUtil.getPixelsFromDensity(context, 3), 0)).resize(120, 120)
|
||||
.centerCrop().into(holder.avatar);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,53 +49,6 @@ public class TeamRepositoriesAdapter extends RecyclerView.Adapter<TeamRepositori
|
|||
reposArr = new ArrayList<>();
|
||||
}
|
||||
|
||||
class TeamReposViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private Repository repoInfo;
|
||||
|
||||
private final ImageView repoAvatar;
|
||||
private final TextView name;
|
||||
private final ImageView addRepoButtonAdd;
|
||||
|
||||
private TeamReposViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
repoAvatar = itemView.findViewById(R.id.userAvatar);
|
||||
name = itemView.findViewById(R.id.userFullName);
|
||||
itemView.findViewById(R.id.userName).setVisibility(View.GONE);
|
||||
addRepoButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
|
||||
ImageView addRepoButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
|
||||
//addRepoButtonAdd.setVisibility(View.VISIBLE);
|
||||
//addRepoButtonRemove.setVisibility(View.GONE);
|
||||
|
||||
new Handler(Looper.getMainLooper()).postDelayed(TeamRepositoriesAdapter.this::getTeamRepos, 200);
|
||||
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
if(reposArr.size() > 0) {
|
||||
for(int i = 0; i < reposArr.size(); i++) {
|
||||
if(!reposArr.get(i).getName().equals(repoInfo.getName())) {
|
||||
addRepoButtonAdd.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
addRepoButtonAdd.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
addRepoButtonAdd.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}, 500);
|
||||
|
||||
addRepoButtonAdd.setOnClickListener(
|
||||
v -> AlertDialogs.addRepoDialog(context, orgName, repoInfo.getName(), Integer.parseInt(String.valueOf(teamId)), teamName));
|
||||
|
||||
addRepoButtonRemove.setOnClickListener(
|
||||
v -> AlertDialogs.removeRepoDialog(context, orgName, repoInfo.getName(), Integer.parseInt(String.valueOf(teamId)), teamName));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public TeamRepositoriesAdapter.TeamReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
@ -112,13 +65,12 @@ public class TeamRepositoriesAdapter extends RecyclerView.Adapter<TeamRepositori
|
|||
|
||||
holder.name.setText(currentItem.getName());
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28)
|
||||
.endConfig().buildRoundRect(String.valueOf(currentItem.getFullName().charAt(0)),
|
||||
ColorGenerator.Companion.getMATERIAL().getColor(currentItem.getName()), 3);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig()
|
||||
.buildRoundRect(String.valueOf(currentItem.getFullName().charAt(0)), ColorGenerator.Companion.getMATERIAL().getColor(currentItem.getName()), 3);
|
||||
|
||||
if(currentItem.getAvatarUrl() != null && !currentItem.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.repoAvatar);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(holder.repoAvatar);
|
||||
}
|
||||
else {
|
||||
holder.repoAvatar.setImageDrawable(drawable);
|
||||
|
@ -156,4 +108,48 @@ public class TeamRepositoriesAdapter extends RecyclerView.Adapter<TeamRepositori
|
|||
}
|
||||
}
|
||||
|
||||
class TeamReposViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView repoAvatar;
|
||||
private final TextView name;
|
||||
private final ImageView addRepoButtonAdd;
|
||||
private Repository repoInfo;
|
||||
|
||||
private TeamReposViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
repoAvatar = itemView.findViewById(R.id.userAvatar);
|
||||
name = itemView.findViewById(R.id.userFullName);
|
||||
itemView.findViewById(R.id.userName).setVisibility(View.GONE);
|
||||
addRepoButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
|
||||
ImageView addRepoButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
|
||||
//addRepoButtonAdd.setVisibility(View.VISIBLE);
|
||||
//addRepoButtonRemove.setVisibility(View.GONE);
|
||||
|
||||
new Handler(Looper.getMainLooper()).postDelayed(TeamRepositoriesAdapter.this::getTeamRepos, 200);
|
||||
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
if(reposArr.size() > 0) {
|
||||
for(int i = 0; i < reposArr.size(); i++) {
|
||||
if(!reposArr.get(i).getName().equals(repoInfo.getName())) {
|
||||
addRepoButtonAdd.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
addRepoButtonAdd.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
addRepoButtonAdd.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}, 500);
|
||||
|
||||
addRepoButtonAdd.setOnClickListener(v -> AlertDialogs.addRepoDialog(context, orgName, repoInfo.getName(), Integer.parseInt(String.valueOf(teamId)), teamName));
|
||||
|
||||
addRepoButtonRemove.setOnClickListener(v -> AlertDialogs.removeRepoDialog(context, orgName, repoInfo.getName(), Integer.parseInt(String.valueOf(teamId)), teamName));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,47 +36,38 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
|||
private final List<Team> teamListFull;
|
||||
private final OrganizationPermissions permissions;
|
||||
private final String orgName;
|
||||
private final Filter orgTeamsFilter = new Filter() {
|
||||
|
||||
static class OrgTeamsViewHolder extends RecyclerView.ViewHolder {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<Team> filteredList = new ArrayList<>();
|
||||
|
||||
private Team team;
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(teamListFull);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
private OrganizationPermissions permissions;
|
||||
private final TextView teamTitle;
|
||||
private final TextView teamDescription;
|
||||
private final LinearLayout membersPreviewFrame;
|
||||
for(Team item : teamListFull) {
|
||||
if(item.getName().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final List<User> userInfos;
|
||||
private final TeamMembersByOrgPreviewAdapter adapter;
|
||||
private String orgName;
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
private OrgTeamsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
teamTitle = itemView.findViewById(R.id.teamTitle);
|
||||
teamDescription = itemView.findViewById(R.id.teamDescription);
|
||||
membersPreviewFrame = itemView.findViewById(R.id.membersPreviewFrame);
|
||||
|
||||
RecyclerView membersPreview = itemView.findViewById(R.id.membersPreview);
|
||||
|
||||
userInfos = new ArrayList<>();
|
||||
adapter = new TeamMembersByOrgPreviewAdapter(itemView.getContext(), userInfos);
|
||||
|
||||
membersPreview.setLayoutManager(new LinearLayoutManager(itemView.getContext(), RecyclerView.HORIZONTAL, false));
|
||||
membersPreview.setAdapter(adapter);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Context context = v.getContext();
|
||||
|
||||
Intent intent = new Intent(context, OrganizationTeamInfoActivity.class);
|
||||
intent.putExtra("team", team);
|
||||
intent.putExtra("permissions", permissions);
|
||||
intent.putExtra("orgName", orgName);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
teamList.clear();
|
||||
teamList.addAll((List<Team>) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public TeamsByOrgAdapter(Context ctx, List<Team> teamListMain, OrganizationPermissions permissions, String orgName) {
|
||||
this.context = ctx;
|
||||
|
@ -145,37 +136,43 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
|||
return orgTeamsFilter;
|
||||
}
|
||||
|
||||
private final Filter orgTeamsFilter = new Filter() {
|
||||
static class OrgTeamsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<Team> filteredList = new ArrayList<>();
|
||||
private final TextView teamTitle;
|
||||
private final TextView teamDescription;
|
||||
private final LinearLayout membersPreviewFrame;
|
||||
private final List<User> userInfos;
|
||||
private final TeamMembersByOrgPreviewAdapter adapter;
|
||||
private Team team;
|
||||
private OrganizationPermissions permissions;
|
||||
private String orgName;
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(teamListFull);
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
private OrgTeamsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
for(Team item : teamListFull) {
|
||||
if(item.getName().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
teamTitle = itemView.findViewById(R.id.teamTitle);
|
||||
teamDescription = itemView.findViewById(R.id.teamDescription);
|
||||
membersPreviewFrame = itemView.findViewById(R.id.membersPreviewFrame);
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
RecyclerView membersPreview = itemView.findViewById(R.id.membersPreview);
|
||||
|
||||
return results;
|
||||
userInfos = new ArrayList<>();
|
||||
adapter = new TeamMembersByOrgPreviewAdapter(itemView.getContext(), userInfos);
|
||||
|
||||
membersPreview.setLayoutManager(new LinearLayoutManager(itemView.getContext(), RecyclerView.HORIZONTAL, false));
|
||||
membersPreview.setAdapter(adapter);
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
Context context = v.getContext();
|
||||
|
||||
Intent intent = new Intent(context, OrganizationTeamInfoActivity.class);
|
||||
intent.putExtra("team", team);
|
||||
intent.putExtra("permissions", permissions);
|
||||
intent.putExtra("orgName", orgName);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
teamList.clear();
|
||||
teamList.addAll((List<Team>) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,16 +43,102 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||
private final Context context;
|
||||
private final Dialog dialog;
|
||||
|
||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
public UserAccountsAdapter(Context ctx, Dialog dialog) {
|
||||
this.dialog = dialog;
|
||||
this.context = ctx;
|
||||
this.userAccountsList = Objects.requireNonNull(BaseApi.getInstance(context, UserAccountsApi.class)).usersAccounts();
|
||||
}
|
||||
|
||||
private int accountId;
|
||||
private String accountName;
|
||||
private void updateLayoutByPosition(int position) {
|
||||
|
||||
userAccountsList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, userAccountsList.size());
|
||||
Toasty.success(context, context.getResources().getString(R.string.accountDeletedMessage));
|
||||
}
|
||||
|
||||
private void getNotificationsCount() {
|
||||
|
||||
Call<NotificationCount> call = RetrofitClient.getApiInterface(context).notifyNewAvailable();
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<NotificationCount> call, @NonNull retrofit2.Response<NotificationCount> response) {
|
||||
|
||||
NotificationCount notificationCount = response.body();
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
assert notificationCount != null;
|
||||
if(notificationCount.getNew() > 0) {
|
||||
String toastMsg = context.getResources().getQuantityString(R.plurals.youHaveNewNotifications, Math.toIntExact(notificationCount.getNew()), Math.toIntExact(notificationCount.getNew()));
|
||||
new Handler().postDelayed(() -> Toasty.info(context, toastMsg), 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<NotificationCount> call, @NonNull Throwable t) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public UserAccountsAdapter.UserAccountsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_user_accounts, parent, false);
|
||||
return new UserAccountsViewHolder(v);
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull UserAccountsAdapter.UserAccountsViewHolder holder, int position) {
|
||||
|
||||
UserAccount currentItem = userAccountsList.get(position);
|
||||
TinyDB tinyDB = TinyDB.getInstance(context);
|
||||
|
||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl()).withPath("/").toString();
|
||||
|
||||
holder.accountId = currentItem.getAccountId();
|
||||
holder.accountName = currentItem.getAccountName();
|
||||
|
||||
holder.userId.setText(currentItem.getUserName());
|
||||
if(currentItem.isLoggedIn()) {
|
||||
holder.accountUrl.setText(url);
|
||||
}
|
||||
else {
|
||||
holder.accountUrl.setText(context.getString(R.string.notLoggedIn, url));
|
||||
}
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get().load(url + "assets/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()) {
|
||||
holder.activeAccount.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.deleteAccount.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return userAccountsList.size();
|
||||
}
|
||||
|
||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView accountUrl;
|
||||
private final TextView userId;
|
||||
private final ImageView activeAccount;
|
||||
private final ImageView deleteAccount;
|
||||
private final ImageView repoAvatar;
|
||||
private int accountId;
|
||||
private String accountName;
|
||||
|
||||
private UserAccountsViewHolder(View itemView) {
|
||||
|
||||
|
@ -66,10 +152,8 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||
|
||||
deleteAccount.setOnClickListener(itemDelete -> {
|
||||
|
||||
new AlertDialog.Builder(context).setIcon(AppCompatResources.getDrawable(context, R.drawable.ic_delete))
|
||||
.setTitle(context.getResources().getString(R.string.removeAccountPopupTitle))
|
||||
.setMessage(context.getResources().getString(R.string.removeAccountPopupMessage))
|
||||
.setPositiveButton(context.getResources().getString(R.string.removeButton), (dialog, which) -> {
|
||||
new AlertDialog.Builder(context).setIcon(AppCompatResources.getDrawable(context, R.drawable.ic_delete)).setTitle(context.getResources().getString(R.string.removeAccountPopupTitle))
|
||||
.setMessage(context.getResources().getString(R.string.removeAccountPopupMessage)).setPositiveButton(context.getResources().getString(R.string.removeButton), (dialog, which) -> {
|
||||
|
||||
updateLayoutByPosition(getBindingAdapterPosition());
|
||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
|
||||
|
@ -132,93 +216,4 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||
|
||||
}
|
||||
|
||||
public UserAccountsAdapter(Context ctx, Dialog dialog) {
|
||||
this.dialog = dialog;
|
||||
this.context = ctx;
|
||||
this.userAccountsList = Objects.requireNonNull(BaseApi.getInstance(context, UserAccountsApi.class)).usersAccounts();
|
||||
}
|
||||
|
||||
private void updateLayoutByPosition(int position) {
|
||||
|
||||
userAccountsList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, userAccountsList.size());
|
||||
Toasty.success(context, context.getResources().getString(R.string.accountDeletedMessage));
|
||||
}
|
||||
|
||||
private void getNotificationsCount() {
|
||||
|
||||
Call<NotificationCount> call = RetrofitClient.getApiInterface(context).notifyNewAvailable();
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<NotificationCount> call, @NonNull retrofit2.Response<NotificationCount> response) {
|
||||
|
||||
NotificationCount notificationCount = response.body();
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
assert notificationCount != null;
|
||||
if(notificationCount.getNew() > 0) {
|
||||
String toastMsg = context.getResources()
|
||||
.getQuantityString(R.plurals.youHaveNewNotifications, Math.toIntExact(notificationCount.getNew()),
|
||||
Math.toIntExact(notificationCount.getNew()));
|
||||
new Handler().postDelayed(() -> Toasty.info(context, toastMsg), 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<NotificationCount> call, @NonNull Throwable t) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public UserAccountsAdapter.UserAccountsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_user_accounts, parent, false);
|
||||
return new UserAccountsViewHolder(v);
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull UserAccountsAdapter.UserAccountsViewHolder holder, int position) {
|
||||
|
||||
UserAccount currentItem = userAccountsList.get(position);
|
||||
TinyDB tinyDB = TinyDB.getInstance(context);
|
||||
|
||||
String url = UrlBuilder.fromString(currentItem.getInstanceUrl()).withPath("/").toString();
|
||||
|
||||
holder.accountId = currentItem.getAccountId();
|
||||
holder.accountName = currentItem.getAccountName();
|
||||
|
||||
holder.userId.setText(currentItem.getUserName());
|
||||
if(currentItem.isLoggedIn()) {
|
||||
holder.accountUrl.setText(url);
|
||||
}
|
||||
else {
|
||||
holder.accountUrl.setText(context.getString(R.string.notLoggedIn, url));
|
||||
}
|
||||
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get().load(url + "assets/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()) {
|
||||
holder.activeAccount.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
holder.deleteAccount.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return userAccountsList.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,24 +41,6 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
|||
this.drawer = drawerLayout;
|
||||
}
|
||||
|
||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView userAccountAvatar;
|
||||
|
||||
private UserAccountsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
userAccountAvatar = itemView.findViewById(R.id.userAccountAvatar);
|
||||
|
||||
itemView.setOnClickListener(item -> {
|
||||
customDialogUserAccountsList();
|
||||
drawer.closeDrawers();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public UserAccountsNavAdapter.UserAccountsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
@ -77,8 +59,8 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
|||
|
||||
int imageSize = AppUtil.getPixelsFromDensity(context, 35);
|
||||
|
||||
PicassoService.getInstance(context).get().load(url + "assets/img/favicon.png").placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(8, 0)).resize(imageSize, imageSize).centerCrop().into(holder.userAccountAvatar);
|
||||
PicassoService.getInstance(context).get().load(url + "assets/img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(imageSize, imageSize).centerCrop()
|
||||
.into(holder.userAccountAvatar);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -111,4 +93,22 @@ public class UserAccountsNavAdapter extends RecyclerView.Adapter<UserAccountsNav
|
|||
dialog.show();
|
||||
}
|
||||
|
||||
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView userAccountAvatar;
|
||||
|
||||
private UserAccountsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
userAccountAvatar = itemView.findViewById(R.id.userAccountAvatar);
|
||||
|
||||
itemView.setOnClickListener(item -> {
|
||||
customDialogUserAccountsList();
|
||||
drawer.closeDrawers();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,32 +30,41 @@ public class UserGridAdapter extends BaseAdapter implements Filterable {
|
|||
private final List<User> membersList;
|
||||
private final Context context;
|
||||
private final List<User> membersListFull;
|
||||
private final Filter membersFilter = new Filter() {
|
||||
|
||||
private class ViewHolder {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<User> filteredList = new ArrayList<>();
|
||||
|
||||
private String userLoginId;
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
|
||||
private final ImageView memberAvatar;
|
||||
private final TextView memberName;
|
||||
filteredList.addAll(membersListFull);
|
||||
}
|
||||
else {
|
||||
|
||||
ViewHolder(View v) {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
memberAvatar = v.findViewById(R.id.userAvatarImageView);
|
||||
memberName = v.findViewById(R.id.userNameTv);
|
||||
for(User item : membersListFull) {
|
||||
if(item.getFullName().toLowerCase().contains(filterPattern) || item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
v.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userLoginId);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
v.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId));
|
||||
return true;
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
membersList.clear();
|
||||
membersList.addAll((List) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public UserGridAdapter(Context ctx, List<User> membersListMain) {
|
||||
|
||||
|
@ -105,8 +114,8 @@ public class UserGridAdapter extends BaseAdapter implements Filterable {
|
|||
User currentItem = membersList.get(position);
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(viewHolder.memberAvatar);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(viewHolder.memberAvatar);
|
||||
|
||||
viewHolder.userLoginId = currentItem.getLogin();
|
||||
|
||||
|
@ -125,40 +134,29 @@ public class UserGridAdapter extends BaseAdapter implements Filterable {
|
|||
return membersFilter;
|
||||
}
|
||||
|
||||
private final Filter membersFilter = new Filter() {
|
||||
private class ViewHolder {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<User> filteredList = new ArrayList<>();
|
||||
private final ImageView memberAvatar;
|
||||
private final TextView memberName;
|
||||
private String userLoginId;
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
ViewHolder(View v) {
|
||||
|
||||
filteredList.addAll(membersListFull);
|
||||
}
|
||||
else {
|
||||
memberAvatar = v.findViewById(R.id.userAvatarImageView);
|
||||
memberName = v.findViewById(R.id.userNameTv);
|
||||
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
v.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userLoginId);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
for(User item : membersListFull) {
|
||||
if(item.getFullName().toLowerCase().contains(filterPattern) || item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
v.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
membersList.clear();
|
||||
membersList.addAll((List) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,44 +43,6 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
|||
this.orgName = orgName;
|
||||
}
|
||||
|
||||
class UserSearchViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private User userInfo;
|
||||
|
||||
private final ImageView userAvatar;
|
||||
private final TextView userFullName;
|
||||
private final TextView userName;
|
||||
private final ImageView addMemberButtonAdd;
|
||||
private final ImageView addMemberButtonRemove;
|
||||
|
||||
private UserSearchViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
userAvatar = itemView.findViewById(R.id.userAvatar);
|
||||
userFullName = itemView.findViewById(R.id.userFullName);
|
||||
userName = itemView.findViewById(R.id.userName);
|
||||
addMemberButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
|
||||
addMemberButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
|
||||
|
||||
addMemberButtonAdd.setOnClickListener(
|
||||
v -> AlertDialogs.addMemberDialog(context, userInfo.getLogin(), Integer.parseInt(String.valueOf(teamId))));
|
||||
addMemberButtonRemove.setOnClickListener(
|
||||
v -> AlertDialogs.removeMemberDialog(context, userInfo.getLogin(), Integer.parseInt(String.valueOf(teamId))));
|
||||
|
||||
userAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userInfo.getLogin());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
userAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userInfo.getLogin(), context.getString(R.string.copyLoginIdToClipBoard, userInfo.getLogin()));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public UserSearchForTeamMemberAdapter.UserSearchViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
@ -107,8 +69,8 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
|||
holder.userName.setText(context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
|
||||
if(!currentItem.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.userAvatar);
|
||||
PicassoService.getInstance(context).get().load(currentItem.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(holder.userAvatar);
|
||||
}
|
||||
|
||||
if(getItemCount() > 0) {
|
||||
|
@ -166,4 +128,39 @@ public class UserSearchForTeamMemberAdapter extends RecyclerView.Adapter<UserSea
|
|||
return usersSearchList.size();
|
||||
}
|
||||
|
||||
class UserSearchViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView userAvatar;
|
||||
private final TextView userFullName;
|
||||
private final TextView userName;
|
||||
private final ImageView addMemberButtonAdd;
|
||||
private final ImageView addMemberButtonRemove;
|
||||
private User userInfo;
|
||||
|
||||
private UserSearchViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
userAvatar = itemView.findViewById(R.id.userAvatar);
|
||||
userFullName = itemView.findViewById(R.id.userFullName);
|
||||
userName = itemView.findViewById(R.id.userName);
|
||||
addMemberButtonAdd = itemView.findViewById(R.id.addCollaboratorButtonAdd);
|
||||
addMemberButtonRemove = itemView.findViewById(R.id.addCollaboratorButtonRemove);
|
||||
|
||||
addMemberButtonAdd.setOnClickListener(v -> AlertDialogs.addMemberDialog(context, userInfo.getLogin(), Integer.parseInt(String.valueOf(teamId))));
|
||||
addMemberButtonRemove.setOnClickListener(v -> AlertDialogs.removeMemberDialog(context, userInfo.getLogin(), Integer.parseInt(String.valueOf(teamId))));
|
||||
|
||||
userAvatar.setOnClickListener(loginId -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
intent.putExtra("username", userInfo.getLogin());
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
userAvatar.setOnLongClickListener(loginId -> {
|
||||
AppUtil.copyToClipboard(context, userInfo.getLogin(), context.getString(R.string.copyLoginIdToClipBoard, userInfo.getLogin()));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,12 +61,31 @@ public class UsersAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
return followersList.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<User> list) {
|
||||
followersList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class UsersHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private User userInfo;
|
||||
private final ImageView userAvatar;
|
||||
private final TextView userFullName;
|
||||
private final TextView userName;
|
||||
private User userInfo;
|
||||
|
||||
UsersHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
@ -101,31 +120,12 @@ public class UsersAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
userName.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
PicassoService.getInstance(context).get().load(userInfo.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(userAvatar);
|
||||
PicassoService.getInstance(context).get().load(userInfo.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(userAvatar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<User> list) {
|
||||
followersList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,15 +38,14 @@ import retrofit2.Response;
|
|||
public class WikiListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final Context ctx;
|
||||
private List<WikiPageMetaData> wikiList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final FragmentWikiBinding fragmentWikiBinding;
|
||||
private final String repoOwner;
|
||||
private final String repoName;
|
||||
private List<WikiPageMetaData> wikiList;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public WikiListAdapter(List<WikiPageMetaData> wikiListMain, Context ctx, String repoOwner, String repoName,
|
||||
FragmentWikiBinding fragmentWikiBinding) {
|
||||
public WikiListAdapter(List<WikiPageMetaData> wikiListMain, Context ctx, String repoOwner, String repoName, FragmentWikiBinding fragmentWikiBinding) {
|
||||
this.ctx = ctx;
|
||||
this.wikiList = wikiListMain;
|
||||
this.repoOwner = repoOwner;
|
||||
|
@ -81,14 +80,81 @@ public class WikiListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
return wikiList.size();
|
||||
}
|
||||
|
||||
class WikisHolder extends RecyclerView.ViewHolder {
|
||||
private void updateAdapter(int position) {
|
||||
wikiList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, wikiList.size());
|
||||
}
|
||||
|
||||
private WikiPageMetaData wikiPageMeta;
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<WikiPageMetaData> list) {
|
||||
wikiList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
private void deleteWiki(final String owner, final String repo, final String pageName, int position, final Context context) {
|
||||
|
||||
new AlertDialog.Builder(context).setTitle(String.format(context.getString(R.string.deleteGenericTitle), pageName)).setMessage(context.getString(R.string.deleteWikiPageMessage, pageName))
|
||||
.setIcon(R.drawable.ic_delete).setPositiveButton(R.string.menuDeleteText, (dialog, whichButton) -> RetrofitClient.getApiInterface(context).repoDeleteWikiPage(owner, repo, pageName).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
updateAdapter(position);
|
||||
Toasty.success(context, context.getString(R.string.wikiPageDeleted));
|
||||
if(getItemCount() == 0) {
|
||||
fragmentWikiBinding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
})).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
class WikisHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView avatar;
|
||||
private final TextView pageName;
|
||||
private final TextView wikiLastUpdatedBy;
|
||||
private final ImageView wikiMenu;
|
||||
private WikiPageMetaData wikiPageMeta;
|
||||
|
||||
WikisHolder(View itemView) {
|
||||
|
||||
|
@ -146,19 +212,15 @@ public class WikiListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
this.wikiPageMeta = wikiPageMetaData;
|
||||
|
||||
pageName.setText(wikiPageMetaData.getTitle());
|
||||
wikiLastUpdatedBy.setText(HtmlCompat.fromHtml(ctx.getResources()
|
||||
.getString(R.string.wikiAuthor, wikiPageMetaData.getLastCommit().getAuthor().getName(),
|
||||
TimeHelper.formatTime(TimeHelper.parseIso8601(wikiPageMetaData.getLastCommit().getAuthor().getDate()),
|
||||
ctx.getResources().getConfiguration().locale, "pretty", ctx)), HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
this.wikiLastUpdatedBy.setOnClickListener(new ClickListener(
|
||||
TimeHelper.customDateFormatForToastDateFormat(TimeHelper.parseIso8601(wikiPageMetaData.getLastCommit().getAuthor().getDate())), ctx));
|
||||
wikiLastUpdatedBy.setText(HtmlCompat.fromHtml(ctx.getResources().getString(R.string.wikiAuthor, wikiPageMetaData.getLastCommit().getAuthor().getName(),
|
||||
TimeHelper.formatTime(TimeHelper.parseIso8601(wikiPageMetaData.getLastCommit().getAuthor().getDate()), ctx.getResources().getConfiguration().locale, "pretty", ctx)), HtmlCompat.FROM_HTML_MODE_COMPACT));
|
||||
this.wikiLastUpdatedBy.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(TimeHelper.parseIso8601(wikiPageMetaData.getLastCommit().getAuthor().getDate())), ctx));
|
||||
|
||||
ColorGenerator generator = ColorGenerator.Companion.getMATERIAL();
|
||||
int color = generator.getColor(wikiPageMetaData.getTitle());
|
||||
String firstCharacter = String.valueOf(wikiPageMetaData.getTitle().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);
|
||||
avatar.setImageDrawable(drawable);
|
||||
|
||||
if(!((RepoDetailActivity) ctx).repository.getPermissions().isPush()) {
|
||||
|
@ -168,74 +230,4 @@ public class WikiListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
|
||||
}
|
||||
|
||||
private void updateAdapter(int position) {
|
||||
wikiList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, wikiList.size());
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<WikiPageMetaData> list) {
|
||||
wikiList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
private void deleteWiki(final String owner, final String repo, final String pageName, int position, final Context context) {
|
||||
|
||||
new AlertDialog.Builder(context).setTitle(String.format(context.getString(R.string.deleteGenericTitle), pageName))
|
||||
.setMessage(context.getString(R.string.deleteWikiPageMessage, pageName)).setIcon(R.drawable.ic_delete)
|
||||
.setPositiveButton(R.string.menuDeleteText,
|
||||
(dialog, whichButton) -> RetrofitClient.getApiInterface(context).repoDeleteWikiPage(owner, repo, pageName).enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
updateAdapter(position);
|
||||
Toasty.success(context, context.getString(R.string.wikiPageDeleted));
|
||||
if(getItemCount() == 0) {
|
||||
fragmentWikiBinding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
})).setNeutralButton(R.string.cancelButton, null).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,17 +71,35 @@ public class RepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
return reposList.size();
|
||||
}
|
||||
|
||||
class RepositoriesHolder extends RecyclerView.ViewHolder {
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
private Repository userRepositories;
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class RepositoriesHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView avatar;
|
||||
private final TextView repoName;
|
||||
private final TextView orgName;
|
||||
private final TextView repoDescription;
|
||||
private CheckBox isRepoAdmin;
|
||||
private final TextView repoStars;
|
||||
private final TextView repoLastUpdated;
|
||||
private Repository userRepositories;
|
||||
private CheckBox isRepoAdmin;
|
||||
|
||||
RepositoriesHolder(View itemView) {
|
||||
|
||||
|
@ -123,13 +141,12 @@ public class RepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
int color = generator.getColor(userRepositories.getName());
|
||||
String firstCharacter = String.valueOf(userRepositories.getFullName().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(userRepositories.getAvatarUrl() != null) {
|
||||
if(!userRepositories.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(userRepositories.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(avatar);
|
||||
PicassoService.getInstance(context).get().load(userRepositories.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(avatar);
|
||||
}
|
||||
else {
|
||||
avatar.setImageDrawable(drawable);
|
||||
|
@ -141,11 +158,9 @@ public class RepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
|
||||
if(userRepositories.getUpdatedAt() != null) {
|
||||
|
||||
repoLastUpdated.setText(
|
||||
context.getString(R.string.lastUpdatedAt, TimeHelper.formatTime(userRepositories.getUpdatedAt(), locale, timeFormat, context)));
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, TimeHelper.formatTime(userRepositories.getUpdatedAt(), locale, timeFormat, context)));
|
||||
if(timeFormat.equals("pretty")) {
|
||||
repoLastUpdated.setOnClickListener(
|
||||
new ClickListener(TimeHelper.customDateFormatForToastDateFormat(userRepositories.getUpdatedAt()), context));
|
||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(userRepositories.getUpdatedAt()), context));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -168,23 +183,4 @@ public class RepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -70,17 +70,35 @@ public class StarredRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||
return reposList.size();
|
||||
}
|
||||
|
||||
class StarredRepositoriesHolder extends RecyclerView.ViewHolder {
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
class StarredRepositoriesHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView avatar;
|
||||
private final TextView repoName;
|
||||
private final TextView orgName;
|
||||
private final TextView repoDescription;
|
||||
private CheckBox isRepoAdmin;
|
||||
private final TextView repoStars;
|
||||
private final TextView repoLastUpdated;
|
||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
||||
private CheckBox isRepoAdmin;
|
||||
|
||||
StarredRepositoriesHolder(View itemView) {
|
||||
|
||||
|
@ -121,13 +139,12 @@ public class StarredRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||
int color = generator.getColor(userRepositories.getName());
|
||||
String firstCharacter = String.valueOf(userRepositories.getFullName().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(userRepositories.getAvatarUrl() != null) {
|
||||
if(!userRepositories.getAvatarUrl().equals("")) {
|
||||
PicassoService.getInstance(context).get().load(userRepositories.getAvatarUrl()).placeholder(R.drawable.loader_animated)
|
||||
.transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(avatar);
|
||||
PicassoService.getInstance(context).get().load(userRepositories.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop()
|
||||
.into(avatar);
|
||||
}
|
||||
else {
|
||||
avatar.setImageDrawable(drawable);
|
||||
|
@ -139,11 +156,9 @@ public class StarredRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||
|
||||
if(userRepositories.getUpdatedAt() != null) {
|
||||
|
||||
repoLastUpdated.setText(
|
||||
context.getString(R.string.lastUpdatedAt, TimeHelper.formatTime(userRepositories.getUpdatedAt(), locale, timeFormat, context)));
|
||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, TimeHelper.formatTime(userRepositories.getUpdatedAt(), locale, timeFormat, context)));
|
||||
if(timeFormat.equals("pretty")) {
|
||||
repoLastUpdated.setOnClickListener(
|
||||
new ClickListener(TimeHelper.customDateFormatForToastDateFormat(userRepositories.getUpdatedAt()), context));
|
||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(userRepositories.getUpdatedAt()), context));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -166,23 +181,4 @@ public class StarredRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
||||
reposList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -56,13 +56,6 @@ public class PicassoService {
|
|||
}
|
||||
}
|
||||
|
||||
public Picasso get() {
|
||||
|
||||
cachePath.mkdirs();
|
||||
return picasso;
|
||||
|
||||
}
|
||||
|
||||
public static synchronized PicassoService getInstance(Context context) {
|
||||
|
||||
if(picassoService == null) {
|
||||
|
@ -77,4 +70,11 @@ public class PicassoService {
|
|||
|
||||
}
|
||||
|
||||
public Picasso get() {
|
||||
|
||||
cachePath.mkdirs();
|
||||
return picasso;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,8 +77,7 @@ public class RetrofitClient {
|
|||
|
||||
if(cacheEnabled && cacheFile != null) {
|
||||
|
||||
int cacheSize = FilesData.returnOnlyNumberFileSize(
|
||||
tinyDB.getString("cacheSizeStr", context.getString(R.string.cacheSizeDataSelectionSelectedText))) * 1024 * 1024;
|
||||
int cacheSize = FilesData.returnOnlyNumberFileSize(tinyDB.getString("cacheSizeStr", context.getString(R.string.cacheSizeDataSelectionSelectedText))) * 1024 * 1024;
|
||||
Cache cache = new Cache(cacheFile, cacheSize);
|
||||
|
||||
okHttpClient.cache(cache).addInterceptor(chain -> {
|
||||
|
@ -94,8 +93,7 @@ public class RetrofitClient {
|
|||
}
|
||||
|
||||
return new Retrofit.Builder().baseUrl(instanceUrl).client(okHttpClient.build()).addConverterFactory(ScalarsConverterFactory.create())
|
||||
.addConverterFactory(GsonConverterFactory.create(new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create()))
|
||||
.addConverterFactory(DateQueryConverterFactory.create()).build();
|
||||
.addConverterFactory(GsonConverterFactory.create(new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create())).addConverterFactory(DateQueryConverterFactory.create()).build();
|
||||
|
||||
}
|
||||
catch(Exception e) {
|
||||
|
@ -107,8 +105,8 @@ public class RetrofitClient {
|
|||
}
|
||||
|
||||
public static ApiInterface getApiInterface(Context context) {
|
||||
return getApiInterface(context, ((BaseActivity) context).getAccount().getAccount().getInstanceUrl(),
|
||||
((BaseActivity) context).getAccount().getAuthorization(), ((BaseActivity) context).getAccount().getCacheDir(context));
|
||||
return getApiInterface(context, ((BaseActivity) context).getAccount().getAccount().getInstanceUrl(), ((BaseActivity) context).getAccount().getAuthorization(),
|
||||
((BaseActivity) context).getAccount().getCacheDir(context));
|
||||
}
|
||||
|
||||
public static WebApi getWebInterface(Context context) {
|
||||
|
@ -116,8 +114,7 @@ public class RetrofitClient {
|
|||
String instanceUrl = ((BaseActivity) context).getAccount().getAccount().getInstanceUrl();
|
||||
instanceUrl = instanceUrl.substring(0, instanceUrl.lastIndexOf("api/v1/"));
|
||||
|
||||
return getWebInterface(context, instanceUrl, ((BaseActivity) context).getAccount().getWebAuthorization(),
|
||||
((BaseActivity) context).getAccount().getCacheDir(context));
|
||||
return getWebInterface(context, instanceUrl, ((BaseActivity) context).getAccount().getWebAuthorization(), ((BaseActivity) context).getAccount().getCacheDir(context));
|
||||
|
||||
}
|
||||
|
||||
|
@ -128,8 +125,7 @@ public class RetrofitClient {
|
|||
synchronized(RetrofitClient.class) {
|
||||
if(!apiInterfaces.containsKey(key)) {
|
||||
|
||||
ApiInterface apiInterface = Objects.requireNonNull(createRetrofit(context, url, true, token, cacheFile))
|
||||
.create(ApiInterface.class);
|
||||
ApiInterface apiInterface = Objects.requireNonNull(createRetrofit(context, url, true, token, cacheFile)).create(ApiInterface.class);
|
||||
apiInterfaces.put(key, apiInterface);
|
||||
|
||||
return apiInterface;
|
||||
|
|
|
@ -24,8 +24,8 @@ import org.mian.gitnex.notifications.Notifications;
|
|||
|
||||
public class MainApplication extends Application {
|
||||
|
||||
private TinyDB tinyDB;
|
||||
public AccountContext currentAccount;
|
||||
private TinyDB tinyDB;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
@ -55,15 +55,12 @@ public class MainApplication extends Application {
|
|||
|
||||
CoreConfigurationBuilder ACRABuilder = new CoreConfigurationBuilder(this);
|
||||
|
||||
ACRABuilder.withBuildConfigClass(BuildConfig.class)
|
||||
.withReportContent(ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL, ReportField.STACK_TRACE, ReportField.AVAILABLE_MEM_SIZE,
|
||||
ReportField.BRAND).setReportFormat(StringFormat.KEY_VALUE_LIST);
|
||||
ACRABuilder.getPluginConfigurationBuilder(NotificationConfigurationBuilder.class).withResTitle(R.string.crashTitle)
|
||||
.withResIcon(R.drawable.gitnex_transparent).withResChannelName(R.string.setCrashReports).withResText(R.string.crashMessage)
|
||||
.withEnabled(true);
|
||||
ACRABuilder.withBuildConfigClass(BuildConfig.class).withReportContent(ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL, ReportField.STACK_TRACE, ReportField.AVAILABLE_MEM_SIZE, ReportField.BRAND)
|
||||
.setReportFormat(StringFormat.KEY_VALUE_LIST);
|
||||
ACRABuilder.getPluginConfigurationBuilder(NotificationConfigurationBuilder.class).withResTitle(R.string.crashTitle).withResIcon(R.drawable.gitnex_transparent).withResChannelName(R.string.setCrashReports)
|
||||
.withResText(R.string.crashMessage).withEnabled(true);
|
||||
ACRABuilder.getPluginConfigurationBuilder(MailSenderConfigurationBuilder.class).withMailTo(getResources().getString(R.string.appEmail))
|
||||
.withSubject(getResources().getString(R.string.crashReportEmailSubject, AppUtil.getAppBuildNo(context))).withReportAsFile(true)
|
||||
.withEnabled(true);
|
||||
.withSubject(getResources().getString(R.string.crashReportEmailSubject, AppUtil.getAppBuildNo(context))).withReportAsFile(true).withEnabled(true);
|
||||
ACRABuilder.getPluginConfigurationBuilder(LimiterConfigurationBuilder.class).setEnabled(true);
|
||||
|
||||
ACRA.init(this, ACRABuilder);
|
||||
|
|
|
@ -21,6 +21,20 @@ public class MainGrammarLocator implements GrammarLocator {
|
|||
private MainGrammarLocator() {
|
||||
}
|
||||
|
||||
public static MainGrammarLocator getInstance() {
|
||||
|
||||
if(instance == null) {
|
||||
synchronized(MainGrammarLocator.class) {
|
||||
if(instance == null) {
|
||||
instance = new MainGrammarLocator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return instance;
|
||||
|
||||
}
|
||||
|
||||
public String fromExtension(String extension) {
|
||||
|
||||
switch(extension.toLowerCase()) {
|
||||
|
@ -118,18 +132,4 @@ public class MainGrammarLocator implements GrammarLocator {
|
|||
return defaultGrammarLocator.languages();
|
||||
}
|
||||
|
||||
public static MainGrammarLocator getInstance() {
|
||||
|
||||
if(instance == null) {
|
||||
synchronized(MainGrammarLocator.class) {
|
||||
if(instance == null) {
|
||||
instance = new MainGrammarLocator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return instance;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,9 +15,8 @@ import java.util.concurrent.Executors;
|
|||
|
||||
public abstract class BaseApi {
|
||||
|
||||
private static final Map<Class<? extends BaseApi>, Object> instances = new HashMap<>();
|
||||
|
||||
protected static final ExecutorService executorService = Executors.newCachedThreadPool();
|
||||
private static final Map<Class<? extends BaseApi>, Object> instances = new HashMap<>();
|
||||
protected final GitnexDatabase gitnexDatabase;
|
||||
|
||||
protected BaseApi(Context context) {
|
||||
|
|
|
@ -20,8 +20,7 @@ public class DraftsApi extends BaseApi {
|
|||
draftsDao = gitnexDatabase.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) {
|
||||
|
||||
Draft draft = new Draft();
|
||||
draft.setDraftRepositoryId(repositoryId);
|
||||
|
|
|
@ -19,8 +19,7 @@ public class UserAccountsApi extends BaseApi {
|
|||
userAccountsDao = gitnexDatabase.userAccountsDao();
|
||||
}
|
||||
|
||||
public long createNewAccount(String accountName, String instanceUrl, String userName, String token, String serverVersion, int maxResponseItems,
|
||||
int defaultPagingNumber) {
|
||||
public long createNewAccount(String accountName, String instanceUrl, String userName, String token, String serverVersion, int maxResponseItems, int defaultPagingNumber) {
|
||||
|
||||
UserAccount userAccount = new UserAccount();
|
||||
userAccount.setAccountName(accountName);
|
||||
|
|
|
@ -22,14 +22,6 @@ import org.mian.gitnex.database.models.UserAccount;
|
|||
public abstract class GitnexDatabase extends RoomDatabase {
|
||||
|
||||
private static final String DB_NAME = "gitnex";
|
||||
private static GitnexDatabase gitnexDatabase;
|
||||
|
||||
public abstract DraftsDao draftsDao();
|
||||
|
||||
public abstract RepositoriesDao repositoriesDao();
|
||||
|
||||
public abstract UserAccountsDao userAccountsDao();
|
||||
|
||||
private static final Migration MIGRATION_1_2 = new Migration(1, 2) {
|
||||
|
||||
@Override
|
||||
|
@ -38,7 +30,6 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'commentId' TEXT");
|
||||
}
|
||||
};
|
||||
|
||||
private static final Migration MIGRATION_2_3 = new Migration(2, 3) {
|
||||
|
||||
@Override
|
||||
|
@ -46,7 +37,6 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||
database.execSQL("ALTER TABLE 'Drafts' ADD COLUMN 'issueType' TEXT");
|
||||
}
|
||||
};
|
||||
|
||||
private static final Migration MIGRATION_3_4 = new Migration(3, 4) {
|
||||
|
||||
@Override
|
||||
|
@ -54,7 +44,6 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||
database.execSQL("ALTER TABLE 'userAccounts' ADD COLUMN 'isLoggedIn' INTEGER NOT NULL DEFAULT 1");
|
||||
}
|
||||
};
|
||||
|
||||
private static final Migration MIGRATION_4_5 = new Migration(4, 5) {
|
||||
|
||||
@Override
|
||||
|
@ -63,6 +52,7 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||
database.execSQL("ALTER TABLE 'userAccounts' ADD COLUMN 'defaultPagingNumber' INTEGER NOT NULL DEFAULT 30");
|
||||
}
|
||||
};
|
||||
private static GitnexDatabase gitnexDatabase;
|
||||
|
||||
public static GitnexDatabase getDatabaseInstance(Context context) {
|
||||
|
||||
|
@ -82,4 +72,10 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
|||
|
||||
}
|
||||
|
||||
public abstract DraftsDao draftsDao();
|
||||
|
||||
public abstract RepositoriesDao repositoriesDao();
|
||||
|
||||
public abstract UserAccountsDao userAccountsDao();
|
||||
|
||||
}
|
||||
|
|
|
@ -12,8 +12,7 @@ import static androidx.room.ForeignKey.CASCADE;
|
|||
* @author M M Arif
|
||||
*/
|
||||
|
||||
@Entity(tableName = "Drafts", foreignKeys = @ForeignKey(entity = Repository.class, parentColumns = "repositoryId", childColumns = "draftRepositoryId", onDelete = CASCADE), indices = {
|
||||
@Index("draftRepositoryId")})
|
||||
@Entity(tableName = "Drafts", foreignKeys = @ForeignKey(entity = Repository.class, parentColumns = "repositoryId", childColumns = "draftRepositoryId", onDelete = CASCADE), indices = {@Index("draftRepositoryId")})
|
||||
public class Draft implements Serializable {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
|
|
|
@ -11,8 +11,7 @@ import static androidx.room.ForeignKey.CASCADE;
|
|||
* @author M M Arif
|
||||
*/
|
||||
|
||||
@Entity(tableName = "Repositories", foreignKeys = @ForeignKey(entity = UserAccount.class, parentColumns = "accountId", childColumns = "repoAccountId", onDelete = CASCADE), indices = {
|
||||
@Index("repoAccountId")})
|
||||
@Entity(tableName = "Repositories", foreignKeys = @ForeignKey(entity = UserAccount.class, parentColumns = "accountId", childColumns = "repoAccountId", onDelete = CASCADE), indices = {@Index("repoAccountId")})
|
||||
public class Repository implements Serializable {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
|
|
|
@ -33,8 +33,7 @@ public class AdministrationFragment extends Fragment {
|
|||
}
|
||||
|
||||
fragmentAdministrationBinding.adminCronFrame.setOnClickListener(v1 -> startActivity(new Intent(getContext(), AdminCronTasksActivity.class)));
|
||||
fragmentAdministrationBinding.unadoptedReposFrame.setOnClickListener(
|
||||
v1 -> startActivity(new Intent(getContext(), AdminUnadoptedReposActivity.class)));
|
||||
fragmentAdministrationBinding.unadoptedReposFrame.setOnClickListener(v1 -> startActivity(new Intent(getContext(), AdminUnadoptedReposActivity.class)));
|
||||
|
||||
String action = requireActivity().getIntent().getStringExtra("giteaAdminAction");
|
||||
if(action != null) {
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.mian.gitnex.structs.BottomSheetListener;
|
|||
|
||||
public class BottomSheetDraftsFragment extends BottomSheetDialogFragment {
|
||||
|
||||
private String TAG = "BottomSheetDraftsFragment";
|
||||
private final String TAG = "BottomSheetDraftsFragment";
|
||||
private BottomSheetListener bmListener;
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -24,8 +24,7 @@ public class BottomSheetMilestonesFilterFragment extends BottomSheetDialogFragme
|
|||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
BottomSheetMilestonesFilterBinding bottomSheetMilestonesFilterBinding = BottomSheetMilestonesFilterBinding.inflate(inflater, container,
|
||||
false);
|
||||
BottomSheetMilestonesFilterBinding bottomSheetMilestonesFilterBinding = BottomSheetMilestonesFilterBinding.inflate(inflater, container, false);
|
||||
|
||||
bottomSheetMilestonesFilterBinding.openMilestone.setOnClickListener(v1 -> {
|
||||
bmListener.onButtonClicked("openMilestone");
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue