Skip to content

Commit

Permalink
Refactoring...
Browse files Browse the repository at this point in the history
  • Loading branch information
xMansour committed Jul 5, 2019
1 parent 829c9df commit 8ff2785
Show file tree
Hide file tree
Showing 54 changed files with 2,005 additions and 1,165 deletions.
7 changes: 4 additions & 3 deletions Application/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<uses-permission
android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.GET_TASKS" /> <!--FOR FOREGROUND APPS BEFORE LOLLIPOP-->
<uses-permission android:name="android.permission.GET_TASKS" /> <!-- FOR FOREGROUND APPS BEFORE LOLLIPOP -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission
android:name="android.permission.WRITE_SETTINGS"
Expand All @@ -34,10 +34,11 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
<activity android:name=".activities.AccountVerificationActivity"></activity>
<activity android:name=".activities.AboutActivity"></activity>
<activity android:name=".activities.SettingsActivity" />
<activity android:name=".activities.AccountVerificationActivity" />
<activity android:name=".activities.ModeSelectionActivity" />
<activity android:name=".activities.PermissionsActivity" />
<activity android:name=".activities.SettingsActivity" />
<activity android:name=".activities.BlockedAppActivity" />
<activity
android:name=".activities.ChildDetailsActivity"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.mansourappdevelopment.androidapp.kidsafe.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.TextView;

import com.mansourappdevelopment.androidapp.kidsafe.R;

public class AboutActivity extends AppCompatActivity {
private ImageButton btnBack;
private ImageButton btnSettings;
private TextView txtTitle;
private FrameLayout toolbar;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
toolbar = (FrameLayout) findViewById(R.id.toolbar);
btnBack = (ImageButton) findViewById(R.id.btnBack);
btnBack.setImageDrawable(getResources().getDrawable(R.drawable.ic_arrow_back));
btnBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
btnSettings = (ImageButton) findViewById(R.id.btnSettings);
btnSettings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(AboutActivity.this, SettingsActivity.class);
startActivity(intent);
}
});
txtTitle = (TextView) findViewById(R.id.txtTitle);
txtTitle.setText(getString(R.string.about));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
Expand All @@ -10,15 +11,22 @@
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.mansourappdevelopment.androidapp.kidsafe.R;
import com.mansourappdevelopment.androidapp.kidsafe.dialogfragments.InformationDialogFragment;
import com.mansourappdevelopment.androidapp.kidsafe.dialogfragments.PasswordValidationDialogFragment;
import com.mansourappdevelopment.androidapp.kidsafe.dialogfragments.PermissionExplanationDialogFragment;
import com.mansourappdevelopment.androidapp.kidsafe.interfaces.OnPasswordValidationListener;
import com.mansourappdevelopment.androidapp.kidsafe.interfaces.OnPermissionExplanationListener;
import com.mansourappdevelopment.androidapp.kidsafe.services.MainForegroundService;
import com.mansourappdevelopment.androidapp.kidsafe.utils.Constant;
import com.mansourappdevelopment.androidapp.kidsafe.utils.SharedPrefsUtils;
import com.mansourappdevelopment.androidapp.kidsafe.utils.Validators;

public class ChildSignedInActivity extends AppCompatActivity {
public class ChildSignedInActivity extends AppCompatActivity implements OnPermissionExplanationListener, OnPasswordValidationListener {
public static final int JOB_ID = 38;
public static final String CHILD_EMAIL = "childEmail";
private static final String TAG = "ChildSignedInTAG";
Expand All @@ -35,8 +43,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_child_signed_in);

boolean childFirstLaunch = SharedPrefsUtils.getBooleanPreference(this, Constant.CHILD_FIRST_LAUNCH, true);
if (childFirstLaunch)
startActivity(new Intent(this, PermissionsActivity.class));
if (childFirstLaunch) startActivity(new Intent(this, PermissionsActivity.class));
else {

auth = FirebaseAuth.getInstance();
Expand All @@ -46,22 +53,27 @@ protected void onCreate(Bundle savedInstanceState) {
/*PersistableBundle bundle = new PersistableBundle();
bundle.putString(CHILD_EMAIL, email);*/

toolbar = (FrameLayout) findViewById(R.id.toolbar);
btnBack = (ImageButton) findViewById(R.id.btnBack);
toolbar = findViewById(R.id.toolbar);
btnBack = findViewById(R.id.btnBack);
btnBack.setImageDrawable(getResources().getDrawable(R.drawable.ic_home_));
btnSettings = (ImageButton) findViewById(R.id.btnSettings);
btnSettings = findViewById(R.id.btnSettings);
btnSettings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ChildSignedInActivity.this, SettingsActivity.class);
startActivity(intent);
startPasswordValidationDialogFragment();
}
});
txtTitle = (TextView) findViewById(R.id.txtTitle);
txtTitle = findViewById(R.id.txtTitle);
txtTitle.setText(getString(R.string.home));

//schedualJob(bundle);
startMainForegroundService(email);

if (!Validators.isLocationOn(this)) startPermissionExplanationDialogFragment();

if (!Validators.isInternetAvailable(this))
startInformationDialogFragment(getResources().getString(R.string.you_re_offline_ncheck_your_connection_and_try_again));

}
}

Expand All @@ -72,6 +84,24 @@ private void startMainForegroundService(String email) {

}

private void startPermissionExplanationDialogFragment() {
PermissionExplanationDialogFragment permissionExplanationDialogFragment = new PermissionExplanationDialogFragment();
Bundle bundle = new Bundle();
bundle.putInt(Constant.PERMISSION_REQUEST_CODE, Constant.CHILD_LOCATION_PERMISSION_REQUEST_CODE);
permissionExplanationDialogFragment.setArguments(bundle);
permissionExplanationDialogFragment.setCancelable(false);
permissionExplanationDialogFragment.show(getSupportFragmentManager(), Constant.PERMISSION_EXPLANATION_FRAGMENT_TAG);
}

private void startInformationDialogFragment(String message) {
InformationDialogFragment informationDialogFragment = new InformationDialogFragment();
Bundle bundle = new Bundle();
bundle.putString(Constant.INFORMATION_MESSAGE, message);
informationDialogFragment.setArguments(bundle);
informationDialogFragment.setCancelable(false);
informationDialogFragment.show(getSupportFragmentManager(), Constant.INFORMATION_DIALOG_FRAGMENT_TAG);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Expand All @@ -86,9 +116,31 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
public void onBackPressed() {
super.onBackPressed();
}




@Override
public void onOk(int requestCode) {
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}

@Override
public void onCancel(int switchId) {
Toast.makeText(this, getString(R.string.canceled), Toast.LENGTH_SHORT).show();

}


private void startPasswordValidationDialogFragment() {
PasswordValidationDialogFragment passwordValidationDialogFragment = new PasswordValidationDialogFragment();
passwordValidationDialogFragment.setCancelable(false);
passwordValidationDialogFragment.show(getSupportFragmentManager(), Constant.PASSWORD_VALIDATION_DIALOG_FRAGMENT_TAG);
}

@Override
public void onValidationOk() {
Intent intent = new Intent(ChildSignedInActivity.this, SettingsActivity.class);
startActivity(intent);
}

/*@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void schedualJob(PersistableBundle bundle) {
ComponentName componentName = new ComponentName(this, UploadAppsService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ protected void onStart() {
String email = user.getEmail();
checkMode(email);
}
} else startInformationDialogFragment(getResources().getString(R.string.you_re_offline_ncheck_your_connection_and_try_again));
} else
startInformationDialogFragment(getResources().getString(R.string.you_re_offline_ncheck_your_connection_and_try_again));
}
}

Expand All @@ -182,8 +183,9 @@ public void onComplete(@NonNull Task<AuthResult> task) {
FirebaseUser user = auth.getCurrentUser();
String email = user.getEmail();
/*if (Validators.isVerified(user))*/
checkMode(email);
//else startAccountVerificationActivity();
checkMode(email);
/*else
startAccountVerificationActivity();*/
} else {
String errorCode;
try {
Expand Down Expand Up @@ -283,6 +285,11 @@ private void startChildSignedInActivity() {
startActivity(intent);
}

private void startAccountVerificationActivity() {
Intent intent = new Intent(this, AccountVerificationActivity.class);
startActivity(intent);
}

private void startModeSelectionActivity() {
Intent intent = new Intent(this, ModeSelectionActivity.class);
startActivity(intent);
Expand All @@ -302,15 +309,11 @@ private void signInWithGoogle() {
GoogleSignInClient googleSignInClient = GoogleSignIn.getClient(this, googleSignInOptions);
Intent signInIntent = googleSignInClient.getSignInIntent();
startActivityForResult(signInIntent, Constant.RC_SIGN_IN);
} else startInformationDialogFragment(getResources().getString(R.string.you_re_offline_ncheck_your_connection_and_try_again));
} else
startInformationDialogFragment(getResources().getString(R.string.you_re_offline_ncheck_your_connection_and_try_again));

}

private void startAccountVerificationActivity() {
Intent intent = new Intent(this, AccountVerificationActivity.class);
startActivity(intent);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Expand Down
Loading

0 comments on commit 8ff2785

Please sign in to comment.