Resouces cleanup, added ru locale

This commit is contained in:
Tariel Hlontsi 2016-09-10 19:15:44 +03:00
parent a52c17b618
commit d7dc1fd048
132 changed files with 2080 additions and 772 deletions

View File

@ -5,7 +5,6 @@
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="1.8" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />

View File

@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
buildToolsVersion "23.0.3"
/*
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
@ -18,7 +18,7 @@ android {
}
buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
@ -31,9 +31,6 @@ repositories {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.1'
compile 'com.squareup.retrofit2:converter-gson:2.0.1'
@ -44,4 +41,6 @@ dependencies {
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.11.0'
compile files('libs/socialauth-4.4.jar')
compile files('libs/socialauth-android-3.2.jar')
}

View File

@ -15,3 +15,35 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep public class java.nio.file.* { public *; }
-dontwarn java.nio.file.**
-keep public class org.codehaus.mojo.animal_sniffer.* { public *; }
-dontwarn org.codehaus.mojo.animal_sniffer.**
-keep public class org.openid4java.consumer.* { public *; }
-dontwarn org.openid4java.consumer.**
-keep public class org.openid4java.message.* { public *; }
-dontwarn org.openid4java.message.**
-keep public class org.openid4java.OpenIDException { public *; }
-dontwarn org.openid4java.OpenIDException
-keep public class org.openid4java.discovery.Identifier { public *; }
-dontwarn org.openid4java.discovery.Identifier
-keep public class javax.servlet.http.HttpServletRequest { public *; }
-dontwarn javax.servlet.http.HttpServletRequest
-keep public class java.lang.invoke.* { public *; }
-dontwarn java.lang.invoke.**
-keep public class org.openid4java.discovery.DiscoveryInformation { public *; }
-dontwarn org.openid4java.discovery.DiscoveryInformation
-dontwarn retrofit2.Platform$Java8

View File

@ -14,7 +14,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
<activity android:name="com.hikapro.backpack.MainActivity">
<activity android:name="com.hikapro.backpack.MainActivity" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@ -0,0 +1 @@
[{"id":2,"photo":"http://hikapro.com/system/backpack/sharing_photos/photos/000/000/002/large/thumb_IMG_2899_1024.jpg?1449590757","photo_thumb":"http://hikapro.com/system/backpack/sharing_photos/photos/000/000/002/thumb/thumb_IMG_2899_1024.jpg?1449590757"}]

View File

@ -0,0 +1,51 @@
#google
www.google.com.consumer_key = socialauth.in
www.google.com.consumer_secret = Mlt6oDI0iIoOiylfiqgnCkrS
#yahoo
api.login.yahoo.com.consumer_key = dj0yJmk9Nlpqd0pIMENnb1N4JmQ9WVdrOWJqbEhURXA0TTJVbWNHbzlNVEk0TXpNeE5EYzJNZy0tJnM9Y29uc3VtZXJzZWNyZXQmeD0yOA--
api.login.yahoo.com.consumer_secret = c04675a9274fb556f9e817b1ad23f0c91c2c0500
#twitter
twitter.com.consumer_key = RbtJOnWBSf9hLYKiw6R5qa2g4
twitter.com.consumer_secret = dyd9Kv7ITZhpYL0FpK9ozUNSgjvHM4lDBg7K2domssdc3p6iPv
#facebook
graph.facebook.com.consumer_key = 297841130364674
graph.facebook.com.consumer_secret = dc9c59d0c72d4f2533580e80ba4c2a59
#LinkedIn
api.linkedin.com.consumer_key = bh82t52rdos6
api.linkedin.com.consumer_secret = zQ1LLrGbhDZ36fH8
#FourSquare
foursquare.com.consumer_key = VJT0YKBEQAQOMPWZPTGF1V5WOHZQMWNNJEBBQBSDNU3COOMQ
foursquare.com.consumer_secret = HCVBO1W5MNWIPAOJABI3LILMLTHTPR52RU3P0GJ3TYTYVBWU
#MySpace
api.myspace.com.consumer_key = 67cc035edf0f4387a2488a0fb0b490ab
api.myspace.com.consumer_secret = 80b58c4873ac4d2e8edb6257d85c79e71692c39d5f0f4b3a90acc1dffaf58cda
#Runkeeper
runkeeper.com.consumer_key=b1320c16082d48e2a7a94f5bfa2ce58b
runkeeper.com.consumer_secret=7cbf7688519d4e8cb5343a4c939ac1a6
#Yammer
www.yammer.com.consumer_key=wLR96V3qBPHPcYLkrLvgg
www.yammer.com.consumer_secret=4hhUOP6tYiHNOUz6dMhWBVHgcsFq3MUZpI8IkA
#Salesforce
login.salesforce.com.consumer_key = 3MVG9Y6d_Btp4xp4yFMR0tPSndvoapjV0sIbnVSNLg_l1vkeDgLelQhr6iYwlTgCL98VSBjU_XvQZYGfSmW_D
login.salesforce.com.consumer_secret = 4962202263932085201
#Google Plus
googleapis.com.consumer_key=505071246058-6i3hf3rhd1s0qst492e23g9sq5t9koiv.apps.googleusercontent.com
googleapis.com.consumer_secret=xrNQTx9ELsxmyUBfh35ntpfR
#Flickr
www.flickr.com.consumer_key = c519f64dbddc50f3e25e8cc73744602b
www.flickr.com.consumer_secret = bf1a181c42bef4ea
#Instagram
api.instagram.com.consumer_key = c28ba7d08da64462a0db848c366ea43e
api.instagram.com.consumer_secret = c5063d4e5f1248a19d2fa3e8bf3d8d6e

View File

@ -40,9 +40,6 @@ public class MainActivity extends Activity implements View.ActivityCallback {
private final StateMaintainer stateMaintainer =
new StateMaintainer(getFragmentManager(), MainActivity.class.getName());
// life cycle -->
@Override
public boolean onOptionsItemSelected(MenuItem item) {
boolean ret;
@ -179,8 +176,6 @@ public class MainActivity extends Activity implements View.ActivityCallback {
super.onDestroy();
Log.i("onDestroy", "Activity");
}
// life cycle <--
@Override
public void startSetListFragment() {

View File

@ -13,7 +13,6 @@ import java.util.HashMap;
*/
public class StateMaintainer {
protected final String TAG = getClass().getSimpleName();
private final String stateMaintainerTag;
private final WeakReference<FragmentManager> fragmentManager;
private StateMngFragment stateMngFragment;
@ -72,7 +71,6 @@ public class StateMaintainer {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Grants that the fragment will be preserved
setRetainInstance(true);
}
@ -89,7 +87,6 @@ public class StateMaintainer {
@SuppressWarnings("unchecked")
public <T> T get(String key) {
Log.i(this.toString(), String.format("Get object %s Total count %d", key, data.size()));
return (T) data.get(key);
}
}

View File

@ -29,7 +29,6 @@ public class AddModel implements Model.Add {
this.filteredItems = new ArrayList<>(256);
this.categoriesCache = new ArrayList<>(20);
this.dao = DAO.getInstance();
dao.registerObserver(this);
}
@Override
@ -72,11 +71,13 @@ public class AddModel implements Model.Add {
if ( !isConfigurationChanging ) {
presenter = null;
}
dao.unregisterObserver(this);
}
@Override
public void executeQuery() {
Message command;
dao.registerObserver(this);
if (categoriesCache.isEmpty()) {
command = Message.obtain();
command.what = Command.ITEM_GET_CATEGORIES;

View File

@ -2,10 +2,12 @@ package com.hikapro.backpack.model;
import java.util.List;
import com.hikapro.backpack.model.dao.Db;
import com.hikapro.backpack.model.entities.Category;
import com.hikapro.backpack.model.entities.Item;
import com.hikapro.backpack.model.entities.Set;
import com.hikapro.backpack.model.entities.SharingPicture;
import com.hikapro.backpack.model.entities.Timestamp;
import com.hikapro.backpack.model.entities.Updates;
import retrofit2.Call;
@ -32,5 +34,6 @@ public interface Api {
@GET("api/v1/backpack/updates/all")
Call<Updates> getUpdates(@Query("timestamp") long timestamp);
@GET("api/v1/backpack/sharing_photos")
Call<List<SharingPicture>> getSharingPicture();
}

View File

@ -10,12 +10,14 @@ import java.util.Hashtable;
import java.util.List;
import com.hikapro.backpack.App;
import com.hikapro.backpack.R;
import com.hikapro.backpack.model.dao.Command;
import com.hikapro.backpack.model.dao.DAO;
import com.hikapro.backpack.model.dao.Event;
import com.hikapro.backpack.model.entities.Category;
import com.hikapro.backpack.model.entities.Item;
import com.hikapro.backpack.presenter.Presenter;
import com.hikapro.backpack.presenter.adapters.helper.AppRater;
/**
* Created by tariel on 22/04/16.
@ -32,6 +34,7 @@ public class ItemModel implements Model.Item {
protected List<Item> itemsCache;
protected Hashtable<Category, List<Item>> items;
protected int lastVisiblePosition;
public ItemModel() {
this.categoriesCache = new Hashtable<>(20, 0.9f);
@ -126,7 +129,11 @@ public class ItemModel implements Model.Item {
break;
case Event.SET_RESTORE_COMPLETED:
executeQuery();
Toast.makeText(App.getAppContext(), "Restore completed", Toast.LENGTH_SHORT).show();
Toast.makeText(App.getAppContext(), R.string.restore_completed, Toast.LENGTH_SHORT).show();
break;
case Event.NEED_TO_RATE_NOW:
if (presenter != null)
presenter.showRateDialog();
break;
}
}
@ -141,7 +148,7 @@ public class ItemModel implements Model.Item {
command.arg1 = currentSet;
dao.executeCommand(command);
if (categoriesCache.isEmpty()) {
if (categoriesCache == null || categoriesCache.isEmpty()) {
command = Message.obtain();
command.what = Command.ITEM_GET_CATEGORIES;
dao.executeCommand(command);
@ -157,8 +164,6 @@ public class ItemModel implements Model.Item {
dao.executeCommand(command);
}
// categories -->
@Override
public Category getCategoryByPosition(int position) {
Category ret = null;
@ -166,21 +171,15 @@ public class ItemModel implements Model.Item {
return ret;
}
// categories <--
// items -->
public int getLastVisiblePosition() {
return lastVisiblePosition < 0 ? 0 : lastVisiblePosition;
}
@Override
public Item findItem(int id) {
Item item = null;
for (Item i : itemsCache) {
if (i.getId() == id) {
item = i;
break;
}
}
return item;
public void setLastVisiblePosition(int lastVisiblePosition) {
this.lastVisiblePosition = lastVisiblePosition;
}
@Override
public Item getItemByPosition(int position) {
Item ret = null;
@ -217,7 +216,7 @@ public class ItemModel implements Model.Item {
@Override
public int getItemsCount() {
return itemsCache.size();
return itemsCache == null ? 0 : itemsCache.size();
}
@Override
@ -229,9 +228,6 @@ public class ItemModel implements Model.Item {
public int getPackedQty() {
return packedQty;
}
// items <--
// events -->
@Override
public void notifyDataSetChanged() {
@ -243,12 +239,11 @@ public class ItemModel implements Model.Item {
public void onDestroy(boolean isConfigurationChanging) {
if ( !isConfigurationChanging ) {
presenter = null;
categoriesCache = null;
itemsCache = null;
}
dao.unregisterObserver(this);
}
// events <--
// process -->
@Override
public void pendingRemove(Item item) {
@ -258,7 +253,6 @@ public class ItemModel implements Model.Item {
command.arg1 = currentSet;
command.arg2 = item.getId();
dao.executeCommand(command);
//itemsCache.remove(item);// TODO check nn
}
}
@ -270,7 +264,6 @@ public class ItemModel implements Model.Item {
command.arg1 = currentSet;
command.arg2 = item.getId();
dao.executeCommand(command);
//itemsCache.remove(item);
}
}
@ -282,7 +275,6 @@ public class ItemModel implements Model.Item {
command.arg1 = currentSet;
command.arg2 = item.getId();
dao.executeCommand(command);
//itemsCache.remove(item);
}
}
@Override
@ -320,17 +312,12 @@ public class ItemModel implements Model.Item {
dao.executeCommand(command);
}
// process <--
// other -->
@Override
public void setPresenter(Presenter.ItemList presenter) {
this.presenter = presenter;
this.currentSet = presenter.getCurrentSet().getId();
this.currentSetActiveItemsQty = presenter.getCurrentSet().getActiveQty();
//dao.registerObserver(this);
}
@Override
@ -338,5 +325,4 @@ public class ItemModel implements Model.Item {
return presenter;
}
// other <--
}

View File

@ -27,16 +27,17 @@ public interface Model {
int getSetsCount();
void setPresenter(Presenter.SetList presenter);
Presenter.SetList getPresenter();
//GLM
List<com.hikapro.backpack.model.entities.Set> getSets(); // tag renamed
int getLastVisiblePosition();
void setLastVisiblePosition(int position);
List<com.hikapro.backpack.model.entities.Set> getSets();
void setsReorderNotify();
}
interface Item extends Base {
void filter(String query);
int getHeaderId(int position);//TODO review
int getItemId(int position);//TODO review
int getHeaderId(int position);
int getItemId(int position);
// leave at home
void pendingRemove(com.hikapro.backpack.model.entities.Item item);
void pendingRemoveCancel(com.hikapro.backpack.model.entities.Item item);
@ -45,7 +46,9 @@ public interface Model {
int getActiveItemsCount();
int getPackedQty();
com.hikapro.backpack.model.entities.Item findItem(int id);
int getLastVisiblePosition();
void setLastVisiblePosition(int position);
com.hikapro.backpack.model.entities.Item getItemByPosition(int position);
com.hikapro.backpack.model.entities.Category getCategoryByPosition(int position);
@ -74,6 +77,7 @@ public interface Model {
interface Share extends Base {
void setPresenter(Presenter.Share presenter);
Presenter.Share getPresenter();
Bitmap[] getSharingPics();
}

View File

@ -1,6 +1,8 @@
package com.hikapro.backpack.model;
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
@ -40,4 +42,16 @@ public class NetworkUtil {
return activeNetwork.getType();
//ConnectivityManager.TYPE_WIFI;
}
public static boolean isNetworkAvailable(Context context) {
if (context.checkCallingOrSelfPermission(Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED) {
return false;
}
ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = connMgr.getActiveNetworkInfo();
return netInfo != null && netInfo.isConnected();
}
}

View File

@ -8,10 +8,12 @@ import java.util.Hashtable;
import java.util.List;
import com.hikapro.backpack.App;
import com.hikapro.backpack.R;
import com.hikapro.backpack.model.dao.Command;
import com.hikapro.backpack.model.dao.Event;
import com.hikapro.backpack.model.entities.Category;
import com.hikapro.backpack.model.entities.Item;
import com.hikapro.backpack.presenter.adapters.helper.AppRater;
/**
* Created by tariel on 12/05/16.
@ -26,7 +28,7 @@ public class PackedModel extends ItemModel {
public void executeQuery() {
Message command;
dao.registerObserver(this);
if (categoriesCache.isEmpty()) {
if (categoriesCache == null || categoriesCache.isEmpty()) {
command = Message.obtain();
command.what = Command.ITEM_GET_CATEGORIES;
dao.executeCommand(command);
@ -128,7 +130,11 @@ public class PackedModel extends ItemModel {
break;
case Event.SET_RESTORE_COMPLETED:
executeQuery();
Toast.makeText(App.getAppContext(), "Restore completed", Toast.LENGTH_SHORT).show();
Toast.makeText(App.getAppContext(), R.string.restore_completed, Toast.LENGTH_SHORT).show();
break;
case Event.NEED_TO_RATE_NOW:
if (presenter != null)
presenter.showRateDialog();
break;
}
}

View File

@ -23,15 +23,21 @@ public class SetModel implements Model.Set {
private List<com.hikapro.backpack.model.entities.Set> cache;
private Presenter.SetList presenter;
private DAO dao;
private int lastVisiblePosition;
public SetModel() {
this.cache = new ArrayList<>();
this.dao = DAO.getInstance();
dao.registerObserver(this);
}
//region sets
public int getLastVisiblePosition() {
return lastVisiblePosition < 0 ? 0 : lastVisiblePosition;
}
public void setLastVisiblePosition(int lastVisiblePosition) {
this.lastVisiblePosition = lastVisiblePosition;
}
@Override
public com.hikapro.backpack.model.entities.Set getSetByPosition(int position) {
@ -54,28 +60,21 @@ public class SetModel implements Model.Set {
return cache.size();
}
//endregion
//region events
@Override
public void onDestroy(boolean isConfigurationChanging) {
if ( !isConfigurationChanging ) {
presenter = null;
}
dao.unregisterObserver(this);
}
@Override
public void notifyDataSetChanged() {
presenter.notifyDataSetChanged();
}
//endregion
//region process
@Override
public void executeQuery() {
dao.registerObserver(this);
if (presenter != null)
presenter.startProgress();
Message command = Message.obtain();
@ -136,9 +135,6 @@ public class SetModel implements Model.Set {
command.obj = cache;
dao.executeCommand(command);
}
//endregion
//region other
@Override
public void setPresenter(Presenter.SetList presenter) {
@ -150,11 +146,6 @@ public class SetModel implements Model.Set {
return presenter;
}
//endregion
//GLM
@Override
public List<com.hikapro.backpack.model.entities.Set> getSets()
{

View File

@ -1,10 +1,22 @@
package com.hikapro.backpack.model;
import android.graphics.Bitmap;
import android.os.Message;
import android.widget.Toast;
import com.hikapro.backpack.App;
import com.hikapro.backpack.R;
import com.hikapro.backpack.model.dao.Command;
import com.hikapro.backpack.model.dao.DAO;
import com.hikapro.backpack.model.dao.Event;
import com.hikapro.backpack.model.entities.Category;
import com.hikapro.backpack.model.entities.Item;
import com.hikapro.backpack.presenter.Presenter;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
/**
* Created by tariel on 16/05/16.
*/
@ -12,30 +24,56 @@ public class ShareModel implements Model.Share {
private Presenter.Share presenter;
private DAO dao;
private Bitmap[] picCache;
public ShareModel() {
this.dao = DAO.getInstance();
dao.registerObserver(this);
}
@Override
public void onDestroy(boolean isConfigurationChanging) {
if ( !isConfigurationChanging ) {
presenter = null;
}
dao.unregisterObserver(this);
}
@Override
public void executeQuery() {
if (picCache == null) {
Message command;
dao.registerObserver(this);
command = Message.obtain();
command.what = Command.SHARING_GET_PIC;
dao.executeCommand(command);
} else
notifyDataSetChanged();
}
@Override
public void notifyDataSetChanged() {
if (presenter != null)
presenter.notifyDataSetChanged();
}
@Override
public void onEvent(Message event) {
switch (event.what) {
case Event.SHARING_GET_PIC_ERROR:
if (!NetworkUtil.isInternetAvailable()) {
Toast.makeText(App.getAppContext(), R.string.no_connection, Toast.LENGTH_SHORT).show();
}
notifyDataSetChanged();
break;
case Event.SHARING_PIC_LOADED:
picCache = (Bitmap[]) event.obj;
notifyDataSetChanged();
break;
}
}
@Override
@ -47,4 +85,8 @@ public class ShareModel implements Model.Share {
public Presenter.Share getPresenter() {
return presenter;
}
public Bitmap[] getSharingPics() {
return picCache;
}
}

View File

@ -5,11 +5,6 @@ package com.hikapro.backpack.model.dao;
*/
public interface Command {
int SET_SCOPE_END = 0x77;
int ITEM_SCOPE_END = 0x8B;
int MY_LIST_SCOPE_END = 0x9F;
int SET_GET_ALL = 0x64;
int SET_REORDER = 0x65;
int SET_GET_ITEMS = 0x66;
@ -32,15 +27,10 @@ public interface Command {
int ITEM_REMOVAL_CANCEL = 0x80;
int ITEM_READ = 0x81;
int MY_LIST_POST = 0x8C;
int MY_LIST_ITEM_ADD = 0x8D;
int MY_LIST_ITEM_DELETE = 0x8E;
int MY_LIST_CLEAR = 0x8F;
int SHARING_GET_PIC = 0x8C;
int SYNC = 0xA0;
int SYNC_IF_NOT_EXISTS = 0xA1;
int SYNC_READ_FROM_FILE = 0xA2;
int TEST = 0xC8;
}

View File

@ -32,6 +32,7 @@ import java.util.concurrent.TimeUnit;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.hikapro.backpack.App;
import com.hikapro.backpack.R;
import com.hikapro.backpack.model.Api;
import com.hikapro.backpack.model.Model;
import com.hikapro.backpack.model.NetworkUtil;
@ -40,8 +41,10 @@ import com.hikapro.backpack.model.SetModel;
import com.hikapro.backpack.model.entities.Category;
import com.hikapro.backpack.model.entities.Item;
import com.hikapro.backpack.model.entities.Set;
import com.hikapro.backpack.model.entities.SharingPicture;
import com.hikapro.backpack.model.entities.Timestamp;
import com.hikapro.backpack.model.entities.UpdateLog;
import com.hikapro.backpack.presenter.adapters.helper.AppRater;
import retrofit2.Response;
@ -55,15 +58,12 @@ public class DAO {
private static final int KEEP_ALIVE_TIME = 1;
private static final TimeUnit KEEP_ALIVE_TIME_UNIT = TimeUnit.SECONDS;
private static final int MY_LIST_ID = 15;
//endregion
private static DAO instance;
private final ThreadPoolExecutor threadPool;
private final Handler handler;
private SetModel setModel;
private final Api api;
private Context context;
private DbHelper helper;
@ -278,16 +278,10 @@ public class DAO {
threadPool.execute(itemTask);
break;
case Command.MY_LIST_ITEM_ADD :
break;
case Command.MY_LIST_ITEM_DELETE :
break;
case Command.MY_LIST_POST :
break;
case Command.MY_LIST_CLEAR :
case Command.SHARING_GET_PIC:
imageProviderTask = new ImageProviderTask(Command.SHARING_GET_PIC,
Process.THREAD_PRIORITY_MORE_FAVORABLE);
threadPool.execute(imageProviderTask);
break;
case Command.SYNC:
@ -329,6 +323,26 @@ public class DAO {
values = Db.LogTable.toContentValues(timestamp);
db.insert(Db.LogTable.TABLE_NAME, null, values);
db.setTransactionSuccessful();
} catch (Exception ex) {
Log.e("Insert Timestamp", ex.getMessage());
} finally {
db.endTransaction();
db.close();
}
}
}
private void insertSharingPic(SharingPicture sharingPicture) {
if (sharingPicture != null) {
ContentValues values;
SQLiteDatabase db = getWriteDB();
try {
db.beginTransaction();
values = Db.SharingPicsTable.toContentValues(sharingPicture);
db.insert(Db.SharingPicsTable.TABLE_NAME, null, values);
db.setTransactionSuccessful();
} catch (Exception ex) {
Log.e("Inserting sharing photo", ex.getMessage());
} finally {
db.endTransaction();
db.close();
@ -347,6 +361,8 @@ public class DAO {
db.insert(Db.ItemsTable.TABLE_NAME, null, values);
}
db.setTransactionSuccessful();
} catch (Exception ex) {
Log.e("Insert Items", ex.getMessage());
} finally {
db.endTransaction();
db.close();
@ -390,6 +406,8 @@ public class DAO {
} else {
ret = item.getId();
}
} catch (Exception ex) {
Log.e("Insert Item", ex.getMessage());
} finally {
if (cursor != null)
cursor.close();
@ -414,6 +432,8 @@ public class DAO {
db.insert(Db.CategoriesTable.TABLE_NAME, null, values);
}
db.setTransactionSuccessful();
} catch (Exception ex) {
Log.e("Insert Categories", ex.getMessage());
} finally {
db.endTransaction();
db.close();
@ -436,6 +456,8 @@ public class DAO {
++i;
}
db.setTransactionSuccessful();
} catch (Exception ex) {
Log.e("Insert Sets", ex.getMessage());
} finally {
db.endTransaction();
db.close();
@ -455,6 +477,8 @@ public class DAO {
db.insert(Db.SetItemsTable.TABLE_NAME, null, values);
}
db.setTransactionSuccessful();
} catch (Exception ex) {
Log.e("Insert Set Items", ex.getMessage());
} finally {
db.endTransaction();
}
@ -471,6 +495,8 @@ public class DAO {
values = Db.SetItemsTable.toContentValues(setId, itemId, userDefined);
ret = db.insert(Db.SetItemsTable.TABLE_NAME, null, values);
db.setTransactionSuccessful();
} catch (Exception ex) {
Log.e("Insert Set Item", ex.getMessage());
} finally {
db.endTransaction();
db.close();
@ -501,6 +527,30 @@ public class DAO {
cursor = db.rawQuery(q,null);
if (cursor.moveToNext())
ret = Db.LogTable.parseCursor(cursor);
} catch (Exception ex) {
Log.e("Update Log", ex.getMessage());
} finally {
if (cursor != null)
cursor.close();
if (db != null)
db.close();
}
return ret;
}
private SharingPicture readLastSharingPic() {
SharingPicture ret = null;
SQLiteDatabase db = null;
Cursor cursor = null;
try {
db = getReadDB();
String q = String.format("SELECT * FROM %s ORDER BY %s DESC LIMIT 1",
Db.SharingPicsTable.TABLE_NAME, Db.SharingPicsTable.COLUMN_ID);
cursor = db.rawQuery(q,null);
if (cursor.moveToNext())
ret = Db.SharingPicsTable.parseCursor(cursor);
} catch (Exception e) {
Log.e("Reading sharing pic", e.getMessage());
} finally {
if (cursor != null)
cursor.close();
@ -523,7 +573,7 @@ public class DAO {
ret = Db.ItemsTable.parseCursor(cursor);
}
} catch (Exception e) {
//TODO write to log here
Log.e("Find item", e.getMessage());
} finally {
if (cursor != null)
cursor.close();
@ -564,12 +614,8 @@ public class DAO {
if (cursor.moveToNext()) {
ret = Db.ItemsTable.parseCursor(cursor);
}
} catch (SQLiteException e) {
//TODO write to log here
} catch (Exception e) {
//TODO write to log here
Log.e("Read item", e.getMessage());
} finally {
if (cursor != null)
cursor.close();
@ -610,12 +656,8 @@ public class DAO {
if (cursor.moveToNext()) {
ret = Db.ItemsTable.parseCursor(cursor);
}
} catch (SQLiteException e) {
//TODO write to log here
} catch (Exception e) {
//TODO write to log here
Log.e("Read item", e.getMessage());
} finally {
if (cursor != null)
cursor.close();
@ -659,16 +701,10 @@ public class DAO {
cursor = db.rawQuery(query, new String[]{String.valueOf(setId)});
while (cursor.moveToNext()) {
item = Db.ItemsTable.parseCursor(cursor);
// if (!packed && item.isPendingRemoval())
// continue;
ret.add(item);
}
} catch (SQLiteException e) {
//TODO write to log here
ret = null;
} catch (Exception e) {
//TODO write to log here
Log.e("Read items", e.getMessage());
ret = null;
} finally {
if (cursor != null)
@ -679,37 +715,6 @@ public class DAO {
return ret;
}
private List<Item> readItemsLike(String like) {
List<Item> ret = new ArrayList<>(256);
Cursor cursor = null;
SQLiteDatabase db = null;
Item item;
String query = String.format("SELECT * FROM %s WHERE %s LIKE %s",
Db.ItemsTable.TABLE_NAME,
Db.ItemsTable.COLUMN_NAME,
'\''+like+'%'+'\'');
try {
db = getReadDB();
cursor = db.rawQuery(query, null);
while (cursor.moveToNext()) {
item = Db.ItemsTable.parseCursor(cursor);
ret.add(item);
}
} catch (SQLiteException e) {
e.toString();
//TODO write to log here
} catch (Exception e) {
//TODO write to log here
} finally {
if (cursor != null)
cursor.close();
if (db != null)
db.close();
}
return ret;
}
private List<Item> readItemsLike(String like, int setId, boolean packed) {
List<Item> ret = new ArrayList<>(256);
Cursor cursor = null;
@ -746,15 +751,10 @@ public class DAO {
cursor = db.rawQuery(query, new String[]{String.valueOf(setId)});
while (cursor.moveToNext()) {
item = Db.ItemsTable.parseCursor(cursor);
// if (!packed && item.isPendingRemoval())
// continue;
ret.add(item);
}
} catch (SQLiteException e) {
//TODO write to log here
ret = null;
} catch (Exception e) {
//TODO write to log here
Log.e("Read items like", e.getMessage());
ret = null;
} finally {
if (cursor != null)
@ -792,11 +792,8 @@ public class DAO {
item.InList = true;
ret.add(item);
}
} catch (SQLiteException e) {
e.toString();
//TODO write to log here
} catch (Exception e) {
//TODO write to log here
Log.e("Read items like", e.getMessage());
} finally {
if (cursor != null)
cursor.close();
@ -823,11 +820,8 @@ public class DAO {
category = Db.CategoriesTable.parseCursor(cursor);
ret.put(category.getId(), category);
}
} catch (SQLiteException e) {
//TODO write to log here
} catch (Exception e) {
//TODO write to log here
Log.e("Read categories", e.getMessage());
} finally {
if (cursor != null)
cursor.close();
@ -861,6 +855,8 @@ public class DAO {
cursor = db.rawQuery(query, null);
if (cursor.moveToNext())
ret = Db.SetsTable.parseCursor(cursor);
} catch (Exception e) {
Log.e("Read set", e.getMessage());
} finally {
if (cursor != null)
cursor.close();
@ -884,11 +880,8 @@ public class DAO {
ret.add(set);
}
Collections.sort(ret);
} catch (SQLiteException e) {
//TODO write to log here
} catch (Exception e) {
//TODO write to log here
Log.e("Read sets", e.getMessage());
} finally {
if (cursor != null)
cursor.close();
@ -911,11 +904,37 @@ public class DAO {
ret = db.update(Db.ItemsTable.TABLE_NAME, values, "_id = ?",
new String[]{String.valueOf(id)});
db.setTransactionSuccessful();
} catch (SQLiteException e) {
//TODO write to log here
} catch (Exception e) {
//TODO write to log here
Log.e("Update local pic", e.getMessage());
} finally {
if (db != null) {
db.endTransaction();
db.close();
}
}
return ret;
}
private int updateSharingPicLocal(int id, String picPath, String picThumbPath) {
int ret = 0;
SQLiteDatabase db = null;
ContentValues values;
if (picPath == null && picThumbPath == null)
return ret;
try {
db = getWriteDB();
db.beginTransaction();
values = new ContentValues();
if (picPath != null)
values.put(Db.SharingPicsTable.COLUMN_PHOTO_LOCAL, picPath);
if (picThumbPath != null)
values.put(Db.SharingPicsTable.COLUMN_PHOTO_THUMB_LOCAL, picThumbPath);
ret = db.update(Db.SharingPicsTable.TABLE_NAME, values, "_id = ?",
new String[]{String.valueOf(id)});
db.setTransactionSuccessful();
} catch (Exception e) {
Log.e("Update sharing pic path", e.getMessage());
ret = -1;
} finally {
if (db != null) {
db.endTransaction();
@ -940,11 +959,8 @@ public class DAO {
new String[]{String.valueOf(set.getId())});
}
db.setTransactionSuccessful();
} catch (SQLiteException e) {
//TODO write to log here
} catch (Exception e) {
//TODO write to log here
Log.e("Update sets order", e.getMessage());
} finally {
if (db != null) {
db.endTransaction();
@ -986,10 +1002,8 @@ public class DAO {
}
db.setTransactionSuccessful();
} catch (SQLiteException e) {
//TODO write to log here
} catch (Exception e) {
//TODO write to log here
Log.e("Update pending removal", e.getMessage());
} finally {
if (db != null) {
db.endTransaction();
@ -1032,10 +1046,8 @@ public class DAO {
new String[]{String.valueOf(setId)});
}
db.setTransactionSuccessful();
} catch (SQLiteException e) {
//TODO write to log here
} catch (Exception e) {
//TODO write to log here
Log.e("Update item deleted", e.getMessage());
} finally {
if (db != null) {
db.endTransaction();
@ -1064,11 +1076,8 @@ public class DAO {
new String[]{String.valueOf(setId)});
}
db.setTransactionSuccessful();
} catch (SQLiteException e) {
//TODO write to log here
ret = -1;
} catch (Exception e) {
//TODO write to log here
Log.e("Update set active", e.getMessage());
ret = -1;
} finally {
if (db != null) {
@ -1093,12 +1102,9 @@ public class DAO {
Db.SetItemsTable.COLUMN_PENDING_REMOVAL),
new String[]{String.valueOf(setId), "1"});
db.setTransactionSuccessful();
} catch (SQLiteException e) {
ret = -1;
//TODO write to log here
} catch (Exception e) {
ret = -1;
//TODO write to log here
Log.e("Clean packed", e.getMessage());
} finally {
if (db != null) {
db.endTransaction();
@ -1131,12 +1137,8 @@ public class DAO {
new String[]{String.valueOf(setId)});
}
db.setTransactionSuccessful();
} catch (SQLiteException e) {
//TODO write to log here
ret = -1;
} catch (Exception e) {
//TODO write to log here
Log.e("Update item packed", e.getMessage());
ret = -1;
} finally {
if (db != null) {
@ -1184,10 +1186,8 @@ public class DAO {
new String[]{String.valueOf(setId)});
}
db.setTransactionSuccessful();
} catch (SQLiteException e) {
//TODO write to log here
} catch (Exception e) {
//TODO write to log here
Log.e("Update item packed", e.getMessage());
} finally {
if (db != null) {
db.endTransaction();
@ -1228,11 +1228,8 @@ public class DAO {
String.format("%s = ? AND %s = ?", Db.SetItemsTable.COLUMN_SET, Db.SetItemsTable.COLUMN_USER_DEFINED),
new String[]{String.valueOf(setId), String.valueOf(1)});
db.setTransactionSuccessful();
} catch (SQLiteException e) {
//TODO write to log here
ret = -1;
} catch (Exception e) {
//TODO write to log here
Log.e("Restore defaults", e.getMessage());
ret = -1;
} finally {
if (db != null) {
@ -1259,11 +1256,8 @@ public class DAO {
new String[]{String.valueOf(set.getId())});
}
db.setTransactionSuccessful();
} catch (SQLiteException e) {
//TODO write to log here
} catch (Exception e) {
//TODO write to log here
Log.e("Update set names", e.getMessage());
} finally {
if (db != null) {
db.endTransaction();
@ -1289,11 +1283,8 @@ public class DAO {
new String[]{String.valueOf(category.getId())});
}
db.setTransactionSuccessful();
} catch (SQLiteException e) {
//TODO write to log here
} catch (Exception e) {
//TODO write to log here
Log.e("Update category names", e.getMessage());
} finally {
if (db != null) {
db.endTransaction();
@ -1320,11 +1311,8 @@ public class DAO {
new String[]{String.valueOf(item.getId())});
}
db.setTransactionSuccessful();
} catch (SQLiteException e) {
//TODO write to log here
} catch (Exception e) {
//TODO write to log here
Log.e("Update item names", e.getMessage());
} finally {
if (db != null) {
db.endTransaction();
@ -1351,11 +1339,8 @@ public class DAO {
new String[]{String.valueOf(id)});
db.setTransactionSuccessful();
} catch (SQLiteException e) {
//TODO write to log here
} catch (Exception e) {
//TODO write to log here
Log.e("Update log locale", e.getMessage());
} finally {
if (db != null) {
db.endTransaction();
@ -1370,27 +1355,6 @@ public class DAO {
//region Task classes
// MY LIST CLASS
private class MyListTask implements Runnable {
int currentCommand;
int priority;
public MyListTask(int command, int priority) {
this.currentCommand = command;
this.priority = priority;
}
@Override
public void run() {
android.os.Process.setThreadPriority(priority);
Message message = Message.obtain();
switch (currentCommand) {
}
handler.sendMessage(message);
}
}
// ITEM CLASS
private class ItemTask implements Runnable {
int currentCommand;
@ -1458,6 +1422,12 @@ public class DAO {
message.what = Event.ITEM_INSERTED;
message.arg1 = setId;
message.arg2 = item.getId();
AppRater.updateSharedPreferences(1);
if (AppRater.checkRatePrompt()) {
Message rateEvent = Message.obtain();
rateEvent.what = Event.NEED_TO_RATE_NOW;
handler.sendMessage(rateEvent);
}
}
} else {
message.what = Event.ITEM_INSERT_ERROR;
@ -1689,6 +1659,10 @@ public class DAO {
Response<Timestamp> response3 = api.getTimestamp().execute();
insertTimestamp(response3.body());
statusCode = response3.code();
Response<List<SharingPicture>> response4 = api.getSharingPicture().execute();
insertSharingPic(response4.body().get(0));
statusCode = response4.code();
message.what = Event.SYNC_COMPLETED;
}
}
@ -1703,13 +1677,13 @@ public class DAO {
break;
case Command.SYNC_READ_FROM_FILE:
try {
String sets = readSetsFromFile();
String categories = readCategoriesFromFile();
String items = readItemsFromFile();
String pic = readSharingPicFromFile();
if (sets != null && categories != null && items != null) {
if (sets != null && categories != null && items != null && pic != null) {
Gson gson = new Gson();
Type type = new TypeToken<List<Set>>() {
}.getType();
@ -1724,6 +1698,14 @@ public class DAO {
List<Item> itemsFromJson = gson.fromJson(items, type);
insertItems(itemsFromJson);
insertTimestamp(new Timestamp(1456083374));
type = new TypeToken<List<SharingPicture>>() {
}.getType();
List<SharingPicture> picFromJson = gson.fromJson(pic, type);
if (picFromJson != null) {
for (SharingPicture sharingPicture : picFromJson) {
insertSharingPic(sharingPicture);
}
}
message.what = Event.SYNC_COMPLETED;
} else {
message.what = Event.SYNC_FAILED;
@ -1801,13 +1783,38 @@ public class DAO {
message.what = Event.ITEM_IMAGE_LOAD_ERROR;
}
break;
case Command.SHARING_GET_PIC:
try {
SharingPicture sharingPicture = readLastSharingPic();
if (sharingPicture != null) {
Bitmap[] ret = null;
Bitmap bitmap1 = loadSharingImage(sharingPicture);
Bitmap bitmap2 = loadSharingThumbImage(sharingPicture);
if (bitmap1 != null || bitmap2 != null) {
ret = new Bitmap[2];
ret[0] = bitmap1;
ret[1] = bitmap2;
message.obj = ret;
message.what = Event.SHARING_PIC_LOADED;
} else
message.what = Event.SHARING_GET_PIC_ERROR;
} else
message.what = Event.SHARING_GET_PIC_ERROR;
} catch (Exception e) {
message.what = Event.SHARING_GET_PIC_ERROR;
}
break;
}
handler.sendMessage(message);
}
}
//endregion
private Bitmap loadItemImage(Item item){
private Bitmap loadItemImage(Item item) {
ImageDownloadHelper downloadHelper = new ImageDownloadHelper();
Bitmap bitmap = null;
String filename = null;
@ -1833,6 +1840,62 @@ public class DAO {
return bitmap;
}
private Bitmap loadSharingImage(SharingPicture sharingPicture) {
ImageDownloadHelper downloadHelper = new ImageDownloadHelper();
Bitmap bitmap = null;
String filename = null;
if (sharingPicture != null) {
if (!TextUtils.isEmpty(sharingPicture.getPhotoLocal()))
bitmap = BitmapFactory.decodeFile(sharingPicture.getPhotoLocal());
// cannot retrieve, download and save then
if (bitmap == null) { // return it
bitmap = downloadHelper.loadImage(sharingPicture.getPhotoUrl());
if (bitmap != null) {
if (downloadHelper.isExternalStorageWritable()) {
filename = downloadHelper.saveImageExternal("sharing_pic", bitmap);
} else {
filename = downloadHelper.saveImageInternal("sharing_pic", bitmap);
}
updateSharingPicLocal(sharingPicture.getId(), filename, null);
}
}
if (bitmap == null) {
bitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.sharing_pic_default);
}
}
return bitmap;
}
private Bitmap loadSharingThumbImage(SharingPicture sharingPicture) {
ImageDownloadHelper downloadHelper = new ImageDownloadHelper();
Bitmap bitmap = null;
String filename = null;
if (sharingPicture != null) {
if (!TextUtils.isEmpty(sharingPicture.getPhotoThumbLocal()))
bitmap = BitmapFactory.decodeFile(sharingPicture.getPhotoThumbLocal());
// cannot retrieve, download and save then
if (bitmap == null) { // return it
bitmap = downloadHelper.loadImage(sharingPicture.getPhotoThumbUrl());
if (bitmap != null) {
if (downloadHelper.isExternalStorageWritable()) {
filename = downloadHelper.saveImageExternal("sharing_pic_thumb", bitmap);
} else {
filename = downloadHelper.saveImageInternal("sharing_pic_thumb", bitmap);
}
updateSharingPicLocal(sharingPicture.getId(), null, filename);
}
}
if (bitmap == null) {
bitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.sharing_pic_thumb_default);
}
}
return bitmap;
}
private String readSetsFromFile() {
String sets = null;
try {
@ -1877,4 +1940,19 @@ public class DAO {
}
return items;
}
private String readSharingPicFromFile() {
String sharingPic = null;
try {
InputStream is = App.getAppContext().getAssets().open("jsons/sharing_photos.json");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
sharingPic = new String(buffer, "UTF-8");
} catch (IOException ex) {
Log.e("Reading json", ex.getMessage());
}
return sharingPic;
}
}

View File

@ -13,6 +13,7 @@ import java.util.Locale;
import com.hikapro.backpack.model.entities.Category;
import com.hikapro.backpack.model.entities.Item;
import com.hikapro.backpack.model.entities.Set;
import com.hikapro.backpack.model.entities.SharingPicture;
import com.hikapro.backpack.model.entities.Timestamp;
import com.hikapro.backpack.model.entities.UpdateLog;
@ -53,6 +54,51 @@ public class Db {
}
public abstract static class SharingPicsTable {
public static final String TABLE_NAME = "sharing_pics";
public static final String COLUMN_ID = "_id";
public static final String COLUMN_PHOTO_URL = "photo_url";
public static final String COLUMN_PHOTO_THUMB_URL = "photo_thumb_url";
public static final String COLUMN_PHOTO_LOCAL = "photo_local";
public static final String COLUMN_PHOTO_THUMB_LOCAL = "photo_thumb_local";
public static final String CREATE =
"CREATE TABLE " + TABLE_NAME + " (" +
COLUMN_ID + " INTEGER PRIMARY KEY, " +
COLUMN_PHOTO_URL + " TEXT, " +
COLUMN_PHOTO_THUMB_URL + " TEXT, " +
COLUMN_PHOTO_LOCAL + " TEXT, " +
COLUMN_PHOTO_THUMB_LOCAL + " TEXT" +
" ); ";
public static ContentValues toContentValues(SharingPicture sharingPicture) {
ContentValues values = new ContentValues();
values.put(COLUMN_ID, sharingPicture.getId());
if (sharingPicture.getPhotoUrl() != null)
values.put(COLUMN_PHOTO_URL, sharingPicture.getPhotoUrl());
if (sharingPicture.getPhotoThumbUrl() != null)
values.put(COLUMN_PHOTO_THUMB_URL, sharingPicture.getPhotoThumbUrl());
if (sharingPicture.getPhotoLocal() != null)
values.put(COLUMN_PHOTO_LOCAL, sharingPicture.getPhotoLocal());
if (sharingPicture.getPhotoThumbLocal() != null)
values.put(COLUMN_PHOTO_THUMB_LOCAL, sharingPicture.getPhotoThumbLocal());
return values;
}
public static SharingPicture parseCursor(Cursor cursor) {
SharingPicture sharingPicture = new SharingPicture();
sharingPicture.setId(cursor.getInt(cursor.getColumnIndexOrThrow(COLUMN_ID)));
sharingPicture.setPhotoUrl(cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_PHOTO_URL)));
sharingPicture.setPhotoThumbUrl(cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_PHOTO_THUMB_URL)));
sharingPicture.setPhotoLocal(cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_PHOTO_LOCAL)));
sharingPicture.setPhotoThumbLocal(cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_PHOTO_THUMB_LOCAL)));
return sharingPicture;
}
}
public abstract static class ItemsTable {
public static final String TABLE_NAME = "items";
@ -103,9 +149,7 @@ public class Db {
values.put(COLUMN_PHOTO_LOCAL, item.getPhotoLocal());
values.put(COLUMN_USER_DEFINED, item.isUserDefined());
/*
values.put(COLUMN_PHOTO_THUMB_LOCAL, item.getName());
*/
return values;
}
@ -194,11 +238,7 @@ public class Db {
values.put(COLUMN_PHOTO_THUMBNAIL_URL, set.getPhotoThumbnail());
values.put(COLUMN_LINE_NUMBER, lineNumber);
values.put(COLUMN_ACTIVE_QTY, items.size());
/*
values.put(COLUMN_PHOTO_LOCAL, "");
values.put(COLUMN_PHOTO_THUMB_LOCAL, "");
values.put(COLUMN_PHOTO_THUMBNAIL_LOCAL, "");
*/
return values;
}

View File

@ -40,6 +40,7 @@ public class DbHelper extends SQLiteOpenHelper {
db.execSQL(Db.SetsTable.CREATE);
db.execSQL(Db.LogTable.CREATE);
db.execSQL(Db.SetItemsTable.CREATE);
db.execSQL(Db.SharingPicsTable.CREATE);
if (oldVersion < 2) {
// place the logic here

View File

@ -52,15 +52,9 @@ public interface Event {
int ITEM_REMOVAL_CANCELED = 0x1D;
int ITEM_READ_COMPLETED = 0x1E;
int MY_LIST_POST_ERROR = -0x28;
int MY_LIST_ITEM_ADD_ERROR = -0x29;
int MY_LIST_ITEM_DELETE_ERROR = -0x2A;
int MY_LIST_CLEAR_ERROR = -0x2B;
int SHARING_GET_PIC_ERROR = -0x28;
int MY_LIST_POSTED = 0x28;
int MY_LIST_ITEM_ADDED = 0x29;
int MY_LIST_ITEM_DELETED = 0x2A;
int MY_LIST_CLEARED = 0x2B;
int SHARING_PIC_LOADED = 0x28;
int SYNC_FAILED = -0x3C;
int SYNC_NO_CONNECTION = -0x3D;
@ -68,6 +62,7 @@ public interface Event {
int NOT_IMPLEMENTED = 0x50;
int NOT_UNDERSTAND = 0x51;
int NEED_TO_RATE_NOW = 0x52;
}

View File

@ -7,6 +7,7 @@ import android.net.Uri;
import android.os.Environment;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.widget.Toast;
import java.io.File;
import java.io.FileOutputStream;
@ -16,6 +17,8 @@ import java.net.URL;
import java.net.URLConnection;
import com.hikapro.backpack.App;
import com.hikapro.backpack.R;
import com.hikapro.backpack.model.NetworkUtil;
/**
* Created by tariel on 04/05/16.
@ -32,6 +35,7 @@ public class ImageDownloadHelper {
public Bitmap loadImage(String netPath) {
Bitmap bitmap = null;
if (NetworkUtil.isInternetAvailable()) {
try {
URL url = new URL(netPath);
URLConnection conn = url.openConnection();
@ -43,6 +47,7 @@ public class ImageDownloadHelper {
} catch (Exception ex) {
Log.e(IMAGE_DOWNLOAD_TAG, " File cannot be downloaded due to exception.");
}
}
return bitmap;
}

View File

@ -1,15 +0,0 @@
package com.hikapro.backpack.model.dao;
/**
* Created by tariel on 27/04/16.
*/
public class Test {
private static Test ourInstance = new Test();
public static Test getInstance() {
return ourInstance;
}
private Test() {
}
}

View File

@ -174,10 +174,6 @@ public class Item implements Comparable<Item>, Serializable {
@Override
public int compareTo(Item another) {
/*
int cmp = Integer.valueOf(category).compareTo(Integer.valueOf(another.category));
return (cmp != 0 ? cmp : name.compareTo(another.name));
*/
int cmp = Integer.valueOf(category).compareTo(Integer.valueOf(another.category));
if (cmp != 0)
return cmp;

View File

@ -0,0 +1,83 @@
package com.hikapro.backpack.model.entities;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by tariel on 24/07/16.
*/
public class SharingPicture {
@SerializedName("id")
@Expose
private int id;
@SerializedName("photo")
@Expose
private String photoUrl;
@SerializedName("photo_thumb")
@Expose
private String photoThumbUrl;
private String photoLocal;
private String photoThumbLocal;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPhotoUrl() {
return photoUrl;
}
public void setPhotoUrl(String photoUrl) {
this.photoUrl = photoUrl;
}
public String getPhotoThumbUrl() {
return photoThumbUrl;
}
public void setPhotoThumbUrl(String photoThumbUrl) {
this.photoThumbUrl = photoThumbUrl;
}
public String getPhotoLocal() {
return photoLocal;
}
public void setPhotoLocal(String photoLocal) {
this.photoLocal = photoLocal;
}
public String getPhotoThumbLocal() {
return photoThumbLocal;
}
public void setPhotoThumbLocal(String photoThumbLocal) {
this.photoThumbLocal = photoThumbLocal;
}
@Override
public int hashCode() {
return 31 * id;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SharingPicture that = (SharingPicture) o;
if (id != that.id)
return false;
return true;
}
}

View File

@ -19,6 +19,4 @@ public class Timestamp {
this.timestamp = value;
}
}

View File

@ -118,34 +118,24 @@ public class AddPresenter implements Presenter.Add {
cancelButton = (Button) custActionBarView.findViewById(R.id.action_add_cancel);
saveButton = (Button) custActionBarView.findViewById(R.id.action_add_save);
cancelButton.setOnClickListener(new ActionBarButtonClickListener());
saveButton.setOnClickListener(new ActionBarButtonClickListener());
android.view.View.OnClickListener listener = new ActionBarButtonClickListener();
cancelButton.setOnClickListener(listener);
saveButton.setOnClickListener(listener);
}
}
searchView = (SearchView) view.findViewById(R.id.add_search);
searchView.setIconified(false);
searchView.setIconifiedByDefault(false);
searchView.setQueryHint("Enter a new item name");
searchView.setQueryHint(getActivityContext().getResources().getString(R.string.search_hint_add));
searchView.setSubmitButtonEnabled(false);
searchView.setBottom(20);
/*
Drawable d = getActivityContext().getResources().getDrawable( R.drawable.search_divider );
searchView.setDividerDrawable(d);*/
int magId = searchView.getContext().getResources().getIdentifier("android:id/search_mag_icon", null, null);
ImageView magImage = (ImageView) searchView.findViewById(magId);
magImage.setLayoutParams(new LinearLayout.LayoutParams(0, 0));
searchView.setMinimumHeight(40);
searchView.setOnQueryTextListener(new SearchTextListener());
/*
int searchPlateId = searchView.getContext().getResources().getIdentifier("android:id/search_plate", null, null);
// Getting the 'search_plate' LinearLayout.
android.view.View searchPlate = searchView.findViewById(searchPlateId);
// Setting background of 'search_plate' to earlier defined drawable.
searchPlate.setBackgroundResource(R.drawable.search_divider);
*/
return view;
}
@ -207,11 +197,11 @@ public class AddPresenter implements Presenter.Add {
private boolean checkUserInput() {
if (!canSave) {
if (searchView.getQuery().length() == 0)
Toast.makeText(getActivityContext(), "Please, enter a name", Toast.LENGTH_SHORT).show();
Toast.makeText(getActivityContext(), R.string.enter_name, Toast.LENGTH_SHORT).show();
else if (categoryContainerMain.getVisibility() == android.view.View.VISIBLE)
Toast.makeText(getActivityContext(), "Please, select a category", Toast.LENGTH_SHORT).show();
Toast.makeText(getActivityContext(), R.string.select_category, Toast.LENGTH_SHORT).show();
else
Toast.makeText(getActivityContext(), "Already in List!", Toast.LENGTH_SHORT).show();
Toast.makeText(getActivityContext(), R.string.already_in_list2, Toast.LENGTH_SHORT).show();
return false;
}
return true;
@ -269,7 +259,6 @@ public class AddPresenter implements Presenter.Add {
}
currentCategoryButton = (Button) v;
Toast.makeText(getActivityContext(), "Id " + currentCategoryButton.getId(), Toast.LENGTH_SHORT).show();
setSaveButtonAccess();
}
}
@ -281,7 +270,6 @@ public class AddPresenter implements Presenter.Add {
switch (v.getId())
{
case R.id.action_add_cancel :
Toast.makeText(getActivityContext(), "Cancel", Toast.LENGTH_SHORT).show();
searchView.clearFocus();
if (fragment != null)
fragment.getFragmentManager().popBackStack();

View File

@ -2,15 +2,19 @@ package com.hikapro.backpack.presenter;
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
@ -19,13 +23,11 @@ import java.lang.ref.WeakReference;
import com.hikapro.backpack.R;
import com.hikapro.backpack.model.Model;
import com.hikapro.backpack.model.entities.Item;
import com.hikapro.backpack.model.entities.Set;
import com.hikapro.backpack.presenter.adapters.helper.AppRater;
import com.hikapro.backpack.presenter.adapters.helper.Util;
import com.hikapro.backpack.presenter.adapters.helper.items.DividerDecoration;
import com.hikapro.backpack.presenter.adapters.ItemListAdapter;
import com.hikapro.backpack.presenter.adapters.helper.items.DividerDecoration2;
import com.hikapro.backpack.presenter.adapters.helper.items.ItemSwipeCallback;
import com.hikapro.backpack.presenter.adapters.helper.items.StickyHeaderDecoration;
import com.hikapro.backpack.view.View;
@ -51,8 +53,6 @@ public class ItemListPresenter implements Presenter.ItemList {
adapter.setHasStableIds(true);
}
// life cycle -->
@Override
public void onDestroy(boolean isChangingConfiguration) {
view = null;
@ -64,12 +64,12 @@ public class ItemListPresenter implements Presenter.ItemList {
@Override
public android.view.View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// TODO check nn
if (savedInstanceState != null)
set = (Set) savedInstanceState.getSerializable(BUNDLE_SET_LIST_KEY);
else
set = getView().getSet();
android.view.View view = inflater.inflate(R.layout.fragment_item_list, container, false);
LinearLayoutManager llm = new LinearLayoutManager(getActivityContext());
recycler = (RecyclerView) view.findViewById(R.id.items_recycler);
recycler.setLayoutManager(llm);
@ -88,6 +88,7 @@ public class ItemListPresenter implements Presenter.ItemList {
});
recycler.setHasFixedSize(true);
model.executeQuery();
footer = (LinearLayout) view.findViewById(R.id.item_list_footer);
packedCount = (TextView) footer.findViewById(R.id.footer_packed_count);
showPacked = (TextView) footer.findViewById(R.id.open_packed);
@ -97,6 +98,15 @@ public class ItemListPresenter implements Presenter.ItemList {
showPackedItems();
}
});
if (set != null) {
android.view.View con = view.findViewById(R.id.item_list_container);
applyBackground(con, set.getId());
}
return view;
}
private void setupActionBar() {
Activity activity = (Activity) getActivityContext();
if (activity != null) {
activity.invalidateOptionsMenu();
@ -110,19 +120,14 @@ public class ItemListPresenter implements Presenter.ItemList {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
return view;
}
@Override
public void onSaveInstanceState(Bundle outState) {
if (set != null)
outState.putSerializable(BUNDLE_SET_LIST_KEY, set);
}
// life cycle <--
// process -->
@Override
public void notifyDataSetChanged() {
adapter.notifyDataSetChanged();
@ -152,20 +157,25 @@ public class ItemListPresenter implements Presenter.ItemList {
} else {
footer.setVisibility(android.view.View.GONE);
}
}
private void showPackedItems () {
getView().showPackedItems(set);
rememberPosition();
}
private void rememberPosition() {
LinearLayoutManager llm = (LinearLayoutManager)recycler.getLayoutManager();
int pos = llm.findFirstVisibleItemPosition();
model.setLastVisiblePosition(pos);
Log.i("Last position remember", String.valueOf(pos));
}
@Override
public void showDetails(int position) {
getView().showItemDetail(getCurrentSet().getId(), model, position);
rememberPosition();
}
// process <--
// other impl -->
@Override
public void setView(View.ItemList view) {
@ -205,8 +215,6 @@ public class ItemListPresenter implements Presenter.ItemList {
Toast.makeText(getView().getAppContext(), message, Toast.LENGTH_SHORT).show();
}
// other impl <--
protected View.ItemList getView() throws NullPointerException {
if ( view != null )
return view.get();
@ -232,37 +240,102 @@ public class ItemListPresenter implements Presenter.ItemList {
@Override
public void restore(final int setId) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivityContext(), AlertDialog.THEME_HOLO_DARK);
builder.setMessage(R.string.dlg_restore_txt)
.setTitle(R.string.dlg_restore_header);
final Dialog dialog = new Dialog(getActivityContext());
builder.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_confirm);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
Button cancel = (Button) dialog.findViewById(R.id.button_cancel);
Button ok = (Button) dialog.findViewById(R.id.button_ok);
cancel.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(android.view.View v) {
try {
dialog.dismiss();
} catch (Exception e) {
}
}
});
ok.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(android.view.View v) {
model.restoreSet(setId);
dialog.dismiss();
}
});
builder.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
//Button button = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
//button.setBackgroundColor(Color.GREEN);
/*
Drawable d = button.getBackground();
PorterDuffColorFilter filter = new PorterDuffColorFilter(Color.GREEN, PorterDuff.Mode.SRC_ATOP);
d.setColorFilter(filter);*/
//button = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
//button.setBackgroundColor(Color.GRAY);
/*
d = button.getBackground();
filter = new PorterDuffColorFilter(Color.GRAY, PorterDuff.Mode.SRC_ATOP);
d.setColorFilter(filter);*/
public void applyBackground(android.view.View view, int setId) {
Drawable drawable = null;
switch (setId) {
case 1:
drawable = ContextCompat.getDrawable(view.getContext(), R.drawable.ic_item_list_1);
break;
case 2:
drawable = ContextCompat.getDrawable(view.getContext(), R.drawable.ic_item_list_2);
break;
case 3:
drawable = ContextCompat.getDrawable(view.getContext(), R.drawable.ic_item_list_3);
break;
case 4:
drawable = ContextCompat.getDrawable(view.getContext(), R.drawable.ic_item_list_4);
break;
case 5:
drawable = ContextCompat.getDrawable(view.getContext(), R.drawable.ic_item_list_5);
break;
case 6:
drawable = ContextCompat.getDrawable(view.getContext(), R.drawable.ic_item_list_6);
break;
case 7:
// nothing
break;
case 8:
drawable = ContextCompat.getDrawable(view.getContext(), R.drawable.ic_item_list_8);
break;
case 9:
// nothing
break;
case 10:
drawable = ContextCompat.getDrawable(view.getContext(), R.drawable.ic_item_list_10);
break;
case 11:
// nothing
break;
case 12:
// nothing
break;
case 13:
// nothing
break;
case 14:
drawable = ContextCompat.getDrawable(view.getContext(), R.drawable.ic_item_list_14);
break;
default:
}
if (drawable != null)
view.setBackground(drawable);
else
view.setBackgroundColor(ContextCompat.getColor(view.getContext(), R.color.colorListBackground));
}
@Override
public void onResume() {
recycler.scrollToPosition(model.getLastVisiblePosition());
setupActionBar();
}
@Override
public void showRateDialog() {
AppRater.showRateDialog(getActivityContext());
}
}

View File

@ -60,9 +60,8 @@ public class PackedListPresenter extends ItemListPresenter {
}
});
recycler.setHasFixedSize(true);
model.executeQuery();
recycler.scrollToPosition(model.getLastVisiblePosition());
backToList = (TextView) view.findViewById(R.id.back_to_list);
packedCount = (TextView) view.findViewById(R.id.header_packed_count);
unpackButton = (Button) view.findViewById(R.id.unpack_button);

View File

@ -60,6 +60,8 @@ public interface Presenter {
void filter(String query);
void unpack(int setId);
void restore(int setId);
void onResume();
void showRateDialog();
}
interface ItemDetail extends Base {
@ -78,6 +80,7 @@ public interface Presenter {
interface Share extends Base {
void setView(View.Share view);
void setModel(Model.Share model);
void notifyDataSetChanged();
Model.Share getModel();
void onDestroy(boolean isChangingConfiguration);
android.view.View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);

View File

@ -45,9 +45,6 @@ public class SetListPresenter implements Presenter.SetList {
this.adapter = new SetListAdapter(this);
}
// life cycle -->
//GLM_add_resources_SetList
@Override
public void onItemDismiss(int position) {
@ -85,7 +82,9 @@ public class SetListPresenter implements Presenter.SetList {
setRecycler.setLayoutManager(llm);
setRecycler.setAdapter(adapter);
setRecycler.setItemAnimator(new DefaultItemAnimator());
setRecycler.setHasFixedSize(true);
model.executeQuery();
setRecycler.scrollToPosition(model.getLastVisiblePosition());
//GLM_add_resources_SetList
ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(adapter);
@ -98,19 +97,11 @@ public class SetListPresenter implements Presenter.SetList {
return view;
}
// life cycle <--
// process -->
@Override
public void notifyDataSetChanged() {
adapter.notifyDataSetChanged();
}
// process <--
// other impl -->
@Override
public Context getAppContext() {
try {
@ -142,8 +133,6 @@ public class SetListPresenter implements Presenter.SetList {
return model;
}
// other impl <--
private View.SetList getView() throws NullPointerException {
if ( view != null )
return view.get();
@ -170,8 +159,11 @@ public class SetListPresenter implements Presenter.SetList {
}
public void showItemList(Set set) {
if (getView() != null)
if (getView() != null) {
getView().showItemList(set);
LinearLayoutManager llm = (LinearLayoutManager)setRecycler.getLayoutManager();
model.setLastVisiblePosition(llm.findFirstVisibleItemPosition());
}
else
Toast.makeText(getActivityContext(), "There is no view in presenter", Toast.LENGTH_SHORT).show();
}

View File

@ -1,19 +1,32 @@
package com.hikapro.backpack.presenter;
import android.app.ActionBar;
import android.app.Activity;
import android.app.Dialog;
import android.app.Fragment;
import android.content.ContentResolver;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;
import com.facebook.share.Sharer;
import com.facebook.share.model.ShareHashtag;
import com.facebook.share.model.ShareLinkContent;
@ -22,6 +35,13 @@ import com.hikapro.backpack.R;
import com.hikapro.backpack.model.Model;
import com.hikapro.backpack.view.View;
import org.brickred.socialauth.Profile;
import org.brickred.socialauth.android.DialogListener;
import org.brickred.socialauth.android.SocialAuthAdapter;
import org.brickred.socialauth.android.SocialAuthError;
import org.brickred.socialauth.android.SocialAuthListener;
import java.io.File;
import java.lang.ref.WeakReference;
/**
@ -34,6 +54,16 @@ public class SharePresenter implements Presenter.Share {
private Button facebookButton;
private Button twitterButton;
private Button cancelButton;
private ImageView sharingImage;
private TextView twitterLogin;
private Profile twitterProfile;
private ViewGroup progress;
private boolean canPost;
private boolean showError;
protected SocialAuthAdapter socialAuthAdapter;
private WeakReference<View.Share> view;
private Model.Share model;
@ -67,6 +97,19 @@ public class SharePresenter implements Presenter.Share {
this.model = model;
}
@Override
public void notifyDataSetChanged() {
Bitmap [] pics = model.getSharingPics();
if (pics != null && pics[1] != null && pics[0] != null) {
canPost = true;
sharingImage.setImageBitmap(pics[0]);
} else {
showError = true;
canPost = true;
}
setVisibility();
}
@Override
public Model.Share getModel() {
return model;
@ -92,44 +135,95 @@ public class SharePresenter implements Presenter.Share {
shareDialog = new ShareDialog((Activity) getActivityContext());
facebookButton = (Button) v.findViewById(R.id.facebook_share_button);
twitterButton = (Button) v.findViewById(R.id.twitter_share_button);
progress = (ViewGroup) v.findViewById(R.id.share_progress_container);
sharingImage = (ImageView) v.findViewById(R.id.share_image_view);
model.executeQuery();
shareDialog.registerCallback(callbackManager, new
FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {}
public void onSuccess(Sharer.Result result) {
Toast.makeText(getActivityContext(), R.string.fb_posted,
Toast.LENGTH_SHORT).show();
}
@Override
public void onCancel() {}
@Override
public void onError(FacebookException error) {}
public void onError(FacebookException error) {
Toast.makeText(getActivityContext(), R.string.fb_error,
Toast.LENGTH_SHORT).show();
Log.e("Share", "Facebook error", error);
}
});
facebookButton.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(android.view.View v) {
if (ShareDialog.canShow(ShareLinkContent.class)) {
try {
Context context = getAppContext();
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Test Pack With Me app")
.setContentDescription("Test of facebook integration")
.setContentUrl(Uri.parse("http://developers.facebook.com/android"))
.setContentTitle(context.getString(R.string.facebook_sharing_header))
.setContentDescription(context.getString(R.string.facebook_sharing_txt))
.setContentUrl(Uri.parse(context.getString(R.string.facebook_url)))
.setShareHashtag(new ShareHashtag.Builder()
.setHashtag("#PackWithMe")
.build())
.build();
shareDialog.show(linkContent);
} catch (Exception e) {
Toast.makeText(getActivityContext(), R.string.fb_error,
Toast.LENGTH_SHORT).show();
Log.e("Sharing", "Facebook error", e);
}
}
});
twitterButton.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(android.view.View v) {
Toast.makeText(getActivityContext(), "Not implemented!", Toast.LENGTH_SHORT).show();
}
});
twitterButton.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(android.view.View v) {
if (! canPost )
Toast.makeText(getActivityContext(), R.string.please_wait, Toast.LENGTH_SHORT).show();
else if (showError)
Toast.makeText(getActivityContext(), R.string.cannot_post, Toast.LENGTH_SHORT).show();
else
postToTwitter();
}
});
Activity activity = (Activity) getActivityContext();
if (activity != null) {
ActionBar actionBar = activity.getActionBar();
if (actionBar != null) {
ViewGroup custActionBarView = (ViewGroup) inflater.inflate(R.layout.share_cust_actionbar, null);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setCustomView(custActionBarView);
cancelButton = (Button) custActionBarView.findViewById(R.id.action_share_cancel);
cancelButton.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(android.view.View v) {
Fragment fragment = (Fragment) getView();
if (fragment != null)
fragment.getFragmentManager().popBackStack();
}
});
}
}
twitterLogin = (TextView) v.findViewById(R.id.twitter_login);
setVisibility();
return v;
}
@ -139,4 +233,171 @@ public class SharePresenter implements Presenter.Share {
else
throw new NullPointerException("View is unavailable");
}
}
private class ResponseListener implements DialogListener {
Bitmap bitmap;
String message;
public ResponseListener(Bitmap bitmap, String message) {
this.bitmap = bitmap;
this.message = message;
}
@Override
public void onComplete(final Bundle values) {
try {
socialAuthAdapter.getUserProfileAsync(new ProfileDataListener());
socialAuthAdapter.uploadImageAsync(message, "PackWithMe.png",
bitmap, 0, new UploadImageListener());
} catch (Exception e) {
Log.e("ShareTwitter", e.getMessage());
}
}
@Override
public void onError(SocialAuthError error) {
Log.d("ShareTwitter", "Authentication Error: " + error.getMessage());
}
@Override
public void onCancel() {
Log.d("ShareTwitter", "Authentication Cancelled");
}
@Override
public void onBack() {
Log.d("ShareTwitter", "Dialog Closed by pressing Back Key");
}
}
private final class UploadImageListener implements SocialAuthListener {
@Override
public void onExecute(String s, Object o) {
Integer status = (Integer) o;
try {
if (status.intValue() == 200 || status.intValue() == 201
|| status.intValue() == 204) {
Toast.makeText(getActivityContext(), R.string.twitter_posted,
Toast.LENGTH_SHORT).show();
Log.d("ShareTwitter", "Posting completed");
} else {
Toast.makeText(getActivityContext(), R.string.twitter_error2,
Toast.LENGTH_SHORT).show();
Log.d("ShareTwitter", "Posting failed");
}
} catch (NullPointerException e) {
Toast.makeText(getActivityContext(), R.string.twitter_error2,
Toast.LENGTH_SHORT).show();
Log.e("ShareTwitter", e.getMessage());
}
}
@Override
public void onError(SocialAuthError e) {
Toast.makeText(getActivityContext(), "Posting to twitter failed!",
Toast.LENGTH_SHORT).show();
Log.e("ShareTwitter", e.getMessage());
}
}
private final class ProfileDataListener implements SocialAuthListener<Profile> {
@Override
public void onExecute(String s, Profile profile) {
twitterProfile = profile;
if (twitterProfile != null && twitterLogin != null) {
twitterLogin.setText(twitterProfile.getDisplayName());
}
}
@Override
public void onError(SocialAuthError socialAuthError) {
}
}
private void setVisibility() {
if (showError) {
progress.setVisibility(android.view.View.GONE);
sharingImage.setVisibility(android.view.View.VISIBLE);
}
else {
progress.setVisibility(canPost ? android.view.View.GONE : android.view.View.VISIBLE);
sharingImage.setVisibility(canPost ? android.view.View.VISIBLE : android.view.View.GONE);
}
}
private void postToTwitter() {
final Dialog dialog = new Dialog(getActivityContext());
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_twitter);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
Button cancel = (Button) dialog.findViewById(R.id.button_cancel);
Button post = (Button) dialog.findViewById(R.id.button_post);
final EditText editText = (EditText) dialog.findViewById(R.id.message);
final ImageView imageView = (ImageView) dialog.findViewById(R.id.image_to_post);
final TextView textView = (TextView) dialog.findViewById(R.id.chars_left);
textView.setText(String.valueOf(140 - editText.getText().length()));
if (model.getSharingPics() != null) {
Bitmap sharingBitmap = model.getSharingPics()[1];
if (sharingBitmap != null) {
imageView.setImageBitmap(sharingBitmap);
} else {
Toast.makeText(getActivityContext(), R.string.twitter_error, Toast.LENGTH_SHORT).show();
}
}
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
int left = 140 - s.length();
textView.setText(String.valueOf(left));
}
@Override
public void afterTextChanged(Editable s) {
}
});
cancel.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(android.view.View v) {
try {
dialog.dismiss();
} catch (Exception e) {
}
}
});
post.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(android.view.View v) {
socialAuthAdapter = new SocialAuthAdapter(new ResponseListener(((BitmapDrawable)imageView.getDrawable()).getBitmap(),
editText.getText().toString()));
socialAuthAdapter.addProvider(SocialAuthAdapter.Provider.TWITTER, R.drawable.ic_twitter_icon);
socialAuthAdapter.authorize(getActivityContext(), SocialAuthAdapter.Provider.TWITTER);
dialog.dismiss();
}
});
dialog.show();
}
}

View File

@ -41,7 +41,7 @@ public class ItemDetailAdapter extends RecyclerView.Adapter<ItemViewHolder> {
public void onBindViewHolder(final ItemViewHolder holder, final int position) {
final Item item = presenter.getModel().getCurrentItem();
holder.cb_item.setChecked(item.isPacked());
holder.tv_text.setText(item.getName() + " " + item.getId() + " pos " + position);
holder.tv_text.setText(item.getName());
holder.im_info.setVisibility(View.GONE);
if (item.isPendingRemoval()) {
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

View File

@ -58,7 +58,7 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
final Item item = presenter.getModel().getItemByPosition(position);
holder.cb_item.setChecked(checkAll);
holder.tv_text.setText(item.getName() + " " + item.getId() + " pos " + position);
holder.tv_text.setText(item.getName());
//holder.tv_text.setTypeface(mainFace);
if (item.isPendingRemoval()) {
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

View File

@ -28,7 +28,7 @@ public class PackedListAdapter extends ItemListAdapter {
final Item item = presenter.getModel().getItemByPosition(position);
holder.cb_item.setChecked(checkAll);
holder.tv_text.setText(item.getName() + " " + item.getId() + " pos " + position);
holder.tv_text.setText(item.getName());
if (item.isPendingRemoval()) {
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
holder.cb_item.setVisibility(View.GONE);
@ -156,11 +156,8 @@ public class PackedListAdapter extends ItemListAdapter {
@Override
public void remove(Item item) {
if (item.isPendingRemoval()) {
presenter.getModel().unpackItem(item);
presenter.getModel().remove(item);
}
else
presenter.getModel().pendingRemove(item);
}
@ -169,4 +166,9 @@ public class PackedListAdapter extends ItemListAdapter {
presenter.getModel().pendingRemove(item);
}
@Override
public void pack(Item item) {
item.setPacked(false);
super.pack(item);
}
}

View File

@ -1,6 +1,8 @@
package com.hikapro.backpack.presenter.adapters;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
@ -37,7 +39,6 @@ public class SetListAdapter extends RecyclerView.Adapter<SetViewHolder> impleme
else
this.rightBracket = "";
}
holder.textView.setText(set.getName() + " " + rightBracket);
holder.textView.setTypeface(App.getMainFace());
String info = String.format("%s %d / %d",
@ -58,6 +59,9 @@ public class SetListAdapter extends RecyclerView.Adapter<SetViewHolder> impleme
return false;
}
});
holder.applyBackground(presenter.getAppContext(), set.getId());
}
@Override

View File

@ -0,0 +1,104 @@
package com.hikapro.backpack.presenter.adapters.helper;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.util.Log;
import android.view.Window;
import android.widget.Button;
import android.widget.Toast;
import com.hikapro.backpack.App;
import com.hikapro.backpack.R;
/**
* Created by tariel on 26/08/16.
*/
public class AppRater {
private final static String APP_PNAME = "com.hikapro.backpack";
private final static String APP_PREFERENCES = "backpack";
private final static String DO_NOT_SHOW = "notshow";
private final static String COUNT = "count";
private final static String TRIGGER_COUNT = "triggercount";
private final static int COUNT_UNTIL_FIRST_PROMPT = 2;
public static boolean checkRatePrompt() {
boolean ret = false;
SharedPreferences preferences = App.getAppContext().getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);
if (preferences.getBoolean(DO_NOT_SHOW, false))
ret = false;
else if (preferences.getInt(COUNT, 1) == preferences.getInt(TRIGGER_COUNT, COUNT_UNTIL_FIRST_PROMPT))
ret = true;
return ret;
}
public static void updateSharedPreferences(int countToAdd) {
SharedPreferences preferences = App.getAppContext().getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
int count = preferences.getInt(COUNT, 0) + countToAdd;
editor.putInt(COUNT, count);
editor.apply();
}
private static void later() {
SharedPreferences preferences = App.getAppContext().getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
int triggerCount = preferences.getInt(TRIGGER_COUNT, COUNT_UNTIL_FIRST_PROMPT);
triggerCount = triggerCount * 2 + triggerCount;
editor.putInt(TRIGGER_COUNT, triggerCount);
editor.apply();
}
private static void sure() {
SharedPreferences preferences = App.getAppContext().getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(DO_NOT_SHOW, true);
editor.apply();
}
public static void showRateDialog(final Context context) {
final Dialog dialog = new Dialog(context);
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_rate);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
final Button later = (Button) dialog.findViewById(R.id.button_later);
Button rate = (Button) dialog.findViewById(R.id.button_rate);
later.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(android.view.View v) {
try {
later();
dialog.dismiss();
} catch (Exception e) {
Log.e("Rate dialog", "Error while closing", e);
}
}
});
rate.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(android.view.View v) {
try {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
sure();
dialog.dismiss();
} catch (Exception e) {
Log.e("Rate dialog", "Error while rating", e);
}
}
});
dialog.show();
}
}

View File

@ -23,7 +23,6 @@ public class HeaderViewCache implements HeaderProvider {
View header = headerViews.get(headerId);
if (header == null) {
//TODO - recycle views
RecyclerView.ViewHolder viewHolder = adapter.onCreateHeaderViewHolder(parent);
adapter.onBindHeaderViewHolder(viewHolder, position);
header = viewHolder.itemView;

View File

@ -62,13 +62,6 @@ public class ItemSwipeCallback extends ItemTouchHelper.SimpleCallback {
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
int swipedPosition = viewHolder.getAdapterPosition();
/*
boolean undoOn = adapter.isUndoOn();
if (undoOn) {
adapter.pendingRemoval(swipedPosition);
} else {
adapter.remove(swipedPosition);
}*/
}
@Override

View File

@ -74,7 +74,6 @@ public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback {
itemViewHolder.onItemSelected();
}
}
super.onSelectedChanged(viewHolder, actionState);
}

View File

@ -45,7 +45,6 @@ public class AddFragment extends Fragment implements com.hikapro.backpack.view.V
// Required empty public constructor
}
// life cycle -->
@Override
public void onAttach(Context context) {
super.onAttach(context);
@ -149,12 +148,5 @@ public class AddFragment extends Fragment implements com.hikapro.backpack.view.V
public Set getSet() {
return (Set) getArguments().getSerializable(BUNDLE_SET_KEY);
}
/*
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_add, menu);
super.onCreateOptionsMenu(menu, inflater);
}
*/
}

View File

@ -74,7 +74,6 @@ public class ItemDetailFragment extends Fragment implements com.hikapro.backpack
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
presenter.setView(this);
View view = presenter.onCreateView(inflater, container, savedInstanceState);
Log.i(this.toString(), " onCreateView");
@ -103,13 +102,13 @@ public class ItemDetailFragment extends Fragment implements com.hikapro.backpack
@Override
public void onDestroyView() {
super.onDestroyView();
presenter.onDestroy(true); // TODO isChangingConfigurations
presenter.onDestroy(true);
Log.i(this.toString(), " onDestroyView");
}
@Override
public void onDestroy() {
super.onDestroy();
presenter.onDestroy(false); // TODO isChangingConfigurations
presenter.onDestroy(false);
Log.i(this.toString(), " onDestroy");
}
@Override
@ -123,8 +122,6 @@ public class ItemDetailFragment extends Fragment implements com.hikapro.backpack
Log.i(this.toString(), " onSaveInstanceState");
}
// life cycle <--
@Override
public void setPresenter(Presenter.ItemDetail presenter) {
this.presenter = presenter;

View File

@ -29,6 +29,7 @@ public class ItemListFragment extends Fragment implements com.hikapro.backpack.v
protected static final String BUNDLE_SET_KEY = "BUNDLE_SET_KEY";
private com.hikapro.backpack.view.View.ActivityCallback activityCallback;
private Presenter.ItemList presenter;
private boolean hz;
public ItemListFragment() {
// Required empty public constructor
@ -50,12 +51,11 @@ public class ItemListFragment extends Fragment implements com.hikapro.backpack.v
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_main, menu);
final MenuItem item = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) item.getActionView();
searchView.setOnQueryTextListener(this);
super.onCreateOptionsMenu(menu, inflater);
final MenuItem item = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) item.getActionView();
searchView.setOnQueryTextListener(this);
Log.i(this.getClass().getName(), " onCreateOptionsMenu");
}
@Override
@ -65,8 +65,11 @@ public class ItemListFragment extends Fragment implements com.hikapro.backpack.v
@Override
public boolean onQueryTextChange(String newText) {
if (hz)
presenter.filter(newText);
return true;
if (!hz)
hz = true;
return hz;
}
@Override
@ -90,13 +93,13 @@ public class ItemListFragment extends Fragment implements com.hikapro.backpack.v
case R.id.action_add :
activityCallback.startAddFragment(getSet());
ret = true;
break;
default:
ret = super.onOptionsItemSelected(item);
}
return ret;
}
// life cycle -->
@Override
public void onAttach(Context context) {
super.onAttach(context);
@ -127,7 +130,6 @@ public class ItemListFragment extends Fragment implements com.hikapro.backpack.v
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
presenter.setView(this);
View view = presenter.onCreateView(inflater, container, savedInstanceState);
Log.i(this.getClass().getName(), " onCreateView");
@ -146,6 +148,7 @@ public class ItemListFragment extends Fragment implements com.hikapro.backpack.v
@Override
public void onResume() {
super.onResume();
presenter.onResume();
Log.i(this.getClass().getName(), " onResume");
}
@Override
@ -157,6 +160,7 @@ public class ItemListFragment extends Fragment implements com.hikapro.backpack.v
public void onDestroyView() {
super.onDestroyView();
presenter.onDestroy(true); // TODO isChangingConfigurations
hz = false;
Log.i(this.getClass().getName(), " onDestroyView");
}
@Override
@ -177,9 +181,6 @@ public class ItemListFragment extends Fragment implements com.hikapro.backpack.v
Log.i(this.getClass().getName(), " onSaveInstanceState");
}
// life cycle <--
@Override
public void showItemDetail(int setId, Model.Item baseModel, int position) {
activityCallback.startItemDetailFragment(setId, baseModel, position);

View File

@ -29,7 +29,6 @@ public class SetListFragment extends Fragment implements com.hikapro.backpack.vi
return ret;
}
// life cycle -->
@Override
public void onAttach(Context context) {
super.onAttach(context);
@ -60,7 +59,6 @@ public class SetListFragment extends Fragment implements com.hikapro.backpack.vi
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.i(this.toString(), "onCreateView");
// Inflate the layout for this fragment
presenter.setView(this);
View view = presenter.onCreateView(inflater, container, savedInstanceState);
@ -109,7 +107,6 @@ public class SetListFragment extends Fragment implements com.hikapro.backpack.vi
super.onDetach();
Log.i(this.toString(), "onDetach");
}
// life cycle <--
@Override
public void showItemList(Set set) {

View File

@ -1,10 +1,14 @@
package com.hikapro.backpack.view.recycler;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.hikapro.backpack.R;
@ -19,8 +23,7 @@ public class SetViewHolder extends RecyclerView.ViewHolder implements ItemTouchH
public TextView textView;
public TextView setInfo;
//GLM_add_resources_SetList
private View view;
private ViewGroup cardContent;
private Drawable drawable;
public SetViewHolder(View v) {
@ -32,20 +35,81 @@ public class SetViewHolder extends RecyclerView.ViewHolder implements ItemTouchH
cardView = (CardView) view.findViewById(R.id.card_view_set);
textView = (TextView) view.findViewById(R.id.set_text);
setInfo = (TextView) view.findViewById(R.id.set_info);
this.view = view;
drawable = view.getBackground();
cardContent = (ViewGroup) view.findViewById(R.id.card_content);
}
//GLM_add_resources_SetList
@Override
public void onItemClear() {
view.setBackground(drawable);
cardContent.setBackgroundColor(cardView.getResources().getColor(R.color.colorListBackground));
if (drawable != null) {
cardContent.setBackground(drawable);
}
drawable = null;
}
//GLM_add_resources_SetList
@Override
public void onItemSelected() {
view.setBackgroundColor(Color.GRAY);
this.drawable = cardContent.getBackground();
cardContent.setBackgroundColor(Color.GRAY);
}
public void applyBackground(Context context, int setId) {
Drawable drawable = null;
switch (setId) {
case 1:
drawable = ContextCompat.getDrawable(context, R.drawable.ic_card_1);
break;
case 2:
drawable = ContextCompat.getDrawable(context, R.drawable.ic_card_2);
break;
case 3:
drawable = ContextCompat.getDrawable(context, R.drawable.ic_card_3);
break;
case 4:
drawable = ContextCompat.getDrawable(context, R.drawable.ic_card_4);
break;
case 5:
drawable = ContextCompat.getDrawable(context, R.drawable.ic_card_5);
break;
case 6:
drawable = ContextCompat.getDrawable(context, R.drawable.ic_card_6);
break;
case 7:
// nothing
break;
case 8:
drawable = ContextCompat.getDrawable(context, R.drawable.ic_card_8);
break;
case 9:
// nothing
break;
case 10:
drawable = ContextCompat.getDrawable(context, R.drawable.ic_card_10);
break;
case 11:
// nothing
break;
case 12:
// nothing
break;
case 13:
// nothing
break;
case 14:
drawable = ContextCompat.getDrawable(context, R.drawable.ic_card_14);
break;
default:
drawable = new ColorDrawable(ContextCompat.getColor(context, R.color.colorListBackground));
}
if (drawable != null)
cardContent.setBackground(drawable);
else
cardContent.setBackgroundColor(cardView.getResources().getColor(R.color.colorFullTransparent));
}
}

View File

@ -3,10 +3,10 @@
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:duration="@integer/duration"
android:propertyName="y"
android:valueFrom="-1000"
android:valueTo="0"
android:valueFrom="@integer/valueTransitionYminus"
android:valueTo="@integer/valueTo"
android:valueType="floatType" />
</set>

View File

@ -3,10 +3,10 @@
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:duration="@integer/duration"
android:propertyName="x"
android:valueFrom="1000"
android:valueTo="0"
android:valueFrom="@integer/valueTransitionXplus"
android:valueTo="@integer/valueTo"
android:valueType="floatType" />
</set>

View File

@ -3,10 +3,10 @@
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:duration="@integer/duration"
android:propertyName="x"
android:valueFrom="-1000"
android:valueTo="0"
android:valueFrom="@integer/valueTransitionXminus"
android:valueTo="@integer/valueTo"
android:valueType="floatType" />
</set>

View File

@ -3,10 +3,10 @@
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:duration="@integer/duration"
android:propertyName="y"
android:valueFrom="1000"
android:valueTo="0"
android:valueFrom="@integer/valueTransitionYplus"
android:valueTo="@integer/valueTo"
android:valueType="floatType" />
</set>

View File

@ -3,10 +3,10 @@
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:duration="@integer/duration"
android:propertyName="y"
android:valueFrom="0"
android:valueTo="-1000"
android:valueFrom="@integer/valueTo"
android:valueTo="@integer/valueTransitionYminus"
android:valueType="floatType" />
</set>

View File

@ -3,10 +3,10 @@
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:duration="@integer/duration"
android:propertyName="x"
android:valueFrom="0"
android:valueTo="1000"
android:valueFrom="@integer/valueTo"
android:valueTo="@integer/valueTransitionXplus"
android:valueType="floatType" />
</set>

View File

@ -3,10 +3,10 @@
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:duration="@integer/duration"
android:propertyName="x"
android:valueFrom="0"
android:valueTo="-1000"
android:valueFrom="@integer/valueTo"
android:valueTo="@integer/valueTransitionXminus"
android:valueType="floatType" />
</set>

View File

@ -3,10 +3,10 @@
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:duration="@integer/duration"
android:propertyName="y"
android:valueFrom="0"
android:valueTo="1000"
android:valueFrom="@integer/valueTo"
android:valueTo="@integer/valueTransitionYplus"
android:valueType="floatType" />
</set>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 579 B

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 973 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 579 B

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/colorShareBtnBackground" />
<corners android:radius="5dp" />
<stroke android:width="2px" android:color="#FFFFFF" />
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:padding="10dp">
<solid android:color="#e0f2ff"/>
<corners android:topLeftRadius="10dip"/>
</shape>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:padding="10dp">
<solid android:color="#e0f2ff"/>
<corners android:topRightRadius="10dip"/>
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#e0f2ff"/>
<stroke android:width="1dip" android:color="#FFe0f2ff" />
<corners android:radius="10dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>

View File

@ -2,33 +2,37 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:enabled="false"
android:paddingLeft="@dimen/margin_standard"
android:paddingRight="@dimen/margin_standard">
android:enabled="false" >
<Button
android:id="@+id/action_add_cancel"
style="@style/ActionBarButtonWhite"
style="@style/ActionBarButtonWhiteStart"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/cancel_button"
android:layout_alignParentStart="true"/>
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="ADD AN ITEM"
android:textSize="@dimen/text_size_medium"
android:layout_centerInParent="true"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/add_an_item"
android:textAllCaps="true"
android:textSize="@dimen/text_action_bar_header"
android:textColor="@color/white"
android:textStyle="bold"/>
<Button
android:id="@+id/action_add_save"
style="@style/ActionBarButtonWhite"
style="@style/ActionBarButtonWhiteEnd"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/save_button"
android:layout_alignParentEnd="true"/>
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
/>
</RelativeLayout>

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="@dimen/dlg_restore_width"
android:layout_height="@dimen/dlg_restore_height">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:background="@android:color/black" >
<TextView
android:id="@+id/txt_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:text="@string/dlg_restore_header"
android:textSize="@dimen/dlg_restore_header"
android:textColor="@color/colorText"
android:textAppearance="?android:attr/textAppearanceLarge" />
<com.hikapro.backpack.presenter.adapters.helper.AutoResizeTextView
android:id="@+id/txt_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:text="@string/dlg_restore_txt"
android:textSize="@dimen/dlg_restore_txt"
android:textColor="@color/colorRestoreDialogTxt"
android:textAppearance="?android:attr/textAppearanceMedium"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dlg_restore_btn_height"
android:orientation="horizontal">
<LinearLayout
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@color/colorRestoreBtnBackground">
<Button
android:id="@+id/button_ok"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/dlg_restore_btn"
android:textColor="@color/colorText"
android:textSize="@dimen/dlg_restore_txt"
android:textAppearance="?android:attr/textAppearanceLarge"
android:background="?android:attr/selectableItemBackground" />
</LinearLayout>
<LinearLayout
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@color/colorCancelBtnBackground" >
<Button
android:id="@+id/button_cancel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/dlg_cancel_btn"
android:textColor="@color/colorText"
android:textSize="@dimen/dlg_restore_txt"
android:textAppearance="?android:attr/textAppearanceLarge"
android:background="?android:attr/selectableItemBackground" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="@dimen/dlg_restore_width"
android:layout_height="@dimen/dlg_restore_height">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:background="@android:color/black" >
<TextView
android:id="@+id/txt_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:text="@string/dlg_rate_header"
android:textSize="@dimen/dlg_restore_header"
android:textColor="@color/colorText"
android:textAppearance="?android:attr/textAppearanceLarge" />
<com.hikapro.backpack.presenter.adapters.helper.AutoResizeTextView
android:id="@+id/txt_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:text="@string/dlg_rate_txt"
android:textSize="@dimen/dlg_restore_txt"
android:textColor="@color/colorRestoreDialogTxt"
android:textAppearance="?android:attr/textAppearanceMedium"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dlg_restore_btn_height"
android:orientation="horizontal">
<LinearLayout
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@color/colorRestoreBtnBackground">
<Button
android:id="@+id/button_rate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/dlg_rate_btn"
android:textColor="@color/colorText"
android:textSize="@dimen/dlg_restore_txt"
android:textAppearance="?android:attr/textAppearanceLarge"
android:background="?android:attr/selectableItemBackground" />
</LinearLayout>
<LinearLayout
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@color/colorCancelBtnBackground" >
<Button
android:id="@+id/button_later"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/dlg_later_btn"
android:textColor="@color/colorText"
android:textSize="@dimen/dlg_restore_txt"
android:textAppearance="?android:attr/textAppearanceLarge"
android:background="?android:attr/selectableItemBackground" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="320dp"
android:layout_height="230dp"
android:background="@drawable/twitter_dlg">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="66dp"
android:orientation="horizontal" >
<Button
android:id="@+id/button_cancel"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="Cancel"
android:gravity="start|center_vertical"
android:textColor="#3333cc"
android:textSize="18sp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:paddingStart="16dp"
android:background="@drawable/tweeter_button"
style="@style/Widget.AppCompat.Button.Borderless.Colored"/>
<TextView
android:id="@+id/txt_header"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingTop="16dp"
android:text="Twitter"
android:textSize="22sp"
android:textStyle="bold"
android:textColor="@android:color/black"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/button_post"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="Post"
android:gravity="end|center_vertical"
android:paddingEnd="16dp"
android:textColor="#3333cc"
android:textSize="18sp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:background="@drawable/tweeter_button2"
style="@style/Widget.AppCompat.Button.Borderless.Colored"/>
</LinearLayout>
<View
android:layout_marginTop="0dp"
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="#666699">
</View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingTop="4dp"
android:orientation="horizontal">
<EditText
android:id="@+id/message"
android:layout_width="220dp"
android:gravity="top"
android:paddingStart="16dp"
android:text="PACK WITH ME - ready-to-go travel checklists"
android:layout_height="match_parent"
android:maxLength="140"
android:background="@null"/>
<ImageView
android:id="@+id/image_to_post"
android:layout_width="84dp"
android:layout_height="84dp"
android:contentDescription="Sharing image."/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="16dp"
android:orientation="horizontal">
<TextView
android:id="@+id/chars_left"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="74"
android:paddingStart="16dp"/>
</LinearLayout>
</LinearLayout>

View File

@ -1,17 +1,13 @@
<ScrollView
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:context="com.hikapro.backpack.view.fragments.AddFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorListBackground">
<LinearLayout
android:id="@+id/fragment_add_main_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/colorListBackground">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
@ -21,7 +17,7 @@
android:id="@+id/add_search"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/colorText"/>
android:theme="@style/ThemeOverlay.AppCompat.Dark"/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
@ -30,6 +26,10 @@
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/add_item_category_container"
android:layout_width="match_parent"
@ -54,5 +54,8 @@
</com.hikapro.backpack.presenter.adapters.helper.FlowLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</ScrollView>
</LinearLayout>

View File

@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="@color/colorUiMainbackground2">
android:background="@color/colorListBackground">
<ScrollView
android:layout_width="match_parent"

View File

@ -9,7 +9,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/colorListBackground">
android:id="@+id/item_list_container">
<com.hikapro.backpack.presenter.adapters.helper.items.swipe2.SwipableRecycler
android:id="@+id/items_recycler"

Some files were not shown because too many files have changed in this diff Show More