Skip to content
This repository has been archived by the owner on Sep 19, 2019. It is now read-only.

Commit

Permalink
Auto-update
Browse files Browse the repository at this point in the history
  • Loading branch information
google-automerger committed May 17, 2017
1 parent 1667047 commit df0aa3a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Application/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.2.0'
}
}

Expand All @@ -32,7 +32,7 @@ List<String> dirs = [

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
buildToolsVersion "25.0.3"

defaultConfig {
minSdkVersion 21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

package com.example.android.apprestrictionschema;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.RestrictionEntry;
import android.content.RestrictionsManager;
import android.os.Build;
Expand Down Expand Up @@ -44,7 +47,7 @@
public class AppRestrictionSchemaFragment extends Fragment implements View.OnClickListener {

// Tag for the logger
private static final String TAG = "AppRestrictionSchemaFragment";
private static final String TAG = "AppRestrictionSchema";

private static final String KEY_CAN_SAY_HELLO = "can_say_hello";
private static final String KEY_MESSAGE = "message";
Expand All @@ -60,6 +63,9 @@ public class AppRestrictionSchemaFragment extends Fragment implements View.OnCli
// Message to show when the button is clicked (String restriction)
private String mMessage;

// Observes restriction changes
private BroadcastReceiver mBroadcastReceiver;

// UI Components
private TextView mTextSayHello;
private Button mButtonSayHello;
Expand Down Expand Up @@ -96,6 +102,28 @@ public void onResume() {
resolveRestrictions();
}

@Override
public void onStart() {
super.onStart();
mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
resolveRestrictions();
}
};
getActivity().registerReceiver(mBroadcastReceiver,
new IntentFilter(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED));
}

@Override
public void onStop() {
super.onStop();
if (mBroadcastReceiver != null) {
getActivity().unregisterReceiver(mBroadcastReceiver);
mBroadcastReceiver = null;
}
}

private void resolveRestrictions() {
RestrictionsManager manager =
(RestrictionsManager) getActivity().getSystemService(Context.RESTRICTIONS_SERVICE);
Expand Down
4 changes: 3 additions & 1 deletion Application/src/main/res/menu/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
limitations under the License.
-->

<menu xmlns:android="http://schemas.android.com/apk/res/android">
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="AppCompatResource">
<item android:id="@+id/menu_toggle_log"
android:showAsAction="always"
android:title="@string/sample_show_log" />
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Pre-requisites
--------------

- Android SDK 25
- Android Build Tools v25.0.2
- Android Build Tools v25.0.3
- Android Support Repository

Screenshots
Expand Down Expand Up @@ -84,7 +84,7 @@ submitting a pull request through GitHub. Please see CONTRIBUTING.md for more de
License
-------

Copyright 2016 The Android Open Source Project, Inc.
Copyright 2017 The Android Open Source Project, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip

0 comments on commit df0aa3a

Please sign in to comment.