Refactoring LoginActivity and other improvements. (#561)
Adding error message for login(). Final touch. Refactoring LoginActivity and other improvements. Co-authored-by: opyale <opyale@noreply.gitea.io> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/561 Reviewed-by: 6543 <6543@noreply.codeberg.org>
This commit is contained in:
parent
95fc5e1e9a
commit
815417bf11
@ -20,3 +20,7 @@ indent_size = 2
|
||||
|
||||
[{*.yml,*.yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = false
|
||||
|
3
.idea/codeStyles/Project.xml
generated
3
.idea/codeStyles/Project.xml
generated
@ -36,6 +36,7 @@
|
||||
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_SYNCHRONIZED_PARENTHESES" value="false" />
|
||||
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
|
||||
<option name="IF_BRACE_FORCE" value="3" />
|
||||
<option name="WRAP_ON_TYPING" value="1" />
|
||||
<indentOptions>
|
||||
@ -156,4 +157,4 @@
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
</component>
|
@ -36,7 +36,7 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def lifecycle_version = "2.2.0"
|
||||
def lifecycle_version = "2.3.0-alpha05"
|
||||
def markwon_version = '4.3.1'
|
||||
def acra = "5.5.0"
|
||||
|
||||
@ -77,7 +77,7 @@ dependencies {
|
||||
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.19"
|
||||
implementation "com.hendraanggrian.appcompat:socialview:0.2"
|
||||
implementation "com.hendraanggrian.appcompat:socialview-commons:0.2"
|
||||
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
|
||||
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" // Deprecated (https://developer.android.com/jetpack/androidx/releases/lifecycle)
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
|
||||
implementation "com.github.HamidrezaAmz:BreadcrumbsView:0.2.9"
|
||||
implementation "commons-io:commons-io:20030203.000550"
|
||||
|
@ -28,7 +28,6 @@ import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.AdminGetUsersViewModel;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -132,7 +131,7 @@ public class AdminGetUsersActivity extends BaseActivity implements BottomSheetAd
|
||||
public void run() {
|
||||
if(searchFilter) {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -146,7 +146,7 @@ public class CreateFileActivity extends BaseActivity {
|
||||
|
||||
private void processNewFile() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
|
@ -82,7 +82,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -153,7 +153,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
|
||||
private void processNewIssue() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
|
@ -73,7 +73,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
colorPicker = findViewById(R.id.colorPicker);
|
||||
@ -154,7 +154,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
private void processUpdateLabel() {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String[] parts = repoFullName.split("/");
|
||||
@ -202,7 +202,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
private void processCreateLabel() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
@ -446,4 +446,4 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -92,7 +92,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
private void processNewMilestone() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
|
@ -48,7 +48,7 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -80,7 +80,7 @@ public class CreateNewUserActivity extends BaseActivity {
|
||||
|
||||
private void processCreateNewUser() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
|
@ -47,7 +47,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -97,7 +97,7 @@ public class CreateOrganizationActivity extends BaseActivity {
|
||||
|
||||
private void processNewOrganization() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
|
@ -60,7 +60,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -125,7 +125,7 @@ public class CreateReleaseActivity extends BaseActivity {
|
||||
|
||||
private void processNewRelease() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
|
@ -64,7 +64,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(ctx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
@ -124,7 +124,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
|
||||
private void processNewRepo() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
AppUtil appUtil = new AppUtil();
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
|
@ -78,7 +78,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -256,7 +256,7 @@ public class CreateTeamByOrgActivity extends BaseActivity implements View.OnClic
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final String orgName = tinyDb.getString("orgName");;
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
String newTeamName = teamName.getText().toString();
|
||||
String newTeamDesc = teamDesc.getText().toString();
|
||||
String newTeamPermission = teamPermission.getText().toString().toLowerCase();
|
||||
|
@ -196,7 +196,7 @@ public class EditIssueActivity extends BaseActivity implements View.OnClickListe
|
||||
|
||||
private void processEditIssue() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -106,7 +106,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
tinyDb.putInt("homeScreenId", 0);
|
||||
}
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
if(!tinyDb.getBoolean("loggedInMode")) {
|
||||
logout(this, ctx);
|
||||
|
@ -62,7 +62,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
View view = viewBinding.getRoot();
|
||||
setContentView(view);
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
@ -217,7 +217,7 @@ public class MergePullRequestActivity extends BaseActivity {
|
||||
String mergePRTitle = viewBinding.mergeTitle.getText().toString();
|
||||
boolean deleteBranch = viewBinding.deleteBranch.isChecked();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class ProfileEmailActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
appCtx = getApplicationContext();
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@ -84,7 +84,7 @@ public class ProfileEmailActivity extends BaseActivity {
|
||||
|
||||
private void processAddNewEmail() {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
|
@ -58,7 +58,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
addComment = findViewById(R.id.addComment);
|
||||
@ -191,7 +191,7 @@ public class ReplyToIssueActivity extends BaseActivity {
|
||||
private void processNewCommentReply() {
|
||||
|
||||
String newReplyDT = addComment.getText().toString();
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(appCtx);
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(appCtx);
|
||||
|
||||
if(!connToInternet) {
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class AppApiService {
|
||||
public static <S> S createService(Class<S> serviceClass, String instanceURL, Context ctx) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(ctx);
|
||||
final boolean connToInternet = AppUtil.haveNetworkConnection(ctx);
|
||||
final boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
||||
File httpCacheDirectory = new File(ctx.getCacheDir(), "responses");
|
||||
int cacheSize = FilesData.returnOnlyNumber(tinyDb.getString("cacheSizeStr")) * 1024 * 1024;
|
||||
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
||||
|
@ -32,7 +32,7 @@ public class RetrofitClient {
|
||||
private RetrofitClient(String instanceUrl, Context ctx) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(ctx);
|
||||
final boolean connToInternet = AppUtil.haveNetworkConnection(ctx);
|
||||
final boolean connToInternet = AppUtil.hasNetworkConnection(ctx);
|
||||
int cacheSize = FilesData.returnOnlyNumber(tinyDb.getString("cacheSizeStr")) * 1024 * 1024;
|
||||
File httpCacheDirectory = new File(ctx.getCacheDir(), "responses");
|
||||
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
||||
|
@ -104,7 +104,7 @@ public class MembersByOrgFragment extends Fragment {
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
@ -81,7 +81,7 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
|
||||
final View v = inflater.inflate(R.layout.fragment_my_repositories, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
@ -196,7 +196,7 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
@ -52,7 +52,7 @@ public class OrganizationsFragment extends Fragment {
|
||||
final View v = inflater.inflate(R.layout.fragment_organizations, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
@ -158,7 +158,7 @@ public class OrganizationsFragment extends Fragment {
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
@ -152,7 +152,7 @@ public class RepositoriesByOrgFragment extends Fragment {
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
@ -51,7 +51,7 @@ public class RepositoriesFragment extends Fragment {
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
|
||||
final View v = inflater.inflate(R.layout.fragment_repositories, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
@ -161,7 +161,7 @@ public class RepositoriesFragment extends Fragment {
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
@ -78,7 +78,7 @@ public class StarredRepositoriesFragment extends Fragment {
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_starred_repositories, container, false);
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getContext());
|
||||
@ -186,7 +186,7 @@ public class StarredRepositoriesFragment extends Fragment {
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
@ -148,7 +148,7 @@ public class TeamsByOrgFragment extends Fragment {
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
@ -19,28 +19,26 @@ public class AlertDialogs {
|
||||
|
||||
public static void authorizationTokenRevokedDialog(final Context context, String title, String message, String copyNegativeButton, String copyPositiveButton) {
|
||||
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context)
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
.setCancelable(true)
|
||||
.setIcon(R.drawable.ic_warning)
|
||||
.setNegativeButton(copyNegativeButton, (dialog, which) -> dialog.dismiss())
|
||||
.setPositiveButton(copyPositiveButton, (dialog, which) -> {
|
||||
|
||||
alertDialogBuilder
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
.setCancelable(true)
|
||||
.setIcon(R.drawable.ic_warning)
|
||||
.setNegativeButton(copyNegativeButton, (dialog, which) -> dialog.dismiss())
|
||||
.setPositiveButton(copyPositiveButton, (dialog, which) -> {
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putBoolean("loggedInMode", false);
|
||||
tinyDb.remove("basicAuthPassword");
|
||||
tinyDb.putBoolean("basicAuthFlag", false);
|
||||
Intent intent = new Intent(context, LoginActivity.class);
|
||||
context.startActivity(intent);
|
||||
dialog.dismiss();
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putBoolean("loggedInMode", false);
|
||||
tinyDb.remove("basicAuthPassword");
|
||||
tinyDb.putBoolean("basicAuthFlag", false);
|
||||
Intent intent = new Intent(context, LoginActivity.class);
|
||||
context.startActivity(intent);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
});
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
alertDialogBuilder.create().show();
|
||||
|
||||
alertDialog.show();
|
||||
}
|
||||
|
||||
public static void labelDeleteDialog(final Context context, final String labelTitle, final String labelId, String title, String message, String positiveButton, String negativeButton) {
|
||||
|
@ -23,73 +23,4 @@ public class LabelWidthCalculator {
|
||||
|
||||
}
|
||||
|
||||
public static int customWidth(int labelLength) {
|
||||
|
||||
int width = 33;
|
||||
|
||||
if(labelLength == 20) {
|
||||
width = ((width * labelLength) - 150);
|
||||
}
|
||||
else if(labelLength == 19) {
|
||||
width = ((width * labelLength) - 140);
|
||||
}
|
||||
else if(labelLength == 18) {
|
||||
width = ((width * labelLength) - 130);
|
||||
}
|
||||
else if(labelLength == 17) {
|
||||
width = ((width * labelLength) - 120);
|
||||
}
|
||||
else if(labelLength == 16) {
|
||||
width = ((width * labelLength) - 110);
|
||||
}
|
||||
else if(labelLength == 15) {
|
||||
width = ((width * labelLength) - 100);
|
||||
}
|
||||
else if(labelLength == 14) {
|
||||
width = ((width * labelLength) - 90);
|
||||
}
|
||||
else if(labelLength == 13) {
|
||||
width = ((width * labelLength) - 80);
|
||||
}
|
||||
else if(labelLength == 12) {
|
||||
width = ((width * labelLength) - 70);
|
||||
}
|
||||
else if(labelLength == 11) {
|
||||
width = ((width * labelLength) - 60);
|
||||
}
|
||||
else if(labelLength == 10) {
|
||||
width = ((width * labelLength) - 50);
|
||||
}
|
||||
else if(labelLength == 9) {
|
||||
width = ((width * labelLength) - 40);
|
||||
}
|
||||
else if(labelLength == 8) {
|
||||
width = ((width * labelLength) - 30);
|
||||
}
|
||||
else if(labelLength == 7) {
|
||||
width = ((width * labelLength) - 20);
|
||||
}
|
||||
else if(labelLength == 6) {
|
||||
width = ((width * labelLength) - 10);
|
||||
}
|
||||
else if(labelLength == 5) {
|
||||
width = ((width * labelLength) - 10);
|
||||
}
|
||||
else if(labelLength == 4) {
|
||||
width = ((width * labelLength) - 10);
|
||||
}
|
||||
else if(labelLength == 3) {
|
||||
width = ((width * labelLength) - 10);
|
||||
}
|
||||
else if(labelLength == 2) {
|
||||
width = ((width * labelLength));
|
||||
}
|
||||
else {
|
||||
width = (width * labelLength - 5);
|
||||
}
|
||||
|
||||
return width;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,34 +13,34 @@ import org.mian.gitnex.R;
|
||||
|
||||
public class Toasty {
|
||||
|
||||
public static void info(Context context, String message) {
|
||||
public static void info(Context context, String message) {
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
View view = inflater.inflate( context.getResources().getLayout(R.layout.custom_toast), null );
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
View view = inflater.inflate(context.getResources().getLayout(R.layout.custom_toast), null);
|
||||
|
||||
TextView text = view.findViewById(R.id.toastText);
|
||||
text.setText(message);
|
||||
TextView text = view.findViewById(R.id.toastText);
|
||||
text.setText(message);
|
||||
|
||||
Toast toast = new Toast(context);
|
||||
toast.setDuration(Toast.LENGTH_LONG);
|
||||
toast.setView(view);
|
||||
toast.show();
|
||||
Toast toast = new Toast(context);
|
||||
toast.setDuration(Toast.LENGTH_LONG);
|
||||
toast.setView(view);
|
||||
toast.show();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void error(Context context, String message) {
|
||||
public static void error(Context context, String message) {
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
View view = inflater.inflate( context.getResources().getLayout(R.layout.custom_toast_error), null );
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
View view = inflater.inflate(context.getResources().getLayout(R.layout.custom_toast_error), null);
|
||||
|
||||
TextView text = view.findViewById(R.id.toastText);
|
||||
text.setText(message);
|
||||
TextView text = view.findViewById(R.id.toastText);
|
||||
text.setText(message);
|
||||
|
||||
Toast toast = new Toast(context);
|
||||
toast.setDuration(Toast.LENGTH_LONG);
|
||||
toast.setView(view);
|
||||
toast.show();
|
||||
Toast toast = new Toast(context);
|
||||
toast.setDuration(Toast.LENGTH_LONG);
|
||||
toast.setView(view);
|
||||
toast.show();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,5 +38,10 @@ public class UrlHelper {
|
||||
|
||||
}
|
||||
|
||||
public static String fixScheme(String url, String scheme) {
|
||||
|
||||
return !url.matches("^(http|https)://.+$") ? scheme + "://" + url : url;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.util.Base64;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@ -28,7 +29,7 @@ public class AppUtil {
|
||||
return str.replace(original, replace);
|
||||
}
|
||||
|
||||
public static boolean haveNetworkConnection(Context context) {
|
||||
public static boolean hasNetworkConnection(Context context) {
|
||||
|
||||
boolean haveConnectedWifi = false;
|
||||
boolean haveConnectedMobile = false;
|
||||
@ -116,16 +117,9 @@ public class AppUtil {
|
||||
|
||||
}
|
||||
|
||||
public static boolean httpCheck(String url) {
|
||||
|
||||
String pattern = "^(http|https)://.*$";
|
||||
return url.matches(pattern);
|
||||
|
||||
}
|
||||
|
||||
public static String formatFileSize(long size) {
|
||||
|
||||
String repoSize = null;
|
||||
String repoSize = size + " B";
|
||||
|
||||
double m = size / 1024.0;
|
||||
double g = ((size / 1024.0) / 1024.0);
|
||||
@ -297,4 +291,12 @@ public class AppUtil {
|
||||
|
||||
}
|
||||
|
||||
public static void setMultiVisibility(int visibility, View... views) {
|
||||
|
||||
for(View view : views) {
|
||||
|
||||
view.setVisibility(visibility);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string-array name="protocolValues">
|
||||
<item>HTTPS</item>
|
||||
<item>HTTP</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user