Skip to content

Commit 6974a00

Browse files
committed
Added descriptions for permission on StartActivity
1 parent af4f580 commit 6974a00

File tree

5 files changed

+123
-30
lines changed

5 files changed

+123
-30
lines changed

.idea/deploymentTargetSelector.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/noti/main/StartActivity.java

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public class StartActivity extends AppCompatActivity {
6464
MaterialButton Permit_Privacy;
6565
MaterialButton Permit_Collect_Data;
6666
MaterialCheckBox Skip_Alarm;
67+
MaterialCheckBox Skip_Location;
6768

6869
ActivityResultLauncher<Intent> startOverlayPermit = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
6970
if(Build.VERSION.SDK_INT < 29 || Settings.canDrawOverlays(this)) {
@@ -74,7 +75,7 @@ public class StartActivity extends AppCompatActivity {
7475

7576
ActivityResultLauncher<Intent> startBatteryOptimizations = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
7677
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
77-
if (Build.VERSION.SDK_INT < 23 || pm.isIgnoringBatteryOptimizations(getPackageName())) {
78+
if (pm.isIgnoringBatteryOptimizations(getPackageName())) {
7879
setButtonCompleted(this, Permit_Battery);
7980
checkPermissionsAndEnableComplete();
8081
}
@@ -130,6 +131,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
130131
Permit_Privacy = findViewById(R.id.Permit_Privacy);
131132
Permit_Collect_Data = findViewById(R.id.Permit_Collect_Data);
132133
Skip_Alarm = findViewById(R.id.Skip_Alarm);
134+
Skip_Location = findViewById(R.id.Skip_Location);
133135
Start_App = findViewById(R.id.Start_App);
134136

135137
int count = 0;
@@ -145,7 +147,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
145147
}
146148

147149
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
148-
if (Build.VERSION.SDK_INT < 23 || isTelevisionsEnabled || pm.isIgnoringBatteryOptimizations(getPackageName())) {
150+
if (isTelevisionsEnabled || pm.isIgnoringBatteryOptimizations(getPackageName())) {
149151
setButtonCompleted(this, Permit_Battery);
150152
count++;
151153
}
@@ -162,16 +164,21 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
162164
count++;
163165
}
164166

165-
boolean isFineLocation = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
166-
boolean isCoarseLocation = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
167-
if(isCoarseLocation || isFineLocation) {
168-
setButtonCompleted(this, Permit_Location);
169-
count++;
170-
}
167+
if(prefs.getBoolean("SkipLocationAccessPermission", false)) {
168+
Skip_Location.setChecked(true);
169+
count += 2;
170+
} else {
171+
boolean isFineLocation = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
172+
boolean isCoarseLocation = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
173+
if(isCoarseLocation || isFineLocation) {
174+
setButtonCompleted(this, Permit_Location);
175+
count++;
176+
}
171177

172-
if(Build.VERSION.SDK_INT < 29 || ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_BACKGROUND_LOCATION) == PackageManager.PERMISSION_GRANTED) {
173-
setButtonCompleted(this, Permit_Background_Location);
174-
count++;
178+
if(Build.VERSION.SDK_INT < 29 || ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_BACKGROUND_LOCATION) == PackageManager.PERMISSION_GRANTED) {
179+
setButtonCompleted(this, Permit_Background_Location);
180+
count++;
181+
}
175182
}
176183

177184
if(prefs.getBoolean("SkipAlarmAccessPermission", false)) {
@@ -232,12 +239,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
232239
}
233240

234241
Permit_Notification.setOnClickListener((v) -> ActivityCompat.requestPermissions(this, new String[] { "android.permission.POST_NOTIFICATIONS" }, 100));
235-
Permit_Overlay.setOnClickListener((v) -> {
236-
if (Build.VERSION.SDK_INT > 22) startOverlayPermit.launch(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
237-
});
238-
Permit_Battery.setOnClickListener((v) -> {
239-
if (Build.VERSION.SDK_INT > 22) startBatteryOptimizations.launch(new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS).setData(Uri.parse("package:" + getPackageName())));
240-
});
242+
Permit_Overlay.setOnClickListener((v) -> startOverlayPermit.launch(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)));
243+
Permit_Battery.setOnClickListener((v) -> startBatteryOptimizations.launch(new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS).setData(Uri.parse("package:" + getPackageName()))));
241244
Permit_Alarm.setOnClickListener((v) -> startAlarmAccessPermit.launch(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS")));
242245
Permit_File.setOnClickListener((v) -> ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 101));
243246
Permit_Location.setOnClickListener((v) -> locationPermissionRequest.launch(new String[] {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}));
@@ -298,6 +301,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
298301
checkPermissionsAndEnableComplete();
299302
prefs.edit().putBoolean("SkipAlarmAccessPermission", b).apply();
300303
});
304+
Skip_Location.setOnCheckedChangeListener((compoundButton, b) -> {
305+
checkPermissionsAndEnableComplete();
306+
prefs.edit().putBoolean("SkipLocationAccessPermission", b).apply();
307+
});
301308
Start_App.setOnClickListener((v) -> {
302309
boolean isBadCondition = Permit_Notification.isEnabled();
303310

@@ -321,11 +328,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
321328
isBadCondition = true;
322329
}
323330

324-
if(Permit_Location.isEnabled()) {
325-
isBadCondition = true;
326-
}
327-
328-
if(Permit_Background_Location.isEnabled()) {
331+
if((Permit_Location.isEnabled() || Permit_Background_Location.isEnabled()) && !Skip_Location.isChecked()) {
329332
isBadCondition = true;
330333
}
331334

@@ -345,7 +348,11 @@ void setButtonCompleted(Context context, MaterialButton button) {
345348
}
346349

347350
void checkPermissionsAndEnableComplete() {
348-
Start_App.setEnabled(!Permit_Notification.isEnabled() && !Permit_Battery.isEnabled() && !Permit_File.isEnabled() && !Permit_Overlay.isEnabled() && (!Permit_Alarm.isEnabled() || Skip_Alarm.isChecked()) && !Permit_Privacy.isEnabled() && !Permit_Collect_Data.isEnabled());
351+
Start_App.setEnabled(!Permit_Notification.isEnabled()
352+
&& !Permit_Battery.isEnabled() && !Permit_File.isEnabled() && !Permit_Overlay.isEnabled()
353+
&& (!(Permit_Location.isEnabled() || Permit_Background_Location.isEnabled()) || Skip_Location.isChecked())
354+
&& (!Permit_Alarm.isEnabled() || Skip_Alarm.isChecked())
355+
&& !Permit_Privacy.isEnabled() && !Permit_Collect_Data.isEnabled());
349356
}
350357

351358
@Override

app/src/main/java/com/noti/main/ui/pair/action/LiveNotificationActivity.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public class LiveNotificationActivity extends AppCompatActivity {
4848
TextView liveNotiStateDescription;
4949
ProgressBar liveNotiStateProgress;
5050

51+
final String BLANK_INFO_TEXT = "There are currently no notifications\ndisplayed on your device.";
52+
5153
@SuppressLint("SetTextI18n")
5254
@Override
5355
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -185,6 +187,11 @@ public LiveNotiItemHolder(Context context, LiveNotificationData liveNotification
185187

186188
dismissButton.setOnClickListener((v) -> {
187189
liveNotiLayout.removeView(liveNotiItem);
190+
191+
if(liveNotiLayout.getChildCount() == 0) {
192+
showError(BLANK_INFO_TEXT, true);
193+
}
194+
188195
if(lastSelectedItemHolder == this) {
189196
lastSelectedItemHolder = null;
190197
}
@@ -232,10 +239,10 @@ private void makeListView(LiveNotificationData[] liveNotificationList) {
232239
if(liveNotificationCount > 0) {
233240
setNotiListVisibility(true);
234241
} else {
235-
showError("There are currently no notifications\ndisplayed on your device.", true);
242+
showError(BLANK_INFO_TEXT, true);
236243
}
237244
} else {
238-
showError("There are currently no notifications\ndisplayed on your device.", true);
245+
showError(BLANK_INFO_TEXT, true);
239246
}
240247
}
241248

app/src/main/res/layout/activity_start.xml

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,35 @@
5959
android:layout_width="match_parent"
6060
android:layout_height="match_parent"
6161
android:layout_marginHorizontal="24dp"
62+
android:layout_marginVertical="8dp"
6263
android:fontFamily="@font/sans"
6364
android:text="Before we start,\nWe need to grant some permissions."
6465
android:textSize="20sp" />
6566

67+
<TextView
68+
android:layout_width="wrap_content"
69+
android:layout_height="wrap_content"
70+
android:layout_gravity="start"
71+
android:layout_marginHorizontal="24dp"
72+
android:layout_marginVertical="15dp"
73+
android:text="Notification permissions"
74+
android:textColor="@color/ui_accent" />
75+
<TextView
76+
android:layout_width="match_parent"
77+
android:layout_height="wrap_content"
78+
android:layout_marginHorizontal="24dp"
79+
android:layout_marginBottom="15dp"
80+
android:fontFamily="@font/sans"
81+
android:text="This permission is required for NotiSender to allow read, mirror, and post notifications on device."
82+
android:textColor="@color/ui_fg_secondary" />
83+
6684
<com.google.android.material.button.MaterialButton
6785
android:id="@+id/Permit_Notification"
6886
android:layout_width="match_parent"
6987
android:layout_height="wrap_content"
7088
android:text="Notification Permission"
7189
android:gravity="center"
7290
android:layout_gravity="center"
73-
android:layout_marginTop="24dp"
7491
android:layout_marginHorizontal="24dp"
7592
android:background="@drawable/round_corner"
7693
android:textColor="@color/ui_bg"
@@ -99,14 +116,32 @@
99116
android:text="Skip Alarm access permission for now"
100117
android:gravity="center"/>
101118

119+
<TextView
120+
android:layout_width="wrap_content"
121+
android:layout_height="wrap_content"
122+
android:layout_gravity="start"
123+
android:layout_marginHorizontal="24dp"
124+
android:layout_marginVertical="15dp"
125+
android:text="Application Optimization permissions"
126+
android:textColor="@color/ui_accent" />
127+
128+
<TextView
129+
android:layout_width="match_parent"
130+
android:layout_height="wrap_content"
131+
android:layout_marginHorizontal="24dp"
132+
android:layout_marginBottom="15dp"
133+
android:fontFamily="@font/sans"
134+
android:text="This permission is required to allow NotiSender to run in the background."
135+
android:textColor="@color/ui_fg_secondary" />
136+
102137
<com.google.android.material.button.MaterialButton
103138
android:id="@+id/Permit_Overlay"
104139
android:layout_width="match_parent"
105140
android:layout_height="wrap_content"
106141
android:text="Overlay Permission"
107142
android:gravity="center"
108143
android:layout_gravity="center"
109-
android:layout_marginVertical="12dp"
144+
android:layout_marginVertical="6dp"
110145
android:layout_marginHorizontal="24dp"
111146
android:textColor="@color/ui_bg"
112147
app:iconTint="@color/ui_bg"
@@ -141,6 +176,24 @@
141176
app:icon="@drawable/ic_fluent_folder_24_regular"
142177
android:background="@drawable/round_corner"/>
143178

179+
<TextView
180+
android:layout_width="wrap_content"
181+
android:layout_height="wrap_content"
182+
android:layout_gravity="start"
183+
android:layout_marginHorizontal="24dp"
184+
android:layout_marginVertical="15dp"
185+
android:text="Location Permissions"
186+
android:textColor="@color/ui_accent" />
187+
188+
<TextView
189+
android:layout_width="match_parent"
190+
android:layout_height="wrap_content"
191+
android:layout_marginHorizontal="24dp"
192+
android:layout_marginBottom="15dp"
193+
android:fontFamily="@font/sans"
194+
android:text="This permission is used to retrieve location information to remotely locate this device from another device.\n\nYou can choose not to grant this permission, but doing so will limit the ability to find locations."
195+
android:textColor="@color/ui_fg_secondary" />
196+
144197
<com.google.android.material.button.MaterialButton
145198
android:id="@+id/Permit_Location"
146199
android:layout_width="match_parent"
@@ -169,6 +222,32 @@
169222
app:icon="@drawable/ic_fluent_globe_location_24_regular"
170223
android:background="@drawable/round_corner"/>
171224

225+
<com.google.android.material.checkbox.MaterialCheckBox
226+
android:id="@+id/Skip_Location"
227+
android:layout_width="match_parent"
228+
android:layout_height="wrap_content"
229+
android:layout_marginHorizontal="24dp"
230+
android:text="Skip Location permission"
231+
android:gravity="center"/>
232+
233+
<TextView
234+
android:layout_width="wrap_content"
235+
android:layout_height="wrap_content"
236+
android:layout_gravity="start"
237+
android:layout_marginHorizontal="24dp"
238+
android:layout_marginVertical="15dp"
239+
android:text="Legal &amp; Regulatory "
240+
android:textColor="@color/ui_accent" />
241+
242+
<TextView
243+
android:layout_width="match_parent"
244+
android:layout_height="wrap_content"
245+
android:layout_marginHorizontal="24dp"
246+
android:layout_marginBottom="15dp"
247+
android:fontFamily="@font/sans"
248+
android:text="EULA that Norix Team and Google requires from its users. You can review this license at any time in the 'App Information' menu."
249+
android:textColor="@color/ui_fg_secondary" />
250+
172251
<com.google.android.material.button.MaterialButton
173252
android:id="@+id/Permit_Privacy"
174253
android:layout_width="match_parent"

0 commit comments

Comments
 (0)