Fixing layout issues and crashes. (#810)

Fixing layout issues and crashes.

Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/810
Reviewed-by: M M Arif <mmarif@noreply.codeberg.org>
Co-Authored-By: opyale <opyale@noreply.codeberg.org>
Co-Committed-By: opyale <opyale@noreply.codeberg.org>
This commit is contained in:
opyale 2021-01-26 18:43:25 +01:00 committed by M M Arif
parent a26737e510
commit 093204df43
43 changed files with 89 additions and 285 deletions

View File

@ -13,7 +13,6 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.mian.gitnex.R;
import org.mian.gitnex.adapters.UserSearchAdapter;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.databinding.ActivityAddCollaboratorToRepositoryBinding;
@ -38,17 +37,13 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
private RecyclerView mRecyclerView;
@Override
protected int getLayoutResourceId(){
return R.layout.activity_add_collaborator_to_repository;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityAddCollaboratorToRepositoryBinding activityAddCollaboratorToRepositoryBinding = ActivityAddCollaboratorToRepositoryBinding.inflate(getLayoutInflater());
setContentView(activityAddCollaboratorToRepositoryBinding.getRoot());
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

View File

@ -36,20 +36,13 @@ public class AddNewAccountActivity extends BaseActivity {
private enum Protocol {HTTPS, HTTP}
private String spinnerSelectedValue;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_add_new_account;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
viewBinding = ActivityAddNewAccountBinding.inflate(getLayoutInflater());
View view = viewBinding.getRoot();
setContentView(view);
setContentView(viewBinding.getRoot());
getWindow().getDecorView().setBackground(new ColorDrawable(Color.TRANSPARENT));

View File

@ -14,7 +14,6 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.mian.gitnex.R;
import org.mian.gitnex.adapters.UserSearchForTeamMemberAdapter;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.databinding.ActivityAddNewTeamMemberBinding;
@ -45,17 +44,13 @@ public class AddNewTeamMemberActivity extends BaseActivity {
private String teamId;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_add_new_team_member;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityAddNewTeamMemberBinding activityAddNewTeamMemberBinding = ActivityAddNewTeamMemberBinding.inflate(getLayoutInflater());
setContentView(activityAddNewTeamMemberBinding.getRoot());
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

View File

@ -39,17 +39,13 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
private TextView noDataUsers;
private Boolean searchFilter = false;
@Override
protected int getLayoutResourceId(){
return R.layout.activity_admin_get_users;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityAdminGetUsersBinding activityAdminGetUsersBinding = ActivityAdminGetUsersBinding.inflate(getLayoutInflater());
setContentView(activityAdminGetUsersBinding.getRoot());
ImageView closeActivity = activityAdminGetUsersBinding.close;
noDataUsers = activityAdminGetUsersBinding.noDataUsers;

View File

@ -100,7 +100,6 @@ public abstract class BaseActivity extends AppCompatActivity {
AppUtil.setAppLocale(getResources(), appLocale);
super.onCreate(savedInstanceState);
setContentView(getLayoutResourceId());
// FIXME Performance nightmare
switch(tinyDB.getInt("customFontId", -1)) {
@ -177,8 +176,6 @@ public abstract class BaseActivity extends AppCompatActivity {
}
}
protected abstract int getLayoutResourceId();
}

View File

@ -51,18 +51,13 @@ public class CommitsActivity extends BaseActivity {
private CommitsAdapter adapter;
private ProgressBar progressLoadMore;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_commits;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityCommitsBinding activityCommitsBinding = ActivityCommitsBinding.inflate(getLayoutInflater());
setContentView(activityCommitsBinding.getRoot());
Toolbar toolbar = activityCommitsBinding.toolbar;
setSupportActionBar(toolbar);

View File

@ -59,11 +59,6 @@ public class CreateFileActivity extends BaseActivity {
private String selectedBranch;
@Override
protected int getLayoutResourceId(){
return R.layout.activity_create_file;
}
@SuppressLint("ClickableViewAccessibility")
@Override
public void onCreate(Bundle savedInstanceState) {
@ -71,6 +66,7 @@ public class CreateFileActivity extends BaseActivity {
super.onCreate(savedInstanceState);
ActivityCreateFileBinding activityCreateFileBinding = ActivityCreateFileBinding.inflate(getLayoutInflater());
setContentView(activityCreateFileBinding.getRoot());
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);

View File

@ -71,11 +71,6 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
private List<Collaborators> assigneesList = new ArrayList<>();
private List<String> assigneesListData = new ArrayList<>();
@Override
protected int getLayoutResourceId() {
return R.layout.activity_create_issue;
}
@SuppressLint("ClickableViewAccessibility")
@Override
public void onCreate(Bundle savedInstanceState) {
@ -83,8 +78,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
super.onCreate(savedInstanceState);
viewBinding = ActivityCreateIssueBinding.inflate(getLayoutInflater());
View view = viewBinding.getRoot();
setContentView(view);
setContentView(viewBinding.getRoot());
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);

View File

@ -41,17 +41,13 @@ public class CreateLabelActivity extends BaseActivity {
private Button createLabelButton;
private TinyDB tinyDB;
@Override
protected int getLayoutResourceId(){
return R.layout.activity_create_label;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityCreateLabelBinding activityCreateLabelBinding = ActivityCreateLabelBinding.inflate(getLayoutInflater());
setContentView(activityCreateLabelBinding.getRoot());
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

View File

@ -38,11 +38,6 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
private EditText milestoneDescription;
private Button createNewMilestoneButton;
@Override
protected int getLayoutResourceId(){
return R.layout.activity_create_milestone;
}
@SuppressLint("ClickableViewAccessibility")
@Override
public void onCreate(Bundle savedInstanceState) {
@ -50,6 +45,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
super.onCreate(savedInstanceState);
ActivityCreateMilestoneBinding activityCreateMilestoneBinding = ActivityCreateMilestoneBinding.inflate(getLayoutInflater());
setContentView(activityCreateMilestoneBinding.getRoot());
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);

View File

@ -35,17 +35,13 @@ public class CreateNewUserActivity extends BaseActivity {
private EditText userPassword;
private Button createUserButton;
@Override
protected int getLayoutResourceId(){
return R.layout.activity_create_new_user;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityCreateNewUserBinding activityCreateNewUserBinding = ActivityCreateNewUserBinding.inflate(getLayoutInflater());
setContentView(activityCreateNewUserBinding.getRoot());
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);

View File

@ -36,11 +36,6 @@ public class CreateOrganizationActivity extends BaseActivity {
private EditText orgName;
private EditText orgDesc;
@Override
protected int getLayoutResourceId(){
return R.layout.activity_create_organization;
}
@SuppressLint("ClickableViewAccessibility")
@Override
public void onCreate(Bundle savedInstanceState) {
@ -48,6 +43,7 @@ public class CreateOrganizationActivity extends BaseActivity {
super.onCreate(savedInstanceState);
ActivityCreateOrganizationBinding activityCreateOrganizationBinding = ActivityCreateOrganizationBinding.inflate(getLayoutInflater());
setContentView(activityCreateOrganizationBinding.getRoot());
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);

View File

@ -61,14 +61,6 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
List<Branches> branchesList = new ArrayList<>();
List<Labels> labelsList = new ArrayList<>();
public CreatePullRequestActivity() {
}
@Override
protected int getLayoutResourceId(){
return R.layout.activity_create_pr;
}
@SuppressLint("ClickableViewAccessibility")
@Override
public void onCreate(Bundle savedInstanceState) {
@ -76,8 +68,7 @@ public class CreatePullRequestActivity extends BaseActivity implements LabelsLis
super.onCreate(savedInstanceState);
viewBinding = ActivityCreatePrBinding.inflate(getLayoutInflater());
View view = viewBinding.getRoot();
setContentView(view);
setContentView(viewBinding.getRoot());
loginUid = tinyDB.getString("loginUid");
String repoFullName = tinyDB.getString("repoFullName");

View File

@ -50,11 +50,6 @@ public class CreateReleaseActivity extends BaseActivity {
List<Branches> branchesList = new ArrayList<>();
@Override
protected int getLayoutResourceId(){
return R.layout.activity_create_release;
}
@SuppressLint("ClickableViewAccessibility")
@Override
public void onCreate(Bundle savedInstanceState) {
@ -62,6 +57,7 @@ public class CreateReleaseActivity extends BaseActivity {
super.onCreate(savedInstanceState);
ActivityCreateReleaseBinding activityCreateReleaseBinding = ActivityCreateReleaseBinding.inflate(getLayoutInflater());
setContentView(activityCreateReleaseBinding.getRoot());
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);

View File

@ -56,17 +56,13 @@ public class CreateRepoActivity extends BaseActivity {
final List<String> reservedRepoNames = Arrays.asList(".", "..");
final Pattern reservedRepoPatterns = Pattern.compile("\\.(git|wiki)$");
@Override
protected int getLayoutResourceId(){
return R.layout.activity_create_repo;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityCreateRepoBinding activityCreateRepoBinding = ActivityCreateRepoBinding.inflate(getLayoutInflater());
setContentView(activityCreateRepoBinding.getRoot());
boolean connToInternet = AppUtil.hasNetworkConnection(ctx);

View File

@ -44,11 +44,6 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
private final String[] permissionList = {"Read", "Write", "Admin"};
public int permissionSelectedChoice = -1;
@Override
protected int getLayoutResourceId(){
return R.layout.activity_create_team_by_org;
}
private final String[] accessControlsList = new String[] {
"Code",
"Issues",
@ -77,6 +72,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
super.onCreate(savedInstanceState);
ActivityCreateTeamByOrgBinding activityCreateTeamByOrgBinding = ActivityCreateTeamByOrgBinding.inflate(getLayoutInflater());
setContentView(activityCreateTeamByOrgBinding.getRoot());
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);

View File

@ -41,20 +41,13 @@ public class DeepLinksActivity extends BaseActivity {
private Intent issueIntent;
private Intent repoIntent;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_deeplinks;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
viewBinding = ActivityDeeplinksBinding.inflate(getLayoutInflater());
View view = viewBinding.getRoot();
setContentView(view);
setContentView(viewBinding.getRoot());
mainIntent = new Intent(ctx, MainActivity.class);
issueIntent = new Intent(ctx, IssueDetailActivity.class);

View File

@ -64,11 +64,6 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
private String repoName;
private int issueIndex;
@Override
protected int getLayoutResourceId(){
return R.layout.activity_edit_issue;
}
@SuppressLint("ClickableViewAccessibility")
@Override
public void onCreate(Bundle savedInstanceState) {
@ -76,6 +71,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
super.onCreate(savedInstanceState);
ActivityEditIssueBinding activityEditIssueBinding = ActivityEditIssueBinding.inflate(getLayoutInflater());
setContentView(activityEditIssueBinding.getRoot());
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

View File

@ -36,18 +36,13 @@ public class FileDiffActivity extends BaseActivity {
private ListView mListView;
private ProgressBar mProgressBar;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_file_diff;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityFileDiffBinding activityFileDiffBinding = ActivityFileDiffBinding.inflate(getLayoutInflater());
setContentView(activityFileDiffBinding.getRoot());
Toolbar toolbar = activityFileDiffBinding.toolbar;
setSupportActionBar(toolbar);

View File

@ -71,12 +71,6 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
private String fileSha;
private AppUtil appUtil;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_file_view;
}
@Override
public void onCreate(Bundle savedInstanceState) {
@ -84,6 +78,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
appUtil = new AppUtil();
ActivityFileViewBinding activityFileViewBinding = ActivityFileViewBinding.inflate(getLayoutInflater());
setContentView(activityFileViewBinding.getRoot());
Toolbar toolbar = activityFileViewBinding.toolbar;
setSupportActionBar(toolbar);

View File

@ -102,20 +102,13 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
private CustomAssigneesSelectionDialogBinding assigneesBinding;
private ActivityIssueDetailBinding viewBinding;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_issue_detail;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
viewBinding = ActivityIssueDetailBinding.inflate(getLayoutInflater());
View view = viewBinding.getRoot();
setContentView(view);
setContentView(viewBinding.getRoot());
String repoFullName = tinyDB.getString("repoFullName");
String[] parts = repoFullName.split("/");

View File

@ -53,18 +53,13 @@ public class LoginActivity extends BaseActivity {
private String device_id = "token";
private String selectedProtocol;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_login;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityLoginBinding activityLoginBinding = ActivityLoginBinding.inflate(getLayoutInflater());
setContentView(activityLoginBinding.getRoot());
NetworkStatusObserver networkStatusObserver = NetworkStatusObserver.get(ctx);

View File

@ -85,18 +85,13 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
private MenuItem navNotifications;
private TextView notificationCounter;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_main;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMainBinding activityMainBinding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(activityMainBinding.getRoot());
tinyDB.putBoolean("noConnection", false);

View File

@ -41,12 +41,6 @@ public class MergePullRequestActivity extends BaseActivity {
private String Do;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_merge_pull_request;
}
@SuppressLint("SetTextI18n")
@Override
public void onCreate(Bundle savedInstanceState) {
@ -54,8 +48,7 @@ public class MergePullRequestActivity extends BaseActivity {
super.onCreate(savedInstanceState);
viewBinding = ActivityMergePullRequestBinding.inflate(getLayoutInflater());
View view = viewBinding.getRoot();
setContentView(view);
setContentView(viewBinding.getRoot());
String repoFullName = tinyDB.getString("repoFullName");
String[] parts = repoFullName.split("/");

View File

@ -20,7 +20,6 @@ import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.google.android.material.tabs.TabLayout;
import org.mian.gitnex.R;
import org.mian.gitnex.databinding.ActivityOrgDetailBinding;
import org.mian.gitnex.fragments.BottomSheetOrganizationFragment;
import org.mian.gitnex.fragments.MembersByOrgFragment;
import org.mian.gitnex.fragments.OrganizationInfoFragment;
@ -37,22 +36,17 @@ import io.mikael.urlbuilder.UrlBuilder;
public class OrganizationDetailActivity extends BaseActivity implements BottomSheetOrganizationFragment.BottomSheetListener {
@Override
protected int getLayoutResourceId(){
return R.layout.activity_org_detail;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityOrgDetailBinding activityOrgDetailBinding = ActivityOrgDetailBinding.inflate(getLayoutInflater());
setContentView(R.layout.activity_org_detail);
String orgName = tinyDB.getString("orgName");
Toolbar toolbar = activityOrgDetailBinding.toolbar;
TextView toolbarTitle = activityOrgDetailBinding.toolbarTitle;
Toolbar toolbar = findViewById(R.id.toolbar);
TextView toolbarTitle = findViewById(R.id.toolbar_title);
setSupportActionBar(toolbar);
Objects.requireNonNull(getSupportActionBar()).setTitle(orgName);
@ -60,10 +54,10 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
OrganizationDetailActivity.SectionsPagerAdapter mSectionsPagerAdapter = new OrganizationDetailActivity.SectionsPagerAdapter(getSupportFragmentManager());
ViewPager mViewPager = activityOrgDetailBinding.container;
ViewPager mViewPager = findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = activityOrgDetailBinding.tabs;
TabLayout tabLayout = findViewById(R.id.tabs);
Typeface myTypeface;

View File

@ -35,17 +35,13 @@ public class OrganizationTeamMembersActivity extends BaseActivity implements Bot
private String teamId;
@Override
protected int getLayoutResourceId(){
return R.layout.activity_org_team_members;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityOrgTeamMembersBinding activityOrgTeamMembersBinding = ActivityOrgTeamMembersBinding.inflate(getLayoutInflater());
setContentView(activityOrgTeamMembersBinding.getRoot());
Toolbar toolbar = activityOrgTeamMembersBinding.toolbar;
setSupportActionBar(toolbar);

View File

@ -36,17 +36,13 @@ public class ProfileEmailActivity extends BaseActivity {
private EditText userEmail;
private Button addEmailButton;
@Override
protected int getLayoutResourceId(){
return R.layout.activity_profile_email;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityProfileEmailBinding activityProfileEmailBinding = ActivityProfileEmailBinding.inflate(getLayoutInflater());
setContentView(activityProfileEmailBinding.getRoot());
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);

View File

@ -29,7 +29,6 @@ import com.google.android.material.tabs.TabLayout;
import com.google.gson.JsonElement;
import org.mian.gitnex.R;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.databinding.ActivityRepoDetailBinding;
import org.mian.gitnex.fragments.BottomSheetIssuesFilterFragment;
import org.mian.gitnex.fragments.BottomSheetMilestonesFilterFragment;
import org.mian.gitnex.fragments.BottomSheetPullRequestFilterFragment;
@ -80,26 +79,20 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
public static ViewPager mViewPager;
private int tabsCount;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_repo_detail;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityRepoDetailBinding activityRepoDetailBinding = ActivityRepoDetailBinding.inflate(getLayoutInflater());
setContentView(R.layout.activity_repo_detail);
String[] repoNameParts = tinyDB.getString("repoFullName").split("/");
repositoryOwner = repoNameParts[0];
repositoryName = repoNameParts[1];
Toolbar toolbar = activityRepoDetailBinding.toolbar;
Toolbar toolbar = findViewById(R.id.toolbar);
TextView toolbarTitle = activityRepoDetailBinding.toolbarTitle;
TextView toolbarTitle = findViewById(R.id.toolbar_title);
toolbarTitle.setText(repositoryName);
setSupportActionBar(toolbar);
@ -133,7 +126,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
toolbarTitle.setTypeface(myTypeface);
TabLayout tabLayout = activityRepoDetailBinding.tabs;
TabLayout tabLayout = findViewById(R.id.tabs);
ViewGroup viewGroup = (ViewGroup) tabLayout.getChildAt(0);
tabsCount = viewGroup.getChildCount();
@ -167,7 +160,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
collaboratorTab.setVisibility(View.GONE);
}
mViewPager = activityRepoDetailBinding.container;
mViewPager = findViewById(R.id.container);
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));

View File

@ -54,12 +54,6 @@ public class RepoForksActivity extends BaseActivity {
private RepoForksAdapter adapter;
private ProgressBar progressLoadMore;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_repo_forks;
}
@SuppressLint("DefaultLocale")
@Override
public void onCreate(Bundle savedInstanceState) {
@ -67,6 +61,7 @@ public class RepoForksActivity extends BaseActivity {
super.onCreate(savedInstanceState);
ActivityRepoForksBinding activityRepoForksBinding = ActivityRepoForksBinding.inflate(getLayoutInflater());
setContentView(activityRepoForksBinding.getRoot());
Toolbar toolbar = activityRepoForksBinding.toolbar;
setSupportActionBar(toolbar);

View File

@ -25,15 +25,11 @@ public class RepoStargazersActivity extends BaseActivity {
private GridView mGridView;
private ProgressBar mProgressBar;
@Override
protected int getLayoutResourceId(){
return R.layout.activity_repo_stargazers;
}
@Override
public void onCreate(Bundle savedInstanceState) {
ActivityRepoStargazersBinding activityRepoStargazersBinding = ActivityRepoStargazersBinding.inflate(getLayoutInflater());
setContentView(activityRepoStargazersBinding.getRoot());
super.onCreate(savedInstanceState);

View File

@ -25,17 +25,13 @@ public class RepoWatchersActivity extends BaseActivity {
private GridView mGridView;
private ProgressBar mProgressBar;
@Override
protected int getLayoutResourceId(){
return R.layout.activity_repo_watchers;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityRepoWatchersBinding activityRepoWatchersBinding = ActivityRepoWatchersBinding.inflate(getLayoutInflater());
setContentView(activityRepoWatchersBinding.getRoot());
ImageView closeActivity = activityRepoWatchersBinding.close;
TextView toolbarTitle = activityRepoWatchersBinding.toolbarTitle;

View File

@ -45,19 +45,13 @@ public class RepositorySettingsActivity extends BaseActivity {
private String repositoryOwner;
private String repositoryName;
@Override
protected int getLayoutResourceId(){
return R.layout.activity_repository_settings;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
viewBinding = ActivityRepositorySettingsBinding.inflate(getLayoutInflater());
View view = viewBinding.getRoot();
setContentView(view);
setContentView(viewBinding.getRoot());
loginUid = tinyDB.getString("loginUid");
String repoFullName = tinyDB.getString("repoFullName");

View File

@ -28,18 +28,13 @@ public class SettingsAppearanceActivity extends BaseActivity {
private static final String[] themeList = {"Dark", "Light", "Auto (Light / Dark)", "Retro", "Auto (Retro / Dark)", "Pitch Black"};
private static int themeSelectedChoice = 0;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_settings_appearance;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivitySettingsAppearanceBinding activitySettingsAppearanceBinding = ActivitySettingsAppearanceBinding.inflate(getLayoutInflater());
setContentView(activitySettingsAppearanceBinding.getRoot());
ImageView closeActivity = activitySettingsAppearanceBinding.close;

View File

@ -15,18 +15,13 @@ public class SettingsDraftsActivity extends BaseActivity {
private View.OnClickListener onClickListener;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_settings_drafts;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivitySettingsDraftsBinding activitySettingsDraftsBinding = ActivitySettingsDraftsBinding.inflate(getLayoutInflater());
setContentView(activitySettingsDraftsBinding.getRoot());
ImageView closeActivity = activitySettingsDraftsBinding.close;

View File

@ -22,18 +22,13 @@ public class SettingsFileViewerActivity extends BaseActivity {
private static final String[] fileViewerSourceCodeThemesList = {"Sublime", "Arduino Light", "Github", "Far ", "Ir Black", "Android Studio"};
private static int fileViewerSourceCodeThemesSelectedChoice = 0;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_settings_fileviewer;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivitySettingsFileviewerBinding activitySettingsFileviewerBinding = ActivitySettingsFileviewerBinding.inflate(getLayoutInflater());
setContentView(activitySettingsFileviewerBinding.getRoot());
ImageView closeActivity = activitySettingsFileviewerBinding.close;

View File

@ -26,20 +26,13 @@ public class SettingsGeneralActivity extends BaseActivity {
private List<String> defaultScreen;
private static int defaultLinkHandlerScreenSelectedChoice = 0;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_settings_general;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
viewBinding = ActivitySettingsGeneralBinding.inflate(getLayoutInflater());
View view = viewBinding.getRoot();
setContentView(view);
setContentView(viewBinding.getRoot());
initCloseListener();
viewBinding.close.setOnClickListener(onClickListener);

View File

@ -21,20 +21,13 @@ public class SettingsNotificationsActivity extends BaseActivity {
private ActivitySettingsNotificationsBinding viewBinding;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_settings_notifications;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
viewBinding = ActivitySettingsNotificationsBinding.inflate(getLayoutInflater());
View view = viewBinding.getRoot();
setContentView(view);
setContentView(viewBinding.getRoot());
View.OnClickListener onClickListener = viewClose -> finish();

View File

@ -15,18 +15,13 @@ public class SettingsReportsActivity extends BaseActivity {
private View.OnClickListener onClickListener;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_settings_reports;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivitySettingsReportsBinding activitySettingsReportsBinding = ActivitySettingsReportsBinding.inflate(getLayoutInflater());
setContentView(activitySettingsReportsBinding.getRoot());
ImageView closeActivity = activitySettingsReportsBinding.close;

View File

@ -31,18 +31,13 @@ public class SettingsSecurityActivity extends BaseActivity {
private static final String[] cacheSizeImagesList = {"50 MB", "100 MB", "250 MB", "500 MB", "1 GB"};
private static int cacheSizeImagesSelectedChoice = 0;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_settings_security;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivitySettingsSecurityBinding activitySettingsSecurityBinding = ActivitySettingsSecurityBinding.inflate(getLayoutInflater());
setContentView(activitySettingsSecurityBinding.getRoot());
ImageView closeActivity = activitySettingsSecurityBinding.close;

View File

@ -24,18 +24,13 @@ public class SettingsTranslationActivity extends BaseActivity {
"Polish", "Portuguese/Brazilian", "Russian", "Serbian", "Spanish", "Turkish", "Ukrainian"};
private static int langSelectedChoice = 0;
@Override
protected int getLayoutResourceId() {
return R.layout.activity_settings_translation;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivitySettingsTranslationBinding activitySettingsTranslationBinding = ActivitySettingsTranslationBinding.inflate(getLayoutInflater());
setContentView(activitySettingsTranslationBinding.getRoot());
ImageView closeActivity = activitySettingsTranslationBinding.close;

View File

@ -16,7 +16,6 @@ import androidx.viewpager.widget.ViewPager;
import com.google.android.material.tabs.TabLayout;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.MainActivity;
import org.mian.gitnex.databinding.FragmentExploreBinding;
import org.mian.gitnex.helpers.TinyDB;
/**
@ -35,14 +34,14 @@ public class ExploreFragment extends Fragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
FragmentExploreBinding fragmentExploreBinding = FragmentExploreBinding.inflate(inflater, container, false);
View view = inflater.inflate(R.layout.fragment_explore, container, false);
ctx = getContext();
tinyDB = TinyDB.getInstance(ctx);
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.navExplore));
TabLayout tabLayout = fragmentExploreBinding.tabsExplore;
TabLayout tabLayout = view.findViewById(R.id.tabsExplore);
ViewGroup viewGroup = (ViewGroup) tabLayout.getChildAt(0);
tabsCount = viewGroup.getChildCount();
@ -80,7 +79,7 @@ public class ExploreFragment extends Fragment {
}
}
mViewPager = fragmentExploreBinding.containerExplore;
mViewPager = view.findViewById(R.id.containerExplore);
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
@ -88,7 +87,8 @@ public class ExploreFragment extends Fragment {
SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager());
mViewPager.setAdapter(mSectionsPagerAdapter);
return fragmentExploreBinding.getRoot();
return view;
}
public class SectionsPagerAdapter extends FragmentPagerAdapter {

View File

@ -10,6 +10,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -23,11 +24,11 @@ import com.squareup.picasso.Callback;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.MainActivity;
import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.databinding.FragmentProfileBinding;
import org.mian.gitnex.helpers.ColorInverter;
import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TinyDB;
import java.util.Locale;
import eightbitlab.com.blurview.BlurView;
import eightbitlab.com.blurview.RenderScriptBlur;
/**
@ -44,55 +45,63 @@ public class ProfileFragment extends Fragment {
ctx = getContext();
FragmentProfileBinding fragmentProfileBinding = FragmentProfileBinding.inflate(inflater, container, false);
View v = inflater.inflate(R.layout.fragment_profile, container, false);
setHasOptionsMenu(true);
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.navProfile));
TinyDB tinyDb = TinyDB.getInstance(getContext());
ViewGroup aboutFrame = fragmentProfileBinding.aboutFrame;
BlurView blurView = v.findViewById(R.id.blurView);
TextView userFullName = v.findViewById(R.id.userFullName);
ImageView userAvatarBackground = v.findViewById(R.id.userAvatarBackground);
ImageView userAvatar = v.findViewById(R.id.userAvatar);
TextView userLogin = v.findViewById(R.id.userLogin);
View divider = v.findViewById(R.id.divider);
TextView userLanguage = v.findViewById(R.id.userLanguage);
ImageView userLanguageIcon = v.findViewById(R.id.userLanguageIcon);
ViewGroup aboutFrame = v.findViewById(R.id.aboutFrame);
String[] userLanguageCodes = tinyDb.getString("userLang").split("-");
if(userLanguageCodes.length >= 2) {
Locale locale = new Locale(userLanguageCodes[0], userLanguageCodes[1]);
fragmentProfileBinding.userLanguage.setText(locale.getDisplayLanguage());
userLanguage.setText(locale.getDisplayLanguage());
}
else {
fragmentProfileBinding.userLanguage.setText(R.string.notSupported);
userLanguage.setText(R.string.notSupported);
}
fragmentProfileBinding.userFullName.setText(tinyDb.getString("userFullname"));
fragmentProfileBinding.userLogin.setText(getString(R.string.usernameWithAt, tinyDb.getString("userLogin")));
userFullName.setText(tinyDb.getString("userFullname"));
userLogin.setText(getString(R.string.usernameWithAt, tinyDb.getString("userLogin")));
PicassoService.getInstance(ctx).get()
.load(tinyDb.getString("userAvatar"))
.transform(new RoundedTransformation(8, 0))
.placeholder(R.drawable.loader_animated)
.resize(120, 120)
.centerCrop().into(fragmentProfileBinding.userAvatar);
.centerCrop().into(userAvatar);
PicassoService.getInstance(ctx).get()
.load(tinyDb.getString("userAvatar"))
.into(fragmentProfileBinding.userAvatarBackground, new Callback() {
.into(userAvatarBackground, new Callback() {
@Override
public void onSuccess() {
int invertedColor = new ColorInverter().getImageViewContrastColor(fragmentProfileBinding.userAvatarBackground);
int invertedColor = new ColorInverter().getImageViewContrastColor(userAvatarBackground);
fragmentProfileBinding.userFullName.setTextColor(invertedColor);
fragmentProfileBinding.divider.setBackgroundColor(invertedColor);
fragmentProfileBinding.userLogin.setTextColor(invertedColor);
fragmentProfileBinding.userLanguage.setTextColor(invertedColor);
userFullName.setTextColor(invertedColor);
divider.setBackgroundColor(invertedColor);
userLogin.setTextColor(invertedColor);
userLanguage.setTextColor(invertedColor);
ImageViewCompat.setImageTintList(fragmentProfileBinding.userLanguageIcon, ColorStateList.valueOf(invertedColor));
ImageViewCompat.setImageTintList(userLanguageIcon, ColorStateList.valueOf(invertedColor));
fragmentProfileBinding.blurView.setupWith(aboutFrame)
blurView.setupWith(aboutFrame)
.setBlurAlgorithm(new RenderScriptBlur(ctx))
.setBlurRadius(3)
.setHasFixedTransformationMatrix(true);
@ -107,7 +116,7 @@ public class ProfileFragment extends Fragment {
ProfileFragment.SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager());
ViewPager mViewPager = fragmentProfileBinding.container;
ViewPager mViewPager = v.findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
Typeface myTypeface;
@ -128,7 +137,7 @@ public class ProfileFragment extends Fragment {
}
TabLayout tabLayout = fragmentProfileBinding.tabs;
TabLayout tabLayout = v.findViewById(R.id.tabs);
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
int tabsCount = vg.getChildCount();
@ -151,7 +160,7 @@ public class ProfileFragment extends Fragment {
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
return fragmentProfileBinding.getRoot();
return v;
}

View File

@ -45,49 +45,49 @@
android:layout_height="wrap_content">
<com.google.android.material.tabs.TabItem
android:id="@+id/tabItem1_info"
android:id="@+id/tab_item_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tab_text_info" />
<com.google.android.material.tabs.TabItem
android:id="@+id/tabItemFiles"
android:id="@+id/tab_item_files"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tab_text_files" />
<com.google.android.material.tabs.TabItem
android:id="@+id/tabItem2_issues"
android:id="@+id/tab_item_issues"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pageTitleIssues" />
<com.google.android.material.tabs.TabItem
android:id="@+id/tabItemPullRequests"
android:id="@+id/tab_item_pull_requests"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tabPullRequests" />
<com.google.android.material.tabs.TabItem
android:id="@+id/tabItem6_releases"
android:id="@+id/tab_item_releases"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tab_text_releases" />
<com.google.android.material.tabs.TabItem
android:id="@+id/tabItem3_ml"
android:id="@+id/tab_item_ml"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tab_text_ml" />
<com.google.android.material.tabs.TabItem
android:id="@+id/tabItem4_labels"
android:id="@+id/tab_item_labels"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tab_text_labels" />
<com.google.android.material.tabs.TabItem
android:id="@+id/tabItem7_collaborators"
android:id="@+id/tab_item_collaborators"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tab_text_collaborators" />