Readme
This commit is contained in:
parent
8ea0f7b28c
commit
58a2bc45fe
@ -11,7 +11,6 @@ android {
|
||||
targetSdk 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
useLibrary 'org.apache.http.legacy'
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@ -41,4 +40,5 @@ dependencies {
|
||||
testImplementation 'junit:junit:4.+'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package de.server47.rcsexport;
|
||||
package de.server47.messageexport;
|
||||
|
||||
import android.content.Context;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="de.server47.rcsexport">
|
||||
package="de.server47.messageexport">
|
||||
|
||||
<uses-permission android:name="android.permission.SEND_SMS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
||||
@ -14,13 +14,13 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.SmsExport">
|
||||
android:theme="@style/Theme.RcsExport">
|
||||
|
||||
<activity
|
||||
android:name="de.server47.rcsexport.MainActivity"
|
||||
android:name="de.server47.messageexport.MainActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.SmsExport.NoActionBar">
|
||||
android:theme="@style/Theme.RcsExport.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@ -28,9 +28,6 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- https://developer.android.com/about/versions/pie/android-9.0-changes-28#apache-p-->
|
||||
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -1,4 +1,4 @@
|
||||
package de.server47.rcsexport;
|
||||
package de.server47.messageexport;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
@ -8,11 +8,15 @@ import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.documentfile.provider.DocumentFile;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -24,81 +28,27 @@ import java.util.Map;
|
||||
|
||||
public class MainActivity extends Activity
|
||||
{
|
||||
Button bRead, bWrite;
|
||||
Button bExport;
|
||||
RadioButton rbRcs, rbSms, rbMms;
|
||||
|
||||
final static int typeSMS = 0;
|
||||
final static int typeMMS = 1;
|
||||
final static int typeICS = 2;
|
||||
final static int typeRCS = 2;
|
||||
|
||||
final static int requestCodeExport = 815;
|
||||
|
||||
String contentToWrite = "bla";
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main_activity);
|
||||
|
||||
bRead = (Button)findViewById(R.id.bRead);
|
||||
bWrite = (Button)findViewById(R.id.bWrite);
|
||||
bExport = (Button)findViewById(R.id.bExport);
|
||||
rbRcs = (RadioButton)findViewById(R.id.rbRcs);
|
||||
rbSms = (RadioButton)findViewById(R.id.rbSms);
|
||||
rbMms = (RadioButton)findViewById(R.id.rbMms);
|
||||
|
||||
bRead.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
List<Map<String,String>> response = readMessages(typeICS);
|
||||
if(response.size() > 0)
|
||||
{
|
||||
StringBuilder export = new StringBuilder();
|
||||
|
||||
export.append("<?xml-stylesheet type=\"text/xsl\" href=\"sms.xsl\"?>");
|
||||
export.append("<smses count=\"" + String.valueOf(response.size()) + "\"");
|
||||
export.append("backup_set=\"c6e0fda0-9bc0-48e2-893f-10ec95966e70\"");
|
||||
export.append("backup_date=\"1631273111057\"");
|
||||
export.append("type=\"full\">");
|
||||
// 05.05.2001 19:15:00
|
||||
String pattern = "dd.MM.yyyy H:m:s";
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
|
||||
|
||||
for(int i = 0; i < response.size(); i++)
|
||||
{
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(Long.parseLong(response.get(i).get("date")));
|
||||
|
||||
/*
|
||||
type: 1 = inbound
|
||||
type: 2 = outbound
|
||||
*/
|
||||
|
||||
export.append(
|
||||
"<sms protocol=\"0\"" +
|
||||
"address=\"" + response.get(i).get("remote_uri").replace("tel:", "") + "\"" +
|
||||
"date=\"" + response.get(i).get("date") + "\"" +
|
||||
"type=\"" + response.get(i).get("type") + "\"" +
|
||||
"subject=\"null\"" +
|
||||
"body=\"" + response.get(i).get("body") + "\"" +
|
||||
"toa=\"null\"" +
|
||||
"sc_toa=\"null\"" +
|
||||
"service_center=\"null\"" +
|
||||
"read=\"1\"" +
|
||||
"status=\"-1\"" +
|
||||
"locked=\"0\"" +
|
||||
"date_sent=\"" + response.get(i).get("date_sent") + "\"" +
|
||||
"sub_id=\"-1\"" +
|
||||
"readable_date=\"" + simpleDateFormat.format(cal.getTime()) + "\"" +
|
||||
"contact_name=\"(Unknown)\"/>"
|
||||
);
|
||||
}
|
||||
|
||||
export.append("</smses>");
|
||||
contentToWrite = export.toString();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
bWrite.setOnClickListener(new View.OnClickListener()
|
||||
bExport.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
@ -122,13 +72,79 @@ public class MainActivity extends Activity
|
||||
if (resultCode == RESULT_OK)
|
||||
{
|
||||
Uri uriTree = data.getData();
|
||||
exportFiles(uriTree, contentToWrite);
|
||||
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();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String getExportString()
|
||||
{
|
||||
List<Map<String,String>> response;
|
||||
|
||||
if(rbSms.isChecked())
|
||||
response = readMessages(typeSMS);
|
||||
else if(rbMms.isChecked())
|
||||
response = readMessages(typeMMS);
|
||||
else
|
||||
response = readMessages(typeRCS);
|
||||
|
||||
if(response.size() > 0)
|
||||
{
|
||||
StringBuilder export = new StringBuilder();
|
||||
|
||||
export.append("<?xml-stylesheet type=\"text/xsl\" href=\"sms.xsl\"?>");
|
||||
export.append("<smses count=\"" + String.valueOf(response.size()) + "\"");
|
||||
export.append(" backup_set=\"" + String.valueOf(Calendar.getInstance().getTimeInMillis()) + "\"");
|
||||
export.append(" backup_date=\"" + String.valueOf(Calendar.getInstance().getTimeInMillis()) + "\"");
|
||||
export.append(" type=\"full\">");
|
||||
|
||||
// 05.05.2001 19:15:00
|
||||
String pattern = "dd.MM.yyyy H:m:s";
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
|
||||
|
||||
for(int i = 0; i < response.size(); i++)
|
||||
{
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(Long.parseLong(response.get(i).get("date")));
|
||||
|
||||
/*
|
||||
type: 1 = inbound
|
||||
type: 2 = outbound
|
||||
*/
|
||||
|
||||
export.append(
|
||||
"<sms protocol=\"0\"" +
|
||||
" address=\"" + response.get(i).get("remote_uri").replace("tel:", "") + "\"" +
|
||||
" date=\"" + response.get(i).get("date") + "\"" +
|
||||
" type=\"" + response.get(i).get("type") + "\"" +
|
||||
" subject=\"null\"" +
|
||||
" body=\"" + StringEscapeUtils.escapeXml11(response.get(i).get("body")).replace("\n", " ") + "\"" +
|
||||
" toa=\"null\"" +
|
||||
" sc_toa=\"null\"" +
|
||||
" service_center=\"null\"" +
|
||||
" read=\"1\"" +
|
||||
" status=\"-1\"" +
|
||||
" locked=\"0\"" +
|
||||
" date_sent=\"" + response.get(i).get("date_sent") + "\"" +
|
||||
" sub_id=\"-1\"" +
|
||||
" readable_date=\"" + simpleDateFormat.format(cal.getTime()) + "\"" +
|
||||
" contact_name=\"(Unknown)\"/>"
|
||||
);
|
||||
}
|
||||
|
||||
export.append("</smses>");
|
||||
return export.toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
void exportFiles(Uri uriTree, String content)
|
||||
{
|
||||
String fileName = "Message_export_" + String.valueOf(Calendar.getInstance().getTimeInMillis()) + ".xml";
|
||||
@ -189,7 +205,7 @@ public class MainActivity extends Activity
|
||||
case typeMMS:
|
||||
path = Uri.parse("content://mms/inbox");
|
||||
break;
|
||||
case typeICS:
|
||||
case typeRCS:
|
||||
path = Uri.parse("content://im/chat");
|
||||
break;
|
||||
default:
|
@ -3,27 +3,46 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_margin="@dimen/defaultMargin"
|
||||
android:gravity="center_horizontal">
|
||||
android:layout_margin="@dimen/defaultMargin" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="@dimen/defaultMargin"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline2" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bRead"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="Read" />
|
||||
<RadioGroup
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbRcs"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="RCS" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbSms"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="SMS" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMms"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="MMS" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bWrite"
|
||||
android:id="@+id/bExport"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="Write" />
|
||||
android:text="Export" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
@ -1,7 +1,7 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="de.server47.rcsexport.MainActivityCrap">
|
||||
tools:context="de.server47.messageexport.MainActivityCrap">
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
<fragment
|
||||
android:id="@+id/FirstFragment"
|
||||
android:name="de.server47.rcsexport.FirstFragment"
|
||||
android:name="de.server47.messageexport.FirstFragment"
|
||||
android:label="@string/first_fragment_label"
|
||||
tools:layout="@layout/fragment_first">
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/SecondFragment"
|
||||
android:name="de.server47.rcsexport.SecondFragment"
|
||||
android:name="de.server47.messageexport.SecondFragment"
|
||||
android:label="@string/second_fragment_label"
|
||||
tools:layout="@layout/fragment_second">
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.SmsExport" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<style name="Theme.RcsExport" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_200</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">RcsExport</string>
|
||||
<string name="app_name">MessageExport</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<!-- Strings used for fragments for navigation -->
|
||||
<string name="first_fragment_label">First Fragment</string>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.SmsExport" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<style name="Theme.RcsExport" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_500</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
@ -14,7 +14,7 @@
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.SmsExport.NoActionBar">
|
||||
<style name="Theme.RcsExport.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
@ -1,4 +1,4 @@
|
||||
package de.server47.rcsexport;
|
||||
package de.server47.messageexport;
|
||||
|
||||
import org.junit.Test;
|
||||
|
Loading…
Reference in New Issue
Block a user