-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ad17b6
commit ec574f8
Showing
11 changed files
with
282 additions
and
164 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
84 changes: 84 additions & 0 deletions
84
...r/src/main/java/net/kdt/pojavlaunch/prefs/screens/LauncherPreferenceLauncherFragment.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,84 @@ | ||
package net.kdt.pojavlaunch.prefs.screens; | ||
|
||
import android.app.Activity; | ||
import android.content.ContentResolver; | ||
import android.content.Intent; | ||
import android.graphics.Bitmap; | ||
import android.graphics.BitmapFactory; | ||
import android.net.Uri; | ||
import android.provider.MediaStore; | ||
import android.os.Bundle; | ||
|
||
import android.widget.Toast; | ||
import androidx.preference.Preference; | ||
|
||
import com.firefly.feature.UpdateLauncher; | ||
import com.kdt.pickafile.FileListView; | ||
import net.kdt.pojavlaunch.R; | ||
import net.kdt.pojavlaunch.Tools; | ||
import org.apache.commons.io.IOUtils; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileOutputStream; | ||
import java.io.InputStream; | ||
|
||
public class LauncherPreferenceLauncherFragment extends LauncherPreferenceFragment { | ||
@Override | ||
public void onCreatePreferences(Bundle b, String str) { | ||
addPreferencesFromResource(R.xml.pref_launcher); | ||
|
||
findPreference("control_mouse_setting").setOnPreferenceClickListener((preference) -> { | ||
Intent intent = new Intent(Intent.ACTION_PICK); | ||
intent.setType("image/*"); | ||
startActivityForResult(intent, 1); | ||
return true; | ||
}); | ||
|
||
findPreference("control_mouse_remove").setOnPreferenceClickListener((preference) -> { | ||
File file = new File(Tools.DIR_GAME_HOME, "mouse"); | ||
if (file.exists()) { | ||
file.delete(); | ||
} | ||
Toast.makeText(getContext(), R.string.notif_mouse1, Toast.LENGTH_SHORT).show(); | ||
return true; | ||
}); | ||
|
||
Preference updatePreference = requirePreference("update_launcher"); | ||
updatePreference.setOnPreferenceClickListener(preference -> { | ||
UpdateLauncher updateLauncher = new UpdateLauncher(getContext()); | ||
updateLauncher.checkForUpdates(false); | ||
return true; | ||
}); | ||
|
||
} | ||
|
||
@Override | ||
public void onActivityResult( | ||
int requestCode, int resultCode, final Intent data) { | ||
if (resultCode != Activity.RESULT_OK) { | ||
// Handle error | ||
return; | ||
} | ||
|
||
if (requestCode == 1) {// Get photo picker response for single select. | ||
Uri currentUri = data.getData(); | ||
try { | ||
File file = new File(Tools.DIR_GAME_HOME, "mouse"); | ||
if (file.exists()) { | ||
file.delete(); | ||
} | ||
|
||
InputStream stream1 = getContext().getContentResolver().openInputStream(currentUri); | ||
FileOutputStream stream = new FileOutputStream(file); | ||
|
||
IOUtils.copy(stream1, stream); | ||
stream.close(); | ||
stream1.close(); | ||
Toast.makeText(getContext(), R.string.notif_mouse, Toast.LENGTH_SHORT).show(); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.