Bläddra i källkod

Add Support for user to choose his history order

Fixes #15
tags/release-v2.7
Schoumi 3 år sedan
förälder
incheckning
024e05f5ce
10 ändrade filer med 50 tillägg och 3 borttagningar
  1. +2
    -2
      app/src/main/java/fr/mobdev/goblim/Database.java
  2. +37
    -1
      app/src/main/java/fr/mobdev/goblim/activity/HistoryActivity.java
  3. Binär
      app/src/main/res/drawable-hdpi/ic_action_sort.png
  4. Binär
      app/src/main/res/drawable-mdpi/ic_action_sort.png
  5. Binär
      app/src/main/res/drawable-xhdpi/ic_action_sort.png
  6. Binär
      app/src/main/res/drawable-xxhdpi/ic_action_sort.png
  7. Binär
      app/src/main/res/drawable-xxxhdpi/ic_action_sort.png
  8. +9
    -0
      app/src/main/res/menu/menu_history.xml
  9. +1
    -0
      app/src/main/res/values-fr/strings.xml
  10. +1
    -0
      app/src/main/res/values/strings.xml

+ 2
- 2
app/src/main/java/fr/mobdev/goblim/Database.java Visa fil

@@ -88,10 +88,10 @@ public class Database extends SQLiteOpenHelper {
}
}

public List<Img> getHistory() {
public List<Img> getHistory(boolean descendingOrder) {
List<Img> history = new ArrayList<>();
//ask for history order by date
String orderBy = "date ASC";
String orderBy = descendingOrder ? "date DESC" : "date ASC";
Cursor cursor = getReadableDatabase().query("history", null, null, null, null, null, orderBy);
while(cursor.moveToNext())
{


+ 37
- 1
app/src/main/java/fr/mobdev/goblim/activity/HistoryActivity.java Visa fil

@@ -20,6 +20,7 @@ package fr.mobdev.goblim.activity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.annotation.NonNull;
@@ -27,6 +28,8 @@ import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
@@ -52,6 +55,7 @@ import fr.mobdev.goblim.R;
public class HistoryActivity extends AppCompatActivity {

private List<Long> imagesIdx;
private boolean descendingOrder;

@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -71,6 +75,15 @@ public class HistoryActivity extends AppCompatActivity {
});

ListView historyList = (ListView) findViewById(R.id.history_list);
SharedPreferences prefs = getSharedPreferences(getString(R.string.app_name), MODE_PRIVATE);
if(prefs.getAll().size() == 0) {
descendingOrder = true;
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("order", descendingOrder);
editor.commit();
} else {
descendingOrder = prefs.getBoolean("order",true);
}

updateHistory();

@@ -96,11 +109,34 @@ public class HistoryActivity extends AppCompatActivity {
updateHistory();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_history, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();

if (id == R.id.action_change_order) {
SharedPreferences prefs = getSharedPreferences(getString(R.string.app_name), MODE_PRIVATE);
descendingOrder = !descendingOrder;
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("order", descendingOrder);
editor.commit();
updateHistory();
return true;
}

return super.onOptionsItemSelected(item);
}

private void updateHistory()
{
ListView historyList = (ListView) findViewById(R.id.history_list);

List<Img> images = Database.getInstance(getApplicationContext()).getHistory();
List<Img> images = Database.getInstance(getApplicationContext()).getHistory(descendingOrder);
if(imagesIdx == null)
imagesIdx = new ArrayList<>();
imagesIdx.clear();


Binär
app/src/main/res/drawable-hdpi/ic_action_sort.png Visa fil

Före Efter
Bredd: 36  |  Höjd: 36  |  Storlek: 151 B

Binär
app/src/main/res/drawable-mdpi/ic_action_sort.png Visa fil

Före Efter
Bredd: 24  |  Höjd: 24  |  Storlek: 105 B

Binär
app/src/main/res/drawable-xhdpi/ic_action_sort.png Visa fil

Före Efter
Bredd: 48  |  Höjd: 48  |  Storlek: 132 B

Binär
app/src/main/res/drawable-xxhdpi/ic_action_sort.png Visa fil

Före Efter
Bredd: 72  |  Höjd: 72  |  Storlek: 163 B

Binär
app/src/main/res/drawable-xxxhdpi/ic_action_sort.png Visa fil

Före Efter
Bredd: 96  |  Höjd: 96  |  Storlek: 218 B

+ 9
- 0
app/src/main/res/menu/menu_history.xml Visa fil

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<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="fr.mobdev.goblim.activity.HistoryActivity">
<item android:id="@+id/action_change_order"
android:icon="@drawable/ic_action_sort"
android:title="@string/reorder_history"
app:showAsAction="ifRoom" />
</menu>

+ 1
- 0
app/src/main/res/values-fr/strings.xml Visa fil

@@ -40,6 +40,7 @@
<string name="uploading_files">Envoi Image </string>
<string name="retry_failed_uploads">Voulez vous retenter l\'envoi des fichiers listés?</string>
<string name="retry_failed_upload">Voulez vous retenter l\'envoi de ce fichier?</string>
<string name="reorder_history">Changer l\'ordre de l\'historique</string>
<string-array name="deleted_days">
<item>Pas de limitation</item>
<item>24 Heures</item>


+ 1
- 0
app/src/main/res/values/strings.xml Visa fil

@@ -40,6 +40,7 @@
<string name="uploading_files">Uploading Image </string>
<string name="retry_failed_uploads">Would you retry upload of listed files?</string>
<string name="retry_failed_upload">Would you retry upload of this file?</string>
<string name="reorder_history">Change history order</string>
<string-array name="deleted_days">
<item>No limitation</item>
<item>24 Hours</item>


Laddar…
Avbryt
Spara