Cleanup and bring back sorting through new settings
This commit is contained in:
parent
92953acfbd
commit
47067c14ac
12 changed files with 38 additions and 72 deletions
|
@ -1,4 +0,0 @@
|
|||
package org.ligi.passandroid.events;
|
||||
|
||||
public class NavigationOpenedEvent {
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
package org.ligi.passandroid.events;
|
||||
|
||||
public class SortOrderChangeEvent {
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package org.ligi.passandroid.events;
|
||||
|
||||
public class TypeFocusEvent {
|
||||
public final String type;
|
||||
|
||||
public TypeFocusEvent(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
|
@ -5,12 +5,15 @@ import android.content.SharedPreferences;
|
|||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import org.ligi.passandroid.R;
|
||||
import org.ligi.passandroid.model.comparator.PassSortOrder;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.ligi.passandroid.R.string.preference_key_autolight;
|
||||
import static org.ligi.passandroid.R.string.preference_key_condensed;
|
||||
|
||||
public class AndroidSettings implements Settings {
|
||||
public static final String ORDER_KEY = "order";
|
||||
public final Context context;
|
||||
|
||||
final SharedPreferences sharedPreferences;
|
||||
|
@ -20,14 +23,11 @@ public class AndroidSettings implements Settings {
|
|||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSortOrder(PassSortOrder order) {
|
||||
sharedPreferences.edit().putInt(ORDER_KEY, order.getInt()).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PassSortOrder getSortOrder() {
|
||||
int id = sharedPreferences.getInt(ORDER_KEY, 0);
|
||||
final String key = context.getString(R.string.preference_key_sort);
|
||||
final String stringValue = sharedPreferences.getString(key, "0");
|
||||
final int id = Integer.valueOf(stringValue);
|
||||
for (PassSortOrder order : PassSortOrder.values()) {
|
||||
if (order.getInt() == id) {
|
||||
return order;
|
||||
|
@ -60,12 +60,12 @@ public class AndroidSettings implements Settings {
|
|||
|
||||
@Override
|
||||
public boolean isCondensedModeEnabled() {
|
||||
return sharedPreferences.getBoolean("CONDENSED", false);
|
||||
return sharedPreferences.getBoolean(context.getString(preference_key_condensed), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutomaticLightEnabled() {
|
||||
return sharedPreferences.getBoolean("AUTOLIGHT", true);
|
||||
return sharedPreferences.getBoolean(context.getString(preference_key_autolight), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@ import java.io.File;
|
|||
|
||||
public interface Settings {
|
||||
|
||||
void setSortOrder(PassSortOrder order);
|
||||
|
||||
PassSortOrder getSortOrder();
|
||||
|
||||
boolean doTraceDroidEmailSend();
|
||||
|
|
|
@ -19,21 +19,15 @@ import android.support.v7.app.AppCompatDelegate;
|
|||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import net.i2p.android.ext.floatingactionbutton.FloatingActionButton;
|
||||
import net.i2p.android.ext.floatingactionbutton.FloatingActionsMenu;
|
||||
|
||||
import org.ligi.axt.AXT;
|
||||
import org.ligi.passandroid.App;
|
||||
import org.ligi.passandroid.R;
|
||||
import org.ligi.passandroid.events.NavigationOpenedEvent;
|
||||
import org.ligi.passandroid.events.SortOrderChangeEvent;
|
||||
import org.ligi.passandroid.events.TypeFocusEvent;
|
||||
import org.ligi.passandroid.helper.PassUtil;
|
||||
import org.ligi.passandroid.model.FiledPass;
|
||||
import org.ligi.passandroid.model.PassClassifier;
|
||||
|
@ -130,16 +124,6 @@ public class PassListActivity extends PassAndroidActivity implements PassClassif
|
|||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void sortOrderChange(SortOrderChangeEvent orderChangeEvent) {
|
||||
refreshPasses();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void typeFocus(TypeFocusEvent typeFocusEvent) {
|
||||
drawer.closeDrawers();
|
||||
}
|
||||
|
||||
public void refreshPasses() {
|
||||
passStore.preCachePassesList();
|
||||
runOnUiThread(new Runnable() {
|
||||
|
@ -183,12 +167,7 @@ public class PassListActivity extends PassAndroidActivity implements PassClassif
|
|||
SnackEngage.from(floatingActionsMenu).withSnack(new DefaultRateSnack()).build().engageWhenAppropriate();
|
||||
}
|
||||
|
||||
drawerToggle = new ActionBarDrawerToggle(this, drawer, R.string.drawer_open, R.string.drawer_close) {
|
||||
@Override
|
||||
public void onDrawerOpened(View drawerView) {
|
||||
bus.post(new NavigationOpenedEvent());
|
||||
}
|
||||
};
|
||||
drawerToggle = new ActionBarDrawerToggle(this, drawer, R.string.drawer_open, R.string.drawer_close);
|
||||
|
||||
drawer.addDrawerListener(drawerToggle);
|
||||
|
||||
|
|
|
@ -12,11 +12,9 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import com.squareup.otto.Bus;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.ligi.passandroid.App;
|
||||
import org.ligi.passandroid.R;
|
||||
import org.ligi.passandroid.events.TypeFocusEvent;
|
||||
import org.ligi.passandroid.helper.MoveHelper;
|
||||
import org.ligi.passandroid.model.FiledPass;
|
||||
import org.ligi.passandroid.model.PassStore;
|
||||
|
@ -165,19 +163,4 @@ public class PassListFragment extends Fragment implements OnClassificationChange
|
|||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void typeFocus(TypeFocusEvent typeFocusEvent) {
|
||||
scrollToType(typeFocusEvent.type);
|
||||
}
|
||||
|
||||
|
||||
private void scrollToType(String type) {
|
||||
|
||||
for (int i = 0; i < adapter.getItemCount(); i++) {
|
||||
if (passStoreProjection.getPassList().get(i).getTypeNotNull().equals(type)) {
|
||||
recyclerView.scrollToPosition(i);
|
||||
return; // we are done
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import com.squareup.otto.Bus;
|
|||
import org.ligi.passandroid.App;
|
||||
import org.ligi.passandroid.R;
|
||||
import org.ligi.passandroid.Tracker;
|
||||
import org.ligi.passandroid.events.SortOrderChangeEvent;
|
||||
import org.ligi.passandroid.model.FiledPass;
|
||||
import org.ligi.passandroid.model.InputStreamWithSource;
|
||||
import org.ligi.passandroid.model.Pass;
|
||||
|
@ -158,7 +157,6 @@ public class SearchPassesIntentService extends IntentService {
|
|||
foundList.add(uuid);
|
||||
final String language = getBaseContext().getResources().getConfiguration().locale.getLanguage();
|
||||
final FiledPass pass = AppleStylePassReader.read(passStore.getPathForID(uuid), language);
|
||||
bus.post(new SortOrderChangeEvent());
|
||||
final Bitmap iconBitmap = pass.getBitmap(Pass.BITMAP_ICON);
|
||||
if (iconBitmap != null) {
|
||||
final Bitmap bitmap = scale2maxSize(iconBitmap, getResources().getDimensionPixelSize(R.dimen.finger));
|
||||
|
|
7
android/src/main/res/values/arrays.xml
Normal file
7
android/src/main/res/values/arrays.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="sort_order_keys" >
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
</string-array>
|
||||
</resources>
|
6
android/src/main/res/values/stings-notranslate.xml
Normal file
6
android/src/main/res/values/stings-notranslate.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="preference_key_sort">SORT</string>
|
||||
<string name="preference_key_autolight">AUTOLIGHT</string>
|
||||
<string name="preference_key_condensed">CONDENSED</string>
|
||||
</resources>
|
|
@ -92,7 +92,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
|
|||
<string name="dialog_delete_confirm_delete_source_checkbox">also delete source?</string>
|
||||
<string name="more">MORE</string>
|
||||
<string name="less">LESS</string>
|
||||
<string name="scanning_for_passes" >Scanning for Passes</string>
|
||||
<string name="scanning_for_passes">Scanning for Passes</string>
|
||||
<string name="fab_choice_scan_pkpass_files">Scan for pkpass files</string>
|
||||
<string name="fab_choice_add_demo_pass">Add Demo-Pass</string>
|
||||
<string name="fab_choice_create_pass">Create Pass (experimental)</string>
|
||||
|
@ -115,4 +115,8 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
|
|||
<string name="move_to_new_topic">Move to new Topic</string>
|
||||
<string name="categories_nav">%d Categories</string>
|
||||
<string name="passes_nav">%d Passes</string>
|
||||
<string-array name="sort_orders">
|
||||
<item>Date</item>
|
||||
<item>Type</item>
|
||||
</string-array>
|
||||
</resources>
|
|
@ -1,12 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<CheckBoxPreference
|
||||
android:key="AUTOLIGHT"
|
||||
android:key="@string/preference_key_autolight"
|
||||
android:summary="Increase brightness when showing barcode"
|
||||
android:title="Automatic light" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="CONDENSED"
|
||||
android:key="@string/preference_key_condensed"
|
||||
android:summary="Show more detail in List"
|
||||
android:title="Condensed mode" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/sort_orders"
|
||||
android:entryValues="@array/sort_order_keys"
|
||||
android:key="@string/preference_key_sort"
|
||||
android:summary="how to sort the passes"
|
||||
android:title="Sort order" />
|
||||
</PreferenceScreen>
|
Loading…
Reference in a new issue