Showing
1 changed file
with
0 additions
and
66 deletions
| 1 | package ly.warp.sdk.activities; | 1 | package ly.warp.sdk.activities; | 
| 2 | 2 | ||
| 3 | -import android.app.AlertDialog; | ||
| 4 | -import android.content.pm.PackageManager; | ||
| 5 | -import android.os.Build; | ||
| 6 | import android.os.Bundle; | 3 | import android.os.Bundle; | 
| 7 | import android.view.MenuItem; | 4 | import android.view.MenuItem; | 
| 8 | -import android.widget.Toast; | ||
| 9 | 5 | ||
| 10 | import androidx.annotation.NonNull; | 6 | import androidx.annotation.NonNull; | 
| 11 | -import androidx.core.app.ActivityCompat; | ||
| 12 | -import androidx.core.content.ContextCompat; | ||
| 13 | import androidx.fragment.app.Fragment; | 7 | import androidx.fragment.app.Fragment; | 
| 14 | import androidx.fragment.app.FragmentActivity; | 8 | import androidx.fragment.app.FragmentActivity; | 
| 15 | 9 | ||
| 16 | import com.google.android.material.bottomnavigation.BottomNavigationView; | 10 | import com.google.android.material.bottomnavigation.BottomNavigationView; | 
| 17 | import com.google.android.material.navigation.NavigationBarView; | 11 | import com.google.android.material.navigation.NavigationBarView; | 
| 18 | 12 | ||
| 19 | -import java.util.ArrayList; | ||
| 20 | - | ||
| 21 | import ly.warp.sdk.R; | 13 | import ly.warp.sdk.R; | 
| 22 | -import ly.warp.sdk.db.WarplyDBHelper; | ||
| 23 | import ly.warp.sdk.fragments.HomeFragment; | 14 | import ly.warp.sdk.fragments.HomeFragment; | 
| 24 | -import ly.warp.sdk.io.callbacks.CallbackReceiver; | ||
| 25 | -import ly.warp.sdk.io.models.Campaign; | ||
| 26 | -import ly.warp.sdk.io.models.RedeemedSMHistoryModel; | ||
| 27 | -import ly.warp.sdk.utils.managers.WarplyManager; | ||
| 28 | 15 | ||
| 29 | public class BaseFragmentActivity extends FragmentActivity implements NavigationBarView.OnItemSelectedListener { | 16 | public class BaseFragmentActivity extends FragmentActivity implements NavigationBarView.OnItemSelectedListener { | 
| 30 | 17 | ||
| ... | @@ -38,7 +25,6 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | ... | @@ -38,7 +25,6 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | 
| 38 | 25 | ||
| 39 | private BottomNavigationView mBottomNavigationView; | 26 | private BottomNavigationView mBottomNavigationView; | 
| 40 | private Fragment mFragmentToSet = null; | 27 | private Fragment mFragmentToSet = null; | 
| 41 | - private static final int REQUEST_NOTIFICATION_PERMISSION = 5000; | ||
| 42 | 28 | ||
| 43 | // =========================================================== | 29 | // =========================================================== | 
| 44 | // Methods for/from SuperClass/Interfaces | 30 | // Methods for/from SuperClass/Interfaces | 
| ... | @@ -50,16 +36,6 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | ... | @@ -50,16 +36,6 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | 
| 50 | setContentView(R.layout.activity_base_fragment); | 36 | setContentView(R.layout.activity_base_fragment); | 
| 51 | 37 | ||
| 52 | mBottomNavigationView = findViewById(R.id.bt_tabs); | 38 | mBottomNavigationView = findViewById(R.id.bt_tabs); | 
| 53 | - | ||
| 54 | - if (WarplyDBHelper.getInstance(this).isTableNotEmpty("auth")) { | ||
| 55 | - WarplyManager.getRedeemedSMHistory(mSMHistoryReceiver); | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | ||
| 59 | - if (!hasNotificationPermission()) { | ||
| 60 | - requestNotificationPermission(); | ||
| 61 | - } | ||
| 62 | - } | ||
| 63 | } | 39 | } | 
| 64 | 40 | ||
| 65 | @Override | 41 | @Override | 
| ... | @@ -92,18 +68,6 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | ... | @@ -92,18 +68,6 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | 
| 92 | return false; | 68 | return false; | 
| 93 | } | 69 | } | 
| 94 | 70 | ||
| 95 | - @Override | ||
| 96 | - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | ||
| 97 | - super.onRequestPermissionsResult(requestCode, permissions, grantResults); | ||
| 98 | - if (requestCode == REQUEST_NOTIFICATION_PERMISSION) { | ||
| 99 | - if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | ||
| 100 | - Toast.makeText(BaseFragmentActivity.this, "Notifications Permission Granted", Toast.LENGTH_SHORT).show(); | ||
| 101 | - } else { | ||
| 102 | - Toast.makeText(BaseFragmentActivity.this, "Notifications Permission Denied", Toast.LENGTH_SHORT).show(); | ||
| 103 | - } | ||
| 104 | - } | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | // =========================================================== | 71 | // =========================================================== | 
| 108 | // Methods | 72 | // Methods | 
| 109 | // =========================================================== | 73 | // =========================================================== | 
| ... | @@ -115,37 +79,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | ... | @@ -115,37 +79,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | 
| 115 | mBottomNavigationView.setSelectedItemId(R.id.menu_home); | 79 | mBottomNavigationView.setSelectedItemId(R.id.menu_home); | 
| 116 | } | 80 | } | 
| 117 | 81 | ||
| 118 | - private boolean hasNotificationPermission() { | ||
| 119 | - return ContextCompat.checkSelfPermission(this, android.Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED; | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - private void requestNotificationPermission() { | ||
| 123 | - if (ActivityCompat.shouldShowRequestPermissionRationale(this, android.Manifest.permission.POST_NOTIFICATIONS)) { | ||
| 124 | - new AlertDialog.Builder(this) | ||
| 125 | - .setTitle("Notification Permission Needed") | ||
| 126 | - .setMessage("This app needs the Notification permission to keep you updated.") | ||
| 127 | - .setPositiveButton("OK", (dialog, which) -> ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.POST_NOTIFICATIONS}, REQUEST_NOTIFICATION_PERMISSION)) | ||
| 128 | - .setNegativeButton("Cancel", (dialog, which) -> dialog.dismiss()) | ||
| 129 | - .create() | ||
| 130 | - .show(); | ||
| 131 | - } else { | ||
| 132 | - ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.POST_NOTIFICATIONS}, REQUEST_NOTIFICATION_PERMISSION); | ||
| 133 | - } | ||
| 134 | - } | ||
| 135 | - | ||
| 136 | // =========================================================== | 82 | // =========================================================== | 
| 137 | // Inner and Anonymous Classes | 83 | // Inner and Anonymous Classes | 
| 138 | // =========================================================== | 84 | // =========================================================== | 
| 139 | - | ||
| 140 | - private final CallbackReceiver<RedeemedSMHistoryModel> mSMHistoryReceiver = new CallbackReceiver<RedeemedSMHistoryModel>() { | ||
| 141 | - @Override | ||
| 142 | - public void onSuccess(RedeemedSMHistoryModel result) { | ||
| 143 | - Toast.makeText(BaseFragmentActivity.this, "SM HISTORY SUCCESS", Toast.LENGTH_SHORT).show(); | ||
| 144 | - } | ||
| 145 | - | ||
| 146 | - @Override | ||
| 147 | - public void onFailure(int errorCode) { | ||
| 148 | - Toast.makeText(BaseFragmentActivity.this, "SM HISTORY ERROR", Toast.LENGTH_SHORT).show(); | ||
| 149 | - } | ||
| 150 | - }; | ||
| 151 | } | 85 | } | ... | ... | 
- 
Please register or login to post a comment
