Skip to content

Commit eff6d33

Browse files
Ability to export a single server
1 parent c4e23e8 commit eff6d33

File tree

6 files changed

+43
-41
lines changed

6 files changed

+43
-41
lines changed

ChangeLog.txt

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Default Qt Client
2121
- Fixed language not set at first start
2222
- Fixed OPUS DTX mode sending too big packets when variable bitrate mode (VBR) was disabled
2323
Android Client
24+
- Ability to export each server in to a .tt file separately
2425
- Broadcast messages are now shown in the chat tab
2526
- Added the ability to send broadcast messages
2627
- Redesigned server list dialog to remove the old remove server button and make it to use popup menus, results in a more clear and modern dialog, and fast navigating for screenreader users

Client/TeamTalkAndroid/src/main/java/dk/bearware/gui/ServerListActivity.java

+36
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,11 @@ public boolean onItemLongClick(AdapterView<?> l, View v, int position, long id)
347347
serverActions.inflate(R.menu.server_actions);
348348
serverActions.setOnMenuItemClickListener(item -> {
349349
switch (item.getItemId()) {
350+
case R.id.action_exportsrv:
351+
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) || Permissions.WRITE_EXTERNAL_STORAGE.request(this)) {
352+
exportServer(entry);
353+
}
354+
return true;
350355
case R.id.action_editsrv:
351356
Intent intent = new Intent(this, ServerEntryActivity.class);
352357
startActivityForResult(Utils.putServerEntry(intent, entry).putExtra(POSITION_NAME, position), REQUEST_EDITSERVER);
@@ -788,6 +793,37 @@ private void exportServers() {
788793
}
789794
}
790795

796+
private void exportServer(ServerEntry entry) {
797+
File dirPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
798+
if (dirPath.mkdirs() || dirPath.isDirectory()) {
799+
final File ttFile = new File(dirPath, entry.servername + "_server.tt");
800+
final String filePath = ttFile.getAbsolutePath();
801+
802+
if (ttFile.exists()) {
803+
AlertDialog.Builder alert = new AlertDialog.Builder(this);
804+
alert.setMessage(getString(R.string.alert_file_override, filePath));
805+
alert.setPositiveButton(android.R.string.yes, (dialog, whichButton) -> {
806+
if (ttFile.delete()) {
807+
int msgId = Utils.saveServers(new Vector<>(Collections.singletonList(entry)), filePath) ?
808+
R.string.server_export_confirmation :
809+
R.string.err_file_write;
810+
Toast.makeText(ServerListActivity.this, getString(msgId, filePath), Toast.LENGTH_LONG).show();
811+
} else {
812+
Toast.makeText(ServerListActivity.this, getString(R.string.err_file_delete, filePath), Toast.LENGTH_LONG).show();
813+
}
814+
});
815+
816+
alert.setNegativeButton(android.R.string.no, null);
817+
alert.show();
818+
} else {
819+
int msgId = Utils.saveServers(new Vector<>(Collections.singletonList(entry)), filePath) ?
820+
R.string.server_export_confirmation :
821+
R.string.err_file_write;
822+
Toast.makeText(this, getString(msgId, filePath), Toast.LENGTH_LONG).show();
823+
}
824+
}
825+
}
826+
791827
private ListFragment getListFragment() {
792828
return (ListFragment) getSupportFragmentManager().findFragmentById(R.id.list_fragment);
793829
}

Client/TeamTalkAndroid/src/main/res/layout-land/item_serverentry.xml

-40
This file was deleted.

Client/TeamTalkAndroid/src/main/res/menu/server_actions.xml

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
22

3+
<item
4+
android:id="@+id/action_exportsrv"
5+
android:title="@string/action_exportsrv"/>
6+
37
<item
48
android:id="@+id/action_editsrv"
59
android:title="@string/action_editsrv"/>

Client/TeamTalkAndroid/src/main/res/values/strings.xml

+2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
<string name="action_move">Move Here</string>
148148
<string name="action_select">Select For Move</string>
149149
<string name="action_deselect">Deselect For Move</string>
150+
<string name="action_exportsrv">Export server</string>
150151
<string name="action_editsrv">Edit server</string>
151152
<string name="action_removesrv">Remove server</string>
152153
<string name="action_upload">Upload File</string>
@@ -228,6 +229,7 @@
228229
<string name="action_import_serverlist">Import from a .tt File</string>
229230
<string name="action_export_serverlist">Export server list</string>
230231
<string name="serverlist_export_confirmation">Server list has been exported to %1$s</string>
232+
<string name="server_export_confirmation">Server has been exported to %1$s</string>
231233

232234
<string name="pref_title_server_props">TeamTalk 5 Server Properties</string>
233235
<string name="pref_title_server_info">Server Information</string>

Client/TeamTalkAndroid/src/main/res/xml/pref_serverentry.xml

-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
android:disableDependentsState="true"
104104
android:persistent="false" />
105105
<EditTextPreference
106-
android:defaultValue="/"
107106
android:key="channel"
108107
android:title="@string/pref_title_channel"
109108
android:selectAllOnFocus="true"

0 commit comments

Comments
 (0)