forked from mlopatkin/andlogview
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add menu to copy metadata of the opened file/device to the clipboard
Fixes mlopatkin#137
- Loading branch information
Showing
20 changed files
with
450 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,4 +68,6 @@ public interface DataSource { | |
* bookmarks become invalid) | ||
*/ | ||
boolean reset(); | ||
|
||
SourceMetadata getMetadata(); | ||
} |
25 changes: 25 additions & 0 deletions
25
src/name/mlopatkin/andlogview/liblogcat/SourceMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2021 Mikhail Lopatkin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package name.mlopatkin.andlogview.liblogcat; | ||
|
||
import java.util.Collection; | ||
|
||
/** A collection of metadata that describes the data source. */ | ||
public interface SourceMetadata { | ||
/** @return the collection of metadata items available for the data source */ | ||
Collection<SourceMetadataItem> getMetadataItems(); | ||
} |
35 changes: 35 additions & 0 deletions
35
src/name/mlopatkin/andlogview/liblogcat/SourceMetadataItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2021 Mikhail Lopatkin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package name.mlopatkin.andlogview.liblogcat; | ||
|
||
public class SourceMetadataItem { | ||
private final String displayName; | ||
private final String value; | ||
|
||
public SourceMetadataItem(String displayName, String value) { | ||
this.displayName = displayName; | ||
this.value = value; | ||
} | ||
|
||
public String getDisplayName() { | ||
return displayName; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/name/mlopatkin/andlogview/liblogcat/ddmlib/AdbSourceMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2021 Mikhail Lopatkin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package name.mlopatkin.andlogview.liblogcat.ddmlib; | ||
|
||
import name.mlopatkin.andlogview.liblogcat.SourceMetadata; | ||
import name.mlopatkin.andlogview.liblogcat.SourceMetadataItem; | ||
|
||
import com.android.ddmlib.IDevice; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
class AdbSourceMetadata implements SourceMetadata { | ||
private final IDevice device; | ||
|
||
public AdbSourceMetadata(IDevice device) { | ||
this.device = device; | ||
} | ||
|
||
@Override | ||
public Collection<SourceMetadataItem> getMetadataItems() { | ||
return Collections.singleton(new SourceMetadataItem("serial", device.getSerialNumber())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/name/mlopatkin/andlogview/liblogcat/file/FileSourceMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2021 Mikhail Lopatkin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package name.mlopatkin.andlogview.liblogcat.file; | ||
|
||
import name.mlopatkin.andlogview.liblogcat.SourceMetadata; | ||
import name.mlopatkin.andlogview.liblogcat.SourceMetadataItem; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
|
||
import java.io.File; | ||
import java.util.Collection; | ||
|
||
class FileSourceMetadata implements SourceMetadata { | ||
private final ImmutableList<SourceMetadataItem> metadataItems; | ||
|
||
public FileSourceMetadata(File path) { | ||
metadataItems = ImmutableList.of( | ||
new SourceMetadataItem("name", path.getName()), | ||
new SourceMetadataItem("path", path.getAbsolutePath())); | ||
} | ||
|
||
@Override | ||
public Collection<SourceMetadataItem> getMetadataItems() { | ||
return metadataItems; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2021 Mikhail Lopatkin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package name.mlopatkin.andlogview.ui; | ||
|
||
import java.awt.Toolkit; | ||
import java.awt.datatransfer.Clipboard; | ||
import java.awt.datatransfer.StringSelection; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
class AwtClipboard implements GlobalClipboard { | ||
@Inject | ||
AwtClipboard() { | ||
} | ||
|
||
@Override | ||
public void setText(String text) { | ||
Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); | ||
systemClipboard.setContents(new StringSelection(text), null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright 2021 Mikhail Lopatkin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package name.mlopatkin.andlogview.ui; | ||
|
||
public interface GlobalClipboard { | ||
void setText(String text); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2021 Mikhail Lopatkin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package name.mlopatkin.andlogview.ui; | ||
|
||
import dagger.Binds; | ||
import dagger.Module; | ||
|
||
@Module | ||
public abstract class SwingUiModule { | ||
@Binds | ||
abstract GlobalClipboard getGlobalClipboard(AwtClipboard awtClipboard); | ||
} |
Oops, something went wrong.