Share feature and some refactor to easily manage source code files

This commit is contained in:
M M Arif
2020-03-17 00:28:03 +05:00
parent c2e80199ca
commit 79bd96f6a2
28 changed files with 134 additions and 57 deletions

View File

@@ -15,14 +15,14 @@ import org.mian.gitnex.R;
* Author M M Arif
*/
public class AdminUsersBottomSheetFragment extends BottomSheetDialogFragment {
public class BottomSheetAdminUsersFragment extends BottomSheetDialogFragment {
private AdminUsersBottomSheetFragment.BottomSheetListener bmListener;
private BottomSheetAdminUsersFragment.BottomSheetListener bmListener;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.admin_users_bottom_sheet_layout, container, false);
View v = inflater.inflate(R.layout.bottom_sheet_admin_users_layout, container, false);
TextView createNewUser = v.findViewById(R.id.createNewUser);
@@ -46,7 +46,7 @@ public class AdminUsersBottomSheetFragment extends BottomSheetDialogFragment {
super.onAttach(context);
try {
bmListener = (AdminUsersBottomSheetFragment.BottomSheetListener) context;
bmListener = (BottomSheetAdminUsersFragment.BottomSheetListener) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString()
+ " must implement BottomSheetListener");

View File

@@ -16,12 +16,12 @@ import androidx.annotation.Nullable;
* Author M M Arif
*/
public class NavSubMenuBottomSheetFragment extends BottomSheetDialogFragment {
public class BottomSheetNavSubMenuFragment extends BottomSheetDialogFragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.nav_sub_menu_bottom_sheet_layout, container, false);
View v = inflater.inflate(R.layout.bottom_sheet_nav_sub_menu_layout, container, false);
TextView adminUsers = v.findViewById(R.id.adminUsers);

View File

@@ -15,14 +15,14 @@ import androidx.annotation.Nullable;
* Author M M Arif
*/
public class OrgBottomSheetFragment extends BottomSheetDialogFragment {
public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
private OrgBottomSheetFragment.BottomSheetListener bmListener;
private BottomSheetOrganizationFragment.BottomSheetListener bmListener;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.org_bottom_sheet_layout, container, false);
View v = inflater.inflate(R.layout.bottom_sheet_organization_layout, container, false);
TextView createTeam = v.findViewById(R.id.createTeam);
@@ -46,7 +46,7 @@ public class OrgBottomSheetFragment extends BottomSheetDialogFragment {
super.onAttach(context);
try {
bmListener = (OrgBottomSheetFragment.BottomSheetListener) context;
bmListener = (BottomSheetOrganizationFragment.BottomSheetListener) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString()
+ " must implement BottomSheetListener");

View File

@@ -16,12 +16,12 @@ import androidx.annotation.Nullable;
* Author M M Arif
*/
public class ProfileBottomSheetFragment extends BottomSheetDialogFragment {
public class BottomSheetProfileFragment extends BottomSheetDialogFragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.profile_bottom_sheet_layout, container, false);
View v = inflater.inflate(R.layout.bottom_sheet_profile_layout, container, false);
TextView addNewEmailAddress = v.findViewById(R.id.addNewEmailAddress);

View File

@@ -17,14 +17,14 @@ import androidx.annotation.Nullable;
* Author M M Arif
*/
public class RepoBottomSheetFragment extends BottomSheetDialogFragment {
public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
private BottomSheetListener bmListener;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.repo_bottom_sheet_layout, container, false);
View v = inflater.inflate(R.layout.bottom_sheet_repo_layout, container, false);
final TinyDB tinyDb = new TinyDB(getContext());
@@ -39,6 +39,7 @@ public class RepoBottomSheetFragment extends BottomSheetDialogFragment {
TextView unStarRepository = v.findViewById(R.id.unStarRepository);
TextView watchRepository = v.findViewById(R.id.watchRepository);
TextView unWatchRepository = v.findViewById(R.id.unWatchRepository);
TextView shareRepository = v.findViewById(R.id.shareRepository);
createLabel.setOnClickListener(new View.OnClickListener() {
@Override
@@ -86,6 +87,14 @@ public class RepoBottomSheetFragment extends BottomSheetDialogFragment {
}
});
shareRepository.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bmListener.onButtonClicked("shareRepo");
dismiss();
}
});
openWebRepo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@@ -27,13 +27,13 @@ import java.util.Objects;
* Author M M Arif
*/
public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.single_issue_bottom_sheet_layout, container, false);
View v = inflater.inflate(R.layout.bottom_sheet_single_issue_layout, container, false);
final TinyDB tinyDB = new TinyDB(getContext());
@@ -46,6 +46,7 @@ public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
TextView copyIssueUrl = v.findViewById(R.id.copyIssueUrl);
TextView openFilesDiff = v.findViewById(R.id.openFilesDiff);
TextView mergePullRequest = v.findViewById(R.id.mergePullRequest);
TextView shareIssue = v.findViewById(R.id.shareIssue);
replyToIssue.setOnClickListener(new View.OnClickListener() {
@Override
@@ -133,6 +134,29 @@ public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
}
});
shareIssue.setOnClickListener(v1 -> {
// get url of repo
String repoFullName = tinyDB.getString("repoFullName");
String instanceUrlWithProtocol = "https://" + tinyDB.getString("instanceUrlRaw");
if (!tinyDB.getString("instanceUrlWithProtocol").isEmpty()) {
instanceUrlWithProtocol = tinyDB.getString("instanceUrlWithProtocol");
}
// get issue Url
String issueUrl = instanceUrlWithProtocol + "/" + repoFullName + "/issues/" + tinyDB.getString("issueNumber");
// share issue
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.hash) + tinyDB.getString("issueNumber") + " " + tinyDB.getString("issueTitle"));
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, issueUrl);
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.hash) + tinyDB.getString("issueNumber") + " " + tinyDB.getString("issueTitle")));
dismiss();
});
copyIssueUrl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -170,7 +194,7 @@ public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
@Override
public void onClick(View v) {
IssueActions.closeReopenIssue(getContext(), Integer.valueOf(tinyDB.getString("issueNumber")), "closed");
IssueActions.closeReopenIssue(getContext(), Integer.parseInt(tinyDB.getString("issueNumber")), "closed");
dismiss();
}
@@ -184,7 +208,7 @@ public class SingleIssueBottomSheetFragment extends BottomSheetDialogFragment {
@Override
public void onClick(View v) {
IssueActions.closeReopenIssue(getContext(), Integer.valueOf(tinyDB.getString("issueNumber")), "open");
IssueActions.closeReopenIssue(getContext(), Integer.parseInt(tinyDB.getString("issueNumber")), "open");
dismiss();
}

View File

@@ -52,7 +52,7 @@ public class ProfileFragment extends Fragment {
userLogin.setText(getString(R.string.usernameWithAt, tinyDb.getString("userLogin")));
userEmail.setText(tinyDb.getString("userEmail"));
ProfileFragment.SectionsPagerAdapter mSectionsPagerAdapter = new ProfileFragment.SectionsPagerAdapter(getFragmentManager());
ProfileFragment.SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager());
ViewPager mViewPager = v.findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
@@ -101,7 +101,7 @@ public class ProfileFragment extends Fragment {
}
public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
public static class SectionsPagerAdapter extends FragmentStatePagerAdapter {
SectionsPagerAdapter(FragmentManager fm) {
super(fm);
@@ -147,9 +147,8 @@ public class ProfileFragment extends Fragment {
((MainActivity)ctx).finish();
return true;
case R.id.profileMenu:
ProfileBottomSheetFragment bottomSheet = new ProfileBottomSheetFragment();
assert getFragmentManager() != null;
bottomSheet.show(getFragmentManager(), "profileBottomSheet");
BottomSheetProfileFragment bottomSheet = new BottomSheetProfileFragment();
bottomSheet.show(getChildFragmentManager(), "profileBottomSheet");
return true;
default:
return super.onOptionsItemSelected(item);