Progress display

This commit is contained in:
Jens 2021-09-18 22:30:39 +02:00
parent ed1445dd4e
commit 165df24f0c
2 changed files with 102 additions and 100 deletions

View File

@ -11,11 +11,13 @@ Unfortunately SMS BR is not able to export this kind of messages (as of Septembe
I didn't want to reinvent the wheel - there are already enough backup/restore apps for SMS and MMS. Instead I just wanted to make an app that was able to export the RCS messages, too. Preferably it should be a format that SMS BR could then import.
## So if you're interested:
1. Backup your SMS and MMS messages with another program.
1. Backup your SMS and MMS messages with another program, e.g. SMS BR
2. Import them on the target phone.
3. Export the RCS using this app.
4. Import those on the new phone as well.
3. Export the RCS messages using this app.
4. Import those on the new phone as well, e.g. with SMS BR.
## Remarks:
- Technically the RCS will be converted to SMS messages.
- This program cannot IMport anything, just export.
- Technically the RCS messages will be converted to SMS messages.
- This program has only been tested with text messages. I don't know if images, etc. can be exported as well.
- Because I don't see any real value in RCS messages over SMS, I deactivated advanced messaging in my SMS app. I encourage you to consider doing the same.

View File

@ -65,49 +65,9 @@ public class MainActivity extends Activity
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
class AsyncTaskExport extends AsyncTask<Uri, Integer, Void>
{
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK)
{
switch (requestCode)
{
case requestCodeExport:
if (resultCode == RESULT_OK)
{
AsyncTask<Void, Integer, Void> asyncTaskExport = new AsyncTask<Void, Integer, Void>()
{
@Override
protected Void doInBackground(Void... voids)
{
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;
}
}
}
String getExportString(AsyncTask<Void,Integer,Void> asyncTaskReference)
String getExportString()
{
List<Map<String,String>> response;
@ -122,7 +82,7 @@ public class MainActivity extends Activity
{
messageCount = response.size();
asyncTaskReference.publishProgress((int)Math.round(messageCount/response.size()));
publishProgress((int)Math.round(messageCount/response.size()));
StringBuilder export = new StringBuilder();
@ -178,6 +138,46 @@ public class MainActivity extends Activity
return null;
}
@Override
protected Void doInBackground(Uri... uriTree)
{
String dataToWrite = getExportString();
if(!StringUtils.isEmpty(dataToWrite))
exportFiles(uriTree[0], 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]);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK)
{
switch (requestCode)
{
case requestCodeExport:
if (resultCode == RESULT_OK)
{
AsyncTask<Uri,Integer,Void> exportTask = new AsyncTaskExport();
exportTask.execute(data.getData());
}
break;
}
}
}
void exportFiles(Uri uriTree, String content)
{
String fileName = "Message_export_" + String.valueOf(Calendar.getInstance().getTimeInMillis()) + ".xml";