-
This commit is contained in:
parent
6fcf2f3985
commit
ed1445dd4e
@ -4,10 +4,12 @@ import android.app.Activity;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -30,6 +32,7 @@ public class MainActivity extends Activity
|
|||||||
{
|
{
|
||||||
Button bExport;
|
Button bExport;
|
||||||
RadioButton rbRcs, rbSms, rbMms;
|
RadioButton rbRcs, rbSms, rbMms;
|
||||||
|
ProgressBar pbStatus;
|
||||||
|
|
||||||
final static int typeSMS = 0;
|
final static int typeSMS = 0;
|
||||||
final static int typeMMS = 1;
|
final static int typeMMS = 1;
|
||||||
@ -49,6 +52,7 @@ public class MainActivity extends Activity
|
|||||||
rbRcs = (RadioButton)findViewById(R.id.rbRcs);
|
rbRcs = (RadioButton)findViewById(R.id.rbRcs);
|
||||||
rbSms = (RadioButton)findViewById(R.id.rbSms);
|
rbSms = (RadioButton)findViewById(R.id.rbSms);
|
||||||
rbMms = (RadioButton)findViewById(R.id.rbMms);
|
rbMms = (RadioButton)findViewById(R.id.rbMms);
|
||||||
|
pbStatus = (ProgressBar)findViewById(R.id.pbStatus);
|
||||||
|
|
||||||
bExport.setOnClickListener(new View.OnClickListener()
|
bExport.setOnClickListener(new View.OnClickListener()
|
||||||
{
|
{
|
||||||
@ -73,19 +77,37 @@ public class MainActivity extends Activity
|
|||||||
case requestCodeExport:
|
case requestCodeExport:
|
||||||
if (resultCode == RESULT_OK)
|
if (resultCode == RESULT_OK)
|
||||||
{
|
{
|
||||||
Uri uriTree = data.getData();
|
AsyncTask<Void, Integer, Void> asyncTaskExport = new AsyncTask<Void, Integer, Void>()
|
||||||
String dataToWrite = getExportString();
|
{
|
||||||
if(!StringUtils.isEmpty(dataToWrite))
|
@Override
|
||||||
exportFiles(uriTree, dataToWrite);
|
protected Void doInBackground(Void... voids)
|
||||||
else
|
{
|
||||||
Toast.makeText(MainActivity.this, "Error reading messages. Can\'t export.", Toast.LENGTH_SHORT).show();
|
Uri uriTree = data.getData();
|
||||||
|
String dataToWrite = getExportString();
|
||||||
|
if(!StringUtils.isEmpty(dataToWrite))
|
||||||
|
exportFiles(uriTree, dataToWrite);
|
||||||
|
else
|
||||||
|
Toast.makeText(MainActivity.this, "Error reading messages. Can\'t export.", Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onProgressUpdate(Integer... values)
|
||||||
|
{
|
||||||
|
super.onProgressUpdate(values);
|
||||||
|
pbStatus.setProgress(values[0]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
asyncTaskExport.execute();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String getExportString()
|
String getExportString(AsyncTask<Void,Integer,Void> asyncTaskReference)
|
||||||
{
|
{
|
||||||
List<Map<String,String>> response;
|
List<Map<String,String>> response;
|
||||||
|
|
||||||
@ -100,6 +122,8 @@ public class MainActivity extends Activity
|
|||||||
{
|
{
|
||||||
messageCount = response.size();
|
messageCount = response.size();
|
||||||
|
|
||||||
|
asyncTaskReference.publishProgress((int)Math.round(messageCount/response.size()));
|
||||||
|
|
||||||
StringBuilder export = new StringBuilder();
|
StringBuilder export = new StringBuilder();
|
||||||
|
|
||||||
export.append("<?xml-stylesheet type=\"text/xsl\" href=\"sms.xsl\"?>");
|
export.append("<?xml-stylesheet type=\"text/xsl\" href=\"sms.xsl\"?>");
|
||||||
@ -122,9 +146,14 @@ public class MainActivity extends Activity
|
|||||||
type: 2 = outbound
|
type: 2 = outbound
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
export.append("<sms protocol=\"0\"");
|
||||||
|
|
||||||
|
if(!StringUtils.isEmpty(response.get(i).get("remote_uri")))
|
||||||
|
export.append(" address=\"" + response.get(i).get("remote_uri").replace("tel:", "") + "\"");
|
||||||
|
else
|
||||||
|
export.append(" address=\"" + response.get(i).get("address") + "\"");
|
||||||
|
|
||||||
export.append(
|
export.append(
|
||||||
"<sms protocol=\"0\"" +
|
|
||||||
" address=\"" + response.get(i).get("remote_uri").replace("tel:", "") + "\"" +
|
|
||||||
" date=\"" + response.get(i).get("date") + "\"" +
|
" date=\"" + response.get(i).get("date") + "\"" +
|
||||||
" type=\"" + response.get(i).get("type") + "\"" +
|
" type=\"" + response.get(i).get("type") + "\"" +
|
||||||
" subject=\"null\"" +
|
" subject=\"null\"" +
|
||||||
@ -238,7 +267,10 @@ public class MainActivity extends Activity
|
|||||||
}
|
}
|
||||||
Log.i("Message", "Message nr. " + messageCounter + " " + message);
|
Log.i("Message", "Message nr. " + messageCounter + " " + message);
|
||||||
|
|
||||||
returnList.add(messageMap);
|
if(!StringUtils.isEmpty(messageMap.get("body")))
|
||||||
|
returnList.add(messageMap);
|
||||||
|
else
|
||||||
|
Log.i("Message", "Skipping a message with an empty body.");
|
||||||
}
|
}
|
||||||
while (cursor.moveToNext());
|
while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,15 @@
|
|||||||
|
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/pbStatus"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||||
|
android:minHeight="50dp"
|
||||||
|
android:max="100" />
|
||||||
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/bExport"
|
android:id="@+id/bExport"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
Loading…
Reference in New Issue
Block a user