Skip to content

Commit

Permalink
Broadcast only
Browse files Browse the repository at this point in the history
  • Loading branch information
theexpensiveinformatics committed Apr 8, 2023
1 parent fa17c44 commit e541bcb
Show file tree
Hide file tree
Showing 14 changed files with 383 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 14 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,51 @@ android {
defaultConfig {
applicationId "error404.gfg.healthcare"
minSdk 23
targetSdk 32
targetSdk 31
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
// dexOptions {
// javaMaxHeapSize "4G"
// }


}

dependencies {
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.firebase:firebase-auth:21.2.0'
implementation 'com.google.firebase:firebase-database:20.1.0'
implementation 'com.google.firebase:firebase-auth-ktx:21.2.0'

// implementation ' com.google.android.gms:play-services-base:6.5.87'

implementation platform('com.google.firebase:firebase-bom:31.2.3')
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.android.gms:play-services-auth:20.5.0'

implementation "com.airbnb.android:lottie:3.4.0"
implementation 'com.google.firebase:firebase-firestore:24.4.5'



implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.firebaseui:firebase-ui-database:8.0.2'
// implementation 'androidx.appcompat:appcompat:1.6.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

}
11 changes: 9 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="error404.gfg.healthcare">

<uses-permission android:name="android.permission.CALL_PHONE"/>

<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.PREVENT_POWER_KEY" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -14,6 +18,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.AppName"
tools:targetApi="31">
<activity
android:name=".Artical"
android:exported="false" />
<activity
android:name=".ECall"
android:exported="false" />
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/error404/gfg/healthcare/Artical.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package error404.gfg.healthcare;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

public class Artical extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_artical);
}
}
33 changes: 33 additions & 0 deletions app/src/main/java/error404/gfg/healthcare/ECall.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
import android.Manifest;
import android.animation.ObjectAnimator;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.PathMeasure;
Expand All @@ -18,6 +21,7 @@
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
Expand Down Expand Up @@ -51,6 +55,9 @@ protected void onCreate(Bundle savedInstanceState) {
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(this, R.color.bg));




//status bar
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow();
Expand Down Expand Up @@ -89,6 +96,25 @@ protected void onCreate(Bundle savedInstanceState) {

activityEcallBinding.ifnotaddesBg.setVisibility(View.GONE);
activityEcallBinding.ifAddedBg.setVisibility(View.VISIBLE);

//powerbutton
BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {

String s = "tel:" + numkey;
Intent call = new Intent(Intent.ACTION_CALL);
call.setData(Uri.parse(s));
startActivity(call);

}
};

// on below line we are creating an intent filter.
IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);

// on below line we are registering receiver.
registerReceiver(receiver, filter);
}

activityEcallBinding.deleteCon.setOnClickListener(new View.OnClickListener() {
Expand Down Expand Up @@ -151,6 +177,10 @@ public void onClick(View v) {
}
});





//onEcallBGClick


Expand Down Expand Up @@ -213,6 +243,9 @@ public void run() {
}
};
_timer.schedule(timer, (int) (200));

finish();
Toast.makeText(ECall.this, "Emergency Number Added, Please Restart App ." , Toast.LENGTH_SHORT).show();
}
}
});
Expand Down
63 changes: 63 additions & 0 deletions app/src/main/java/error404/gfg/healthcare/Model.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package error404.gfg.healthcare;

public class Model {
String img;
String headline;
String description;
String publisher;
String time;
String weblink;
String ytlink;


public String getImg() {
return this.img;
}
public String getHeadline() {
return this.headline;
}
public String getDescription() {
return this.description;
}
public String getTime() {
return this.time;
}
public String getPublisher() {
return this.publisher;
}
public String getWeblink() {
return this.weblink;
}
public String getYtlink() {
return this.ytlink;
}

public void setImg(String img) {
this.img = img;
}
public void setHeadline(String headline) {
this.headline = headline;
}
public void setDescription(String description) {
this.description = description;
}
public void setPublisher(String publisher) {
this.publisher = publisher;
}
public void setTime(String time) {
this.time = time;
}
public void setWeblink(String weblink) {
this.weblink = weblink;
}
public void setYtlink(String ytlink) {
this.ytlink = ytlink;
}



public Model()
{

}
}
79 changes: 78 additions & 1 deletion app/src/main/java/error404/gfg/healthcare/ThirdFragment.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
package error404.gfg.healthcare;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.Toast;

//import com.firebase.ui.database.FirebaseRecyclerAdapter;
//import com.firebase.ui.database.FirebaseRecyclerOptions;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.firebase.ui.database.FirebaseRecyclerOptions;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

/**
* A simple {@link Fragment} subclass.
* Use the {@link ThirdFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class ThirdFragment extends Fragment {
LinearLayoutManager mlinearLayoutManager;
RecyclerView mrecyclerView;
FirebaseDatabase mfirebaseDatabase;
DatabaseReference mdatabaseReference;
FirebaseRecyclerAdapter<Model,ViewHolder> firebaseRecyclerAdapter;
FirebaseRecyclerOptions<Model> options;

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
Expand Down Expand Up @@ -59,6 +78,64 @@ public void onCreate(Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_third, container, false);


View v = inflater.inflate(R.layout.fragment_third, container, false);

mlinearLayoutManager = new LinearLayoutManager(getActivity());
mlinearLayoutManager.setReverseLayout(true);
mlinearLayoutManager.setStackFromEnd(true);

mrecyclerView = v.findViewById(R.id.broadcast_recyclerView);
mfirebaseDatabase=FirebaseDatabase.getInstance();
mdatabaseReference =mfirebaseDatabase.getReference("broadcast");
showData();

return v;
}

private void showData() {

options = new FirebaseRecyclerOptions.Builder<Model>().setQuery(mdatabaseReference,Model.class).build();
firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Model, ViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull ViewHolder holder, int position, @NonNull Model model) {
holder.setDeatils(getActivity().getApplicationContext(),model.getImg(), model.getHeadline(), model.getDescription(),model.getPublisher(),model.getTime(),model.getWeblink(),model.getYtlink());
}

@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.broadcast_recycler,parent,false);
ViewHolder viewHolder = new ViewHolder(itemView);
viewHolder.setOnClickListener(new ViewHolder.ClickListener() {
@Override
public void onItemClick(View view, int position) {
Toast.makeText(getActivity(), "hi", Toast.LENGTH_SHORT).show();
}

@Override
public void onItemLongClick(View view, int position) {
Toast.makeText(getActivity(), "Long CLick ", Toast.LENGTH_SHORT).show();
}
});
return viewHolder;
}
};

mrecyclerView.setLayoutManager(mlinearLayoutManager);
firebaseRecyclerAdapter.startListening();
mrecyclerView.setAdapter(firebaseRecyclerAdapter);


}

public void onStart()
{
super.onStart();
if(firebaseRecyclerAdapter != null)
{
firebaseRecyclerAdapter.startListening();
}
}
}
Loading

0 comments on commit e541bcb

Please sign in to comment.