List of usage examples for android.content Intent setPackage
public @NonNull Intent setPackage(@Nullable String packageName)
From source file:com.tct.mail.compose.ComposeActivity.java
private static void launch(Context context, Account account, Message message, int action, String toAddress, String body, String quotedText, String subject, final ContentValues extraValues) { //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_S if (message != null && message.bodyHtml != null && message.bodyHtml.length() > 1024 * 5) { message.bodyHtml = ""; LogUtils.d("Email", "test---launch---bodyHtml set to empty"); }//from w w w . jav a 2s . c om if (message != null && message.bodyText != null && message.bodyText.length() > 1024 * 5) { message.bodyText = ""; LogUtils.d("Email", "test---launch---bodyText set to empty"); } //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_E //Note: intent can not take too much extra data, so not take these two string in extra data. if (message != null) { message.bodyHtmlLinkify = ""; message.bodyTextLinkify = ""; } Intent intent = new Intent(ACTION_LAUNCH_COMPOSE); intent.setPackage(context.getPackageName()); intent.putExtra(EXTRA_FROM_EMAIL_TASK, true); intent.putExtra(EXTRA_ACTION, action); intent.putExtra(Utils.EXTRA_ACCOUNT, account); if (action == EDIT_DRAFT) { intent.putExtra(ORIGINAL_DRAFT_MESSAGE, message); } else { intent.putExtra(EXTRA_IN_REFERENCE_TO_MESSAGE, message); } if (message != null) { LogUtils.d("Email", String.format("test---launch---action=%d messageId=%d conversationUri=%s uri=%s subject=%s", action, message.id, message.conversationUri, message.uri, message.subject)); } //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_S // if(message != null && message.bodyHtml != null && message.bodyHtml.length() > 1024*10){ // message.bodyHtml = ""; // Log.d("Email","test---launch---bodyHtml set to empty"); // } //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_E if (toAddress != null) { intent.putExtra(EXTRA_TO, toAddress); } if (body != null) { intent.putExtra(EXTRA_BODY, body); } if (quotedText != null) { intent.putExtra(EXTRA_QUOTED_TEXT, quotedText); } if (subject != null) { intent.putExtra(EXTRA_SUBJECT, subject); } if (extraValues != null) { LogUtils.d(LOG_TAG, "Launching with extraValues: %s", extraValues.toString()); intent.putExtra(EXTRA_VALUES, extraValues); } if (action == COMPOSE) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); } else if (message != null) { //TS: jin.dong 2015-10-19 EMAIL BUGFIX_1100033 ADD_S if (message.uri == null) { LogUtils.e(LOG_TAG, "what ? message's uri is null? want launch ComposeActivity ? do nothing is the right thing!!!"); return; } //TS: jin.dong 2015-10-19 EMAIL BUGFIX_1100033 ADD_E //TS: yanhua.chen 2016-03-31 EMAIL BUGFIX_1877378 ADD_S intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); //TS: yanhua.chen 2016-03-31 EMAIL BUGFIX_1877378 ADD_E intent.setData(Utils.normalizeUri(message.uri)); } // TS: xiaolin.li 2015-01-29 EMAIL BUGFIX-917401 ADD_S //context.startActivity(intent); try { context.startActivity(intent); } catch (Exception e) { LogUtils.e(LOG_TAG, "Launch compose activity err."); } // TS: xiaolin.li 2015-01-29 EMAIL BUGFIX-917401 ADD_E }
From source file:com.tct.mail.ui.AbstractActivityController.java
public void changeAccount(Account account) { LogUtils.d(LOG_TAG, "AAC.changeAccount(%s)", account); // Is the account or account settings different from the existing account? final boolean firstLoad = mAccount == null; final boolean accountChanged = firstLoad || !account.uri.equals(mAccount.uri); // If nothing has changed, return early without wasting any more time. if (!accountChanged && !account.settingsDiffer(mAccount)) { return;// w w w .j a v a 2 s . com } // We also don't want to do anything if the new account is null if (account == null) { LogUtils.e(LOG_TAG, "AAC.changeAccount(null) called."); return; } final String emailAddress = account.getEmailAddress(); mHandler.post(new Runnable() { @Override public void run() { MailActivity.setNfcMessage(emailAddress); } }); if (accountChanged) { commitDestructiveActions(false); } Analytics.getInstance().setCustomDimension(Analytics.CD_INDEX_ACCOUNT_TYPE, AnalyticsUtils.getAccountTypeForAccount(emailAddress)); // Change the account here setAccount(account); // And carry out associated actions. cancelRefreshTask(); if (accountChanged) { loadAccountInbox(); } // Check if we need to force setting up an account before proceeding. if (mAccount != null && !Uri.EMPTY.equals(mAccount.settings.setupIntentUri)) { // Launch the intent! final Intent intent = new Intent(Intent.ACTION_EDIT); intent.setPackage(mContext.getPackageName()); intent.setData(mAccount.settings.setupIntentUri); mActivity.startActivity(intent); } }
From source file:me.spadival.podmode.PodModeService.java
public void run() { podCommand pCommand = null;//ww w.j a v a 2s .co m podResponse pResponse = null; byte[] respBytes = null; long eventtime; Intent downIntent = null; KeyEvent downEvent = null; Intent upIntent = null; KeyEvent upEvent = null; // serialWrite(new byte[] { (byte) 0xFF, 0x55, 0x02, 0x00, 0x00, // (byte) 0xFE }); while (mPodRunning) { pCommand = readCommand(); if (pCommand == null) continue; if (pCommand.mode == 0x03) mPodStatus = podStat.DISPLAYREMOTE; if (mAccessoryName != null && (mPodStatus == podStat.SIMPLEREMOTE || mPodStatus == podStat.DISPLAYREMOTE || mPodStatus == podStat.ADVANCEDREMOTE || mPodStatus == podStat.ADVANCEDHACK) && mHTTPsend) { mHTTPsend = false; mHttpThread.start(); } if (mLaunchFirstTime && (pCommand.mode == 02 || (pCommand.mode == 04 && !mAdvancedRemoteApp.equals(PACKAGENAME)))) { String launchApp = null; if (pCommand.mode == 02) { mBanner = getString(R.string.simple_remote); launchApp = mSimpleRemoteApp; } if (pCommand.mode == 04) { mPodStatus = podStat.ADVANCEDREMOTE; if (!mAdvancedRemoteApp.equals(PACKAGENAME)) mPodStatus = podStat.ADVANCEDHACK; mBanner = getString(R.string.advanced_remote); launchApp = mAdvancedRemoteApp; } if (launchApp != null) { PackageManager pm = getPackageManager(); Intent LaunchIntent = pm.getLaunchIntentForPackage(launchApp); startActivity(LaunchIntent); ResolveInfo info = pm.resolveActivity(LaunchIntent, PackageManager.MATCH_DEFAULT_ONLY); mSongTitle = (String) info.loadLabel(pm); mElapsedTime = 0; if (pCommand.mode == 04) mRetriever.changeApp(false, mSongTitle, getString(R.string.advanced_remote), 999); mAlbumArtUri = "android.resource://" + launchApp + "/" + String.valueOf(info.getIconResource()); setUpAsForeground(mBanner); localBroadcast(false); } mLaunchFirstTime = false; } if (pCommand.mode == 02) { mPodStatus = podStat.SIMPLEREMOTE; switch (pCommand.command) { case RemoteRelease: respBytes = new byte[] { (byte) 0x01, 0x00, 0x00 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case RemotePlayPause: eventtime = SystemClock.uptimeMillis(); downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(downIntent, null); break; case RemoteJustPlay: eventtime = SystemClock.uptimeMillis(); downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(downIntent, null); break; case RemoteJustPause: eventtime = SystemClock.uptimeMillis(); downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PAUSE, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(downIntent, null); break; case RemoteSkipFwd: eventtime = SystemClock.uptimeMillis(); if (downEvent != null) { if (downEvent.getKeyCode() == KeyEvent.KEYCODE_MEDIA_NEXT || downEvent.getKeyCode() == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) { if ((eventtime - downEvent.getEventTime()) > 1000) { downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_FAST_FORWARD, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(downIntent, null); upIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); upEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_FAST_FORWARD, 0); upIntent.putExtra(Intent.EXTRA_KEY_EVENT, upEvent); if (mSimpleRemoteApp != null) upIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(upIntent, null); } } } else { downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); } break; case RemoteSkipRwd: eventtime = SystemClock.uptimeMillis(); if (downEvent != null) { if (downEvent.getKeyCode() == KeyEvent.KEYCODE_MEDIA_PREVIOUS || downEvent.getKeyCode() == KeyEvent.KEYCODE_MEDIA_REWIND) { if ((eventtime - downEvent.getEventTime()) > 1000) { downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_REWIND, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(downIntent, null); upIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); upEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_REWIND, 0); upIntent.putExtra(Intent.EXTRA_KEY_EVENT, upEvent); if (mSimpleRemoteApp != null) upIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(upIntent, null); } } } else { downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PREVIOUS, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); } break; case RemoteStop: eventtime = SystemClock.uptimeMillis(); downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_STOP, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (mSimpleRemoteApp != null) downIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(downIntent, null); break; case RemoteButtonRel: eventtime = SystemClock.uptimeMillis(); if (downIntent != null) { if (downEvent.getKeyCode() == KeyEvent.KEYCODE_MEDIA_NEXT || downEvent.getKeyCode() == KeyEvent.KEYCODE_MEDIA_PREVIOUS) sendOrderedBroadcast(downIntent, null); if (downEvent.getKeyCode() != KeyEvent.KEYCODE_MEDIA_FAST_FORWARD && downEvent.getKeyCode() != KeyEvent.KEYCODE_MEDIA_REWIND) { upIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); upEvent = new KeyEvent(downEvent.getDownTime(), eventtime, KeyEvent.ACTION_UP, downEvent.getKeyCode(), 0); upIntent.putExtra(Intent.EXTRA_KEY_EVENT, upEvent); if (mSimpleRemoteApp != null) upIntent.setPackage(mSimpleRemoteApp); sendOrderedBroadcast(upIntent, null); } } downIntent = null; downEvent = null; upIntent = null; upEvent = null; break; default: break; } } else { switch (pCommand.command) { case AppCmd: byte[] appNameBytes = new byte[pCommand.params.length - 3]; System.arraycopy(pCommand.params, 2, appNameBytes, 0, appNameBytes.length); String appName = ""; try { appName = new String(appNameBytes, "UTF8"); Log.d("PodMode", "AppCmd " + appName); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } break; case AppAck: break; case GetUpdateFlag: respBytes = new byte[] { 0x00, 0x0A, mUpdateFlag }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case SetUpdateFlag: mUpdateFlag = pCommand.params[0]; respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case SwitchToMainPlaylist: if (mPodStatus == podStat.ADVANCEDHACK) { mNowPlaying = 0; mPrevPlaying = 0; } else mNowPlaying = 0; mRetriever.switchToMainPlaylist(); respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case SwitchToItem: int itemNo = 0; itemNo = pCommand.params[4] & 0xFF; itemNo += ((pCommand.params[3] & 0xFF) << 8); itemNo += ((pCommand.params[2] & 0xFF) << 16); itemNo += ((pCommand.params[1] & 0xFF) << 24); if ((mPodStatus == podStat.ADVANCEDHACK && mNotifyHack)) { mNotifyHack = false; } else { if (mRetriever.switchToItem((int) pCommand.params[0], itemNo)) { if (pCommand.params[0] == (byte) 0x05) { mNowPlaying = itemNo; tryToGetAudioFocus(); playNextSong(null); } } } respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetCountForType: respBytes = new byte[] { 0x00, 0x19, 0x00, 0x00, 0x00, 0x00 }; int num = mRetriever.getCountForType((int) pCommand.params[0]); respBytes[5] = (byte) (num & 0xFF); respBytes[4] = (byte) ((num >> 8) & 0xFF); respBytes[3] = (byte) ((num >> 16) & 0xFF); respBytes[2] = (byte) ((num >> 24) & 0xFF); pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetItemNames: int startPos = 0; int count = 0; startPos = pCommand.params[4] & 0xFF; startPos += ((pCommand.params[3] & 0xFF) << 8); startPos += ((pCommand.params[2] & 0xFF) << 16); startPos += ((pCommand.params[1] & 0xFF) << 24); count = pCommand.params[8] & 0xFF; count += ((pCommand.params[7] & 0xFF) << 8); count += ((pCommand.params[6] & 0xFF) << 16); count += ((pCommand.params[5] & 0xFF) << 24); String[] itemNames = mRetriever.GetItemNames((int) pCommand.params[0], startPos, count); if (itemNames != null) { for (int i = 0; i < itemNames.length; i++) { byte[] part1 = { (byte) 0x00, (byte) 0x1B, (byte) (startPos >>> 24), (byte) (startPos >>> 16), (byte) (startPos >>> 8), (byte) startPos }; startPos++; respBytes = new String(new String(part1) + itemNames[i] + '\0').getBytes(); pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); } } break; case GetTimeStatus: respBytes = new byte[] { 0x00, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; if (mState != State.Preparing && mState != State.Retrieving) { int trackLen = 0; if (mPlayer != null) trackLen = mPlayer.getDuration(); respBytes[2] = (byte) (trackLen >>> 24); respBytes[3] = (byte) (trackLen >>> 16); respBytes[4] = (byte) (trackLen >>> 8); respBytes[5] = (byte) trackLen; int elapsedTime = 0; if (mPlayer != null) elapsedTime = mPlayer.getCurrentPosition(); respBytes[6] = (byte) (elapsedTime >>> 24); respBytes[7] = (byte) (elapsedTime >>> 16); respBytes[8] = (byte) (elapsedTime >>> 8); respBytes[9] = (byte) elapsedTime; switch (mState) { case Stopped: respBytes[10] = (byte) 0x00; break; case Playing: respBytes[10] = (byte) 0x01; break; case Paused: respBytes[10] = (byte) 0x02; break; case Preparing: respBytes[10] = (byte) 0x01; break; case Retrieving: respBytes[10] = (byte) 0x01; break; } } pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetPlaylistPos: respBytes = new byte[] { 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00 }; respBytes[2] = (byte) ((mNowPlaying) >>> 24); respBytes[3] = (byte) ((mNowPlaying) >>> 16); respBytes[4] = (byte) ((mNowPlaying) >>> 8); respBytes[5] = (byte) mNowPlaying; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetSongTitle: byte[] part1 = new byte[] { 0x00, 0x21 }; int index; index = pCommand.params[3] & 0xFF; index += ((pCommand.params[2] & 0xFF) << 8); index += ((pCommand.params[1] & 0xFF) << 16); index += ((pCommand.params[0] & 0xFF) << 24); if (index == -1) index = 0; respBytes = new String(new String(part1) + mRetriever.getTrack(index).title + '\0').getBytes(); pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetSongArtist: part1 = new byte[] { 0x00, 0x23 }; index = pCommand.params[3] & 0xFF; index += ((pCommand.params[2] & 0xFF) << 8); index += ((pCommand.params[1] & 0xFF) << 16); index += ((pCommand.params[0] & 0xFF) << 24); if (index == -1) index = 0; respBytes = new String(new String(part1) + mRetriever.getTrack(index).artist + '\0').getBytes(); pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetSongAlbum: part1 = new byte[] { 0x00, 0x25 }; index = pCommand.params[3] & 0xFF; index += ((pCommand.params[2] & 0xFF) << 8); index += ((pCommand.params[1] & 0xFF) << 16); index += ((pCommand.params[0] & 0xFF) << 24); if (index == -1) index = 0; respBytes = new String(new String(part1) + mRetriever.getTrack(index).album + '\0').getBytes(); pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case PollingMode: respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); mPollSpeed = (byte) pCommand.params[0]; if (pCommand.params[0] == (byte) 0x01 && mUpdateFlag != (byte) 0x01) { mUpdateFlag = pCommand.params[0]; if (mMediaChangeTimer == null) mMediaChangeTimer = new Timer(); mMediaChangeTimer.scheduleAtFixedRate(mMediaChangeTask, 0, 500); } else if (pCommand.params[0] == (byte) 0x00 && mUpdateFlag != (byte) 0x00) { mUpdateFlag = pCommand.params[0]; if (mMediaChangeTimer != null) mMediaChangeTimer.cancel(); } break; case ExecPlaylist: itemNo = pCommand.params[3] & 0xFF; itemNo += ((pCommand.params[2] & 0xFF) << 8); itemNo += ((pCommand.params[1] & 0xFF) << 16); itemNo += ((pCommand.params[0] & 0xFF) << 24); if (itemNo == -1) itemNo = 0; mRetriever.ExecPlaylist(); if (mPodShuffleMode == modeStat.Songs) mRetriever.shuffleTracks(); mNowPlaying = itemNo; tryToGetAudioFocus(); playNextSong(null); respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case PlaybackControl: switch (pCommand.params[0]) { case 0x01: // processStopRequest(); processTogglePlaybackRequest(); break; case 0x02: processStopRequest(); break; case 0x03: processPauseRequest(); processSkipRequest(); break; case 0x04: processPauseRequest(); processSkipRwdRequest(); break; case 0x05: // processSkipRequest(); break; case 0x06: // processRewindRequest(); break; case 0x07: // TODO Add Stop FF/RR function break; } respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetPlayListSongNum: respBytes = new byte[] { 0x00, 0x36, 0x00, 0x00, 0x00, 0x00 }; num = mRetriever.getCount(); respBytes[5] = (byte) (num & 0xFF); respBytes[4] = (byte) ((num >> 8) & 0xFF); respBytes[3] = (byte) ((num >> 16) & 0xFF); respBytes[2] = (byte) ((num >> 24) & 0xFF); pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case JumpToSong: itemNo = pCommand.params[3] & 0xFF; itemNo += ((pCommand.params[2] & 0xFF) << 8); itemNo += ((pCommand.params[1] & 0xFF) << 16); itemNo += ((pCommand.params[0] & 0xFF) << 24); mNowPlaying = itemNo; tryToGetAudioFocus(); playNextSong(null); respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case FrankPlaylist: respBytes = new byte[] { 0x00, 0x4F, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }; num = mRetriever.getPlaylistNum(); if (num != -1) { respBytes[5] = (byte) (num & 0xFF); respBytes[4] = (byte) ((num >> 8) & 0xFF); respBytes[3] = (byte) ((num >> 16) & 0xFF); respBytes[2] = (byte) ((num >> 24) & 0xFF); } pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case StartID: respBytes = new byte[] { 0x02 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetPodProtocols: // start respBytes = new byte[] { 0x02 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); if (pCommand.rawBytes[13] == (byte) 0x00 && pCommand.rawBytes[14] == (byte) 0x00 && pCommand.rawBytes[15] == (byte) 0x00 && pCommand.rawBytes[16] == (byte) 0x00) { // respBytes = new byte[] { 0x00 }; // pResponse = new podResponse(pCommand, respBytes); // serialWrite(pResponse.getBytes()); } else { respBytes = new byte[] { 0x14 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); } break; case DeviceAuthInfo: if (pCommand.length == 4) { respBytes = new byte[] { 0x16 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); respBytes = new byte[] { 0x17, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); } else { if (pCommand.rawBytes[7] != pCommand.rawBytes[8]) { respBytes = new byte[] { 0x02 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); } else { respBytes = new byte[] { 0x16 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); respBytes = new byte[] { 0x17, 0x02 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); } } break; case DeviceAuthSig: respBytes = new byte[] { 0x19 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetPodOptions: // start if (pCommand.rawBytes[5] == 0x00) respBytes = new byte[] { 0x4C }; else respBytes = new byte[] { (byte) 0x02, 0x04 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetPodOption: // start respBytes = new byte[] { 0x25 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case SetIdTokens: respBytes = new byte[] { 0x3A }; pResponse = new podResponse(pCommand, respBytes); if (mAccessoryName == null) { mAccessoryName = pResponse.accessoryName; mAccessoryMnf = pResponse.accessoryMnf; mAccessoryModel = pResponse.accessoryModel; mHTTPsend = true; } serialWrite(pResponse.getBytes()); break; case EndID: respBytes = new byte[] { 0x3C }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); respBytes = new byte[] { 0x14 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetProtoVersion: respBytes = new byte[] { 0x0F }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case DeviceDetails: respBytes = new byte[] { 0x02 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case DevName: respBytes = new byte[] { 0x00, 0x15, 0x50, 0x6F, 0x64, 0x4D, 0x6F, 0x64, 0x65, 0x00 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case DevTypeSize: pResponse = new podResponse(pCommand, DEVTYPESIZE); serialWrite(pResponse.getBytes()); break; case StateInfo: respBytes = new byte[] { 0x0D }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case RemoteNotify: respBytes = new byte[] { 0x02 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case SwitchRemote: mPodStatus = podStat.SIMPLEREMOTE; break; case ReqAdvRemote: respBytes = new byte[] { 0x04, 0x00 }; if (mPodStatus == podStat.ADVANCEDREMOTE || mPodStatus == podStat.ADVANCEDHACK) respBytes[1] = 0x04; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case StartAdvRemote: mPodStatus = podStat.ADVANCEDREMOTE; if (!mAdvancedRemoteApp.equals(PACKAGENAME)) mPodStatus = podStat.ADVANCEDHACK; respBytes = new byte[] { 0x2 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case EndAdvRemote: mPodStatus = podStat.WAITING; respBytes = new byte[] { 0x2 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetSoftVersion: respBytes = new byte[] { 0x0A }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetSerialNum: respBytes = new byte[] { 0x0C }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case DevModel: respBytes = new byte[] { 0x0E }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case SwitchAdvanced: mPodStatus = podStat.ADVANCEDREMOTE; if (!mAdvancedRemoteApp.equals(PACKAGENAME)) mPodStatus = podStat.ADVANCEDHACK; break; case SetRepeatMode: if (pCommand.params[0] == (byte) 0x00) mPodRepeatMode = modeStat.Off; else if (pCommand.params[0] == (byte) 0x01) mPodRepeatMode = modeStat.Songs; else mPodRepeatMode = modeStat.Albums; respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetRepeatMode: respBytes = new byte[] { 0x00, 0x30, 0x00 }; if (mPodRepeatMode == modeStat.Songs) respBytes[2] = 0x01; if (mPodRepeatMode == modeStat.Albums) respBytes[2] = 0x02; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case SetShuffleMode: if (pCommand.params[0] == (byte) 0x00) mPodShuffleMode = modeStat.Off; else if (pCommand.params[0] == (byte) 0x01) mPodShuffleMode = modeStat.Songs; else mPodShuffleMode = modeStat.Albums; respBytes = new byte[] { 0x00, 0x01 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetShuffleMode: respBytes = new byte[] { 0x00, 0x2D, 0x00 }; if (mPodShuffleMode == modeStat.Songs) respBytes[2] = 0x01; if (mPodShuffleMode == modeStat.Albums) respBytes[2] = 0x02; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; case GetScreenSize: respBytes = new byte[] { 0x00, 0x34 }; pResponse = new podResponse(pCommand, respBytes); serialWrite(pResponse.getBytes()); break; default: break; } } } }
From source file:com.tct.mail.compose.ComposeActivity.java
protected void sendOrSave(final boolean save, final boolean showToast) { // Check if user is a monkey. Monkeys can compose and hit send // button but are not allowed to send anything off the device. // TS: xiaolin.li 2015-01-08 EMAIL BUGFIX-893877 DEL_S /*if (ActivityManager.isUserAMonkey()) { return;/* ww w . j ava 2 s . com*/ }*/ // TS: xiaolin.li 2015-01-08 EMAIL BUGFIX-893877 DEL_E final SendOrSaveCallback callback = new SendOrSaveCallback() { // FIXME: unused private int mRestoredRequestId; @Override public void initializeSendOrSave(SendOrSaveTask sendOrSaveTask) { synchronized (mActiveTasks) { int numTasks = mActiveTasks.size(); if (numTasks == 0) { // Start service so we won't be killed if this app is // put in the background. startService(new Intent(ComposeActivity.this, EmptyService.class)); } mActiveTasks.add(sendOrSaveTask); } if (sTestSendOrSaveCallback != null) { sTestSendOrSaveCallback.initializeSendOrSave(sendOrSaveTask); } } @Override public void notifyMessageIdAllocated(SendOrSaveMessage sendOrSaveMessage, Message message) { synchronized (mDraftLock) { mDraftAccount = sendOrSaveMessage.mAccount; mDraftId = message.id; mDraft = message; if (sRequestMessageIdMap != null) { sRequestMessageIdMap.put(sendOrSaveMessage.requestId(), mDraftId); } // Cache request message map, in case the process is killed saveRequestMap(); } if (sTestSendOrSaveCallback != null) { sTestSendOrSaveCallback.notifyMessageIdAllocated(sendOrSaveMessage, message); } } @Override public Message getMessage() { synchronized (mDraftLock) { return mDraft; } } @Override public void sendOrSaveFinished(SendOrSaveTask task, boolean success) { // Update the last sent from account. if (mAccount != null) { MailAppProvider.getInstance().setLastSentFromAccount(mAccount.uri.toString()); } // TS: zhaotianyong 2015-03-25 EMAIL BUGFIX-954496 ADD_S // TS: zhaotianyong 2015-03-31 EMAIL BUGFIX-963249 ADD_S if (doSend) { ConnectivityManager mConnectivityManager = (ConnectivityManager) ComposeActivity.this .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = mConnectivityManager.getActiveNetworkInfo(); if (info == null) { Utility.showToast(ComposeActivity.this, R.string.send_failed); } } // TS: zhaotianyong 2015-03-31 EMAIL BUGFIX-963249 ADD_E // TS: zhaotianyong 2015-03-25 EMAIL BUGFIX-954496 ADD_E if (success) { // Successfully sent or saved so reset change markers discardChanges(); //TS: zheng.zou 2015-03-18 EMAIL FEATURE_996919 ADD_S if (!doSend && showToast) { Intent intent = new Intent(DRAFT_SAVED_ACTION); intent.setPackage(getString(R.string.email_package_name)); intent.putExtra(BaseColumns._ID, mDraftId); //send ordered broadcast to execute the event in sequence in different receivers, //ordered by priority sendOrderedBroadcast(intent, null); } //TS: zheng.zou 2015-03-18 EMAIL FEATURE_996919 ADD_E } else { // A failure happened with saving/sending the draft // TODO(pwestbro): add a better string that should be used // when failing to send or save //[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,08/05/2016,2635083 Utility.showShortToast(ComposeActivity.this, R.string.send_failed); //Toast.makeText(ComposeActivity.this, R.string.send_failed, Toast.LENGTH_SHORT) // .show(); } int numTasks; synchronized (mActiveTasks) { // Remove the task from the list of active tasks mActiveTasks.remove(task); numTasks = mActiveTasks.size(); } if (numTasks == 0) { // Stop service so we can be killed. stopService(new Intent(ComposeActivity.this, EmptyService.class)); } if (sTestSendOrSaveCallback != null) { sTestSendOrSaveCallback.sendOrSaveFinished(task, success); } } @Override public void incrementRecipientsTimesContacted(final List<String> recipients) { ComposeActivity.this.incrementRecipientsTimesContacted(recipients); } }; //TS: zheng.zou 2015-3-16 EMAIL BUGFIX_948927 Mod_S if (mReplyFromAccount == null && mAccount != null) { mReplyFromAccount = getDefaultReplyFromAccount(mAccount); } if (mReplyFromAccount != null) { setAccount(mReplyFromAccount.account); } //TS: zheng.zou 2015-3-16 EMAIL BUGFIX_948927 Mod_E // TS: yanhua.chen 2015-9-19 EMAIL BUGFIX_569665 ADD_S mIsSaveDraft = save; // TS: yanhua.chen 2015-9-19 EMAIL BUGFIX_569665 ADD_E final Spanned body = removeComposingSpans(mBodyView.getText()); SEND_SAVE_TASK_HANDLER.post(new Runnable() { @Override public void run() { final Message msg = createMessage(mReplyFromAccount, mRefMessage, getMode(), body); // TS: kaifeng.lu 2016-4-6 EMAIL BUGFIX_1909143 ADD_S if (/*!mIsClickIcon &&*/ !mEditDraft && (mIsSaveDraft || doSend)) {//[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,05/06/2016,2013535 String body1 = mBodyView.getText().toString().replace("\n", "\n\r"); SpannableString spannableString = new SpannableString(body1); StringBuffer bodySignature = new StringBuffer(body1); //[BUGFIX]-DEL begin by SCDTABLET.shujing.jin@tcl.com,05/17/2016,2013535,2148647 //if(mCachedSettings != null){ // bodySignature.append(convertToPrintableSignature(mCachedSettings.signature)); //} //[BUGFIX]-DEL end by SCDTABLET.shujing.jin spannableString = new SpannableString(bodySignature.toString()); msg.bodyHtml = spannedBodyToHtml(spannableString, true); msg.bodyText = bodySignature.toString(); } // TS: kaifeng.lu 2016-4-6 EMAIL BUGFIX_1909143 ADD_E mRequestId = sendOrSaveInternal(ComposeActivity.this, mReplyFromAccount, msg, mRefMessage, mQuotedTextView.getQuotedTextIfIncluded(), callback, SEND_SAVE_TASK_HANDLER, save, mComposeMode, mDraftAccount, mExtraValues); } }); // Don't display the toast if the user is just changing the orientation, // but we still need to save the draft to the cursor because this is how we restore // the attachments when the configuration change completes. if (showToast && (getChangingConfigurations() & ActivityInfo.CONFIG_ORIENTATION) == 0) { //TS: xinlei.sheng 2015-01-26 EMAIL FIXBUG_886976 MOD_S if (mLaunchContact) { mLaunchContact = false; } else { //TS: zheng.zou 2015-03-18 EMAIL FEATURE_996919 MDD_S if (!save) { //[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,08/05/2016,2635083 Utility.showToast(this, R.string.sending_message); //Toast.makeText(this, R.string.sending_message, // Toast.LENGTH_LONG).show(); } // Toast.makeText(this, save ? R.string.message_saved : R.string.sending_message, // Toast.LENGTH_LONG).show(); //TS: zheng.zou 2015-03-18 EMAIL FEATURE_996919 MOD_E } //TS: xinlei.sheng 2015-01-26 EMAIL FIXBUG_886976 MOD_E } // Need to update variables here because the send or save completes // asynchronously even though the toast shows right away. discardChanges(); updateSaveUi(); // If we are sending, finish the activity if (!save) { finish(); //TS: yanhua.chen 2015-6-15 EMAIL BUGFIX_1024081 ADD_S //TS: lin-zhou 2015-10-15 EMAIL BUGFIX_718388 MOD_S Uri soundUri = Uri.parse( "android.resource://" + getApplicationContext().getPackageName() + "/" + R.raw.email_sent); MediaPlayer player = new MediaPlayer(); try { if (soundUri != null) { player.setDataSource(getApplicationContext(), soundUri); } player.setAudioStreamType(AudioManager.STREAM_NOTIFICATION); player.prepare(); player.start(); } catch (IllegalArgumentException e) { LogUtils.e(LOG_TAG, "Send mail mediaPlayer get dataSource occur IllegalArgumentException"); } catch (SecurityException e) { LogUtils.e(LOG_TAG, "Send mail mediaPlayer get dataSource occur SecurityException"); } catch (IllegalStateException e) { LogUtils.e(LOG_TAG, "Send mail mediaPlayer get dataSource occur IllegalStateException"); } catch (IOException e) { LogUtils.e(LOG_TAG, "Send mail mediaPlayer get dataSource occur IOException"); } catch (NullPointerException e) { LogUtils.e(LOG_TAG, "Send mail mediaPlayer get dataSource occur NullPointerException"); } //TS: lin-zhou 2015-10-15 EMAIL BUGFIX_718388 MOD_E //TS: yanhua.chen 2015-6-15 EMAIL BUGFIX_1024081 ADD_E } }
From source file:com.tct.mail.compose.ComposeActivity.java
private void finishCreate() { final Bundle savedState = mInnerSavedState; findViews();//from w w w. ja v a 2 s . c o m // TS: junwei-xu 2015-09-01 EMAIL BUGFIX-526192 ADD_S updateFromRowByAccounts(); // TS: junwei-xu 2015-09-01 EMAIL BUGFIX-526192 ADD_E final Intent intent = getIntent(); final Message message; final ArrayList<AttachmentPreview> previews; mShowQuotedText = false; final CharSequence quotedText; int action; // Check for any of the possibly supplied accounts.; final Account account; if (hadSavedInstanceStateMessage(savedState)) { action = savedState.getInt(EXTRA_ACTION, COMPOSE); account = savedState.getParcelable(Utils.EXTRA_ACCOUNT); message = savedState.getParcelable(EXTRA_MESSAGE); previews = savedState.getParcelableArrayList(EXTRA_ATTACHMENT_PREVIEWS); mRefMessage = savedState.getParcelable(EXTRA_IN_REFERENCE_TO_MESSAGE); quotedText = savedState.getCharSequence(EXTRA_QUOTED_TEXT); mExtraValues = savedState.getParcelable(EXTRA_VALUES); } else { account = obtainAccount(intent); action = intent.getIntExtra(EXTRA_ACTION, COMPOSE); // Initialize the message from the message in the intent message = intent.getParcelableExtra(ORIGINAL_DRAFT_MESSAGE); previews = intent.getParcelableArrayListExtra(EXTRA_ATTACHMENT_PREVIEWS); mRefMessage = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE); //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_S if (mRefMessage != null && "".equals(mRefMessage.bodyHtml)) { String htmlbody = Body.restoreBodyHtmlWithMessageId(this, mRefMessage.getId()); mRefMessage.bodyHtml = htmlbody; //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_S } else if (message != null) { if ("".equals(message.bodyHtml)) { String htmlbody = Body.restoreBodyHtmlWithMessageId(this, message.getId()); message.bodyHtml = htmlbody; } if ("".equals(message.bodyText)) { String body = Body.restoreBodyTextWithMessageId(this, message.getId()); message.bodyText = body; } //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_S } //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_E mRefMessageUri = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE_URI); quotedText = null; if (Analytics.isLoggable()) { if (intent.getBooleanExtra(Utils.EXTRA_FROM_NOTIFICATION, false)) { Analytics.getInstance().sendEvent("notification_action", "compose", getActionString(action), 0); } } } //TS: Gantao 2015-08-27 EMAIL FEATURE_ID DEL_S // mAttachmentsView.setAttachmentPreviews(previews); //TS: Gantao 2015-08-27 EMAIL FEATURE_ID DEL_E // TS: yanhua.chen 2015-9-19 EMAIL BUGFIX_569665 ADD_S if (action == EDIT_DRAFT) { //mIsClickIcon = true;//[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,05/06/2016,2013535 mEditDraft = true; } // TS: yanhua.chen 2015-9-19 EMAIL BUGFIX_569665 ADD_E setAccount(account); if (mAccount == null) { return; } // TS: chenyanhua 2015-01-12 EMAIL BUGFIX-890424 MOD_S // initRecipients(); // TS: chenyanhua 2015-01-12 EMAIL BUGFIX-890424 MOD_S // Clear the notification and mark the conversation as seen, if necessary final Folder notificationFolder = intent.getParcelableExtra(EXTRA_NOTIFICATION_FOLDER); if (notificationFolder != null) { final Uri conversationUri = intent.getParcelableExtra(EXTRA_NOTIFICATION_CONVERSATION); Intent actionIntent; if (conversationUri != null) { actionIntent = new Intent(MailIntentService.ACTION_RESEND_NOTIFICATIONS_WEAR); actionIntent.putExtra(Utils.EXTRA_CONVERSATION, conversationUri); } else { actionIntent = new Intent(MailIntentService.ACTION_CLEAR_NEW_MAIL_NOTIFICATIONS); actionIntent.setData(Utils.appendVersionQueryParameter(this, notificationFolder.folderUri.fullUri)); } actionIntent.setPackage(getPackageName()); actionIntent.putExtra(Utils.EXTRA_ACCOUNT, account); actionIntent.putExtra(Utils.EXTRA_FOLDER, notificationFolder); startService(actionIntent); } if (intent.getBooleanExtra(EXTRA_FROM_EMAIL_TASK, false)) { mLaunchedFromEmail = true; } else if (Intent.ACTION_SEND.equals(intent.getAction())) { final Uri dataUri = intent.getData(); if (dataUri != null) { final String dataScheme = intent.getData().getScheme(); final String accountScheme = mAccount.composeIntentUri.getScheme(); mLaunchedFromEmail = TextUtils.equals(dataScheme, accountScheme); } } if (mRefMessageUri != null) { mShowQuotedText = true; mComposeMode = action; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); String wearReply = null; if (remoteInput != null) { LogUtils.d(LOG_TAG, "Got remote input from new api"); CharSequence input = remoteInput.getCharSequence(NotificationActionUtils.WEAR_REPLY_INPUT); if (input != null) { wearReply = input.toString(); } } else { // TODO: remove after legacy code has been removed. LogUtils.d(LOG_TAG, "No remote input from new api, falling back to compatibility mode"); ClipData clipData = intent.getClipData(); if (clipData != null && LEGACY_WEAR_EXTRA.equals(clipData.getDescription().getLabel())) { Bundle extras = clipData.getItemAt(0).getIntent().getExtras(); if (extras != null) { wearReply = extras.getString(NotificationActionUtils.WEAR_REPLY_INPUT); } } } if (!TextUtils.isEmpty(wearReply)) { createWearReplyTask(this, mRefMessageUri, UIProvider.MESSAGE_PROJECTION, mComposeMode, wearReply).execute(); finish(); return; } else { LogUtils.w(LOG_TAG, "remote input string is null"); } } getLoaderManager().initLoader(INIT_DRAFT_USING_REFERENCE_MESSAGE, null, this); return; } else if (message != null && action != EDIT_DRAFT) { initFromDraftMessage(message); initQuotedTextFromRefMessage(mRefMessage, action); mShowQuotedText = message.appendRefMessageContent; // if we should be showing quoted text but mRefMessage is null // and we have some quotedText, display that if (mShowQuotedText && mRefMessage == null) { if (quotedText != null) { initQuotedText(quotedText, false /* shouldQuoteText */); } else if (mExtraValues != null) { initExtraValues(mExtraValues); return; } } } else if (action == EDIT_DRAFT) { if (message == null) { throw new IllegalStateException("Message must not be null to edit draft"); } initFromDraftMessage(message); // Update the action to the draft type of the previous draft switch (message.draftType) { case UIProvider.DraftType.REPLY: action = REPLY; break; case UIProvider.DraftType.REPLY_ALL: action = REPLY_ALL; break; case UIProvider.DraftType.FORWARD: action = FORWARD; break; case UIProvider.DraftType.COMPOSE: default: action = COMPOSE; break; } LogUtils.d(LOG_TAG, "Previous draft had action type: %d", action); mShowQuotedText = message.appendRefMessageContent; //TS: Gantao 2015-07-28 EMAIL BUGFIX_1053829 MOD_S //Terrible original design,refMessageUri did not save to db,the value is always 0 here. //but the body's sourceKey is saved ,it points to the refMessage's id,so we can get //the refMessage from the body's sourceKey. long sourceKey = Body.restoreBodySourceKey(this, message.id); if (sourceKey != 0) { // If we're editing an existing draft that was in reference to an existing message, // still need to load that original message since we might need to refer to the // original sender and recipients if user switches "reply <-> reply-all". mRefMessageUri = Uri.parse("content://" + EmailContent.AUTHORITY + "/uimessage/" + sourceKey); //TS: Gantao 2015-07-28 EMAIL BUGFIX_1053829 MOD_E mComposeMode = action; getLoaderManager().initLoader(REFERENCE_MESSAGE_LOADER, null, this); return; } } else if ((action == REPLY || action == REPLY_ALL || action == FORWARD)) { if (mRefMessage != null) { initFromRefMessage(action); mShowQuotedText = true; } } else { if (initFromExtras(intent)) { return; } } mComposeMode = action; finishSetup(action, intent, savedState); }
From source file:com.zoffcc.applications.zanavi.Navit.java
@SuppressLint("NewApi") public boolean onOptionsItemSelected_wrapper(int id) { // Handle item selection switch (id) { case 1://from w ww.j a v a 2s.co m // zoom in Message msg = new Message(); Bundle b = new Bundle(); b.putInt("Callback", 1); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); // if we zoom, hide the bubble if (N_NavitGraphics.NavitAOverlay != null) { N_NavitGraphics.NavitAOverlay.hide_bubble(); } Log.e("Navit", "onOptionsItemSelected -> zoom in"); break; case 2: // zoom out msg = new Message(); b = new Bundle(); b.putInt("Callback", 2); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); // if we zoom, hide the bubble if (N_NavitGraphics.NavitAOverlay != null) { N_NavitGraphics.NavitAOverlay.hide_bubble(); } Log.e("Navit", "onOptionsItemSelected -> zoom out"); break; case 3: // map download menu Intent map_download_list_activity = new Intent(this, NavitDownloadSelectMapActivity.class); this.startActivityForResult(map_download_list_activity, Navit.NavitDownloaderPriSelectMap_id); break; case 5: toggle_poi_pref(); set_poi_layers(); draw_map(); break; case 6: // ok startup address search activity (online google maps search) Navit.use_index_search = false; Intent search_intent = new Intent(this, NavitAddressSearchActivity.class); search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS search_intent.putExtra("address_string", Navit_last_address_search_string); //search_intent.putExtra("hn_string", Navit_last_address_hn_string); search_intent.putExtra("type", "online"); String pm_temp = "0"; if (Navit_last_address_partial_match) { pm_temp = "1"; } search_intent.putExtra("partial_match", pm_temp); this.startActivityForResult(search_intent, NavitAddressSearch_id_online); break; case 7: // ok startup address search activity (offline binfile search) Navit.use_index_search = Navit.allow_use_index_search(); Intent search_intent2 = new Intent(this, NavitAddressSearchActivity.class); search_intent2.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS search_intent2.putExtra("address_string", Navit_last_address_search_string); search_intent2.putExtra("hn_string", Navit_last_address_hn_string); search_intent2.putExtra("type", "offline"); search_intent2.putExtra("search_country_id", Navit_last_address_search_country_id); String pm_temp2 = "0"; if (Navit_last_address_partial_match) { pm_temp2 = "1"; } search_intent2.putExtra("partial_match", pm_temp2); this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline); break; case 8: // map delete menu Intent map_delete_list_activity2 = new Intent(this, NavitDeleteSelectMapActivity.class); this.startActivityForResult(map_delete_list_activity2, Navit.NavitDeleteSecSelectMap_id); break; case 9: // stop navigation (this menu should only appear when navigation is actually on!) Message msg2 = new Message(); Bundle b2 = new Bundle(); b2.putInt("Callback", 7); msg2.setData(b2); NavitGraphics.callback_handler.sendMessage(msg2); Log.e("Navit", "stop navigation"); break; case 10: // open settings menu Intent settingsActivity = new Intent(getBaseContext(), NavitPreferences.class); startActivity(settingsActivity); break; case 11: //zoom_to_route zoom_to_route(); break; case 12: // --------- make app crash --------- // --------- make app crash --------- // --------- make app crash --------- // ** // DEBUG // ** // crash_app_java(1); // ** // DEBUG // ** // crash_app_C(); // --------- make app crash --------- // --------- make app crash --------- // --------- make app crash --------- // announcer off Navit_Announcer = false; msg = new Message(); b = new Bundle(); b.putInt("Callback", 34); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); try { invalidateOptionsMenu(); } catch (Exception e) { } break; case 13: // announcer on Navit_Announcer = true; msg = new Message(); b = new Bundle(); b.putInt("Callback", 35); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); try { invalidateOptionsMenu(); } catch (Exception e) { } break; case 14: // show recent destination list Intent i2 = new Intent(this, NavitRecentDestinationActivity.class); this.startActivityForResult(i2, Navit.NavitRecentDest_id); break; case 15: // show current target on googlemaps String current_target_string = NavitGraphics.CallbackGeoCalc(4, 1, 1); // Log.e("Navit", "got target 1: "+current_target_string); if (current_target_string.equals("x:x")) { Log.e("Navit", "no target set!"); } else { try { String tmp[] = current_target_string.split(":", 2); googlemaps_show(tmp[0], tmp[1], "ZANavi Target"); } catch (Exception e) { e.printStackTrace(); Log.e("Navit", "problem with target!"); } } break; case 16: // show online manual Log.e("Navit", "user wants online help, show the website lang=" + NavitTextTranslations.main_language.toLowerCase()); // URL to ZANavi Manual (in english language) String url = "http://zanavi.cc/index.php/Manual"; if (FDBL) { url = "http://fd.zanavi.cc/manual"; } if (NavitTextTranslations.main_language.toLowerCase().equals("de")) { // show german manual url = "http://zanavi.cc/index.php/Manual/de"; if (FDBL) { url = "http://fd.zanavi.cc/manualde"; } } Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); break; case 17: // show age of maps (online) Intent i3 = new Intent(Intent.ACTION_VIEW); i3.setData(Uri.parse(NavitMapDownloader.ZANAVI_MAPS_AGE_URL)); startActivity(i3); break; case 18: Intent intent_latlon = new Intent(Intent.ACTION_MAIN); //intent_latlon.setAction("android.intent.action.POINTPICK"); intent_latlon.setPackage("com.cruthu.latlongcalc1"); intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongMain"); //intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongPointPick"); try { startActivity(intent_latlon); } catch (Exception e88) { e88.printStackTrace(); // show install page try { // String urlx = "http://market.android.com/details?id=com.cruthu.latlongcalc1"; String urlx = "market://details?id=com.cruthu.latlongcalc1"; Intent ix = new Intent(Intent.ACTION_VIEW); ix.setData(Uri.parse(urlx)); startActivity(ix); } catch (Exception ex) { ex.printStackTrace(); } } break; case 19: // GeoCoordEnterDialog Intent it001 = new Intent(this, GeoCoordEnterDialog.class); this.startActivityForResult(it001, Navit.NavitGeoCoordEnter_id); break; case 20: // convert GPX file Intent intent77 = new Intent(getBaseContext(), FileDialog.class); File a = new File(p.PREF_last_selected_dir_gpxfiles); try { // convert the "/../" in the path to normal absolut dir intent77.putExtra(FileDialog.START_PATH, a.getCanonicalPath()); //can user select directories or not intent77.putExtra(FileDialog.CAN_SELECT_DIR, false); // disable the "new" button intent77.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN); //alternatively you can set file filter //intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "gpx" }); startActivityForResult(intent77, Navit.NavitGPXConvChooser_id); } catch (IOException e1) { e1.printStackTrace(); } break; case 21: // add traffic block (like blocked road, or construction site) at current location of crosshair try { String traffic = ""; if (Navit.GFX_OVERSPILL) { traffic = NavitGraphics.CallbackGeoCalc(7, (int) (NavitGraphics.Global_dpi_factor * (NavitGraphics.mCanvasWidth / 2 + NavitGraphics.mCanvasWidth_overspill)), (int) (NavitGraphics.Global_dpi_factor * (NavitGraphics.mCanvasHeight / 2 + NavitGraphics.mCanvasHeight_overspill))); } else { traffic = NavitGraphics.CallbackGeoCalc(7, (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasWidth / 2), (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasHeight / 2)); } // System.out.println("traffic=" + traffic); File traffic_file_dir = new File(MAP_FILENAME_PATH); traffic_file_dir.mkdirs(); File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt"); FileOutputStream fOut = null; OutputStreamWriter osw = null; try { fOut = new FileOutputStream(traffic_file, true); osw = new OutputStreamWriter(fOut); osw.write("type=traffic_distortion maxspeed=0" + "\n"); // item header osw.write(traffic); // item coordinates osw.close(); fOut.close(); } catch (Exception ef) { ef.printStackTrace(); } // update route, if a route is set msg = new Message(); b = new Bundle(); b.putInt("Callback", 73); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); // draw map no-async msg = new Message(); b = new Bundle(); b.putInt("Callback", 64); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); } catch (Exception e) { e.printStackTrace(); } break; case 22: // clear all traffic blocks try { File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt"); traffic_file.delete(); // update route, if a route is set msg = new Message(); b = new Bundle(); b.putInt("Callback", 73); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); // draw map no-async msg = new Message(); b = new Bundle(); b.putInt("Callback", 64); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); } catch (Exception e) { } break; case 23: // clear all GPX maps try { File gpx_file = new File(MAP_FILENAME_PATH + "/gpxtracks.txt"); gpx_file.delete(); // draw map no-async msg = new Message(); b = new Bundle(); b.putInt("Callback", 64); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); } catch (Exception e) { } break; case 24: // show feedback form Intent i4 = new Intent(this, NavitFeedbackFormActivity.class); this.startActivityForResult(i4, Navit.NavitSendFeedback_id); break; case 25: // share the current destination with your friends String current_target_string2 = NavitGraphics.CallbackGeoCalc(4, 1, 1); if (current_target_string2.equals("x:x")) { Log.e("Navit", "no target set!"); } else { try { String tmp[] = current_target_string2.split(":", 2); if (Navit.OSD_route_001.arriving_time_valid) { share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), Navit.OSD_route_001.arriving_time, true); } else { share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), "", true); } } catch (Exception e) { e.printStackTrace(); Log.e("Navit", "problem with target!"); } } break; case 26: // donate Log.e("Navit", "start donate app"); donate(); break; case 27: // donate Log.e("Navit", "donate bitcoins"); donate_bitcoins(); break; case 28: // replay GPS file Intent intent771 = new Intent(getBaseContext(), FileDialog.class); File a1 = new File(Navit.NAVIT_DATA_DEBUG_DIR); try { // convert the "/../" in the path to normal absolut dir intent771.putExtra(FileDialog.START_PATH, a1.getCanonicalPath()); //can user select directories or not intent771.putExtra(FileDialog.CAN_SELECT_DIR, false); // disable the "new" button intent771.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN); //alternatively you can set file filter intent771.putExtra(FileDialog.FORMAT_FILTER, new String[] { "txt", "yaml" }); startActivityForResult(intent771, Navit.NavitReplayFileConvChooser_id); } catch (IOException e1) { e1.printStackTrace(); } break; case 29: // About Screen Intent it002 = new Intent(this, ZANaviAboutPage.class); this.startActivityForResult(it002, Navit.ZANaviAbout_id); break; case 88: // dummy entry, just to make "breaks" in the menu break; case 601: // DEBUG: activate demo vehicle and set position to position to screen center Navit.DemoVehicle = true; msg = new Message(); b = new Bundle(); b.putInt("Callback", 101); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); final Thread demo_v_001 = new Thread() { @Override public void run() { try { Thread.sleep(1000); // wait 1 seconds before we start try { float lat = 0; float lon = 0; String lat_lon = ""; if (Navit.GFX_OVERSPILL) { lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor * (NG__map_main.view.getWidth() / 2 + NavitGraphics.mCanvasWidth_overspill), NavitGraphics.Global_dpi_factor * (NG__map_main.view.getHeight() / 2 + NavitGraphics.mCanvasHeight_overspill)); } else { lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor * NG__map_main.view.getWidth() / 2, NavitGraphics.Global_dpi_factor * NG__map_main.view.getHeight() / 2); } String tmp[] = lat_lon.split(":", 2); //System.out.println("tmp=" + lat_lon); lat = Float.parseFloat(tmp[0]); lon = Float.parseFloat(tmp[1]); //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon); Location l = null; l = new Location("ZANavi Demo 001"); l.setLatitude(lat); l.setLongitude(lon); l.setBearing(0.0f); l.setSpeed(0); l.setAccuracy(4.0f); // accuracy 4 meters // NavitVehicle.update_compass_heading(0.0f); NavitVehicle.set_mock_location__fast(l); } catch (Exception e) { } Message msg = new Message(); Bundle b = new Bundle(); b.putInt("Callback", 52); b.putString("s", "45"); // speed in km/h of Demo-Vehicle // b.putString("s", "20"); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); } catch (Exception e) { } } }; demo_v_001.start(); msg = new Message(); b = new Bundle(); b.putInt("Callback", 51); if (Navit.GFX_OVERSPILL) { b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill))); b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill))); } else { b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2)); b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2)); } msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); break; case 602: // DEBUG: toggle textview with spoken and translated string (to help with translation) try { if (NavitGraphics.NavitMsgTv2_.getVisibility() == View.VISIBLE) { NavitGraphics.NavitMsgTv2_.setVisibility(View.GONE); NavitGraphics.NavitMsgTv2_.setEnabled(false); NavitGraphics.NavitMsgTv2sc_.setVisibility(View.GONE); NavitGraphics.NavitMsgTv2sc_.setEnabled(false); } else { NavitGraphics.NavitMsgTv2sc_.setVisibility(View.VISIBLE); NavitGraphics.NavitMsgTv2sc_.setEnabled(true); NavitGraphics.NavitMsgTv2_.setVisibility(View.VISIBLE); NavitGraphics.NavitMsgTv2_.setEnabled(true); } } catch (Exception e) { e.printStackTrace(); } break; case 603: // DEBUG: show all possible navigation commands (also translated) NavitGraphics.generate_all_speech_commands(); break; case 604: // DEBUG: activate FAST driving demo vehicle and set position to screen center Navit.DemoVehicle = true; msg = new Message(); b = new Bundle(); b.putInt("Callback", 52); b.putString("s", "800"); // speed in ~km/h of Demo-Vehicle msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); msg = new Message(); b = new Bundle(); b.putInt("Callback", 51); if (Navit.GFX_OVERSPILL) { b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill))); b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill))); } else { b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2)); b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2)); } msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); try { float lat = 0; float lon = 0; lat = 0; lon = 0; String lat_lon = ""; if (Navit.GFX_OVERSPILL) { lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor * (NG__map_main.view.getWidth() / 2 + NavitGraphics.mCanvasWidth_overspill), NavitGraphics.Global_dpi_factor * (NG__map_main.view.getHeight() / 2 + NavitGraphics.mCanvasHeight_overspill)); } else { lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor * NG__map_main.view.getWidth() / 2, NavitGraphics.Global_dpi_factor * NG__map_main.view.getHeight() / 2); } String tmp[] = lat_lon.split(":", 2); //System.out.println("tmp=" + lat_lon); lat = Float.parseFloat(tmp[0]); lon = Float.parseFloat(tmp[1]); //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon); Location l = null; l = new Location("ZANavi Demo 001"); l.setLatitude(lat); l.setLongitude(lon); l.setBearing(0.0f); l.setSpeed(0); l.setAccuracy(4.0f); // accuracy 4 meters // NavitVehicle.update_compass_heading(0.0f); NavitVehicle.set_mock_location__fast(l); } catch (Exception e) { } break; case 605: // DEBUG: toggle Routgraph on/off msg = new Message(); b = new Bundle(); b.putInt("Callback", 71); Navit.Routgraph_enabled = 1 - Navit.Routgraph_enabled; b.putString("s", "" + Navit.Routgraph_enabled); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); break; case 606: // DEBUG: spill contents of index file(s) msg = new Message(); b = new Bundle(); b.putInt("Callback", 83); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); break; case 607: export_map_points_to_sdcard(); break; case 608: import_map_points_from_sdcard(); break; case 609: // run yaml tests new Thread() { public void run() { try { ZANaviDebugReceiver.DR_run_all_yaml_tests(); } catch (Exception e) { } } }.start(); break; case 99: try { if (wl_navigating != null) { //if (wl_navigating.isHeld()) //{ wl_navigating.release(); Log.e("Navit", "WakeLock Nav: release 1"); //} } } catch (Exception e) { e.printStackTrace(); } // exit this.onPause(); this.onStop(); this.exit(); //msg = new Message(); //b = new Bundle(); //b.putInt("Callback", 5); //b.putString("cmd", "quit();"); //msg.setData(b); //N_NavitGraphics.callback_handler.sendMessage(msg); break; } return true; }
From source file:com.zoffcc.applications.zanavi.Navit.java
/** Called when the activity is first created. */ // ----------- remove later ------------- // ----------- remove later ------------- @SuppressLint("NewApi") // ----------- remove later ------------- // ----------- remove later ------------- @TargetApi(Build.VERSION_CODES.FROYO)//w w w .java 2 s. c om @Override public void onCreate(Bundle savedInstanceState) { // if (Navit.METHOD_DEBUG) Navit.my_func_name(0); // ------- only after API level 9 ------- // ------- only after API level 9 ------- // try // { // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyDeath().penaltyLog().build()); // StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build()); // // StrictMode.ThreadPolicy old = StrictMode.getThreadPolicy(); // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder(old).permitDiskWrites().build()); // old = StrictMode.getThreadPolicy(); // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder(old).permitDiskReads().build()); // // } // catch (NoClassDefFoundError e) // { // } // ------- only after API level 9 ------- // ------- only after API level 9 ------- // Log.e("Navit", "OnCreate"); // if (checkPlayServices()) // { // } ZANaviMainApplication.restore_error_msg(this.getApplicationContext()); // app_status_lastalive = PreferenceManager.getDefaultSharedPreferences(this).getLong(PREF_KEY_LASTALIVE, -1L); app_status_string = PreferenceManager.getDefaultSharedPreferences(this).getString(PREF_KEY_CRASH, "down"); if (FDBL) { p.PREF_enable_debug_crashdetect = PreferenceManager.getDefaultSharedPreferences(this) .getBoolean("enable_debug_crashdetect", true); } else { p.PREF_enable_debug_crashdetect = PreferenceManager.getDefaultSharedPreferences(this) .getBoolean("enable_debug_crashdetect", PLAYSTORE_VERSION_CRASHDETECT); } System.out.println("app_status_string get:[onCreate]" + app_status_string); System.out.println("app_status_string=" + app_status_string); // System.out.println("app_status_string:app_status_lastalive=" + app_status_lastalive); if (app_status_string.compareToIgnoreCase("down") != 0) { if (Navit.CI_ALLOWCRASHREPORTS) { intro_flag_crash = true; System.out.println("app_status_string:1:" + "intro_flag_crash=" + intro_flag_crash); } else { intro_flag_crash = false; } } else { intro_flag_crash = false; } // if (System.currentTimeMillis() > app_status_lastalive + allowed_seconds_alive_for_crash) // { // // reset crash flag after X seconds // intro_flag_crash = false; // } if (checkForUpdate()) { // reset crash flag if we just updated intro_flag_crash = false; } if (!p.PREF_enable_debug_crashdetect) { // reset crash flag if we preference set to "false" intro_flag_crash = false; } // --- if we have no stacktrace -> don't show crash screen ---------- if (intro_flag_crash) { try { if (ZANaviMainApplication.last_stack_trace_as_string == null) { intro_flag_crash = false; } else if (ZANaviMainApplication.last_stack_trace_as_string.length() < 2) { intro_flag_crash = false; } } catch (Exception e) { e.printStackTrace(); } } // --- if we have no stacktrace -> don't show crash screen ---------- System.out.println("app_status_string:2:" + "intro_flag_crash=" + intro_flag_crash); try { app_status_string = "running"; PreferenceManager.getDefaultSharedPreferences(this).edit().putString(PREF_KEY_CRASH, "running") .commit(); System.out.println("app_status_string set:[onCreate]" + app_status_string); } catch (Exception e) { e.printStackTrace(); } api_version_int = Integer.valueOf(android.os.Build.VERSION.SDK); System.out.println("XXX:API=" + api_version_int); if (api_version_int > 10) { Navit.PAINT_OLD_API = false; } else { Navit.PAINT_OLD_API = true; } getPrefs_theme(); getPrefs_theme_main(); Navit.applySharedTheme(this, p.PREF_current_theme_M); super.onCreate(savedInstanceState); Global_Navit_Object = this; asset_mgr = getAssets(); PackageInfo pInfo; try { pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); ZANAVI_VERSION = pInfo.versionName; } catch (NameNotFoundException e4) { } // Intent intent = new Intent(this, ZANaviAboutPage.class); // startActivity(intent); // --------- check permissions ----------- // --------- check permissions ----------- // --------- check permissions ----------- /* * * <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> * <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> * <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> * <uses-permission android:name="android.permission.WAKE_LOCK" /> * <uses-permission android:name="android.permission.INTERNET" /> * <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> * <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> */ //if (EasyPermissions.hasPermissions(this, perms)) //{ // // have permissions! //} //else //{ // // ask for permissions // EasyPermissions.requestPermissions(this, Navit.get_text("ZANavi needs some permissions..."), RC_PERM_001, perms); //} // --------- check permissions ----------- // --------- check permissions ----------- // --------- check permissions ----------- OSD_blueish_bg_color = getResources().getColor(R.color.blueish_bg_color); // getBaseContext_ = getBaseContext().getApplicationContext(); getBaseContext_ = getBaseContext(); last_orientation = getResources().getConfiguration().orientation; content_resolver = getContentResolver(); // get_reglevel(); Display display_ = getWindowManager().getDefaultDisplay(); metrics = new DisplayMetrics(); display_.getMetrics(Navit.metrics); road_book_items = new ArrayList<ListViewItem>(); fragmentManager = getSupportFragmentManager(); setContentView(R.layout.main_layout); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { try { setSupportActionBar(toolbar); // System.out.println("TTT01:" + toolbar); } catch (NoClassDefFoundError e) { } } try { getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); getSupportActionBar().setDisplayUseLogoEnabled(false); getSupportActionBar().setIcon(R.drawable.icon); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); } catch (NoClassDefFoundError e) { } catch (Exception e) { e.printStackTrace(); } progressbar_main_activity = (ProgressBar) findViewById(R.id.progressbar_main_activity); progressbar_main_activity.setVisibility(View.GONE); progressbar_main_activity.setProgress(0); // ------------ bottom bar slider ---------------- // ------------ bottom bar slider ---------------- // ------------ bottom bar slider ---------------- if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { smaller_top_bar(true); } else { smaller_top_bar(false); } bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height); // System.out.println("VVV:bottom_bar_height:" + bottom_bar_px); bottom_bar_slider_shadow_px = (int) getResources() .getDimension(R.dimen.bottom_slide_view_shadow_compat_height); // System.out.println("VVV:bottom_bar_slider_shadow_px:" + bottom_bar_slider_shadow_px); // final RelativeLayout a = (RelativeLayout) findViewById(R.id.bottom_bar_container); final FrameLayout a = (FrameLayout) findViewById(R.id.bottom_bar_slide); final RelativeLayout.LayoutParams pp22 = (RelativeLayout.LayoutParams) a.getLayoutParams(); // Calculate ToolBar height try { TypedValue tv = new TypedValue(); if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); System.out.println("VVV:abh:" + actionBarHeight); } else { actionBarHeight = NavitGraphics.dp_to_px(144); } } catch (Exception e) { actionBarHeight = NavitGraphics.dp_to_px(144); } final android.support.v7.widget.Toolbar view_toolbar_top = (android.support.v7.widget.Toolbar) findViewById( R.id.toolbar); ViewTreeObserver vto = view_toolbar_top.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { view_toolbar_top.getViewTreeObserver().removeGlobalOnLayoutListener(this); // int width = view_toolbar_top.getMeasuredWidth(); int height = view_toolbar_top.getMeasuredHeight(); Navit.actionBarHeight = height; // System.out.println("hhh:88=" + Navit.actionBarHeight); Navit.cur_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom pp22.setMargins(0, (int) Navit.cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom a.setLayoutParams(pp22); a.requestLayout(); } }); // actionBarHeight = 168; // final int SWIPE_MIN_DISTANCE = NavitGraphics.dp_to_px(25); // final float SWIPE_THRESHOLD_VELOCITY = 5.5f; // final float FLING_PIXELS_PER_SECOND = 100; // final float maxFlingVelocity = ViewConfiguration.get(this).getScaledMaximumFlingVelocity(); final ViewConfiguration vc = ViewConfiguration.get(this); final int swipeMinDistance = vc.getScaledPagingTouchSlop(); final int swipeThresholdVelocity = vc.getScaledMinimumFlingVelocity(); swipeMaxOffPath = vc.getScaledTouchSlop(); // (there is also vc.getScaledMaximumFlingVelocity() one could check against) // setup some values -------- NavitGraphics.long_press_on_screen_max_distance = swipeMaxOffPath; // setup some values -------- class MyGestureDetector extends SimpleOnGestureListener { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { // float velocityPercentY = velocityY / maxFlingVelocity; // the percent is a value in the range of (0, 1] // float normalizedVelocityY = velocityPercentY * FLING_PIXELS_PER_SECOND; // where PIXELS_PER_SECOND is a device-independent measurement // System.out.println("VVV:" + (e1.getY() - e2.getY()) + " " + NavitGraphics.dp_to_px((int) (e1.getY() - e2.getY())) + " " + maxFlingVelocity + " " + velocityY + " " + velocityPercentY + " " + normalizedVelocityY + " " + SWIPE_THRESHOLD_VELOCITY); // System.out.println("VVV:2:" + swipeMinDistance + " " + swipeThresholdVelocity + " " + swipeMaxOffPath); // bottom to top if (e1.getY() - e2.getY() > swipeMinDistance && Math.abs(velocityY) > swipeThresholdVelocity) { //int featureWidth = getMeasuredWidth(); //mActiveFeature = (mActiveFeature < (mItems.size() - 1)) ? mActiveFeature + 1 : mItems.size() - 1; //smoothScrollTo(mActiveFeature * featureWidth, 0); //System.out.println("GS:002:up:" + velocityY + " " + e2.getY() + " " + e1.getY()); animate_bottom_bar_up(); return true; } // top to bottom else if (e2.getY() - e1.getY() > swipeMinDistance && Math.abs(velocityY) > swipeThresholdVelocity) { //int featureWidth = getMeasuredWidth(); //mActiveFeature = (mActiveFeature > 0) ? mActiveFeature - 1 : 0; //smoothScrollTo(mActiveFeature * featureWidth, 0); //System.out.println("GS:003:down:" + velocityY + " " + e1.getY() + " " + e2.getY()); animate_bottom_bar_down(); return true; } } catch (Exception e) { //System.out.println("GS:009:EE:" + e.getMessage()); } return false; } } mGestureDetector = new GestureDetector(new MyGestureDetector()); push_pin_view = (ImageView) findViewById(R.id.bottom_slide_left_side); push_pin_view.setOnClickListener(new ImageView.OnClickListener() { public void onClick(View v) { try { toggle_follow_button(); } catch (Exception e) { } } }); cur_y_margin_bottom_bar_touch = 0; // try to put view at bottom a.setOnTouchListener(new View.OnTouchListener() { @Override synchronized public boolean onTouch(View v, MotionEvent m) { int action = m.getAction(); if (mGestureDetector.onTouchEvent(m)) { //System.out.println("GS:001:fling!!"); // System.out.println("FRAG:fling:011"); return true; } else if (action == MotionEvent.ACTION_DOWN) { last_y_bottom_bar_touch = m.getY(); // put roadbook into layout ----------- FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); try { if (road_book == null) { road_book = new ZANaviRoadbookFragment(); // System.out.println("FRAG:attach:001"); fragmentTransaction.replace(R.id.roadbook_fragment_container, road_book, ""); fragmentTransaction.commitAllowingStateLoss(); // fragmentTransaction.show(road_book); } else { // System.out.println("FRAG:attached:003"); } } catch (Exception ef) { } // put roadbook into layout ----------- return true; } else if ((action == MotionEvent.ACTION_UP) || (action == MotionEvent.ACTION_CANCEL)) { // System.out.println("FRAG:up/cancel:012"); // release if (cur_y_margin_bottom_bar_touch > (bottom_y_margin_bottom_bar_touch / 2)) { // snap back to bottom animate_bottom_bar_down(); } else { // snap top top animate_bottom_bar_up(); } } else // if (action == MotionEvent.ACTION_MOVE) { // System.out.println("FRAG:*else*:012"); if (Math.abs(last_y_bottom_bar_touch - m.getY()) > 2) { float last_margin = cur_y_margin_bottom_bar_touch; cur_y_margin_bottom_bar_touch = cur_y_margin_bottom_bar_touch - (last_y_bottom_bar_touch - m.getY()); if ((cur_y_margin_bottom_bar_touch >= 0) && (cur_y_margin_bottom_bar_touch <= bottom_y_margin_bottom_bar_touch)) { // System.out.println("VVV:move:" + cur_y_margin_bottom_bar_touch + " " + bottom_y_margin_bottom_bar_touch); last_y_bottom_bar_touch = m.getY() + (last_y_bottom_bar_touch - m.getY()); RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a .getLayoutParams(); relativeParams.setMargins(0, (int) cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom a.setLayoutParams(relativeParams); a.requestLayout(); } else { // System.out.println("VVV:revert"); // revert position cur_y_margin_bottom_bar_touch = last_margin; } } } return true; } }); // ------------ bottom bar slider ---------------- // ------------ bottom bar slider ---------------- // ------------ bottom bar slider ---------------- // init cancel dialog!! ---------- // init cancel dialog!! ---------- Message msg2 = new Message(); Bundle b2 = new Bundle(); b2.putString("text", ""); msg2.what = 0; msg2.setData(b2); ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg2); // init cancel dialog!! ---------- // init cancel dialog!! ---------- app_window = getWindow(); // ---------------- set some directories ----------------- // ---------------- set some directories ----------------- NAVIT_DATA_DIR = this.getFilesDir().getPath(); this.getFilesDir().mkdirs(); // --- // System.out.println("data dir=" + NAVIT_DATA_DIR); NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR + "/share/"; File tmp3 = new File(NAVIT_DATA_SHARE_DIR); tmp3.mkdirs(); // --- FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt"; VERSION_FILE = NAVIT_DATA_SHARE_DIR + "/version.txt"; // ---------------- set some directories ----------------- // ---------------- set some directories ----------------- try { toneG = new ToneGenerator(AudioManager.STREAM_MUSIC, 100); } catch (Exception e) { } try { Class.forName("android.app.backup.BackupManager"); backupManager = new BackupManager(this); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } int width_ = display_.getWidth(); int height_ = display_.getHeight(); Log.e("Navit", "Navit -> pixels x=" + width_ + " pixels y=" + height_); Log.e("Navit", "Navit -> dpi=" + Navit.metrics.densityDpi); Log.e("Navit", "Navit -> density=" + Navit.metrics.density); Log.e("Navit", "Navit -> scaledDensity=" + Navit.metrics.scaledDensity); try { // send overspill factor to C-code Message msg33 = new Message(); Bundle b33 = new Bundle(); b33.putInt("Callback", 104); msg33.setData(b33); NavitGraphics.callback_handler.sendMessage(msg33); } catch (Exception eee) { } // ----- service ----- // ----- service ----- ZANaviMapDownloaderServiceIntent = new Intent(Navit.getBaseContext_, ZANaviMapDownloaderService.class); // ----- service ----- // ----- service ----- System.out.println("Navit:onCreate:JTHREAD ID=" + Thread.currentThread().getId()); System.out.println("Navit:onCreate:THREAD ID=" + NavitGraphics.GetThreadId()); // bitmaps for lanes lane_left = BitmapFactory.decodeResource(getResources(), R.drawable.lane_left); lane_right = BitmapFactory.decodeResource(getResources(), R.drawable.lane_right); lane_merge_to_left = BitmapFactory.decodeResource(getResources(), R.drawable.lane_merge_to_left); lane_merge_to_right = BitmapFactory.decodeResource(getResources(), R.drawable.lane_merge_to_right); lane_none = BitmapFactory.decodeResource(getResources(), R.drawable.lane_none); // bitmaps for lanes // paint for bitmapdrawing on map NavitGraphics.paint_for_map_display.setAntiAlias(true); NavitGraphics.paint_for_map_display.setFilterBitmap(true); // sky NavitGraphics.paint_sky_day.setAntiAlias(true); NavitGraphics.paint_sky_day.setColor(Color.parseColor("#79BAEC")); NavitGraphics.paint_sky_night.setAntiAlias(true); NavitGraphics.paint_sky_night.setColor(Color.parseColor("#090909")); // stars NavitGraphics.paint_sky_night_stars.setColor(Color.parseColor("#DEDDEF")); // twilight NavitGraphics.paint_sky_twilight1.setColor(Color.parseColor("#090909")); NavitGraphics.paint_sky_twilight2.setColor(Color.parseColor("#113268")); NavitGraphics.paint_sky_twilight3.setColor(Color.parseColor("#79BAEC")); Random m = new Random(); int i6 = 0; for (i6 = 0; i6 < (NavitGraphics.max_stars + 1); i6++) { NavitGraphics.stars_x[i6] = m.nextFloat(); NavitGraphics.stars_y[i6] = m.nextFloat(); NavitGraphics.stars_size[i6] = m.nextInt(3) + 1; } res_ = getResources(); int ii = 0; NavitGraphics.dl_thread_cur = 0; for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++) { NavitGraphics.dl_thread[ii] = null; } String font_file_name = "Roboto-Regular.ttf"; // "LiberationSans-Regular.ttf"; NavitStreetnameFont = Typeface.createFromAsset(getBaseContext().getAssets(), font_file_name); // System.out.println("NavitStreetnameFont" + NavitStreetnameFont); Navit_maps_loaded = false; // only take arguments here, onResume gets called all the time (e.g. when screenblanks, etc.) Navit.startup_intent = this.getIntent(); // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target! Navit.startup_intent_timestamp = System.currentTimeMillis(); Log.e("Navit", "**1**A " + startup_intent.getAction()); Log.e("Navit", "**1**D " + startup_intent.getDataString()); Log.e("Navit", "**1**I " + startup_intent.toString()); try { Log.e("Navit", "**1**DH E " + startup_intent.getExtras().describeContents()); } catch (Exception ee) { } startup_status = Navit_Status_NORMAL_STARTUP; // glSurfaceView = (GLSurfaceView) findViewById(R.id.glSurfaceView_001); // glSurfaceView.setEGLContextClientVersion(2); // enable OpenGL 2.0 // glSurfaceView.setRenderer(new GlRenderer()); // glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); // only render on demand // // // draw some sample lines ---- // // draw some sample lines ---- // // draw some sample lines ---- // ZANaviGlLine vertLine = new ZANaviGlLine(); // vertLine.SetVerts(1000f, 1000f, 0f, -1000f, -1000f, 0f); // vertLine.SetColor(.8f, .8f, 0f, 1.0f); // // float[] mMVPMatrix = new float[16]; // // // Position the eye behind the origin. // final float eyeX = 0.0f; // final float eyeY = 0.0f; // final float eyeZ = 1.5f; // // // We are looking toward the distance // final float lookX = 0.0f; // final float lookY = 0.0f; // final float lookZ = -5.0f; // // // Set our up vector. This is where our head would be pointing were we holding the camera. // final float upX = 0.0f; // final float upY = 1.0f; // final float upZ = 0.0f; // // // Set the view matrix. This matrix can be said to represent the camera position. // // NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and // // view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose. // Matrix.setLookAtM(mMVPMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ); // // vertLine.draw(mMVPMatrix); // // glSurfaceView.postInvalidate(); // glSurfaceView.requestRender(); // glSurfaceView.postInvalidate(); // // draw some sample lines ---- // // draw some sample lines ---- // // draw some sample lines ---- // setup graphics objects // setup graphics objects // setup graphics objects NG__vehicle = new NavitGraphics(this, 1, 0, 0, 50, 50, 65535, 0, 0); NG__map_main = new NavitGraphics(this, 0, 0, 0, 100, 100, 0, 0, 0); Navit.N_NavitGraphics = NG__map_main; // setup graphics objects // setup graphics objects // setup graphics objects NV = new NavitVehicle(this); NSp = new NavitSpeech2(this); // init translated text ------------------------------------ // NavitTextTranslations.init(); final Runnable r = new Runnable() { public void run() { NavitTextTranslations.init(); } }; ThreadGroup group = new ThreadGroup("Group1"); new Thread(group, r, "ZTransInit1", 100000).start(); // use 0.1MByte stack // init translated text ------------------------------------ // set the new locale here ----------------------------------- getPrefs_loc(); activatePrefs_loc(); // set the new locale here ----------------------------------- // get the local language ------------- Locale locale = java.util.Locale.getDefault(); String lang = locale.getLanguage(); String langu = lang; String langc = lang; Log.e("Navit", "lang=" + lang); int pos = langu.indexOf('_'); if (pos != -1) { langc = langu.substring(0, pos); langu = langc + langu.substring(pos).toUpperCase(locale); Log.e("Navit", "substring lang " + langu.substring(pos).toUpperCase(locale)); // set lang. for translation NavitTextTranslations.main_language = langc; NavitTextTranslations.sub_language = langu.substring(pos).toUpperCase(locale); } else { String country = locale.getCountry(); Log.e("Navit", "Country1 " + country); Log.e("Navit", "Country2 " + country.toUpperCase(locale)); langu = langc + "_" + country.toUpperCase(locale); // set lang. for translation NavitTextTranslations.main_language = langc; NavitTextTranslations.sub_language = country.toUpperCase(locale); } Log.e("Navit", "Language " + lang); // get the local language ------------- TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text); no_maps_text.setText("\n\n\n" + Navit.get_text("No Maps installed") + "\n" + Navit.get_text("Please download a map") + "\n\n"); // if (api_version_int < 11) // { try { try { no_maps_text.setVisibility(View.INVISIBLE); } catch (NoSuchMethodError e) { } try { no_maps_text.setActivated(false); } catch (NoSuchMethodError e) { } } catch (Exception e) { e.printStackTrace(); } // } // no_maps_text.postInvalidate(); // set map cache size here ----------------------------------- getPrefs_mapcache(); activatePrefs_mapcache(); // set map cache size here ----------------------------------- // get map data dir and set it ----------------------------- getPrefs_mapdir(); activatePrefs_mapdir(true); // get map data dir and set it ----------------------------- // get special prefs here ------------------------------------ get_prefs_highdpi(); // get special prefs here ------------------------------------ // make sure the new path for the navitmap.bin file(s) exist!! File navit_maps_dir = new File(MAP_FILENAME_PATH); navit_maps_dir.mkdirs(); // create nomedia files File nomedia_file = new File(MAP_FILENAME_PATH + ".nomedia"); try { nomedia_file.createNewFile(); } catch (Exception e1) { e1.printStackTrace(); } // create nomedia files // check if we already have a borders.bin file (if not, then extract the included simplified one) File b_ = new File(MAP_FILENAME_PATH + "/borders.bin"); try { if (!b_.exists()) { try { File c_ = new File(MAPMD5_FILENAME_PATH + "/borders.bin.md5"); c_.delete(); } catch (Exception e2) { } Log.e("Navit", "trying to extract borders simple resource to:" + MAP_FILENAME_PATH + "/borders.bin"); if (!extractRes("borders_simple", MAP_FILENAME_PATH + "/borders.bin")) { Log.e("Navit", "Failed to extract borders simple resource to:" + MAP_FILENAME_PATH + "/borders.bin"); } } } catch (Exception e) { } // check if we already have a borders.bin file // make sure the new path for config files exist File navit_cfg_dir = new File(CFG_FILENAME_PATH); navit_cfg_dir.mkdirs(); // make sure the new path for the navitmap.bin file(s) exist!! File navit_mapsmd5_dir = new File(MAPMD5_FILENAME_PATH); navit_mapsmd5_dir.mkdirs(); // make sure the share dir exists, otherwise the infobox will not show File navit_data_share_dir = new File(NAVIT_DATA_SHARE_DIR); navit_data_share_dir.mkdirs(); File dd = new File(NAVIT_DATA_DEBUG_DIR); dd.mkdirs(); // try to create cat. file if it does not exist File navit_maps_catalogue = new File(CFG_FILENAME_PATH + NavitMapDownloader.CAT_FILE); if (!navit_maps_catalogue.exists()) { FileOutputStream fos_temp; try { fos_temp = new FileOutputStream(navit_maps_catalogue); fos_temp.write((NavitMapDownloader.MAP_CAT_HEADER + "\n").getBytes()); // just write header to the file fos_temp.flush(); fos_temp.close(); } catch (Exception e) { e.printStackTrace(); } } // ---------- downloader threads ---------------- PackageInfo pkgInfo; Navit_DonateVersion_Installed = false; try { // is the donate version installed? pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_donate", 0); String sharedUserId = pkgInfo.sharedUserId; System.out.println("str nd=" + sharedUserId); if (sharedUserId.equals("com.zoffcc.applications.zanavi")) { System.out.println("##bonus 001##"); Navit_DonateVersion_Installed = true; NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX; } } catch (NameNotFoundException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } try { if (get_reglevel() == 1) { System.out.println("##U:bonus 001##"); Navit_DonateVersion_Installed = true; NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX; } } catch (Exception e) { e.printStackTrace(); } try { // is the "large map" donate version installed? pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_largemap_donate", 0); String sharedUserId = pkgInfo.sharedUserId; System.out.println("str lm=" + sharedUserId); if (sharedUserId.equals("com.zoffcc.applications.zanavi")) { System.out.println("##bonus 002##"); Navit_DonateVersion_Installed = true; Navit_Largemap_DonateVersion_Installed = true; NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX; } } catch (NameNotFoundException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } try { if (get_reglevel() == 1) { System.out.println("##U:bonus 002##"); Navit_DonateVersion_Installed = true; Navit_Largemap_DonateVersion_Installed = true; NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX; } } catch (Exception e) { e.printStackTrace(); } // update map list NavitMapDownloader.init_maps_without_donate_largemaps(); // ---------- downloader threads ---------------- // ---- detect menu button ---- detect_menu_button(); if (Navit.metrics.densityDpi >= 320) //&& (PREF_shrink_on_high_dpi)) { Navit.menu_button = BitmapFactory.decodeResource(getResources(), R.drawable.menu_001); } else { Navit.menu_button = BitmapFactory.decodeResource(getResources(), R.drawable.menu_001_small); } Navit.long_green_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.long_green_arrow); Navit.follow_on = BitmapFactory.decodeResource(getResources(), R.drawable.follow); Navit.follow_off = BitmapFactory.decodeResource(getResources(), R.drawable.follow_off); Navit.follow_current = Navit.follow_on; if ((Navit.metrics.densityDpi >= 320) && (p.PREF_shrink_on_high_dpi)) { float factor; factor = (float) NavitGraphics.Global_Scaled_DPI_normal / (float) Navit.metrics.densityDpi; factor = factor * 1.7f; // BitmapFactory.Options o = new BitmapFactory.Options(); o.inDither = true; //o.inScaled = true; //o.inTargetDensity = NavitGraphics.Global_Scaled_DPI_normal; Navit.nav_arrow_stopped = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_stopped, o); Navit.nav_arrow_moving = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving, o); Navit.nav_arrow_moving_grey = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_grey, o); Navit.nav_arrow_moving_shadow = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_shadow, o); Navit.nav_arrow_stopped_small = Bitmap.createScaledBitmap(Navit.nav_arrow_stopped, (int) (Navit.nav_arrow_stopped.getWidth() / NavitGraphics.strech_factor_3d_map * factor), (int) (Navit.nav_arrow_stopped.getHeight() / NavitGraphics.strech_factor_3d_map * factor), true); Navit.nav_arrow_moving_small = Bitmap.createScaledBitmap(Navit.nav_arrow_moving, (int) (Navit.nav_arrow_moving.getWidth() / NavitGraphics.strech_factor_3d_map * factor), (int) (Navit.nav_arrow_moving.getHeight() / NavitGraphics.strech_factor_3d_map * factor), true); Navit.nav_arrow_moving_shadow_small = Bitmap.createScaledBitmap(Navit.nav_arrow_moving_shadow, (int) (Navit.nav_arrow_moving_shadow.getWidth() / NavitGraphics.strech_factor_3d_map * factor), (int) (Navit.nav_arrow_moving_shadow.getHeight() / NavitGraphics.strech_factor_3d_map * factor), true); } else { Navit.nav_arrow_stopped = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_stopped); Navit.nav_arrow_moving = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving); Navit.nav_arrow_moving_grey = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_grey); Navit.nav_arrow_moving_shadow = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_shadow); Navit.nav_arrow_stopped_small = Bitmap.createScaledBitmap(Navit.nav_arrow_stopped, (int) (Navit.nav_arrow_stopped.getWidth() / NavitGraphics.strech_factor_3d_map), (int) (Navit.nav_arrow_stopped.getHeight() / NavitGraphics.strech_factor_3d_map), true); Navit.nav_arrow_moving_small = Bitmap.createScaledBitmap(Navit.nav_arrow_moving, (int) (Navit.nav_arrow_moving.getWidth() / NavitGraphics.strech_factor_3d_map), (int) (1.5 * Navit.nav_arrow_moving.getHeight() / NavitGraphics.strech_factor_3d_map), true); Navit.nav_arrow_moving_shadow_small = Bitmap.createScaledBitmap(Navit.nav_arrow_moving_shadow, (int) (Navit.nav_arrow_moving_shadow.getWidth() / NavitGraphics.strech_factor_3d_map), (int) (1.5 * Navit.nav_arrow_moving_shadow.getHeight() / NavitGraphics.strech_factor_3d_map), true); } Navit.zoomin = BitmapFactory.decodeResource(getResources(), R.drawable.zoom_in_32_32); Navit.zoomout = BitmapFactory.decodeResource(getResources(), R.drawable.zoom_out_32_32); //Navit.oneway_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.oneway); Navit.oneway_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.oneway_large); Navit.oneway_bicycle_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.oneway_bicycle_large); // ******************* // ******************* // ******************* // ******************* // check/init the catalogue file for downloaded maps NavitMapDownloader.init_cat_file(); // ******************* // ******************* // ******************* // ******************* xmlconfig_unpack_file = false; write_new_version_file = false; try { NavitAppVersion = "" + this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionCode; NavitAppVersion_string = "" + this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); NavitAppVersion = "1"; NavitAppVersion_string = "1"; } catch (Exception e) { e.printStackTrace(); NavitAppVersion = "2"; NavitAppVersion_string = "2"; } try { File navit_version = new File(VERSION_FILE); if (!navit_version.exists()) { System.out.println("version file does not exist"); NavitAppVersion_prev = "-1"; write_new_version_file = true; } else { // files exists, read in the prev. verison number System.out.println("version file is here"); FileInputStream fos_temp; byte[] buffer = new byte[101]; fos_temp = new FileInputStream(navit_version); int len = fos_temp.read(buffer, 0, 100); if (len != -1) { // use only len bytes to make the string (the rest is garbage!!) NavitAppVersion_prev = new String(buffer).substring(0, len); } else { NavitAppVersion_prev = "-1"; write_new_version_file = true; } fos_temp.close(); } } catch (Exception e) { NavitAppVersion_prev = "-1"; write_new_version_file = true; e.printStackTrace(); } System.out.println("vprev:" + NavitAppVersion_prev + " vcur:" + NavitAppVersion); intro_flag_update = false; if (NavitAppVersion_prev.compareTo(NavitAppVersion) != 0) { // different version System.out.println("different version!!"); write_new_version_file = true; xmlconfig_unpack_file = true; //if ((NavitAppVersion_prev.compareTo("-1") != 0) && (NavitAppVersion.compareTo("-1") != 0)) //{ // user has upgraded to a new version of ZANavi startup_status = Navit_Status_UPGRADED_TO_NEW_VERSION; intro_flag_update = true; //} } else { // same version System.out.println("same version"); xmlconfig_unpack_file = false; } // write new version file if (write_new_version_file) { try { System.out.println("write version file"); FileOutputStream fos_temp; File navit_version = new File(VERSION_FILE); navit_version.delete(); fos_temp = new FileOutputStream(navit_version); fos_temp.write(NavitAppVersion.getBytes()); fos_temp.flush(); fos_temp.close(); } catch (Exception e) { e.printStackTrace(); } } // Sample useragent strings: // // Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0a1) Gecko/20110616 Firefox/7.0a1 SeaMonkey/2.4a1 // Dalvik/1.4.0 (Linux; U; Android 2.3.3; GT-I9100 Build/GINGERBREAD) // Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-S5830 Build/FROYO) // Dalvik/1.4.0 (Linux; U; Android 2.3.3; HTC Desire S Build/GRI40) // Dalvik/1.2.0 (Linux; U; Android 2.2.2; MB525 Build/3.4.2-179) // Dalvik/1.4.0 (Linux; U; Android 2.3.3; HTC Wildfire S A510e Build/GRI40) // Wget/1.10.2 // Dalvik/1.4.0 (Linux; U; Android 2.3.3; sdk Build/GRI34) // Dalvik/1.2.0 (Linux; U; Android 2.2.2; MB525 Build/3.4.2-164) // Dalvik/1.2.0 (Linux; U; Android 2.2; GT-I9000 Build/FROYO) // Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-S5570L Build/FROYO) // Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-I9000 Build/FROYO) // Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1) String ANDROID = android.os.Build.VERSION.SDK; //The current development codename, or the string "REL" if this is a release build. //String BOARD = android.os.Build.BOARD; //The name of the underlying board, like "goldfish". //String BOOTLOADER = android.os.Build.BOOTLOADER; // The system bootloader version number. String BRAND = android.os.Build.BRAND; //The brand (e.g., carrier) the software is customized for, if any. //String CPU_ABI = android.os.Build.CPU_ABI; //The name of the instruction set (CPU type + ABI convention) of native code. //String CPU_ABI2 = android.os.Build.CPU_ABI2; // The name of the second instruction set (CPU type + ABI convention) of native code. String DEVICE = android.os.Build.DEVICE; // The name of the industrial design. String DISPLAY = android.os.Build.DISPLAY; //A build ID string meant for displaying to the user //String FINGERPRINT = android.os.Build.FINGERPRINT; //A string that uniquely identifies this build. //String HARDWARE = android.os.Build.HARDWARE; //The name of the hardware (from the kernel command line or /proc). //String HOST = android.os.Build.HOST; //String ID = android.os.Build.ID; //Either a changelist number, or a label like "M4-rc20". String MANUFACTURER = android.os.Build.MANUFACTURER; //The manufacturer of the product/hardware. //String MODEL = android.os.Build.MODEL; //The end-user-visible name for the end product. //String PRODUCT = android.os.Build.PRODUCT; //The name of the overall product. //String RADIO = android.os.Build.RADIO; //The radio firmware version number. //String TAGS = android.os.Build.TAGS; //Comma-separated tags describing the build, like "unsigned,debug". //String TYPE = android.os.Build.TYPE; //The type of build, like "user" or "eng". //String USER = android.os.Build.USER; String android_version = "Android " + ANDROID; String android_device = MANUFACTURER + " " + BRAND + " " + DEVICE; if (MANUFACTURER.equalsIgnoreCase("amazon")) { // we are on amazon device ZANaviNormalDonateActivity.on_amazon_device = true; } // debug // debug // android_device = "telechips telechips m801"; // debug // debug String android_rom_name = DISPLAY; if (FDBL) { android_rom_name = android_rom_name + "; FD"; } if (Navit_DonateVersion_Installed == false) { UserAgentString = "Mozilla/5.0 (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")"; UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")"; } else { if (Navit_Largemap_DonateVersion_Installed == false) { UserAgentString = "Mozilla/5.0 (Linux; U; " + "donateZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")"; UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "donateZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")"; } else { UserAgentString = "Mozilla/5.0 (Linux; U; " + "LMdonateLMZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")"; UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "LMdonateLMZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")"; } } // System.out.println("UA=" + UserAgentString); // --------- enable GPS ? -------------- // --------- enable GPS ? -------------- // try // { // final LocationManager llmanager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // if (!llmanager.isProviderEnabled(LocationManager.GPS_PROVIDER)) // { // buildAlertMessageNoGps(); // } // } // catch (Exception e) // { // e.printStackTrace(); // } // --------- enable GPS ? -------------- // --------- enable GPS ? -------------- unsupported = false; try { if (android_device.toLowerCase().contains("telechips")) { if (android_device.toLowerCase().contains("m801")) { // if the donate version is already installed, dont disable the app if (Navit_DonateVersion_Installed == false) { if (Navit_Largemap_DonateVersion_Installed == false) { // activate [Weltbild] Cat Nova again (19.12.2011) // ** // unsupported = true; } } } } } catch (Exception e) { e.printStackTrace(); } try { // this hangs the emulator, if emulator < 2.3 (only works in emulator >= 2.3)!! if (!NAVIT_IS_EMULATOR) { sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); } } catch (Exception e3) { e3.printStackTrace(); } // try // { // vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); // } // catch (Exception e) // { // e.printStackTrace(); // } //sensorManager_ = sensorManager; // light sensor ------------------- try { lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); lightsensor_max_value = lightSensor.getMaximumRange(); lightSensorEventListener = new SensorEventListener() { @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { } @Override public void onSensorChanged(SensorEvent event) { try { if (p.PREF_auto_night_mode) { if (event.sensor.getType() == Sensor.TYPE_LIGHT) { if (Navit.DEBUG_LUX_VALUE) { debug_cur_lux_value = event.values[0]; NavitGraphics.NavitAOverlay_s.postInvalidate(); } // System.out.println("Current Reading(Lux): cur=" + event.values[0] + " max=" + lightsensor_max_value); if (night_mode == false) { if (event.values[0] < p.PREF_night_mode_lux) { night_mode = true; set_night_mode(1); draw_map(); } } else if (night_mode == true) { if (event.values[0] > (p.PREF_night_mode_lux + p.PREF_night_mode_buffer)) { night_mode = false; set_night_mode(0); draw_map(); } } } } else { try { sensorManager.unregisterListener(lightSensorEventListener); System.out.println("stop lightsensor"); } catch (Exception e) { } try { night_mode = false; set_night_mode(0); draw_map(); } catch (Exception e) { } } } catch (Exception e) { // e.printStackTrace(); } } }; } catch (Exception e) { } // light sensor ------------------- generic_alert_box = new AlertDialog.Builder(this); /* * show info box for first time users */ AlertDialog.Builder infobox = new AlertDialog.Builder(this); //. english text: Welcome to ZANavi infobox.setTitle(Navit.get_text("__INFO_BOX_TITLE__")); //TRANS infobox.setCancelable(false); final TextView message = new TextView(this); message.setFadingEdgeLength(20); message.setVerticalFadingEdgeEnabled(true); message.setPadding(10, 5, 10, 5); message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); message.setGravity(Gravity.LEFT); // message.setScrollBarStyle(TextView.SCROLLBARS_INSIDE_OVERLAY); // message.setVerticalScrollBarEnabled(true); RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); rlp.leftMargin = 7; rlp.rightMargin = 7; Navit.Navit_Geocoder = null; try { // for online search Navit.Navit_Geocoder = new Geocoder(this); } catch (Exception e) { e.printStackTrace(); } // if (api_version_int < 11) // { // //TRANS // infobox.setPositiveButton(Navit.get_text("Ok"), new DialogInterface.OnClickListener() // { // public void onClick(DialogInterface arg0, int arg1) // { // Log.e("Navit", "Ok, user saw the infobox"); // } // }); // // //TRANS // infobox.setNeutralButton(Navit.get_text("More info"), new DialogInterface.OnClickListener() // { // public void onClick(DialogInterface arg0, int arg1) // { // Log.e("Navit", "user wants more info, show the website"); // // URL to ZANavi Manual (in english language) // String url = "http://zanavi.cc/index.php/Manual"; // if (FDBL) // { // url = "http://fd.zanavi.cc/manual"; // } // Intent i = new Intent(Intent.ACTION_VIEW); // i.setData(Uri.parse(url)); // startActivity(i); // } // }); // } info_popup_seen_count_end = false; File navit_first_startup = new File(FIRST_STARTUP_FILE); // if file does NOT exist, show the info box if (!navit_first_startup.exists()) { // set first-ever-startup flag first_ever_startup = true; info_popup_seen_count_end = true; // don't show on first ever start of the app startup_status = Navit_Status_COMPLETE_NEW_INSTALL; FileOutputStream fos_temp; try { info_popup_seen_count++; fos_temp = new FileOutputStream(navit_first_startup); fos_temp.write((int) info_popup_seen_count); // use to store info popup seen count fos_temp.flush(); fos_temp.close(); // if (api_version_int < 11) // { // message.setLayoutParams(rlp); // //. TRANSLATORS: multiline info text for first startup of application (see en_US for english text) // final SpannableString s = new SpannableString(" " + Navit.get_text("__INFO_BOX_TEXT__")); //TRANS // Linkify.addLinks(s, Linkify.WEB_URLS); // message.setText(s); // message.setMovementMethod(LinkMovementMethod.getInstance()); // infobox.setView(message); // infobox.show(); // } } catch (Exception e) { e.printStackTrace(); } } else { FileOutputStream fos_temp; FileInputStream fis_temp; try { fis_temp = new FileInputStream(navit_first_startup); info_popup_seen_count = fis_temp.read(); fis_temp.close(); if (info_popup_seen_count < 0) { info_popup_seen_count = 0; } // we wrote "A" -> (int)65 previously, so account for that if (info_popup_seen_count == 65) { info_popup_seen_count = 0; } if (info_popup_seen_count > info_popup_seen_count_max) { info_popup_seen_count_end = true; } else { info_popup_seen_count++; fos_temp = new FileOutputStream(navit_first_startup); fos_temp.write((int) info_popup_seen_count); // use to store info popup seen count fos_temp.flush(); fos_temp.close(); } } catch (Exception e) { e.printStackTrace(); } } /* * show info box for first time users */ // // ----------- info popup // ----------- info popup // ----------- info popup // ----------- info popup // intro_flag_info = false; if ((!info_popup_seen_count_end) && (startup_status == Navit_Status_NORMAL_STARTUP)) { intro_flag_info = true; } System.out.println("info_popup_seen_count=" + info_popup_seen_count); System.out.println("info_popup_seen_count_end=" + info_popup_seen_count_end + " intro_flag_info=" + intro_flag_info + " startup_status=" + startup_status); // make handler statically available for use in "msg_to_msg_handler" Navit_progress_h = this.progress_handler; // try // { // Navit.bigmap_bitmap = BitmapFactory.decodeResource(getResources(), R.raw.bigmap_colors_zanavi2); // } // catch (Exception e) // { // // when not enough memory is available, then disable large world overview map! // System.gc(); // Navit.bigmap_bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); // } // // ------no----- // Navit.bigmap_bitmap.setDensity(120); // set our dpi!! try { setVolumeControlStream(AudioManager.STREAM_MUSIC); ActivityResults = new NavitActivityResult[16]; } catch (Exception e) { e.printStackTrace(); } try { NavitAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); } catch (Exception e) { e.printStackTrace(); } PowerManager pm = null; try { pm = (PowerManager) getSystemService(Context.POWER_SERVICE); } catch (Exception e) { e.printStackTrace(); } try { // -- // pm.wakeUp(SystemClock.uptimeMillis()); // -- // // **screen always full on** // wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen"); // **screen can go off, cpu will stay on** // wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen"); // this works so far, lets the screen dim, but it cpu and screen stays on wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen"); } catch (Exception e) { e.printStackTrace(); wl = null; } try { wl_cpu = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ZANaviNeedCpu"); } catch (Exception e) { e.printStackTrace(); wl_cpu = null; } try { wl_navigating = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "ZANaviNavigationOn"); } catch (Exception e) { Log.e("Navit", "WakeLock NAV: create failed!!"); e.printStackTrace(); wl_navigating = null; } // try // { // if (wl_navigating != null) // { // wl_navigating.acquire(); // Log.e("Navit", "WakeLock NAV: acquire 00"); // } // } // catch (Exception e) // { // Log.e("Navit", "WakeLock NAV: something wrong 00"); // e.printStackTrace(); // } // try // { // if (wl != null) // { // try // { // wl.release(); // } // catch (Exception e2) // { // } // wl.acquire(); // Log.e("Navit", "WakeLock: acquire 1"); // } // } // catch (Exception e) // { // e.printStackTrace(); // } // -- extract overview maps -- // -- extract overview maps -- // File navit_worldmap2_file = new File(NAVIT_DATA_DIR + "/share/worldmap2.txt"); File navit_worldmap2_file = new File(MAP_FILENAME_PATH + "/worldmap2.txt"); if (!navit_worldmap2_file.exists()) { if (!extractRes("worldmap2", MAP_FILENAME_PATH + "/worldmap2.txt")) { Log.e("Navit", "Failed to extract worldmap2.txt"); } } File navit_worldmap5_file = new File(MAP_FILENAME_PATH + "/worldmap5.txt"); if (!navit_worldmap5_file.exists()) { if (!extractRes("worldmap5", MAP_FILENAME_PATH + "/worldmap5.txt")) { Log.e("Navit", "Failed to extract worldmap5.txt"); } } // -- extract overview maps -- // -- extract overview maps -- Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language); if (!extractRes(NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language, NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language + "/LC_MESSAGES/navit.mo")) { Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language); } Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language.toLowerCase()); if (!extractRes( NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language.toLowerCase(), NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language + "/LC_MESSAGES/navit.mo")) { Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language.toLowerCase()); } Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language); if (!extractRes(NavitTextTranslations.main_language, NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "/LC_MESSAGES/navit.mo")) { Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language); } // DEBUG - check if language file is on SDCARD - try { File debug_mo_src = new File("/sdcard/zanavi/debug/navit.mo"); File debug_mo_dest = new File( NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "/LC_MESSAGES/navit.mo"); //* File navit_debug_dir = new File("/sdcard/zanavi/debug/"); //* navit_debug_dir.mkdirs(); copyFile(debug_mo_src, debug_mo_dest); } catch (Exception e) { e.printStackTrace(); } // DEBUG - check if language file is on SDCARD - File navit_config_xml_file = new File(NAVIT_DATA_SHARE_DIR + "/navit.xml"); if ((!navit_config_xml_file.exists()) || (NAVIT_ALWAYS_UNPACK_XMLFILE)) { xmlconfig_unpack_file = true; Log.e("Navit", "navit.xml does not exist, unpacking in any case"); } my_display_density = "mdpi"; // ldpi display (120 dpi) NavitGraphics.Global_want_dpi = Navit.metrics.densityDpi; NavitGraphics.Global_want_dpi_other = Navit.metrics.densityDpi; if (Navit.metrics.densityDpi <= 120) { my_display_density = "ldpi"; if (xmlconfig_unpack_file) { if (!extractRes("navitldpi", NAVIT_DATA_SHARE_DIR + "/navit.xml")) { Log.e("Navit", "Failed to extract navit.xml for ldpi device(s)"); } } } // mdpi display (160 dpi) else if ((Navit.metrics.densityDpi > 120) && (Navit.metrics.densityDpi <= 160)) { my_display_density = "mdpi"; if (xmlconfig_unpack_file) { if (!extractRes("navitmdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml")) { Log.e("Navit", "Failed to extract navit.xml for mdpi device(s)"); } } } // hdpi display (240 dpi) else if ((Navit.metrics.densityDpi > 160) && (Navit.metrics.densityDpi < 320)) //else if (Navit.metrics.densityDpi == 240) { my_display_density = "hdpi"; if (xmlconfig_unpack_file) { if (!extractRes("navithdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml")) { Log.e("Navit", "Failed to extract navit.xml for hdpi device(s)"); } } } // xhdpi display (320 dpi) else if (Navit.metrics.densityDpi >= 320) { // set the map display DPI down. otherwise everything will be very small and unreadable // and performance will be very low if (p.PREF_shrink_on_high_dpi) { NavitGraphics.Global_want_dpi = NavitGraphics.Global_Scaled_DPI_normal; } NavitGraphics.Global_want_dpi_other = NavitGraphics.Global_Scaled_DPI_normal; Log.e("Navit", "found xhdpi device, this is not fully supported yet"); Log.e("Navit", "using hdpi values for compatibility"); my_display_density = "hdpi"; if (xmlconfig_unpack_file) { if (!extractRes("navithdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml")) { Log.e("Navit", "Failed to extract navit.xml for xhdpi device(s)"); } } } else { /* default, meaning we just dont know what display this is */ if (xmlconfig_unpack_file) { if (!extractRes("navitmdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml")) { Log.e("Navit", "Failed to extract navit.xml (default version)"); } } } // Debug.startMethodTracing("calc"); int have_dpi = Navit.metrics.densityDpi; System.out.println("Global_want_dpi[001]=" + NavitGraphics.Global_want_dpi + ":" + Navit.metrics.densityDpi + ":" + NavitGraphics.Global_dpi_factor + ":" + NavitGraphics.Global_dpi_factor_better); if (NavitGraphics.Global_want_dpi == have_dpi) { NavitGraphics.Global_dpi_factor = 1; NavitGraphics.preview_coord_factor = 1; } else // this was missing??????!!!!!!!!!??????!!!!!! { NavitGraphics.Global_dpi_factor = ((float) NavitGraphics.Global_want_dpi / (float) have_dpi); NavitGraphics.preview_coord_factor = ((float) have_dpi / (float) NavitGraphics.Global_want_dpi); } System.out.println("Global_want_dpi[002]=" + NavitGraphics.Global_dpi_factor + ":" + NavitGraphics.preview_coord_factor); // gggggggggggggggggggggggggg new !!!!!!!!!!!!!!!!!!!! // --> dont use!! NavitMain(this, langu, android.os.Build.VERSION.SDK_INT); Log.e("Navit", "android.os.Build.VERSION.SDK_INT=" + Integer.valueOf(android.os.Build.VERSION.SDK)); // -- report share dir back to C-code -- //Message msg2 = new Message(); //Bundle b2 = new Bundle(); //b2.putInt("Callback", 82); //b2.putString("s", NAVIT_DATA_DIR + "/share/"); //msg2.setData(b2); //N_NavitGraphics.callback_handler.sendMessage(msg2); // -- report share dir back to C-code -- // -- report data dir back to C-code -- //msg2 = new Message(); //b2 = new Bundle(); //b2.putInt("Callback", 84); //b2.putString("s", NAVIT_DATA_DIR + "/"); //msg2.setData(b2); //N_NavitGraphics.callback_handler.sendMessage(msg2); // -- report share dir back to C-code -- draw_osd_thread = new drawOSDThread(); draw_osd_thread.start(); cwthr = new CWorkerThread(); cwthr.start(); // --new-- cwthr.StartMain(this, langu, Integer.valueOf(android.os.Build.VERSION.SDK), "" + Navit.metrics.densityDpi, NAVIT_DATA_DIR, NAVIT_DATA_SHARE_DIR); // --old-- // NavitMain(this, langu, Integer.valueOf(android.os.Build.VERSION.SDK), my_display_density); // --old-- // NavitActivity(3); // CAUTION: don't use android.os.Build.VERSION.SDK_INT if <uses-sdk android:minSdkVersion="3" /> // You will get exception on all devices with Android 1.5 and lower // because Build.VERSION.SDK_INT is since SDK 4 (Donut 1.6) // (see: http://developer.android.com/guide/appendix/api-levels.html) // Platform Version API Level // ============================================= // Android 4.0.3 15 // Android 4.0, 4.0.1, 4.0.2 14 // Android 3.2 13 // Android 3.1 12 // Android 3.0 11 // Android 2.3.3 10 // Android 2.3.1 9 // Android 2.2 8 // Android 2.1 7 // Android 2.0.1 6 // Android 2.0 5 // Android 1.6 4 // Android 1.5 3 // Android 1.1 2 // Android 1.0 1 Navit.mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); //try //{ // Thread.sleep(2000); //} //catch (InterruptedException e) //{ //} //getPrefs(); //activatePrefs(); // unpack some localized Strings // a test now, later we will unpack all needed strings for java, here at this point!! //String x = NavitGraphics.getLocalizedString("Austria"); //Log.e("Navit", "x=" + x); Navit.show_mem_used(); /* * GpsStatus.Listener listener = new GpsStatus.Listener() * { * public void onGpsStatusChanged(int event) * { * //System.out.println("xxxxx"); * if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) * { * } * } * }; */ try { Intent sintent = new Intent(); sintent.setPackage("com.zoffcc.applications.zanavi_msg"); sintent.setAction("com.zoffcc.applications.zanavi_msg.ZanaviCloudService"); // ComponentName cname = startService(sintent); // Log.i("NavitPlugin", "start Service res=" + cname); // System.out.println("NavitPlugin:bind to Service"); boolean res_bind = bindService(sintent, serviceConnection, Context.BIND_AUTO_CREATE); // Log.i("NavitPlugin", "bind to Service res=" + res_bind); } catch (Exception e) { e.printStackTrace(); } // ------------- get all the flags for intro pages ------------- // ------------- get all the flags for intro pages ------------- // ------------- get all the flags for intro pages ------------- try { intro_flag_indexmissing = false; allow_use_index_search(); if (Navit_index_on_but_no_idx_files) { if (!NavitMapDownloader.download_active_start) { intro_flag_indexmissing = true; } } } catch (Exception e) { } try { intro_flag_nomaps = false; if (!have_maps_installed()) { if ((!NavitMapDownloader.download_active) && (!NavitMapDownloader.download_active_start)) { intro_flag_nomaps = true; } } } catch (Exception e) { } intro_flag_firststart = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(PREF_KEY_FIRST_START, true); if (intro_flag_firststart) { intro_flag_update = false; } if (EasyPermissions.hasPermissions(this, perms)) { // have permissions! intro_flag_permissions = false; } else { // ask for permissions intro_flag_permissions = true; } // ------------- get all the flags for intro pages ------------- // ------------- get all the flags for intro pages ------------- // ------------- get all the flags for intro pages ------------- // -------------- INTRO -------------- // -------------- INTRO -------------- // -------------- INTRO -------------- intro_show_count = 0; // // -------------- INTRO -------------- // // -------------- INTRO -------------- // // -------------- INTRO -------------- // if (Navit.METHOD_DEBUG) Navit.my_func_name(1); }
From source file:com.android.vending.billing.InAppBillingService.LACK.listAppsFragment.java
public void connectToLicensing() { mServiceConnL = new ServiceConnection() { public void onServiceConnected(ComponentName paramAnonymousComponentName, IBinder paramAnonymousIBinder) { System.out.println("Licensing service try to connect."); if (listAppsFragment.this.mServiceL == null) { listAppsFragment.this.mServiceL = ILicensingService.Stub.asInterface(paramAnonymousIBinder); }/*w w w . ja va2 s. c o m*/ try { listAppsFragment.this.mServiceL.checkLicense(new Random().nextLong(), listAppsFragment.getInstance().getPackageName(), new ILicenseResultListener.Stub() { public void verifyLicense(int paramAnonymous2Int, String paramAnonymous2String1, String paramAnonymous2String2) throws RemoteException { System.out.println(paramAnonymous2Int); listAppsFragment.this.responseCode = paramAnonymous2Int; listAppsFragment.removeDialogLP(11); switch (paramAnonymous2Int) { case 1: case 2: default: listAppsFragment.handler.post(new Runnable() { public void run() { listAppsFragment.this.showMessage(Utils.getText(2131165549), Utils.getText(2131165547)); } }); } for (;;) { System.out.println("" + paramAnonymous2String1); System.out.println(paramAnonymous2String2); listAppsFragment.this.cleanupService(); return; listAppsFragment.handler.post(new Runnable() { public void run() { listAppsFragment.this.showMessage(Utils.getText(2131165549), Utils.getText(2131165548)); } }); continue; if ((paramAnonymous2String1 != null) && (paramAnonymous2String2 != null) && (Utils.checkCoreJarPatch11()) && (Utils.checkCoreJarPatch12())) { listAppsFragment.handler.post(new Runnable() { public void run() { listAppsFragment.this.showMessage(Utils.getText(2131165549), Utils.getText(2131165550)); } }); } else { listAppsFragment.handler.post(new Runnable() { public void run() { listAppsFragment.this.showMessage(Utils.getText(2131165549), Utils.getText(2131165547)); } }); } } } }); return; } catch (RemoteException paramAnonymousComponentName) { paramAnonymousComponentName.printStackTrace(); } } public void onServiceDisconnected(ComponentName paramAnonymousComponentName) { System.out.println("Licensing service disconnected."); listAppsFragment.this.mServiceL = null; listAppsFragment.removeDialogLP(11); } }; if (this.mServiceL == null) { boolean bool1; label311: do { try { Intent localIntent = new Intent(new String( Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U="))); localIntent.setPackage("com.android.vending"); localIntent.putExtra("xexe", "lp"); boolean bool4 = false; bool1 = false; boolean bool3 = false; boolean bool2 = bool4; try { if (getPkgMng().queryIntentServices(localIntent, 0).isEmpty()) { continue; } bool2 = bool4; Iterator localIterator = getPkgMng().queryIntentServices(localIntent, 0).iterator(); bool1 = bool3; Object localObject; cleanupService(); } catch (Exception localException1) { try { for (;;) { if (!localIterator.hasNext()) { break label311; } localObject = (ResolveInfo) localIterator.next(); if ((((ResolveInfo) localObject).serviceInfo.packageName == null) || (!((ResolveInfo) localObject).serviceInfo.packageName .equals("com.android.vending"))) { break; } localObject = new ComponentName(((ResolveInfo) localObject).serviceInfo.packageName, ((ResolveInfo) localObject).serviceInfo.name); localIntent = new Intent(); bool2 = bool1; localIntent.setComponent((ComponentName) localObject); bool2 = bool1; localIntent.putExtra("xexe", "lp"); bool2 = bool1; handler.post(new Runnable() { public void run() { listAppsFragment.removeDialogLP(11); listAppsFragment.showDialogLP(11); listAppsFragment.progress2.setCancelable(true); listAppsFragment.progress2.setMessage(Utils.getText(2131165747)); } }); bool2 = bool1; bool1 = getInstance().bindService(localIntent, mServiceConnL, 1); } } catch (Exception localException2) { for (;;) { } } localException1 = localException1; bool1 = bool2; localException1.printStackTrace(); removeDialogLP(11); } removeDialogLP(11); return; } catch (SecurityException localSecurityException) { localSecurityException.printStackTrace(); cleanupService(); return; } catch (Base64DecoderException localBase64DecoderException) { localBase64DecoderException.printStackTrace(); cleanupService(); return; } } while (!bool1); } }
From source file:com.android.vending.billing.InAppBillingService.LACK.listAppsFragment.java
public void runId(int paramInt) { Object localObject2;/*from w w w . jav a 2 s. co m*/ boolean bool; switch (paramInt) { case 2131165211: case 2131165387: case 2131165388: default: case 2131165662: case 2131165705: case 2131165707: case 2131165709: case 2131165713: case 2131165711: case 2131165546: case 2131165315: case 2131165561: case 2131165321: case 2131165256: case 2131165263: case 2131165261: case 2131165285: case 2131165286: case 2131165272: case 2131165292: case 2131165287: case 2131165281: case 2131165266: case 2131165267: case 2131165318: case 2131165296: case 2131165323: case 2131165265: case 2131165271: case 2131165269: case 2131165293: case 2131165257: case 2131165366: case 2131165283: case 2131165258: case 2131165284: case 2131165298: case 2131165299: case 2131165297: case 2131165324: case 2131165279: case 2131165278: case 2131165277: case 2131165766: case 2131165769: case 2131165798: case 2131165799: case 2131165291: case 2131165316: case 2131165317: case 2131165367: case 2131165383: case 2131165282: case 2131165386: case 2131165384: case 2131165254: case 2131165389: case 2131165385: case 2131165624: case 2131165413: case 2131165243: case 2131165375: case 2131165753: case 2131165511: case 2131165787: for (;;) { try { if (!menu_open) { break label5209; } hideMenu(); return; } catch (Exception localException1) { Intent localIntent; localException1.printStackTrace(); return; } getConfig().edit().putBoolean("switch_auto_backup_apk", false).commit(); getConfig().edit().putBoolean("switch_auto_backup_apk_only_gp", false).commit(); getConfig().edit().putBoolean("switch_auto_integrate_update", false).commit(); getConfig().edit().putBoolean("switch_auto_move_to_sd", false).commit(); getConfig().edit().putBoolean("switch_auto_move_to_internal", false).commit(); getPkgMng().setComponentEnabledSetting(new ComponentName(getInstance(), LicensingService.class), 2, 1); getPkgMng().setComponentEnabledSetting(new ComponentName(getInstance(), MarketBillingService.class), 1, 1); getPkgMng().setComponentEnabledSetting(new ComponentName(getInstance(), InAppBillingService.class), 1, 1); getPkgMng().setComponentEnabledSetting(new ComponentName(getInstance(), InAppBillingFService.class), 2, 1); Utils.market_billing_services(true); Utils.market_licensing_services(true); localIntent = new Intent(getInstance(), inapp_widget.class); localIntent.setPackage(getInstance().getPackageName()); localIntent.setAction(inapp_widget.ACTION_WIDGET_RECEIVER_Updater); getInstance().sendBroadcast(localIntent); localIntent = new Intent(getInstance(), lvl_widget.class); localIntent.setPackage(getInstance().getPackageName()); localIntent.setAction(lvl_widget.ACTION_WIDGET_RECEIVER_Updater); getInstance().sendBroadcast(localIntent); runWithWait(new Runnable() { public void run() { PackageInfo localPackageInfo = Utils.getPkgInfo("com.android.vending", 0); File localFile; long l1; if (localPackageInfo != null) { localFile = new File( Utils.getPlaceForOdex(localPackageInfo.applicationInfo.sourceDir, false)); l1 = 0L; } try { long l2 = localFile.length(); l1 = l2; } catch (Exception localException2) { for (;;) { } } if ((l1 > 1048576L) || (l1 == 0L)) { return; } listAppsFragment.this.runToMain(new Runnable() { public void run() { listAppsFragment.showDialogLP(11); listAppsFragment.progress2.setCancelable(true); listAppsFragment.progress2.setMessage(Utils.getText(2131165747)); } }); try { new Utils("").cmdRoot(new String[] { listAppsFragment.dalvikruncommand + ".pinfo " + localPackageInfo.applicationInfo.sourceDir + " " + listAppsFragment.toolfilesdir + " " + String.valueOf(localPackageInfo.applicationInfo.uid) + " recovery" }); Utils.market_billing_services(true); Utils.market_licensing_services(true); Utils.kill("com.android.vending"); listAppsFragment.this.runToMain(new Runnable() { public void run() { listAppsFragment.menu_adapt.notifyDataSetChanged(); } }); return; } catch (Exception localException1) { localException1.printStackTrace(); return; } } }); continue; if (getConfig().getBoolean("switch_auto_backup_apk", false)) { getConfig().edit().putBoolean("switch_auto_backup_apk", false).commit(); } else { getConfig().edit().putBoolean("switch_auto_backup_apk", true).commit(); getConfig().edit().putBoolean("switch_auto_backup_apk_only_gp", false).commit(); continue; if (getConfig().getBoolean("switch_auto_backup_apk_only_gp", false)) { getConfig().edit().putBoolean("switch_auto_backup_apk_only_gp", false).commit(); } else { getConfig().edit().putBoolean("switch_auto_backup_apk_only_gp", true).commit(); getConfig().edit().putBoolean("switch_auto_backup_apk", false).commit(); continue; if (getConfig().getBoolean("switch_auto_integrate_update", false)) { getConfig().edit().putBoolean("switch_auto_integrate_update", false).commit(); } else { getConfig().edit().putBoolean("switch_auto_integrate_update", true).commit(); continue; if (getConfig().getBoolean("switch_auto_move_to_sd", false)) { getConfig().edit().putBoolean("switch_auto_move_to_sd", false).commit(); } else { getConfig().edit().putBoolean("switch_auto_move_to_sd", true).commit(); getConfig().edit().putBoolean("switch_auto_move_to_internal", false).commit(); continue; if (getConfig().getBoolean("switch_auto_move_to_internal", false)) { getConfig().edit().putBoolean("switch_auto_move_to_internal", false).commit(); } else { getConfig().edit().putBoolean("switch_auto_move_to_internal", true).commit(); getConfig().edit().putBoolean("switch_auto_move_to_sd", false).commit(); continue; mod_market_check(); continue; removeDialogLP(7); custompatchselector(); if ((adapt.getCount() > 0) && (adapt.getCount() <= 1)) { func = 1; removeDialogLP(15); customselect = (File) adapt.getItem(0); showDialogLP(15); } else { func = 1; showDialogLP(16); continue; removeDialogLP(7); new_method_lvl(); continue; contextlvl(); removeDialogLP(7); showDialogLP(7); continue; removeDialogLP(20); removeDialogLP(7); showDialogAll(20, contextselpatchlvl(true)); continue; removeDialogLP(21); getpermissions(); removeDialogLP(7); showDialogLP(21); continue; contextpermmenu(); showDialogLP(7); continue; removeDialogLP(22); getpermissions(); removeDialogLP(7); showDialogLP(22); continue; Object localObject1 = ""; try { String str1 = getPkgMng().getPackageInfo(pli.pkgName, 0).applicationInfo.sourceDir; localObject1 = str1; } catch (PackageManager.NameNotFoundException localNameNotFoundException1) { for (;;) { localNameNotFoundException1.printStackTrace(); } } catch (Exception localException5) { for (;;) { localException5.printStackTrace(); } showMessage(Utils.getText(2131165748), Utils.getText(2131165649)); } if ((Utils.checkCoreJarPatch20()) || ((pli.system) && (((String) localObject1).startsWith("/system/app")))) { removeDialogLP(25); getpermissions(); removeDialogLP(7); showDialogLP(25); } else { continue; runWithWait(new Runnable() { public void run() { listAppsFragment.removeDialogLP(10); listAppsFragment.this.getpackagesxml(); listAppsFragment.this.contextpermissions(); listAppsFragment.this.runToMain(new Runnable() { public void run() { listAppsFragment.removeDialogLP(7); listAppsFragment.showDialogLP(10); } }); } }); continue; removeDialogLP(17); contextads(); removeDialogLP(7); showDialogLP(7); continue; removeDialogLP(34); removeDialogLP(7); showDialogAll(34, contextsupport(false)); continue; removeDialogLP(17); removeDialogLP(7); showDialogAll(17, contextselpatchads(true)); continue; removeDialogLP(29); getLPActivity(); removeDialogLP(7); showDialogLP(29); continue; removeDialogLP(31); getComponents(); removeDialogLP(7); showDialogLP(31); continue; contextfix(); removeDialogLP(7); showDialogLP(7); continue; removeDialogLP(7); custompatchselector(); if (adapt.getCount() <= 1) { removeDialogLP(15); customselect = (File) adapt.getItem(0); bootadd(pli, "custom"); } else { func = 2; removeDialogLP(16); showDialogLP(16); continue; startActivity(new Intent(getContext(), LivepatchActivity.class)); continue; try { dexopt_app( getPkgMng().getPackageInfo(pli.pkgName, 0).applicationInfo.sourceDir, pli.pkgName, "" + getPkgMng().getPackageInfo(pli.pkgName, 0).applicationInfo.uid); } catch (Exception localException2) { localException2.printStackTrace(); showMessage(Utils.getText(2131165748), Utils.getText(2131165436)); } continue; try { disable_package(pli.pkgName, true); } catch (Exception localException3) { localException3.printStackTrace(); showMessage(Utils.getText(2131165748), Utils.getText(2131165436)); } continue; try { disable_package(pli.pkgName, false); } catch (Exception localException4) { localException4.printStackTrace(); showMessage(Utils.getText(2131165748), Utils.getText(2131165436)); } continue; context_backup_menu(); removeDialogLP(7); showDialogLP(7); continue; backup(pli); continue; context_restore_menu(); removeDialogLP(7); showDialogLP(7); continue; removeDialogLP(7); backupselector(); removeDialogLP(26); showDialogLP(26); continue; backup_data(); continue; restore_data(); continue; bootadd(pli, "custom"); continue; bootadd(pli, "lvl"); continue; bootadd(pli, "ads"); continue; odex(pli); continue; adapterSelectType = 2131165247; selected_apps(); continue; adapterSelectType = 2131165763; selected_apps(); continue; adapterSelectType = 2131165762; selected_apps(); continue; adapterSelectType = 2131165761; selected_apps(); continue; adapterSelectType = 2131165764; selected_apps(); continue; set_internet(false); continue; set_internet(true); continue; adapterSelectType = 2131165765; selected_apps(); continue; deodex(pli); continue; runextendetpatch(pli); continue; contextselpatch(); continue; contextcreateapk(); removeDialogLP(7); showDialogLP(7); continue; context_remove_saved_purchases(); removeDialogLP(7); showDialogLP(7); continue; removeDialogLP(19); removeDialogLP(7); showDialogAll(19, contextselpatchlvl(false)); continue; removeDialogLP(18); removeDialogLP(7); showDialogAll(18, contextselpatchads(false)); continue; removeDialogLP(7); if (!rebuldApk.equals("")) { Utils.showDialogYesNo(new File(rebuldApk).getName(), Utils.getText(2131165378), new DialogInterface.OnClickListener() { public void onClick( DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) { listAppsFragment.this .toolbar_cloneApplication(); } }, null, null); } else { Utils.showDialogYesNo(pli.name, Utils.getText(2131165378), new DialogInterface.OnClickListener() { public void onClick( DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) { listAppsFragment.this.cloneApplication(); } }, null, null); continue; removeDialogLP(35); removeDialogLP(7); showDialogAll(35, contextsupport(true)); continue; removeDialogLP(7); custompatchselector(); if (adapt.getCount() <= 1) { removeDialogLP(15); customselect = (File) adapt.getItem(0); showDialogLP(15); func = 0; } else { func = 0; removeDialogLP(15); removeDialogLP(16); showDialogLP(16); continue; removeDialogLP(10); getpackagesxml(); contextpermissions(); removeDialogLP(7); showDialogLP(10); continue; startActivity( new Intent(getContext(), BinderActivity.class)); continue; removeDialogLP(3); showDialogLP(3); continue; contextCorePatch(); continue; contextXposedPatch(); continue; if (getInstance().getPackageManager() .getComponentEnabledSetting( new ComponentName(getInstance(), LicensingService.class)) == 2) { getPkgMng().setComponentEnabledSetting( new ComponentName(getInstance(), LicensingService.class), 1, 1); showMessage(Utils.getText(2131165748), Utils.getText(2131165544)); } for (;;) { localObject2 = new Intent(getInstance(), lvl_widget.class); ((Intent) localObject2) .setPackage(getInstance().getPackageName()); ((Intent) localObject2).setAction( lvl_widget.ACTION_WIDGET_RECEIVER_Updater); getInstance().sendBroadcast((Intent) localObject2); break; getPkgMng().setComponentEnabledSetting( new ComponentName(getInstance(), LicensingService.class), 2, 1); Utils.market_licensing_services(true); } paramInt = 0; if (!Utils.isXposedEnabled()) { break label5220; } new ArrayList(); localObject2 = null; try { JSONObject localJSONObject = Utils .readXposedParamBoolean(); localObject2 = localJSONObject; } catch (JSONException localJSONException) { for (;;) { localJSONException.printStackTrace(); } showMessage(Utils.getText(2131165748), Utils.getText(2131165792)); } bool = false; if (localObject2 == null) { break label5210; } bool = ((JSONObject) localObject2).optBoolean("patch4", false); break label5210; } } } } } } } } } } } } for (;;) { if ((Utils.checkCoreJarPatch11()) && (Utils.checkCoreJarPatch12())) { if (paramInt != 0) { showDialogLP(11); progress2.setCancelable(true); progress2.setMessage(Utils.getText(2131165747)); runWithWait(new Runnable() { public void run() { PackageInfo localPackageInfo = Utils.getPkgInfo("com.android.vending", 0); File localFile2; File localFile1; long l2; if (localPackageInfo != null) { if (!new File(listAppsFragment.toolfilesdir + "/p.apk").exists()) { listAppsFragment.this.pinfocopy(); } localFile2 = new File( Utils.getPlaceForOdex(localPackageInfo.applicationInfo.sourceDir, false)); localFile1 = Utils.getFileDalvikCache(localPackageInfo.applicationInfo.sourceDir); l2 = 0L; } try { if (localFile2.exists()) { } for (l1 = localFile2.length(); (l1 > 1048576L) || (l1 == 0L); l1 = localFile1.length()) { Utils.kill("com.android.vending"); new Utils("").cmdRoot(new String[] { listAppsFragment.dalvikruncommand + ".pinfo " + localPackageInfo.applicationInfo.sourceDir + " " + listAppsFragment.toolfilesdir + " " + String.valueOf(localPackageInfo.applicationInfo.uid) + " proxy" }); listAppsFragment.getPkgMng().setComponentEnabledSetting(new ComponentName( listAppsFragment.getInstance(), MarketBillingService.class), 2, 1); listAppsFragment.getPkgMng().setComponentEnabledSetting(new ComponentName( listAppsFragment.getInstance(), InAppBillingService.class), 2, 1); listAppsFragment.getPkgMng().setComponentEnabledSetting(new ComponentName( listAppsFragment.getInstance(), MarketBillingService.class), 1, 1); listAppsFragment.getPkgMng().setComponentEnabledSetting(new ComponentName( listAppsFragment.getInstance(), InAppBillingService.class), 1, 1); Utils.market_billing_services(true); Utils.market_licensing_services(true); Utils.kill("com.android.vending"); listAppsFragment.getPkgMng().setComponentEnabledSetting(new ComponentName( listAppsFragment.getInstance(), InAppBillingFService.class), 2, 1); listAppsFragment.this.runToMain(new Runnable() { public void run() { listAppsFragment.menu_adapt.notifyDataSetChanged(); Intent localIntent = new Intent(listAppsFragment.getInstance(), proxyGP_widget.class); localIntent.setPackage(listAppsFragment.getInstance().getPackageName()); localIntent.setAction(proxyGP_widget.ACTION_WIDGET_RECEIVER_Updater); listAppsFragment.getInstance().sendBroadcast(localIntent); } }); return; } } catch (Exception localException3) { for (;;) { long l1 = l2; try { if (localFile1.exists()) { l1 = localFile1.length(); } } catch (Exception localException2) { localException2.printStackTrace(); l1 = l2; } } listAppsFragment.this.runToMain(new Runnable() { public void run() { listAppsFragment.showDialogLP(11); listAppsFragment.progress2.setCancelable(true); listAppsFragment.progress2.setMessage(Utils.getText(2131165747)); } }); try { new Utils("").cmdRoot(new String[] { listAppsFragment.dalvikruncommand + ".pinfo " + localPackageInfo.applicationInfo.sourceDir + " " + listAppsFragment.toolfilesdir + " " + String.valueOf(localPackageInfo.applicationInfo.uid) + " recovery" }); Utils.market_billing_services(true); Utils.market_licensing_services(true); Utils.kill("com.android.vending"); listAppsFragment.this.runToMain(new Runnable() { public void run() { listAppsFragment.menu_adapt.notifyDataSetChanged(); Intent localIntent = new Intent(listAppsFragment.getInstance(), proxyGP_widget.class); localIntent.setPackage(listAppsFragment.getInstance().getPackageName()); localIntent.setAction(proxyGP_widget.ACTION_WIDGET_RECEIVER_Updater); listAppsFragment.getInstance().sendBroadcast(localIntent); } }); return; } catch (Exception localException1) { localException1.printStackTrace(); } } } }); break; } break; } if (((!Utils.checkCoreJarPatch11()) || (!Utils.checkCoreJarPatch12())) && ((Utils.exists("/system/framework/core.jar.jex")) || (Utils.exists("/system/framework/core-libart.jar.jex")) || (Utils.exists("/system/framework/services.jar.jex")))) { showMessage(Utils.getText(2131165748), Utils.getText(2131165819)); break; } if ((Utils.isBootOatCache()) && (api >= 20)) { Utils.showDialogYesNo(Utils.getText(2131165748), Utils.getText(2131165808), new DialogInterface.OnClickListener() { public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) { listAppsFragment.this.runWithWait(new Runnable() { public void run() { if (((Utils.getFileDalvikCache("/system/framework/core.jar") != null) && (!Utils.getCurrentRuntimeValue().equals("ART"))) || ((Utils.isBootOatCache()) && (listAppsFragment.api >= 20))) { listAppsFragment.patchOnlyDalvikCore = true; listAppsFragment.install_market_to_system = true; listAppsFragment.this.corepatch("_patch1"); } } }); } }, null, null); break; } showMessage(Utils.getText(2131165748), Utils.getText(2131165793)); break; if ((getInstance().getPackageManager() .getComponentEnabledSetting(new ComponentName(getInstance(), MarketBillingService.class)) == 2) || (getInstance().getPackageManager().getComponentEnabledSetting( new ComponentName(getInstance(), InAppBillingService.class)) == 2)) { getPkgMng().setComponentEnabledSetting(new ComponentName(getInstance(), MarketBillingService.class), 1, 1); getPkgMng().setComponentEnabledSetting(new ComponentName(getInstance(), InAppBillingService.class), 1, 1); } for (;;) { localObject2 = new Intent(getInstance(), inapp_widget.class); ((Intent) localObject2).setPackage(getInstance().getPackageName()); ((Intent) localObject2).setAction(inapp_widget.ACTION_WIDGET_RECEIVER_Updater); getInstance().sendBroadcast((Intent) localObject2); break; getPkgMng().setComponentEnabledSetting(new ComponentName(getInstance(), MarketBillingService.class), 2, 1); getPkgMng().setComponentEnabledSetting(new ComponentName(getInstance(), InAppBillingService.class), 2, 1); if (getInstance().getPackageManager().getComponentEnabledSetting( new ComponentName(getInstance(), InAppBillingFService.class)) == 2) { Utils.market_billing_services(true); } } if (getInstance().getPackageManager().getComponentEnabledSetting( new ComponentName(getInstance(), InAppBillingFService.class)) == 2) { getPkgMng().setComponentEnabledSetting(new ComponentName(getInstance(), InAppBillingFService.class), 1, 1); } for (;;) { localObject2 = new Intent(getInstance(), inapp_widget.class); ((Intent) localObject2).setPackage(getInstance().getPackageName()); ((Intent) localObject2).setAction(inapp_widget.ACTION_WIDGET_RECEIVER_Updater); getInstance().sendBroadcast((Intent) localObject2); break; getPkgMng().setComponentEnabledSetting(new ComponentName(getInstance(), InAppBillingFService.class), 2, 1); Utils.market_billing_services(true); } if (!su) { break; } localObject2 = Utils.getPkgInfo("com.android.vending", 4); int i = 0; if ((localObject2 == null) || (((PackageInfo) localObject2).services == null) || (((PackageInfo) localObject2).services.length == 0)) { break; } paramInt = 0; int j; for (;;) { j = ((PackageInfo) localObject2).services.length; if (paramInt >= j) { break; } try { if (((localObject2.services[paramInt].name.endsWith("InAppBillingService")) || (localObject2.services[paramInt].name.endsWith("MarketBillingService"))) && (getPkgMng().getComponentEnabledSetting(new ComponentName("com.android.vending", localObject2.services[paramInt].name)) != 1)) { showDialogLP(11); progress2.setCancelable(true); progress2.setMessage(Utils.getText(2131165747)); Utils.market_billing_services(true); } if (!localObject2.services[paramInt].name.endsWith("InAppBillingService")) { j = i; if (!localObject2.services[paramInt].name.endsWith("MarketBillingService")) { } } else { j = i; if (getPkgMng().getComponentEnabledSetting(new ComponentName("com.android.vending", localObject2.services[paramInt].name)) == 1) { showDialogLP(11); progress2.setCancelable(true); progress2.setMessage(Utils.getText(2131165747)); Utils.market_billing_services(false); if (i == 0) { showMessage(Utils.getText(2131165748), Utils.getText(2131165543)); } j = 1; } } } catch (Exception localException6) { for (;;) { localException6.printStackTrace(); j = i; } } paramInt += 1; i = j; } if (!su) { break; } localObject2 = Utils.getPkgInfo("com.android.vending", 4); if ((localObject2 == null) || (((PackageInfo) localObject2).services == null) || (((PackageInfo) localObject2).services.length == 0)) { break; } paramInt = 0; for (;;) { i = ((PackageInfo) localObject2).services.length; if (paramInt >= i) { break; } try { if ((localObject2.services[paramInt].name.endsWith("LicensingService")) && (getPkgMng().getComponentEnabledSetting(new ComponentName("com.android.vending", localObject2.services[paramInt].name)) != 1)) { showDialogLP(11); progress2.setCancelable(true); progress2.setMessage(Utils.getText(2131165747)); Utils.market_licensing_services(true); } if ((localObject2.services[paramInt].name.endsWith("LicensingService")) && (getPkgMng().getComponentEnabledSetting(new ComponentName("com.android.vending", localObject2.services[paramInt].name)) == 1)) { showDialogLP(11); progress2.setCancelable(true); progress2.setMessage(Utils.getText(2131165747)); Utils.market_licensing_services(false); showMessage(Utils.getText(2131165748), Utils.getText(2131165545)); } } catch (Exception localException7) { for (;;) { localException7.printStackTrace(); } } paramInt += 1; } remove_all_saved_purchases(); break; proxyGP_install(); break; removeDialogLP(30); showDialogLP(30); break; localObject2 = new Intent("android.intent.action.VIEW", Uri.parse("https://play.google.com/store/apps/details?id=eu.chainfire.supersu")); ((Intent) localObject2).addFlags(1073741824); startActivity((Intent) localObject2); break; localObject2 = "none"; try { String str2 = getPkgMng().getPackageInfo("eu.chainfire.supersu", 0).applicationInfo.dataDir; localObject2 = str2; new Utils("supersu") .cmdRoot(new String[] { dalvikruncommand + ".reworkSuperSu " + (String) localObject2 }); } catch (Exception localException8) { for (;;) { localException8.printStackTrace(); } localObject2 = new Intent("android.intent.action.VIEW", Uri.parse("https://play.google.com/store/apps/details?id=stericson.busybox&feature")); ((Intent) localObject2).addFlags(1073741824); startActivity((Intent) localObject2); break; odex_all_system_app(); break; removefixes(); break; cleardalvik(); break; setDefInstall(); break; dialog_reboot(); break; setDefInstallAuto(); break; setDefInstallInternalMemory(); break; setDefInstallSDcard(); break; localObject2 = new FileApkListItem(getInstance(), new File(rebuldApk), false); removeDialogLP(7); toolbar_restore((FileApkListItem) localObject2, false); break; localObject2 = new FileApkListItem(getInstance(), new File(rebuldApk), false); removeDialogLP(7); toolbar_integrate_dalvik_code((FileApkListItem) localObject2, false); break; rebuldApk = this.current.full; contexttoolbarcreateframework(); removeDialogLP(7); break; rebuldApk = this.current.full; contexttoolbarcreateapk(); removeDialogLP(7); showDialogLP(7); break; localObject2 = new FileApkListItem(getInstance(), new File(rebuldApk), false); removeDialogLP(7); toolbar_uninstall((FileApkListItem) localObject2); break; removeDialogLP(7); toolbar_install_system(new FileApkListItem(getInstance(), new File(rebuldApk), false)); break; removeDialogLP(7); delete_file(); break; removeDialogLP(7); share_app(); break; if (!su) { break; } System.out.println("Disable Google services ads"); localObject2 = null; try { PackageInfo localPackageInfo1 = getPkgMng().getPackageInfo("com.google.android.gms", 4); localObject2 = localPackageInfo1; } catch (PackageManager.NameNotFoundException localNameNotFoundException2) { try { for (;;) { if ((localObject2.services[paramInt].name .startsWith("com.google.android.gms.ads.identifier.")) && (getPkgMng().getComponentEnabledSetting(new ComponentName( "com.google.android.gms", localObject2.services[paramInt].name)) != 2) && (!localObject2.services[paramInt].name .startsWith("com.google.android.gms.ads.social")) && (!localObject2.services[paramInt].name .startsWith("com.google.android.gms.ads.jams."))) { System.out.println( "Disable Google services ads:" + localObject2.services[paramInt].name); showDialogLP(11); progress2.setCancelable(true); progress2.setMessage(Utils.getText(2131165747)); new Utils("") .cmdRoot( new String[] { "pm disable 'com.google.android.gms/" + localObject2.services[paramInt].name + "'", "skipOut" }); } paramInt += 1; } localNameNotFoundException2 = localNameNotFoundException2; localNameNotFoundException2.printStackTrace(); } catch (Exception localException9) { for (;;) { localException9.printStackTrace(); } } } if ((localObject2 == null) || (((PackageInfo) localObject2).services == null) || (((PackageInfo) localObject2).services.length == 0)) { break; } paramInt = 0; i = ((PackageInfo) localObject2).services.length; if ((paramInt >= i) || (!su)) { break; } System.out.println("Enable Google services ads"); localObject2 = null; try { PackageInfo localPackageInfo2 = getPkgMng().getPackageInfo("com.google.android.gms", 4); localObject2 = localPackageInfo2; } catch (PackageManager.NameNotFoundException localNameNotFoundException3) { try { for (;;) { if ((localObject2.services[paramInt].name.startsWith("com.google.android.gms.ads")) && (getPkgMng() .getComponentEnabledSetting(new ComponentName("com.google.android.gms", localObject2.services[paramInt].name)) == 2)) { System.out.println( "Enable Google services ads:" + localObject2.services[paramInt].name); showDialogLP(11); progress2.setCancelable(true); progress2.setMessage(Utils.getText(2131165747)); new Utils("") .cmdRoot( new String[] { "pm enable 'com.google.android.gms/" + localObject2.services[paramInt].name + "'", "skipOut" }); } paramInt += 1; } localNameNotFoundException3 = localNameNotFoundException3; localNameNotFoundException3.printStackTrace(); } catch (Exception localException10) { for (;;) { localException10.printStackTrace(); } } } if ((localObject2 == null) || (((PackageInfo) localObject2).services == null) || (((PackageInfo) localObject2).services.length == 0)) { break; } paramInt = 0; i = ((PackageInfo) localObject2).services.length; if (paramInt >= i) { break; } removeDialogLP(7); toolbar_addfree_on(); break; removeDialogLP(7); toolbar_addfree_off(); break; removeDialogLP(7); toolbar_addfree_clear(); break; move_to_system_click(); break; localObject2 = new ArrayList(1); ((ArrayList) localObject2).add(pli); integrate_to_system((ArrayList) localObject2, true, false); } catch (PackageManager.NameNotFoundException localNameNotFoundException4) { for (;;) { } } label5209: return; label5210: if (!bool) { paramInt = 1; continue; label5220: paramInt = 1; } } }