-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds information about cellular terms to an info dialog
- Loading branch information
1 parent
e1799e3
commit f6a9f04
Showing
9 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.appcompat.app.AlertDialog; | ||
import androidx.core.app.ActivityCompat; | ||
import androidx.lifecycle.LifecycleOwner; | ||
import androidx.lifecycle.ViewModelProvider; | ||
|
@@ -111,6 +112,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c | |
|
||
initializeLocationTextView(); | ||
|
||
initializeUiListeners(); | ||
|
||
initializeObservers(); | ||
|
||
return binding.getRoot(); | ||
|
@@ -199,6 +202,14 @@ public void onLocationChanged(@NonNull Location location) | |
viewModel.setLocation(location); | ||
} | ||
|
||
/** | ||
* Initialize the UI listeners for the various buttons and other UI elements. | ||
*/ | ||
private void initializeUiListeners() | ||
{ | ||
binding.cellularInfoIcon.setOnClickListener(c -> showCellularInfoDialog()); | ||
} | ||
|
||
/** | ||
* Initialize the model view observers. These observers look for changes to the model view | ||
* values, and then update the UI based on any changes. | ||
|
@@ -1034,4 +1045,57 @@ private void addValueToRow(Context context, TableRow row, int value) | |
view.setText(cellText); | ||
row.addView(view); | ||
} | ||
|
||
/** | ||
* Displays a dialog with some information about cellular terms. | ||
*/ | ||
private void showCellularInfoDialog() | ||
{ | ||
final Context context = getContext(); | ||
if (context == null) return; | ||
|
||
CellularProtocol protocol = viewModel.getServingCellProtocol().getValue(); | ||
|
||
// Default to LTE as a fallback | ||
String cellularInfoTitle = getString(R.string.lte_info_description); | ||
CharSequence cellularInfoBody = getString(R.string.lte_cellular_terms_explanation); | ||
|
||
if (protocol == null) protocol = CellularProtocol.LTE; | ||
switch (protocol) | ||
{ | ||
case NONE, LTE -> | ||
{ | ||
cellularInfoTitle = getString(R.string.lte_info_description); | ||
cellularInfoBody = getText(R.string.lte_cellular_terms_explanation); | ||
} | ||
case GSM -> | ||
{ | ||
cellularInfoTitle = getString(R.string.gsm_info_description); | ||
cellularInfoBody = getText(R.string.gsm_cellular_terms_explanation); | ||
} | ||
case CDMA -> | ||
{ | ||
cellularInfoTitle = "How did you find CDMA?"; | ||
cellularInfoBody = "CDMA is no longer supported. I am impressed you were able to find a CDMA network! Honestly, send me an email at [email protected] and let me know where you found it."; | ||
} | ||
case UMTS -> | ||
{ | ||
cellularInfoTitle = getString(R.string.umts_info_description); | ||
cellularInfoBody = getText(R.string.umts_cellular_terms_explanation); | ||
} | ||
case NR -> | ||
{ | ||
cellularInfoTitle = getString(R.string.nr_info_description); | ||
cellularInfoBody = getText(R.string.nr_cellular_terms_explanation); | ||
} | ||
} | ||
|
||
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context); | ||
alertBuilder.setCancelable(true); | ||
alertBuilder.setTitle(cellularInfoTitle); | ||
alertBuilder.setMessage(cellularInfoBody); | ||
alertBuilder.setPositiveButton(android.R.string.ok, (dialog, which) -> { | ||
}); | ||
alertBuilder.create().show(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24" | ||
android:tint="#FFFFFF" | ||
android:alpha="0.8"> | ||
<group | ||
android:scaleX="1.2" | ||
android:scaleY="1.2" | ||
android:translateX="-2.4" | ||
android:translateY="-2.4"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M11,7h2v2h-2V7zM11,11h2v6h-2V11zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10s10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8s8,3.59 8,8S16.41,20 12,20z" /> | ||
</group> | ||
</vector> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters