Remove excessive permissions

This commit is contained in:
serso 2016-03-23 21:39:05 +01:00
parent 72b333681c
commit ea61997f07
5 changed files with 11 additions and 46 deletions

View File

@ -7,12 +7,10 @@
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.android.vending.BILLING" /> <uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<!-- for onscreen --> <!-- for onscreen -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<supports-screens android:smallScreens="true" /> <supports-screens android:smallScreens="true" />
<supports-screens android:normalScreens="true" /> <supports-screens android:normalScreens="true" />
@ -159,16 +157,15 @@
android:name=".floating.FloatingCalculatorService" android:name=".floating.FloatingCalculatorService"
android:exported="false"> android:exported="false">
<intent-filter> <intent-filter>
<action android:name="org.solovyev.android.calculator.onscreen.SHOW_WINDOW" /> <action android:name="org.solovyev.android.calculator.floating.SHOW_WINDOW" />
<action android:name="org.solovyev.android.calculator.onscreen.SHOW_NOTIFICATION" /> <action android:name="org.solovyev.android.calculator.floating.SHOW_NOTIFICATION" />
</intent-filter> </intent-filter>
</service> </service>
<receiver android:name=".floating.FloatingCalculatorBroadcastReceiver"> <receiver android:name=".floating.FloatingCalculatorBroadcastReceiver" android:exported="false">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="org.solovyev.android.calculator.floating.SHOW_WINDOW" />
<action android:name="org.solovyev.android.calculator.onscreen.SHOW_WINDOW" /> <action android:name="org.solovyev.android.calculator.floating.SHOW_NOTIFICATION" />
<action android:name="org.solovyev.android.calculator.onscreen.SHOW_NOTIFICATION" />
</intent-filter> </intent-filter>
</receiver> </receiver>

View File

@ -142,7 +142,6 @@ public final class Preferences {
Calculations.preferredNumeralBase.tryPutDefault(preferences, editor); Calculations.preferredNumeralBase.tryPutDefault(preferences, editor);
Onscreen.showAppIcon.tryPutDefault(preferences, editor); Onscreen.showAppIcon.tryPutDefault(preferences, editor);
Onscreen.startOnBoot.tryPutDefault(preferences, editor);
Onscreen.theme.tryPutDefault(preferences, editor); Onscreen.theme.tryPutDefault(preferences, editor);
Widget.theme.tryPutDefault(preferences, editor); Widget.theme.tryPutDefault(preferences, editor);
@ -252,7 +251,6 @@ public final class Preferences {
} }
public static class Onscreen { public static class Onscreen {
public static final Preference<Boolean> startOnBoot = BooleanPreference.of("onscreen_start_on_boot", false);
public static final Preference<Boolean> showAppIcon = BooleanPreference.of("onscreen_show_app_icon", true); public static final Preference<Boolean> showAppIcon = BooleanPreference.of("onscreen_show_app_icon", true);
public static final Preference<SimpleTheme> theme = StringPreference.ofEnum("onscreen.theme", SimpleTheme.default_theme, SimpleTheme.class); public static final Preference<SimpleTheme> theme = StringPreference.ofEnum("onscreen.theme", SimpleTheme.default_theme, SimpleTheme.class);
@ -425,5 +423,6 @@ public final class Preferences {
static final Preference<Boolean> usePrevAsBack = BooleanPreference.of("org.solovyev.android.calculator.CalculatorActivity_use_back_button_as_prev", false); static final Preference<Boolean> usePrevAsBack = BooleanPreference.of("org.solovyev.android.calculator.CalculatorActivity_use_back_button_as_prev", false);
static final Preference<Boolean> showEqualsButton = BooleanPreference.of("showEqualsButton", true); static final Preference<Boolean> showEqualsButton = BooleanPreference.of("showEqualsButton", true);
static final Preference<Boolean> autoOrientation = BooleanPreference.of("autoOrientation", true); static final Preference<Boolean> autoOrientation = BooleanPreference.of("autoOrientation", true);
static final Preference<Boolean> startOnBoot = BooleanPreference.of("onscreen_start_on_boot", false);
} }
} }

View File

@ -25,39 +25,19 @@ package org.solovyev.android.calculator.floating;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.ga.Ga;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.inject.Inject;
import static org.solovyev.android.calculator.App.cast;
public final class FloatingCalculatorBroadcastReceiver extends BroadcastReceiver { public final class FloatingCalculatorBroadcastReceiver extends BroadcastReceiver {
@Inject
SharedPreferences preferences;
@Inject
Ga ga;
public FloatingCalculatorBroadcastReceiver() { public FloatingCalculatorBroadcastReceiver() {
} }
@Override @Override
public void onReceive(@Nonnull Context context, public void onReceive(@Nonnull Context context,
@Nonnull Intent intent) { @Nonnull Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { final Intent newIntent = new Intent(intent);
cast(context).getComponent().inject(this); newIntent.setClass(context, FloatingCalculatorService.class);
if (Preferences.Onscreen.startOnBoot.getPreferenceNoError(preferences)) { context.startService(newIntent);
FloatingCalculatorService.showNotification(context);
ga.onBootStart();
}
} else {
final Intent newIntent = new Intent(intent);
newIntent.setClass(context, FloatingCalculatorService.class);
context.startService(newIntent);
}
} }
} }

View File

@ -46,8 +46,8 @@ import static org.solovyev.android.calculator.App.cast;
public class FloatingCalculatorService extends Service implements FloatingViewListener, SharedPreferences.OnSharedPreferenceChangeListener { public class FloatingCalculatorService extends Service implements FloatingViewListener, SharedPreferences.OnSharedPreferenceChangeListener {
private static final String SHOW_WINDOW_ACTION = "org.solovyev.android.calculator.onscreen.SHOW_WINDOW"; private static final String SHOW_WINDOW_ACTION = "org.solovyev.android.calculator.floating.SHOW_WINDOW";
private static final String SHOW_NOTIFICATION_ACTION = "org.solovyev.android.calculator.onscreen.SHOW_NOTIFICATION"; private static final String SHOW_NOTIFICATION_ACTION = "org.solovyev.android.calculator.floating.SHOW_NOTIFICATION";
private static final int NOTIFICATION_ID = 9031988; // my birthday =) private static final int NOTIFICATION_ID = 9031988; // my birthday =)
private FloatingCalculatorView view; private FloatingCalculatorView view;
@ -63,12 +63,6 @@ public class FloatingCalculatorService extends Service implements FloatingViewLi
@Inject @Inject
SharedPreferences preferences; SharedPreferences preferences;
public static void showNotification(@Nonnull Context context) {
final Intent intent = new Intent(SHOW_NOTIFICATION_ACTION);
intent.setClass(context, FloatingCalculatorBroadcastReceiver.class);
context.sendBroadcast(intent);
}
public static void show(@Nonnull Context context) { public static void show(@Nonnull Context context) {
context.sendBroadcast(createShowWindowIntent(context)); context.sendBroadcast(createShowWindowIntent(context));
} }

View File

@ -30,11 +30,6 @@
a:key="onscreen.theme" a:key="onscreen.theme"
a:title="@string/c_calc_theme" /> a:title="@string/c_calc_theme" />
<android.preference.CheckBoxPreference
a:key="onscreen_start_on_boot"
a:summary="@string/prefs_onscreen_start_on_boot_summary"
a:title="@string/prefs_onscreen_start_on_boot_title" />
<android.preference.CheckBoxPreference <android.preference.CheckBoxPreference
a:key="onscreen_show_app_icon" a:key="onscreen_show_app_icon"
a:summary="@string/prefs_onscreen_show_app_icon_summary" a:summary="@string/prefs_onscreen_show_app_icon_summary"