-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
セーフサーチを実装した
- Loading branch information
Showing
13 changed files
with
184 additions
and
22 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
47 changes: 47 additions & 0 deletions
47
app/src/main/java/jp/panta/misskeyandroidclient/ui/main/SafeSearchDescriptionDialog.kt
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,47 @@ | ||
package jp.panta.misskeyandroidclient.ui.main | ||
|
||
import android.app.Dialog | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.fragment.app.DialogFragment | ||
import androidx.fragment.app.activityViewModels | ||
import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||
import jp.panta.misskeyandroidclient.ui.main.viewmodel.MainViewModel | ||
import net.pantasystem.milktea.common_resource.R | ||
import net.pantasystem.milktea.setting.activities.SettingMovementActivity | ||
|
||
class SafeSearchDescriptionDialog : DialogFragment() { | ||
companion object { | ||
const val TAG = "SafeSearchDescriptionDialog" | ||
} | ||
|
||
private val preferences by lazy { | ||
requireContext().getSharedPreferences("safe_search_description_dialog", Context.MODE_PRIVATE) | ||
} | ||
|
||
private val mainViewModel by activityViewModels<MainViewModel>() | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
return MaterialAlertDialogBuilder(requireContext()) | ||
.setTitle(R.string.safe_search_description_dialog_title) | ||
.setMessage(R.string.safe_search_description_dialog_message) | ||
.setPositiveButton(R.string.safe_search_description_dialog_positive_button) { _, _ -> | ||
val intent = Intent(requireContext(), SettingMovementActivity::class.java) | ||
intent.putExtra(SettingMovementActivity.EXTRA_HIGHLIGHT_SAFE_SEARCH, true) | ||
startActivity(intent) | ||
dismiss() | ||
} | ||
.setNegativeButton(R.string.safe_search_description_dialog_negative_button) { _, _ -> | ||
preferences.edit().putInt("counter", preferences.getInt("counter", 0) + 1).apply() | ||
if (preferences.getInt("counter", 0) >= 3) { | ||
mainViewModel.onDoNotShowSafeSearchDescription() | ||
} | ||
// 何もしない | ||
dismiss() | ||
} | ||
.setCancelable(false) | ||
|
||
.create() | ||
} | ||
} |
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
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
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
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
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
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