List of usage examples for android.app Dialog setTitle
public void setTitle(@StringRes int titleId)
From source file:nf.frex.android.FrexActivity.java
private Dialog createColorsDialog() { Dialog dialog = new Dialog(this); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0)); dialog.setContentView(R.layout.colors_dialog); dialog.setTitle(getString(R.string.colors)); dialog.setCancelable(true);//w w w . j a v a 2 s.c o m dialog.setCanceledOnTouchOutside(true); return dialog; }
From source file:org.wso2.emm.agent.AuthenticationActivity.java
/** * Show the license text retrieved from the server. * * @param message Message text to be shown as the license. * @param title Title of the license./*from w w w . j av a 2 s .co m*/ */ private void showAgreement(final String message, String title) { AuthenticationActivity.this.runOnUiThread(new Runnable() { @Override public void run() { final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.custom_terms_popup); dialog.setTitle(Constants.EULA_TITLE); dialog.setCancelable(false); WebView webView = (WebView) dialog.findViewById(R.id.webview); webView.loadDataWithBaseURL(null, message, Constants.MIME_TYPE, Constants.ENCODING_METHOD, null); Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK); Button cancelButton = (Button) dialog.findViewById(R.id.dialogButtonCancel); dialogButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Preference.putBoolean(context, Constants.PreferenceFlag.IS_AGREED, true); dialog.dismiss(); //load the next intent based on ownership type checkManifestPermissions(); } }); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); CommonUtils.clearClientCredentials(context); cancelEntry(); } }); dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == Constants.DEFAILT_REPEAT_COUNT) { return true; } else if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == Constants.DEFAILT_REPEAT_COUNT) { return true; } return false; } }); dialog.show(); } }); }
From source file:eu.power_switch.gui.dialog.ConfigurationDialog.java
@NonNull @Override/*from w w w .java 2 s .co m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = new Dialog(getActivity()) { @Override public void onBackPressed() { if (modified) { // ask to really close new AlertDialog.Builder(getActivity()).setTitle(R.string.are_you_sure) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { getDialog().cancel(); } }).setNeutralButton(android.R.string.no, null) .setMessage(R.string.all_changes_will_be_lost).show(); } else { getDialog().cancel(); } } }; dialog.setTitle(getDialogTitle()); dialog.setCanceledOnTouchOutside(isCancelableOnTouchOutside()); dialog.getWindow().setSoftInputMode(getSoftInputMode()); dialog.show(); return dialog; }
From source file:info.staticfree.android.units.Units.java
@Override protected void onPrepareDialog(int id, Dialog dialog) { switch (id) { case DIALOG_UNIT_CATEGORY: { dialog.setTitle(mDialogUnitCategoryUnit); final String[] projection = { UsageEntry._ID, UsageEntry._UNIT, UsageEntry._FACTOR_FPRINT }; final Cursor c = managedQuery( UsageEntry.getEntriesMatchingFprint(UnitUsageDBHelper.getFingerprint(mDialogUnitCategoryUnit)), projection, null, null, UnitUsageDBHelper.USAGE_SORT); dialogUnitCategoryList.changeCursor(c); final ListView lv = ((AlertDialog) dialog).getListView(); lv.setSelectionFromTop(0, 0);//from ww w.j ava 2 s . c om } break; default: super.onPrepareDialog(id, dialog); } }
From source file:com.owncloud.android.ui.adapter.FileListListAdapter.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { View view = convertView;//www . j a va 2 s. c o m if (view == null) { LayoutInflater inflator = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflator.inflate(R.layout.list_item, null); } if (mFiles != null && mFiles.size() > position) { OCFile file = mFiles.get(position); TextView fileName = (TextView) view.findViewById(R.id.Filename); String name = file.getFileName(); if (dataSourceShareFile == null) dataSourceShareFile = new DbShareFile(mContext); Account account = AccountUtils.getCurrentOwnCloudAccount(mContext); String[] accountNames = account.name.split("@"); if (accountNames.length > 2) { accountName = accountNames[0] + "@" + accountNames[1]; url = accountNames[2]; } Map<String, String> fileSharers = dataSourceShareFile.getUsersWhoSharedFilesWithMe(accountName); TextView sharer = (TextView) view.findViewById(R.id.sharer); ImageView shareButton = (ImageView) view.findViewById(R.id.shareItem); fileName.setText(name); ImageView fileIcon = (ImageView) view.findViewById(R.id.imageView1); fileIcon.setImageResource(DisplayUtils.getResourceId(file.getMimetype())); ImageView localStateView = (ImageView) view.findViewById(R.id.imageView2); FileDownloaderBinder downloaderBinder = mTransferServiceGetter.getFileDownloaderBinder(); FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder(); if (fileSharers.size() != 0 && (!file.equals("Shared") && file.getRemotePath().contains("Shared"))) { if (fileSharers.containsKey(name)) { sharer.setText(fileSharers.get(name)); fileSharers.remove(name); } else { sharer.setText(" "); } } else { sharer.setText(" "); } if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) { localStateView.setImageResource(R.drawable.downloading_file_indicator); localStateView.setVisibility(View.VISIBLE); } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) { localStateView.setImageResource(R.drawable.uploading_file_indicator); localStateView.setVisibility(View.VISIBLE); } else if (file.isDown()) { localStateView.setImageResource(R.drawable.local_file_indicator); localStateView.setVisibility(View.VISIBLE); } else { localStateView.setVisibility(View.INVISIBLE); } TextView fileSizeV = (TextView) view.findViewById(R.id.file_size); TextView lastModV = (TextView) view.findViewById(R.id.last_mod); ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox); shareButton.setOnClickListener(new OnClickListener() { String shareStatusDisplay; int flagShare = 0; @Override public void onClick(View v) { final Dialog dialog = new Dialog(mContext); final OCFile fileToBeShared = (OCFile) getItem(position); final ArrayAdapter<String> shareWithFriends; final ArrayAdapter<String> shareAdapter; final String filePath; sharedWith = new ArrayList<String>(); dataSource = new DbFriends(mContext); dataSourceShareFile = new DbShareFile(mContext); dialog.setContentView(R.layout.share_file_with); dialog.setTitle("Share"); Account account = AccountUtils.getCurrentOwnCloudAccount(mContext); String[] accountNames = account.name.split("@"); if (accountNames.length > 2) { accountName = accountNames[0] + "@" + accountNames[1]; url = accountNames[2]; } final AutoCompleteTextView textView = (AutoCompleteTextView) dialog .findViewById(R.id.autocompleteshare); Button shareBtn = (Button) dialog.findViewById(R.id.ShareBtn); Button doneBtn = (Button) dialog.findViewById(R.id.ShareDoneBtn); final ListView listview = (ListView) dialog.findViewById(R.id.alreadySharedWithList); textView.setThreshold(2); final String itemType; filePath = "files" + String.valueOf(fileToBeShared.getRemotePath()); final String fileName = fileToBeShared.getFileName(); final String fileRemotePath = fileToBeShared.getRemotePath(); if (dataSourceShareFile == null) dataSourceShareFile = new DbShareFile(mContext); sharedWith = dataSourceShareFile.getUsersWithWhomIhaveSharedFile(fileName, fileRemotePath, accountName, String.valueOf(1)); shareAdapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1, sharedWith); listview.setAdapter(shareAdapter); final String itemSource; if (fileToBeShared.isDirectory()) { itemType = "folder"; int lastSlashInFolderPath = filePath.lastIndexOf('/'); itemSource = filePath.substring(0, lastSlashInFolderPath); } else { itemType = "file"; itemSource = filePath; } //Permissions disabled with friends app ArrayList<String> friendList = dataSource.getFriendList(accountName); dataSource.close(); shareWithFriends = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1, friendList); textView.setAdapter(shareWithFriends); textView.setFocusableInTouchMode(true); dialog.show(); textView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { } }); final Handler finishedHandler = new Handler() { @Override public void handleMessage(Message msg) { shareAdapter.notifyDataSetChanged(); Toast.makeText(mContext, shareStatusDisplay, Toast.LENGTH_SHORT).show(); } }; shareBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final String shareWith = textView.getText().toString(); if (shareWith.equals("")) { textView.setHint("Share With"); Toast.makeText(mContext, "Please enter the friends name with whom you want to share", Toast.LENGTH_SHORT).show(); } else if (sharedWith.contains(shareWith)) { textView.setHint("Share With"); Toast.makeText(mContext, "You have shared the file with that person", Toast.LENGTH_SHORT).show(); } else { textView.setText(""); Runnable runnable = new Runnable() { @Override public void run() { HttpPost post = new HttpPost( "http://" + url + "/owncloud/androidshare.php"); final ArrayList<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("itemType", itemType)); params.add(new BasicNameValuePair("itemSource", itemSource)); params.add(new BasicNameValuePair("shareType", shareType)); params.add(new BasicNameValuePair("shareWith", shareWith)); params.add(new BasicNameValuePair("permission", permissions)); params.add(new BasicNameValuePair("uidOwner", accountName)); HttpEntity entity; String shareSuccess = "false"; try { entity = new UrlEncodedFormEntity(params, "utf-8"); HttpClient client = new DefaultHttpClient(); post.setEntity(entity); HttpResponse response = client.execute(post); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { HttpEntity entityresponse = response.getEntity(); String jsonentity = EntityUtils.toString(entityresponse); JSONObject obj = new JSONObject(jsonentity); shareSuccess = obj.getString("SHARE_STATUS"); flagShare = 1; if (shareSuccess.equals("true")) { dataSourceShareFile.putNewShares(fileName, fileRemotePath, accountName, shareWith); sharedWith.add(shareWith); shareStatusDisplay = "File share succeeded"; } else if (shareSuccess.equals("INVALID_FILE")) { shareStatusDisplay = "File you are trying to share does not exist"; } else if (shareSuccess.equals("INVALID_SHARETYPE")) { shareStatusDisplay = "File Share type is invalid"; } else { shareStatusDisplay = "Share did not succeed. Please check your internet connection"; } finishedHandler.sendEmptyMessage(flagShare); } } catch (Exception e) { e.printStackTrace(); } } }; new Thread(runnable).start(); } if (flagShare == 1) { } } }); doneBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); //dataSourceShareFile.close(); } }); } }); //dataSourceShareFile.close(); if (!file.isDirectory()) { fileSizeV.setVisibility(View.VISIBLE); fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength())); lastModV.setVisibility(View.VISIBLE); lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp())); // this if-else is needed even thoe fav icon is visible by default // because android reuses views in listview if (!file.keepInSync()) { view.findViewById(R.id.imageView3).setVisibility(View.GONE); } else { view.findViewById(R.id.imageView3).setVisibility(View.VISIBLE); } ListView parentList = (ListView) parent; if (parentList.getChoiceMode() == ListView.CHOICE_MODE_NONE) { checkBoxV.setVisibility(View.GONE); } else { if (parentList.isItemChecked(position)) { checkBoxV.setImageResource(android.R.drawable.checkbox_on_background); } else { checkBoxV.setImageResource(android.R.drawable.checkbox_off_background); } checkBoxV.setVisibility(View.VISIBLE); } } else { fileSizeV.setVisibility(View.VISIBLE); fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength())); lastModV.setVisibility(View.VISIBLE); lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp())); checkBoxV.setVisibility(View.GONE); view.findViewById(R.id.imageView3).setVisibility(View.GONE); } } return view; }
From source file:org.connectbot.ConsoleFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.disconnect: { // disconnect or close the currently visible session final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final TerminalBridge bridge = terminalView.bridge; bridge.dispatchDisconnect(true); return true; }/*from w w w. j a v a 2 s. c o m*/ case R.id.copy: { // mark as copying and reset any previous bounds final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); copySource = terminalView.bridge; final SelectionArea area = copySource.getSelectionArea(); area.reset(); area.setBounds(copySource.buffer.getColumns(), copySource.buffer.getRows()); copySource.setSelectingForCopy(true); // Make sure we show the initial selection copySource.redraw(); Toast.makeText(getActivity(), getString(R.string.console_copy_start), Toast.LENGTH_LONG).show(); return true; } case R.id.paste: { // force insert of clipboard text into current console final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final TerminalBridge bridge = terminalView.bridge; // pull string from clipboard and generate all events to force down final String clip = clipboard.getText().toString(); bridge.injectString(clip); return true; } case R.id.port_forwards: { final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final TerminalBridge bridge = terminalView.bridge; final Intent intent = new Intent(getActivity(), PortForwardListActivity.class); intent.putExtra(Intent.EXTRA_TITLE, bridge.host.getId()); startActivityForResult(intent, REQUEST_EDIT); return true; } case R.id.url_scan: { final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final List<String> urls = terminalView.bridge.scanForURLs(); final Dialog urlDialog = new Dialog(getActivity()); urlDialog.setTitle(R.string.console_menu_urlscan); ListView urlListView = new ListView(getActivity()); final URLItemListener urlListener = new URLItemListener(getActivity()); urlListView.setOnItemClickListener(urlListener); urlListView .setAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, urls)); urlDialog.setContentView(urlListView); urlDialog.show(); return true; } case R.id.resize: { final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final View resizeView = inflater.inflate(R.layout.dia_resize, null, false); new AlertDialog.Builder(getActivity()).setView(resizeView) .setPositiveButton(R.string.button_resize, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { final int width, height; try { width = Integer.parseInt( ((EditText) resizeView.findViewById(R.id.width)).getText().toString()); height = Integer.parseInt( ((EditText) resizeView.findViewById(R.id.height)).getText().toString()); } catch (NumberFormatException nfe) { // TODO change this to a real dialog where we can // make the input boxes turn red to indicate an error. return; } terminalView.forceSize(width, height); } }).setNegativeButton(android.R.string.cancel, null).create().show(); return true; } default: return super.onOptionsItemSelected(item); } }
From source file:de.bogutzky.psychophysiocollector.app.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_add_bluetooth_device) { addBluetoothDevice();//from ww w. j av a2 s.co m return true; } if (id == R.id.action_connect) { disconnectMenuItem.setEnabled(true); connectMenuItem.setEnabled(false); addMenuItem.setEnabled(false); connectAllShimmerImus(); connectBioHarness(); } if (id == R.id.action_disconnect) { disconnectDevices(); } if (id == R.id.action_settings) { showSettings(); } if (id == R.id.action_start_streaming) { this.isFirstSelfReportRequest = true; startSession(); //showQuestionnaire(true); } if (id == R.id.action_stop_streaming) { this.isSessionStarted = false; this.stopTimestamp = System.currentTimeMillis(); stopAllStreamingOfAllShimmerImus(); stopStreamingBioHarness(); stopStreamingInternalSensorData(); if (intervalConfigured) { stopTimerThread(); } else { feedbackNotification(); showQuestionnaire(); } this.directoryName = null; this.startStreamMenuItem.setEnabled(true); this.stopStreamMenuItem.setEnabled(false); this.disconnectMenuItem.setEnabled(true); } if (id == R.id.action_info) { Dialog dialog = new Dialog(this); dialog.setTitle(getString(R.string.action_info)); dialog.setContentView(R.layout.info_popup); TextView infoSessionStatus = (TextView) dialog.findViewById(R.id.textViewInfoSessionStatus); if (isSessionStarted) { infoSessionStatus.setText(getString(R.string.info_started)); } if (shimmerImuService != null) { int shimmerImuCount = shimmerImuService.shimmerImuMap.values().size(); TextView infoShimmerImoConnectionStatus = (TextView) dialog .findViewById(R.id.textViewInfoShimmerImoConnectionStatus); infoShimmerImoConnectionStatus.setText(getString(R.string.info_number_connected, shimmerImuCount)); } if (bioHarnessService != null) { if (bioHarnessService.isBioHarnessConnected()) { TextView infoBioHarnessConnectionStatus = (TextView) dialog .findViewById(R.id.textViewInfoBioHarnessConnectionStatus); infoBioHarnessConnectionStatus.setText(getString(R.string.info_number_connected, 1)); } } infoGpsConnectionStatus = (TextView) dialog.findViewById(R.id.textViewInfoGpsConnectionStatus); if (gpsStatusText == null) { gpsStatusText = getString(R.string.info_not_connected); } infoGpsConnectionStatus.setText(gpsStatusText); TextView infoVersionName = (TextView) dialog.findViewById(R.id.textViewInfoVersionName); try { PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0); infoVersionName.setText(packageInfo.versionName); } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Could not read package info", e); infoVersionName.setText(R.string.info_could_not_read); } dialog.show(); } return super.onOptionsItemSelected(item); }
From source file:com.example.pyrkesa.frag.User_Fragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setRetainInstance(true);//from www . ja va2 s.c om rootView = inflater.inflate(R.layout.user_fragment, container, false); userList = (ListView) rootView.findViewById(R.id.lt_user); // custom dialog final Dialog dialog = new Dialog(rootView.getContext()); d = dialog; userIcons = getResources().obtainTypedArray(R.array.userIcons);// load icons from userIcons1 = getResources().obtainTypedArray(R.array.userIcons1); userItems = new ArrayList<UserItem>(); adapter = new UserAdapter(getActivity(), userItems, getActivity()); userList.setAdapter(adapter); ImageButton addButton = (ImageButton) rootView.findViewById(R.id.add); addButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ModelFactory model = (ModelFactory) ModelFactory.getContext(); if (model.user.type == 1) { dialog.setContentView(R.layout.adduser_dialog); dialog.setTitle("Ajouter un utilisateur "); dialogTypes = getResources().getStringArray(R.array.user_type_dialog); // load Button dialogButtonOk = (Button) dialog.findViewById(R.id.button_ok); Button dialogButtonCancel = (Button) dialog.findViewById(R.id.button_cancel); final EditText Newlogin = (EditText) dialog.findViewById(R.id.dialogLogin); final EditText NewPW = (EditText) dialog.findViewById(R.id.dialogPW); final Spinner NewType = (Spinner) dialog.findViewById(R.id.dialogType); ArrayList<String> types = new ArrayList<String>(); for (String t : dialogTypes) { types.add(t); } NewType.setAdapter(new ArrayAdapter<String>(rootView.getContext(), android.R.layout.simple_spinner_dropdown_item, types)); dialogButtonCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialogButtonOk.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ArrayList<String> temp = new ArrayList<String>(); String login = Newlogin.getText().toString(); String password = NewPW.getText().toString(); String type = NewType.getSelectedItem().toString(); if (login.equalsIgnoreCase("") && password.equalsIgnoreCase("") && type != null) { new AlertDialog.Builder(v.getContext()).setTitle("Attention") .setMessage("Veuillez remplir toutes les informations.").show(); } else { temp.add(login); temp.add(password); if (type.equalsIgnoreCase("admin")) { temp.add("1"); } else if (type.equalsIgnoreCase("utilisateur")) { temp.add("0"); } else { temp.add("0"); } } new addUser().execute(temp); } }); dialog.show(); } else { new AlertDialog.Builder(v.getContext()).setTitle("Attention") .setMessage("Opration interdite : Droits d'administration requis.").show(); } } }); // adding user items new LoadAllUser().execute(); return rootView; }
From source file:com.pimp.companionforband.activities.main.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); sContext = getApplicationContext();/* w ww. j a va 2 s . c o m*/ sActivity = this; sharedPreferences = getApplicationContext().getSharedPreferences("MyPrefs", 0); editor = sharedPreferences.edit(); bandSensorData = new BandSensorData(); mDestinationUri = Uri.fromFile(new File(getCacheDir(), SAMPLE_CROPPED_IMAGE_NAME)); SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; if (!checkCameraPermission(true)) requestCameraPermission(true); if (!checkCameraPermission(false)) requestCameraPermission(false); FiveStarsDialog fiveStarsDialog = new FiveStarsDialog(this, "pimplay69@gmail.com"); fiveStarsDialog.setTitle(getString(R.string.rate_dialog_title)) .setRateText(getString(R.string.rate_dialog_text)).setForceMode(false).setUpperBound(4) .setNegativeReviewListener(this).showAfter(5); AnalyticsApplication application = (AnalyticsApplication) getApplication(); mTracker = application.getDefaultTracker(); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.container); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOffscreenPageLimit(2); mViewPager.setPageTransformer(true, new ZoomOutPageTransformer()); mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { String name; switch (position) { case 0: name = "THEME"; break; case 1: name = "SENSORS"; break; case 2: name = "EXTRAS"; break; default: name = "CfB"; } mTracker.setScreenName("Image~" + name); mTracker.send(new HitBuilders.ScreenViewBuilder().build()); logSwitch = (Switch) findViewById(R.id.log_switch); backgroundLogSwitch = (Switch) findViewById(R.id.backlog_switch); logStatus = (TextView) findViewById(R.id.logStatus); backgroundLogStatus = (TextView) findViewById(R.id.backlogStatus); } @Override public void onPageScrollStateChanged(int state) { } }); TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(mViewPager); Drawable headerBackground = null; String encoded = sharedPreferences.getString("me_tile_image", "null"); if (!encoded.equals("null")) { byte[] imageAsBytes = Base64.decode(encoded.getBytes(), Base64.DEFAULT); headerBackground = new BitmapDrawable( BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length)); } AccountHeader accountHeader = new AccountHeaderBuilder().withActivity(this).withCompactStyle(true) .withHeaderBackground((headerBackground == null) ? getResources().getDrawable(R.drawable.pipboy) : headerBackground) .addProfiles(new ProfileDrawerItem() .withName(sharedPreferences.getString("device_name", "Companion For Band")) .withEmail(sharedPreferences.getString("device_mac", "pimplay69@gmail.com")) .withIcon(getResources().getDrawable(R.drawable.band))) .build(); result = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withActionBarDrawerToggleAnimated(true) .withAccountHeader(accountHeader) .addDrawerItems( new PrimaryDrawerItem().withName(getString(R.string.drawer_cloud)) .withIcon(GoogleMaterial.Icon.gmd_cloud).withIdentifier(1), new DividerDrawerItem(), new PrimaryDrawerItem().withName(getString(R.string.rate)) .withIcon(GoogleMaterial.Icon.gmd_rate_review).withIdentifier(2), new PrimaryDrawerItem().withName(getString(R.string.feedback)) .withIcon(GoogleMaterial.Icon.gmd_feedback).withIdentifier(3), new DividerDrawerItem(), new PrimaryDrawerItem().withName(getString(R.string.share)) .withIcon(GoogleMaterial.Icon.gmd_share).withIdentifier(4), new PrimaryDrawerItem().withName(getString(R.string.other)) .withIcon(GoogleMaterial.Icon.gmd_apps).withIdentifier(5), new DividerDrawerItem(), new PrimaryDrawerItem().withName(getString(R.string.report)) .withIcon(GoogleMaterial.Icon.gmd_bug_report).withIdentifier(6), new PrimaryDrawerItem().withName(getString(R.string.translate)) .withIcon(GoogleMaterial.Icon.gmd_translate).withIdentifier(9), new DividerDrawerItem(), new PrimaryDrawerItem().withName(getString(R.string.support)) .withIcon(GoogleMaterial.Icon.gmd_attach_money).withIdentifier(7), new PrimaryDrawerItem().withName(getString(R.string.aboutLib)) .withIcon(GoogleMaterial.Icon.gmd_info).withIdentifier(8)) .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { boolean flag; if (drawerItem != null) { flag = true; switch ((int) drawerItem.getIdentifier()) { case 1: mTracker.send(new HitBuilders.EventBuilder().setCategory("Action") .setAction("Cloud").build()); if (!sharedPreferences.getString("access_token", "hi").equals("hi")) startActivity(new Intent(getApplicationContext(), CloudActivity.class)); else startActivity(new Intent(getApplicationContext(), WebviewActivity.class)); break; case 2: mTracker.send(new HitBuilders.EventBuilder().setCategory("Action") .setAction("Rate and Review").build()); String MARKET_URL = "https://play.google.com/store/apps/details?id="; String PlayStoreListing = getPackageName(); Intent rate = new Intent(Intent.ACTION_VIEW, Uri.parse(MARKET_URL + PlayStoreListing)); startActivity(rate); break; case 3: mTracker.send(new HitBuilders.EventBuilder().setCategory("Action") .setAction("Feedback").build()); final StringBuilder emailBuilder = new StringBuilder(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:pimplay69@gmail.com")); intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.app_name)); emailBuilder.append("\n \n \nOS Version: ").append(System.getProperty("os.version")) .append("(").append(Build.VERSION.INCREMENTAL).append(")"); emailBuilder.append("\nOS API Level: ").append(Build.VERSION.SDK_INT); emailBuilder.append("\nDevice: ").append(Build.DEVICE); emailBuilder.append("\nManufacturer: ").append(Build.MANUFACTURER); emailBuilder.append("\nModel (and Product): ").append(Build.MODEL).append(" (") .append(Build.PRODUCT).append(")"); PackageInfo appInfo = null; try { appInfo = getPackageManager().getPackageInfo(getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } assert appInfo != null; emailBuilder.append("\nApp Version Name: ").append(appInfo.versionName); emailBuilder.append("\nApp Version Code: ").append(appInfo.versionCode); intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString()); startActivity(Intent.createChooser(intent, "Send via")); break; case 4: mTracker.send(new HitBuilders.EventBuilder().setCategory("Action") .setAction("Share").build()); Intent i = new AppInviteInvitation.IntentBuilder( getString(R.string.invitation_title)) .setMessage(getString(R.string.invitation_message)) .setCallToActionText(getString(R.string.invitation_cta)).build(); startActivityForResult(i, REQUEST_INVITE); break; case 5: mTracker.send(new HitBuilders.EventBuilder().setCategory("Action") .setAction("Other Apps").build()); String PlayStoreDevAccount = "https://play.google.com/store/apps/developer?id=P.I.M.P."; Intent devPlay = new Intent(Intent.ACTION_VIEW, Uri.parse(PlayStoreDevAccount)); startActivity(devPlay); break; case 6: mTracker.send(new HitBuilders.EventBuilder().setCategory("Action") .setAction("Report Bugs").build()); startActivity(new Intent(MainActivity.this, GittyActivity.class)); break; case 7: mTracker.send(new HitBuilders.EventBuilder().setCategory("Action") .setAction("Donate").build()); String base64EncodedPublicKey = getString(R.string.base64); mHelper = new IabHelper(getApplicationContext(), base64EncodedPublicKey); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { if (!result.isSuccess()) { Toast.makeText(MainActivity.this, "Problem setting up In-app Billing: " + result, Toast.LENGTH_LONG).show(); } } }); final Dialog dialog = new Dialog(MainActivity.this); dialog.setContentView(R.layout.dialog_donate); dialog.setTitle("Donate"); String[] title = { "Coke", "Coffee", "Burger", "Pizza", "Meal" }; String[] price = { "Rs. 10.00", "Rs. 50.00", "Rs. 100.00", "Rs. 500.00", "Rs. 1,000.00" }; ListView listView = (ListView) dialog.findViewById(R.id.list); listView.setAdapter(new DonateListAdapter(MainActivity.this, title, price)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: mHelper.launchPurchaseFlow(MainActivity.this, SKU_COKE, 1, mPurchaseFinishedListener, "payload"); break; case 1: mHelper.launchPurchaseFlow(MainActivity.this, SKU_COFFEE, 1, mPurchaseFinishedListener, "payload"); break; case 2: mHelper.launchPurchaseFlow(MainActivity.this, SKU_BURGER, 1, mPurchaseFinishedListener, "payload"); break; case 3: mHelper.launchPurchaseFlow(MainActivity.this, SKU_PIZZA, 1, mPurchaseFinishedListener, "payload"); break; case 4: mHelper.launchPurchaseFlow(MainActivity.this, SKU_MEAL, 1, mPurchaseFinishedListener, "payload"); break; } } }); dialog.show(); break; case 8: mTracker.send(new HitBuilders.EventBuilder().setCategory("Action") .setAction("About").build()); new LibsBuilder().withLicenseShown(true).withVersionShown(true) .withActivityStyle(Libs.ActivityStyle.DARK).withAboutVersionShown(true) .withActivityTitle(getString(R.string.app_name)).withAboutIconShown(true) .withListener(libsListener).start(MainActivity.this); break; case 9: mTracker.send(new HitBuilders.EventBuilder().setCategory("Action") .setAction("Translate").build()); Intent translate = new Intent(Intent.ACTION_VIEW, Uri.parse("https://poeditor.com/join/project/AZQxDV2440")); startActivity(translate); break; default: break; } } else { flag = false; } return flag; } }).withSavedInstance(savedInstanceState).build(); AppUpdater appUpdater = new AppUpdater(this); appUpdater.start(); final DirectoryChooserConfig config = DirectoryChooserConfig.builder() .allowNewDirectoryNameModification(true).newDirectoryName("CfBCamera") .initialDirectory( sharedPreferences.getString("pic_location", "/storage/emulated/0/CompanionForBand/Camera")) .build(); mDialog = DirectoryChooserFragment.newInstance(config); new BandUtils().execute(); CustomActivityOnCrash.install(this); }
From source file:eu.power_switch.gui.dialog.ConfigurationDialogTabbed.java
@NonNull @Override/* ww w. j a v a 2s . c om*/ public Dialog onCreateDialog(Bundle savedInstanceState) { // ask to really close Dialog dialog = new Dialog(getActivity()) { @Override public void onBackPressed() { if (modified) { // ask to really close new AlertDialog.Builder(getActivity()).setTitle(R.string.are_you_sure) .setPositiveButton(android.R.string.yes, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { getDialog().cancel(); } }).setNeutralButton(android.R.string.no, null) .setMessage(R.string.all_changes_will_be_lost).show(); } else { getDialog().cancel(); } } }; dialog.setTitle(getDialogTitle()); dialog.setCanceledOnTouchOutside(isCancelableOnTouchOutside()); dialog.getWindow().setSoftInputMode(getSoftInputMode()); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; dialog.show(); dialog.getWindow().setAttributes(lp); dialog.show(); return dialog; }