Initial commit.
This commit is contained in:
commit
c75135f288
10 changed files with 153 additions and 0 deletions
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/bin
|
||||
/gen
|
||||
/project.properties
|
||||
/proguard-project.txt
|
||||
/.classpath
|
||||
/.project
|
27
AndroidManifest.xml
Normal file
27
AndroidManifest.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="net.thauvin.erik.android.avion"
|
||||
android:installLocation="auto"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="13" />
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||
|
||||
<application
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.Holo.Light.Dialog.NoActionBar.MinWidth" >
|
||||
<activity
|
||||
android:name=".AvionActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
BIN
avion.png
Normal file
BIN
avion.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
BIN
res/drawable-hdpi/ic_launcher.png
Normal file
BIN
res/drawable-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
BIN
res/drawable-ldpi/ic_launcher.png
Normal file
BIN
res/drawable-ldpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
res/drawable-mdpi/ic_launcher.png
Normal file
BIN
res/drawable-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
res/drawable-xhdpi/ic_launcher.png
Normal file
BIN
res/drawable-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
9
res/values-fr/strings.xml
Normal file
9
res/values-fr/strings.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Avion</string>
|
||||
<string name="title">Mode Avion</string>
|
||||
<string name="activated">Mode Avion activée</string>
|
||||
<string name="deactivated">Mode Avion désactivé</string>
|
||||
<string name="ok">OK</string>
|
||||
|
||||
</resources>
|
9
res/values/strings.xml
Normal file
9
res/values/strings.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Plane</string>
|
||||
<string name="title">Airplane Mode</string>
|
||||
<string name="activated">Airplane Mode activated</string>
|
||||
<string name="deactivated">Airplane Mode deactivated</string>
|
||||
<string name="ok">OK</string>
|
||||
|
||||
</resources>
|
102
src/net/thauvin/erik/android/avion/AvionActivity.java
Normal file
102
src/net/thauvin/erik/android/avion/AvionActivity.java
Normal file
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* AvionActivity.java
|
||||
*
|
||||
* Copyright (c) 2012 Erik C. Thauvin (http://erik.thauvin.net/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
package net.thauvin.erik.android.avion;
|
||||
|
||||
/**
|
||||
* The <code>AvionActivity</code> class implements an airplane mode toggler.
|
||||
*
|
||||
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
||||
* @created May 20, 2012
|
||||
* @since 1.0
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
|
||||
public class AvionActivity extends Activity
|
||||
{
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Get the airplane mode status
|
||||
boolean isEnabled = (Settings.System.getInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 1);
|
||||
|
||||
// Toggle airplane mode
|
||||
Settings.System.putInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1);
|
||||
|
||||
// Send intent to refresh status
|
||||
final Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||
intent.putExtra("state", !isEnabled);
|
||||
sendBroadcast(intent);
|
||||
|
||||
// Create Dialog
|
||||
final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
|
||||
|
||||
// Set Dialog Icon
|
||||
alertDialog.setIcon(R.drawable.ic_launcher);
|
||||
|
||||
// Set Dialog Title
|
||||
alertDialog.setTitle(R.string.title);
|
||||
|
||||
// Set Dialog Message
|
||||
if (isEnabled)
|
||||
{
|
||||
alertDialog.setMessage(getString(R.string.deactivated));
|
||||
}
|
||||
else
|
||||
{
|
||||
alertDialog.setMessage(getString(R.string.activated));
|
||||
}
|
||||
|
||||
// Set OK button
|
||||
alertDialog.setButton(getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
// Terminate activity
|
||||
AvionActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
// Show Alert Message
|
||||
alertDialog.show();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue