.
This commit is contained in:
@@ -7,11 +7,12 @@ import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Telephony;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
@@ -226,6 +227,49 @@ public class FUAActivity extends AppCompatActivity {
|
||||
mySharedPref.setArrayList("APP_LIST", appsName);
|
||||
}
|
||||
} else {
|
||||
// Aditya -> removing Basic apps from block list i.e. APP_LIST
|
||||
|
||||
try {
|
||||
// Camera
|
||||
Intent camIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
ResolveInfo camInfo = packageManager.resolveActivity(camIntent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
if (camInfo != null){
|
||||
appsName.remove(camInfo.activityInfo.packageName);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
try {
|
||||
// Gallery
|
||||
Intent mainIntent = new Intent(Intent.ACTION_PICK);
|
||||
mainIntent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
|
||||
List<ResolveInfo> galleryApps = getPackageManager().queryIntentActivities(mainIntent, PackageManager.GET_RESOLVED_FILTER);
|
||||
if (galleryApps != null && !galleryApps.isEmpty()) {
|
||||
appsName.remove(galleryApps.get(0).activityInfo.packageName);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
// SMS
|
||||
try {
|
||||
appsName.remove(Telephony.Sms.getDefaultSmsPackage(this));
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
// CALL
|
||||
try {
|
||||
Intent dailIntent = new Intent(Intent.ACTION_DIAL);
|
||||
ResolveInfo dialInfo = getPackageManager().resolveActivity(dailIntent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
if (dialInfo != null) {
|
||||
appsName.remove(dialInfo.activityInfo.packageName);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
mySharedPref.setArrayList("APP_LIST", appsName);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
package com.app.simplitend.apputils;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.net.Uri;
|
||||
import android.provider.MediaStore;
|
||||
import android.provider.Telephony;
|
||||
import android.util.Log;
|
||||
|
||||
import com.onesignal.Continue;
|
||||
import com.onesignal.OneSignal;
|
||||
import com.onesignal.debug.LogLevel;
|
||||
import com.app.simplitend.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SimpliTendApp extends Application {
|
||||
|
||||
@Override
|
||||
@@ -31,4 +40,5 @@ public class SimpliTendApp extends Application {
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,27 @@
|
||||
package com.app.simplitend.articles;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.app.simplitend.welcome.welcomepatient.mvvm.models.CallResponse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Header;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.PartMap;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface ArticleApiService {
|
||||
|
||||
@GET("api/get-list-of-news-articles")
|
||||
Call<CallResponse<ArrayList<ArticleResult>>> getArticles();
|
||||
@GET("api/get-search-of-news-articles")
|
||||
Call<CallResponse<ArrayList<ArticleResult>>> getArticles(@Header("Authorization") String token,
|
||||
@Header("title") String search_query,
|
||||
@Query("per_page") int per_page,
|
||||
@Query("page") int page);
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ArticlePresenter {
|
||||
|
||||
private ArticleApiService apiService;
|
||||
|
||||
private ArticlePresenter(){
|
||||
private ArticlePresenter() {
|
||||
this.apiService = RetrofitHelper.getRetrofit()
|
||||
.create(ArticleApiService.class);
|
||||
}
|
||||
@@ -30,19 +30,24 @@ public class ArticlePresenter {
|
||||
return articlePresenter;
|
||||
}
|
||||
|
||||
public void getArticles(@NonNull ArticleContracts.GetArticleCallback getArticleCallback){
|
||||
apiService.getArticles()
|
||||
public void getArticles(String token,
|
||||
String search_query,
|
||||
int per_page,
|
||||
int page_no,
|
||||
@NonNull ArticleContracts.GetArticleCallback getArticleCallback) {
|
||||
|
||||
apiService.getArticles(token, search_query, per_page, page_no)
|
||||
.enqueue(new Callback<CallResponse<ArrayList<ArticleResult>>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<ArrayList<ArticleResult>>> call, Response<CallResponse<ArrayList<ArticleResult>>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200 || response.body().result == null){
|
||||
if (response.body() != null) {
|
||||
if (response.body().status != 200 || response.body().result == null) {
|
||||
getArticleCallback.onArticleFetchFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
getArticleCallback.onArticlesFetched(response.body().result);
|
||||
}else{
|
||||
} else {
|
||||
getArticleCallback.onArticleFetchFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,27 +3,35 @@ package com.app.simplitend.articles;
|
||||
import static com.app.simplitend.articles.ArticleShowerActivity.ARTICLE_TITLE;
|
||||
import static com.app.simplitend.articles.ArticleShowerActivity.ARTICLE_URL_KEY;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.app.simplitend.R;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.app.simplitend.apputils.AppUtil;
|
||||
import com.app.simplitend.databinding.ActivityArticlesBinding;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ArticlesActivity extends AppCompatActivity
|
||||
implements ArticlesAdapter.ArticleClickListener, ArticleContracts.GetArticleCallback {
|
||||
|
||||
private static final int PER_PAGE_COUNT = 10;
|
||||
protected ActivityArticlesBinding binding;
|
||||
|
||||
private ArticlePresenter presenter;
|
||||
|
||||
private ArticlesAdapter articlesAdapter;
|
||||
|
||||
private boolean isLoadingArticles, lastPageHit;
|
||||
|
||||
private int page_no;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -37,28 +45,75 @@ public class ArticlesActivity extends AppCompatActivity
|
||||
|
||||
clickEvents();
|
||||
|
||||
getArticles();
|
||||
page_no = 1;
|
||||
getArticles(binding.searchEt.getText().toString().trim(), PER_PAGE_COUNT, page_no, false);
|
||||
|
||||
}
|
||||
|
||||
private void getArticles() {
|
||||
binding.noArticles.setVisibility(View.GONE);
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
binding.search.setVisibility(View.GONE);
|
||||
private void getArticles(String search_query, int per_page, int page_no, boolean bottom_progress) {
|
||||
|
||||
presenter.getArticles(this);
|
||||
binding.noArticles.setVisibility(View.GONE);
|
||||
|
||||
if (bottom_progress){
|
||||
binding.pageProgress.setVisibility(View.VISIBLE);
|
||||
binding.searchView.setVisibility(View.GONE);
|
||||
}else{
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
articlesAdapter.submitList(null);
|
||||
}
|
||||
|
||||
isLoadingArticles = true;
|
||||
presenter.getArticles("Bearer " + AppUtil.getCgToken(this), search_query, per_page, page_no,this);
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
binding.articlesRv.setLayoutManager(new LinearLayoutManager(this));
|
||||
articlesAdapter = new ArticlesAdapter(this);
|
||||
binding.articlesRv.setAdapter(articlesAdapter);
|
||||
|
||||
binding.articlesRv.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
int visibleItemCount = layoutManager.getChildCount();
|
||||
int totalItemCount = layoutManager.getItemCount();
|
||||
int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
|
||||
|
||||
if (!isLoadingArticles && !lastPageHit) {
|
||||
if ((visibleItemCount + firstVisibleItemPosition) >= (totalItemCount)
|
||||
&& firstVisibleItemPosition >= 0) {
|
||||
getArticles(binding.searchEt.getText().toString(), 10, ++page_no, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
binding.backBtn.setOnClickListener(v -> {
|
||||
onBackPressed();
|
||||
});
|
||||
|
||||
binding.closeBtn.setOnClickListener(v -> {
|
||||
if (!binding.searchEt.getText().toString().trim().isEmpty()){
|
||||
page_no = 1;
|
||||
getArticles("", PER_PAGE_COUNT, page_no, false);
|
||||
}
|
||||
|
||||
binding.searchEt.setText("");
|
||||
});
|
||||
|
||||
binding.searchEt.setOnEditorActionListener((textView, i, keyEvent) -> {
|
||||
if (binding.searchEt.getText().toString().trim().isEmpty()){
|
||||
return true;
|
||||
}
|
||||
|
||||
AppUtil.closeKeyboard(this);
|
||||
page_no = 1;
|
||||
getArticles(binding.searchEt.getText().toString().trim(), PER_PAGE_COUNT, page_no, false);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,24 +126,32 @@ public class ArticlesActivity extends AppCompatActivity
|
||||
|
||||
@Override
|
||||
public void onArticlesFetched(ArrayList<ArticleResult> articleResults) {
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
binding.noArticles.setVisibility(View.GONE);
|
||||
binding.search.setVisibility(View.VISIBLE);
|
||||
isLoadingArticles = false;
|
||||
lastPageHit = articleResults.size() < PER_PAGE_COUNT; // there are no articles left at server side to be fetched.
|
||||
|
||||
if (articleResults.isEmpty()){
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
binding.pageProgress.setVisibility(View.GONE);
|
||||
binding.noArticles.setVisibility(View.GONE);
|
||||
binding.searchView.setVisibility(View.VISIBLE);
|
||||
|
||||
List<ArticleResult> currentArticleList = articlesAdapter.getCurrentList();
|
||||
|
||||
ArrayList<ArticleResult> totalArticles = new ArrayList<>(currentArticleList);
|
||||
totalArticles.addAll(articleResults);
|
||||
|
||||
if (totalArticles.isEmpty()){
|
||||
binding.noArticles.setVisibility(View.VISIBLE);
|
||||
binding.search.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
articlesAdapter.submitList(articleResults);
|
||||
articlesAdapter.submitList(totalArticles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArticleFetchFailed(Throwable t, String message) {
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
binding.pageProgress.setVisibility(View.GONE);
|
||||
binding.noArticles.setVisibility(View.VISIBLE);
|
||||
binding.search.setVisibility(View.GONE);
|
||||
|
||||
binding.searchView.setVisibility(View.GONE);
|
||||
|
||||
Toast.makeText(this, "" + message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,14 @@ public class ArticlesAdapter extends ListAdapter<ArticleResult, ArticlesAdapter.
|
||||
|
||||
@Override
|
||||
public boolean areContentsTheSame(@NonNull ArticleResult oldItem, @NonNull ArticleResult newItem) {
|
||||
return false;
|
||||
try {
|
||||
return oldItem.large_image.equals(newItem.large_image) &&
|
||||
oldItem.article_title.equals(newItem.article_title) &&
|
||||
oldItem.article_author.equals(newItem.article_author) &&
|
||||
oldItem.created_at.equals(newItem.created_at);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
}
|
||||
|
||||
private void loadArticles() {
|
||||
viewModel.getArticles(this);
|
||||
viewModel.getArticles(requireContext(), this);
|
||||
}
|
||||
|
||||
private void setDetails() {
|
||||
@@ -311,7 +311,6 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
binding.articleView.setVisibility(View.VISIBLE);
|
||||
|
||||
setArticleDetails(articleResults.get(0));
|
||||
|
||||
}else{
|
||||
// no articles
|
||||
binding.articleView.setVisibility(View.GONE);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.app.simplitend.caregiverdashboard.mvvm;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
@@ -52,9 +53,9 @@ public class CaregiverMainViewModel extends ViewModel {
|
||||
this.articleResults = articleResults;
|
||||
}
|
||||
|
||||
public void getArticles(@NonNull ArticleContracts.GetArticleCallback articleCallback){
|
||||
public void getArticles(Context context, @NonNull ArticleContracts.GetArticleCallback articleCallback){
|
||||
if (articleResults == null){
|
||||
cgHomeRepository.getArticles(articleCallback);
|
||||
cgHomeRepository.getArticles(context, articleCallback);
|
||||
}else{
|
||||
articleCallback.onArticlesFetched(articleResults);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.app.simplitend.caregiverdashboard.mvvm;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.app.simplitend.apputils.AppUtil;
|
||||
import com.app.simplitend.apputils.RetrofitHelper;
|
||||
import com.app.simplitend.articles.ArticleContracts;
|
||||
import com.app.simplitend.articles.ArticlePresenter;
|
||||
@@ -36,10 +39,9 @@ public class CgHomeRepository {
|
||||
return cgHomeRepository;
|
||||
}
|
||||
|
||||
public void getArticles(@NonNull ArticleContracts.GetArticleCallback getArticleCallback) {
|
||||
public void getArticles(Context context, @NonNull ArticleContracts.GetArticleCallback getArticleCallback) {
|
||||
ArticlePresenter articlePresenter = ArticlePresenter.getArticlePresenter();
|
||||
|
||||
articlePresenter.getArticles(getArticleCallback);
|
||||
articlePresenter.getArticles("Bearer " + AppUtil.getCgToken(context), "", 1,1,getArticleCallback);
|
||||
}
|
||||
|
||||
public void getGeoFenceDetails(String p_id,
|
||||
|
||||
@@ -439,10 +439,14 @@ public class PatientDashboardFragment extends Fragment implements ProfileContrac
|
||||
}
|
||||
|
||||
// Now checking activities
|
||||
routineViewModel.getRoutines(AppUtil.getPatientUid(requireContext()),
|
||||
"Bearer " + AppUtil.getPatientToken(requireContext()),
|
||||
Calendar.getInstance().get(Calendar.DAY_OF_WEEK)-1,
|
||||
this);
|
||||
try {
|
||||
routineViewModel.getRoutines(AppUtil.getPatientUid(requireContext()),
|
||||
"Bearer " + AppUtil.getPatientToken(requireContext()),
|
||||
Calendar.getInstance().get(Calendar.DAY_OF_WEEK)-1,
|
||||
this);
|
||||
} catch (Exception e) {
|
||||
// do nothing user has left the fragment
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,7 @@ import static com.app.simplitend.patientprofile.RegisterCompleteFragment.IS_CONN
|
||||
import static com.app.simplitend.patientprofile.RegisterCompleteFragment.PROFILE_PROGRESS;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -16,6 +17,7 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.app.simplitend.R;
|
||||
import com.app.simplitend.appblocking.FUAActivity;
|
||||
import com.app.simplitend.apputils.AppUtil;
|
||||
import com.app.simplitend.apputils.RetrofitHelper;
|
||||
import com.app.simplitend.databinding.ProfileProgressFragmentBinding;
|
||||
@@ -112,6 +114,68 @@ public class ProfileProgressFragment extends Fragment implements ProfileContract
|
||||
Navigation.findNavController(v).navigate(R.id.action_profileProgressFragment_to_registerCompleteFragment, bundle);
|
||||
});
|
||||
|
||||
binding.fua.setOnClickListener(v -> {
|
||||
checkSubscriptionStatus();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void checkSubscriptionStatus() {
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we fetch details.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
PatientProfileAPIService apiService = RetrofitHelper.getRetrofit().create(PatientProfileAPIService.class);
|
||||
|
||||
String token = "Bearer " + AppUtil.getPatientToken(requireContext());
|
||||
|
||||
apiService.getUsrProfileProgress(token)
|
||||
.enqueue(new Callback<CallResponse<PatientData>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<PatientData>> call, Response<CallResponse<PatientData>> response) {
|
||||
progressDialog.dismiss();
|
||||
if (response.body() != null) {
|
||||
if (response.body().status != 200 || response.body().result == null) {
|
||||
onProfileProgressFetchFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.body().result.isCaregiverTakeSubscription == 1) {
|
||||
// CG subscribed
|
||||
try {
|
||||
Intent intent = new Intent(requireActivity(), FUAActivity.class);
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
} else {
|
||||
// no subscription alert
|
||||
try {
|
||||
AppUtil.showAlert(requireContext(),
|
||||
"Kindly ask Caregiver to complete SimpliTend subscription.",
|
||||
"Once your caregiver has completed the " +
|
||||
"subscription, you will be able to use the " +
|
||||
"application.",
|
||||
"OK",
|
||||
((dialogInterface, i) -> {
|
||||
|
||||
}), null, null);
|
||||
}catch (Exception e){
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
} else {
|
||||
onProfileProgressFetchFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<PatientData>> call, Throwable t) {
|
||||
onProfileProgressFetchFailed(new Exception(), "Couldn't connect");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -99,7 +99,7 @@ public class ContactViewModel extends AndroidViewModel {
|
||||
FileOutputStream outputStream = new FileOutputStream(file);
|
||||
|
||||
// Compress and save the Bitmap as a PNG file (you can choose a different format)
|
||||
contactPhoto.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
|
||||
contactPhoto.compress(Bitmap.CompressFormat.PNG, 40, outputStream);
|
||||
|
||||
// Close the output stream and input stream when done
|
||||
outputStream.close();
|
||||
|
||||
Reference in New Issue
Block a user