List of usage examples for android.os Build MODEL
String MODEL
To view the source code for android.os Build MODEL.
Click Source Link
From source file:com.irccloud.android.NetworkConnection.java
@SuppressWarnings("deprecation") public NetworkConnection() { String version;//from w w w .ja v a 2s .c o m String network_type = null; try { version = "/" + IRCCloudApplication.getInstance().getPackageManager().getPackageInfo( IRCCloudApplication.getInstance().getApplicationContext().getPackageName(), 0).versionName; } catch (Exception e) { version = ""; } try { ConnectivityManager cm = (ConnectivityManager) IRCCloudApplication.getInstance() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni != null) network_type = ni.getTypeName(); } catch (Exception e) { } try { config = new JSONObject(PreferenceManager .getDefaultSharedPreferences(IRCCloudApplication.getInstance().getApplicationContext()) .getString("config", "{}")); } catch (JSONException e) { e.printStackTrace(); config = new JSONObject(); } useragent = "IRCCloud" + version + " (" + android.os.Build.MODEL + "; " + Locale.getDefault().getCountry().toLowerCase() + "; " + "Android " + android.os.Build.VERSION.RELEASE; WindowManager wm = (WindowManager) IRCCloudApplication.getInstance() .getSystemService(Context.WINDOW_SERVICE); useragent += "; " + wm.getDefaultDisplay().getWidth() + "x" + wm.getDefaultDisplay().getHeight(); if (network_type != null) useragent += "; " + network_type; useragent += ")"; WifiManager wfm = (WifiManager) IRCCloudApplication.getInstance().getApplicationContext() .getSystemService(Context.WIFI_SERVICE); wifiLock = wfm.createWifiLock(TAG); kms = new X509ExtendedKeyManager[1]; kms[0] = new X509ExtendedKeyManager() { @Override public String chooseClientAlias(String[] keyTypes, Principal[] issuers, Socket socket) { return SSLAuthAlias; } @Override public String chooseServerAlias(String keyType, Principal[] issuers, Socket socket) { throw new UnsupportedOperationException(); } @Override public X509Certificate[] getCertificateChain(String alias) { return SSLAuthCertificateChain; } @Override public String[] getClientAliases(String keyType, Principal[] issuers) { throw new UnsupportedOperationException(); } @Override public String[] getServerAliases(String keyType, Principal[] issuers) { throw new UnsupportedOperationException(); } @Override public PrivateKey getPrivateKey(String alias) { return SSLAuthKey; } }; tms = new TrustManager[1]; tms[0] = new X509TrustManager() { @Override public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { throw new CertificateException("Not implemented"); } @Override public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { try { TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("X509"); trustManagerFactory.init((KeyStore) null); for (TrustManager trustManager : trustManagerFactory.getTrustManagers()) { if (trustManager instanceof X509TrustManager) { X509TrustManager x509TrustManager = (X509TrustManager) trustManager; x509TrustManager.checkServerTrusted(chain, authType); } } } catch (KeyStoreException e) { throw new CertificateException(e); } catch (NoSuchAlgorithmException e) { throw new CertificateException(e); } if (BuildConfig.SSL_FPS != null && BuildConfig.SSL_FPS.length > 0) { try { MessageDigest md = MessageDigest.getInstance("SHA-1"); byte[] sha1 = md.digest(chain[0].getEncoded()); // http://stackoverflow.com/questions/9655181/convert-from-byte-array-to-hex-string-in-java final char[] hexArray = "0123456789ABCDEF".toCharArray(); char[] hexChars = new char[sha1.length * 2]; for (int j = 0; j < sha1.length; j++) { int v = sha1[j] & 0xFF; hexChars[j * 2] = hexArray[v >>> 4]; hexChars[j * 2 + 1] = hexArray[v & 0x0F]; } String hexCharsStr = new String(hexChars); boolean matched = false; for (String fp : BuildConfig.SSL_FPS) { if (fp.equals(hexCharsStr)) { matched = true; break; } } if (!matched) throw new CertificateException("Incorrect CN in cert chain"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } } } @Override public X509Certificate[] getAcceptedIssuers() { return null; } }; WebSocketClient.setTrustManagers(tms); }
From source file:net.heroicefforts.viable.android.rep.jira.JIRARepository.java
public int postIssueComment(Issue issue, Comment comment) throws ServiceException { try {/* ww w . j a v a2s.com*/ HttpPost post = new HttpPost(rootURL + "/issue/" + issue.getIssueId() + "/comments.json"); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(12); nameValuePairs.add(new BasicNameValuePair("app_name", issue.getAppName())); nameValuePairs.add(new BasicNameValuePair("body", comment.getBody())); if (issue.getStacktrace() != null) { nameValuePairs.add(new BasicNameValuePair("phone_model", Build.MODEL)); nameValuePairs.add(new BasicNameValuePair("phone_device", Build.DEVICE)); nameValuePairs.add(new BasicNameValuePair("phone_version", String.valueOf(Build.VERSION.SDK_INT))); } if (Config.LOGD) Log.d(TAG, "post params: " + nameValuePairs.toString()); post.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP Post Request HttpResponse response = execute(post); int responseCode = response.getStatusLine().getStatusCode(); if (HttpStatus.SC_OK == responseCode || HttpStatus.SC_CREATED == responseCode) { JSONObject obj = readJSON(response); if (Config.LOGV) Log.v(TAG, "postIssueComment response: \n" + obj.toString(4)); //TODO pull dates from response Comment newComment = new Comment(obj); comment.copy(newComment); } else throw new ServiceException(MSG_REMOTE_ERROR + responseCode); if (Config.LOGD) Log.d(TAG, "postIssueComment code " + responseCode); return responseCode; } catch (UnsupportedEncodingException e) { throw new ServiceException("Encoding error occurred parsing JIRA response", e); } catch (IOException e) { throw new ServiceException(MSG_CONNECT_ERROR, e); } catch (JSONException e) { throw new ServiceException(MSG_PARSE_ERROR, e); } }
From source file:org.mariotaku.twidere.activity.support.HomeActivity.java
@Override protected void onStart() { super.onStart(); mMultiSelectHandler.dispatchOnStart(); sendBroadcast(new Intent(BROADCAST_HOME_ACTIVITY_ONSTART)); final ContentResolver resolver = getContentResolver(); resolver.registerContentObserver(Accounts.CONTENT_URI, true, mAccountChangeObserver); final Bus bus = TwidereApplication.getInstance(this).getMessageBus(); assert bus != null; bus.register(this); // spice// w w w .ja v a 2s .c om SpiceProfilingUtil.profile(this, SpiceProfilingUtil.FILE_NAME_APP, "App Launch" + "," + Build.MODEL + "," + "mediaPreview=" + mPreferences.getBoolean(KEY_MEDIA_PREVIEW, false)); SpiceProfilingUtil.profile(this, SpiceProfilingUtil.FILE_NAME_ONLAUNCH, "App Launch" + "," + NetworkStateUtil.getConnectedType(this) + "," + Build.MODEL); //end mReadStateManager.registerOnSharedPreferenceChangeListener(mReadStateChangeListener); updateUnreadCount(); }
From source file:at.aec.solutions.checkmkagent.AgentService.java
private void writeDMIDecode(PrintWriter _out) { _out.write("<<<dmi_sysinfo>>>" + NEWLINE); _out.write("System Information" + NEWLINE); _out.write(" Manufacturer: " + Build.MANUFACTURER + " (" + Build.BRAND + ")" + NEWLINE); _out.write(" Product Name: " + Build.MODEL + NEWLINE); _out.write(" Version: " + Build.VERSION.RELEASE + NEWLINE); _out.write(" Serial Number: " + Build.DISPLAY + NEWLINE); TelephonyManager tManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); String uuid = tManager.getDeviceId(); _out.write(" UUID: " + uuid + NEWLINE); _out.write(" Radio Version: " + Build.getRadioVersion() + NEWLINE); _out.write(" Wake-up Type: Power Switch" + NEWLINE); _out.write(" SKU Number: Not Specified" + NEWLINE); _out.write(" Family: Not Specified" + NEWLINE); }
From source file:nl.nikhef.eduroam.WiFiEduroam.java
private void postData(String username, String password, String csr) throws RuntimeException { // Create a new HttpClient and Post Header HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(CONF_HTTP_URL); String android_id = Secure.getString(getBaseContext().getContentResolver(), Secure.ANDROID_ID); try {/*from ww w .j a v a 2 s .c om*/ // Add the post data List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("username", username)); nameValuePairs.add(new BasicNameValuePair("password", password)); nameValuePairs.add(new BasicNameValuePair("csr", csr)); nameValuePairs.add(new BasicNameValuePair("device_id", android_id)); nameValuePairs.add(new BasicNameValuePair("device_serial", android.os.Build.SERIAL)); nameValuePairs.add(new BasicNameValuePair("device_description", android.os.Build.MANUFACTURER + " " + android.os.Build.MODEL + " / " + android.os.Build.PRODUCT)); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP POST request synchronously HttpResponse response = httpclient.execute(httppost); if (!response.getStatusLine().toString().endsWith("200 OK")) { updateStatus("HTTP Error: " + response.getStatusLine()); } // Convert input to JSON object BufferedReader reader = new BufferedReader( new InputStreamReader(response.getEntity().getContent(), "UTF-8")); StringBuilder builder = new StringBuilder(); for (String line = null; (line = reader.readLine()) != null;) { builder.append(line).append("\n"); } String json = builder.toString(); JSONObject obj = new JSONObject(json); if (!obj.getString("status").equals("ok")) { updateStatus("JSON Status Error: " + obj.getString("error")); throw new RuntimeException(obj.getString("error")); } // Grab the information certificate = obj.getString("certificate"); ca = obj.getString("ca"); ca_name = obj.getString("ca_name"); realm = obj.getString("realm"); subject_match = obj.getString("subject_match"); ssid = obj.getString("ssid"); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (UnknownHostException e) { e.printStackTrace(); throw new RuntimeException("Please check your connection!"); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { throw new RuntimeException("JSON: " + e.getMessage()); } }
From source file:org.alfresco.mobile.android.application.managers.ActionUtils.java
public static boolean actionSendFeedbackEmail(Fragment fr) { try {// w w w. j a v a2s . c o m ShareCompat.IntentBuilder iBuilder = ShareCompat.IntentBuilder.from(fr.getActivity()); Context context = fr.getContext(); // Email iBuilder.addEmailTo(context.getResources() .getStringArray(org.alfresco.mobile.android.foundation.R.array.bugreport_email)); // Prepare Subject String versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; int versionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; String subject = "Alfresco Android Mobile Feedback"; iBuilder.setSubject(subject); // Content DisplayMetrics dm = context.getResources().getDisplayMetrics(); String densityBucket = getDensityString(dm); Map<String, String> info = new LinkedHashMap<>(); info.put("Version", versionName); info.put("Version code", Integer.toString(versionCode)); info.put("Make", Build.MANUFACTURER); info.put("Model", Build.MODEL); info.put("Resolution", dm.heightPixels + "x" + dm.widthPixels); info.put("Density", dm.densityDpi + "dpi (" + densityBucket + ")"); info.put("Release", Build.VERSION.RELEASE); info.put("API", String.valueOf(Build.VERSION.SDK_INT)); info.put("Language", context.getResources().getConfiguration().locale.getDisplayLanguage()); StringBuilder builder = new StringBuilder(); builder.append("\n\n\n\n"); builder.append("Alfresco Mobile and device details\n"); builder.append("-------------------\n").toString(); for (Map.Entry entry : info.entrySet()) { builder.append(entry.getKey()).append(": ").append(entry.getValue()).append('\n'); } builder.append("-------------------\n\n").toString(); iBuilder.setType("message/rfc822"); iBuilder.setText(builder.toString()); iBuilder.setChooserTitle(fr.getString(R.string.settings_feedback_email)).startChooser(); return true; } catch (Exception e) { AlfrescoNotificationManager.getInstance(fr.getActivity()).showAlertCrouton(fr.getActivity(), R.string.error_general); Log.d(TAG, Log.getStackTraceString(e)); } return false; }
From source file:com.almalence.opencam.Fragment.java
@TargetApi(13) private void showCameraParameters() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle(R.string.Pref_CameraParameters_Title); final StringBuilder about_string = new StringBuilder(); String version = "UNKNOWN_VERSION"; int version_code = -1; try {//w w w. j a v a2s .c om PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0); version = pInfo.versionName; version_code = pInfo.versionCode; } catch (NameNotFoundException e) { e.printStackTrace(); } about_string.append("\nApplication name: "); about_string.append(MainScreen.getInstance().getResources().getString(R.string.Pref_About)); about_string.append("\nAndroid API version: "); about_string.append(Build.VERSION.SDK_INT); about_string.append("\nDevice manufacturer: "); about_string.append(Build.MANUFACTURER); about_string.append("\nDevice model: "); about_string.append(Build.MODEL); about_string.append("\nDevice code-name: "); about_string.append(Build.HARDWARE); about_string.append("\nDevice variant: "); about_string.append(Build.DEVICE); { ActivityManager activityManager = (ActivityManager) getActivity() .getSystemService(Activity.ACTIVITY_SERVICE); about_string.append("\nStandard max heap (MB): "); about_string.append(activityManager.getMemoryClass()); about_string.append("\nLarge max heap (MB): "); about_string.append(activityManager.getLargeMemoryClass()); } { Point display_size = new Point(); Display display = getActivity().getWindowManager().getDefaultDisplay(); display.getSize(display_size); about_string.append("\nDisplay size: "); about_string.append(display_size.x); about_string.append("x"); about_string.append(display_size.y); } //show camera 2 support level int level = CameraController.getCamera2Level(); about_string.append("\nCamera2 API: "); switch (level) { case 0://limited about_string.append("limited"); break; case 1://full about_string.append("full"); break; case 2://legacy about_string.append("legacy"); break; default: about_string.append("not supported"); } // about_string.append("\nSensor orientation, back camera: "); // about_string.append(CameraController.getSensorOrientation(0)); // about_string.append("\nSensor orientation, front camera: "); // about_string.append(CameraController.getSensorOrientation(1)); if (MainScreen.getInstance().preview_sizes != null) { about_string.append("\nPreview resolutions: "); for (int i = 0; i < MainScreen.getInstance().preview_sizes.size(); i++) { if (i > 0) { about_string.append(", "); } about_string.append(MainScreen.getInstance().preview_sizes.get(i).getWidth()); about_string.append("x"); about_string.append(MainScreen.getInstance().preview_sizes.get(i).getHeight()); } } about_string.append("\nCurrent camera ID: "); about_string.append(MainScreen.getInstance().cameraId); if (MainScreen.getInstance().picture_sizes != null) { about_string.append("\nPhoto resolutions: "); for (int i = 0; i < MainScreen.getInstance().picture_sizes.size(); i++) { if (i > 0) { about_string.append(", "); } about_string.append(MainScreen.getInstance().picture_sizes.get(i).getWidth()); about_string.append("x"); about_string.append(MainScreen.getInstance().picture_sizes.get(i).getHeight()); } } if (MainScreen.getInstance().video_sizes != null) { about_string.append("\nVideo resolutions: "); for (int i = 0; i < MainScreen.getInstance().video_sizes.size(); i++) { if (i > 0) { about_string.append(", "); } about_string.append(MainScreen.getInstance().video_sizes.get(i).getWidth()); about_string.append("x"); about_string.append(MainScreen.getInstance().video_sizes.get(i).getHeight()); } } about_string.append("\nVideo stabilization: "); about_string.append(MainScreen.getInstance().supports_video_stabilization ? "true" : "false"); about_string.append("\nFlash modes: "); if (MainScreen.getInstance().flash_values != null && MainScreen.getInstance().flash_values.size() > 0) { for (int i = 0; i < MainScreen.getInstance().flash_values.size(); i++) { if (i > 0) { about_string.append(", "); } about_string.append(MainScreen.getInstance().flash_values.get(i)); } } else { about_string.append("None"); } about_string.append("\nFocus modes: "); if (MainScreen.getInstance().focus_values != null && MainScreen.getInstance().focus_values.size() > 0) { for (int i = 0; i < MainScreen.getInstance().focus_values.size(); i++) { if (i > 0) { about_string.append(", "); } about_string.append(MainScreen.getInstance().focus_values.get(i)); } } else { about_string.append("None"); } about_string.append("\nScene modes: "); if (MainScreen.getInstance().scene_modes_values != null && MainScreen.getInstance().scene_modes_values.size() > 0) { for (int i = 0; i < MainScreen.getInstance().scene_modes_values.size(); i++) { if (i > 0) { about_string.append(", "); } about_string.append(MainScreen.getInstance().scene_modes_values.get(i)); } } else { about_string.append("None"); } about_string.append("\nWhite balances: "); if (MainScreen.getInstance().white_balances_values != null && MainScreen.getInstance().white_balances_values.size() > 0) { for (int i = 0; i < MainScreen.getInstance().white_balances_values.size(); i++) { if (i > 0) { about_string.append(", "); } about_string.append(MainScreen.getInstance().white_balances_values.get(i)); } } else { about_string.append("None"); } about_string.append("\nISOs: "); if (MainScreen.getInstance().isos != null && MainScreen.getInstance().isos.size() > 0) { for (int i = 0; i < MainScreen.getInstance().isos.size(); i++) { if (i > 0) { about_string.append(", "); } about_string.append(MainScreen.getInstance().isos.get(i)); } } else { about_string.append("None"); } String save_location = SavingService.getSaveToPath(); about_string.append("\nSave Location: " + save_location); if (MainScreen.getInstance().flattenParamteters != null && !MainScreen.getInstance().flattenParamteters.equals("")) { about_string.append("\nFULL INFO:\n"); about_string.append(MainScreen.getInstance().flattenParamteters); } alertDialog.setMessage(about_string); alertDialog.setPositiveButton(R.string.Pref_CameraParameters_Ok, null); alertDialog.setNegativeButton(R.string.Pref_CameraParameters_CopyToClipboard, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Activity.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("OpenCamera About", about_string); clipboard.setPrimaryClip(clip); } }); alertDialog.show(); }
From source file:de.da_sense.moses.client.WelcomeActivity.java
/** * User comes back from another activity. *//*from w w w.j a v a 2 s. c om*/ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d("MainActivity", "onActivityResult called with requestCode " + requestCode); if (!isMosesServiceRunning()) startAndBindService(); if (requestCode == 1) { // Login activity waitingForResult = false; switch (resultCode) { case Activity.RESULT_OK: SharedPreferences.Editor e = PreferenceManager.getDefaultSharedPreferences(this).edit(); String username = data.getStringExtra(MosesPreferences.PREF_EMAIL); String password = data.getStringExtra(MosesPreferences.PREF_PASSWORD); String deviceName = data.getStringExtra(MosesPreferences.PREF_DEVICENAME); Log.d("MoSeS.ACTIVITY", username); Log.d("MoSeS.ACTIVITY", password); e.putString(MosesPreferences.PREF_EMAIL, username); e.putString(MosesPreferences.PREF_PASSWORD, password); // only set the deviceName sent by the server if the client // does not know his name if (deviceName != null) { // the server may not know the // name of the device, so check // if the response contained the // name e.putString(MosesPreferences.PREF_DEVICENAME, deviceName); } else { // the server does not know the deviceName either, set // the device's model name as the device name e.putString(MosesPreferences.PREF_DEVICENAME, Build.MODEL); } e.apply(); if (onLoginCompleteShowUserStudy != null) { // if a user study is to be displayed UserstudyNotificationManager.displayUserStudyContent(onLoginCompleteShowUserStudy, this.getApplicationContext()); onLoginCompleteShowUserStudy = null; } break; case Activity.RESULT_CANCELED: finish(); break; } } else if (requestCode == RunningFragment.REQUEST_CODE_NOTIFY_ABOUT_SEND) { if (resultCode == RESULT_OK) // the survey has successfully been sent to server, meaning it // disappeared from available tab // switch to history tab, she is there mViewPager.setCurrentItem(WelcomeActivityPagerAdapter.TAB_HISTORY, true); } }
From source file:org.mariotaku.twidere.activity.support.HomeActivity.java
@Override protected void onStop() { mMultiSelectHandler.dispatchOnStop(); mReadStateManager.unregisterOnSharedPreferenceChangeListener(mReadStateChangeListener); final Bus bus = TwidereApplication.getInstance(this).getMessageBus(); assert bus != null; bus.unregister(this); final ContentResolver resolver = getContentResolver(); resolver.unregisterContentObserver(mAccountChangeObserver); mPreferences.edit().putInt(KEY_SAVED_TAB_POSITION, mViewPager.getCurrentItem()).apply(); sendBroadcast(new Intent(BROADCAST_HOME_ACTIVITY_ONSTOP)); // spice//w ww . j a v a2 s . c om SpiceProfilingUtil.profile(this, SpiceProfilingUtil.FILE_NAME_APP, "App Stop"); SpiceProfilingUtil.profile(this, SpiceProfilingUtil.FILE_NAME_ONLAUNCH, "App Stop" + "," + NetworkStateUtil.getConnectedType(this) + "," + Build.MODEL); //end super.onStop(); }
From source file:github.daneren2005.dsub.fragments.NowPlayingFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { rootView = inflater.inflate(R.layout.download, container, false); setTitle(R.string.button_bar_now_playing); WindowManager w = context.getWindowManager(); Display d = w.getDefaultDisplay();// www . java 2s. c o m swipeDistance = (d.getWidth() + d.getHeight()) * PERCENTAGE_OF_SCREEN_FOR_SWIPE / 100; swipeVelocity = (d.getWidth() + d.getHeight()) * PERCENTAGE_OF_SCREEN_FOR_SWIPE / 100; gestureScanner = new GestureDetector(this); playlistFlipper = (ViewFlipper) rootView.findViewById(R.id.download_playlist_flipper); emptyTextView = (TextView) rootView.findViewById(R.id.download_empty); songTitleTextView = (TextView) rootView.findViewById(R.id.download_song_title); albumArtImageView = (ImageView) rootView.findViewById(R.id.download_album_art_image); positionTextView = (TextView) rootView.findViewById(R.id.download_position); durationTextView = (TextView) rootView.findViewById(R.id.download_duration); statusTextView = (TextView) rootView.findViewById(R.id.download_status); progressBar = (SeekBar) rootView.findViewById(R.id.download_progress_bar); previousButton = (AutoRepeatButton) rootView.findViewById(R.id.download_previous); nextButton = (AutoRepeatButton) rootView.findViewById(R.id.download_next); pauseButton = rootView.findViewById(R.id.download_pause); stopButton = rootView.findViewById(R.id.download_stop); startButton = rootView.findViewById(R.id.download_start); repeatButton = (ImageButton) rootView.findViewById(R.id.download_repeat); bookmarkButton = (ImageButton) rootView.findViewById(R.id.download_bookmark); rateBadButton = (ImageButton) rootView.findViewById(R.id.download_rating_bad); rateGoodButton = (ImageButton) rootView.findViewById(R.id.download_rating_good); toggleListButton = rootView.findViewById(R.id.download_toggle_list); playlistView = (RecyclerView) rootView.findViewById(R.id.download_list); FastScroller fastScroller = (FastScroller) rootView.findViewById(R.id.download_fast_scroller); fastScroller.attachRecyclerView(playlistView); setupLayoutManager(playlistView, false); ItemTouchHelper touchHelper = new ItemTouchHelper(new DownloadFileItemHelperCallback(this, true)); touchHelper.attachToRecyclerView(playlistView); starButton = (ImageButton) rootView.findViewById(R.id.download_star); if (Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_STAR, true)) { starButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { DownloadFile currentDownload = getDownloadService().getCurrentPlaying(); if (currentDownload != null) { final Entry currentSong = currentDownload.getSong(); toggleStarred(currentSong, new OnStarChange() { @Override void starChange(boolean starred) { if (currentSong.isStarred()) { starButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_toggle_star)); } else { if (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { starButton.setImageResource( DrawableTint.getDrawableRes(context, R.attr.star_outline)); } else { starButton.setImageResource(R.drawable.ic_toggle_star_outline_dark); } } } }); } } }); } else { starButton.setVisibility(View.GONE); } View.OnTouchListener touchListener = new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent me) { return gestureScanner.onTouchEvent(me); } }; pauseButton.setOnTouchListener(touchListener); stopButton.setOnTouchListener(touchListener); startButton.setOnTouchListener(touchListener); bookmarkButton.setOnTouchListener(touchListener); rateBadButton.setOnTouchListener(touchListener); rateGoodButton.setOnTouchListener(touchListener); emptyTextView.setOnTouchListener(touchListener); albumArtImageView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent me) { if (me.getAction() == MotionEvent.ACTION_DOWN) { lastY = (int) me.getRawY(); } return gestureScanner.onTouchEvent(me); } }); previousButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfStorageUnavailable(); new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().previous(); return null; } }.execute(); setControlsVisible(true); } }); previousButton.setOnRepeatListener(new Runnable() { public void run() { changeProgress(-INCREMENT_TIME); } }); nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfStorageUnavailable(); new SilentBackgroundTask<Boolean>(context) { @Override protected Boolean doInBackground() throws Throwable { getDownloadService().next(); return true; } }.execute(); setControlsVisible(true); } }); nextButton.setOnRepeatListener(new Runnable() { public void run() { changeProgress(INCREMENT_TIME); } }); pauseButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().pause(); return null; } }.execute(); } }); stopButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().reset(); return null; } }.execute(); } }); startButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfStorageUnavailable(); new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { start(); return null; } }.execute(); } }); repeatButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { RepeatMode repeatMode = getDownloadService().getRepeatMode().next(); getDownloadService().setRepeatMode(repeatMode); switch (repeatMode) { case OFF: Util.toast(context, R.string.download_repeat_off); break; case ALL: Util.toast(context, R.string.download_repeat_all); break; case SINGLE: Util.toast(context, R.string.download_repeat_single); break; default: break; } updateRepeatButton(); setControlsVisible(true); } }); bookmarkButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { createBookmark(); } }); rateBadButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { DownloadService downloadService = getDownloadService(); if (downloadService == null) { return; } DownloadFile downloadFile = downloadService.getCurrentPlaying(); if (downloadFile == null) { return; } Entry entry = downloadFile.getSong(); // If rating == 1, already set so unset if (entry.getRating() == 1) { setRating(entry, 0); if (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { rateBadButton.setImageResource(R.drawable.ic_action_rating_bad_dark); } else { rateBadButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.rating_bad)); } } else { // Immediately skip to the next song downloadService.next(true); // Otherwise set rating to 1 setRating(entry, 1); rateBadButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_action_rating_bad_selected)); // Make sure good rating is blank if (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { rateGoodButton.setImageResource(R.drawable.ic_action_rating_good_dark); } else { rateGoodButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.rating_good)); } } } }); rateGoodButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { DownloadService downloadService = getDownloadService(); if (downloadService == null) { return; } DownloadFile downloadFile = downloadService.getCurrentPlaying(); if (downloadFile == null) { return; } Entry entry = downloadFile.getSong(); // If rating == 5, already set so unset if (entry.getRating() == 5) { setRating(entry, 0); if (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { rateGoodButton.setImageResource(R.drawable.ic_action_rating_good_dark); } else { rateGoodButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.rating_good)); } } else { // Otherwise set rating to maximum setRating(entry, 5); rateGoodButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_action_rating_good_selected)); // Make sure bad rating is blank if (context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { rateBadButton.setImageResource(R.drawable.ic_action_rating_bad_dark); } else { rateBadButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.rating_bad)); } } } }); toggleListButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggleFullscreenAlbumArt(); setControlsVisible(true); } }); View overlay = rootView.findViewById(R.id.download_overlay_buttons); final int overlayHeight = overlay != null ? overlay.getHeight() : -1; albumArtImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (overlayHeight == -1 || lastY < (view.getBottom() - overlayHeight)) { toggleFullscreenAlbumArt(); setControlsVisible(true); } } }); progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(final SeekBar seekBar) { new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().seekTo(progressBar.getProgress()); return null; } @Override protected void done(Void result) { seekInProgress = false; } }.execute(); } @Override public void onStartTrackingTouch(final SeekBar seekBar) { seekInProgress = true; } @Override public void onProgressChanged(final SeekBar seekBar, final int position, final boolean fromUser) { if (fromUser) { positionTextView.setText(Util.formatDuration(position / 1000)); setControlsVisible(true); } } }); if (Build.MODEL.equals("Nexus 4") || Build.MODEL.equals("GT-I9100")) { View slider = rootView.findViewById(R.id.download_slider); slider.setPadding(0, 0, 0, 0); } return rootView; }