mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
convert a couple simple activity to kotlin, no functionality change
This commit is contained in:
parent
d4c75c2107
commit
0959403628
8 changed files with 101 additions and 149 deletions
|
@ -1,46 +0,0 @@
|
|||
package com.simplemobiletools.gallery.activities;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.simplemobiletools.gallery.R;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class LicenseActivity extends SimpleActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_license);
|
||||
ButterKnife.bind(this);
|
||||
}
|
||||
|
||||
@OnClick(R.id.license_butterknife_title)
|
||||
public void butterKnifeClicked() {
|
||||
openUrl(R.string.butterknife_url);
|
||||
}
|
||||
|
||||
@OnClick(R.id.license_photoview_title)
|
||||
public void photoViewClicked() {
|
||||
openUrl(R.string.photoview_url);
|
||||
}
|
||||
|
||||
@OnClick(R.id.license_glide_title)
|
||||
public void glideClicked() {
|
||||
openUrl(R.string.glide_url);
|
||||
}
|
||||
|
||||
@OnClick(R.id.license_cropper_title)
|
||||
public void cropperClicked() {
|
||||
openUrl(R.string.cropper_url);
|
||||
}
|
||||
|
||||
private void openUrl(int id) {
|
||||
final String url = getResources().getString(id);
|
||||
final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
startActivity(browserIntent);
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package com.simplemobiletools.gallery.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
public class PhotoActivity extends PhotoVideoActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
mIsVideo = false;
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
package com.simplemobiletools.gallery.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
|
||||
import com.simplemobiletools.gallery.Config;
|
||||
import com.simplemobiletools.gallery.R;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class SettingsActivity extends SimpleActivity {
|
||||
@BindView(R.id.settings_dark_theme) SwitchCompat mDarkThemeSwitch;
|
||||
@BindView(R.id.settings_same_sorting) SwitchCompat mSameSortingSwitch;
|
||||
@BindView(R.id.settings_show_hidden_folders) SwitchCompat mShowHiddenFoldersSwitch;
|
||||
@BindView(R.id.settings_autoplay_videos) SwitchCompat mAutoplayVideosSwitch;
|
||||
|
||||
private static Config mConfig;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_settings);
|
||||
mConfig = Config.newInstance(getApplicationContext());
|
||||
ButterKnife.bind(this);
|
||||
|
||||
setupDarkTheme();
|
||||
setupSameSorting();
|
||||
setupShowHiddenFolders();
|
||||
setupAutoplayVideos();
|
||||
}
|
||||
|
||||
private void setupDarkTheme() {
|
||||
mDarkThemeSwitch.setChecked(mConfig.getIsDarkTheme());
|
||||
}
|
||||
|
||||
private void setupSameSorting() {
|
||||
mSameSortingSwitch.setChecked(mConfig.getIsSameSorting());
|
||||
}
|
||||
|
||||
private void setupShowHiddenFolders() {
|
||||
mShowHiddenFoldersSwitch.setChecked(mConfig.getShowHiddenFolders());
|
||||
}
|
||||
|
||||
private void setupAutoplayVideos() {
|
||||
mAutoplayVideosSwitch.setChecked(mConfig.getAutoplayVideos());
|
||||
}
|
||||
|
||||
@OnClick(R.id.settings_dark_theme_holder)
|
||||
public void handleDarkTheme() {
|
||||
mDarkThemeSwitch.setChecked(!mDarkThemeSwitch.isChecked());
|
||||
mConfig.setIsDarkTheme(mDarkThemeSwitch.isChecked());
|
||||
restartActivity();
|
||||
}
|
||||
|
||||
@OnClick(R.id.settings_same_sorting_holder)
|
||||
public void handleSameSorting() {
|
||||
mSameSortingSwitch.setChecked(!mSameSortingSwitch.isChecked());
|
||||
mConfig.setIsSameSorting(mSameSortingSwitch.isChecked());
|
||||
}
|
||||
|
||||
@OnClick(R.id.settings_show_hidden_folders_holder)
|
||||
public void handleShowHiddenFolders() {
|
||||
mShowHiddenFoldersSwitch.setChecked(!mShowHiddenFoldersSwitch.isChecked());
|
||||
mConfig.setShowHiddenFolders(mShowHiddenFoldersSwitch.isChecked());
|
||||
}
|
||||
|
||||
@OnClick(R.id.settings_autoplay_videos_holder)
|
||||
public void handleAutoplayVideos() {
|
||||
mAutoplayVideosSwitch.setChecked(!mAutoplayVideosSwitch.isChecked());
|
||||
mConfig.setAutoplayVideos(mAutoplayVideosSwitch.isChecked());
|
||||
}
|
||||
|
||||
private void restartActivity() {
|
||||
TaskStackBuilder.create(getApplicationContext()).addNextIntentWithParentStack(getIntent()).startActivities();
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package com.simplemobiletools.gallery.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
public class VideoActivity extends PhotoVideoActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
mIsVideo = true;
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.simplemobiletools.gallery.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import com.simplemobiletools.gallery.R
|
||||
import kotlinx.android.synthetic.main.activity_license.*
|
||||
|
||||
class LicenseActivity : SimpleActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_license)
|
||||
|
||||
license_butterknife_title.setOnClickListener { openUrl(R.string.butterknife_url) }
|
||||
license_photoview_title.setOnClickListener { openUrl(R.string.photoview_url) }
|
||||
license_glide_title.setOnClickListener { openUrl(R.string.glide_url) }
|
||||
license_cropper_title.setOnClickListener { openUrl(R.string.cropper_url) }
|
||||
}
|
||||
|
||||
private fun openUrl(id: Int) {
|
||||
val url = resources.getString(id)
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
startActivity(browserIntent)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.simplemobiletools.gallery.activities
|
||||
|
||||
import android.os.Bundle
|
||||
|
||||
class PhotoActivity : PhotoVideoActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
PhotoVideoActivity.mIsVideo = false
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.simplemobiletools.gallery.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.TaskStackBuilder
|
||||
import com.simplemobiletools.gallery.R
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
|
||||
class SettingsActivity : SimpleActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_settings)
|
||||
|
||||
setupDarkTheme()
|
||||
setupSameSorting()
|
||||
setupShowHiddenFolders()
|
||||
setupAutoplayVideos()
|
||||
}
|
||||
|
||||
private fun setupDarkTheme() {
|
||||
settings_dark_theme.isChecked = mConfig.isDarkTheme
|
||||
settings_dark_theme_holder.setOnClickListener {
|
||||
settings_dark_theme.toggle()
|
||||
mConfig.isDarkTheme = settings_dark_theme.isChecked
|
||||
restartActivity()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSameSorting() {
|
||||
settings_same_sorting.isChecked = mConfig.isSameSorting
|
||||
settings_same_sorting_holder.setOnClickListener {
|
||||
settings_same_sorting.toggle()
|
||||
mConfig.isSameSorting = settings_same_sorting.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupShowHiddenFolders() {
|
||||
settings_show_hidden_folders.isChecked = mConfig.showHiddenFolders
|
||||
settings_show_hidden_folders_holder.setOnClickListener {
|
||||
settings_show_hidden_folders.toggle()
|
||||
mConfig.showHiddenFolders = settings_show_hidden_folders.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupAutoplayVideos() {
|
||||
settings_autoplay_videos_holder.setOnClickListener {
|
||||
settings_autoplay_videos.toggle()
|
||||
mConfig.autoplayVideos = settings_autoplay_videos.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun restartActivity() {
|
||||
TaskStackBuilder.create(applicationContext).addNextIntentWithParentStack(intent).startActivities()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.simplemobiletools.gallery.activities
|
||||
|
||||
import android.os.Bundle
|
||||
|
||||
class VideoActivity : PhotoVideoActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
PhotoVideoActivity.mIsVideo = true
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue