Create repository from organization menu, refactors too
This commit is contained in:
@@ -32,7 +32,7 @@ import retrofit2.Callback;
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class NewFileActivity extends BaseActivity {
|
||||
public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
public ImageView closeActivity;
|
||||
private View.OnClickListener onClickListener;
|
||||
@@ -28,7 +28,7 @@ import java.util.Calendar;
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class NewMilestoneActivity extends BaseActivity implements View.OnClickListener {
|
||||
public class CreateMilestoneActivity extends BaseActivity implements View.OnClickListener {
|
||||
|
||||
private EditText milestoneDueDate;
|
||||
private View.OnClickListener onClickListener;
|
||||
@@ -24,7 +24,7 @@ import retrofit2.Callback;
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class NewOrganizationActivity extends BaseActivity {
|
||||
public class CreateOrganizationActivity extends BaseActivity {
|
||||
|
||||
public ImageView closeActivity;
|
||||
private View.OnClickListener onClickListener;
|
||||
@@ -32,7 +32,7 @@ import retrofit2.Callback;
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class NewRepoActivity extends BaseActivity {
|
||||
public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
public ImageView closeActivity;
|
||||
private View.OnClickListener onClickListener;
|
||||
@@ -43,7 +43,7 @@ public class NewRepoActivity extends BaseActivity {
|
||||
private CheckBox repoAccess;
|
||||
final Context ctx = this;
|
||||
|
||||
List<OrgOwner> orgsList = new ArrayList<>();
|
||||
List<OrgOwner> organizationsList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
@@ -72,7 +72,7 @@ public class NewRepoActivity extends BaseActivity {
|
||||
|
||||
spinner = findViewById(R.id.ownerSpinner);
|
||||
spinner.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
|
||||
getOrgs(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), userLogin);
|
||||
getOrganizations(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), userLogin);
|
||||
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
@@ -225,7 +225,9 @@ public class NewRepoActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
private void getOrgs(String instanceUrl, String instanceToken, final String userLogin) {
|
||||
private void getOrganizations(String instanceUrl, String instanceToken, final String userLogin) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
Call<List<OrgOwner>> call = RetrofitClient
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
@@ -240,26 +242,37 @@ public class NewRepoActivity extends BaseActivity {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 200) {
|
||||
|
||||
List<OrgOwner> orgsList_ = response.body();
|
||||
int organizationId = 0;
|
||||
|
||||
orgsList.add(new OrgOwner(userLogin));
|
||||
assert orgsList_ != null;
|
||||
if(orgsList_.size() > 0) {
|
||||
for (int i = 0; i < orgsList_.size(); i++) {
|
||||
List<OrgOwner> organizationsList_ = response.body();
|
||||
|
||||
organizationsList.add(new OrgOwner(userLogin));
|
||||
assert organizationsList_ != null;
|
||||
if(organizationsList_.size() > 0) {
|
||||
for (int i = 0; i < organizationsList_.size(); i++) {
|
||||
|
||||
if(Integer.parseInt(tinyDb.getString("organizationId")) == organizationsList_.get(i).getId()) {
|
||||
organizationId = i + 1;
|
||||
}
|
||||
OrgOwner data = new OrgOwner(
|
||||
orgsList_.get(i).getUsername()
|
||||
organizationsList_.get(i).getUsername()
|
||||
);
|
||||
orgsList.add(data);
|
||||
organizationsList.add(data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<OrgOwner> adapter = new ArrayAdapter<>(getApplicationContext(),
|
||||
R.layout.spinner_item, orgsList);
|
||||
R.layout.spinner_item, organizationsList);
|
||||
|
||||
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
|
||||
spinner.setAdapter(adapter);
|
||||
|
||||
if (tinyDb.getBoolean("organizationAction")) {
|
||||
spinner.setSelection(organizationId);
|
||||
tinyDb.putBoolean("organizationAction", false);
|
||||
}
|
||||
|
||||
enableProcessButton();
|
||||
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import java.util.Objects;
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class OrgDetailActivity extends BaseActivity implements BottomSheetOrganizationFragment.BottomSheetListener {
|
||||
public class OrganizationDetailActivity extends BaseActivity implements BottomSheetOrganizationFragment.BottomSheetListener {
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
@@ -50,7 +50,7 @@ public class OrgDetailActivity extends BaseActivity implements BottomSheetOrgani
|
||||
Objects.requireNonNull(getSupportActionBar()).setTitle(orgName);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
OrgDetailActivity.SectionsPagerAdapter mSectionsPagerAdapter = new OrgDetailActivity.SectionsPagerAdapter(getSupportFragmentManager());
|
||||
OrganizationDetailActivity.SectionsPagerAdapter mSectionsPagerAdapter = new OrganizationDetailActivity.SectionsPagerAdapter(getSupportFragmentManager());
|
||||
|
||||
ViewPager mViewPager = findViewById(R.id.container);
|
||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||
@@ -130,9 +130,15 @@ public class OrgDetailActivity extends BaseActivity implements BottomSheetOrgani
|
||||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
switch (text) {
|
||||
case "repository":
|
||||
tinyDb.putBoolean("organizationAction", true);
|
||||
startActivity(new Intent(OrganizationDetailActivity.this, CreateRepoActivity.class));
|
||||
break;
|
||||
case "team":
|
||||
startActivity(new Intent(OrgDetailActivity.this, CreateTeamByOrgActivity.class));
|
||||
startActivity(new Intent(OrganizationDetailActivity.this, CreateTeamByOrgActivity.class));
|
||||
break;
|
||||
}
|
||||
//Log.i("clicked", text);
|
||||
@@ -142,7 +148,7 @@ public class OrgDetailActivity extends BaseActivity implements BottomSheetOrgani
|
||||
public class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||
|
||||
SectionsPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -151,7 +157,7 @@ public class OrgDetailActivity extends BaseActivity implements BottomSheetOrgani
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
String orgName;
|
||||
if(getIntent().getStringExtra("orgName") != null || !getIntent().getStringExtra("orgName").equals("")) {
|
||||
if(getIntent().getStringExtra("orgName") != null || !Objects.equals(getIntent().getStringExtra("orgName"), "")) {
|
||||
orgName = getIntent().getStringExtra("orgName");
|
||||
}
|
||||
else {
|
||||
@@ -21,7 +21,7 @@ import java.util.Objects;
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class OrgTeamMembersActivity extends BaseActivity {
|
||||
public class OrganizationTeamMembersActivity extends BaseActivity {
|
||||
|
||||
private TextView noDataMembers;
|
||||
private View.OnClickListener onClickListener;
|
||||
@@ -213,7 +213,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateIssueActivity.class));
|
||||
break;
|
||||
case "newMilestone":
|
||||
startActivity(new Intent(RepoDetailActivity.this, NewMilestoneActivity.class));
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateMilestoneActivity.class));
|
||||
break;
|
||||
case "addCollaborator":
|
||||
startActivity(new Intent(RepoDetailActivity.this, AddCollaboratorToRepositoryActivity.class));
|
||||
@@ -233,7 +233,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
startActivity(Intent.createChooser(sharingIntent, url.toString()));
|
||||
break;
|
||||
case "newFile":
|
||||
startActivity(new Intent(RepoDetailActivity.this, NewFileActivity.class));
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateFileActivity.class));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.mian.gitnex.adapters;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -13,7 +14,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OrgDetailActivity;
|
||||
import org.mian.gitnex.activities.OrganizationDetailActivity;
|
||||
import org.mian.gitnex.models.UserOrganizations;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
@@ -35,23 +36,27 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<Organizations
|
||||
private ImageView image;
|
||||
private TextView mTextView1;
|
||||
private TextView mTextView2;
|
||||
private TextView organizationId;
|
||||
|
||||
private OrganizationsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mTextView1 = itemView.findViewById(R.id.orgUsername);
|
||||
mTextView2 = itemView.findViewById(R.id.orgDescription);
|
||||
image = itemView.findViewById(R.id.imageAvatar);
|
||||
organizationId = itemView.findViewById(R.id.organizationId);
|
||||
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, OrgDetailActivity.class);
|
||||
Intent intent = new Intent(context, OrganizationDetailActivity.class);
|
||||
intent.putExtra("orgName", mTextView1.getText().toString());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putString("orgName", mTextView1.getText().toString());
|
||||
tinyDb.putString("organizationId", organizationId.getText().toString());
|
||||
tinyDb.putBoolean("organizationAction", true);
|
||||
context.startActivity(intent);
|
||||
|
||||
}
|
||||
@@ -73,11 +78,13 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<Organizations
|
||||
return new OrganizationsViewHolder(v);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull OrganizationsViewHolder holder, int position) {
|
||||
|
||||
UserOrganizations currentItem = orgList.get(position);
|
||||
holder.mTextView2.setVisibility(View.GONE);
|
||||
holder.organizationId.setText(Integer.toString(currentItem.getId()));
|
||||
|
||||
Picasso.get().load(currentItem.getAvatar_url()).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image);
|
||||
holder.mTextView1.setText(currentItem.getUsername());
|
||||
|
||||
@@ -9,7 +9,7 @@ import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.TextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.OrgTeamMembersActivity;
|
||||
import org.mian.gitnex.activities.OrganizationTeamMembersActivity;
|
||||
import org.mian.gitnex.models.Teams;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -46,7 +46,7 @@ public class TeamsByOrgAdapter extends RecyclerView.Adapter<TeamsByOrgAdapter.Or
|
||||
|
||||
Context context = v.getContext();
|
||||
|
||||
Intent intent = new Intent(context, OrgTeamMembersActivity.class);
|
||||
Intent intent = new Intent(context, OrganizationTeamMembersActivity.class);
|
||||
intent.putExtra("teamTitle", teamTitle.getText().toString());
|
||||
intent.putExtra("teamId", teamId.getText().toString());
|
||||
context.startActivity(intent);
|
||||
|
||||
@@ -25,6 +25,7 @@ public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
|
||||
View v = inflater.inflate(R.layout.bottom_sheet_organization_layout, container, false);
|
||||
|
||||
TextView createTeam = v.findViewById(R.id.createTeam);
|
||||
TextView createRepository = v.findViewById(R.id.createRepository);
|
||||
|
||||
createTeam.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -34,6 +35,14 @@ public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
|
||||
}
|
||||
});
|
||||
|
||||
createRepository.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
bmListener.onButtonClicked("repository");
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.NewRepoActivity;
|
||||
import org.mian.gitnex.activities.CreateRepoActivity;
|
||||
import org.mian.gitnex.adapters.MyReposListAdapter;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
@@ -110,7 +110,7 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(view.getContext(), NewRepoActivity.class);
|
||||
Intent intent = new Intent(view.getContext(), CreateRepoActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.NewOrganizationActivity;
|
||||
import org.mian.gitnex.activities.CreateOrganizationActivity;
|
||||
import org.mian.gitnex.adapters.OrganizationsListAdapter;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
@@ -77,7 +77,7 @@ public class OrganizationsFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(view.getContext(), NewOrganizationActivity.class);
|
||||
Intent intent = new Intent(view.getContext(), CreateOrganizationActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.NewRepoActivity;
|
||||
import org.mian.gitnex.activities.CreateRepoActivity;
|
||||
import org.mian.gitnex.adapters.ReposListAdapter;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
@@ -79,7 +79,7 @@ public class RepositoriesFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(view.getContext(), NewRepoActivity.class);
|
||||
Intent intent = new Intent(view.getContext(), CreateRepoActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.NewRepoActivity;
|
||||
import org.mian.gitnex.activities.CreateRepoActivity;
|
||||
import org.mian.gitnex.adapters.StarredReposListAdapter;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
@@ -104,7 +104,7 @@ public class StarredRepositoriesFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(view.getContext(), NewRepoActivity.class);
|
||||
Intent intent = new Intent(view.getContext(), CreateRepoActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ package org.mian.gitnex.models;
|
||||
|
||||
public class OrgOwner {
|
||||
|
||||
private int id;
|
||||
private String username;
|
||||
|
||||
public OrgOwner(String username) {
|
||||
@@ -16,6 +17,10 @@ public class OrgOwner {
|
||||
return username;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return username;
|
||||
|
||||
@@ -6,6 +6,7 @@ package org.mian.gitnex.models;
|
||||
|
||||
public class UserOrganizations {
|
||||
|
||||
private int id;
|
||||
private String username;
|
||||
private String avatar_url;
|
||||
private String description;
|
||||
@@ -20,6 +21,10 @@ public class UserOrganizations {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user