今天,我尝试了 zsh 。我通过简单的操作遇到了严重的用户体验问题。
当我使用 Tab 在此处自动完成我的命令时,在 bash 中我将顺利获得private static int NOTIFICATION_ID = 1001;
private static String VIDEO_FILE_FORMAT = "video/*";
public static String upload(YouTube youtube, final InputStream fileInputStream,
final long fileSize, Context context) {
final NotificationManager mNotifyManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
mBuilder.setContentTitle(context.getString(R.string.youtube_upload))
.setContentText(context.getString(R.string.youtube_direct_lite_upload_started))
.setSmallIcon(R.drawable.icon);
String videoId = null;
try {
// Add extra information to the video before uploading.
Video videoObjectDefiningMetadata = new Video();
VideoStatus status = new VideoStatus();
status.setPrivacyStatus("public");
videoObjectDefiningMetadata.setStatus(status);
// We set a majority of the metadata with the VideoSnippet object.
VideoSnippet snippet = new VideoSnippet();
Calendar cal = Calendar.getInstance();
snippet.setTitle("Test Upload via Java on " + cal.getTime());
snippet.setDescription("Video uploaded via YouTube Data API V3 using the Java library "
+ "on " + cal.getTime());
List<String> tags = new ArrayList<String>();
tags.add(Constants.DEFAULT_KEYWORD);
tags.add(Upload.generateKeywordFromPlaylistId(Constants.UPLOAD_PLAYLIST));
snippet.setTags(tags);
videoObjectDefiningMetadata.setSnippet(snippet);
InputStreamContent mediaContent =
new InputStreamContent(VIDEO_FILE_FORMAT, new BufferedInputStream(fileInputStream));
mediaContent.setLength(fileSize);
YouTube.Videos.Insert videoInsert =
youtube.videos().insert("snippet,statistics,status", videoObjectDefiningMetadata,
mediaContent);
MediaHttpUploader uploader = videoInsert.getMediaHttpUploader();
uploader.setDirectUploadEnabled(false);
MediaHttpUploaderProgressListener progressListener = new MediaHttpUploaderProgressListener() {
public void progressChanged(MediaHttpUploader uploader) throws IOException {
switch (uploader.getUploadState()) {
case INITIATION_STARTED:
mBuilder.setContentText("Initiation Started").setProgress((int) fileSize,
(int) uploader.getNumBytesUploaded(), false);
mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build());
break;
case INITIATION_COMPLETE:
mBuilder.setContentText("Initiation Completed").setProgress((int) fileSize,
(int) uploader.getNumBytesUploaded(), false);
mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build());
break;
case MEDIA_IN_PROGRESS:
mBuilder
.setContentTitle("YouTube Upload " + (int) (uploader.getProgress() * 100) + "%")
.setContentText("Direct Lite upload in progress")
.setProgress((int) fileSize, (int) uploader.getNumBytesUploaded(), false);
mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build());
break;
case MEDIA_COMPLETE:
mBuilder.setContentTitle("YouTube Upload Completed")
.setContentText("Upload complete")
// Removes the progress bar
.setProgress(0, 0, false);
mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build());
case NOT_STARTED:
Log.d(this.getClass().getSimpleName(), "Upload Not Started!");
break;
}
}
};
uploader.setProgressListener(progressListener);
// Execute upload.
Video returnedVideo = videoInsert.execute();
videoId = returnedVideo.getId();
} catch (final GoogleJsonResponseException e) {
if (401 == e.getDetails().getCode()) {
Log.e(ResumableUpload.class.getSimpleName(), e.getMessage());
LocalBroadcastManager manager = LocalBroadcastManager.getInstance(context);
manager.sendBroadcast(new Intent(MainActivity.INVALIDATE_TOKEN_INTENT));
}
} catch (IOException e) {
Log.e("IOException", e.getMessage());
} catch (Throwable t) {
Log.e("Throwable", t.getMessage());
}
return videoId;
}
。
但是在 zsh 中,安装了 oh-my-zsh 后,我得到了一堆不是我需要的建议。
如何禁用 oh-my-zsh 的全局自动完成趋势并让它在当前上下文中自动完成?