use of com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION in project kcanotify by antest1.
the class UpdateCheckActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rescheck);
Intent intent = this.getIntent();
if (intent != null && intent.getExtras() != null) {
main_flag = intent.getExtras().getBoolean("main_flag", false);
}
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getResources().getString(R.string.setting_menu_kand_title_game_data_down));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
KcaApiData.setDBHelper(dbHelper);
downloader = KcaUtils.getInfoDownloader(getApplicationContext());
FetchConfiguration fetchConfiguration = new FetchConfiguration.Builder(getApplicationContext()).setDownloadConcurrentLimit(80).build();
fetch = Fetch.Impl.getInstance(fetchConfiguration);
handler = new UpdateHandler(this);
gamedata_adapter.setHandler(handler);
resource_adapter.setHandler(handler);
checkstart_chkbox = findViewById(R.id.reschk_checkatstart);
checkstart_chkbox.setText(getStringWithLocale(R.string.download_setting_checkatstart));
checkstart_chkbox.setChecked(getBooleanPreferences(getApplicationContext(), PREF_CHECK_UPDATE_START));
checkstart_chkbox.setOnCheckedChangeListener((buttonView, isChecked) -> setPreferences(getApplicationContext(), PREF_CHECK_UPDATE_START, isChecked));
localonly_chkbox = findViewById(R.id.reschk_local);
localonly_chkbox.setText(getStringWithLocale(R.string.download_use_internal_data));
localonly_chkbox.setChecked(getBooleanPreferences(getApplicationContext(), PREF_RES_USELOCAL));
localonly_chkbox.setOnCheckedChangeListener((buttonView, isChecked) -> setPreferences(getApplicationContext(), PREF_RES_USELOCAL, isChecked));
resource_reset = findViewById(R.id.reschk_reset);
resource_reset.setText(getStringWithLocale(R.string.download_reset));
resource_reset.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(UpdateCheckActivity.this);
alertDialog.setMessage(getString(R.string.download_reset_message));
alertDialog.setPositiveButton(getStringWithLocale(R.string.dialog_ok), (dialog, which) -> {
dbHelper.clearResVer();
setPreferences(getApplicationContext(), PREF_KCARESOURCE_VERSION, 0);
Intent mainIntent = new Intent(this, InitStartActivity.class);
mainIntent.putExtra(ACTION_RESET, true);
startActivity(mainIntent);
finish();
});
alertDialog.setNegativeButton(getStringWithLocale(R.string.dialog_cancel), (dialog, which) -> {
resource_reset.setChecked(false);
dialog.dismiss();
});
AlertDialog alert = alertDialog.create();
alert.setIcon(R.mipmap.ic_launcher);
alert.show();
}
});
data_list = findViewById(R.id.gamedata_list);
resource_list = findViewById(R.id.resources_list);
data_list.setAdapter(gamedata_adapter);
resource_list.setAdapter(resource_adapter);
gamedata_load = findViewById(R.id.gamedata_loading);
resource_load = findViewById(R.id.resources_loading);
gamedata_chk = findViewById(R.id.gamedata_updatecheck);
resource_chk = findViewById(R.id.resources_updatecheck);
resource_downall = findViewById(R.id.resources_downloadall);
gamedata_chk.setOnClickListener(v -> checkVersionUpdate());
resource_chk.setOnClickListener(v -> checkResourceUpdate());
resource_downall.setOnClickListener(v -> downloadAllResources());
resource_downall.setVisibility(View.GONE);
gamedata_server = findViewById(R.id.gamedata_server);
gamedata_server.setText(getStringWithLocale(R.string.action_server));
gamedata_server.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final int initValue = checked;
String[] listItems = getResources().getStringArray(R.array.ServerLocation);
String[] listEntry = getResources().getStringArray(R.array.ServerLocationValue);
AlertDialog.Builder mBuilder = new AlertDialog.Builder(UpdateCheckActivity.this);
mBuilder.setTitle(getStringWithLocale(R.string.setting_menu_app_title_updatecheckserver));
String currentServer = getStringPreferences(getApplicationContext(), PREF_UPDATE_SERVER);
for (int i = 0; i < listEntry.length; i++) if (currentServer.equals(listEntry[i])) {
checked = i;
break;
}
mBuilder.setSingleChoiceItems(listItems, checked, (dialog, which) -> {
checked = which;
});
mBuilder.setPositiveButton(getStringWithLocale(R.string.dialog_ok), (dialog, which) -> {
Log.e("KCA", "selected: " + checked);
if (checked != -1) {
String selectedServer = listEntry[checked];
setPreferences(getApplicationContext(), PREF_UPDATE_SERVER, selectedServer);
}
});
mBuilder.setNegativeButton(getStringWithLocale(R.string.dialog_cancel), ((dialog, which) -> {
checked = initValue;
}));
AlertDialog mDialog = mBuilder.create();
mDialog.show();
}
});
checkVersionUpdate();
checkResourceUpdate();
}
use of com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION in project kcanotify by antest1.
the class KcaBattleViewService method onCreate.
@Override
public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
} else {
try {
active = true;
view_status = Integer.parseInt(getStringPreferences(getApplicationContext(), PREF_VIEW_YLOC));
contextWithLocale = getContextWithLocale(getApplicationContext(), getBaseContext());
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
deckInfoCalc = new KcaDeckInfo(getApplicationContext(), contextWithLocale);
// mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
customToast = new KcaCustomToast(getApplicationContext());
prefs = PreferenceManager.getDefaultSharedPreferences(this);
mInflater = LayoutInflater.from(contextWithLocale);
mView = mInflater.inflate(R.layout.view_sortie_battle, null);
KcaUtils.resizeFullWidthView(getApplicationContext(), mView);
mView.setVisibility(View.GONE);
battleview = mView.findViewById(R.id.battleview);
battleview.setOnTouchListener(mViewTouchListener);
battleview.findViewById(R.id.battle_node_area).setOnTouchListener(infoListViewTouchListener);
itemView = mInflater.inflate(R.layout.view_battleview_items, null);
acView = mInflater.inflate(R.layout.view_battleview_aircombat, null);
acView.findViewById(R.id.view_ac_head).setOnTouchListener(acViewTouchListener);
acView.findViewById(R.id.view_ac_phase1_0_f).setOnTouchListener(acViewTouchListener);
acView.findViewById(R.id.view_ac_phase1_0_e).setOnTouchListener(acViewTouchListener);
acView.findViewById(R.id.view_ac_phase2_0_f).setOnTouchListener(acViewTouchListener);
acView.findViewById(R.id.view_ac_phase2_0_e).setOnTouchListener(acViewTouchListener);
((TextView) acView.findViewById(R.id.view_ac_title)).setText(getStringWithLocale(R.string.battleview_menu0));
menuView = mInflater.inflate(R.layout.view_battleview_menu, null);
menuView.setVisibility(View.GONE);
menuView.findViewById(R.id.view_head).setOnClickListener(battleViewMenuListener);
menuView.findViewById(R.id.view_item0).setOnClickListener(battleViewMenuListener);
menuView.findViewById(R.id.view_item1).setOnClickListener(battleViewMenuListener);
menuView.findViewById(R.id.view_item2).setOnClickListener(battleViewMenuListener);
((TextView) menuView.findViewById(R.id.view_bm_title)).setText(getStringWithLocale(R.string.battleview_menu_head));
mParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT, getWindowLayoutType(), WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT);
mParams.gravity = KcaUtils.getGravity(view_status);
setPreferences(getApplicationContext(), PREF_VIEW_YLOC, view_status);
mManager = (WindowManager) getSystemService(WINDOW_SERVICE);
mManager.addView(mView, mParams);
Display display = ((WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
Point size = new Point();
display.getSize(size);
displayWidth = size.x;
refreshreceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.e("KCA", "=> Received Intent");
// mViewBackup = mView;
// mManager.removeView(mView);
api_data = KcaBattle.getCurrentApiData();
if (api_data != null && api_data.has("api_heavy_damaged")) {
int value = api_data.get("api_heavy_damaged").getAsInt();
if (value == HD_DANGER) {
mView.findViewById(R.id.battleviewpanel).setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.colorHeavyDmgStatePanel));
} else {
mView.findViewById(R.id.battleviewpanel).setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark));
}
}
int setViewResult = setView();
if (setViewResult == 0) {
if (KcaViewButtonService.getClickCount() == 0) {
mView.setVisibility(View.GONE);
}
// mManager.addView(mView, mParams);
mView.invalidate();
mManager.updateViewLayout(mView, mParams);
}
}
};
LocalBroadcastManager.getInstance(this).registerReceiver(refreshreceiver, new IntentFilter(KCA_MSG_BATTLE_VIEW_REFRESH));
} catch (Exception e) {
active = false;
error_flag = true;
sendReport(e, ERORR_INIT);
stopSelf();
}
}
}
use of com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION in project kcanotify by antest1.
the class KcaFleetViewService method onCreate.
@Override
public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
}
try {
active = true;
switch_status = 1;
prefs = PreferenceManager.getDefaultSharedPreferences(this);
view_status = Integer.parseInt(getStringPreferences(getApplicationContext(), PREF_VIEW_YLOC));
mManager = (WindowManager) getSystemService(WINDOW_SERVICE);
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
dbHelper.updateExpScore(0);
KcaApiData.setDBHelper(dbHelper);
contextWithLocale = getContextWithLocale(getApplicationContext(), getBaseContext());
deckInfoCalc = new KcaDeckInfo(getApplicationContext(), contextWithLocale);
gunfitData = loadGunfitData(getAssets());
// mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mInflater = LayoutInflater.from(contextWithLocale);
initView();
fleetInfoLine.setText(getStringWithLocale(R.string.kca_init_content));
itemView = mInflater.inflate(R.layout.view_battleview_items, null);
mHandler = new Handler();
timer = new Runnable() {
@Override
public void run() {
updateFleetInfoLine();
}
};
runTimer();
mManager.addView(mView, mParams);
Display display = ((WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
Point size = new Point();
display.getSize(size);
displayWidth = size.x;
} catch (Exception e) {
e.printStackTrace();
active = false;
error_flag = true;
sendReport(e, 1);
stopSelf();
}
}
use of com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION in project kcanotify by antest1.
the class KcaBattleViewService method sendReport.
private void sendReport(Exception e, int type) {
error_flag = true;
if (mView != null)
mView.setVisibility(View.GONE);
if (itemView != null)
itemView.setVisibility(View.GONE);
if (menuView != null)
menuView.setVisibility(View.GONE);
Toast.makeText(getApplicationContext(), getStringWithLocale(R.string.battleview_error), Toast.LENGTH_SHORT).show();
String api_url = "url";
JsonObject sendData = new JsonObject();
if (api_data == null) {
api_data = new JsonObject();
api_data.addProperty("api_data", "api_data is null");
}
if (type == ERORR_ITEMVIEW) {
api_url = api_data.get("api_url").getAsString();
api_data.add("api_deckport", deckportdata);
api_data.add("api_fs_data", friendShipData);
api_data.add("api_fsc_data", friendCombinedShipData);
api_data.add("api_es_data", enemyShipData);
api_data.add("api_esc_data", enemyCombinedShipData);
}
sendData.addProperty("data", api_data.toString());
sendData.addProperty("error", getStringFromException(e));
KcaDBHelper helper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
helper.recordErrorLog(ERROR_TYPE_BATTLEVIEW, api_url, "BV", api_data.toString(), getStringFromException(e));
}
use of com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION in project kcanotify by antest1.
the class KcaConstructPopupService method onCreate.
@Override
public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
} else {
clickcount = 0;
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
LayoutInflater mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mView = mInflater.inflate(R.layout.view_ship_constr, null);
mView.setOnTouchListener(mViewTouchListener);
((TextView) mView.findViewById(R.id.view_sc_title)).setText(getStringWithLocale(R.string.viewmenu_construction_title));
mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
popupWidth = mView.getMeasuredWidth();
popupHeight = mView.getMeasuredHeight();
// Button (Fairy) Settings
mParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, getWindowLayoutType(), WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT);
mParams.gravity = Gravity.TOP | Gravity.START;
Display display = ((WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
Point size = new Point();
display.getSize(size);
screenWidth = size.x;
screenHeight = size.y;
Log.e("KCA", "w/h: " + String.valueOf(screenWidth) + " " + String.valueOf(screenHeight));
mParams.x = (screenWidth - popupWidth) / 2;
mParams.y = (screenHeight - popupHeight) / 2;
mManager = (WindowManager) getSystemService(WINDOW_SERVICE);
mManager.addView(mView, mParams);
constructTimer = () -> {
Log.e("KCA-CPS", "constructTimer");
try {
updatePopup();
} catch (Exception e) {
Log.e("KCA-CPS", getStringFromException(e));
}
};
spoilerStatus = getBooleanPreferences(getApplicationContext(), PREF_SHOW_CONSTRSHIP_NAME);
constructionViewButton = mView.findViewById(R.id.view_sc_btn);
constructionViewButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
spoilerStatus = !spoilerStatus;
updateSpoilerButton();
updatePopup();
}
});
updateSpoilerButton();
constructTimeScheduler = Executors.newSingleThreadScheduledExecutor();
constructTimeScheduler.scheduleAtFixedRate(constructTimer, 0, 1, TimeUnit.SECONDS);
}
}
Aggregations