Skip to content

Commit

Permalink
0.9.7 minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazyeraser committed Jan 8, 2018
1 parent e62aa6c commit 23cd7c6
Show file tree
Hide file tree
Showing 19 changed files with 405 additions and 292 deletions.
11 changes: 4 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.lazyeraser.imas.derehelper"
minSdkVersion 17
targetSdkVersion 25
versionCode 6
versionName "0.9.6"
versionCode 7
versionName "0.9.7"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
Expand Down Expand Up @@ -60,9 +60,6 @@ android {
dependencies {
provided fileTree(include: ['*.jar'], dir: 'libs')

// compile 'io.reactivex.rxjava2:rxjava:2.0.4'
// compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
Expand Down Expand Up @@ -91,6 +88,6 @@ dependencies {

compile 'net.jpountz.lz4:lz4:1.3.0'

// compile 'com.umeng.sdk:common:latest.integration'
// compile 'com.umeng.sdk:analytics:latest.integration'
compile 'com.umeng.sdk:common:latest.integration'
compile 'com.umeng.sdk:analytics:latest.integration'
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.content.SharedPreferences;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -17,6 +16,9 @@ public class SharedHelper {
public final static String KEY_AUTO_APP = "autoAppUpdate";
public final static String KEY_DEFAULT_TRAN = "defaultTranslated";

public final static String KEY_UMENG_ON = "turnOnUmeng";
public final static String KEY_UMENG_ASKED = "askedUmeng";

public final static String KEY_TruthVersion = "truthVersion";
public final static String KEY_MasterDbHash = "masterHash";

Expand All @@ -26,6 +28,8 @@ public class SharedHelper {
defaultKeyValues.put(KEY_AUTO_DATA, "true");
defaultKeyValues.put(KEY_AUTO_APP, "true");
defaultKeyValues.put(KEY_DEFAULT_TRAN, "false");
defaultKeyValues.put(KEY_UMENG_ON, "false");
defaultKeyValues.put(KEY_UMENG_ASKED, "false");
}

public SharedHelper(Context mContext) {
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/lazyeraser/imas/cgss/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

import com.lazyeraser.imas.derehelper.R;
import com.lazyeraser.imas.main.SStaticR;
import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure;

import java.io.File;
import java.io.FileNotFoundException;
Expand All @@ -40,6 +42,14 @@

public class Utils {

public static void turnOnUmeng(Context context){
SStaticR.uMeng = true;
UMConfigure.init(context.getApplicationContext(), "5a51be59b27b0a6d310004c2", "ALL", UMConfigure.DEVICE_TYPE_PHONE, null);
UMConfigure.setEncryptEnabled(true);
MobclickAgent.setScenarioType(context.getApplicationContext(), MobclickAgent.EScenarioType.E_UM_NORMAL);
MobclickAgent.setLocation(233, 233);
}

public static String emptyLessString(Context context, String s){
return TextUtils.isEmpty(s) ? context.getString(R.string.empty) : s;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lazyeraser.imas.cgss.view;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ScrollView;
import android.widget.TextView;
Expand All @@ -14,7 +15,9 @@

public class BeatMapActivity extends BaseActivity {

int anchor;
private int anchor;

private boolean init = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -37,7 +40,11 @@ protected void onCreate(Bundle savedInstanceState) {
public void onEnterAnimationComplete() {
super.onEnterAnimationComplete();
ScrollView scrollView = (ScrollView)findViewById(R.id.scrollView);
if (scrollView.getScrollY() == 0 && !init){
scrollView.smoothScrollTo(0, anchor);
init = true;
}
// scrollView.scrollTo(0, Integer.MAX_VALUE);
scrollView.smoothScrollTo(0, anchor);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import com.lazyeraser.imas.derehelper.R;
import com.lazyeraser.imas.main.BaseActivity;
import com.lazyeraser.imas.main.BaseFragment;
import com.lazyeraser.imas.main.SStaticR;
import com.umeng.analytics.MobclickAgent;


import java.util.HashMap;
Expand Down Expand Up @@ -158,7 +160,9 @@ private void askRestart(){
}else{
mgr.setExact(AlarmManager.RTC, System.currentTimeMillis() + 500, restartIntent);
}
// MobclickAgent.onKillProcess(this);
if (SStaticR.uMeng){
MobclickAgent.onKillProcess(this);
}
System.exit(0);
});
sweetAlertDialog.setCancelable(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.lazyeraser.imas.cgss.utils.DBHelper;
import com.lazyeraser.imas.cgss.utils.JsonUtils;
import com.lazyeraser.imas.cgss.utils.SharedHelper;
import com.lazyeraser.imas.cgss.utils.Utils;
import com.lazyeraser.imas.cgss.view.CardDetailActivity;
import com.lazyeraser.imas.cgss.view.MainActivity;
import com.lazyeraser.imas.cgss.view.fragments.CardListFrag;
Expand All @@ -33,6 +34,7 @@
import java.util.List;
import java.util.Map;

import cn.pedant.SweetAlert.SweetAlertDialog;
import me.tatarka.bindingcollectionadapter.ItemView;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
Expand Down Expand Up @@ -123,6 +125,24 @@ public void onPropertyChanged(android.databinding.Observable sender, int propert
}else {
umi.dismissLoading();
}
if (!umi.getSP(SharedHelper.KEY_UMENG_ASKED)){
SweetAlertDialog sweetAlertDialog = new SweetAlertDialog(mContext)
.setTitleText(mContext.getString(R.string.analytics_ask_title))
.setContentText(mContext.getString(R.string.analytics_ask_content))
.setConfirmText(mContext.getString(R.string.accept))
.setCancelText(mContext.getString(R.string.decline))
.setConfirmClickListener(dialog -> {
dialog.dismiss();
Utils.turnOnUmeng(mContext);
umi.spSave(SharedHelper.KEY_UMENG_ASKED, "true");
})
.setCancelClickListener(dialog -> {
dialog.dismiss();
umi.spSave(SharedHelper.KEY_UMENG_ASKED, "true");
});
sweetAlertDialog.setCanceledOnTouchOutside(false);
sweetAlertDialog.show();
}
}
});
Messenger.getDefault().register(mContext, MainActivity.TOKEN_DATA_UPDATED, this::loadData);
Expand Down Expand Up @@ -172,7 +192,7 @@ static void loadData(BaseActivity mContext, ObservableField<Map<Card, CardViewMo
cardsJsonBuilder.append("]");
List<Card> cards = JsonUtils.getArrayFromJson(cardsJsonBuilder.toString(), new TypeToken<List<Card>>(){});
Map<Card, CardViewModel> map = new HashMap<>();
if (SStaticR.skillTypeMap.size() == 0 || SStaticR.isJp){
if (SStaticR.skillTypeMap.size() < 5 || SStaticR.isJp){
if (!SStaticR.isJp){
for (Card card : cards) {
if (card.getSkill() != null){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.util.Pair;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.View;

Expand Down Expand Up @@ -105,7 +106,8 @@ private void setData(Chara chara) {
bloodType.set(getRealText(chara.getBlood_type(), 3));
hand.set(mContext.getString(handTypeMap.get(getRealText(chara.getHand(), 5))));
threeSize.set(getRealText(chara.getBody_size_1(), 6) + "/" + getRealText(chara.getBody_size_2(), 6) + "/" + getRealText(chara.getBody_size_3(), 6));
constellation.set(getRealText(chara.getConstellation(), 4)); // TODO translation from JP to CN & EN
String con_jp = getRealText(chara.getConstellation(), 4);
constellation.set(!SStaticR.connMap.containsKey(con_jp) ? con_jp : mContext.getString(SStaticR.connMap.get(con_jp)));
age.set(getRealText(chara.getAge(), 6) + mContext.getString(R.string.unit_age));
hometown.set(getRealText(chara.getHome_town(), 2));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.lazyeraser.imas.derehelper.R;
import com.lazyeraser.imas.main.BaseActivity;
import com.lazyeraser.imas.main.BaseViewModel;
import com.lazyeraser.imas.main.SStaticR;
import com.lazyeraser.imas.retrofit.ExceptionHandler;
import com.lazyeraser.imas.retrofit.RetrofitProvider;
import com.trello.rxlifecycle.ActivityLifecycleProvider;
Expand Down Expand Up @@ -69,9 +68,9 @@ public MainViewModel(BaseActivity mContext) {
if (umi.getSP(SharedHelper.KEY_AUTO_DATA)) {
checkDataUpdate();
}
if (SStaticR.isDebug) {
umi.spSave(SharedHelper.KEY_MasterDbHash, "");
umi.spSave(SharedHelper.KEY_TruthVersion, "");

if (umi.getSP(SharedHelper.KEY_UMENG_ON)){
Utils.turnOnUmeng(mContext);
}
}

Expand Down Expand Up @@ -108,7 +107,7 @@ public void checkDataUpdate() {
if (aBoolean) {
checkData();
}
}, ExceptionHandler::handleException);
}, throwable -> upToDate.set(true));
}

private void checkData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.kelin.mvvmlight.command.ReplyCommand;
import com.lazyeraser.imas.cgss.utils.SharedHelper;
import com.lazyeraser.imas.cgss.utils.Utils;
import com.lazyeraser.imas.main.BaseActivity;
import com.lazyeraser.imas.main.BaseViewModel;

Expand All @@ -16,13 +17,20 @@ public class SettingsViewModel extends BaseViewModel {
public final ObservableBoolean autoData = new ObservableBoolean(umi.getSP(SharedHelper.KEY_AUTO_DATA));
public final ObservableBoolean autoApp = new ObservableBoolean(umi.getSP(SharedHelper.KEY_AUTO_APP));
public final ObservableBoolean defaultTran = new ObservableBoolean(umi.getSP(SharedHelper.KEY_DEFAULT_TRAN));
public final ObservableBoolean um = new ObservableBoolean(umi.getSP(SharedHelper.KEY_UMENG_ON));

public final ReplyCommand<Boolean> onAutoDataSwitchCheck = new ReplyCommand<>(check -> saveSP(SharedHelper.KEY_AUTO_DATA, check));

public final ReplyCommand<Boolean> onAutoAppSwitchCheck = new ReplyCommand<>(check -> saveSP(SharedHelper.KEY_AUTO_APP, check));

public final ReplyCommand<Boolean> onDefaultTranSwitchCheck = new ReplyCommand<>(check -> saveSP(SharedHelper.KEY_DEFAULT_TRAN, check));

public final ReplyCommand<Boolean> onUMCheck = new ReplyCommand<>(check -> {
saveSP(SharedHelper.KEY_UMENG_ON, check);
if (check)
Utils.turnOnUmeng(mContext);
});

private void saveSP(String key, boolean value){
umi.spSave(key, value ? "true" : "false");
}
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/java/com/lazyeraser/imas/main/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.lazyeraser.imas.derehelper.R;
import com.squareup.picasso.Picasso;
import com.trello.rxlifecycle.components.support.RxAppCompatActivity;
import com.umeng.analytics.MobclickAgent;


import java.util.ArrayList;
Expand Down Expand Up @@ -56,6 +57,7 @@ protected void onCreate(Bundle savedInstanceState) {
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
decorView.setSystemUiVisibility(option);
getWindow().setStatusBarColor(0xFFB08870);
getWindow().setNavigationBarColor(0xFFB08870);
}
}

Expand Down Expand Up @@ -236,12 +238,14 @@ public interface OnBackBtnClickedListener {
@Override
protected void onResume() {
super.onResume();
// MobclickAgent.onResume(this);
if (SStaticR.uMeng)
MobclickAgent.onResume(this);
}

@Override
protected void onPause() {
super.onPause();
// MobclickAgent.onPause(this);
if (SStaticR.uMeng)
MobclickAgent.onPause(this);
}
}
5 changes: 1 addition & 4 deletions app/src/main/java/com/lazyeraser/imas/main/LIVE.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ public void onCreate() {
built.setIndicatorsEnabled(false);
built.setLoggingEnabled(true);
Picasso.setSingletonInstance(built);
/*MobclickAgent.setLocation(233, 233);
UMConfigure.init(this, "5a51be59b27b0a6d310004c2", "ALL", UMConfigure.DEVICE_TYPE_BOX, null);
UMConfigure.setEncryptEnabled(true);
MobclickAgent.setScenarioType(getApplicationContext(), MobclickAgent.EScenarioType.E_UM_NORMAL);*/

}

@Override
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/com/lazyeraser/imas/main/SStaticR.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
public class SStaticR {

public final static boolean isDebug = BuildConfig.DEBUG;
public static boolean uMeng = false;
public final static boolean isCn = Locale.getDefault().getLanguage().endsWith("zh");
public final static boolean isJp = Locale.getDefault().getLanguage().endsWith("ja");
public final static boolean isEN = !(isCn || isJp);

public final static String SERVER_URL_RES = "https://truecolor.kirara.ca";
public final static String SERVER_URL_UPDATE = "https://raw.githubusercontent.com/Lazyeraser/DereHelper/master/appupdate/";
Expand Down Expand Up @@ -47,6 +49,7 @@ public class SStaticR {
public static Map<String, Integer> skillTypeMap = new LinkedHashMap<>();
public static Map<Integer, String> skillTypeNameMap = new LinkedHashMap<>();
public static List<TextData> textDataList;
public static Map<String, Integer> connMap = new LinkedHashMap<>(); // constellation translate from JP
static {
if (isJp){
skillTypeMap.put("PERFECTボーナス" ,1);
Expand All @@ -67,6 +70,22 @@ public class SStaticR {
skillTypeMap.put("Passionフォーカス" ,23);
skillTypeMap.put("オールラウンド" ,24);
skillTypeMap.put("ライブスパークル" ,25);
}else {
connMap.put("牡羊座" ,R.string.constellation_1);
connMap.put("牡牛座" ,R.string.constellation_2);
connMap.put("双子座" ,R.string.constellation_3);
connMap.put("獅子座" ,R.string.constellation_5);
connMap.put("天秤座" ,R.string.constellation_7);
connMap.put("蠍座" ,R.string.constellation_8);
connMap.put("射手座" ,R.string.constellation_9);
connMap.put("山羊座" ,R.string.constellation_10);
connMap.put("水瓶座" ,R.string.constellation_11);
connMap.put("魚座" ,R.string.constellation_12);

connMap.put("蟹座" ,R.string.constellation_4);
connMap.put("かに座" ,R.string.constellation_4);
connMap.put("乙女座" ,R.string.constellation_6);
connMap.put("花も恥らう乙女座" ,R.string.constellation_6_special);
}
rarityMap.put(1, "N");
rarityMap.put(2, "N+");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public static Retrofit getInstance(String baseUrl, boolean json) {
if (okHttpClient == null){
okHttpClient = new OkHttpClient.Builder()
.connectTimeout(60, TimeUnit.SECONDS)
.readTimeout(300, TimeUnit.SECONDS)
.writeTimeout(300, TimeUnit.SECONDS)
.readTimeout(600, TimeUnit.SECONDS)
.writeTimeout(600, TimeUnit.SECONDS)
.build();
}
if (gson == null){
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
bind:onCheckChanged="@{viewModel.onDefaultTranSwitchCheck}"
bind:checked="@{viewModel.defaultTran}" />

<com.lazyeraser.imas.cgss.utils.view.SettingOptionView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
bind:titleTxt="@{R.string.settings_analytics}"
bind:onCheckChanged="@{viewModel.onUMCheck}"
bind:checked="@{viewModel.um}" />

</LinearLayout>


Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/item_list_chara.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
type="com.lazyeraser.imas.cgss.viewmodel.CharaViewModel" />
<import type="android.view.View" />
<import type="com.lazyeraser.imas.derehelper.R" />
<import type="com.lazyeraser.imas.main.SStaticR" />
</data>

<RelativeLayout
Expand All @@ -34,7 +35,7 @@
android:layout_marginStart="10dp"
android:textSize="@dimen/txt_2"
android:textColor="@color/txtBlack"
android:text="@{viewModel.chara.getName()}"/>
android:text="@{SStaticR.isEN ? viewModel.chara.getConventional() : viewModel.chara.getName()}"/>

<View
android:layout_marginStart="5dp"
Expand Down
Loading

0 comments on commit 23cd7c6

Please sign in to comment.