mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-04-13 11:57:26 -04:00
Allow user to import/export cards to/from CSV on external storage
Italian translations provided by Airon90. Dutch translations provided by PanderMusubi
This commit is contained in:
@@ -38,6 +38,12 @@
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:windowSoftInputMode="stateHidden"
|
||||
android:parentActivityName="protect.card_locker.MainActivity"/>
|
||||
<activity
|
||||
android:name=".ImportExportActivity"
|
||||
android:label="@string/importExport"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:parentActivityName=".MainActivity"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package protect.card_locker;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
public class ImportExportActivity extends AppCompatActivity
|
||||
{
|
||||
|
||||
ImportExportTask importExporter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.import_export_activity);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if(actionBar != null)
|
||||
{
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
Button importButton = (Button)findViewById(R.id.importButton);
|
||||
importButton.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
importExporter = new ImportExportTask(ImportExportActivity.this,
|
||||
true, DataFormat.CSV);
|
||||
importExporter.execute();
|
||||
}
|
||||
});
|
||||
|
||||
Button exportButton = (Button)findViewById(R.id.exportButton);
|
||||
exportButton.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
importExporter = new ImportExportTask(ImportExportActivity.this,
|
||||
false, DataFormat.CSV);
|
||||
importExporter.execute();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy()
|
||||
{
|
||||
if(importExporter != null && importExporter.getStatus() != AsyncTask.Status.RUNNING)
|
||||
{
|
||||
importExporter.cancel(true);
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,13 @@ public class MainActivity extends AppCompatActivity
|
||||
return true;
|
||||
}
|
||||
|
||||
if(id == R.id.action_import_export)
|
||||
{
|
||||
Intent i = new Intent(getApplicationContext(), ImportExportActivity.class);
|
||||
startActivity(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
BIN
app/src/main/res/drawable-hdpi/ic_import_export_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_import_export_white_24dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 172 B |
BIN
app/src/main/res/drawable-mdpi/ic_import_export_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_import_export_white_24dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 132 B |
BIN
app/src/main/res/drawable-xhdpi/ic_import_export_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_import_export_white_24dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 202 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_import_export_white_24dp.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_import_export_white_24dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 252 B |
Binary file not shown.
|
After Width: | Height: | Size: 328 B |
54
app/src/main/res/layout/import_export_activity.xml
Normal file
54
app/src/main/res/layout/import_export_activity.xml
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<LinearLayout android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="20dp"
|
||||
android:textSize="20sp"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/importExportHelp"/>
|
||||
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/importName"
|
||||
android:layout_weight="1.0"
|
||||
android:id="@+id/importButton"/>
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/exportName"
|
||||
android:layout_weight="1.0"
|
||||
android:id="@+id/exportButton"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
@@ -7,4 +7,9 @@
|
||||
android:icon="@drawable/ic_add_white_24dp"
|
||||
android:title="@string/action_add"
|
||||
app:showAsAction="always"/>
|
||||
<item
|
||||
android:id="@+id/action_import_export"
|
||||
android:icon="@drawable/ic_import_export_white_24dp"
|
||||
android:title="@string/importExport"
|
||||
app:showAsAction="ifRoom"/>
|
||||
</menu>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<resources>
|
||||
<resources
|
||||
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<string name="app_name">Carte fedeltà</string>
|
||||
<string name="action_add">Aggiungi</string>
|
||||
|
||||
@@ -26,4 +28,17 @@
|
||||
|
||||
<string name="cardIdFormat">%1$s: %2$s</string>
|
||||
<string name="note">Note</string>
|
||||
|
||||
<string name="importExport">Importa/Esporta</string>
|
||||
<string name="importName">Importa</string>
|
||||
<string name="exportName">Esporta</string>
|
||||
<string name="importExportHelp">I dati sono stati importati in o esportati dal file LoyaltyCardLocker.csv sulla memoria esterna</string>
|
||||
<string name="importedFrom">Importato da: %1$s</string>
|
||||
<string name="exportedTo">Esportato in: %1$s</string>
|
||||
<string name="fileMissing">File mancante: %1$s</string>
|
||||
<string name="importFailed">Impossibile importare: %1$s</string>
|
||||
<string name="exportFailed">Impossibile esportare: %1$s</string>
|
||||
<string name="importing">Importazione in corso…</string>
|
||||
<string name="exporting">Esportazione in corso…</string>
|
||||
<string name="noExternalStoragePermissionError">Impossibile importare o esportare i dati senza il permesso per l\'uso della memoria esterna.</string>
|
||||
</resources>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<resources>
|
||||
<resources
|
||||
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<string name="app_name">Klantenkaartenkluis</string>
|
||||
<string name="action_add">Voeg toe</string>
|
||||
|
||||
@@ -26,4 +28,17 @@
|
||||
|
||||
<string name="cardIdFormat">%1$s: %2$s</string>
|
||||
<string name="note">Notitie</string>
|
||||
|
||||
<string name="importExport">Importeer/Exporteer</string>
|
||||
<string name="importName">Importeer</string>
|
||||
<string name="exportName">Exporteer</string>
|
||||
<string name="importExportHelp">Data is geïmporteerd van of geëxporteerd naar LoyaltyCardLocker.csv op externe opslag</string>
|
||||
<string name="importedFrom">Geïmporteerd van: %1$s</string>
|
||||
<string name="exportedTo">Geëxporteerd naar: %1$s</string>
|
||||
<string name="fileMissing">Bestand niet gevonden: %1$s</string>
|
||||
<string name="importFailed">Importeren mislukte: %1$s</string>
|
||||
<string name="exportFailed">Exporteren mislukte: %1$s</string>
|
||||
<string name="importing">Importerende…</string>
|
||||
<string name="exporting">Exporterende…</string>
|
||||
<string name="noExternalStoragePermissionError">Niet mogelijk te importeren of exporteren zonder rechten op externe opslag</string>
|
||||
</resources>
|
||||
|
||||
@@ -50,9 +50,10 @@ public class MainActivityTest
|
||||
assertTrue(menu != null);
|
||||
|
||||
// The settings and add button should be present
|
||||
assertEquals(menu.size(), 1);
|
||||
assertEquals(menu.size(), 2);
|
||||
|
||||
assertEquals("Add", menu.findItem(R.id.action_add).getTitle().toString());
|
||||
assertEquals("Import/Export", menu.findItem(R.id.action_import_export).getTitle().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user