Skip to content

Commit b4f3c2a

Browse files
author
Devansh
committed
Added new Invite option
1 parent 2fea4bc commit b4f3c2a

5 files changed

Lines changed: 194 additions & 74 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ dependencies {
5858
implementation 'com.squareup.picasso:picasso:2.71828'
5959
implementation 'com.google.android.gms:play-services-maps:17.0.0'
6060
implementation 'com.google.android.gms:play-services-location:17.1.0'
61+
implementation 'com.google.firebase:firebase-invites:17.0.0'
62+
implementation 'com.google.firebase:firebase-dynamic-links:19.1.1'
6163
testImplementation 'junit:junit:4.13.1'
6264
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
6365
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

app/src/main/AndroidManifest.xml

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
<uses-permission android:name = "android.permission.INTERNET" />
1212
<uses-permission android:name = "android.permission.READ_EXTERNAL_STORAGE" />
1313
<uses-permission android:name = "android.permission.WRITE_EXTERNAL_STORAGE" />
14-
<uses-permission android:name = "android.permission.ACCESS_COARSE_LOCATION"/>
15-
<uses-permission android:name="android.permission.SEND_SMS"/>
16-
<uses-permission android:name="android.permission.READ_SMS"/>
17-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
18-
14+
<uses-permission android:name = "android.permission.ACCESS_COARSE_LOCATION" />
15+
<uses-permission android:name = "android.permission.SEND_SMS" />
16+
<uses-permission android:name = "android.permission.READ_SMS" />
17+
<uses-permission android:name = "android.permission.ACCESS_NETWORK_STATE" />
18+
1919
<application
20-
android:name=".Activities.Notifications.App"
20+
android:name = ".Activities.Notifications.App"
2121
android:allowBackup = "true"
2222
android:hardwareAccelerated = "false"
2323
android:icon = "@mipmap/hygeia_icon"
@@ -39,9 +39,9 @@
3939
android:name = "com.google.android.geo.API_KEY"
4040
android:value = "@string/google_maps_key" />
4141
<meta-data
42-
android:name="preloaded_fonts"
43-
android:resource="@array/preloaded_fonts" />
44-
42+
android:name = "preloaded_fonts"
43+
android:resource = "@array/preloaded_fonts" />
44+
4545
<activity
4646
android:name = ".Activities.MapsActivity"
4747
android:label = "@string/title_activity_maps" />
@@ -64,9 +64,41 @@
6464
android:theme = "@style/Splash">
6565
<intent-filter>
6666
<action android:name = "android.intent.action.MAIN" />
67-
67+
6868
<category android:name = "android.intent.category.LAUNCHER" />
6969
</intent-filter>
70+
71+
72+
<intent-filter>
73+
<action android:name = "android.intent.action.VIEW" />
74+
75+
<category android:name = "android.intent.category.DEFAULT" />
76+
<category android:name = "android.intent.category.BROWSABLE" />
77+
78+
<data
79+
android:host = "github.com"
80+
android:scheme = "http" />
81+
<data
82+
android:host = "github.com"
83+
android:scheme = "https" />
84+
</intent-filter>
85+
86+
87+
<intent-filter android:autoVerify = "true">
88+
<action android:name = "android.intent.action.VIEW" />
89+
90+
<category android:name = "android.intent.category.DEFAULT" />
91+
<category android:name = "android.intent.category.BROWSABLE" />
92+
93+
<data
94+
android:host = "remotehealthcareproject.page.link"
95+
android:pathPrefix = "/invite"
96+
android:scheme = "http" />
97+
<data
98+
android:host = "remotehealthcareproject.page.link"
99+
android:pathPrefix = "/invite"
100+
android:scheme = "https" />
101+
</intent-filter>
70102
</activity>
71103
<activity
72104
android:name = ".Activities.Redundant.JoyInterface"
@@ -91,9 +123,9 @@
91123
android:name = ".Activities.Login.PhoneAuthActivity"
92124
android:label = "Phone Authentication">
93125
</activity>
94-
<activity android:name=".Activities.Login.CreateAccount"
95-
android:label="Create Account">
96-
126+
<activity
127+
android:name = ".Activities.Login.CreateAccount"
128+
android:label = "Create Account">
97129
</activity>
98130
</application>
99131

app/src/main/java/com/sdp/remotehealthcareapp/Activities/MainActivity.java

Lines changed: 80 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,29 @@
1313
import android.content.DialogInterface;
1414
import android.content.Intent;
1515
import android.content.SharedPreferences;
16+
import android.net.Uri;
1617
import android.os.Bundle;
1718

19+
import android.util.Log;
1820
import android.view.MenuItem;
1921

2022
import android.view.View;
2123
import android.widget.FrameLayout;
2224
import android.widget.TextView;
25+
import android.widget.Toast;
2326

2427
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
2528

2629
import com.google.android.gms.tasks.OnCompleteListener;
30+
import com.google.android.gms.tasks.OnFailureListener;
31+
import com.google.android.gms.tasks.OnSuccessListener;
2732
import com.google.android.gms.tasks.Task;
2833
import com.google.android.material.navigation.NavigationView;
2934

3035
import com.google.firebase.auth.FirebaseAuth;
3136
import com.google.firebase.auth.FirebaseUser;
37+
import com.google.firebase.dynamiclinks.FirebaseDynamicLinks;
38+
import com.google.firebase.dynamiclinks.PendingDynamicLinkData;
3239
import com.google.firebase.firestore.DocumentSnapshot;
3340
import com.google.firebase.firestore.FirebaseFirestore;
3441
import com.sdp.remotehealthcareapp.Activities.Login.PhoneAuthActivity;
@@ -39,9 +46,13 @@
3946
import com.sdp.remotehealthcareapp.Fragments.Appointments.RecentAppointment_Fragment;
4047
import com.sdp.remotehealthcareapp.R;
4148

49+
import static com.google.firebase.dynamiclinks.FirebaseDynamicLinks.*;
50+
4251

4352
public class MainActivity extends AppCompatActivity {
4453

54+
private static final String TAG = "MainActivity";
55+
4556
private Fragment selectorFragment;
4657
private GoogleSignInClient mGoogleSignInClient;
4758
private final static int RC_SIGN_IN = 123;
@@ -63,11 +74,31 @@ protected void onCreate(Bundle savedInstanceState) {
6374
setContentView(R.layout.activity_main);
6475
getDrawer_started();
6576
getProfile();
77+
78+
//For handling dynamic links
79+
FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent()).addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
80+
@Override
81+
public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
82+
Toast.makeText(MainActivity.this, "Found a dynamic link", Toast.LENGTH_SHORT).show();
83+
84+
Uri link = null;
85+
if (pendingDynamicLinkData != null)
86+
link = pendingDynamicLinkData.getLink();
87+
88+
if (link != null)
89+
Log.d(TAG, "onSuccess: " + link);
90+
}
91+
}).addOnFailureListener(this, new OnFailureListener() {
92+
@Override
93+
public void onFailure(@NonNull Exception e) {
94+
Toast.makeText(MainActivity.this, "No data extractable", Toast.LENGTH_SHORT).show();
95+
}
96+
});
6697
}
6798

68-
private void getProfile(){
99+
private void getProfile() {
69100
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
70-
if(user !=null) {
101+
if (user != null) {
71102
NavigationView navigationView = (NavigationView) findViewById(R.id.navigation);
72103
View headerView = navigationView.getHeaderView(0);
73104
navUsername = (TextView) headerView.findViewById(R.id.user_name);
@@ -81,7 +112,7 @@ private void getProfile(){
81112
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
82113
if (task.isSuccessful()) {
83114
DocumentSnapshot document = task.getResult();
84-
String name= (document.getString("Name"));
115+
String name = (document.getString("Name"));
85116
navUsername.setText(name);
86117

87118
}
@@ -90,78 +121,72 @@ public void onComplete(@NonNull Task<DocumentSnapshot> task) {
90121
}
91122
}
92123

93-
public static String getName()
94-
{
124+
public static String getName() {
95125
return navUsername.getText().toString();
96126
}
97-
private void getDrawer_started()
98-
{
99127

100-
drawerLayout= findViewById(R.id.drawerlayout);
101-
coordinatorLayout= findViewById(R.id.coordinator);
102-
toolbar= findViewById(R.id.toolbar);
128+
private void getDrawer_started() {
129+
130+
drawerLayout = findViewById(R.id.drawerlayout);
131+
coordinatorLayout = findViewById(R.id.coordinator);
132+
toolbar = findViewById(R.id.toolbar);
103133
// frameLayout= findViewById(R.id.framelayout);
104-
navigationView= findViewById(R.id.navigation);
134+
navigationView = findViewById(R.id.navigation);
105135
setUpToolbar();
106136
getSupportFragmentManager().beginTransaction().replace(R.id.fragment,
107137
new Dashboard()).addToBackStack("Dashboard").commit();
108138

109139

110-
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout,R.string.open_drawer, R.string.close_drawer);
140+
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.open_drawer, R.string.close_drawer);
111141
drawerLayout.addDrawerListener(actionBarDrawerToggle);
112142
actionBarDrawerToggle.syncState();
113143

114144
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
115145
@Override
116146
public boolean onNavigationItemSelected(MenuItem item) {
117-
selectorFragment=new Dashboard();
118-
if(item.getItemId() == R.id.logout) {
119-
//finish();
147+
selectorFragment = new Dashboard();
148+
if (item.getItemId() == R.id.logout) {
149+
//finish();
120150
/*sharedPreferences= getSharedPreferences(getString(R.string.preference_file_name), MODE_PRIVATE);
121151
sharedPreferences.edit().putBoolean("isLoggedin", false).apply();*/
122-
startActivity(new Intent(getApplicationContext(), PhoneAuthActivity.class));
123-
finish();
124-
}
125-
else if(item.getItemId()== R.id.book_appointment)
126-
selectorFragment= new AppointmentFragment();
127-
else if(item.getItemId() == R.id.profile){
128-
selectorFragment = new MyProfile();
129-
}
130-
else if(item.getItemId() == R.id.healthfiles) {
131-
selectorFragment= new HealthFiles();
132-
}
133-
else if(item.getItemId()== R.id.dashboard){
134-
selectorFragment= new Dashboard();
135-
}
136-
else if(item.getItemId() == R.id.recent)
137-
{
138-
selectorFragment= new RecentAppointment_Fragment();
139-
}
140-
else if(item.getItemId() == R.id.about){
141-
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this)
142-
.setTitle("About Hygeia")
143-
.setMessage("Build and published by \nAkshat Srivastava(201851013)\nDevansh Agarwal(201851038)\nUjjwal Shrivastava(201851136)\n"+"\nIf you want to hire us or\n"+"if you want to check our other works\n"+"Have a look at our website:")
144-
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
145-
@Override
146-
public void onClick(DialogInterface dialogInterface, int i) {
147-
Intent intent = new Intent(MainActivity.this, MyWebViewActivity.class);
148-
intent.putExtra("url","https://www.example.com/");
149-
startActivity(intent);
150-
}
151-
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
152-
@Override
153-
public void onClick(DialogInterface dialogInterface, int i) {
154-
155-
}
156-
});
157-
builder.create().show();
158-
}
159-
getSupportFragmentManager().beginTransaction().replace(R.id.fragment,selectorFragment).addToBackStack("Profile Setup").commit();
160-
drawerLayout.closeDrawers();
152+
startActivity(new Intent(getApplicationContext(), PhoneAuthActivity.class));
153+
finish();
154+
} else if (item.getItemId() == R.id.book_appointment)
155+
selectorFragment = new AppointmentFragment();
156+
else if (item.getItemId() == R.id.profile) {
157+
selectorFragment = new MyProfile();
158+
} else if (item.getItemId() == R.id.healthfiles) {
159+
selectorFragment = new HealthFiles();
160+
} else if (item.getItemId() == R.id.dashboard) {
161+
selectorFragment = new Dashboard();
162+
} else if (item.getItemId() == R.id.recent) {
163+
selectorFragment = new RecentAppointment_Fragment();
164+
} else if (item.getItemId() == R.id.about) {
165+
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this)
166+
.setTitle("About Hygeia")
167+
.setMessage("Build and published by \nAkshat Srivastava(201851013)\nDevansh Agarwal(201851038)\nUjjwal Shrivastava(201851136)\n" + "\nIf you want to hire us or\n" + "if you want to check our other works\n" + "Have a look at our website:")
168+
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
169+
@Override
170+
public void onClick(DialogInterface dialogInterface, int i) {
171+
Intent intent = new Intent(MainActivity.this, MyWebViewActivity.class);
172+
intent.putExtra("url", "https://www.example.com/");
173+
startActivity(intent);
174+
}
175+
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
176+
@Override
177+
public void onClick(DialogInterface dialogInterface, int i) {
178+
179+
}
180+
});
181+
builder.create().show();
182+
}
183+
getSupportFragmentManager().beginTransaction().replace(R.id.fragment, selectorFragment).addToBackStack("Profile Setup").commit();
184+
drawerLayout.closeDrawers();
161185
return true;
162186
}
163187
});
164188
}
189+
165190
private void setUpToolbar() {
166191
//setSupportActionBar(toolbar);
167192
setSupportActionBar(toolbar);
@@ -173,8 +198,7 @@ private void setUpToolbar() {
173198
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
174199

175200

176-
if(item.getItemId() == android.R.id.home)
177-
{
201+
if (item.getItemId() == android.R.id.home) {
178202
drawerLayout.openDrawer(GravityCompat.START);
179203
}
180204
return super.onOptionsItemSelected(item);

0 commit comments

Comments
 (0)