Skip to content

Commit

Permalink
README update, and small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
retanar committed Jan 21, 2021
1 parent fe488aa commit 65a62c3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Divergence Meter
Android divergence meter widget like that in Steins;Gate.

#### Features
### Features
- Displaying divergence number in nixie tubes;
- Changing the divergence every 2 hours;
- Balanced random system, that lowers the chance of going to another attractor field;
- Ability to set your own divergence number;
- Notifications, when changing attractor field.

#### Images
### Images
Normal view:

![widget preview](app/src/main/res/drawable-nodpi/appwidget_preview.jpg)
Expand All @@ -20,9 +20,6 @@ With minus:
## Download
https://github.com/retanar/Divergence_Meter/releases

#### Known issues
### Known issues
- For unknown reasons, you may encounter an error "Problem loading widget".
Fix: delete and add the widget again.
- There is -1.000000 divergence which is displayed as -.000000
- Although the program uses a modified random generator it's still random, so it's possible to switch the attractor field a few times in a row.
I'm working on a fix for this for the 0.4.0 version.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "0.4.0 alpha 3"
versionName "0.4.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/java/com/vlprojects/divergence/DivergenceWidget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.appwidget.AppWidgetManager
import android.content.Context
import android.content.Context.NOTIFICATION_SERVICE
import android.os.Build
import android.util.Log
//import android.util.Log
import android.widget.RemoteViews
import androidx.core.app.NotificationCompat
import com.vlprojects.divergence.DivergenceMeter.getDivergenceValuesOrGenerate
Expand All @@ -18,12 +18,12 @@ class DivergenceWidget : android.appwidget.AppWidgetProvider() {
override fun onEnabled(context: Context) {
super.onEnabled(context)

val prefs = context.getSharedPreferences(SHARED_FILENAME, 0)
val (currentDiv, nextDiv) = prefs.getDivergenceValuesOrGenerate()
Log.d(
"DivergenceWidget", "onEnabled() call. Current divergence = $currentDiv; " +
"Next divergence = $nextDiv"
)
// val prefs = context.getSharedPreferences(SHARED_FILENAME, 0)
// val (currentDiv, nextDiv) = prefs.getDivergenceValuesOrGenerate()
// Log.d(
// "DivergenceWidget",
// "onEnabled() call. Current divergence = $currentDiv; Next divergence = $nextDiv"
// )

createNotificationChannel(context)
}
Expand Down Expand Up @@ -80,7 +80,7 @@ class DivergenceWidget : android.appwidget.AppWidgetProvider() {
/** Notifications **/

private fun sendNotification(context: Context, text: String) {
Log.d("DivergenceWidget", "sendNotification() call with text = \"$text\"")
// Log.d("DivergenceWidget", "sendNotification() call with text = \"$text\"")
val notifyManager = getNotificationManager(context)
val builder = NotificationCompat.Builder(context, CHANGE_WORLDLINE_NOTIFICATION_CHANNEL)
.setSmallIcon(R.drawable.ic_notification)
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/com/vlprojects/divergence/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ import com.vlprojects.divergence.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() {

private lateinit var binding: ActivityMainBinding
private val prefs by lazy { getSharedPreferences(SHARED_FILENAME, 0) }
private lateinit var prefs: SharedPreferences

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)

prefs = getSharedPreferences(SHARED_FILENAME, 0)
setDivergenceText()
binding.changeDivergenceButton.setOnClickListener { changeDivergence(prefs) }
prefs.registerOnSharedPreferenceChangeListener(onPreferenceChangeListener)
prefs.registerOnSharedPreferenceChangeListener(onDivergenceChangeListener)
}

private fun setDivergenceText() {
Expand Down Expand Up @@ -64,7 +65,7 @@ class MainActivity : AppCompatActivity() {
}

// Using field so it won't be garbage collected
private val onPreferenceChangeListener = SharedPreferences.OnSharedPreferenceChangeListener { _, tag ->
private val onDivergenceChangeListener = SharedPreferences.OnSharedPreferenceChangeListener { _, tag ->
if (tag == SHARED_CURRENT_DIVERGENCE)
setDivergenceText()
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
android:layout_margin="6dp"/>
android:layout_margin="8dp"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
Expand Down Expand Up @@ -80,7 +80,7 @@
android:inputType="numberSigned|numberDecimal"
android:hint="@string/hint_enter_new_divergence_here"
android:layout_marginBottom="16dp"
android:importantForAutofill="no"/>
android:importantForAutofill="no" android:maxLength="9"/>
<Button
android:id="@+id/changeDivergenceButton"
android:text="@string/change"
Expand Down

0 comments on commit 65a62c3

Please sign in to comment.