<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
- <runningDeviceTargetSelectedWithDropDown>
- <Target>
- <type value="RUNNING_DEVICE_TARGET" />
- <deviceKey>
- <Key>
- <type value="VIRTUAL_DEVICE_PATH" />
- <value value="C:\Users\MRSa\.android\avd\Android_Wear_Round_Chin_API_26.avd" />
- </Key>
- </deviceKey>
- </Target>
- </runningDeviceTargetSelectedWithDropDown>
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<entry key="..\:/Users/MRSa/AndroidStudioProjects/JoggingTimer/wear/src/main/res/layout-notround/column_list.xml" value="1.0904605263157894" />
<entry key="..\:/Users/MRSa/AndroidStudioProjects/JoggingTimer/wear/src/main/res/layout-notround/icon_list.xml" value="1.0904605263157894" />
<entry key="..\:/Users/MRSa/AndroidStudioProjects/JoggingTimer/wear/src/main/res/layout-notround/information_dialog.xml" value="1.0904605263157894" />
+ <entry key="..\:/Users/MRSa/AndroidStudioProjects/JoggingTimer/wear/src/main/res/layout-notround/select_reference_dialog.xml" value="1.7394366197183098" />
<entry key="..\:/Users/MRSa/AndroidStudioProjects/JoggingTimer/wear/src/main/res/layout-notround/select_set_reference_dialog.xml" value="1.7570422535211268" />
<entry key="..\:/Users/MRSa/AndroidStudioProjects/JoggingTimer/wear/src/main/res/layout-notround/time_model_picker.xml" value="1.0904605263157894" />
<entry key="..\:/Users/MRSa/AndroidStudioProjects/JoggingTimer/wear/src/main/res/layout-round/activity_list.xml" value="0.9636627906976745" />
<entry key="..\:/Users/MRSa/AndroidStudioProjects/JoggingTimer/wear/src/main/res/layout-round/column_list.xml" value="0.9636627906976745" />
<entry key="..\:/Users/MRSa/AndroidStudioProjects/JoggingTimer/wear/src/main/res/layout-round/icon_list.xml" value="0.9636627906976745" />
<entry key="..\:/Users/MRSa/AndroidStudioProjects/JoggingTimer/wear/src/main/res/layout-round/information_dialog.xml" value="0.9636627906976745" />
+ <entry key="..\:/Users/MRSa/AndroidStudioProjects/JoggingTimer/wear/src/main/res/layout-round/select_reference_dialog.xml" value="1.5502092050209204" />
<entry key="..\:/Users/MRSa/AndroidStudioProjects/JoggingTimer/wear/src/main/res/layout-round/select_set_reference_dialog.xml" value="1.5658995815899581" />
<entry key="..\:/Users/MRSa/AndroidStudioProjects/JoggingTimer/wear/src/main/res/layout-round/time_model_picker.xml" value="0.9636627906976745" />
<entry key="..\:/Users/MRSa/AndroidStudioProjects/JoggingTimer/wear/src/main/res/menu/selector_detail.xml" value="2.1392857142857142" />
}
}
});
-
ret = true;
}
else if (itemId == R.id.menu_share_data)
*
*
*/
-public class ButtonClickListener implements View.OnClickListener, View.OnLongClickListener, View.OnTouchListener, Parcelable
+public class ButtonClickListener implements View.OnClickListener, View.OnLongClickListener, View.OnTouchListener, Parcelable
{
private final String TAG = toString();
private IClickCallback callback = null;
package net.osdn.gokigen.joggingtimer.stopwatch;
+import static net.osdn.gokigen.joggingtimer.utilities.SelectReferenceViewModeDialog.PREF_KEY_DISPLAY_LAPGRAPHIC;
+import static net.osdn.gokigen.joggingtimer.utilities.SelectReferenceViewModeDialog.PREF_KEY_REFERENCE_TIME_SELECTION;
+
import android.content.Intent;
+import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
+import android.preference.PreferenceManager;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.FragmentManager;
import androidx.wear.ambient.AmbientModeSupport;
import androidx.wear.widget.BoxInsetLayout;
import net.osdn.gokigen.joggingtimer.R;
import net.osdn.gokigen.joggingtimer.recordlist.ListActivity;
import net.osdn.gokigen.joggingtimer.stopwatch.graphview.LapTimeGraphView;
+import net.osdn.gokigen.joggingtimer.utilities.SelectReferenceViewModeDialog;
+import net.osdn.gokigen.joggingtimer.utilities.SetReferenceDialog;
import net.osdn.gokigen.joggingtimer.utilities.TimeStringConvert;
import java.text.SimpleDateFormat;
*
*
*/
-public class MainActivity extends AppCompatActivity implements IClickCallback, MyTimerTrigger.ITimeoutReceiver, MyTimerCounter.ICounterStatusNotify, AmbientModeSupport.AmbientCallbackProvider
+public class MainActivity extends AppCompatActivity implements IClickCallback, MyTimerTrigger.ITimeoutReceiver, MyTimerCounter.ICounterStatusNotify, AmbientModeSupport.AmbientCallbackProvider, SelectReferenceViewModeDialog.SelectReferenceCallback
{
private final String TAG = toString();
private final IWearableActivityControl controller = new WearableActivityController();
private boolean isLaptimeView = true;
private boolean pendingStart = false;
private int currentLapCount = 0;
+ private int currentReferenceId = 0;
private ITimerStopTrigger stopTrigger = null;
/**
}
}
isLaptimeView = controller.getDisplayMode();
+ currentReferenceId = controller.getReferenceTimerSelection();
//Log.v(TAG, "isLaptimeView " + isLaptimeView);
controller.setupReferenceData();
@Override
public boolean pushedArea()
{
- isLaptimeView = !isLaptimeView;
- controller.setDisplayMode(isLaptimeView);
- Log.v(TAG, "pushedArea() : " + isLaptimeView);
- changeGraphicView(isLaptimeView);
- updateTimerLabel();
+ try
+ {
+ // 基準値の設定ダイアログを表示する
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ final boolean viewMode = preferences.getBoolean(PREF_KEY_DISPLAY_LAPGRAPHIC, false);
+ final int selectionId = preferences.getInt(PREF_KEY_REFERENCE_TIME_SELECTION, 0);
+ final SelectReferenceViewModeDialog.SelectReferenceCallback callback = this;
+
+ this.runOnUiThread(() -> {
+ try
+ {
+ // 基準値&表示モード設定ダイアログを表示する
+ SelectReferenceViewModeDialog dialog = SelectReferenceViewModeDialog.newInstance(getString(R.string.select_reference_title), " ", viewMode, selectionId, callback);
+ FragmentManager manager = getSupportFragmentManager();
+ dialog.show(manager, "dialog");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
return (true);
}
}
});
}
+
+ @Override
+ public void selectedReferenceViewMode(int referenceId, int viewMode)
+ {
+ isLaptimeView = (viewMode != 0);
+ currentReferenceId = referenceId;
+
+ controller.setDisplayMode(isLaptimeView);
+ controller.setReferenceTimerSelection(currentReferenceId);
+ controller.setupReferenceData();
+
+ Log.v(TAG, "pushedArea() : " + isLaptimeView + " REF: " + currentReferenceId);
+
+ runOnUiThread(() -> {
+ // ラップタイム表示状態の更新
+ reloadLapTimeList(true);
+
+ // 表示ビューの切り替え
+ changeGraphicView(isLaptimeView);
+
+ // 表示のボタン状態を変更
+ updateTimerLabel();
+ });
+ }
}
referenceTimeA = new ArrayList<>(timelist);
size = referenceTimeA.size();
}
- if (referenceTimeId == 1)
+ else if (referenceTimeId == 1)
{
referenceTimeB = null;
referenceTimeB = new ArrayList<>(timelist);
import static android.content.Context.VIBRATOR_SERVICE;
+import static net.osdn.gokigen.joggingtimer.utilities.SelectReferenceViewModeDialog.PREF_KEY_DISPLAY_LAPGRAPHIC;
+import static net.osdn.gokigen.joggingtimer.utilities.SelectReferenceViewModeDialog.PREF_KEY_REFERENCE_TIME_SELECTION;
+
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
private final String TAG = toString();
private final String PREF_KEY_TIMER_STARTED = "TMR_START";
private final String PREF_KEY_TIMER_INDEXID = "TMR_INDEX";
- private final String PREF_KEY_DISPLAY_LAPGRAPHIC = "DISP_LAPGRPH";
- private final String PREF_KEY_REFERENCE_TIME_SELECTION = "REF_TIME_SEL";
private SharedPreferences preferences = null;
private final ButtonClickListener clickListener = new ButtonClickListener();
if (id == 0)
{
return (REFERENCE_ICON_ID_A);
- } else if (id == 1)
+ }
+ else if (id == 1)
{
return (REFERENCE_ICON_ID_B);
}
--- /dev/null
+package net.osdn.gokigen.joggingtimer.utilities;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Spinner;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.DialogFragment;
+
+import net.osdn.gokigen.joggingtimer.R;
+
+
+public class SelectReferenceViewModeDialog extends DialogFragment
+{
+ private final String TAG = toString();
+ public static final String PREF_KEY_DISPLAY_LAPGRAPHIC = "DISP_LAPGRPH";
+ public static final String PREF_KEY_REFERENCE_TIME_SELECTION = "REF_TIME_SEL";
+
+ int selectedId = 0;
+ int selectedMode = 0;
+ String title = "";
+ String message = "";
+ SelectReferenceViewModeDialog.SelectReferenceCallback callback = null;
+ Dialog myDialog = null;
+
+ public static SelectReferenceViewModeDialog newInstance(String title, String message, boolean viewMode, int referenceId, @NonNull SelectReferenceViewModeDialog.SelectReferenceCallback callback)
+ {
+ SelectReferenceViewModeDialog instance = new SelectReferenceViewModeDialog();
+ instance.prepare(callback, viewMode, referenceId, title, message);
+
+ // パラメータはBundleにまとめておく
+ Bundle arguments = new Bundle();
+ arguments.putString("title", title);
+ arguments.putString("message", message);
+ instance.setArguments(arguments);
+
+ return (instance);
+ }
+
+ /**
+ *
+ *
+ */
+ private void prepare(SelectReferenceViewModeDialog.SelectReferenceCallback callback, boolean viewMode, int referenceId, String title, String message)
+ {
+ this.callback = callback;
+ this.title = title;
+ this.message = message;
+ selectedMode = (viewMode) ? 1 : 0;
+ selectedId = referenceId;
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public @NonNull Dialog onCreateDialog(Bundle savedInstanceState)
+ {
+ String title = this.title;
+ String message = this.message;
+ if (savedInstanceState != null)
+ {
+ title = savedInstanceState.getString("title");
+ message = savedInstanceState.getString("message");
+ }
+ Activity activity = getActivity();
+ final AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity);
+ LayoutInflater inflater = activity.getLayoutInflater();
+ final View alertView = inflater.inflate(R.layout.select_reference_dialog, null, false);
+ alertDialog.setView(alertView);
+
+
+ final String[] viewObjects = activity.getResources().getStringArray(R.array.show_laptime_array);
+ final Spinner spinner0 = alertView.findViewById(R.id.show_laptime_mode);
+ ArrayAdapter<String> arrayAdapter0 = new ArrayAdapter<>(activity, android.R.layout.simple_list_item_1, viewObjects);
+ // selectedMode = 0;
+ try
+ {
+ spinner0.setAdapter(arrayAdapter0);
+ spinner0.setSelection(selectedMode);
+ spinner0.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+ Log.v(TAG, "onItemSelected : " + position + " (" + id + ")");
+ selectedMode = position;
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> parent) {
+ Log.v(TAG, "onNothingSelected");
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ final String[] objects = activity.getResources().getStringArray(R.array.reference_selection_array);
+ final Spinner spinner = alertView.findViewById(R.id.spinner_select_reference);
+ ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(activity, android.R.layout.simple_list_item_1, objects);
+ // selectedId = 0;
+ try
+ {
+ spinner.setAdapter(arrayAdapter);
+ spinner.setSelection(selectedId);
+ spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+ Log.v(TAG, "onItemSelected : " + position + " (" + id + ")");
+ selectedId = position;
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> parent) {
+ Log.v(TAG, "onNothingSelected");
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ alertDialog.setTitle(title);
+ alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
+ alertDialog.setCancelable(true);
+
+ String positiveLabel = activity.getString(R.string.dialog_positive_execute);
+ String negativeLabel = activity.getString(R.string.dialog_negative_cancel);
+
+ // ボタンを設定する(実行ボタン)
+ alertDialog.setPositiveButton(positiveLabel,
+ (dialog, which) -> {
+ Log.v(TAG, "ConfirmationDialog::OK " + selectedId + " " + selectedMode);
+ if (callback != null)
+ {
+ callback.selectedReferenceViewMode(selectedId, selectedMode);
+ }
+ dialog.dismiss();
+ });
+
+ // ボタンを設定する (キャンセルボタン)
+ alertDialog.setNegativeButton(negativeLabel,
+ (dialog, which) -> dialog.cancel());
+
+ myDialog = alertDialog.create();
+ return (myDialog);
+ }
+
+ @Override
+ public void onPause()
+ {
+ super.onPause();
+ Log.v(TAG, "AlertDialog::onPause()");
+ if (myDialog != null)
+ {
+ myDialog.cancel();
+ }
+ }
+
+ // コールバックインタフェース
+ public interface SelectReferenceCallback
+ {
+ void selectedReferenceViewMode(int referenceId, int viewMode); // OKを選択したとき
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.wear.widget.BoxInsetLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/list_drawer_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:nestedScrollingEnabled="true"
+ android:paddingStart="@dimen/list_start_padding"
+ android:paddingEnd="@dimen/list_end_padding"
+ >
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ >
+ <LinearLayout
+ android:id="@+id/layout_select_reference"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:padding="2dp"
+ >
+ <Spinner
+ android:id="@+id/show_laptime_mode"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/blank"
+ android:visibility="visible" />
+ <Spinner
+ android:id="@+id/spinner_select_reference"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/blank"
+ android:visibility="visible" />
+ </LinearLayout>
+ </ScrollView>
+</androidx.wear.widget.BoxInsetLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.wear.widget.BoxInsetLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/list_drawer_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:nestedScrollingEnabled="true"
+ android:paddingStart="@dimen/list_start_padding"
+ android:paddingEnd="@dimen/list_end_padding"
+ >
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ >
+ <LinearLayout
+ android:id="@+id/layout_select_reference"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:padding="2dp"
+ >
+ <Spinner
+ android:id="@+id/show_laptime_mode"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/blank"
+ android:visibility="visible" />
+ <Spinner
+ android:id="@+id/spinner_select_reference"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/blank"
+ android:visibility="visible" />
+ </LinearLayout>
+ </ScrollView>
+</androidx.wear.widget.BoxInsetLayout>
<item>B</item>
<item>C</item>
</string-array>
+ <string-array name="show_laptime_array">
+ <item>List</item>
+ <item>Graphic</item>
+ </string-array>
</resources>
<string name="time_picker_second_separator"> </string>
<string name="information_time_picker">LAPと総時間を入力</string>
<string name="information_modify_time">目標ラップタイムを設定</string>
+ <string name="select_reference_title">表示/基準 設定</string>
</resources>
\ No newline at end of file
<item>B</item>
<item>C</item>
</string-array>
+ <string-array name="show_laptime_array">
+ <item>List</item>
+ <item>Graphic</item>
+ </string-array>
</resources>
\ No newline at end of file
<string name="time_picker_second_separator"> </string>
<string name="information_time_picker">Set LAP and total Time</string>
<string name="information_modify_time">Set Target LAP Time</string>
+ <string name="select_reference_title">Set Mode/Ref.</string>
</resources>
<item>B</item>
<item>C</item>
</string-array>
+ <string-array name="show_laptime_array">
+ <item>List</item>
+ <item>Graphic</item>
+ </string-array>
</resources>
<string name="time_picker_second_separator"> </string>
<string name="information_time_picker">Set LAP and total Time</string>
<string name="information_modify_time">Set Target LAP Time</string>
+ <string name="select_reference_title">Set Mode/Ref.</string>
</resources>